25 require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
37 public $element =
'propal_merge_pdf_product';
42 public $table_element =
'propal_merge_pdf_product';
46 public $fk_user_author;
52 public $lines = array();
75 public function create($user, $notrigger = 0)
82 if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
83 if (isset($this->file_name)) $this->file_name = trim($this->file_name);
84 if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author);
85 if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
86 if (isset($this->lang)) $this->lang = trim($this->lang);
87 if (isset($this->import_key)) $this->import_key = trim($this->import_key);
95 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"propal_merge_pdf_product(";
97 $sql .=
"fk_product,";
99 if ($conf->global->MAIN_MULTILANGS) {
102 $sql .=
"fk_user_author,";
103 $sql .=
"fk_user_mod,";
107 $sql .=
") VALUES (";
109 $sql .=
" ".(!isset($this->fk_product) ?
'NULL' :
"'".$this->db->escape($this->fk_product).
"'").
",";
110 $sql .=
" ".(!isset($this->file_name) ?
'NULL' :
"'".$this->db->escape($this->file_name).
"'").
",";
111 if ($conf->global->MAIN_MULTILANGS) {
112 $sql .=
" ".(!isset($this->lang) ?
'NULL' :
"'".$this->db->escape($this->lang).
"'").
",";
114 $sql .=
" ".$user->id.
",";
115 $sql .=
" ".$user->id.
",";
116 $sql .=
" '".$this->db->idate(
dol_now()).
"'";
125 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
129 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"propal_merge_pdf_product");
135 foreach ($this->errors as $errmsg)
137 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
138 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
140 $this->
db->rollback();
157 global $langs, $conf;
162 $sql .=
" t.fk_product,";
163 $sql .=
" t.file_name,";
165 $sql .=
" t.fk_user_author,";
166 $sql .=
" t.fk_user_mod,";
169 $sql .=
" t.import_key";
172 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal_merge_pdf_product as t";
173 $sql .=
" WHERE t.rowid = ".$id;
181 $obj = $this->
db->fetch_object(
$resql);
183 $this->
id = $obj->rowid;
185 $this->fk_product = $obj->fk_product;
186 $this->file_name = $obj->file_name;
187 if ($conf->global->MAIN_MULTILANGS) {
188 $this->lang = $obj->lang;
190 $this->fk_user_author = $obj->fk_user_author;
191 $this->fk_user_mod = $obj->fk_user_mod;
192 $this->datec = $this->
db->jdate($obj->datec);
193 $this->tms = $this->
db->jdate($obj->tms);
194 $this->import_key = $obj->import_key;
200 $this->error =
"Error ".$this->db->lasterror();
201 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
217 global $langs, $conf;
222 $sql .=
" t.fk_product,";
223 $sql .=
" t.file_name,";
225 $sql .=
" t.fk_user_author,";
226 $sql .=
" t.fk_user_mod,";
229 $sql .=
" t.import_key";
232 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal_merge_pdf_product as t";
233 $sql .=
" WHERE t.fk_product = ".$product_id;
234 if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
235 $sql .=
" AND t.lang = '".$this->db->escape($lang).
"'";
244 while ($obj = $this->
db->fetch_object(
$resql)) {
247 $line->id = $obj->rowid;
249 $line->fk_product = $obj->fk_product;
250 $line->file_name = $obj->file_name;
251 if ($conf->global->MAIN_MULTILANGS) {
252 $line->lang = $obj->lang;
254 $line->fk_user_author = $obj->fk_user_author;
255 $line->fk_user_mod = $obj->fk_user_mod;
256 $line->datec = $this->
db->jdate($obj->datec);
257 $line->tms = $this->
db->jdate($obj->tms);
258 $line->import_key = $obj->import_key;
261 if ($conf->global->MAIN_MULTILANGS) {
262 $this->lines[$obj->file_name.
'_'.$obj->lang] = $line;
264 $this->lines[$obj->file_name] = $line;
272 $this->error =
"Error ".$this->db->lasterror();
273 dol_syslog(get_class($this).
"::fetch_by_product ".$this->error, LOG_ERR);
286 public function update($user = 0, $notrigger = 0)
288 global $conf, $langs;
293 if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product);
294 if (isset($this->file_name)) $this->file_name = trim($this->file_name);
295 if (isset($this->fk_user_mod)) $this->fk_user_mod = trim($this->fk_user_mod);
296 if (isset($this->lang)) $this->lang = trim($this->lang);
302 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal_merge_pdf_product SET";
304 $sql .=
" fk_product=".(isset($this->fk_product) ? $this->fk_product :
"null").
",";
305 $sql .=
" file_name=".(isset($this->file_name) ?
"'".$this->db->escape($this->file_name).
"'" :
"null").
",";
306 if ($conf->global->MAIN_MULTILANGS) {
307 $sql .=
" lang=".(isset($this->lang) ?
"'".$this->db->escape($this->lang).
"'" :
"null").
",";
309 $sql .=
" fk_user_mod=".$user->id;
312 $sql .=
" WHERE rowid=".$this->id;
318 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
323 foreach ($this->errors as $errmsg)
325 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
326 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
328 $this->
db->rollback();
344 public function delete($user, $notrigger = 0)
346 global $conf, $langs;
353 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"propal_merge_pdf_product";
354 $sql .=
" WHERE rowid=".$this->id;
358 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
364 foreach ($this->errors as $errmsg)
366 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
367 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
369 $this->
db->rollback();
390 global $conf, $langs;
397 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"propal_merge_pdf_product";
398 $sql .=
" WHERE fk_product=".$product_id;
400 if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) {
401 $sql .=
" AND lang='".$this->db->escape($lang_id).
"'";
406 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
412 foreach ($this->errors as $errmsg)
414 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
415 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
417 $this->
db->rollback();
435 global $conf, $langs;
442 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"propal_merge_pdf_product";
443 $sql .=
" WHERE fk_product=".$this->fk_product.
" AND file_name='".$this->
db->escape($this->file_name).
"'";
447 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
453 foreach ($this->errors as $errmsg)
455 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
456 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
458 $this->
db->rollback();
484 $object->fetch($fromid);
492 $object->context[
'createfromclone'] =
'createfromclone';
493 $result = $object->create($user);
498 $this->error = $object->error;
499 $this->errors = array_merge($this->errors, $object->errors);
507 unset($object->context[
'createfromclone']);
515 $this->
db->rollback();
531 $this->fk_product =
'';
532 $this->file_name =
'';
533 $this->fk_user_author =
'';
534 $this->fk_user_mod =
'';
537 $this->import_key =
'';
562 public $fk_user_author;
fetch($id)
Load object in memory from the database.
Put here description of your class.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct($db)
Constructor.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
$conf db
API class for accounts.
update($user=0, $notrigger=0)
Update object into database.
Class to manage propal merge of product line.
fetch_by_product($product_id, $lang= '')
Load object in memory from the database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
delete_by_file($user)
Delete object in database.
delete_by_product($user, $product_id, $lang_id= '', $notrigger=0)
Delete object in database.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
create($user, $notrigger=0)
Create object into database.
__construct()
Constructor.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)