26require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
38 public $element =
'propal_merge_pdf_product';
43 public $table_element =
'propal_merge_pdf_product';
58 public $fk_user_author;
74 public $lines = array();
95 public function create($user, $notrigger = 0)
102 if (isset($this->fk_product)) {
103 $this->fk_product = (int) $this->fk_product;
105 if (isset($this->file_name)) {
106 $this->file_name = trim($this->file_name);
108 if (isset($this->fk_user_author)) {
109 $this->fk_user_author = (int) $this->fk_user_author;
111 if (isset($this->fk_user_mod)) {
112 $this->fk_user_mod = (int) $this->fk_user_mod;
114 if (isset($this->lang)) {
115 $this->lang = trim($this->lang);
117 if (isset($this->import_key)) {
118 $this->import_key = trim($this->import_key);
126 $sql =
"INSERT INTO ".$this->db->prefix().
"propal_merge_pdf_product(";
127 $sql .=
"fk_product,";
128 $sql .=
"file_name,";
132 $sql .=
"fk_user_author,";
133 $sql .=
"fk_user_mod,";
135 $sql .=
") VALUES (";
136 $sql .=
" ".(!isset($this->fk_product) ?
'NULL' : ((int) $this->fk_product)).
",";
137 $sql .=
" ".(!isset($this->file_name) ?
'NULL' :
"'".$this->db->escape($this->file_name).
"'").
",";
139 $sql .=
" ".(!isset($this->lang) ?
'NULL' :
"'".$this->db->escape($this->lang).
"'").
",";
141 $sql .=
" ".((int) $user->id).
",";
142 $sql .=
" ".((int) $user->id).
",";
143 $sql .=
" '".$this->db->idate(
dol_now()).
"'";
148 $resql = $this->db->query($sql);
151 $this->errors[] =
"Error ".$this->db->lasterror();
155 $this->
id = $this->db->last_insert_id($this->db->prefix().
"propal_merge_pdf_product");
160 foreach ($this->errors as $errmsg) {
161 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
162 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
164 $this->db->rollback();
181 global $langs, $conf;
186 $sql .=
" t.fk_product,";
187 $sql .=
" t.file_name,";
189 $sql .=
" t.fk_user_author,";
190 $sql .=
" t.fk_user_mod,";
193 $sql .=
" t.import_key";
196 $sql .=
" FROM ".$this->db->prefix().
"propal_merge_pdf_product as t";
197 $sql .=
" WHERE t.rowid = ".((int) $id);
200 $resql = $this->db->query($sql);
202 if ($this->db->num_rows($resql)) {
203 $obj = $this->db->fetch_object($resql);
205 $this->
id = $obj->rowid;
207 $this->fk_product = $obj->fk_product;
208 $this->file_name = $obj->file_name;
210 $this->lang = $obj->lang;
212 $this->fk_user_author = $obj->fk_user_author;
213 $this->fk_user_mod = $obj->fk_user_mod;
214 $this->datec = $this->db->jdate($obj->datec);
215 $this->tms = $this->db->jdate($obj->tms);
216 $this->import_key = $obj->import_key;
218 $this->db->free($resql);
222 $this->error =
"Error ".$this->db->lasterror();
223 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
239 global $langs, $conf;
244 $sql .=
" t.fk_product,";
245 $sql .=
" t.file_name,";
247 $sql .=
" t.fk_user_author,";
248 $sql .=
" t.fk_user_mod,";
251 $sql .=
" t.import_key";
254 $sql .=
" FROM ".$this->db->prefix().
"propal_merge_pdf_product as t";
255 $sql .=
" WHERE t.fk_product = ".((int) $product_id);
257 $sql .=
" AND t.lang = '".$this->db->escape($lang).
"'";
261 $resql = $this->db->query($sql);
263 if ($this->db->num_rows($resql)) {
264 while ($obj = $this->db->fetch_object($resql)) {
267 $line->id = $obj->rowid;
269 $line->fk_product = $obj->fk_product;
270 $line->file_name = $obj->file_name;
272 $line->lang = $obj->lang;
274 $line->fk_user_author = $obj->fk_user_author;
275 $line->fk_user_mod = $obj->fk_user_mod;
276 $line->datec = $this->db->jdate($obj->datec);
277 $line->tms = $this->db->jdate($obj->tms);
278 $line->import_key = $obj->import_key;
282 $this->lines[$obj->file_name.
'_'.$obj->lang] = $line;
284 $this->lines[$obj->file_name] = $line;
288 $this->db->free($resql);
292 $this->error =
"Error ".$this->db->lasterror();
293 dol_syslog(get_class($this).
"::fetch_by_product ".$this->error, LOG_ERR);
308 global $conf, $langs;
313 if (isset($this->fk_product)) {
314 $this->fk_product = (int) $this->fk_product;
316 if (isset($this->file_name)) {
317 $this->file_name = trim($this->file_name);
319 if (isset($this->fk_user_mod)) {
320 $this->fk_user_mod = (int) $this->fk_user_mod;
322 if (isset($this->lang)) {
323 $this->lang = trim($this->lang);
330 $sql =
"UPDATE ".$this->db->prefix().
"propal_merge_pdf_product SET";
332 $sql .=
" fk_product = ".(isset($this->fk_product) ? $this->fk_product :
"null").
",";
333 $sql .=
" file_name = ".(isset($this->file_name) ?
"'".$this->db->escape($this->file_name).
"'" :
"null").
",";
335 $sql .=
" lang = ".(isset($this->lang) ?
"'".$this->db->escape($this->lang).
"'" :
"null").
",";
337 $sql .=
" fk_user_mod = ".((int) $user->id);
340 $sql .=
" WHERE rowid = ".((int) $this->
id);
345 $resql = $this->db->query($sql);
348 $this->errors[] =
"Error ".$this->db->lasterror();
353 foreach ($this->errors as $errmsg) {
354 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
355 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
357 $this->db->rollback();
373 public function delete($user, $notrigger = 0)
375 global $conf, $langs;
381 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
382 $sql .=
" WHERE rowid=".((int) $this->
id);
385 $resql = $this->db->query($sql);
388 $this->errors[] =
"Error ".$this->db->lasterror();
394 foreach ($this->errors as $errmsg) {
395 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
396 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
398 $this->db->rollback();
419 global $conf, $langs;
425 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
426 $sql .=
" WHERE fk_product = ".((int) $product_id);
429 $sql .=
" AND lang = '".$this->db->escape($lang_id).
"'";
433 $resql = $this->db->query($sql);
436 $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;
470 $sql =
"DELETE FROM ".$this->db->prefix().
"propal_merge_pdf_product";
471 $sql .=
" WHERE fk_product = ".((int) $this->fk_product).
" AND file_name = '".$this->db->escape($this->file_name).
"'";
474 $resql = $this->db->query($sql);
477 $this->errors[] =
"Error ".$this->db->lasterror();
483 foreach ($this->errors as $errmsg) {
484 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
485 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
487 $this->db->rollback();
521 $object->context[
'createfromclone'] =
'createfromclone';
522 $result =
$object->create($user);
527 $this->errors = array_merge($this->errors,
$object->errors);
534 unset(
$object->context[
'createfromclone']);
541 $this->db->rollback();
557 $this->fk_product = 0;
558 $this->file_name =
'';
559 $this->fk_user_author = 0;
560 $this->fk_user_mod = 0;
563 $this->import_key =
'';
597 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.