27require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
39 public $element =
'propal_merge_pdf_product';
44 public $table_element =
'propal_merge_pdf_product';
59 public $fk_user_author;
78 public $lines = array();
99 public function create($user, $notrigger = 0)
101 global
$conf, $langs;
106 if (isset($this->fk_product)) {
107 $this->fk_product = (int) $this->fk_product;
109 if (isset($this->file_name)) {
110 $this->file_name = trim($this->file_name);
112 if (isset($this->fk_user_author)) {
113 $this->fk_user_author = (int) $this->fk_user_author;
115 if (isset($this->fk_user_mod)) {
116 $this->fk_user_mod = (int) $this->fk_user_mod;
118 if (isset($this->lang)) {
119 $this->lang = trim($this->lang);
121 if (isset($this->import_key)) {
122 $this->import_key = trim($this->import_key);
130 $sql =
"INSERT INTO ".$this->db->prefix().
"propal_merge_pdf_product(";
131 $sql .=
"fk_product,";
132 $sql .=
"file_name,";
136 $sql .=
"fk_user_author,";
137 $sql .=
"fk_user_mod,";
139 $sql .=
") VALUES (";
140 $sql .=
" ".(!isset($this->fk_product) ?
'NULL' : ((int) $this->fk_product)).
",";
141 $sql .=
" ".(!isset($this->file_name) ?
'NULL' :
"'".$this->db->escape($this->file_name).
"'").
",";
143 $sql .=
" ".(!isset($this->lang) ?
'NULL' :
"'".$this->db->escape($this->lang).
"'").
",";
145 $sql .=
" ".((int) $user->id).
",";
146 $sql .=
" ".((int) $user->id).
",";
147 $sql .=
" '".$this->db->idate(
dol_now()).
"'";
152 $resql = $this->db->query($sql);
155 $this->errors[] =
"Error ".$this->db->lasterror();
159 $this->
id = $this->db->last_insert_id($this->db->prefix().
"propal_merge_pdf_product");
164 foreach ($this->errors as $errmsg) {
165 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
166 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
168 $this->db->rollback();
185 global $langs,
$conf;
190 $sql .=
" t.fk_product,";
191 $sql .=
" t.file_name,";
193 $sql .=
" t.fk_user_author,";
194 $sql .=
" t.fk_user_mod,";
197 $sql .=
" t.import_key";
200 $sql .=
" FROM ".$this->db->prefix().
"propal_merge_pdf_product as t";
201 $sql .=
" WHERE t.rowid = ".((int) $id);
204 $resql = $this->db->query($sql);
206 if ($this->db->num_rows($resql)) {
207 $obj = $this->db->fetch_object($resql);
209 $this->
id = $obj->rowid;
211 $this->fk_product = $obj->fk_product;
212 $this->file_name = $obj->file_name;
214 $this->lang = $obj->lang;
216 $this->fk_user_author = $obj->fk_user_author;
217 $this->fk_user_mod = $obj->fk_user_mod;
218 $this->datec = $this->db->jdate($obj->datec);
219 $this->tms = $this->db->jdate($obj->tms);
220 $this->import_key = $obj->import_key;
222 $this->db->free($resql);
226 $this->error =
"Error ".$this->db->lasterror();
227 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
243 global $langs,
$conf;
248 $sql .=
" t.fk_product,";
249 $sql .=
" t.file_name,";
251 $sql .=
" t.fk_user_author,";
252 $sql .=
" t.fk_user_mod,";
255 $sql .=
" t.import_key";
258 $sql .=
" FROM ".$this->db->prefix().
"propal_merge_pdf_product as t";
259 $sql .=
" WHERE t.fk_product = ".((int) $product_id);
261 $sql .=
" AND t.lang = '".$this->db->escape($lang).
"'";
265 $resql = $this->db->query($sql);
267 if ($this->db->num_rows($resql)) {
268 while ($obj = $this->db->fetch_object($resql)) {
271 $line->id = $obj->rowid;
273 $line->fk_product = $obj->fk_product;
274 $line->file_name = $obj->file_name;
276 $line->lang = $obj->lang;
278 $line->fk_user_author = $obj->fk_user_author;
279 $line->fk_user_mod = $obj->fk_user_mod;
280 $line->datec = $this->db->jdate($obj->datec);
281 $line->tms = $this->db->jdate($obj->tms);
282 $line->import_key = $obj->import_key;
286 $this->lines[$obj->file_name.
'_'.$obj->lang] = $line;
288 $this->lines[$obj->file_name] = $line;
292 $this->db->free($resql);
296 $this->error =
"Error ".$this->db->lasterror();
297 dol_syslog(get_class($this).
"::fetch_by_product ".$this->error, LOG_ERR);
312 global
$conf, $langs;
317 if (isset($this->fk_product)) {
318 $this->fk_product = (int) $this->fk_product;
320 if (isset($this->file_name)) {
321 $this->file_name = trim($this->file_name);
323 if (isset($this->fk_user_mod)) {
324 $this->fk_user_mod = (int) $this->fk_user_mod;
326 if (isset($this->lang)) {
327 $this->lang = trim($this->lang);
334 $sql =
"UPDATE ".$this->db->prefix().
"propal_merge_pdf_product SET";
336 $sql .=
" fk_product = ".(isset($this->fk_product) ? ((int) $this->fk_product) :
"null").
",";
337 $sql .=
" file_name = ".(isset($this->file_name) ?
"'".$this->db->escape($this->file_name).
"'" :
"null").
",";
339 $sql .=
" lang = ".(isset($this->lang) ?
"'".$this->db->escape($this->lang).
"'" :
"null").
",";
341 $sql .=
" fk_user_mod = ".((int) $user->id);
344 $sql .=
" WHERE rowid = ".((int) $this->
id);
349 $resql = $this->db->query($sql);
352 $this->errors[] =
"Error ".$this->db->lasterror();
357 foreach ($this->errors as $errmsg) {
358 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
359 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
361 $this->db->rollback();
377 public function delete($user, $notrigger = 0)
379 global
$conf, $langs;
384 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
385 $sql .=
" WHERE rowid=".((int) $this->
id);
388 $resql = $this->db->query($sql);
391 $this->errors[] =
"Error ".$this->db->lasterror();
396 foreach ($this->errors as $errmsg) {
397 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
398 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
400 $this->db->rollback();
421 global
$conf, $langs;
426 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
427 $sql .=
" WHERE fk_product = ".((int) $product_id);
430 $sql .=
" AND lang = '".$this->db->escape($lang_id).
"'";
434 $resql = $this->db->query($sql);
437 $this->errors[] =
"Error ".$this->db->lasterror();
442 foreach ($this->errors as $errmsg) {
443 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
444 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
446 $this->db->rollback();
464 global
$conf, $langs;
469 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
470 $sql .=
" WHERE fk_product = ".((int) $this->fk_product).
" AND file_name = '".$this->db->escape($this->file_name).
"'";
473 $resql = $this->db->query($sql);
476 $this->errors[] =
"Error ".$this->db->lasterror();
481 foreach ($this->errors as $errmsg) {
482 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
483 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
485 $this->db->rollback();
519 $object->context[
'createfromclone'] =
'createfromclone';
520 $result =
$object->create($user);
525 $this->errors = array_merge($this->errors,
$object->errors);
532 unset(
$object->context[
'createfromclone']);
539 $this->db->rollback();
555 $this->fk_product = 0;
556 $this->file_name =
'';
557 $this->fk_user_author = 0;
558 $this->fk_user_mod = 0;
561 $this->import_key =
'';
595 public $fk_user_author;
if(! $sortfield) if(! $sortorder) $object
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Put here description of your class.
create($user, $notrigger=0)
Create object into database.
fetch_by_product($product_id, $lang='')
Load object in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetch($id)
Load object in memory from the database.
update(User $user, $notrigger=0)
Update object into database.
__construct($db)
Constructor.
delete_by_file($user)
Delete object in database.
delete_by_product($user, $product_id, $lang_id='', $notrigger=0)
Delete object in database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
Class to manage propal merge of product line.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.