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) ? $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;
385 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
386 $sql .=
" WHERE rowid=".((int) $this->
id);
389 $resql = $this->db->query($sql);
392 $this->errors[] =
"Error ".$this->db->lasterror();
398 foreach ($this->errors as $errmsg) {
399 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
400 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
402 $this->db->rollback();
423 global
$conf, $langs;
429 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
430 $sql .=
" WHERE fk_product = ".((int) $product_id);
433 $sql .=
" AND lang = '".$this->db->escape($lang_id).
"'";
437 $resql = $this->db->query($sql);
440 $this->errors[] =
"Error ".$this->db->lasterror();
446 foreach ($this->errors as $errmsg) {
447 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
448 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
450 $this->db->rollback();
468 global
$conf, $langs;
474 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
475 $sql .=
" WHERE fk_product = ".((int) $this->fk_product).
" AND file_name = '".$this->db->escape($this->file_name).
"'";
478 $resql = $this->db->query($sql);
481 $this->errors[] =
"Error ".$this->db->lasterror();
487 foreach ($this->errors as $errmsg) {
488 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
489 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
491 $this->db->rollback();
525 $object->context[
'createfromclone'] =
'createfromclone';
526 $result =
$object->create($user);
531 $this->errors = array_merge($this->errors,
$object->errors);
538 unset(
$object->context[
'createfromclone']);
545 $this->db->rollback();
561 $this->fk_product = 0;
562 $this->file_name =
'';
563 $this->fk_user_author = 0;
564 $this->fk_user_mod = 0;
567 $this->import_key =
'';
601 public $fk_user_author;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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='auto')
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...