39require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobjectline.class.php";
41require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/reception/class/receptionlinebatch.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
62 public $TRIGGER_PREFIX =
'RECEPTION';
72 public $element =
"reception";
77 public $fk_element =
"fk_reception";
82 public $table_element =
"reception";
87 public $table_element_line =
"receptiondet_batch";
92 public $picto =
'dollyrevert';
101 public $ref_supplier;
110 public $tracking_number;
114 public $tracking_url;
131 public $weight_units;
147 public $height_units;
167 public $user_author_id;
172 public $date_delivery;
184 public $date_reception;
194 public $fk_user_author;
199 public $fk_user_valid;
213 public $lines = array();
220 public $detail_batch;
222 const STATUS_CANCELED = -1;
223 const STATUS_DRAFT = 0;
224 const STATUS_VALIDATED = 1;
225 const STATUS_CLOSED = 2;
237 $this->ismultientitymanaged = 1;
238 $this->isextrafieldmanaged = 1;
247 public function getNextNumRef($soc)
249 global $langs,
$conf;
250 $langs->load(
"receptions");
259 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
261 foreach ($dirmodels as $reldir) {
265 $mybool = ((bool) @include_once $dir.$file) || $mybool;
273 $obj =
new $classname();
274 '@phan-var-force ModelNumRefReception $obj';
277 $numref = $obj->getNextValue($soc, $this);
282 dol_print_error($this->db, get_class($this).
"::getNextNumRef ".$obj->error);
286 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_RECEPTION_ADDON_NUMBER_NotDefined");
298 public function create($user, $notrigger = 0)
304 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
309 if (empty($this->fk_project)) {
310 $this->fk_project = 0;
312 if (empty($this->weight_units)) {
313 $this->weight_units = 0;
315 if (empty($this->size_units)) {
316 $this->size_units = 0;
318 if (empty($this->date_creation)) {
319 $this->date_creation = $now;
328 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"reception (";
331 $sql .=
", ref_supplier";
332 $sql .=
", date_creation";
333 $sql .=
", fk_user_author";
334 $sql .=
", date_reception";
335 $sql .=
", date_delivery";
337 $sql .=
", fk_projet";
338 $sql .=
", fk_shipping_method";
339 $sql .=
", tracking_number";
344 $sql .=
", weight_units";
345 $sql .=
", size_units";
346 $sql .=
", note_private";
347 $sql .=
", note_public";
348 $sql .=
", model_pdf";
349 $sql .=
", fk_incoterms, location_incoterms";
350 $sql .=
") VALUES (";
352 $sql .=
", ".((int) $this->entity);
353 $sql .=
", ".($this->ref_supplier ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null");
354 $sql .=
", '".$this->db->idate($this->date_creation).
"'";
355 $sql .=
", ".((int) $user->id);
356 $sql .=
", ".($this->date_reception > 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
"null");
357 $sql .=
", ".($this->date_delivery > 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
358 $sql .=
", ".($this->socid > 0 ? ((int) $this->socid) :
"null");
359 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
360 $sql .=
", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) :
"null");
361 $sql .=
", '".$this->db->escape($this->tracking_number).
"'";
362 $sql .=
", ".(is_null($this->weight) ?
"NULL" : ((float) $this->weight));
363 $sql .=
", ".(is_null($this->trueDepth) ?
"NULL" : ((float) $this->trueDepth));
364 $sql .=
", ".(is_null($this->trueWidth) ?
"NULL" : ((float) $this->trueWidth));
365 $sql .=
", ".(is_null($this->trueHeight) ?
"NULL" : ((float) $this->trueHeight));
366 $sql .=
", ".((int) $this->weight_units);
367 $sql .=
", ".((int) $this->size_units);
368 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
369 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
370 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
371 $sql .=
", ".(int) $this->fk_incoterms;
372 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
375 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
377 $resql = $this->db->query($sql);
380 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"reception");
383 $initialref =
'(PROV'.$this->id.
')';
384 if (!empty($this->
ref)) {
385 $initialref = $this->ref;
388 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
389 $sql .=
" SET ref = '".$this->db->escape($initialref).
"'";
390 $sql .=
" WHERE rowid = ".((int) $this->
id);
392 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
393 if ($this->db->query($sql)) {
395 $num = count($this->lines);
396 for ($i = 0; $i < $num; $i++) {
397 $this->lines[$i]->fk_reception = $this->id;
399 if ($this->lines[$i]->
create($user) <= 0) {
405 if (!$error && $this->
id && $this->origin_id) {
420 if (!$error && !$notrigger) {
422 $result = $this->call_trigger(
'RECEPTION_CREATE', $user);
433 foreach ($this->errors as $errmsg) {
434 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
435 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
437 $this->db->rollback();
442 $this->error = $this->db->lasterror().
" - sql=$sql";
443 $this->db->rollback();
448 $this->error = $this->db->error().
" - sql=$sql";
449 $this->db->rollback();
467 public function create_line($entrepot_id, $origin_line_id, $qty, $rang = 0, $array_options = [], $parent_line_id = 0, $product_id = 0)
473 $receptionline->fk_reception = $this->id;
474 $receptionline->entrepot_id = $entrepot_id;
475 $receptionline->fk_elementdet = $origin_line_id;
476 $receptionline->element_type = $this->origin;
477 $receptionline->fk_parent = $parent_line_id;
478 $receptionline->fk_product = $product_id;
479 $receptionline->qty = $qty;
480 $receptionline->rang = $rang;
481 $receptionline->array_options = $array_options;
483 if (!($receptionline->fk_product > 0)) {
485 $order_line->fetch($receptionline->fk_elementdet);
486 $receptionline->fk_product = $order_line->fk_product;
489 if (($lineId = $receptionline->insert($user)) < 0) {
490 $this->errors[] = $receptionline->error;
503 public function fetch($id, $ref =
'', $ref_ext =
'')
506 if (empty($id) && empty($ref) && empty($ref_ext)) {
510 $sql =
"SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut as status, e.fk_projet as fk_project, e.billed";
511 $sql .=
", e.fk_user_valid";
512 $sql .=
", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
513 $sql .=
", e.date_reception as date_reception, e.model_pdf, e.date_delivery, e.date_valid";
514 $sql .=
", e.fk_shipping_method, e.tracking_number";
515 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
516 $sql .=
", e.note_private, e.note_public";
517 $sql .=
', e.fk_incoterms, e.location_incoterms';
518 $sql .=
', i.libelle as label_incoterms';
519 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception as e";
520 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element).
"' AND el.sourcetype = 'order_supplier'";
521 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON e.fk_incoterms = i.rowid';
524 $sql .=
" WHERE e.rowid = ".((int) $id);
526 $sql .=
" WHERE e.entity IN (".getEntity(
'reception').
")";
528 $sql .=
" AND e.ref = '".$this->db->escape($ref).
"'";
529 } elseif ($ref_ext) {
530 $sql .=
" AND e.ref_ext = '".$this->db->escape($ref_ext).
"'";
534 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
535 $result = $this->db->query($sql);
537 if ($this->db->num_rows($result)) {
538 $obj = $this->db->fetch_object($result);
540 $this->
id = $obj->rowid;
541 $this->entity = $obj->entity;
542 $this->
ref = $obj->ref;
543 $this->socid = $obj->socid;
544 $this->ref_supplier = $obj->ref_supplier;
545 $this->ref_ext = $obj->ref_ext;
546 $this->statut = $obj->status;
547 $this->
status = $obj->status;
548 $this->billed = $obj->billed;
549 $this->fk_project = $obj->fk_project;
550 $this->user_author_id = $obj->fk_user_author;
551 $this->fk_user_author = $obj->fk_user_author;
552 $this->fk_user_valid = $obj->fk_user_valid;
553 $this->date_creation = $this->db->jdate($obj->date_creation);
554 $this->
date = $this->db->jdate($obj->date_reception);
555 $this->date_reception = $this->db->jdate($obj->date_reception);
556 $this->date_delivery = $this->db->jdate($obj->date_delivery);
557 $this->date_valid = $this->db->jdate($obj->date_valid);
558 $this->model_pdf = $obj->model_pdf;
559 $this->shipping_method_id = $obj->fk_shipping_method;
560 $this->tracking_number = $obj->tracking_number;
561 $this->origin = ($obj->origin ? $obj->origin : ($obj->origin_id > 0 ?
'commande' :
''));
562 $this->origin_type = ($obj->origin ? $obj->origin : ($obj->origin_id > 0 ?
'commande' :
''));
563 $this->origin_id = $obj->origin_id;
565 $this->trueWeight = $obj->weight;
566 $this->weight_units = $obj->weight_units;
568 $this->trueWidth = $obj->width;
569 $this->width_units = $obj->size_units;
570 $this->trueHeight = $obj->height;
571 $this->height_units = $obj->size_units;
572 $this->trueDepth = $obj->size;
573 $this->depth_units = $obj->size_units;
575 $this->note_public = $obj->note_public;
576 $this->note_private = $obj->note_private;
579 $this->trueSize = $obj->size.
"x".$obj->width.
"x".$obj->height;
580 $this->size_units = $obj->size_units;
583 $this->fk_incoterms = $obj->fk_incoterms;
584 $this->location_incoterms = $obj->location_incoterms;
585 $this->label_incoterms = $obj->label_incoterms;
587 $this->db->free($result);
603 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
605 $extrafields->fetch_name_optionals_label($this->table_element,
true);
611 if (empty($obj->origin_id)) {
622 dol_syslog(get_class($this).
'::Fetch no reception found', LOG_ERR);
623 $this->error =
'Reception with id '.$id.
' not found';
627 $this->error = $this->db->error();
639 public function valid($user, $notrigger = 0)
641 global
$conf, $langs;
643 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
649 dol_syslog(get_class($this).
"::valid no draft status", LOG_WARNING);
653 if (!((!
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer'))
654 || (
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')))) {
655 $this->error =
'Permission denied';
656 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
666 $soc->fetch($this->socid);
670 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
671 $numref = $this->getNextNumRef($soc);
681 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
682 $sql .=
" ref='".$this->db->escape($numref).
"'";
683 $sql .=
", fk_statut = 1";
684 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
685 $sql .=
", fk_user_valid = ".((int) $user->id);
686 $sql .=
" WHERE rowid = ".((int) $this->
id);
687 dol_syslog(get_class($this).
"::valid update reception", LOG_DEBUG);
688 $resql = $this->db->query($sql);
690 $this->error = $this->db->lasterror();
696 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
698 $langs->load(
"agenda");
702 $sql =
"SELECT cd.fk_product, cd.subprice, cd.remise_percent,";
703 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
704 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
705 $sql .=
" ed.fk_elementdet, ed.cost_price";
706 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
707 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
708 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
709 $sql .=
" AND cd.rowid = ed.fk_elementdet";
711 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
712 $resql = $this->db->query($sql);
714 $cpt = $this->db->num_rows($resql);
715 for ($i = 0; $i < $cpt; $i++) {
716 $obj = $this->db->fetch_object($resql);
720 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
724 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid);
728 $mouvS->origin = &$this;
729 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
731 if (empty($obj->batch)) {
736 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionValidatedInDolibarr", $numref),
'',
'',
'',
'', 0, $inventorycode);
738 if (intval($result) < 0) {
749 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch,
'', 0, $inventorycode);
751 if (intval($result) < 0) {
759 $this->db->rollback();
760 $this->error = $this->db->error();
765 if (!$error && $this->origin_id > 0) {
773 $ret = $this->origin_object->Livraison($user,
dol_now(),
'tot',
'');
776 $this->errors = array_merge($this->errors, $this->origin_object->errors);
779 $ret = $this->
setStatut($status, $this->origin_id,
'commande_fournisseur', $trigger_key);
787 if (!$error && !$notrigger) {
789 $result = $this->call_trigger(
'RECEPTION_VALIDATE', $user);
797 $this->oldref = $this->ref;
800 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
802 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'reception/".$this->db->escape($this->newref).
"'";
803 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'reception/".$this->db->escape($this->
ref).
"' AND entity = ".((int)
$conf->entity);
804 $resql = $this->db->query($sql);
807 $this->error = $this->db->lasterror();
809 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'reception/".$this->db->escape($this->newref).
"'";
810 $sql .=
" WHERE filepath = 'reception/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
811 $resql = $this->db->query($sql);
814 $this->error = $this->db->lasterror();
820 $dirsource =
$conf->reception->dir_output.
'/'.$oldref;
821 $dirdest =
$conf->reception->dir_output.
'/'.$newref;
822 if (!$error && file_exists($dirsource)) {
823 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
825 if (@rename($dirsource, $dirdest)) {
828 $listoffiles =
dol_dir_list(
$conf->reception->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
829 foreach ($listoffiles as $fileentry) {
830 $dirsource = $fileentry[
'name'];
831 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
832 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
833 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
834 @rename($dirsource, $dirdest);
843 $this->
ref = $numref;
844 $this->statut = self::STATUS_VALIDATED;
845 $this->
status = self::STATUS_VALIDATED;
852 foreach ($this->errors as $errmsg) {
853 dol_syslog(get_class($this).
"::valid ".$errmsg, LOG_ERR);
854 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
856 $this->db->rollback();
868 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
869 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
873 if (!empty($this->origin) && $this->origin_id > 0 && ($this->origin ==
'order_supplier' || $this->origin ==
'commandeFournisseur')) {
874 if (empty($this->origin_object)) {
876 if ($this->origin_object instanceof
CommonObject && empty($this->origin_object->lines)) {
877 $res = $this->origin_object->fetch_lines();
878 $this->commandeFournisseur =
null;
882 } elseif ($this->origin_object instanceof
CommandeFournisseur && empty($this->origin_object->lines)) {
883 $res = $this->origin_object->fetch_lines();
891 $qty_received = array();
892 $qty_wished = array();
895 $filter = array(
't.fk_element' => $this->origin_id);
897 $filter[
't.status'] = 1;
900 $ret = $supplierorderdispatch->fetchAll(
'',
'', 0, 0, $filter);
906 $draft_lines = array();
907 $sql =
"SELECT rb.rowid FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as rb";
908 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"reception as r ON r.rowid = rb.fk_reception";
909 $sql .=
" WHERE rb.fk_element = ".((int) $this->origin_id);
910 $sql .=
" AND r.fk_statut = ".self::STATUS_DRAFT;
911 $resql = $this->db->query($sql);
913 $this->error = $this->db->lasterror();
916 while ($obj = $this->db->fetch_object($resql)) {
917 $draft_lines[(int) $obj->rowid] = (
int) $obj->rowid;
919 $this->db->free($resql);
922 foreach ($supplierorderdispatch->lines as $dispatch_line) {
923 if (isset($draft_lines[(
int) $dispatch_line->id])) {
926 if (array_key_exists($dispatch_line->fk_product, $qty_received)) {
927 $qty_received[$dispatch_line->fk_product] += $dispatch_line->qty;
929 $qty_received[$dispatch_line->fk_product] = $dispatch_line->qty;
934 foreach ($this->origin_object->lines as $origin_line) {
936 if (($origin_line->product_type > 0 && (!
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES') || empty($origin_line->stockable_product))) || $origin_line->product_type > 1) {
939 if (array_key_exists($origin_line->fk_product, $qty_wished)) {
940 $qty_wished[$origin_line->fk_product] += $origin_line->qty;
942 $qty_wished[$origin_line->fk_product] = $origin_line->qty;
947 $diff_array = array_diff_assoc($qty_received, $qty_wished);
948 $keys_in_wished_not_in_received = array_diff(array_keys($qty_wished), array_keys($qty_received));
949 $keys_in_received_not_in_wished = array_diff(array_keys($qty_received), array_keys($qty_wished));
951 if (count($diff_array) == 0 && count($keys_in_wished_not_in_received) == 0 && count($keys_in_received_not_in_wished) == 0) {
957 if (count($diff_array) > 0) {
960 foreach ($diff_array as $key => $value) {
962 if ($qty_received[$key] >= $qty_wished[$key]) {
968 if ($close == count($diff_array)) {
995 public function addline($entrepot_id, $id, $qty, $array_options = [], $comment =
'', $eatby =
null, $sellby =
null, $batch =
'', $cost_price = 0)
997 global
$conf, $langs, $user;
999 $num = count($this->lines);
1002 $line->fk_entrepot = $entrepot_id;
1003 $line->fk_commandefourndet = $id;
1007 $result = $supplierorderline->fetch($id);
1014 if (
isModEnabled(
'stock') && !empty($supplierorderline->fk_product)) {
1015 $fk_product = $supplierorderline->fk_product;
1017 if (!($entrepot_id > 0) && !
getDolGlobalInt(
'STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS')) {
1018 $langs->load(
"errors");
1019 $this->error = $langs->trans(
"ErrorWarehouseRequiredIntoReceptionLine");
1025 $product =
new Product($this->db);
1026 $product->fetch($fk_product);
1028 $langs->load(
"errors");
1029 if (!empty($product->status_batch) && empty($batch)) {
1030 $this->error = $langs->trans(
'ErrorProductNeedBatchNumber', $product->ref);
1032 } elseif (empty($product->status_batch) && !empty($batch)) {
1033 $this->error = $langs->trans(
'ErrorProductDoesNotNeedBatchNumber', $product->ref);
1039 if (!empty($errorMsgArr)) {
1040 $errorMessage =
'<b>' . $product->ref .
'</b> : ';
1041 $errorMessage .=
'<ul>';
1042 foreach ($errorMsgArr as $errorMsg) {
1043 $errorMessage .=
'<li>' . $errorMsg .
'</li>';
1045 $errorMessage .=
'</ul>';
1046 $this->error = $errorMessage;
1053 $line->array_options = $supplierorderline->array_options;
1054 if (!
getDolGlobalInt(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1055 foreach ($array_options as $key => $value) {
1056 $line->array_options[$key] = $value;
1060 $line->fk_product = $fk_product;
1061 $line->fk_commande = $supplierorderline->fk_commande;
1062 $line->fk_user = $user->id;
1063 $line->comment = $comment;
1064 $line->batch = $batch;
1065 $line->eatby = $eatby;
1066 $line->sellby = $sellby;
1068 $line->cost_price = $cost_price;
1069 $line->fk_reception = $this->id;
1071 $this->lines[$num] = $line;
1088 public function addlinefree($qty, $element_type, $fk_product, $fk_unit, $rang, $description, $array_options = [])
1090 global
$mysoc, $langs, $user;
1092 if ($this->
status == self::STATUS_DRAFT) {
1103 if ($ranktouse == -1) {
1104 $rangmax = $this->
line_max($this->fk_reception);
1105 $ranktouse = $rangmax + 1;
1110 $this->line->fk_reception = $this->id;
1111 $this->line->element_type = $element_type;
1112 $this->line->fk_product = $fk_product;
1113 $this->line->description = $description;
1115 $this->line->qty = (float) $qty;
1116 $this->line->fk_unit = $fk_unit;
1117 $this->line->rang = $ranktouse;
1119 if (is_array($array_options) && count($array_options) > 0) {
1120 $this->line->array_options = $array_options;
1123 $result = $this->line->insert($user);
1125 if (!isset($this->context[
'createfromclone'])) {
1126 if ($this->fk_reception) {
1128 } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) {
1129 $linecount = count($this->lines);
1130 for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
1134 $this->lines[] = $this->line;
1137 $this->db->commit();
1138 return $this->line->id;
1140 $this->error = $this->line->error;
1141 dol_syslog(get_class($this).
"::addlinefree error=".$this->error, LOG_ERR);
1142 $this->db->rollback();
1146 dol_syslog(get_class($this).
"::addlinefree status of reception must be Draft to allow use of ->addlinefree()", LOG_ERR);
1165 public function updatelinefree($rowid, $qty, $element_type, $fk_product, $fk_unit, $rang, $description, $notrigger, $array_options = array())
1167 global
$mysoc, $langs, $user;
1169 if ($this->statut == self::STATUS_DRAFT) {
1179 $qty = (float) $qty;
1180 $description = trim((
string) $description);
1185 $line->fetch($rowid);
1186 $line->fetch_optionals();
1188 if (!empty($line->fk_product)) {
1189 $product =
new Product($this->db);
1190 $result = $product->fetch($line->fk_product);
1191 $product_type = $product->type;
1194 $staticline = clone $line;
1196 $line->oldline = $staticline;
1197 $this->line = $line;
1198 $this->line->context = $this->context;
1199 $this->line->rang = $rang;
1200 $this->line->fk_reception = $this->id;
1201 $this->line->element_type = $element_type;
1202 $this->line->fk_product = $line->fk_product;
1203 $this->line->qty = $qty;
1204 $this->line->fk_unit = $fk_unit;
1205 $this->line->description = $description;
1207 if (is_array($array_options) && count($array_options) > 0) {
1209 foreach ($array_options as $key => $value) {
1210 $this->line->array_options[$key] = $array_options[$key];
1215 $result = $this->line->update($user, $notrigger);
1220 $this->db->commit();
1223 $this->error = $this->line->error;
1225 $this->db->rollback();
1229 $this->error = get_class($this).
"::updatelinefree reception status makes operation forbidden";
1230 $this->errors = array(
'ReceptionStatusMakeOperationForbidden');
1244 $this->lines = array();
1246 $sql =
'SELECT rc.rowid, rc.fk_reception, rc.fk_entrepot, rc.fk_product, rc.fk_unit, rc.description, rc.fk_elementdet, rc.fk_element, rc.element_type, rc.qty, rc.rang';
1247 $sql .=
' FROM '.MAIN_DB_PREFIX.
'receptiondet_batch as rc';
1248 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON (p.rowid = rc.fk_product)';
1249 $sql .=
' WHERE rc.fk_reception = '.((int) $this->
id);
1251 $sql .=
' ORDER BY rc.rang, rc.rowid';
1253 dol_syslog(get_class($this).
"::fetch_lines_free", LOG_DEBUG);
1254 $result = $this->db->query($sql);
1256 $num = $this->db->num_rows($result);
1260 $objp = $this->db->fetch_object($result);
1264 $line->rowid = $objp->rowid;
1265 $line->id = $objp->rowid;
1266 $line->fk_reception = $this->id;
1268 $line->description = $objp->description;
1269 $line->qty = $objp->qty;
1270 $line->fk_entrepot = $objp->fk_entrepot;
1271 $line->fk_product = $objp->fk_product;
1273 $line->rang = $objp->rang;
1276 $line->fk_element = $objp->fk_element;
1277 $line->fk_unit = $objp->fk_unit;
1278 $line->fk_elementdet = $objp->fk_elementdet;
1279 $line->fk_element_type = $objp->element_type;
1280 $line->fetch_optionals();
1282 $this->lines[$i] = $line;
1287 $this->db->free($result);
1291 $this->error = $this->db->error();
1313 public function update($user =
null, $notrigger = 0)
1320 if (isset($this->
ref)) {
1321 $this->
ref = trim($this->
ref);
1323 if (isset($this->entity)) {
1324 $this->entity = (int) $this->entity;
1326 if (isset($this->ref_supplier)) {
1327 $this->ref_supplier = trim($this->ref_supplier);
1329 if (isset($this->socid)) {
1330 $this->socid = (int) trim((
string) $this->socid);
1332 if (isset($this->fk_user_author)) {
1333 $this->fk_user_author = (int) $this->fk_user_author;
1335 if (isset($this->fk_user_valid)) {
1336 $this->fk_user_valid = (int) $this->fk_user_valid;
1338 if (isset($this->shipping_method_id)) {
1339 $this->shipping_method_id = (int) $this->shipping_method_id;
1341 if (isset($this->tracking_number)) {
1342 $this->tracking_number = trim($this->tracking_number);
1344 if (isset($this->statut)) {
1345 $this->statut = (int) $this->statut;
1347 if (isset($this->trueDepth)) {
1348 $this->trueDepth =
price2num($this->trueDepth);
1350 if (isset($this->trueWidth)) {
1351 $this->trueWidth =
price2num($this->trueWidth);
1353 if (isset($this->trueHeight)) {
1354 $this->trueHeight =
price2num($this->trueHeight);
1356 $this->size_units = (int) $this->size_units;
1358 if (isset($this->trueWeight)) {
1359 $this->weight =
price2num($this->trueWeight);
1361 $this->weight_units = (int) $this->weight_units;
1363 if (isset($this->note_private)) {
1364 $this->note_private = trim($this->note_private);
1366 if (isset($this->note_public)) {
1367 $this->note_public = trim($this->note_public);
1369 if (isset($this->model_pdf)) {
1370 $this->model_pdf = trim($this->model_pdf);
1378 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
1380 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"null").
",";
1381 $sql .=
" ref_supplier=".(isset($this->ref_supplier) ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null").
",";
1382 $sql .=
" fk_soc=".(isset($this->socid) ? ((int) $this->socid) :
"null").
",";
1383 $sql .=
" date_creation=".(dol_strlen($this->date_creation) != 0 ?
"'".$this->db->idate($this->date_creation).
"'" :
'null').
",";
1384 $sql .=
" fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) :
"null").
",";
1385 $sql .=
" date_valid=".(dol_strlen($this->date_valid) != 0 ?
"'".$this->db->idate($this->date_valid).
"'" :
'null').
",";
1386 $sql .=
" fk_user_valid=".(isset($this->fk_user_valid) ? ((int) $this->fk_user_valid) :
"null").
",";
1387 $sql .=
" date_reception=".(dol_strlen($this->date_reception) != 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
'null').
",";
1388 $sql .=
" date_delivery=".(dol_strlen($this->date_delivery) != 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
'null').
",";
1389 $sql .=
" fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? ((
int) $this->shipping_method_id) :
"null").
",";
1390 $sql .=
" tracking_number=".(isset($this->tracking_number) ?
"'".$this->db->escape($this->tracking_number).
"'" :
"null").
",";
1391 $sql .=
" fk_statut=".(isset($this->statut) ? ((int) $this->statut) :
"null").
",";
1392 $sql .=
" height=".(($this->trueHeight !=
'') ? (
float) $this->trueHeight :
"null").
",";
1393 $sql .=
" width=".(($this->trueWidth !=
'') ? (
float) $this->trueWidth :
"null").
",";
1394 $sql .=
" size_units=".((int) $this->size_units).
",";
1395 $sql .=
" size=".(($this->trueDepth !=
'') ? (
float) $this->trueDepth :
"null").
",";
1396 $sql .=
" weight_units=".((int) $this->weight_units).
",";
1397 $sql .=
" weight=".(($this->trueWeight !=
'') ? (
float) $this->trueWeight :
"null").
",";
1398 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1399 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1400 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1401 $sql .=
" fk_projet=".((isset($this->fk_project) && $this->fk_project > 0) ? ((
int) $this->fk_project) :
"null").
",";
1402 $sql .=
" entity = ".((int)
$conf->entity);
1403 $sql .=
" WHERE rowid=".((int) $this->
id);
1407 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1408 $resql = $this->db->query($sql);
1411 $this->errors[] =
"Error ".$this->db->lasterror();
1417 $result = $this->call_trigger(
'RECEPTION_MODIFY', $user);
1427 foreach ($this->errors as $errmsg) {
1428 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1429 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1431 $this->db->rollback();
1434 $this->db->commit();
1445 public function delete(
User $user)
1447 global
$conf, $langs, $user;
1448 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1458 || (
getDolGlobalInt(
'STOCK_CALCULATE_ON_RECEPTION_CLOSE') && $this->
status == Reception::STATUS_CLOSED))
1460 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1462 $langs->load(
"agenda");
1465 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.eatby, ed.sellby, ed.batch, ed.rowid as receptiondet_batch_id";
1466 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
1467 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
1468 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
1469 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1471 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1472 $resql = $this->db->query($sql);
1474 $cpt = $this->db->num_rows($resql);
1475 for ($i = 0; $i < $cpt; $i++) {
1476 dol_syslog(get_class($this).
"::delete movement index ".$i);
1477 $obj = $this->db->fetch_object($resql);
1480 if ($obj->qty == 0 || ($obj->qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
1486 $mouvS->origin =
null;
1488 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ReceptionDeletedInDolibarr", $this->ref),
'', $obj->eatby ? $this->db->jdate($obj->eatby) : null, $obj->sellby ? $this->db->jdate($obj->sellby) : null, $obj->batch);
1491 $this->error = $mouvS->error;
1492 $this->errors = $mouvS->errors;
1497 $this->errors[] =
"Error ".$this->db->lasterror();
1502 $sanitized_main = MAIN_DB_PREFIX.
'receptiondet_batch';
1503 $sanitized_ef = $sanitized_main.
"_extrafields";
1505 $sqlef =
"DELETE FROM ".$sanitized_ef.
" WHERE fk_object IN (SELECT rowid FROM ".$sanitized_main.
" WHERE fk_reception = ".((int) $this->
id).
")";
1507 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"receptiondet_batch";
1508 $sql .=
" WHERE fk_reception = ".((int) $this->
id);
1510 if ($this->db->query($sqlef) && $this->db->query($sql)) {
1518 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"reception";
1519 $sql .=
" WHERE rowid = ".((int) $this->
id);
1521 if ($this->db->query($sql)) {
1523 $result = $this->call_trigger(
'RECEPTION_DELETE', $user);
1529 if (!empty($this->origin) && $this->origin_id > 0) {
1532 '@phan-var-force CommandeFournisseur $origin_object';
1545 $this->db->commit();
1549 if (!empty(
$conf->reception->dir_output)) {
1550 $dir =
$conf->reception->dir_output.
'/'.$ref;
1551 $file = $dir.
'/'.$ref.
'.pdf';
1552 if (file_exists($file)) {
1557 if (file_exists($dir)) {
1559 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1567 $this->db->rollback();
1571 $this->error = $this->db->lasterror().
" - sql=$sql";
1572 $this->db->rollback();
1576 $this->error = $this->db->lasterror().
" - sql=$sql";
1577 $this->db->rollback();
1581 $this->error = $this->db->lasterror().
" - sql=$sql";
1582 $this->db->rollback();
1586 $this->db->rollback();
1600 if ($this->
status != self::STATUS_DRAFT) {
1601 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
1606 if ($line->fetch($lineid) <= 0) {
1607 $this->error =
'ErrorRecordNotFound';
1610 if ($line->fk_reception != $this->id) {
1611 $this->error =
'ErrorLineIDDoesNotMatchWithObjectID';
1616 if ($line->delete($user) > 0) {
1617 $this->db->commit();
1620 $this->error = $line->error;
1621 $this->db->rollback();
1634 $this->lines = array();
1636 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
1638 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"receptiondet_batch";
1639 $sql .=
" WHERE fk_reception = ".((int) $this->
id);
1641 $resql = $this->db->query($sql);
1643 if (!empty($resql)) {
1644 while ($obj = $this->db->fetch_object($resql)) {
1647 $line->fetch($obj->rowid);
1650 $line->fetch_product();
1652 $sql_commfourndet =
'SELECT qty, ref, label, description, tva_tx, vat_src_code, localtax1_tx, localtax2_tx, subprice, multicurrency_subprice, remise_percent, total_ht, total_ttc, total_tva, date_start, date_end, product_type';
1653 $sql_commfourndet .=
' FROM '.MAIN_DB_PREFIX.
'commande_fournisseurdet';
1654 $sql_commfourndet .=
' WHERE rowid = '.((int) $line->fk_commandefourndet);
1655 $sql_commfourndet .=
' ORDER BY rang';
1657 $resql_commfourndet = $this->db->query($sql_commfourndet);
1658 if (!empty($resql_commfourndet)) {
1659 $obj = $this->db->fetch_object($resql_commfourndet);
1660 $line->qty_asked = $obj->qty;
1661 $line->description = $obj->description;
1662 $line->desc = $obj->description;
1663 $line->tva_tx = $obj->tva_tx;
1664 $line->vat_src_code = $obj->vat_src_code;
1665 $line->localtax1_tx = $obj->localtax1_tx;
1666 $line->localtax2_tx = $obj->localtax2_tx;
1667 $line->subprice = $obj->subprice;
1668 $line->multicurrency_subprice = $obj->multicurrency_subprice;
1669 $line->remise_percent = $obj->remise_percent;
1670 $line->label = !empty($obj->label) ? $obj->label : (is_object($line->product) ? $line->product->label :
'');
1671 $line->ref_supplier = $obj->ref;
1672 $line->total_ht = $obj->total_ht;
1673 $line->total_ttc = $obj->total_ttc;
1674 $line->total_tva = $obj->total_tva;
1675 $line->date_start = $this->db->jdate($obj->date_start);
1676 $line->date_end = $this->db->jdate($obj->date_end);
1677 $line->product_type = $obj->product_type;
1679 $line->qty_asked = 0;
1680 $line->description =
'';
1682 $line->label = $obj->label;
1685 $pu_ht = ($line->subprice * $line->qty) * (100 - $line->remise_percent) / 100;
1686 $tva = $pu_ht * $line->tva_tx / 100;
1687 $this->total_ht += $pu_ht;
1688 $this->total_tva += $pu_ht * $line->tva_tx / 100;
1690 $this->total_ttc += $pu_ht + $tva;
1692 if (
isModEnabled(
'productbatch') && !empty($line->batch)) {
1694 $detail_batch->eatby = $line->eatby;
1695 $detail_batch->sellby = $line->sellby;
1696 $detail_batch->batch = $line->batch;
1697 $detail_batch->qty = $line->qty;
1699 $line->detail_batch[] = $detail_batch;
1702 $this->lines[] = $line;
1721 public function getNomUrl($withpicto = 0, $option =
'', $max = 0, $short = 0, $notooltip = 0)
1723 global $langs, $hookmanager;
1726 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Reception").
'</u>';
1727 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1728 $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.($this->ref_supplier ? $this->ref_supplier :
'');
1730 $url = DOL_URL_ROOT.
'/reception/card.php?id='.$this->id;
1737 if (empty($notooltip)) {
1739 $label = $langs->trans(
"Reception");
1740 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1742 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
1743 $linkclose .=
' class="classfortooltip"';
1746 $linkstart =
'<a href="'.$url.
'"';
1747 $linkstart .= $linkclose.
'>';
1750 $result .= $linkstart;
1752 $result .=
img_object(($notooltip ?
'' : $label), $this->picto,
'', 0, 0, $notooltip ? 0 : 1);
1754 if ($withpicto != 2) {
1755 $result .= $this->ref;
1758 $result .= $linkend;
1761 $hookmanager->initHooks(array($this->element .
'dao'));
1762 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1763 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1765 $result = $hookmanager->resPrint;
1767 $result .= $hookmanager->resPrint;
1780 return $this->
LibStatut($this->statut, $mode);
1797 $this->labelStatus[-1] =
'StatusReceptionCanceled';
1798 $this->labelStatus[0] =
'StatusReceptionDraft';
1800 $this->labelStatus[1] =
'StatusReceptionValidated';
1802 $this->labelStatus[1] =
'StatusReceptionValidatedReceived';
1805 $this->labelStatus[1] =
'StatusReceptionValidatedToReceive';
1807 $this->labelStatus[2] =
'StatusReceptionProcessed';
1810 $this->labelStatusShort[-1] =
'StatusReceptionCanceledShort';
1811 $this->labelStatusShort[0] =
'StatusReceptionDraftShort';
1812 $this->labelStatusShort[1] =
'StatusReceptionValidatedShort';
1813 $this->labelStatusShort[2] =
'StatusReceptionProcessedShort';
1815 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
1816 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]);
1818 $statusType =
'status'.$status;
1819 if ($status == self::STATUS_VALIDATED) {
1820 $statusType =
'status4';
1822 if ($status == self::STATUS_CLOSED) {
1823 $statusType =
'status6';
1826 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
1838 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1840 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1841 $return .=
'<div class="info-box info-box-sm">';
1842 $return .=
'<div class="info-box-icon bg-infobox-action">';
1844 $return .=
'</div>';
1845 $return .=
'<div class="info-box-content">';
1846 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1847 if ($selected >= 0) {
1848 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1850 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1851 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1856 if (method_exists($this,
'getLibStatut')) {
1857 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1859 $return .=
'</div>';
1860 $return .=
'</div>';
1861 $return .=
'</div>';
1877 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1878 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
1881 dol_syslog(get_class($this).
"::initAsSpecimen");
1884 $order->initAsSpecimen();
1888 $this->
ref =
'SPECIMEN';
1889 $this->specimen = 1;
1893 $this->date_creation = $now;
1894 $this->date_valid = $now;
1895 $this->date_delivery = $now;
1896 $this->date_reception = $now + 24 * 3600;
1897 $this->entrepot_id = 0;
1899 $this->origin_id = 1;
1900 $this->origin_type =
'supplier_order';
1901 $this->origin_object = $order;
1902 $this->note_private =
'Private note';
1903 $this->note_public =
'Public note';
1904 $this->tracking_number =
'TRACKID-ABC123';
1905 $this->fk_incoterms = 1;
1908 while ($xnbp < $nbp) {
1910 $line->desc = $langs->trans(
"Description").
" ".$xnbp;
1911 $line->libelle = $langs->trans(
"Description").
" ".$xnbp;
1912 $line->label = $langs->trans(
"Description").
" ".$xnbp;
1915 $line->fk_product = $this->origin_object->lines[$xnbp]->fk_product;
1917 $this->lines[] = $line;
1934 if ($user->hasRight(
'reception',
'creer')) {
1935 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1936 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1937 $sql .=
" WHERE rowid = ".((int) $this->
id);
1939 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1940 $resql = $this->db->query($sql);
1942 $this->date_delivery = $delivery_date;
1945 $this->error = $this->db->error();
1962 if ($user->hasRight(
'reception',
'creer')) {
1963 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1964 $sql .=
" SET date_reception = ".($reception_date ?
"'".$this->db->idate($reception_date).
"'" :
'null');
1965 $sql .=
" WHERE rowid = ".((int) $this->
id);
1967 dol_syslog(get_class($this).
"::setReceptionDate", LOG_DEBUG);
1968 $resql = $this->db->query($sql);
1970 $this->date_reception = $reception_date;
1973 $this->error = $this->db->error();
1991 $this->meths = array();
1993 $sql =
"SELECT em.rowid, em.code, em.libelle";
1994 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
1995 $sql .=
" WHERE em.active = 1";
1996 $sql .=
" ORDER BY em.libelle ASC";
1998 $resql = $this->db->query($sql);
2000 while ($obj = $this->db->fetch_object($resql)) {
2001 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
2002 $this->meths[$obj->rowid] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
2019 $this->listmeths = array();
2022 $sql =
"SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
2023 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2025 $sql .=
" WHERE em.rowid = ".((int) $id);
2028 $resql = $this->db->query($sql);
2030 while ($obj = $this->db->fetch_object($resql)) {
2031 $this->listmeths[$i][
'rowid'] = $obj->rowid;
2032 $this->listmeths[$i][
'code'] = $obj->code;
2033 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
2034 $this->listmeths[$i][
'libelle'] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
2035 $this->listmeths[$i][
'description'] = $obj->description;
2036 $this->listmeths[$i][
'tracking'] = $obj->tracking;
2037 $this->listmeths[$i][
'active'] = $obj->active;
2051 if (!empty($this->shipping_method_id)) {
2052 $sql =
"SELECT em.code, em.tracking";
2053 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2054 $sql .=
" WHERE em.rowid = ".((int) $this->shipping_method_id);
2056 $resql = $this->db->query($sql);
2058 if ($obj = $this->db->fetch_object($resql)) {
2059 $tracking = $obj->tracking;
2064 if (!empty($tracking) && !empty($value)) {
2065 $url = str_replace(
'{TRACKID}', $value, $tracking);
2066 $this->tracking_url = sprintf(
'<a target="_blank" rel="noopener noreferrer" href="%s">%s</a>', $url, ($value ? $value :
'url'));
2068 $this->tracking_url = $value;
2079 global
$conf, $langs, $user;
2084 if ($this->statut == Reception::STATUS_CLOSED) {
2085 dol_syslog(get_class($this).
"::setClosed already in closed status", LOG_WARNING);
2089 if ($this->statut != Reception::STATUS_VALIDATED) {
2090 $langs->load(
"receptions");
2091 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionValidatedShort'));
2092 dol_syslog(get_class($this).
"::setClosed reception is not validated", LOG_WARNING);
2098 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut = '.self::STATUS_CLOSED;
2099 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut = '.self::STATUS_VALIDATED;
2101 $resql = $this->db->query($sql);
2102 if ($resql && $this->db->affected_rows($resql) <= 0) {
2104 $this->db->rollback();
2105 $langs->load(
"receptions");
2106 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionValidatedShort'));
2107 dol_syslog(get_class($this).
"::setClosed reception is not validated in database", LOG_WARNING);
2112 if ($this->origin ==
'order_supplier' && $this->origin_id > 0) {
2113 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
2116 $order->fetch($this->origin_id);
2118 $order->loadReceptions(self::STATUS_CLOSED);
2120 $receptions_match_order = 1;
2121 foreach ($order->lines as $line) {
2122 $lineid = $line->id;
2124 if (($line->product_type == 0 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && $order->receptions[$lineid] < $qty) {
2125 $receptions_match_order = 0;
2126 $text =
'Qty for order line id '.$lineid.
' is '.$qty.
'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.
' we have qty = '.$order->receptions[$lineid].
', so we can t close order';
2131 if ($receptions_match_order) {
2132 dol_syslog(
"Qty for the ".count($order->lines).
" lines of order have same value for receptions with status Reception::STATUS_CLOSED=".self::STATUS_CLOSED.
', so we close order');
2133 $order->Livraison($user,
dol_now(),
'tot',
'Reception '.$this->
ref);
2137 $this->statut = self::STATUS_CLOSED;
2138 $this->
status = self::STATUS_CLOSED;
2142 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2144 $langs->load(
"agenda");
2148 $sql =
"SELECT cd.fk_product, cd.subprice,";
2149 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2150 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2151 $sql .=
" ed.fk_elementdet, ed.cost_price";
2152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2153 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2154 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2155 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2157 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2158 $resql = $this->db->query($sql);
2161 $cpt = $this->db->num_rows($resql);
2162 for ($i = 0; $i < $cpt; $i++) {
2163 $obj = $this->db->fetch_object($resql);
2167 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2171 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid);
2174 $mouvS->origin = &$this;
2175 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2177 if (empty($obj->batch)) {
2181 $inventorycode =
'';
2182 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionClassifyClosedInDolibarr", $this->ref),
'',
'',
'',
'', 0, $inventorycode);
2184 $this->error = $mouvS->error;
2185 $this->errors = $mouvS->errors;
2193 $inventorycode =
'';
2194 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionClassifyClosedInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch,
'', 0, $inventorycode);
2197 $this->error = $mouvS->error;
2198 $this->errors = $mouvS->errors;
2205 $this->error = $this->db->lasterror();
2212 $result = $this->call_trigger(
'RECEPTION_CLOSED', $user);
2223 $this->db->commit();
2226 $this->statut = self::STATUS_VALIDATED;
2227 $this->
status = self::STATUS_VALIDATED;
2228 $this->db->rollback();
2245 if ($this->statut == Reception::STATUS_VALIDATED) {
2250 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET billed=1';
2251 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2253 $resql = $this->db->query($sql);
2258 $result = $this->call_trigger(
'RECEPTION_BILLED', $user);
2265 $this->errors[] = $this->db->lasterror;
2268 if (empty($error)) {
2269 $this->db->commit();
2272 $this->db->rollback();
2284 global $langs, $user;
2289 if ($this->statut != self::STATUS_CLOSED) {
2290 $langs->load(
"receptions");
2291 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionProcessedShort'));
2297 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut=1, billed=0';
2298 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut = '.self::STATUS_CLOSED;
2300 $resql = $this->db->query($sql);
2301 $rollbackStatus = $this->status;
2302 $rollbackBilled = $this->billed;
2304 if ($this->db->affected_rows($resql) <= 0) {
2306 $this->db->rollback();
2307 $langs->load(
"receptions");
2308 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionProcessedShort'));
2311 $this->statut = self::STATUS_VALIDATED;
2312 $this->
status = self::STATUS_VALIDATED;
2317 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2319 $langs->load(
"agenda");
2323 $sql =
"SELECT ed.fk_product, cd.subprice,";
2324 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2325 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2326 $sql .=
" ed.fk_elementdet, ed.cost_price";
2327 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2328 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2329 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2330 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2332 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2333 $resql = $this->db->query($sql);
2335 $cpt = $this->db->num_rows($resql);
2336 for ($i = 0; $i < $cpt; $i++) {
2337 $obj = $this->db->fetch_object($resql);
2341 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2344 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid);
2348 $mouvS->origin = &$this;
2349 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2351 if (empty($obj->batch)) {
2355 $inventorycode =
'';
2356 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionUnClassifyCloseddInDolibarr", $numref),
'',
'',
'',
'', 0, $inventorycode);
2359 $this->error = $mouvS->error;
2360 $this->errors = $mouvS->errors;
2368 $inventorycode =
'';
2369 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionUnClassifyCloseddInDolibarr", $numref),
'', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, 0, $inventorycode);
2371 $this->error = $mouvS->error;
2372 $this->errors = $mouvS->errors;
2379 $this->error = $this->db->lasterror();
2386 $result = $this->call_trigger(
'RECEPTION_REOPEN', $user);
2392 if (!$error && $this->origin ==
'order_supplier') {
2393 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
2396 $commande->fetch($this->origin_id);
2397 $result = $commande->setStatus($user, 4);
2400 $this->error = $commande->error;
2401 $this->errors = $commande->errors;
2406 $this->errors[] = $this->db->lasterror();
2410 $this->db->commit();
2413 $this->statut = $this->
status = $rollbackStatus;
2414 $this->billed = $rollbackBilled;
2415 $this->db->rollback();
2434 if ($this->statut <= self::STATUS_DRAFT) {
2438 if (!((!
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer'))
2439 || (
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')))) {
2440 $this->error =
'Permission denied';
2446 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
2447 $sql .=
" SET fk_statut = ".self::STATUS_DRAFT;
2448 $sql .=
" WHERE rowid = ".((int) $this->
id);
2449 $sql .=
" AND fk_statut = ".((int) $this->statut);
2452 $resql = $this->db->query($sql);
2453 if ($resql && $this->db->affected_rows($resql) <= 0) {
2455 $this->db->rollback();
2456 $langs->load(
"receptions");
2457 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv($this->statut == self::STATUS_CLOSED ?
'StatusReceptionProcessedShort' :
'StatusReceptionValidatedShort'));
2463 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2465 $langs->load(
"agenda");
2469 $sql =
"SELECT cd.fk_product, cd.subprice,";
2470 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2471 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2472 $sql .=
" ed.fk_elementdet, ed.cost_price";
2473 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2474 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2475 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2476 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2478 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2479 $resql = $this->db->query($sql);
2481 $cpt = $this->db->num_rows($resql);
2482 for ($i = 0; $i < $cpt; $i++) {
2483 $obj = $this->db->fetch_object($resql);
2487 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2491 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid);
2495 $mouvS->origin = &$this;
2496 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2498 if (empty($obj->batch)) {
2502 $inventorycode =
'';
2503 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionBackToDraftInDolibarr", $this->ref),
'',
'',
'',
'', 0, $inventorycode);
2505 $this->error = $mouvS->error;
2506 $this->errors = $mouvS->errors;
2514 $inventorycode =
'';
2515 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionBackToDraftInDolibarr", $this->ref),
'', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, 0, $inventorycode);
2517 $this->error = $mouvS->error;
2518 $this->errors = $mouvS->errors;
2525 $this->error = $this->db->lasterror();
2532 $result = $this->call_trigger(
'RECEPTION_UNVALIDATE', $user);
2537 if ($this->origin ==
'order_supplier') {
2538 if (!empty($this->origin) && $this->origin_id > 0) {
2540 if ($this->origin_object->statut == 4) {
2542 $this->origin_object->fetchObjectLinked();
2544 if (!empty($this->origin_object->linkedObjects[
'reception'])) {
2545 foreach ($this->origin_object->linkedObjects[
'reception'] as $rcption) {
2546 if ($rcption->statut > 0) {
2553 $this->origin_object->setStatut(3);
2561 $this->statut = self::STATUS_DRAFT;
2562 $this->
status = self::STATUS_DRAFT;
2563 $this->db->commit();
2566 $this->db->rollback();
2570 $this->error = $this->db->error();
2571 $this->db->rollback();
2586 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2588 global
$conf, $langs;
2590 $langs->load(
"receptions");
2593 $modele =
'squille';
2595 if ($this->model_pdf) {
2596 $modele = $this->model_pdf;
2602 $modelpath =
"core/modules/reception/doc/";
2604 if (!empty($this->origin) && $this->origin_id > 0) {
2608 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2621 $tables = array(
'reception');
2637 'receptiondet_batch'
Class to manage table ReceptionLineBatch.
Class to manage predefined suppliers products.
const STATUS_RECEIVED_PARTIALLY
Received partially.
const STATUS_RECEIVED_COMPLETELY
Received completely.
Class to manage line orders.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true)
Save a new position (field rang) for details lines.
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='')
Set status of an object.
add_object_linked($origin=null, $origin_id=null, $f_user=null, $notrigger=0)
Add an object link into llx_element_element.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
setErrorsFromObject($object)
setErrorsFromObject
updateRangOfLine($rowid, $rang)
Update position of line (rang)
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
static commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a product id with another one.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
fetch_origin()
Read linked origin object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage Dolibarr database access.
Class to manage stock movements.
Class to manage products or services.
static checkSellOrEatByMandatoryFromProductAndDates($product, $sellBy, $eatBy, $onlyFieldName='', $alreadyCheckConf=false)
Check sell or eat by date is mandatory from product and sell-by and eat-by dates.
Class to manage receptions.
setBilled()
Classify the reception as invoiced (used for example by trigger when WORKFLOW_RECEPTION_CLASSIFY_BILL...
fetch_delivery_methods()
Fetch deliveries method and return an array.
getLibStatut($mode=0)
Return status label.
valid($user, $notrigger=0)
Validate object and update stock if option enabled.
updatelinefree($rowid, $qty, $element_type, $fk_product, $fk_unit, $rang, $description, $notrigger, $array_options=array())
Update a simple reception line.
getUrlTrackingStatus($value='')
Forge an set tracking url.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
getLinesArray()
Create an array of reception lines.
fetch_lines_free()
Load lines of simple reception.
update($user=null, $notrigger=0)
Update database.
deleteLine($user, $lineid)
Delete a line of the reception.
setClosed()
Classify the reception as closed (this records also the stock movement)
static replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a product id with another one.
LibStatut($status, $mode)
Return label of a status.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create a document onto disk according to template module.
getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0)
Return clickable link of object (with eventually picto)
create_line($entrepot_id, $origin_line_id, $qty, $rang=0, $array_options=[], $parent_line_id=0, $product_id=0)
Create a reception line.
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
list_delivery_methods($id=0)
Fetch all deliveries method and return an array.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
__construct($db)
Constructor.
addlinefree($qty, $element_type, $fk_product, $fk_unit, $rang, $description, $array_options=[])
Add a simple reception line.
initAsSpecimen()
Initialise an instance with random values.
setReceptionDate($user, $reception_date)
Set the reception date.
create($user, $notrigger=0)
Create reception.
fetch($id, $ref='', $ref_ext='')
Get object and lines from database.
reOpen()
Classify the reception as validated/opened.
getStatusDispatch()
Get status from all dispatched lines.
addline($entrepot_id, $id, $qty, $array_options=[], $comment='', $eatby=null, $sellby=null, $batch='', $cost_price=0)
Add an reception line.
setDraft($user)
Set draft status.
Class to manage table commandefournisseurdispatch.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
setEntity($currentobject)
Set entity id to use when to create an object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
$conf db user
Active Directory does not allow anonymous connections.