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;
114 public $lines = array();
119 public $user_author_id;
122 const STATUS_DRAFT = 0;
123 const STATUS_VALIDATED = 1;
124 const STATUS_CANCELED = -1;
137 $this->labelStatus[-1] =
'StatusDeliveryCanceled';
138 $this->labelStatus[0] =
'StatusDeliveryDraft';
139 $this->labelStatus[1] =
'StatusDeliveryValidated';
154 if (empty($this->model_pdf)) {
169 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
173 $sql .=
", ref_customer";
174 $sql .=
", date_creation";
175 $sql .=
", fk_user_author";
176 $sql .=
", date_delivery";
177 $sql .=
", fk_address";
178 $sql .=
", note_private";
179 $sql .=
", note_public";
180 $sql .=
", model_pdf";
181 $sql .=
", fk_incoterms, location_incoterms";
182 $sql .=
") VALUES (";
184 $sql .=
", ".((int) $conf->entity);
185 $sql .=
", ".((int) $this->socid);
186 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
187 $sql .=
", '".$this->db->idate($now).
"'";
188 $sql .=
", ".((int) $user->id);
189 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
190 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
191 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
192 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
193 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
194 $sql .=
", ".(int) $this->fk_incoterms;
195 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
199 $resql = $this->db->query($sql);
201 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
203 $numref =
"(PROV".$this->id.
")";
205 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
206 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
207 $sql .=
" WHERE rowid = ".((int) $this->
id);
210 $resql = $this->db->query($sql);
213 $commande =
new Commande($this->db);
214 $commande->id = $this->commande_id;
215 $commande->fetch_lines();
222 $num = count($this->lines);
223 for ($i = 0; $i < $num; $i++) {
224 $origin_id = $this->lines[$i]->origin_line_id;
226 $origin_id = $this->lines[$i]->commande_ligne_id;
229 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
234 if (!$error && $this->
id && $this->origin_id) {
241 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
253 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
254 $this->db->rollback();
259 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
260 $this->db->rollback();
265 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
266 $this->db->rollback();
282 public function create_line($origin_id, $qty, $fk_product, $description, $array_options = [])
287 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
288 $sql .=
" fk_product, description, qty)";
289 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
290 $sql .=
" ".($fk_product > 0 ? ((int) $fk_product) :
"null").
",";
291 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
294 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
295 if (!$this->db->query($sql)) {
299 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
301 if (is_array($array_options) && count($array_options) > 0) {
304 $line->array_options = $array_options;
305 $result = $line->insertExtraFields();
323 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
324 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
325 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
326 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
327 $sql .=
', l.fk_incoterms, l.location_incoterms';
328 $sql .=
", i.libelle as label_incoterms";
329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
330 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
331 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
332 $sql .=
" WHERE l.rowid = ".((int) $id);
334 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
335 $result = $this->db->query($sql);
337 if ($this->db->num_rows($result)) {
338 $obj = $this->db->fetch_object($result);
340 $this->
id = $obj->rowid;
341 $this->date_delivery = $this->db->jdate($obj->date_delivery);
342 $this->date_creation = $this->db->jdate($obj->date_creation);
343 $this->date_valid = $this->db->jdate($obj->date_valid);
344 $this->
ref = $obj->ref;
345 $this->ref_customer = $obj->ref_customer;
346 $this->socid = $obj->fk_soc;
347 $this->statut = $obj->fk_statut;
348 $this->
status = $obj->fk_statut;
349 $this->user_author_id = $obj->fk_user_author;
350 $this->user_validation_id = $obj->fk_user_valid;
351 $this->fk_delivery_address = $obj->fk_address;
352 $this->note = $obj->note_private;
353 $this->note_private = $obj->note_private;
354 $this->note_public = $obj->note_public;
355 $this->model_pdf = $obj->model_pdf;
356 $this->origin = $obj->origin;
357 $this->origin_id = $obj->origin_id;
360 $this->fk_incoterms = $obj->fk_incoterms;
361 $this->location_incoterms = $obj->location_incoterms;
362 $this->label_incoterms = $obj->label_incoterms;
363 $this->db->free($result);
381 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
382 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
386 $this->error = $this->db->error();
398 public function valid($user, $notrigger = 0)
402 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
410 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
411 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
416 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
417 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
422 $objMod =
new $modName($this->db);
423 '@phan-var-force ModeleNumRefDeliveryOrder $objMod';
425 $soc->fetch($this->socid);
427 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
428 $numref = $objMod->getNextValue($soc, $this);
430 $numref = $this->ref;
436 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
437 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
438 $sql .=
" AND fk_statut <> 0";
439 $sql .=
" AND entity = ".((int) $conf->entity);
441 $resql = $this->db->query($sql);
443 $num = $this->db->num_rows($resql);
449 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
450 $sql .=
" ref='".$this->db->escape($numref).
"'";
451 $sql .=
", fk_statut = 1";
452 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
453 $sql .=
", fk_user_valid = ".((int) $user->id);
454 $sql .=
" WHERE rowid = ".((int) $this->
id);
455 $sql .=
" AND fk_statut = 0";
457 $resql = $this->db->query($sql);
460 $this->error = $this->db->lasterror();
464 if (!$error && !$notrigger) {
466 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
474 $this->oldref = $this->ref;
477 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
479 $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).
"'";
480 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
481 $resql = $this->db->query($sql);
484 $this->error = $this->db->lasterror();
486 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
487 $sql .=
" WHERE filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
488 $resql = $this->db->query($sql);
491 $this->error = $this->db->lasterror();
497 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
498 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
499 if (!$error && file_exists($dirsource)) {
500 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
502 if (@rename($dirsource, $dirdest)) {
505 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
506 foreach ($listoffiles as $fileentry) {
507 $dirsource = $fileentry[
'name'];
508 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
509 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
510 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
511 @rename($dirsource, $dirdest);
519 $this->
ref = $numref;
530 $this->db->rollback();
538 $this->error =
"NotAllowed";
539 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
558 $result = $expedition->fetch($sending_id);
563 $this->lines = array();
565 $num = count($expedition->lines);
566 for ($i = 0; $i < $num; $i++) {
568 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
569 $line->label = $expedition->lines[$i]->label;
570 $line->description = $expedition->lines[$i]->description;
571 $line->qty = $expedition->lines[$i]->qty_shipped;
572 $line->fk_product = $expedition->lines[$i]->fk_product;
573 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
574 $line->array_options = $expedition->lines[$i]->array_options;
576 $this->lines[$i] = $line;
579 $this->origin = $expedition->element;
580 $this->origin_id = $expedition->id;
581 $this->note_private = $expedition->note_private;
582 $this->note_public = $expedition->note_public;
583 $this->fk_project = $expedition->fk_project;
584 $this->date_delivery = $expedition->date_delivery;
585 $this->fk_delivery_address = $expedition->fk_delivery_address;
586 $this->socid = $expedition->socid;
587 $this->ref_customer = $expedition->ref_customer;
590 $this->fk_incoterms = $expedition->fk_incoterms;
591 $this->location_incoterms = $expedition->location_incoterms;
593 return $this->
create($user);
610 if ($id > 0 && !$error && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
612 $line->array_options = $array_options;
614 $result = $line->insertExtraFields();
617 $this->errors[] = $line->error;
638 public function addline($origin_id, $qty, $array_options = [])
640 $num = count($this->lines);
643 $line->origin_id = $origin_id;
645 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
646 $line->array_options = $array_options;
648 $this->lines[$num] = $line;
660 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
661 $sql .=
" WHERE rowid = ".((int) $lineid);
663 if ($this->db->query($sql)) {
681 public function delete($user =
null)
683 global $conf, $langs;
685 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
691 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
692 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
693 if ($this->db->query($sql)) {
701 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
702 $sql .=
" WHERE rowid = ".((int) $this->
id);
703 if ($this->db->query($sql)) {
708 if (!empty($conf->expedition->dir_output)) {
709 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
710 $file = $dir.
'/'.$ref.
'.pdf';
711 if (file_exists($file)) {
716 if (file_exists($dir)) {
718 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
725 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
727 $this->db->rollback();
734 $this->error = $this->db->lasterror().
" - sql=$sql";
735 $this->db->rollback();
739 $this->error = $this->db->lasterror().
" - sql=$sql";
740 $this->db->rollback();
744 $this->error = $this->db->lasterror().
" - sql=$sql";
745 $this->db->rollback();
760 $langs->load(
'deliveries');
764 $datas[
'picto'] =
img_picto(
'', $this->picto,
'', 0, 0, 0,
'',
'paddingrightonly').
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
765 $datas[
'ref'] =
'<b>'.$langs->trans(
"Ref").
'</b>: '.$this->ref;
777 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
779 global $langs, $hookmanager;
785 'objecttype' => $this->element,
787 $classfortooltip =
'classfortooltip';
790 $classfortooltip =
'classforajaxtooltip';
791 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
797 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
802 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
803 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
804 $add_save_lastsearch_values = 1;
806 if ($add_save_lastsearch_values) {
807 $url .=
'&save_lastsearch_values=1';
811 $linkstart =
'<a href="'.$url.
'"';
812 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
813 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
817 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
819 if ($withpicto && $withpicto != 2) {
822 $result .= $linkstart.$this->ref.$linkend;
825 $hookmanager->initHooks(array($this->element .
'dao'));
826 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
827 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
829 $result = $hookmanager->resPrint;
831 $result .= $hookmanager->resPrint;
845 $this->lines = array();
847 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
848 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
849 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
850 $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";
851 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
853 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
854 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
856 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
857 $resql = $this->db->query($sql);
859 $num = $this->db->num_rows($resql);
862 $obj = $this->db->fetch_object($resql);
866 $line->id = $obj->rowid;
867 $line->label = $obj->custom_label;
868 $line->description = $obj->description;
869 $line->fk_product = $obj->fk_product;
870 $line->qty_asked = $obj->qty_asked;
871 $line->qty_shipped = $obj->qty_shipped;
873 $line->product_label = $obj->product_label;
874 $line->product_ref = $obj->product_ref;
875 $line->product_desc = $obj->product_desc;
876 $line->product_type = $obj->fk_product_type;
878 $line->fk_origin_line = $obj->fk_origin_line;
880 $line->price = $obj->subprice;
881 $line->total_ht = $obj->total_ht;
884 $line->weight = $obj->weight;
885 $line->weight_units = $obj->weight_units;
886 $line->width = $obj->width;
887 $line->width_units = $obj->width_units;
888 $line->height = $obj->height;
889 $line->height_units = $obj->height_units;
890 $line->length = $obj->length;
891 $line->length_units = $obj->length_units;
892 $line->surface = $obj->surface;
893 $line->surface_units = $obj->surface_units;
894 $line->volume = $obj->volume;
895 $line->volume_units = $obj->volume_units;
897 $line->fk_unit = $obj->fk_unit;
898 $line->fetch_optionals();
900 $this->lines[$i] = $line;
904 $this->db->free($resql);
937 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
940 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
941 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
942 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
943 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
944 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
945 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
948 $statusType =
'status0';
950 $statusType =
'status5';
953 $statusType =
'status4';
956 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
974 $sql =
"SELECT rowid";
975 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
976 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
977 $sql .=
" AND tosell = 1";
978 $sql .= $this->db->plimit(100);
980 $resql = $this->db->query($sql);
982 $num_prods = $this->db->num_rows($resql);
984 while ($i < $num_prods) {
986 $row = $this->db->fetch_row($resql);
987 $prodids[$i] = $row[0];
993 $this->
ref =
'SPECIMEN';
996 $this->date_delivery = $now;
997 $this->note_public =
'Public note';
998 $this->note_private =
'Private note';
1002 $line->fk_product = reset($prodids);
1003 $line->qty_asked = 10;
1004 $line->qty_shipped = 9;
1005 $line->product_ref =
'REFPROD';
1006 $line->label =
'Specimen';
1007 $line->description =
'Description';
1009 $line->total_ht = 100;
1011 $this->lines[$i] = $line;
1028 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1029 $sqlSourceLine .=
", p.ref, p.label";
1030 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1031 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1032 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1034 $resultSourceLine = $this->db->query($sqlSourceLine);
1035 if ($resultSourceLine) {
1036 $num_lines = $this->db->num_rows($resultSourceLine);
1039 while ($i < $num_lines) {
1040 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1043 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1044 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1045 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1046 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1047 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1048 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1049 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1050 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1051 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1052 $sql .=
" GROUP BY ld.fk_origin_line";
1054 $result = $this->db->query($sql);
1055 $row = $this->db->fetch_row($result);
1057 if ($objSourceLine->qty - $row[1] > 0) {
1058 if ($row[0] == $objSourceLine->rowid) {
1059 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1061 $array[$i][
'qty'] = $objSourceLine->qty;
1064 $array[$i][
'ref'] = $objSourceLine->ref;
1065 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1066 } elseif ($objSourceLine->qty - $row[1] < 0) {
1067 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1068 $array[$i][
'ref'] = $objSourceLine->ref;
1069 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1076 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1090 if ($user->hasRight(
'expedition',
'creer')) {
1091 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1092 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1093 $sql .=
" WHERE rowid = ".((int) $this->
id);
1095 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1096 $resql = $this->db->query($sql);
1098 $this->date_delivery = $delivery_date;
1101 $this->error = $this->db->error();
1119 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1121 global $conf, $langs;
1123 $langs->load(
"deliveries");
1124 $outputlangs->load(
"products");
1129 if ($this->model_pdf) {
1130 $modele = $this->model_pdf;
1136 $modelpath =
"core/modules/delivery/doc/";
1138 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1190 public $element =
'deliverydet';
1195 public $table_element =
'deliverydet';
1205 public $description;
1234 public $qty_shipped;
1243 public $product_desc;
1247 public $product_type;
1251 public $product_ref;
1255 public $product_label;
1265 public $fk_origin_line;
1274 public $origin_line_id;
1281 public $commande_ligne_id;
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()
Get data list of Products remaining to be delivered for an order (with qty)
getNomUrl($withpicto=0, $save_lastsearch_value=-1)
Return clickable name (with picto eventually)
Management class of delivery note lines.
__construct($db)
Constructor.
Class to manage Dolibarr database access.
Class to manage third parties objects (customers, suppliers, prospects...)
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...
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 a 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.