32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
36if (isModEnabled(
"propal")) {
37 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
39if (isModEnabled(
'order')) {
40 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54 public $element =
"delivery";
59 public $fk_element =
"fk_delivery";
64 public $table_element =
"delivery";
69 public $table_element_line =
"deliverydet";
74 public $picto =
'sending';
94 public $date_delivery;
99 public $date_creation;
116 public $lines = array();
121 public $user_author_id;
124 const STATUS_DRAFT = 0;
125 const STATUS_VALIDATED = 1;
126 const STATUS_CANCELED = -1;
139 $this->labelStatus[-1] =
'StatusDeliveryCanceled';
140 $this->labelStatus[0] =
'StatusDeliveryDraft';
141 $this->labelStatus[1] =
'StatusDeliveryValidated';
156 if (empty($this->model_pdf)) {
171 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
175 $sql .=
", ref_customer";
176 $sql .=
", date_creation";
177 $sql .=
", fk_user_author";
178 $sql .=
", date_delivery";
179 $sql .=
", fk_address";
180 $sql .=
", note_private";
181 $sql .=
", note_public";
182 $sql .=
", model_pdf";
183 $sql .=
", fk_incoterms, location_incoterms";
184 $sql .=
") VALUES (";
186 $sql .=
", ".((int) $conf->entity);
187 $sql .=
", ".((int) $this->socid);
188 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
189 $sql .=
", '".$this->db->idate($now).
"'";
190 $sql .=
", ".((int) $user->id);
191 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
192 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
193 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
194 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
195 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
196 $sql .=
", ".(int) $this->fk_incoterms;
197 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
201 $resql = $this->db->query($sql);
203 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
205 $numref =
"(PROV".$this->id.
")";
207 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
208 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
209 $sql .=
" WHERE rowid = ".((int) $this->
id);
212 $resql = $this->db->query($sql);
215 $commande =
new Commande($this->db);
216 $commande->id = $this->commande_id;
217 $commande->fetch_lines();
224 $num = count($this->lines);
225 for ($i = 0; $i < $num; $i++) {
226 $origin_id = $this->lines[$i]->origin_line_id;
228 $origin_id = $this->lines[$i]->commande_ligne_id;
231 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
236 if (!$error && $this->
id && $this->origin_id) {
243 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
255 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
256 $this->db->rollback();
261 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
262 $this->db->rollback();
267 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
268 $this->db->rollback();
284 public function create_line($origin_id, $qty, $fk_product, $description, $array_options = [])
288 $idprod = $fk_product;
290 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
291 $sql .=
" fk_product, description, qty)";
292 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
293 $sql .=
" ".($idprod > 0 ? ((int) $idprod) :
"null").
",";
294 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
297 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
298 if (!$this->db->query($sql)) {
302 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
304 if (is_array($array_options) && count($array_options) > 0) {
307 $line->array_options = $array_options;
308 $result = $line->insertExtraFields();
326 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
327 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
328 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
329 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
330 $sql .=
', l.fk_incoterms, l.location_incoterms';
331 $sql .=
", i.libelle as label_incoterms";
332 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
333 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
334 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
335 $sql .=
" WHERE l.rowid = ".((int) $id);
337 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
338 $result = $this->db->query($sql);
340 if ($this->db->num_rows($result)) {
341 $obj = $this->db->fetch_object($result);
343 $this->
id = $obj->rowid;
344 $this->date_delivery = $this->db->jdate($obj->date_delivery);
345 $this->date_creation = $this->db->jdate($obj->date_creation);
346 $this->date_valid = $this->db->jdate($obj->date_valid);
347 $this->
ref = $obj->ref;
348 $this->ref_customer = $obj->ref_customer;
349 $this->socid = $obj->fk_soc;
350 $this->
statut = $obj->fk_statut;
351 $this->
status = $obj->fk_statut;
352 $this->user_author_id = $obj->fk_user_author;
353 $this->user_validation_id = $obj->fk_user_valid;
354 $this->fk_delivery_address = $obj->fk_address;
355 $this->note = $obj->note_private;
356 $this->note_private = $obj->note_private;
357 $this->note_public = $obj->note_public;
358 $this->model_pdf = $obj->model_pdf;
359 $this->origin = $obj->origin;
360 $this->origin_id = $obj->origin_id;
363 $this->fk_incoterms = $obj->fk_incoterms;
364 $this->location_incoterms = $obj->location_incoterms;
365 $this->label_incoterms = $obj->label_incoterms;
366 $this->db->free($result);
384 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
385 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
389 $this->error = $this->db->error();
401 public function valid($user, $notrigger = 0)
405 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
413 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
414 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
419 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
420 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
425 $objMod =
new $modName($this->db);
427 $soc->fetch($this->socid);
429 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
430 $numref = $objMod->getNextValue($soc, $this);
432 $numref = $this->ref;
438 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
439 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
440 $sql .=
" AND fk_statut <> 0";
441 $sql .=
" AND entity = ".((int) $conf->entity);
443 $resql = $this->db->query($sql);
445 $num = $this->db->num_rows($resql);
451 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
452 $sql .=
" ref='".$this->db->escape($numref).
"'";
453 $sql .=
", fk_statut = 1";
454 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
455 $sql .=
", fk_user_valid = ".$user->id;
456 $sql .=
" WHERE rowid = ".((int) $this->
id);
457 $sql .=
" AND fk_statut = 0";
459 $resql = $this->db->query($sql);
462 $this->error = $this->db->lasterror();
466 if (!$error && !$notrigger) {
468 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
476 $this->oldref = $this->ref;
479 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
481 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
482 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
483 $resql = $this->db->query($sql);
486 $this->error = $this->db->lasterror();
488 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
489 $sql .=
" WHERE filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
490 $resql = $this->db->query($sql);
493 $this->error = $this->db->lasterror();
499 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
500 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
501 if (!$error && file_exists($dirsource)) {
502 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
504 if (@rename($dirsource, $dirdest)) {
507 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
508 foreach ($listoffiles as $fileentry) {
509 $dirsource = $fileentry[
'name'];
510 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
511 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
512 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
513 @rename($dirsource, $dirdest);
521 $this->
ref = $numref;
532 $this->db->rollback();
540 $this->error =
"NotAllowed";
541 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
560 $result = $expedition->fetch($sending_id);
565 $this->lines = array();
567 $num = count($expedition->lines);
568 for ($i = 0; $i < $num; $i++) {
570 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
571 $line->label = $expedition->lines[$i]->label;
572 $line->description = $expedition->lines[$i]->description;
573 $line->qty = $expedition->lines[$i]->qty_shipped;
574 $line->fk_product = $expedition->lines[$i]->fk_product;
575 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
576 $line->array_options = $expedition->lines[$i]->array_options;
578 $this->lines[$i] = $line;
581 $this->origin = $expedition->element;
582 $this->origin_id = $expedition->id;
583 $this->note_private = $expedition->note_private;
584 $this->note_public = $expedition->note_public;
585 $this->fk_project = $expedition->fk_project;
586 $this->date_delivery = $expedition->date_delivery;
587 $this->fk_delivery_address = $expedition->fk_delivery_address;
588 $this->socid = $expedition->socid;
589 $this->ref_customer = $expedition->ref_customer;
592 $this->fk_incoterms = $expedition->fk_incoterms;
593 $this->location_incoterms = $expedition->location_incoterms;
595 return $this->
create($user);
612 if ($id > 0 && !$error && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
614 $line->array_options = $array_options;
616 $result = $line->insertExtraFields();
619 $this->errors[] = $line->error;
640 public function addline($origin_id, $qty, $array_options = [])
644 $num = count($this->lines);
647 $line->origin_id = $origin_id;
649 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
650 $line->array_options = $array_options;
652 $this->lines[$num] = $line;
664 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
665 $sql .=
" WHERE rowid = ".((int) $lineid);
667 if ($this->db->query($sql)) {
685 public function delete($user =
null)
687 global $conf, $langs;
689 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
695 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
696 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
697 if ($this->db->query($sql)) {
705 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
706 $sql .=
" WHERE rowid = ".((int) $this->
id);
707 if ($this->db->query($sql)) {
712 if (!empty($conf->expedition->dir_output)) {
713 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
714 $file = $dir.
'/'.$ref.
'.pdf';
715 if (file_exists($file)) {
720 if (file_exists($dir)) {
722 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
729 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
731 $this->db->rollback();
738 $this->error = $this->db->lasterror().
" - sql=$sql";
739 $this->db->rollback();
743 $this->error = $this->db->lasterror().
" - sql=$sql";
744 $this->db->rollback();
748 $this->error = $this->db->lasterror().
" - sql=$sql";
749 $this->db->rollback();
764 $langs->load(
'deliveries');
768 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
769 $datas[
'picto'] .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
781 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
783 global $langs, $hookmanager;
789 'objecttype' => $this->element,
791 $classfortooltip =
'classfortooltip';
794 $classfortooltip =
'classforajaxtooltip';
795 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
801 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
806 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
807 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
808 $add_save_lastsearch_values = 1;
810 if ($add_save_lastsearch_values) {
811 $url .=
'&save_lastsearch_values=1';
815 $linkstart =
'<a href="'.$url.
'"';
816 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
817 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
821 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
823 if ($withpicto && $withpicto != 2) {
826 $result .= $linkstart.$this->ref.$linkend;
829 $hookmanager->initHooks(array($this->element .
'dao'));
830 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
831 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
833 $result = $hookmanager->resPrint;
835 $result .= $hookmanager->resPrint;
849 $this->lines = array();
851 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
852 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
853 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
854 $sql .=
" p.weight, p.weight_units, p.width, p.width_units, p.length, p.length_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch";
855 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
856 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
857 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
858 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
860 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
861 $resql = $this->db->query($sql);
863 $num = $this->db->num_rows($resql);
866 $obj = $this->db->fetch_object($resql);
870 $line->id = $obj->rowid;
871 $line->label = $obj->custom_label;
872 $line->description = $obj->description;
873 $line->fk_product = $obj->fk_product;
874 $line->qty_asked = $obj->qty_asked;
875 $line->qty_shipped = $obj->qty_shipped;
877 $line->product_label = $obj->product_label;
878 $line->product_ref = $obj->product_ref;
879 $line->product_desc = $obj->product_desc;
880 $line->product_type = $obj->fk_product_type;
882 $line->fk_origin_line = $obj->fk_origin_line;
884 $line->price = $obj->subprice;
885 $line->total_ht = $obj->total_ht;
888 $line->weight = $obj->weight;
889 $line->weight_units = $obj->weight_units;
890 $line->width = $obj->width;
891 $line->width_units = $obj->width_units;
892 $line->height = $obj->height;
893 $line->height_units = $obj->height_units;
894 $line->length = $obj->length;
895 $line->length_units = $obj->length_units;
896 $line->surface = $obj->surface;
897 $line->surface_units = $obj->surface_units;
898 $line->volume = $obj->volume;
899 $line->volume_units = $obj->volume_units;
901 $line->fk_unit = $obj->fk_unit;
902 $line->fetch_optionals();
904 $this->lines[$i] = $line;
908 $this->db->free($resql);
941 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
944 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
945 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
946 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
947 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
948 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
949 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
952 $statusType =
'status0';
954 $statusType =
'status5';
957 $statusType =
'status4';
960 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
978 $sql =
"SELECT rowid";
979 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
980 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
981 $sql .=
" AND tosell = 1";
982 $sql .= $this->db->plimit(100);
984 $resql = $this->db->query($sql);
986 $num_prods = $this->db->num_rows($resql);
988 while ($i < $num_prods) {
990 $row = $this->db->fetch_row($resql);
991 $prodids[$i] = $row[0];
997 $this->
ref =
'SPECIMEN';
1000 $this->date_delivery = $now;
1001 $this->note_public =
'Public note';
1002 $this->note_private =
'Private note';
1006 $line->fk_product = reset($prodids);
1007 $line->qty_asked = 10;
1008 $line->qty_shipped = 9;
1009 $line->ref =
'REFPROD';
1010 $line->label =
'Specimen';
1011 $line->description =
'Description';
1013 $line->total_ht = 100;
1015 $this->lines[$i] = $line;
1032 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1033 $sqlSourceLine .=
", p.ref, p.label";
1034 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1035 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1036 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1038 $resultSourceLine = $this->db->query($sqlSourceLine);
1039 if ($resultSourceLine) {
1040 $num_lines = $this->db->num_rows($resultSourceLine);
1043 while ($i < $num_lines) {
1044 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1047 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1048 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1049 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1050 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1051 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1052 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1053 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1054 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1055 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1056 $sql .=
" GROUP BY ld.fk_origin_line";
1058 $result = $this->db->query($sql);
1059 $row = $this->db->fetch_row($result);
1061 if ($objSourceLine->qty - $row[1] > 0) {
1062 if ($row[0] == $objSourceLine->rowid) {
1063 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1065 $array[$i][
'qty'] = $objSourceLine->qty;
1068 $array[$i][
'ref'] = $objSourceLine->ref;
1069 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1070 } elseif ($objSourceLine->qty - $row[1] < 0) {
1071 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1072 $array[$i][
'ref'] = $objSourceLine->ref;
1073 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1080 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1094 if ($user->hasRight(
'expedition',
'creer')) {
1095 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1096 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1097 $sql .=
" WHERE rowid = ".((int) $this->
id);
1099 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1100 $resql = $this->db->query($sql);
1102 $this->date_delivery = $delivery_date;
1105 $this->error = $this->db->error();
1123 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1125 global $conf, $langs;
1127 $langs->load(
"deliveries");
1128 $outputlangs->load(
"products");
1133 if ($this->model_pdf) {
1134 $modele = $this->model_pdf;
1140 $modelpath =
"core/modules/delivery/doc/";
1142 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1194 public $element =
'deliverydet';
1199 public $table_element =
'deliverydet';
1209 public $description;
1236 public $qty_shipped;
1239 public $product_desc;
1240 public $product_type;
1241 public $product_ref;
1242 public $product_label;
1246 public $fk_origin_line;
1252 public $origin_line_id;
1259 public $commande_ligne_id;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Class to manage customers 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...
update_price($exclspec=0, $roundingadjust='auto', $nodatabaseupdate=0, $seller=null)
Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
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.
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='fk_statut')
Set status of an object.
fetchObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $clause='OR', $alsosametype=1, $orderby='sourcetype', $loadalsoobjects=1)
Fetch array of objects linked to current object (object of enabled modules only).
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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage receptions.
create_line($origin_id, $qty, $fk_product, $description, $array_options=[])
Create a line.
valid($user, $notrigger=0)
Validate object and update stock if option enabled.
__construct($db)
Constructor.
static replaceProduct(DoliDB $db, $origin_id, $dest_id)
Function used to replace a product id with another one.
deleteLine($lineid)
Delete line.
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create object on disk.
update_line($id, $array_options=[])
Update a livraison line (only extrafields)
addline($origin_id, $qty, $array_options=[])
Add line.
fetch($id)
Load a delivery receipt.
create($user)
Create delivery receipt in database.
initAsSpecimen()
Initialise an instance with random values.
create_from_sending($user, $sending_id)
Creating the delivery slip from an existing shipment.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
getTooltipContentArray($params)
getTooltipContentArray
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode)
Return the label of a given status.
fetch_lines()
Load lines insto $this->lines.
getRemainingDelivered()
Renvoie la quantite de produit restante a livrer pour une commande.
getNomUrl($withpicto=0, $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
Management class of delivery note lines.
__construct($db)
Constructor.
Class to manage Dolibarr database access.
Class to manage shipments.
Class to manage third parties objects (customers, suppliers, prospects...)
trait CommonIncoterm
Superclass for incoterm classes.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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 '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db user
Active Directory does not allow anonymous connections.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut