123 public function create($user, $notrigger = 0, $forceupdateaffiliate = 0)
125 global $conf, $langs;
130 if (isset($this->entity)) {
131 $this->entity = trim($this->entity);
133 if (isset($this->fk_product)) {
134 $this->fk_product = trim($this->fk_product);
136 if (isset($this->fk_soc)) {
137 $this->fk_soc = trim($this->fk_soc);
139 if (isset($this->ref_customer)) {
140 $this->ref_customer = trim($this->ref_customer);
142 if (isset($this->
price)) {
145 if (isset($this->price_ttc)) {
146 $this->price_ttc = trim($this->price_ttc);
148 if (isset($this->price_min)) {
149 $this->price_min = trim($this->price_min);
151 if (isset($this->price_min_ttc)) {
152 $this->price_min_ttc = trim($this->price_min_ttc);
154 if (isset($this->price_base_type)) {
155 $this->price_base_type = trim($this->price_base_type);
157 if (isset($this->tva_tx)) {
158 $this->tva_tx = (float) $this->tva_tx;
160 if (isset($this->recuperableonly)) {
161 $this->recuperableonly = trim($this->recuperableonly);
163 if (isset($this->localtax1_tx)) {
164 $this->localtax1_tx = trim($this->localtax1_tx);
166 if (isset($this->localtax2_tx)) {
167 $this->localtax2_tx = trim($this->localtax2_tx);
169 if (isset($this->fk_user)) {
170 $this->fk_user = trim($this->fk_user);
172 if (isset($this->import_key)) {
173 $this->import_key = trim($this->import_key);
179 if ($this->
price !=
'' || $this->
price == 0) {
180 if ($this->price_base_type ==
'TTC') {
185 if ($this->price_min !=
'' || $this->price_min == 0) {
186 $this->price_min_ttc =
price2num($this->price_min,
'MU');
187 $this->price_min =
price2num($this->price_min) / (1 + ($this->tva_tx / 100));
188 $this->price_min =
price2num($this->price_min,
'MU');
190 $this->price_min = 0;
191 $this->price_min_ttc = 0;
195 $this->price_ttc = ($this->recuperableonly != 1) ?
price2num($this->
price) * (1 + ($this->tva_tx / 100)) : $this->price;
196 $this->price_ttc =
price2num($this->price_ttc,
'MU');
198 if ($this->price_min !=
'' || $this->price_min == 0) {
199 $this->price_min =
price2num($this->price_min,
'MU');
200 $this->price_min_ttc =
price2num($this->price_min) * (1 + ($this->tva_tx / 100));
201 $this->price_min_ttc =
price2num($this->price_min_ttc,
'MU');
204 $this->price_min = 0;
205 $this->price_min_ttc = 0;
211 $sql =
"INSERT INTO ".$this->db->prefix().
"product_customer_price(";
214 $sql .=
"fk_product,";
216 $sql .=
'ref_customer,';
218 $sql .=
"price_ttc,";
219 $sql .=
"price_min,";
220 $sql .=
"price_min_ttc,";
221 $sql .=
"price_base_type,";
222 $sql .=
"default_vat_code,";
224 $sql .=
"recuperableonly,";
225 $sql .=
"localtax1_type,";
226 $sql .=
"localtax1_tx,";
227 $sql .=
"localtax2_type,";
228 $sql .=
"localtax2_tx,";
230 $sql .=
"import_key";
231 $sql .=
") VALUES (";
232 $sql .=
" ".((int) $conf->entity).
",";
233 $sql .=
" '".$this->db->idate(
dol_now()).
"',";
234 $sql .=
" ".(!isset($this->fk_product) ?
'NULL' :
"'".$this->db->escape($this->fk_product).
"'").
",";
235 $sql .=
" ".(!isset($this->fk_soc) ?
'NULL' :
"'".$this->db->escape($this->fk_soc).
"'").
",";
236 $sql .=
" ".(!isset($this->ref_customer) ?
'NULL' :
"'".$this->db->escape($this->ref_customer).
"'").
",";
237 $sql .=
" ".(empty($this->
price) ?
'0' :
"'".$this->db->escape($this->
price).
"'").
",";
238 $sql .=
" ".(empty($this->price_ttc) ?
'0' :
"'".$this->db->escape($this->price_ttc).
"'").
",";
239 $sql .=
" ".(empty($this->price_min) ?
'0' :
"'".$this->db->escape($this->price_min).
"'").
",";
240 $sql .=
" ".(empty($this->price_min_ttc) ?
'0' :
"'".$this->db->escape($this->price_min_ttc).
"'").
",";
241 $sql .=
" ".(!isset($this->price_base_type) ?
'NULL' :
"'".$this->db->escape($this->price_base_type).
"'").
",";
242 $sql .=
" ".($this->default_vat_code ?
"'".$this->db->escape($this->default_vat_code).
"'" :
"null").
",";
243 $sql .=
" ".(!isset($this->tva_tx) ?
'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).
",";
244 $sql .=
" ".(!isset($this->recuperableonly) ?
'NULL' :
"'".$this->db->escape($this->recuperableonly).
"'").
",";
245 $sql .=
" ".(empty($this->localtax1_type) ?
"'0'" :
"'".$this->db->escape($this->localtax1_type).
"'").
",";
246 $sql .=
" ".(!isset($this->localtax1_tx) ?
'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).
",";
247 $sql .=
" ".(empty($this->localtax2_type) ?
"'0'" :
"'".$this->db->escape($this->localtax2_type).
"'").
",";
248 $sql .=
" ".(!isset($this->localtax2_tx) ?
'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).
",";
249 $sql .=
" ".((int) $user->id).
",";
250 $sql .=
" ".(!isset($this->import_key) ?
'NULL' :
"'".$this->db->escape($this->import_key).
"'");
255 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
256 $resql = $this->db->query($sql);
259 $this->errors [] =
"Error ".$this->db->lasterror();
263 $this->
id = $this->db->last_insert_id($this->db->prefix().
"product_customer_price");
266 $result = $this->
call_trigger(
'PRODUCT_CUSTOMER_PRICE_CREATE', $user);
282 foreach ($this->errors as $errmsg) {
283 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
284 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
286 $this->db->rollback();
306 $sql .=
" t.entity,";
309 $sql .=
" t.fk_product,";
310 $sql .=
" t.fk_soc,";
311 $sql .=
" t.ref_customer,";
313 $sql .=
" t.price_ttc,";
314 $sql .=
" t.price_min,";
315 $sql .=
" t.price_min_ttc,";
316 $sql .=
" t.price_base_type,";
317 $sql .=
" t.default_vat_code,";
318 $sql .=
" t.tva_tx,";
319 $sql .=
" t.recuperableonly,";
320 $sql .=
" t.localtax1_tx,";
321 $sql .=
" t.localtax2_tx,";
322 $sql .=
" t.fk_user,";
323 $sql .=
" t.import_key";
324 $sql .=
" FROM ".$this->db->prefix().
"product_customer_price as t";
325 $sql .=
" WHERE t.rowid = ".((int) $id);
327 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
328 $resql = $this->db->query($sql);
330 if ($this->db->num_rows($resql)) {
331 $obj = $this->db->fetch_object($resql);
333 $this->
id = $obj->rowid;
335 $this->entity = $obj->entity;
336 $this->datec = $this->db->jdate($obj->datec);
337 $this->tms = $this->db->jdate($obj->tms);
338 $this->fk_product = $obj->fk_product;
339 $this->fk_soc = $obj->fk_soc;
340 $this->ref_customer = $obj->ref_customer;
341 $this->
price = $obj->price;
342 $this->price_ttc = $obj->price_ttc;
343 $this->price_min = $obj->price_min;
344 $this->price_min_ttc = $obj->price_min_ttc;
345 $this->price_base_type = $obj->price_base_type;
346 $this->default_vat_code = $obj->default_vat_code;
347 $this->tva_tx = $obj->tva_tx;
348 $this->recuperableonly = $obj->recuperableonly;
349 $this->localtax1_tx = $obj->localtax1_tx;
350 $this->localtax2_tx = $obj->localtax2_tx;
351 $this->fk_user = $obj->fk_user;
352 $this->import_key = $obj->import_key;
354 $this->db->free($resql);
358 $this->db->free($resql);
363 $this->error =
"Error ".$this->db->lasterror();
379 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter = array())
381 if (empty($sortfield)) {
382 $sortfield =
"t.rowid";
384 if (empty($sortorder)) {
390 $sql .=
" t.entity,";
393 $sql .=
" t.fk_product,";
394 $sql .=
" t.fk_soc,";
395 $sql .=
" t.ref_customer,";
397 $sql .=
" t.price_ttc,";
398 $sql .=
" t.price_min,";
399 $sql .=
" t.price_min_ttc,";
400 $sql .=
" t.price_base_type,";
401 $sql .=
" t.default_vat_code,";
402 $sql .=
" t.tva_tx,";
403 $sql .=
" t.recuperableonly,";
404 $sql .=
" t.localtax1_tx,";
405 $sql .=
" t.localtax2_tx,";
406 $sql .=
" t.localtax1_type,";
407 $sql .=
" t.localtax2_type,";
408 $sql .=
" t.fk_user,";
409 $sql .=
" t.import_key,";
410 $sql .=
" soc.nom as socname,";
411 $sql .=
" prod.ref as prodref";
412 $sql .=
" FROM ".$this->db->prefix().
"product_customer_price as t,";
413 $sql .=
" ".$this->db->prefix().
"product as prod,";
414 $sql .=
" ".$this->db->prefix().
"societe as soc";
415 $sql .=
" WHERE soc.rowid=t.fk_soc ";
416 $sql .=
" AND prod.rowid=t.fk_product ";
417 $sql .=
" AND prod.entity IN (".getEntity(
'product').
")";
418 $sql .=
" AND t.entity IN (".getEntity(
'productprice').
")";
421 if (count($filter) > 0) {
422 foreach ($filter as $key => $value) {
423 if (strpos($key,
'date')) {
424 $sql .=
" AND ".$key.
" = '".$this->db->escape($value).
"'";
425 } elseif ($key ==
'soc.nom') {
426 $sql .=
" AND ".$key.
" LIKE '%".$this->db->escape($value).
"%'";
427 } elseif ($key ==
'prod.ref' || $key ==
'prod.label') {
428 $sql .=
" AND ".$key.
" LIKE '%".$this->db->escape($value).
"%'";
429 } elseif ($key ==
't.price' || $key ==
't.price_ttc') {
430 $sql .=
" AND ".$key.
" LIKE '%".
price2num($value).
"%'";
432 $sql .=
" AND ".$key.
" = ".((int) $value);
436 $sql .= $this->db->order($sortfield, $sortorder);
437 if (!empty($limit)) {
438 $sql .= $this->db->plimit($limit + 1, $offset);
441 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
442 $resql = $this->db->query($sql);
444 $this->lines = array();
445 $num = $this->db->num_rows($resql);
447 while ($obj = $this->db->fetch_object($resql)) {
450 $line->id = $obj->rowid;
452 $line->entity = $obj->entity;
453 $line->datec = $this->db->jdate($obj->datec);
454 $line->tms = $this->db->jdate($obj->tms);
455 $line->fk_product = $obj->fk_product;
456 $line->fk_soc = $obj->fk_soc;
457 $line->ref_customer = $obj->ref_customer;
458 $line->price = $obj->price;
459 $line->price_ttc = $obj->price_ttc;
460 $line->price_min = $obj->price_min;
461 $line->price_min_ttc = $obj->price_min_ttc;
462 $line->price_base_type = $obj->price_base_type;
463 $line->default_vat_code = $obj->default_vat_code;
464 $line->tva_tx = $obj->tva_tx;
465 $line->recuperableonly = $obj->recuperableonly;
466 $line->localtax1_tx = $obj->localtax1_tx;
467 $line->localtax2_tx = $obj->localtax2_tx;
468 $line->localtax1_type = $obj->localtax1_type;
469 $line->localtax2_type = $obj->localtax2_type;
470 $line->fk_user = $obj->fk_user;
471 $line->import_key = $obj->import_key;
472 $line->socname = $obj->socname;
473 $line->prodref = $obj->prodref;
475 $this->lines[] = $line;
477 $this->db->free($resql);
481 $this->error =
"Error ".$this->db->lasterror();
496 public function fetchAllLog($sortorder, $sortfield, $limit, $offset, $filter = array())
498 if (!empty($sortfield)) {
499 $sortfield =
"t.rowid";
501 if (!empty($sortorder)) {
507 $sql .=
" t.entity,";
509 $sql .=
" t.fk_product,";
510 $sql .=
" t.fk_soc,";
511 $sql .=
" t.ref_customer,";
513 $sql .=
" t.price_ttc,";
514 $sql .=
" t.price_min,";
515 $sql .=
" t.price_min_ttc,";
516 $sql .=
" t.price_base_type,";
517 $sql .=
" t.default_vat_code,";
518 $sql .=
" t.tva_tx,";
519 $sql .=
" t.recuperableonly,";
520 $sql .=
" t.localtax1_tx,";
521 $sql .=
" t.localtax2_tx,";
522 $sql .=
" t.fk_user,";
523 $sql .=
" t.import_key,";
524 $sql .=
" soc.nom as socname,";
525 $sql .=
" prod.ref as prodref";
526 $sql .=
" FROM ".$this->db->prefix().
"product_customer_price_log as t";
527 $sql .=
" ,".$this->db->prefix().
"product as prod";
528 $sql .=
" ,".$this->db->prefix().
"societe as soc";
529 $sql .=
" WHERE soc.rowid=t.fk_soc";
530 $sql .=
" AND prod.rowid=t.fk_product ";
531 $sql .=
" AND prod.entity IN (".getEntity(
'product').
")";
532 $sql .=
" AND t.entity IN (".getEntity(
'productprice').
")";
534 if (count($filter) > 0) {
535 foreach ($filter as $key => $value) {
536 if (strpos($key,
'date')) {
537 $sql .=
" AND ".$key.
" = '".$this->db->escape($value).
"'";
538 } elseif ($key ==
'soc.nom') {
539 $sql .=
" AND ".$key.
" LIKE '%".$this->db->escape($value).
"%'";
541 $sql .=
" AND ".$key.
" = ".((int) $value);
545 $sql .= $this->db->order($sortfield, $sortorder);
546 if (!empty($limit)) {
547 $sql .= $this->db->plimit($limit + 1, $offset);
550 dol_syslog(get_class($this).
"::fetchAllLog", LOG_DEBUG);
551 $resql = $this->db->query($sql);
553 $this->lines = array();
554 $num = $this->db->num_rows($resql);
556 while ($obj = $this->db->fetch_object($resql)) {
559 $line->id = $obj->rowid;
561 $line->entity = $obj->entity;
562 $line->datec = $this->db->jdate($obj->datec);
563 $line->tms = $this->db->jdate($obj->tms);
564 $line->fk_product = $obj->fk_product;
565 $line->fk_soc = $obj->fk_soc;
566 $line->ref_customer = $obj->ref_customer;
567 $line->price = $obj->price;
568 $line->price_ttc = $obj->price_ttc;
569 $line->price_min = $obj->price_min;
570 $line->price_min_ttc = $obj->price_min_ttc;
571 $line->price_base_type = $obj->price_base_type;
572 $line->default_vat_code = $obj->default_vat_code;
573 $line->tva_tx = $obj->tva_tx;
574 $line->recuperableonly = $obj->recuperableonly;
575 $line->localtax1_tx = $obj->localtax1_tx;
576 $line->localtax2_tx = $obj->localtax2_tx;
577 $line->fk_user = $obj->fk_user;
578 $line->import_key = $obj->import_key;
579 $line->socname = $obj->socname;
580 $line->prodref = $obj->prodref;
582 $this->lines [] = $line;
584 $this->db->free($resql);
588 $this->error =
"Error ".$this->db->lasterror();
601 public function update($user = 0, $notrigger = 0, $forceupdateaffiliate = 0)
603 global $conf, $langs;
608 if (isset($this->entity)) {
609 $this->entity = trim($this->entity);
611 if (isset($this->fk_product)) {
612 $this->fk_product = trim($this->fk_product);
614 if (isset($this->fk_soc)) {
615 $this->fk_soc = trim($this->fk_soc);
617 if (isset($this->ref_customer)) {
618 $this->ref_customer = trim($this->ref_customer);
620 if (isset($this->
price)) {
623 if (isset($this->price_ttc)) {
624 $this->price_ttc = trim($this->price_ttc);
626 if (isset($this->price_min)) {
627 $this->price_min = trim($this->price_min);
629 if (isset($this->price_min_ttc)) {
630 $this->price_min_ttc = trim($this->price_min_ttc);
632 if (isset($this->price_base_type)) {
633 $this->price_base_type = trim($this->price_base_type);
635 if (isset($this->tva_tx)) {
636 $this->tva_tx = (float) $this->tva_tx;
638 if (isset($this->recuperableonly)) {
639 $this->recuperableonly = trim($this->recuperableonly);
641 if (isset($this->localtax1_tx)) {
642 $this->localtax1_tx = trim($this->localtax1_tx);
644 if (isset($this->localtax2_tx)) {
645 $this->localtax2_tx = trim($this->localtax2_tx);
647 if (isset($this->fk_user)) {
648 $this->fk_user = trim($this->fk_user);
650 if (isset($this->import_key)) {
651 $this->import_key = trim($this->import_key);
657 if ($this->
price !=
'' || $this->
price == 0) {
658 if ($this->price_base_type ==
'TTC') {
663 if ($this->price_min !=
'' || $this->price_min == 0) {
664 $this->price_min_ttc =
price2num($this->price_min,
'MU');
665 $this->price_min =
price2num($this->price_min) / (1 + ($this->tva_tx / 100));
666 $this->price_min =
price2num($this->price_min,
'MU');
668 $this->price_min = 0;
669 $this->price_min_ttc = 0;
673 $this->price_ttc = ($this->recuperableonly != 1) ?
price2num($this->
price) * (1 + ($this->tva_tx / 100)) : $this->price;
674 $this->price_ttc =
price2num($this->price_ttc,
'MU');
676 if ($this->price_min !=
'' || $this->price_min == 0) {
677 $this->price_min =
price2num($this->price_min,
'MU');
678 $this->price_min_ttc =
price2num($this->price_min) * (1 + ($this->tva_tx / 100));
679 $this->price_min_ttc =
price2num($this->price_min_ttc,
'MU');
682 $this->price_min = 0;
683 $this->price_min_ttc = 0;
690 $sql =
"INSERT INTO ".$this->db->prefix().
"product_customer_price_log(";
694 $sql .=
"fk_product,";
696 $sql .=
"ref_customer,";
698 $sql .=
"price_ttc,";
699 $sql .=
"price_min,";
700 $sql .=
"price_min_ttc,";
701 $sql .=
"price_base_type,";
702 $sql .=
"default_vat_code,";
704 $sql .=
"recuperableonly,";
705 $sql .=
"localtax1_tx,";
706 $sql .=
"localtax2_tx,";
707 $sql .=
"localtax1_type,";
708 $sql .=
"localtax2_type,";
710 $sql .=
"import_key";
715 $sql .=
" t.entity,";
717 $sql .=
" t.fk_product,";
718 $sql .=
" t.fk_soc,";
719 $sql .=
" t.ref_customer,";
721 $sql .=
" t.price_ttc,";
722 $sql .=
" t.price_min,";
723 $sql .=
" t.price_min_ttc,";
724 $sql .=
" t.price_base_type,";
725 $sql .=
" t.default_vat_code,";
726 $sql .=
" t.tva_tx,";
727 $sql .=
" t.recuperableonly,";
728 $sql .=
" t.localtax1_tx,";
729 $sql .=
" t.localtax2_tx,";
730 $sql .=
" t.localtax1_type,";
731 $sql .=
" t.localtax2_type,";
732 $sql .=
" t.fk_user,";
733 $sql .=
" t.import_key";
735 $sql .=
" FROM ".$this->db->prefix().
"product_customer_price as t";
736 $sql .=
" WHERE t.rowid = ".((int) $this->
id);
739 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
740 $resql = $this->db->query($sql);
743 $this->errors [] =
"Error ".$this->db->lasterror();
747 $sql =
"UPDATE ".$this->db->prefix().
"product_customer_price SET";
749 $sql .=
" entity=".$conf->entity.
",";
750 $sql .=
" datec='".$this->db->idate(
dol_now()).
"',";
751 $sql .=
" tms=".(dol_strlen($this->tms) != 0 ?
"'".$this->db->idate($this->tms).
"'" :
'null').
",";
752 $sql .=
" fk_product=".(isset($this->fk_product) ? $this->fk_product :
"null").
",";
753 $sql .=
" fk_soc=".(isset($this->fk_soc) ? $this->fk_soc :
"null").
",";
754 $sql .=
" ref_customer=".(isset($this->ref_customer) ?
"'".$this->db->escape($this->ref_customer).
"'" :
"null").
",";
755 $sql .=
" price=".(isset($this->
price) ? $this->
price :
"null").
",";
756 $sql .=
" price_ttc=".(isset($this->price_ttc) ? $this->price_ttc :
"null").
",";
757 $sql .=
" price_min=".(isset($this->price_min) ? $this->price_min :
"null").
",";
758 $sql .=
" price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc :
"null").
",";
759 $sql .=
" price_base_type=".(isset($this->price_base_type) ?
"'".$this->db->escape($this->price_base_type).
"'" :
"null").
",";
760 $sql .=
" default_vat_code = ".($this->default_vat_code ?
"'".$this->db->escape($this->default_vat_code).
"'" :
"null").
",";
761 $sql .=
" tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) :
"null").
",";
762 $sql .=
" recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly :
"null").
",";
763 $sql .=
" localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) :
"null").
",";
764 $sql .=
" localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) :
"null").
",";
765 $sql .=
" localtax1_type=".(!empty($this->localtax1_type) ?
"'".$this->db->escape($this->localtax1_type).
"'" :
"'0'").
",";
766 $sql .=
" localtax2_type=".(!empty($this->localtax2_type) ?
"'".$this->db->escape($this->localtax2_type).
"'" :
"'0'").
",";
767 $sql .=
" fk_user=".$user->id.
",";
768 $sql .=
" import_key=".(isset($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
770 $sql .=
" WHERE rowid=".((int) $this->
id);
772 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
773 $resql = $this->db->query($sql);
776 $this->errors [] =
"Error ".$this->db->lasterror();
779 if (!$error && !$notrigger) {
781 $result = $this->
call_trigger(
'PRODUCT_CUSTOMER_PRICE_MODIFY', $user);
797 foreach ($this->errors as $errmsg) {
798 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
799 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
801 $this->db->rollback();
820 if (
getDolGlobalString(
'PRODUCT_DISABLE_PROPAGATE_CUSTOMER_PRICES_ON_CHILD_COMPANIES')) {
827 $sql =
"SELECT s.rowid";
828 $sql .=
" FROM ".$this->db->prefix().
"societe as s";
829 $sql .=
" WHERE s.parent = ".((int) $this->fk_soc);
830 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
832 dol_syslog(get_class($this).
"::setPriceOnAffiliateThirdparty", LOG_DEBUG);
833 $resql = $this->db->query($sql);
836 $this->lines = array();
837 $num = $this->db->num_rows($resql);
839 while (($obj = $this->db->fetch_object($resql)) && (empty($error))) {
844 't.fk_product' => $this->fk_product,
't.fk_soc' => $obj->rowid
847 $result = $prodsocprice->fetchAll(
'',
'', 0, 0, $filter);
850 $this->error = $prodsocprice->error;
853 if (count($prodsocprice->lines) > 0) {
855 if (!empty($forceupdateaffiliate)) {
857 $prodsocpriceupd->fetch($prodsocprice->lines [0]->id);
859 $prodsocpriceupd->price = $this->price;
860 $prodsocpriceupd->price_min = $this->price_min;
861 $prodsocpriceupd->price_base_type = $this->price_base_type;
862 $prodsocpriceupd->tva_tx = $this->tva_tx;
863 $prodsocpriceupd->recuperableonly = $this->recuperableonly;
865 $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate);
866 if ($resultupd < 0) {
868 $this->error = $prodsocpriceupd->error;
874 $prodsocpricenew->fk_soc = $obj->rowid;
875 $prodsocpricenew->ref_customer = $obj->ref_customer;
876 $prodsocpricenew->fk_product = $this->fk_product;
877 $prodsocpricenew->price = $this->price;
878 $prodsocpricenew->price_min = $this->price_min;
879 $prodsocpricenew->price_base_type = $this->price_base_type;
880 $prodsocpricenew->tva_tx = $this->tva_tx;
881 $prodsocpricenew->recuperableonly = $this->recuperableonly;
883 $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
884 if ($resultupd < 0) {
886 $this->error = $prodsocpricenew->error;
891 $this->db->free($resql);
899 $this->error =
"Error ".$this->db->lasterror();