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_DRAFT = 0;
223 const STATUS_VALIDATED = 1;
224 const STATUS_CLOSED = 2;
236 $this->ismultientitymanaged = 1;
237 $this->isextrafieldmanaged = 1;
246 public function getNextNumRef($soc)
248 global $langs, $conf;
249 $langs->load(
"receptions");
258 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
260 foreach ($dirmodels as $reldir) {
264 $mybool = ((bool) @include_once $dir.$file) || $mybool;
272 $obj =
new $classname();
273 '@phan-var-force ModelNumRefReception $obj';
276 $numref = $obj->getNextValue($soc, $this);
281 dol_print_error($this->db, get_class($this).
"::getNextNumRef ".$obj->error);
285 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_RECEPTION_ADDON_NUMBER_NotDefined");
297 public function create($user, $notrigger = 0)
303 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
308 if (empty($this->fk_project)) {
309 $this->fk_project = 0;
311 if (empty($this->weight_units)) {
312 $this->weight_units = 0;
314 if (empty($this->size_units)) {
315 $this->size_units = 0;
317 if (empty($this->date_creation)) {
318 $this->date_creation = $now;
327 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"reception (";
330 $sql .=
", ref_supplier";
331 $sql .=
", date_creation";
332 $sql .=
", fk_user_author";
333 $sql .=
", date_reception";
334 $sql .=
", date_delivery";
336 $sql .=
", fk_projet";
337 $sql .=
", fk_shipping_method";
338 $sql .=
", tracking_number";
343 $sql .=
", weight_units";
344 $sql .=
", size_units";
345 $sql .=
", note_private";
346 $sql .=
", note_public";
347 $sql .=
", model_pdf";
348 $sql .=
", fk_incoterms, location_incoterms";
349 $sql .=
") VALUES (";
351 $sql .=
", ".((int) $this->entity);
352 $sql .=
", ".($this->ref_supplier ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null");
353 $sql .=
", '".$this->db->idate($this->date_creation).
"'";
354 $sql .=
", ".((int) $user->id);
355 $sql .=
", ".($this->date_reception > 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
"null");
356 $sql .=
", ".($this->date_delivery > 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
357 $sql .=
", ".($this->socid > 0 ? ((int) $this->socid) :
"null");
358 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
359 $sql .=
", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) :
"null");
360 $sql .=
", '".$this->db->escape($this->tracking_number).
"'";
361 $sql .=
", ".(is_null($this->weight) ?
"NULL" : ((float) $this->weight));
362 $sql .=
", ".(is_null($this->trueDepth) ?
"NULL" : ((float) $this->trueDepth));
363 $sql .=
", ".(is_null($this->trueWidth) ?
"NULL" : ((float) $this->trueWidth));
364 $sql .=
", ".(is_null($this->trueHeight) ?
"NULL" : ((float) $this->trueHeight));
365 $sql .=
", ".((int) $this->weight_units);
366 $sql .=
", ".((int) $this->size_units);
367 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
368 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
369 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
370 $sql .=
", ".(int) $this->fk_incoterms;
371 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
374 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
376 $resql = $this->db->query($sql);
379 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"reception");
382 $initialref =
'(PROV'.$this->id.
')';
383 if (!empty($this->
ref)) {
384 $initialref = $this->ref;
387 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
388 $sql .=
" SET ref = '".$this->db->escape($initialref).
"'";
389 $sql .=
" WHERE rowid = ".((int) $this->
id);
391 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
392 if ($this->db->query($sql)) {
394 $num = count($this->lines);
395 for ($i = 0; $i < $num; $i++) {
396 $this->lines[$i]->fk_reception = $this->id;
398 if ($this->lines[$i]->
create($user) <= 0) {
404 if (!$error && $this->
id && $this->origin_id) {
419 if (!$error && !$notrigger) {
421 $result = $this->call_trigger(
'RECEPTION_CREATE', $user);
432 foreach ($this->errors as $errmsg) {
433 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
434 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
436 $this->db->rollback();
441 $this->error = $this->db->lasterror().
" - sql=$sql";
442 $this->db->rollback();
447 $this->error = $this->db->error().
" - sql=$sql";
448 $this->db->rollback();
466 public function create_line($entrepot_id, $origin_line_id, $qty, $rang = 0, $array_options = [], $parent_line_id = 0, $product_id = 0)
472 $receptionline->fk_reception = $this->id;
473 $receptionline->entrepot_id = $entrepot_id;
474 $receptionline->fk_elementdet = $origin_line_id;
475 $receptionline->element_type = $this->origin;
476 $receptionline->fk_parent = $parent_line_id;
477 $receptionline->fk_product = $product_id;
478 $receptionline->qty = $qty;
479 $receptionline->rang = $rang;
480 $receptionline->array_options = $array_options;
482 if (!($receptionline->fk_product > 0)) {
484 $order_line->fetch($receptionline->fk_elementdet);
485 $receptionline->fk_product = $order_line->fk_product;
488 if (($lineId = $receptionline->insert($user)) < 0) {
489 $this->errors[] = $receptionline->error;
502 public function fetch($id, $ref =
'', $ref_ext =
'')
505 if (empty($id) && empty($ref) && empty($ref_ext)) {
509 $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";
510 $sql .=
", e.fk_user_valid";
511 $sql .=
", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
512 $sql .=
", e.date_reception as date_reception, e.model_pdf, e.date_delivery, e.date_valid";
513 $sql .=
", e.fk_shipping_method, e.tracking_number";
514 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
515 $sql .=
", e.note_private, e.note_public";
516 $sql .=
', e.fk_incoterms, e.location_incoterms';
517 $sql .=
', i.libelle as label_incoterms';
518 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception as e";
519 $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'";
520 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON e.fk_incoterms = i.rowid';
523 $sql .=
" WHERE e.rowid = ".((int) $id);
525 $sql .=
" WHERE e.entity IN (".getEntity(
'reception').
")";
527 $sql .=
" AND e.ref = '".$this->db->escape($ref).
"'";
528 } elseif ($ref_ext) {
529 $sql .=
" AND e.ref_ext = '".$this->db->escape($ref_ext).
"'";
533 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
534 $result = $this->db->query($sql);
536 if ($this->db->num_rows($result)) {
537 $obj = $this->db->fetch_object($result);
539 $this->
id = $obj->rowid;
540 $this->entity = $obj->entity;
541 $this->
ref = $obj->ref;
542 $this->socid = $obj->socid;
543 $this->ref_supplier = $obj->ref_supplier;
544 $this->ref_ext = $obj->ref_ext;
545 $this->statut = $obj->status;
546 $this->
status = $obj->status;
547 $this->billed = $obj->billed;
548 $this->fk_project = $obj->fk_project;
549 $this->user_author_id = $obj->fk_user_author;
550 $this->fk_user_author = $obj->fk_user_author;
551 $this->fk_user_valid = $obj->fk_user_valid;
552 $this->date_creation = $this->db->jdate($obj->date_creation);
553 $this->
date = $this->db->jdate($obj->date_reception);
554 $this->date_reception = $this->db->jdate($obj->date_reception);
555 $this->date_delivery = $this->db->jdate($obj->date_delivery);
556 $this->date_valid = $this->db->jdate($obj->date_valid);
557 $this->model_pdf = $obj->model_pdf;
558 $this->shipping_method_id = $obj->fk_shipping_method;
559 $this->tracking_number = $obj->tracking_number;
560 $this->origin = ($obj->origin ? $obj->origin : ($obj->origin_id > 0 ?
'commande' :
''));
561 $this->origin_type = ($obj->origin ? $obj->origin : ($obj->origin_id > 0 ?
'commande' :
''));
562 $this->origin_id = $obj->origin_id;
564 $this->trueWeight = $obj->weight;
565 $this->weight_units = $obj->weight_units;
567 $this->trueWidth = $obj->width;
568 $this->width_units = $obj->size_units;
569 $this->trueHeight = $obj->height;
570 $this->height_units = $obj->size_units;
571 $this->trueDepth = $obj->size;
572 $this->depth_units = $obj->size_units;
574 $this->note_public = $obj->note_public;
575 $this->note_private = $obj->note_private;
578 $this->trueSize = $obj->size.
"x".$obj->width.
"x".$obj->height;
579 $this->size_units = $obj->size_units;
582 $this->fk_incoterms = $obj->fk_incoterms;
583 $this->location_incoterms = $obj->location_incoterms;
584 $this->label_incoterms = $obj->label_incoterms;
586 $this->db->free($result);
602 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
604 $extrafields->fetch_name_optionals_label($this->table_element,
true);
610 if (empty($obj->origin_id)) {
621 dol_syslog(get_class($this).
'::Fetch no reception found', LOG_ERR);
622 $this->error =
'Reception with id '.$id.
' not found';
626 $this->error = $this->db->error();
638 public function valid($user, $notrigger = 0)
640 global $conf, $langs;
642 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
648 dol_syslog(get_class($this).
"::valid no draft status", LOG_WARNING);
652 if (!((!
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer'))
653 || (
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')))) {
654 $this->error =
'Permission denied';
655 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
665 $soc->fetch($this->socid);
669 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
670 $numref = $this->getNextNumRef($soc);
672 $numref = (string) $this->
ref;
680 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
681 $sql .=
" ref='".$this->db->escape($numref).
"'";
682 $sql .=
", fk_statut = 1";
683 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
684 $sql .=
", fk_user_valid = ".((int) $user->id);
685 $sql .=
" WHERE rowid = ".((int) $this->
id);
686 dol_syslog(get_class($this).
"::valid update reception", LOG_DEBUG);
687 $resql = $this->db->query($sql);
689 $this->error = $this->db->lasterror();
695 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
697 $langs->load(
"agenda");
701 $sql =
"SELECT cd.fk_product, cd.subprice, cd.remise_percent,";
702 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
703 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
704 $sql .=
" ed.fk_elementdet, ed.cost_price";
705 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
706 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
707 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
708 $sql .=
" AND cd.rowid = ed.fk_elementdet";
710 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
711 $resql = $this->db->query($sql);
713 $cpt = $this->db->num_rows($resql);
714 for ($i = 0; $i < $cpt; $i++) {
715 $obj = $this->db->fetch_object($resql);
719 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
723 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid);
727 $mouvS->origin = &$this;
728 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
730 if (empty($obj->batch)) {
735 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionValidatedInDolibarr", $numref),
'',
'',
'',
'', 0, $inventorycode);
737 if (intval($result) < 0) {
748 $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);
750 if (intval($result) < 0) {
758 $this->db->rollback();
759 $this->error = $this->db->error();
764 if (!$error && $this->origin_id > 0) {
772 $ret = $this->origin_object->Livraison($user,
dol_now(),
'tot',
'');
775 $this->errors = array_merge($this->errors, $this->origin_object->errors);
778 $ret = $this->
setStatut($status, $this->origin_id,
'commande_fournisseur', $trigger_key);
786 if (!$error && !$notrigger) {
788 $result = $this->call_trigger(
'RECEPTION_VALIDATE', $user);
796 $this->oldref = $this->ref;
799 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
801 $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).
"'";
802 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'reception/".$this->db->escape($this->
ref).
"' AND entity = ".((int) $conf->entity);
803 $resql = $this->db->query($sql);
806 $this->error = $this->db->lasterror();
808 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'reception/".$this->db->escape($this->newref).
"'";
809 $sql .=
" WHERE filepath = 'reception/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
810 $resql = $this->db->query($sql);
813 $this->error = $this->db->lasterror();
819 $dirsource = $conf->reception->dir_output.
'/'.$oldref;
820 $dirdest = $conf->reception->dir_output.
'/'.$newref;
821 if (!$error && file_exists($dirsource)) {
822 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
824 if (@rename($dirsource, $dirdest)) {
827 $listoffiles =
dol_dir_list($conf->reception->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
828 foreach ($listoffiles as $fileentry) {
829 $dirsource = $fileentry[
'name'];
830 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
831 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
832 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
833 @rename($dirsource, $dirdest);
842 $this->
ref = $numref;
843 $this->statut = self::STATUS_VALIDATED;
844 $this->
status = self::STATUS_VALIDATED;
851 foreach ($this->errors as $errmsg) {
852 dol_syslog(get_class($this).
"::valid ".$errmsg, LOG_ERR);
853 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
855 $this->db->rollback();
867 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
868 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
872 if (!empty($this->origin) && $this->origin_id > 0 && ($this->origin ==
'order_supplier' || $this->origin ==
'commandeFournisseur')) {
873 if (empty($this->origin_object)) {
875 if ($this->origin_object instanceof
CommonObject && empty($this->origin_object->lines)) {
876 $res = $this->origin_object->fetch_lines();
877 $this->commandeFournisseur =
null;
881 } elseif ($this->origin_object instanceof
CommandeFournisseur && empty($this->origin_object->lines)) {
882 $res = $this->origin_object->fetch_lines();
890 $qty_received = array();
891 $qty_wished = array();
894 $filter = array(
't.fk_element' => $this->origin_id);
896 $filter[
't.status'] = 1;
899 $ret = $supplierorderdispatch->fetchAll(
'',
'', 0, 0, $filter);
905 $draft_lines = array();
906 $sql =
"SELECT rb.rowid FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as rb";
907 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"reception as r ON r.rowid = rb.fk_reception";
908 $sql .=
" WHERE rb.fk_element = ".((int) $this->origin_id);
909 $sql .=
" AND r.fk_statut = ".self::STATUS_DRAFT;
910 $resql = $this->db->query($sql);
912 $this->error = $this->db->lasterror();
915 while ($obj = $this->db->fetch_object($resql)) {
916 $draft_lines[(int) $obj->rowid] = (
int) $obj->rowid;
918 $this->db->free($resql);
921 foreach ($supplierorderdispatch->lines as $dispatch_line) {
922 if (isset($draft_lines[(
int) $dispatch_line->id])) {
925 if (array_key_exists($dispatch_line->fk_product, $qty_received)) {
926 $qty_received[$dispatch_line->fk_product] += $dispatch_line->qty;
928 $qty_received[$dispatch_line->fk_product] = $dispatch_line->qty;
933 foreach ($this->origin_object->lines as $origin_line) {
935 if ((!
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES') && $origin_line->product_type > 0) || $origin_line->product_type > 1) {
938 if (array_key_exists($origin_line->fk_product, $qty_wished)) {
939 $qty_wished[$origin_line->fk_product] += $origin_line->qty;
941 $qty_wished[$origin_line->fk_product] = $origin_line->qty;
946 $diff_array = array_diff_assoc($qty_received, $qty_wished);
947 $keys_in_wished_not_in_received = array_diff(array_keys($qty_wished), array_keys($qty_received));
948 $keys_in_received_not_in_wished = array_diff(array_keys($qty_received), array_keys($qty_wished));
950 if (count($diff_array) == 0 && count($keys_in_wished_not_in_received) == 0 && count($keys_in_received_not_in_wished) == 0) {
956 if (count($diff_array) > 0) {
959 foreach ($diff_array as $key => $value) {
961 if ($qty_received[$key] >= $qty_wished[$key]) {
967 if ($close == count($diff_array)) {
994 public function addline($entrepot_id, $id, $qty, $array_options = [], $comment =
'', $eatby =
null, $sellby =
null, $batch =
'', $cost_price = 0)
996 global $conf, $langs, $user;
998 $num = count($this->lines);
1001 $line->fk_entrepot = $entrepot_id;
1002 $line->fk_commandefourndet = $id;
1006 $result = $supplierorderline->fetch($id);
1013 if (
isModEnabled(
'stock') && !empty($supplierorderline->fk_product)) {
1014 $fk_product = $supplierorderline->fk_product;
1016 if (!($entrepot_id > 0) && !
getDolGlobalInt(
'STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS')) {
1017 $langs->load(
"errors");
1018 $this->error = $langs->trans(
"ErrorWarehouseRequiredIntoReceptionLine");
1024 $product =
new Product($this->db);
1025 $product->fetch($fk_product);
1027 $langs->load(
"errors");
1028 if (!empty($product->status_batch) && empty($batch)) {
1029 $this->error = $langs->trans(
'ErrorProductNeedBatchNumber', $product->ref);
1031 } elseif (empty($product->status_batch) && !empty($batch)) {
1032 $this->error = $langs->trans(
'ErrorProductDoesNotNeedBatchNumber', $product->ref);
1038 if (!empty($errorMsgArr)) {
1039 $errorMessage =
'<b>' . $product->ref .
'</b> : ';
1040 $errorMessage .=
'<ul>';
1041 foreach ($errorMsgArr as $errorMsg) {
1042 $errorMessage .=
'<li>' . $errorMsg .
'</li>';
1044 $errorMessage .=
'</ul>';
1045 $this->error = $errorMessage;
1052 $line->array_options = $supplierorderline->array_options;
1053 if (!
getDolGlobalInt(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1054 foreach ($array_options as $key => $value) {
1055 $line->array_options[$key] = $value;
1059 $line->fk_product = $fk_product;
1060 $line->fk_commande = $supplierorderline->fk_commande;
1061 $line->fk_user = $user->id;
1062 $line->comment = $comment;
1063 $line->batch = $batch;
1064 $line->eatby = $eatby;
1065 $line->sellby = $sellby;
1067 $line->cost_price = $cost_price;
1068 $line->fk_reception = $this->id;
1070 $this->lines[$num] = $line;
1087 public function addlinefree($qty, $element_type, $fk_product, $fk_unit, $rang, $description, $array_options = [])
1089 global
$mysoc, $langs, $user;
1091 if ($this->
status == self::STATUS_DRAFT) {
1102 if ($ranktouse == -1) {
1103 $rangmax = $this->
line_max($this->fk_reception);
1104 $ranktouse = $rangmax + 1;
1109 $this->line->fk_reception = $this->id;
1110 $this->line->element_type = $element_type;
1111 $this->line->fk_product = $fk_product;
1112 $this->line->description = $description;
1114 $this->line->qty = (float) $qty;
1115 $this->line->fk_unit = $fk_unit;
1116 $this->line->rang = $ranktouse;
1118 if (is_array($array_options) && count($array_options) > 0) {
1119 $this->line->array_options = $array_options;
1122 $result = $this->line->insert($user);
1124 if (!isset($this->context[
'createfromclone'])) {
1125 if ($this->fk_reception) {
1127 } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) {
1128 $linecount = count($this->lines);
1129 for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
1133 $this->lines[] = $this->line;
1136 $this->db->commit();
1137 return $this->line->id;
1139 $this->error = $this->line->error;
1140 dol_syslog(get_class($this).
"::addlinefree error=".$this->error, LOG_ERR);
1141 $this->db->rollback();
1145 dol_syslog(get_class($this).
"::addlinefree status of reception must be Draft to allow use of ->addlinefree()", LOG_ERR);
1164 public function updatelinefree($rowid, $qty, $element_type, $fk_product, $fk_unit, $rang, $description, $notrigger, $array_options = array())
1166 global
$mysoc, $langs, $user;
1168 if ($this->statut == self::STATUS_DRAFT) {
1178 $qty = (float) $qty;
1179 $description = trim((
string) $description);
1184 $line->fetch($rowid);
1185 $line->fetch_optionals();
1187 if (!empty($line->fk_product)) {
1188 $product =
new Product($this->db);
1189 $result = $product->fetch($line->fk_product);
1190 $product_type = $product->type;
1193 $staticline = clone $line;
1195 $line->oldline = $staticline;
1196 $this->line = $line;
1197 $this->line->context = $this->context;
1198 $this->line->rang = $rang;
1199 $this->line->fk_reception = $this->id;
1200 $this->line->element_type = $element_type;
1201 $this->line->fk_product = $line->fk_product;
1202 $this->line->qty = $qty;
1203 $this->line->fk_unit = $fk_unit;
1204 $this->line->description = $description;
1206 if (is_array($array_options) && count($array_options) > 0) {
1208 foreach ($array_options as $key => $value) {
1209 $this->line->array_options[$key] = $array_options[$key];
1214 $result = $this->line->update($user, $notrigger);
1219 $this->db->commit();
1222 $this->error = $this->line->error;
1224 $this->db->rollback();
1228 $this->error = get_class($this).
"::updatelinefree reception status makes operation forbidden";
1229 $this->errors = array(
'ReceptionStatusMakeOperationForbidden');
1245 $this->lines = array();
1247 $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';
1248 $sql .=
' FROM '.MAIN_DB_PREFIX.
'receptiondet_batch as rc';
1249 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON (p.rowid = rc.fk_product)';
1250 $sql .=
' WHERE rc.fk_reception = '.((int) $this->
id);
1252 $sql .=
' ORDER BY rc.rang, rc.rowid';
1254 dol_syslog(get_class($this).
"::fetch_lines_free", LOG_DEBUG);
1255 $result = $this->db->query($sql);
1257 $num = $this->db->num_rows($result);
1261 $objp = $this->db->fetch_object($result);
1265 $line->rowid = $objp->rowid;
1266 $line->id = $objp->rowid;
1267 $line->fk_reception = $this->id;
1269 $line->description = $objp->description;
1270 $line->qty = $objp->qty;
1271 $line->fk_entrepot = $objp->fk_entrepot;
1272 $line->fk_product = $objp->fk_product;
1274 $line->rang = $objp->rang;
1277 $line->fk_element = $objp->fk_element;
1278 $line->fk_unit = $objp->fk_unit;
1279 $line->fk_elementdet = $objp->fk_elementdet;
1280 $line->fk_element_type = $objp->element_type;
1281 $line->fetch_optionals();
1285 $this->lines[$i] = $line;
1290 $this->db->free($result);
1294 $this->error = $this->db->error();
1316 public function update($user =
null, $notrigger = 0)
1323 if (isset($this->
ref)) {
1324 $this->
ref = trim($this->
ref);
1326 if (isset($this->entity)) {
1327 $this->entity = (int) $this->entity;
1329 if (isset($this->ref_supplier)) {
1330 $this->ref_supplier = trim($this->ref_supplier);
1332 if (isset($this->socid)) {
1333 $this->socid = (int) trim((
string) $this->socid);
1335 if (isset($this->fk_user_author)) {
1336 $this->fk_user_author = (int) $this->fk_user_author;
1338 if (isset($this->fk_user_valid)) {
1339 $this->fk_user_valid = (int) $this->fk_user_valid;
1341 if (isset($this->shipping_method_id)) {
1342 $this->shipping_method_id = (int) $this->shipping_method_id;
1344 if (isset($this->tracking_number)) {
1345 $this->tracking_number = trim($this->tracking_number);
1347 if (isset($this->statut)) {
1348 $this->statut = (int) $this->statut;
1350 if (isset($this->trueDepth)) {
1351 $this->trueDepth =
price2num($this->trueDepth);
1353 if (isset($this->trueWidth)) {
1354 $this->trueWidth =
price2num($this->trueWidth);
1356 if (isset($this->trueHeight)) {
1357 $this->trueHeight =
price2num($this->trueHeight);
1359 $this->size_units = (int) $this->size_units;
1361 if (isset($this->trueWeight)) {
1362 $this->weight =
price2num($this->trueWeight);
1364 $this->weight_units = (int) $this->weight_units;
1366 if (isset($this->note_private)) {
1367 $this->note_private = trim($this->note_private);
1369 if (isset($this->note_public)) {
1370 $this->note_public = trim($this->note_public);
1372 if (isset($this->model_pdf)) {
1373 $this->model_pdf = trim($this->model_pdf);
1381 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
1383 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"null").
",";
1384 $sql .=
" ref_supplier=".(isset($this->ref_supplier) ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null").
",";
1385 $sql .=
" fk_soc=".(isset($this->socid) ? $this->socid :
"null").
",";
1386 $sql .=
" date_creation=".(dol_strlen($this->date_creation) != 0 ?
"'".$this->db->idate($this->date_creation).
"'" :
'null').
",";
1387 $sql .=
" fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author :
"null").
",";
1388 $sql .=
" date_valid=".(dol_strlen($this->date_valid) != 0 ?
"'".$this->db->idate($this->date_valid).
"'" :
'null').
",";
1389 $sql .=
" fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid :
"null").
",";
1390 $sql .=
" date_reception=".(dol_strlen($this->date_reception) != 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
'null').
",";
1391 $sql .=
" date_delivery=".(dol_strlen($this->date_delivery) != 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
'null').
",";
1392 $sql .=
" fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id :
"null").
",";
1393 $sql .=
" tracking_number=".(isset($this->tracking_number) ?
"'".$this->db->escape($this->tracking_number).
"'" :
"null").
",";
1394 $sql .=
" fk_statut=".(isset($this->statut) ? $this->statut :
"null").
",";
1395 $sql .=
" height=".(($this->trueHeight !=
'') ? (
float) $this->trueHeight :
"null").
",";
1396 $sql .=
" width=".(($this->trueWidth !=
'') ? (
float) $this->trueWidth :
"null").
",";
1397 $sql .=
" size_units=".((int) $this->size_units).
",";
1398 $sql .=
" size=".(($this->trueDepth !=
'') ? (
float) $this->trueDepth :
"null").
",";
1399 $sql .=
" weight_units=".((int) $this->weight_units).
",";
1400 $sql .=
" weight=".(($this->trueWeight !=
'') ? (
float) $this->trueWeight :
"null").
",";
1401 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1402 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1403 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1404 $sql .=
" fk_projet=".((isset($this->fk_project) && $this->fk_project > 0) ? ((
int) $this->fk_project) :
"null").
",";
1405 $sql .=
" entity = ".((int) $conf->entity);
1406 $sql .=
" WHERE rowid=".((int) $this->
id);
1410 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1411 $resql = $this->db->query($sql);
1414 $this->errors[] =
"Error ".$this->db->lasterror();
1420 $result = $this->call_trigger(
'RECEPTION_MODIFY', $user);
1430 foreach ($this->errors as $errmsg) {
1431 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1432 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1434 $this->db->rollback();
1437 $this->db->commit();
1448 public function delete(
User $user)
1450 global $conf, $langs, $user;
1451 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1461 || (
getDolGlobalInt(
'STOCK_CALCULATE_ON_RECEPTION_CLOSE') && $this->
status == Reception::STATUS_CLOSED))
1463 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1465 $langs->load(
"agenda");
1468 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.eatby, ed.sellby, ed.batch, ed.rowid as receptiondet_batch_id";
1469 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
1470 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
1471 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
1472 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1474 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1475 $resql = $this->db->query($sql);
1477 $cpt = $this->db->num_rows($resql);
1478 for ($i = 0; $i < $cpt; $i++) {
1479 dol_syslog(get_class($this).
"::delete movement index ".$i);
1480 $obj = $this->db->fetch_object($resql);
1483 if ($obj->qty == 0 || ($obj->qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
1489 $mouvS->origin =
null;
1491 $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);
1494 $this->error = $mouvS->error;
1495 $this->errors = $mouvS->errors;
1500 $this->errors[] =
"Error ".$this->db->lasterror();
1505 $main = MAIN_DB_PREFIX.
'receptiondet_batch';
1506 $ef = $main.
"_extrafields";
1508 $sqlef =
"DELETE FROM ".$ef.
" WHERE fk_object IN (SELECT rowid FROM ".$main.
" WHERE fk_reception = ".((int) $this->
id).
")";
1510 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"receptiondet_batch";
1511 $sql .=
" WHERE fk_reception = ".((int) $this->
id);
1513 if ($this->db->query($sqlef) && $this->db->query($sql)) {
1521 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"reception";
1522 $sql .=
" WHERE rowid = ".((int) $this->
id);
1524 if ($this->db->query($sql)) {
1526 $result = $this->call_trigger(
'RECEPTION_DELETE', $user);
1532 if (!empty($this->origin) && $this->origin_id > 0) {
1535 '@phan-var-force CommandeFournisseur $origin_object';
1548 $this->db->commit();
1552 if (!empty($conf->reception->dir_output)) {
1553 $dir = $conf->reception->dir_output.
'/'.$ref;
1554 $file = $dir.
'/'.$ref.
'.pdf';
1555 if (file_exists($file)) {
1560 if (file_exists($dir)) {
1562 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1570 $this->db->rollback();
1574 $this->error = $this->db->lasterror().
" - sql=$sql";
1575 $this->db->rollback();
1579 $this->error = $this->db->lasterror().
" - sql=$sql";
1580 $this->db->rollback();
1584 $this->error = $this->db->lasterror().
" - sql=$sql";
1585 $this->db->rollback();
1589 $this->db->rollback();
1603 if ($this->
status != self::STATUS_DRAFT) {
1604 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
1609 if ($line->fetch($lineid) <= 0) {
1610 $this->error =
'ErrorRecordNotFound';
1613 if ($line->fk_reception != $this->id) {
1614 $this->error =
'ErrorLineIDDoesNotMatchWithObjectID';
1619 if ($line->delete($user) > 0) {
1620 $this->db->commit();
1623 $this->error = $line->error;
1624 $this->db->rollback();
1637 $this->lines = array();
1639 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
1641 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"receptiondet_batch";
1642 $sql .=
" WHERE fk_reception = ".((int) $this->
id);
1644 $resql = $this->db->query($sql);
1646 if (!empty($resql)) {
1647 while ($obj = $this->db->fetch_object($resql)) {
1650 $line->fetch($obj->rowid);
1653 $line->fetch_product();
1655 $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';
1656 $sql_commfourndet .=
' FROM '.MAIN_DB_PREFIX.
'commande_fournisseurdet';
1657 $sql_commfourndet .=
' WHERE rowid = '.((int) $line->fk_commandefourndet);
1658 $sql_commfourndet .=
' ORDER BY rang';
1660 $resql_commfourndet = $this->db->query($sql_commfourndet);
1661 if (!empty($resql_commfourndet)) {
1662 $obj = $this->db->fetch_object($resql_commfourndet);
1663 $line->qty_asked = $obj->qty;
1664 $line->description = $obj->description;
1665 $line->desc = $obj->description;
1666 $line->tva_tx = $obj->tva_tx;
1667 $line->vat_src_code = $obj->vat_src_code;
1668 $line->localtax1_tx = $obj->localtax1_tx;
1669 $line->localtax2_tx = $obj->localtax2_tx;
1670 $line->subprice = $obj->subprice;
1671 $line->multicurrency_subprice = $obj->multicurrency_subprice;
1672 $line->remise_percent = $obj->remise_percent;
1673 $line->label = !empty($obj->label) ? $obj->label : (is_object($line->product) ? $line->product->label :
'');
1674 $line->ref_supplier = $obj->ref;
1675 $line->total_ht = $obj->total_ht;
1676 $line->total_ttc = $obj->total_ttc;
1677 $line->total_tva = $obj->total_tva;
1678 $line->date_start = $this->db->jdate($obj->date_start);
1679 $line->date_end = $this->db->jdate($obj->date_end);
1680 $line->product_type = $obj->product_type;
1682 $line->qty_asked = 0;
1683 $line->description =
'';
1685 $line->label = $obj->label;
1688 $pu_ht = ($line->subprice * $line->qty) * (100 - $line->remise_percent) / 100;
1689 $tva = $pu_ht * $line->tva_tx / 100;
1690 $this->total_ht += $pu_ht;
1691 $this->total_tva += $pu_ht * $line->tva_tx / 100;
1693 $this->total_ttc += $pu_ht + $tva;
1695 if (
isModEnabled(
'productbatch') && !empty($line->batch)) {
1697 $detail_batch->eatby = $line->eatby;
1698 $detail_batch->sellby = $line->sellby;
1699 $detail_batch->batch = $line->batch;
1700 $detail_batch->qty = $line->qty;
1702 $line->detail_batch[] = $detail_batch;
1705 $this->lines[] = $line;
1724 public function getNomUrl($withpicto = 0, $option =
'', $max = 0, $short = 0, $notooltip = 0)
1726 global $langs, $hookmanager;
1729 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Reception").
'</u>';
1730 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1731 $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.($this->ref_supplier ? $this->ref_supplier :
'');
1733 $url = DOL_URL_ROOT.
'/reception/card.php?id='.$this->id;
1740 if (empty($notooltip)) {
1742 $label = $langs->trans(
"Reception");
1743 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1745 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
1746 $linkclose .=
' class="classfortooltip"';
1749 $linkstart =
'<a href="'.$url.
'"';
1750 $linkstart .= $linkclose.
'>';
1753 $result .= $linkstart;
1755 $result .=
img_object(($notooltip ?
'' : $label), $this->picto,
'', 0, 0, $notooltip ? 0 : 1);
1757 if ($withpicto != 2) {
1758 $result .= $this->ref;
1761 $result .= $linkend;
1764 $hookmanager->initHooks(array($this->element .
'dao'));
1765 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1766 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1768 $result = $hookmanager->resPrint;
1770 $result .= $hookmanager->resPrint;
1783 return $this->
LibStatut($this->statut, $mode);
1800 $this->labelStatus[-1] =
'StatusReceptionCanceled';
1801 $this->labelStatus[0] =
'StatusReceptionDraft';
1803 $this->labelStatus[1] =
'StatusReceptionValidated';
1805 $this->labelStatus[1] =
'StatusReceptionValidatedReceived';
1808 $this->labelStatus[1] =
'StatusReceptionValidatedToReceive';
1810 $this->labelStatus[2] =
'StatusReceptionProcessed';
1813 $this->labelStatusShort[-1] =
'StatusReceptionCanceledShort';
1814 $this->labelStatusShort[0] =
'StatusReceptionDraftShort';
1815 $this->labelStatusShort[1] =
'StatusReceptionValidatedShort';
1816 $this->labelStatusShort[2] =
'StatusReceptionProcessedShort';
1818 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
1819 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]);
1821 $statusType =
'status'.$status;
1822 if ($status == self::STATUS_VALIDATED) {
1823 $statusType =
'status4';
1825 if ($status == self::STATUS_CLOSED) {
1826 $statusType =
'status6';
1829 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
1841 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1843 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1844 $return .=
'<div class="info-box info-box-sm">';
1845 $return .=
'<div class="info-box-icon bg-infobox-action">';
1847 $return .=
'</div>';
1848 $return .=
'<div class="info-box-content">';
1849 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1850 if ($selected >= 0) {
1851 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1853 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1854 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1859 if (method_exists($this,
'getLibStatut')) {
1860 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1862 $return .=
'</div>';
1863 $return .=
'</div>';
1864 $return .=
'</div>';
1880 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1881 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
1884 dol_syslog(get_class($this).
"::initAsSpecimen");
1887 $order->initAsSpecimen();
1891 $this->
ref =
'SPECIMEN';
1892 $this->specimen = 1;
1896 $this->date_creation = $now;
1897 $this->date_valid = $now;
1898 $this->date_delivery = $now;
1899 $this->date_reception = $now + 24 * 3600;
1900 $this->entrepot_id = 0;
1902 $this->origin_id = 1;
1903 $this->origin_type =
'supplier_order';
1904 $this->origin_object = $order;
1905 $this->note_private =
'Private note';
1906 $this->note_public =
'Public note';
1907 $this->tracking_number =
'TRACKID-ABC123';
1908 $this->fk_incoterms = 1;
1911 while ($xnbp < $nbp) {
1913 $line->desc = $langs->trans(
"Description").
" ".$xnbp;
1914 $line->libelle = $langs->trans(
"Description").
" ".$xnbp;
1915 $line->label = $langs->trans(
"Description").
" ".$xnbp;
1918 $line->fk_product = $this->origin_object->lines[$xnbp]->fk_product;
1920 $this->lines[] = $line;
1937 if ($user->hasRight(
'reception',
'creer')) {
1938 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1939 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1940 $sql .=
" WHERE rowid = ".((int) $this->
id);
1942 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1943 $resql = $this->db->query($sql);
1945 $this->date_delivery = $delivery_date;
1948 $this->error = $this->db->error();
1965 if ($user->hasRight(
'reception',
'creer')) {
1966 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1967 $sql .=
" SET date_reception = ".($reception_date ?
"'".$this->db->idate($reception_date).
"'" :
'null');
1968 $sql .=
" WHERE rowid = ".((int) $this->
id);
1970 dol_syslog(get_class($this).
"::setReceptionDate", LOG_DEBUG);
1971 $resql = $this->db->query($sql);
1973 $this->date_reception = $reception_date;
1976 $this->error = $this->db->error();
1994 $this->meths = array();
1996 $sql =
"SELECT em.rowid, em.code, em.libelle";
1997 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
1998 $sql .=
" WHERE em.active = 1";
1999 $sql .=
" ORDER BY em.libelle ASC";
2001 $resql = $this->db->query($sql);
2003 while ($obj = $this->db->fetch_object($resql)) {
2004 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
2005 $this->meths[$obj->rowid] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
2022 $this->listmeths = array();
2025 $sql =
"SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
2026 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2028 $sql .=
" WHERE em.rowid = ".((int) $id);
2031 $resql = $this->db->query($sql);
2033 while ($obj = $this->db->fetch_object($resql)) {
2034 $this->listmeths[$i][
'rowid'] = $obj->rowid;
2035 $this->listmeths[$i][
'code'] = $obj->code;
2036 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
2037 $this->listmeths[$i][
'libelle'] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
2038 $this->listmeths[$i][
'description'] = $obj->description;
2039 $this->listmeths[$i][
'tracking'] = $obj->tracking;
2040 $this->listmeths[$i][
'active'] = $obj->active;
2054 if (!empty($this->shipping_method_id)) {
2055 $sql =
"SELECT em.code, em.tracking";
2056 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2057 $sql .=
" WHERE em.rowid = ".((int) $this->shipping_method_id);
2059 $resql = $this->db->query($sql);
2061 if ($obj = $this->db->fetch_object($resql)) {
2062 $tracking = $obj->tracking;
2067 if (!empty($tracking) && !empty($value)) {
2068 $url = str_replace(
'{TRACKID}', $value, $tracking);
2069 $this->tracking_url = sprintf(
'<a target="_blank" rel="noopener noreferrer" href="%s">%s</a>', $url, ($value ? $value :
'url'));
2071 $this->tracking_url = $value;
2082 global $conf, $langs, $user;
2087 if ($this->statut == Reception::STATUS_CLOSED) {
2088 dol_syslog(get_class($this).
"::setClosed already in closed status", LOG_WARNING);
2092 if ($this->statut != Reception::STATUS_VALIDATED) {
2093 $langs->load(
"receptions");
2094 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionValidatedShort'));
2095 dol_syslog(get_class($this).
"::setClosed reception is not validated", LOG_WARNING);
2101 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut = '.self::STATUS_CLOSED;
2102 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut = '.self::STATUS_VALIDATED;
2104 $resql = $this->db->query($sql);
2105 if ($resql && $this->db->affected_rows($resql) <= 0) {
2107 $this->db->rollback();
2108 $langs->load(
"receptions");
2109 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionValidatedShort'));
2110 dol_syslog(get_class($this).
"::setClosed reception is not validated in database", LOG_WARNING);
2115 if ($this->origin ==
'order_supplier' && $this->origin_id > 0) {
2116 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
2119 $order->fetch($this->origin_id);
2121 $order->loadReceptions(self::STATUS_CLOSED);
2123 $receptions_match_order = 1;
2124 foreach ($order->lines as $line) {
2125 $lineid = $line->id;
2127 if (($line->product_type == 0 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && $order->receptions[$lineid] < $qty) {
2128 $receptions_match_order = 0;
2129 $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';
2134 if ($receptions_match_order) {
2135 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');
2136 $order->Livraison($user,
dol_now(),
'tot',
'Reception '.$this->
ref);
2140 $this->statut = self::STATUS_CLOSED;
2141 $this->
status = self::STATUS_CLOSED;
2145 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2147 $langs->load(
"agenda");
2151 $sql =
"SELECT cd.fk_product, cd.subprice,";
2152 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2153 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2154 $sql .=
" ed.fk_elementdet, ed.cost_price";
2155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2156 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2157 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2158 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2160 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2161 $resql = $this->db->query($sql);
2164 $cpt = $this->db->num_rows($resql);
2165 for ($i = 0; $i < $cpt; $i++) {
2166 $obj = $this->db->fetch_object($resql);
2170 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2174 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid);
2177 $mouvS->origin = &$this;
2178 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2180 if (empty($obj->batch)) {
2184 $inventorycode =
'';
2185 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionClassifyClosedInDolibarr", $this->ref),
'',
'',
'',
'', 0, $inventorycode);
2187 $this->error = $mouvS->error;
2188 $this->errors = $mouvS->errors;
2196 $inventorycode =
'';
2197 $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);
2200 $this->error = $mouvS->error;
2201 $this->errors = $mouvS->errors;
2208 $this->error = $this->db->lasterror();
2215 $result = $this->call_trigger(
'RECEPTION_CLOSED', $user);
2226 $this->db->commit();
2229 $this->statut = self::STATUS_VALIDATED;
2230 $this->
status = self::STATUS_VALIDATED;
2231 $this->db->rollback();
2248 if ($this->statut == Reception::STATUS_VALIDATED) {
2253 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET billed=1';
2254 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2256 $resql = $this->db->query($sql);
2261 $result = $this->call_trigger(
'RECEPTION_BILLED', $user);
2268 $this->errors[] = $this->db->lasterror;
2271 if (empty($error)) {
2272 $this->db->commit();
2275 $this->db->rollback();
2287 global $langs, $user;
2292 if ($this->statut != self::STATUS_CLOSED) {
2293 $langs->load(
"receptions");
2294 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionProcessedShort'));
2300 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut=1, billed=0';
2301 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut = '.self::STATUS_CLOSED;
2303 $resql = $this->db->query($sql);
2304 $rollbackStatus = $this->status;
2305 $rollbackBilled = $this->billed;
2307 if ($this->db->affected_rows($resql) <= 0) {
2309 $this->db->rollback();
2310 $langs->load(
"receptions");
2311 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv(
'StatusReceptionProcessedShort'));
2314 $this->statut = self::STATUS_VALIDATED;
2315 $this->
status = self::STATUS_VALIDATED;
2320 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2321 $numref = (string) $this->
ref;
2322 $langs->load(
"agenda");
2326 $sql =
"SELECT ed.fk_product, cd.subprice,";
2327 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2328 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2329 $sql .=
" ed.fk_elementdet, ed.cost_price";
2330 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2331 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2332 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2333 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2335 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2336 $resql = $this->db->query($sql);
2338 $cpt = $this->db->num_rows($resql);
2339 for ($i = 0; $i < $cpt; $i++) {
2340 $obj = $this->db->fetch_object($resql);
2344 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2347 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid);
2351 $mouvS->origin = &$this;
2352 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2354 if (empty($obj->batch)) {
2358 $inventorycode =
'';
2359 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionUnClassifyCloseddInDolibarr", $numref),
'',
'',
'',
'', 0, $inventorycode);
2362 $this->error = $mouvS->error;
2363 $this->errors = $mouvS->errors;
2371 $inventorycode =
'';
2372 $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);
2374 $this->error = $mouvS->error;
2375 $this->errors = $mouvS->errors;
2382 $this->error = $this->db->lasterror();
2389 $result = $this->call_trigger(
'RECEPTION_REOPEN', $user);
2395 if (!$error && $this->origin ==
'order_supplier') {
2396 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
2399 $commande->fetch($this->origin_id);
2400 $result = $commande->setStatus($user, 4);
2403 $this->error = $commande->error;
2404 $this->errors = $commande->errors;
2409 $this->errors[] = $this->db->lasterror();
2413 $this->db->commit();
2416 $this->statut = $this->
status = $rollbackStatus;
2417 $this->billed = $rollbackBilled;
2418 $this->db->rollback();
2432 global $conf, $langs;
2437 if ($this->statut <= self::STATUS_DRAFT) {
2441 if (!((!
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer'))
2442 || (
getDolGlobalInt(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')))) {
2443 $this->error =
'Permission denied';
2449 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
2450 $sql .=
" SET fk_statut = ".self::STATUS_DRAFT;
2451 $sql .=
" WHERE rowid = ".((int) $this->
id);
2452 $sql .=
" AND fk_statut = ".((int) $this->statut);
2455 $resql = $this->db->query($sql);
2456 if ($resql && $this->db->affected_rows($resql) <= 0) {
2458 $this->db->rollback();
2459 $langs->load(
"receptions");
2460 $this->error = $langs->trans(
'StatusOfRefMustBe', $this->
ref, $langs->transnoentitiesnoconv($this->statut == self::STATUS_CLOSED ?
'StatusReceptionProcessedShort' :
'StatusReceptionValidatedShort'));
2466 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2468 $langs->load(
"agenda");
2472 $sql =
"SELECT cd.fk_product, cd.subprice,";
2473 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2474 $sql .=
" ed.eatby, ed.sellby, ed.batch,";
2475 $sql .=
" ed.fk_elementdet, ed.cost_price";
2476 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
2477 $sql .=
" ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2478 $sql .=
" WHERE ed.fk_reception = ".((int) $this->
id);
2479 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2481 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2482 $resql = $this->db->query($sql);
2484 $cpt = $this->db->num_rows($resql);
2485 for ($i = 0; $i < $cpt; $i++) {
2486 $obj = $this->db->fetch_object($resql);
2490 if ($qty == 0 || ($qty < 0 && !
getDolGlobalInt(
'RECEPTION_ALLOW_NEGATIVE_QTY'))) {
2494 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid);
2498 $mouvS->origin = &$this;
2499 $mouvS->setOrigin($this->element, $this->
id, $obj->fk_elementdet, $obj->rowid);
2501 if (empty($obj->batch)) {
2505 $inventorycode =
'';
2506 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans(
"ReceptionBackToDraftInDolibarr", $this->ref),
'',
'',
'',
'', 0, $inventorycode);
2508 $this->error = $mouvS->error;
2509 $this->errors = $mouvS->errors;
2517 $inventorycode =
'';
2518 $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);
2520 $this->error = $mouvS->error;
2521 $this->errors = $mouvS->errors;
2528 $this->error = $this->db->lasterror();
2535 $result = $this->call_trigger(
'RECEPTION_UNVALIDATE', $user);
2540 if ($this->origin ==
'order_supplier') {
2541 if (!empty($this->origin) && $this->origin_id > 0) {
2543 if ($this->origin_object->statut == 4) {
2545 $this->origin_object->fetchObjectLinked();
2547 if (!empty($this->origin_object->linkedObjects[
'reception'])) {
2548 foreach ($this->origin_object->linkedObjects[
'reception'] as $rcption) {
2549 if ($rcption->statut > 0) {
2556 $this->origin_object->setStatut(3);
2564 $this->statut = self::STATUS_DRAFT;
2565 $this->
status = self::STATUS_DRAFT;
2566 $this->db->commit();
2569 $this->db->rollback();
2573 $this->error = $this->db->error();
2574 $this->db->rollback();
2589 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2591 global $conf, $langs;
2593 $langs->load(
"receptions");
2596 $modele =
'squille';
2598 if ($this->model_pdf) {
2599 $modele = $this->model_pdf;
2605 $modelpath =
"core/modules/reception/doc/";
2607 if (!empty($this->origin) && $this->origin_id > 0) {
2611 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2624 $tables = array(
'reception');
2640 '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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left 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 PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
$conf db user
Active Directory does not allow anonymous connections.