24 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
34 public $element =
'product_customer_price';
39 public $table_element =
'product_customer_price';
62 public $price_min_ttc;
63 public $price_base_type;
65 public $recuperableonly;
66 public $localtax1_type;
68 public $localtax2_type;
76 public $lines = array();
97 public function create($user, $notrigger = 0, $forceupdateaffiliate = 0)
100 global $conf, $langs;
105 if (isset($this->entity))
106 $this->entity = trim($this->entity);
107 if (isset($this->fk_product))
108 $this->fk_product = trim($this->fk_product);
109 if (isset($this->fk_soc))
110 $this->fk_soc = trim($this->fk_soc);
111 if (isset($this->
price))
113 if (isset($this->price_ttc))
114 $this->price_ttc = trim($this->price_ttc);
115 if (isset($this->price_min))
116 $this->price_min = trim($this->price_min);
117 if (isset($this->price_min_ttc))
118 $this->price_min_ttc = trim($this->price_min_ttc);
119 if (isset($this->price_base_type))
120 $this->price_base_type = trim($this->price_base_type);
121 if (isset($this->tva_tx))
122 $this->tva_tx = trim($this->tva_tx);
123 if (isset($this->recuperableonly))
124 $this->recuperableonly = trim($this->recuperableonly);
125 if (isset($this->localtax1_tx))
126 $this->localtax1_tx = trim($this->localtax1_tx);
127 if (isset($this->localtax2_tx))
128 $this->localtax2_tx = trim($this->localtax2_tx);
129 if (isset($this->fk_user))
130 $this->fk_user = trim($this->fk_user);
131 if (isset($this->import_key))
132 $this->import_key = trim($this->import_key);
137 if ($this->
price !=
'' || $this->
price == 0) {
138 if ($this->price_base_type ==
'TTC') {
143 if ($this->price_min !=
'' || $this->price_min == 0) {
144 $this->price_min_ttc =
price2num($this->price_min,
'MU');
145 $this->price_min =
price2num($this->price_min) / (1 + ($this->tva_tx / 100));
146 $this->price_min =
price2num($this->price_min,
'MU');
148 $this->price_min = 0;
149 $this->price_min_ttc = 0;
153 $this->price_ttc = ($this->recuperableonly != 1) ?
price2num($this->
price) * (1 + ($this->tva_tx / 100)) : $this->price;
154 $this->price_ttc =
price2num($this->price_ttc,
'MU');
156 if ($this->price_min !=
'' || $this->price_min == 0) {
157 $this->price_min =
price2num($this->price_min,
'MU');
158 $this->price_min_ttc =
price2num($this->price_min) * (1 + ($this->tva_tx / 100));
159 $this->price_min_ttc =
price2num($this->price_min_ttc,
'MU');
162 $this->price_min = 0;
163 $this->price_min_ttc = 0;
169 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_customer_price(";
172 $sql .=
"fk_product,";
175 $sql .=
"price_ttc,";
176 $sql .=
"price_min,";
177 $sql .=
"price_min_ttc,";
178 $sql .=
"price_base_type,";
179 $sql .=
"default_vat_code,";
181 $sql .=
"recuperableonly,";
182 $sql .=
"localtax1_type,";
183 $sql .=
"localtax1_tx,";
184 $sql .=
"localtax2_type,";
185 $sql .=
"localtax2_tx,";
187 $sql .=
"import_key";
188 $sql .=
") VALUES (";
189 $sql .=
" ".$conf->entity.
",";
190 $sql .=
" '".$this->db->idate(
dol_now()).
"',";
191 $sql .=
" ".(!isset($this->fk_product) ?
'NULL' :
"'".$this->db->escape($this->fk_product).
"'").
",";
192 $sql .=
" ".(!isset($this->fk_soc) ?
'NULL' :
"'".$this->db->escape($this->fk_soc).
"'").
",";
193 $sql .=
" ".(empty($this->
price) ?
'0' :
"'".$this->db->escape($this->
price).
"'").
",";
194 $sql .=
" ".(empty($this->price_ttc) ?
'0' :
"'".$this->db->escape($this->price_ttc).
"'").
",";
195 $sql .=
" ".(empty($this->price_min) ?
'0' :
"'".$this->db->escape($this->price_min).
"'").
",";
196 $sql .=
" ".(empty($this->price_min_ttc) ?
'0' :
"'".$this->db->escape($this->price_min_ttc).
"'").
",";
197 $sql .=
" ".(!isset($this->price_base_type) ?
'NULL' :
"'".$this->db->escape($this->price_base_type).
"'").
",";
198 $sql .=
" ".($this->default_vat_code ?
"'".$this->db->escape($this->default_vat_code).
"'" :
"null").
",";
199 $sql .=
" ".(!isset($this->tva_tx) ?
'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).
",";
200 $sql .=
" ".(!isset($this->recuperableonly) ?
'NULL' :
"'".$this->db->escape($this->recuperableonly).
"'").
",";
201 $sql .=
" ".(empty($this->localtax1_type) ?
"'0'" :
"'".$this->db->escape($this->localtax1_type).
"'").
",";
202 $sql .=
" ".(!isset($this->localtax1_tx) ?
'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).
",";
203 $sql .=
" ".(empty($this->localtax2_type) ?
"'0'" :
"'".$this->db->escape($this->localtax2_type).
"'").
",";
204 $sql .=
" ".(!isset($this->localtax2_tx) ?
'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).
",";
205 $sql .=
" ".$user->id.
",";
206 $sql .=
" ".(!isset($this->import_key) ?
'NULL' :
"'".$this->db->escape($this->import_key).
"'").
"";
211 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
215 $this->errors [] =
"Error ".$this->db->lasterror();
219 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"product_customer_price");
222 $result = $this->
call_trigger(
'PRODUCT_CUSTOMER_PRICE_CREATE', $user);
238 foreach ($this->errors as $errmsg) {
239 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
240 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
242 $this->
db->rollback();
262 $sql .=
" t.entity,";
265 $sql .=
" t.fk_product,";
266 $sql .=
" t.fk_soc,";
268 $sql .=
" t.price_ttc,";
269 $sql .=
" t.price_min,";
270 $sql .=
" t.price_min_ttc,";
271 $sql .=
" t.price_base_type,";
272 $sql .=
" t.default_vat_code,";
273 $sql .=
" t.tva_tx,";
274 $sql .=
" t.recuperableonly,";
275 $sql .=
" t.localtax1_tx,";
276 $sql .=
" t.localtax2_tx,";
277 $sql .=
" t.fk_user,";
278 $sql .=
" t.import_key";
280 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price as t";
281 $sql .=
" WHERE t.rowid = ".$id;
283 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
287 $obj = $this->
db->fetch_object(
$resql);
289 $this->
id = $obj->rowid;
291 $this->entity = $obj->entity;
292 $this->datec = $this->
db->jdate($obj->datec);
293 $this->tms = $this->
db->jdate($obj->tms);
294 $this->fk_product = $obj->fk_product;
295 $this->fk_soc = $obj->fk_soc;
296 $this->
price = $obj->price;
297 $this->price_ttc = $obj->price_ttc;
298 $this->price_min = $obj->price_min;
299 $this->price_min_ttc = $obj->price_min_ttc;
300 $this->price_base_type = $obj->price_base_type;
301 $this->default_vat_code = $obj->default_vat_code;
302 $this->tva_tx = $obj->tva_tx;
303 $this->recuperableonly = $obj->recuperableonly;
304 $this->localtax1_tx = $obj->localtax1_tx;
305 $this->localtax2_tx = $obj->localtax2_tx;
306 $this->fk_user = $obj->fk_user;
307 $this->import_key = $obj->import_key;
313 $this->error =
"Error ".$this->db->lasterror();
329 public function fetch_all($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter = array())
334 if (empty($sortfield)) $sortfield =
"t.rowid";
335 if (empty($sortorder)) $sortorder =
"DESC";
339 $sql .=
" t.entity,";
342 $sql .=
" t.fk_product,";
343 $sql .=
" t.fk_soc,";
345 $sql .=
" t.price_ttc,";
346 $sql .=
" t.price_min,";
347 $sql .=
" t.price_min_ttc,";
348 $sql .=
" t.price_base_type,";
349 $sql .=
" t.default_vat_code,";
350 $sql .=
" t.tva_tx,";
351 $sql .=
" t.recuperableonly,";
352 $sql .=
" t.localtax1_tx,";
353 $sql .=
" t.localtax2_tx,";
354 $sql .=
" t.localtax1_type,";
355 $sql .=
" t.localtax2_type,";
356 $sql .=
" t.fk_user,";
357 $sql .=
" t.import_key,";
358 $sql .=
" soc.nom as socname,";
359 $sql .=
" prod.ref as prodref";
360 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price as t ";
361 $sql .=
" ,".MAIN_DB_PREFIX.
"product as prod ";
362 $sql .=
" ,".MAIN_DB_PREFIX.
"societe as soc ";
363 $sql .=
" WHERE soc.rowid=t.fk_soc ";
364 $sql .=
" AND prod.rowid=t.fk_product ";
365 $sql .=
" AND prod.entity IN (".getEntity(
'product').
")";
366 $sql .=
" AND t.entity IN (".getEntity(
'productprice').
")";
369 if (count($filter) > 0) {
370 foreach ($filter as $key => $value) {
371 if (strpos($key,
'date')) {
372 $sql .=
' AND '.$key.
' = \''.$this->
db->escape($value).
'\'';
373 } elseif ($key ==
'soc.nom') {
374 $sql .=
' AND '.$key.
' LIKE \'%'.$this->
db->escape($value).
'%\'';
375 } elseif ($key ==
'prod.ref' || $key ==
'prod.label') {
376 $sql .=
' AND '.$key.
' LIKE \'%'.$this->
db->escape($value).
'%\'';
377 } elseif ($key ==
't.price' || $key ==
't.price_ttc') {
378 $sql .=
' AND '.$key.
' LIKE \'%'.
price2num($value).
'%\'';
380 $sql .=
' AND '.$key.
' = '.((int) $value);
384 $sql .= $this->
db->order($sortfield, $sortorder);
385 if (!empty($limit)) $sql .=
' '.$this->db->plimit($limit + 1, $offset);
387 dol_syslog(get_class($this).
"::fetch_all", LOG_DEBUG);
390 $this->lines = array();
393 while ($obj = $this->
db->fetch_object(
$resql)) {
396 $line->id = $obj->rowid;
398 $line->entity = $obj->entity;
399 $line->datec = $this->
db->jdate($obj->datec);
400 $line->tms = $this->
db->jdate($obj->tms);
401 $line->fk_product = $obj->fk_product;
402 $line->fk_soc = $obj->fk_soc;
403 $line->price = $obj->price;
404 $line->price_ttc = $obj->price_ttc;
405 $line->price_min = $obj->price_min;
406 $line->price_min_ttc = $obj->price_min_ttc;
407 $line->price_base_type = $obj->price_base_type;
408 $line->default_vat_code = $obj->default_vat_code;
409 $line->tva_tx = $obj->tva_tx;
410 $line->recuperableonly = $obj->recuperableonly;
411 $line->localtax1_tx = $obj->localtax1_tx;
412 $line->localtax2_tx = $obj->localtax2_tx;
413 $line->localtax1_type = $obj->localtax1_type;
414 $line->localtax2_type = $obj->localtax2_type;
415 $line->fk_user = $obj->fk_user;
416 $line->import_key = $obj->import_key;
417 $line->socname = $obj->socname;
418 $line->prodref = $obj->prodref;
420 $this->lines [] = $line;
426 $this->error =
"Error ".$this->db->lasterror();
442 public function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array())
447 if (!empty($sortfield)) $sortfield =
"t.rowid";
448 if (!empty($sortorder)) $sortorder =
"DESC";
453 $sql .=
" t.entity,";
455 $sql .=
" t.fk_product,";
456 $sql .=
" t.fk_soc,";
458 $sql .=
" t.price_ttc,";
459 $sql .=
" t.price_min,";
460 $sql .=
" t.price_min_ttc,";
461 $sql .=
" t.price_base_type,";
462 $sql .=
" t.default_vat_code,";
463 $sql .=
" t.tva_tx,";
464 $sql .=
" t.recuperableonly,";
465 $sql .=
" t.localtax1_tx,";
466 $sql .=
" t.localtax2_tx,";
467 $sql .=
" t.fk_user,";
468 $sql .=
" t.import_key,";
469 $sql .=
" soc.nom as socname,";
470 $sql .=
" prod.ref as prodref";
471 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_log as t ";
472 $sql .=
" ,".MAIN_DB_PREFIX.
"product as prod ";
473 $sql .=
" ,".MAIN_DB_PREFIX.
"societe as soc ";
474 $sql .=
" WHERE soc.rowid=t.fk_soc ";
475 $sql .=
" AND prod.rowid=t.fk_product ";
476 $sql .=
" AND prod.entity IN (".getEntity(
'product').
")";
477 $sql .=
" AND t.entity IN (".getEntity(
'productprice').
")";
480 if (count($filter) > 0) {
481 foreach ($filter as $key => $value) {
482 if (strpos($key,
'date'))
484 $sql .=
' AND '.$key.
' = \''.$value.
'\'';
485 } elseif ($key ==
'soc.nom') {
486 $sql .=
' AND '.$key.
' LIKE \'%'.$value.
'%\'';
488 $sql .=
' AND '.$key.
' = '.$value;
493 $sql .= $this->
db->order($sortfield, $sortorder);
494 if (!empty($limit)) $sql .=
' '.$this->db->plimit($limit + 1, $offset);
496 dol_syslog(get_class($this).
"::fetch_all_log", LOG_DEBUG);
499 $this->lines = array();
502 while ($obj = $this->
db->fetch_object(
$resql)) {
505 $line->id = $obj->rowid;
507 $line->entity = $obj->entity;
508 $line->datec = $this->
db->jdate($obj->datec);
509 $line->tms = $this->
db->jdate($obj->tms);
510 $line->fk_product = $obj->fk_product;
511 $line->fk_soc = $obj->fk_soc;
512 $line->price = $obj->price;
513 $line->price_ttc = $obj->price_ttc;
514 $line->price_min = $obj->price_min;
515 $line->price_min_ttc = $obj->price_min_ttc;
516 $line->price_base_type = $obj->price_base_type;
517 $line->default_vat_code = $obj->default_vat_code;
518 $line->tva_tx = $obj->tva_tx;
519 $line->recuperableonly = $obj->recuperableonly;
520 $line->localtax1_tx = $obj->localtax1_tx;
521 $line->localtax2_tx = $obj->localtax2_tx;
522 $line->fk_user = $obj->fk_user;
523 $line->import_key = $obj->import_key;
524 $line->socname = $obj->socname;
525 $line->prodref = $obj->prodref;
527 $this->lines [] = $line;
533 $this->error =
"Error ".$this->db->lasterror();
546 public function update($user = 0, $notrigger = 0, $forceupdateaffiliate = 0)
549 global $conf, $langs;
554 if (isset($this->entity))
555 $this->entity = trim($this->entity);
556 if (isset($this->fk_product))
557 $this->fk_product = trim($this->fk_product);
558 if (isset($this->fk_soc))
559 $this->fk_soc = trim($this->fk_soc);
560 if (isset($this->
price))
562 if (isset($this->price_ttc))
563 $this->price_ttc = trim($this->price_ttc);
564 if (isset($this->price_min))
565 $this->price_min = trim($this->price_min);
566 if (isset($this->price_min_ttc))
567 $this->price_min_ttc = trim($this->price_min_ttc);
568 if (isset($this->price_base_type))
569 $this->price_base_type = trim($this->price_base_type);
570 if (isset($this->tva_tx))
571 $this->tva_tx = trim($this->tva_tx);
572 if (isset($this->recuperableonly))
573 $this->recuperableonly = trim($this->recuperableonly);
574 if (isset($this->localtax1_tx))
575 $this->localtax1_tx = trim($this->localtax1_tx);
576 if (isset($this->localtax2_tx))
577 $this->localtax2_tx = trim($this->localtax2_tx);
578 if (isset($this->fk_user))
579 $this->fk_user = trim($this->fk_user);
580 if (isset($this->import_key))
581 $this->import_key = trim($this->import_key);
586 if ($this->
price !=
'' || $this->
price == 0) {
587 if ($this->price_base_type ==
'TTC') {
592 if ($this->price_min !=
'' || $this->price_min == 0) {
593 $this->price_min_ttc =
price2num($this->price_min,
'MU');
594 $this->price_min =
price2num($this->price_min) / (1 + ($this->tva_tx / 100));
595 $this->price_min =
price2num($this->price_min,
'MU');
597 $this->price_min = 0;
598 $this->price_min_ttc = 0;
602 $this->price_ttc = ($this->recuperableonly != 1) ?
price2num($this->
price) * (1 + ($this->tva_tx / 100)) : $this->price;
603 $this->price_ttc =
price2num($this->price_ttc,
'MU');
605 if ($this->price_min !=
'' || $this->price_min == 0) {
606 $this->price_min =
price2num($this->price_min,
'MU');
607 $this->price_min_ttc =
price2num($this->price_min) * (1 + ($this->tva_tx / 100));
608 $this->price_min_ttc =
price2num($this->price_min_ttc,
'MU');
611 $this->price_min = 0;
612 $this->price_min_ttc = 0;
619 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_customer_price_log(";
623 $sql .=
"fk_product,";
626 $sql .=
"price_ttc,";
627 $sql .=
"price_min,";
628 $sql .=
"price_min_ttc,";
629 $sql .=
"price_base_type,";
630 $sql .=
"default_vat_code,";
632 $sql .=
"recuperableonly,";
633 $sql .=
"localtax1_tx,";
634 $sql .=
"localtax2_tx,";
635 $sql .=
"localtax1_type,";
636 $sql .=
"localtax2_type,";
638 $sql .=
"import_key";
643 $sql .=
" t.entity,";
645 $sql .=
" t.fk_product,";
646 $sql .=
" t.fk_soc,";
648 $sql .=
" t.price_ttc,";
649 $sql .=
" t.price_min,";
650 $sql .=
" t.price_min_ttc,";
651 $sql .=
" t.price_base_type,";
652 $sql .=
" t.default_vat_code,";
653 $sql .=
" t.tva_tx,";
654 $sql .=
" t.recuperableonly,";
655 $sql .=
" t.localtax1_tx,";
656 $sql .=
" t.localtax2_tx,";
657 $sql .=
" t.localtax1_type,";
658 $sql .=
" t.localtax2_type,";
659 $sql .=
" t.fk_user,";
660 $sql .=
" t.import_key";
662 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price as t";
663 $sql .=
" WHERE t.rowid = ".$this->id;
666 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
670 $this->errors [] =
"Error ".$this->db->lasterror();
674 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_customer_price SET";
676 $sql .=
" entity=".$conf->entity.
",";
677 $sql .=
" datec='".$this->db->idate(
dol_now()).
"',";
678 $sql .=
" tms=".(dol_strlen($this->tms) != 0 ?
"'".$this->db->idate($this->tms).
"'" :
'null').
",";
679 $sql .=
" fk_product=".(isset($this->fk_product) ? $this->fk_product :
"null").
",";
680 $sql .=
" fk_soc=".(isset($this->fk_soc) ? $this->fk_soc :
"null").
",";
681 $sql .=
" price=".(isset($this->
price) ? $this->
price :
"null").
",";
682 $sql .=
" price_ttc=".(isset($this->price_ttc) ? $this->price_ttc :
"null").
",";
683 $sql .=
" price_min=".(isset($this->price_min) ? $this->price_min :
"null").
",";
684 $sql .=
" price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc :
"null").
",";
685 $sql .=
" price_base_type=".(isset($this->price_base_type) ?
"'".$this->db->escape($this->price_base_type).
"'" :
"null").
",";
686 $sql .=
" default_vat_code = ".($this->default_vat_code ?
"'".$this->db->escape($this->default_vat_code).
"'" :
"null").
",";
687 $sql .=
" tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) :
"null").
",";
688 $sql .=
" recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly :
"null").
",";
689 $sql .=
" localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) :
"null").
",";
690 $sql .=
" localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) :
"null").
",";
691 $sql .=
" localtax1_type=".(!empty($this->localtax1_type) ?
"'".$this->db->escape($this->localtax1_type).
"'" :
"'0'").
",";
692 $sql .=
" localtax2_type=".(!empty($this->localtax2_type) ?
"'".$this->db->escape($this->localtax2_type).
"'" :
"'0'").
",";
693 $sql .=
" fk_user=".$user->id.
",";
694 $sql .=
" import_key=".(isset($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null").
"";
696 $sql .=
" WHERE rowid=".$this->id;
698 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
702 $this->errors [] =
"Error ".$this->db->lasterror();
705 if (!$error && !$notrigger)
708 $result = $this->
call_trigger(
'PRODUCT_CUSTOMER_PRICE_UPDATE', $user);
709 if ($result < 0) $error++;
722 foreach ($this->errors as $errmsg) {
723 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
724 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
726 $this->
db->rollback();
745 if (!empty($conf->global->PRODUCT_DISABLE_PROPAGATE_CUSTOMER_PRICES_ON_CHILD_COMPANIES)) {
752 $sql =
"SELECT s.rowid";
753 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
754 $sql .=
" WHERE s.parent = ".$this->fk_soc;
755 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
757 dol_syslog(get_class($this).
"::setPriceOnAffiliateThirdparty", LOG_DEBUG);
761 $this->lines = array();
764 while (($obj = $this->
db->fetch_object(
$resql)) && (empty($error))) {
769 't.fk_product' => $this->fk_product,
't.fk_soc' => $obj->rowid
772 $result = $prodsocprice->fetch_all(
'',
'', 0, 0, $filter);
775 $this->error = $prodsocprice->error;
778 if (count($prodsocprice->lines) > 0) {
780 if (!empty($forceupdateaffiliate)) {
782 $prodsocpriceupd->fetch($prodsocprice->lines [0]->id);
784 $prodsocpriceupd->price = $this->price;
785 $prodsocpriceupd->price_min = $this->price_min;
786 $prodsocpriceupd->price_base_type = $this->price_base_type;
787 $prodsocpriceupd->tva_tx = $this->tva_tx;
788 $prodsocpriceupd->recuperableonly = $this->recuperableonly;
790 $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate);
793 $this->error = $prodsocpriceupd->error;
799 $prodsocpricenew->fk_soc = $obj->rowid;
800 $prodsocpricenew->fk_product = $this->fk_product;
801 $prodsocpricenew->price = $this->price;
802 $prodsocpricenew->price_min = $this->price_min;
803 $prodsocpricenew->price_base_type = $this->price_base_type;
804 $prodsocpricenew->tva_tx = $this->tva_tx;
805 $prodsocpricenew->recuperableonly = $this->recuperableonly;
807 $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
810 $this->error = $prodsocpriceupd->error;
823 $this->error =
"Error ".$this->db->lasterror();
835 public function delete($user, $notrigger = 0)
838 global $conf, $langs;
843 if (!$error && !$notrigger) {
844 $result = $this->
call_trigger(
'PRODUCT_CUSTOMER_PRICE_DELETE', $user);
851 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_customer_price";
852 $sql .=
" WHERE rowid=".$this->id;
854 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
858 $this->errors [] =
"Error ".$this->db->lasterror();
864 foreach ($this->errors as $errmsg) {
865 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
866 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
868 $this->
db->rollback();
892 $object->fetch($fromid);
900 $object->context[
'createfromclone'] =
'createfromclone';
901 $result = $object->create($user);
905 $this->error = $object->error;
906 $this->errors = array_merge($this->errors, $object->errors);
913 unset($object->context[
'createfromclone']);
920 $this->
db->rollback();
939 $this->fk_product =
'';
942 $this->price_ttc =
'';
943 $this->price_min =
'';
944 $this->price_min_ttc =
'';
945 $this->price_base_type =
'';
946 $this->default_vat_code =
'';
948 $this->recuperableonly =
'';
949 $this->localtax1_tx =
'';
950 $this->localtax2_tx =
'';
952 $this->import_key =
'';
987 public $price_min_ttc;
988 public $price_base_type;
989 public $default_vat_code;
991 public $recuperableonly;
992 public $localtax1_tx;
993 public $localtax2_tx;
File of class to manage predefined price products or services by customer.
fetch($id)
Load object in memory from the database.
fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter=array())
Load all objects in memory from database.
create($user, $notrigger=0, $forceupdateaffiliate=0)
Create object into database.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
update($user=0, $notrigger=0, $forceupdateaffiliate=0)
Update object into database.
__construct($db)
Constructor.
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
fetch_all($sortorder= '', $sortfield= '', $limit=0, $offset=0, $filter=array())
Load all customer prices in memory from database.
File of class to manage predefined price products or services by customer lines.
setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate)
Force update price on child companies so child company has same prices than parent.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
call_trigger($triggerName, $user)
Call trigger based on this instance.
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.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)