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;
132 $this->labelStatus[-1] =
'StatusDeliveryCanceled';
133 $this->labelStatus[0] =
'StatusDeliveryDraft';
134 $this->labelStatus[1] =
'StatusDeliveryValidated';
149 if (empty($this->model_pdf)) {
164 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
168 $sql .=
", ref_customer";
169 $sql .=
", date_creation";
170 $sql .=
", fk_user_author";
171 $sql .=
", date_delivery";
172 $sql .=
", fk_address";
173 $sql .=
", note_private";
174 $sql .=
", note_public";
175 $sql .=
", model_pdf";
176 $sql .=
", fk_incoterms, location_incoterms";
177 $sql .=
") VALUES (";
179 $sql .=
", ".((int) $conf->entity);
180 $sql .=
", ".((int) $this->socid);
181 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
182 $sql .=
", '".$this->db->idate($now).
"'";
183 $sql .=
", ".((int) $user->id);
184 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
185 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
186 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
187 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
188 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
189 $sql .=
", ".(int) $this->fk_incoterms;
190 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
194 $resql = $this->db->query($sql);
196 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
198 $numref =
"(PROV".$this->id.
")";
200 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
201 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
202 $sql .=
" WHERE rowid = ".((int) $this->
id);
205 $resql = $this->db->query($sql);
208 $commande =
new Commande($this->db);
209 $commande->id = $this->commande_id;
210 $commande->fetch_lines();
217 $num = count($this->lines);
218 for ($i = 0; $i < $num; $i++) {
219 $origin_id = $this->lines[$i]->origin_line_id;
221 $origin_id = $this->lines[$i]->commande_ligne_id;
224 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
229 if (!$error && $this->
id && $this->origin_id) {
236 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
248 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
249 $this->db->rollback();
254 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
255 $this->db->rollback();
260 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
261 $this->db->rollback();
277 public function create_line($origin_id, $qty, $fk_product, $description, $array_options = [])
281 $idprod = $fk_product;
283 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
284 $sql .=
" fk_product, description, qty)";
285 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
286 $sql .=
" ".($idprod > 0 ? ((int) $idprod) :
"null").
",";
287 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
290 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
291 if (!$this->db->query($sql)) {
295 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
297 if (is_array($array_options) && count($array_options) > 0) {
300 $line->array_options = $array_options;
301 $result = $line->insertExtraFields();
319 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
320 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
321 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
322 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
323 $sql .=
', l.fk_incoterms, l.location_incoterms';
324 $sql .=
", i.libelle as label_incoterms";
325 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
326 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
327 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
328 $sql .=
" WHERE l.rowid = ".((int) $id);
330 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
331 $result = $this->db->query($sql);
333 if ($this->db->num_rows($result)) {
334 $obj = $this->db->fetch_object($result);
336 $this->
id = $obj->rowid;
337 $this->date_delivery = $this->db->jdate($obj->date_delivery);
338 $this->date_creation = $this->db->jdate($obj->date_creation);
339 $this->date_valid = $this->db->jdate($obj->date_valid);
340 $this->
ref = $obj->ref;
341 $this->ref_customer = $obj->ref_customer;
342 $this->socid = $obj->fk_soc;
343 $this->
statut = $obj->fk_statut;
344 $this->
status = $obj->fk_statut;
345 $this->user_author_id = $obj->fk_user_author;
346 $this->user_validation_id = $obj->fk_user_valid;
347 $this->fk_delivery_address = $obj->fk_address;
348 $this->note = $obj->note_private;
349 $this->note_private = $obj->note_private;
350 $this->note_public = $obj->note_public;
351 $this->model_pdf = $obj->model_pdf;
352 $this->origin = $obj->origin;
353 $this->origin_id = $obj->origin_id;
356 $this->fk_incoterms = $obj->fk_incoterms;
357 $this->location_incoterms = $obj->location_incoterms;
358 $this->label_incoterms = $obj->label_incoterms;
359 $this->db->free($result);
377 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
378 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
382 $this->error = $this->db->error();
394 public function valid($user, $notrigger = 0)
398 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
406 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
407 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
412 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
413 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
418 $objMod =
new $modName($this->db);
420 $soc->fetch($this->socid);
422 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
423 $numref = $objMod->getNextValue($soc, $this);
425 $numref = $this->ref;
431 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
432 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
433 $sql .=
" AND fk_statut <> 0";
434 $sql .=
" AND entity = ".((int) $conf->entity);
436 $resql = $this->db->query($sql);
438 $num = $this->db->num_rows($resql);
444 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
445 $sql .=
" ref='".$this->db->escape($numref).
"'";
446 $sql .=
", fk_statut = 1";
447 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
448 $sql .=
", fk_user_valid = ".$user->id;
449 $sql .=
" WHERE rowid = ".((int) $this->
id);
450 $sql .=
" AND fk_statut = 0";
452 $resql = $this->db->query($sql);
455 $this->error = $this->db->lasterror();
459 if (!$error && !$notrigger) {
461 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
469 $this->oldref = $this->ref;
472 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
474 $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).
"'";
475 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
476 $resql = $this->db->query($sql);
479 $this->error = $this->db->lasterror();
481 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
482 $sql .=
" WHERE filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
483 $resql = $this->db->query($sql);
486 $this->error = $this->db->lasterror();
492 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
493 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
494 if (!$error && file_exists($dirsource)) {
495 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
497 if (@rename($dirsource, $dirdest)) {
500 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
501 foreach ($listoffiles as $fileentry) {
502 $dirsource = $fileentry[
'name'];
503 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
504 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
505 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
506 @rename($dirsource, $dirdest);
514 $this->
ref = $numref;
525 $this->db->rollback();
533 $this->error =
"NotAllowed";
534 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
553 $result = $expedition->fetch($sending_id);
558 $this->lines = array();
560 $num = count($expedition->lines);
561 for ($i = 0; $i < $num; $i++) {
563 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
564 $line->label = $expedition->lines[$i]->label;
565 $line->description = $expedition->lines[$i]->description;
566 $line->qty = $expedition->lines[$i]->qty_shipped;
567 $line->fk_product = $expedition->lines[$i]->fk_product;
568 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
569 $line->array_options = $expedition->lines[$i]->array_options;
571 $this->lines[$i] = $line;
574 $this->origin = $expedition->element;
575 $this->origin_id = $expedition->id;
576 $this->note_private = $expedition->note_private;
577 $this->note_public = $expedition->note_public;
578 $this->fk_project = $expedition->fk_project;
579 $this->date_delivery = $expedition->date_delivery;
580 $this->fk_delivery_address = $expedition->fk_delivery_address;
581 $this->socid = $expedition->socid;
582 $this->ref_customer = $expedition->ref_customer;
585 $this->fk_incoterms = $expedition->fk_incoterms;
586 $this->location_incoterms = $expedition->location_incoterms;
588 return $this->
create($user);
605 if ($id > 0 && !$error && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
607 $line->array_options = $array_options;
609 $result = $line->insertExtraFields();
612 $this->errors[] = $line->error;
633 public function addline($origin_id, $qty, $array_options = [])
637 $num = count($this->lines);
640 $line->origin_id = $origin_id;
642 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
643 $line->array_options = $array_options;
645 $this->lines[$num] = $line;
657 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
658 $sql .=
" WHERE rowid = ".((int) $lineid);
660 if ($this->db->query($sql)) {
678 public function delete($user =
null)
680 global $conf, $langs;
682 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
688 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
689 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
690 if ($this->db->query($sql)) {
698 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
699 $sql .=
" WHERE rowid = ".((int) $this->
id);
700 if ($this->db->query($sql)) {
705 if (!empty($conf->expedition->dir_output)) {
706 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
707 $file = $dir.
'/'.$ref.
'.pdf';
708 if (file_exists($file)) {
713 if (file_exists($dir)) {
715 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
722 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
724 $this->db->rollback();
731 $this->error = $this->db->lasterror().
" - sql=$sql";
732 $this->db->rollback();
736 $this->error = $this->db->lasterror().
" - sql=$sql";
737 $this->db->rollback();
741 $this->error = $this->db->lasterror().
" - sql=$sql";
742 $this->db->rollback();
757 $langs->load(
'deliveries');
761 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
762 $datas[
'picto'] .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
774 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
776 global $langs, $hookmanager;
782 'objecttype' => $this->element,
784 $classfortooltip =
'classfortooltip';
787 $classfortooltip =
'classforajaxtooltip';
788 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
794 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
799 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
800 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
801 $add_save_lastsearch_values = 1;
803 if ($add_save_lastsearch_values) {
804 $url .=
'&save_lastsearch_values=1';
808 $linkstart =
'<a href="'.$url.
'"';
809 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
810 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
814 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
816 if ($withpicto && $withpicto != 2) {
819 $result .= $linkstart.$this->ref.$linkend;
822 $hookmanager->initHooks(array($this->element .
'dao'));
823 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
824 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
826 $result = $hookmanager->resPrint;
828 $result .= $hookmanager->resPrint;
842 $this->lines = array();
844 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
845 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
846 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
847 $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";
848 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
850 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
851 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
853 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
854 $resql = $this->db->query($sql);
856 $num = $this->db->num_rows($resql);
859 $obj = $this->db->fetch_object($resql);
863 $line->id = $obj->rowid;
864 $line->label = $obj->custom_label;
865 $line->description = $obj->description;
866 $line->fk_product = $obj->fk_product;
867 $line->qty_asked = $obj->qty_asked;
868 $line->qty_shipped = $obj->qty_shipped;
870 $line->product_label = $obj->product_label;
871 $line->product_ref = $obj->product_ref;
872 $line->product_desc = $obj->product_desc;
873 $line->product_type = $obj->fk_product_type;
875 $line->fk_origin_line = $obj->fk_origin_line;
877 $line->price = $obj->subprice;
878 $line->total_ht = $obj->total_ht;
881 $line->weight = $obj->weight;
882 $line->weight_units = $obj->weight_units;
883 $line->width = $obj->width;
884 $line->width_units = $obj->width_units;
885 $line->height = $obj->height;
886 $line->height_units = $obj->height_units;
887 $line->length = $obj->length;
888 $line->length_units = $obj->length_units;
889 $line->surface = $obj->surface;
890 $line->surface_units = $obj->surface_units;
891 $line->volume = $obj->volume;
892 $line->volume_units = $obj->volume_units;
894 $line->fk_unit = $obj->fk_unit;
895 $line->fetch_optionals();
897 $this->lines[$i] = $line;
901 $this->db->free($resql);
934 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
937 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
938 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
939 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
940 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
941 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
942 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
945 $statusType =
'status0';
947 $statusType =
'status5';
950 $statusType =
'status4';
953 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
971 $sql =
"SELECT rowid";
972 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
973 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
974 $sql .=
" AND tosell = 1";
975 $sql .= $this->db->plimit(100);
977 $resql = $this->db->query($sql);
979 $num_prods = $this->db->num_rows($resql);
981 while ($i < $num_prods) {
983 $row = $this->db->fetch_row($resql);
984 $prodids[$i] = $row[0];
990 $this->
ref =
'SPECIMEN';
993 $this->date_delivery = $now;
994 $this->note_public =
'Public note';
995 $this->note_private =
'Private note';
999 $line->fk_product = reset($prodids);
1000 $line->qty_asked = 10;
1001 $line->qty_shipped = 9;
1002 $line->product_ref =
'REFPROD';
1003 $line->label =
'Specimen';
1004 $line->description =
'Description';
1006 $line->total_ht = 100;
1008 $this->lines[$i] = $line;
1025 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1026 $sqlSourceLine .=
", p.ref, p.label";
1027 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1028 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1029 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1031 $resultSourceLine = $this->db->query($sqlSourceLine);
1032 if ($resultSourceLine) {
1033 $num_lines = $this->db->num_rows($resultSourceLine);
1036 while ($i < $num_lines) {
1037 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1040 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1041 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1042 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1043 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1044 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1045 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1046 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1047 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1048 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1049 $sql .=
" GROUP BY ld.fk_origin_line";
1051 $result = $this->db->query($sql);
1052 $row = $this->db->fetch_row($result);
1054 if ($objSourceLine->qty - $row[1] > 0) {
1055 if ($row[0] == $objSourceLine->rowid) {
1056 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1058 $array[$i][
'qty'] = $objSourceLine->qty;
1061 $array[$i][
'ref'] = $objSourceLine->ref;
1062 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1063 } elseif ($objSourceLine->qty - $row[1] < 0) {
1064 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1065 $array[$i][
'ref'] = $objSourceLine->ref;
1066 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1073 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1087 if ($user->hasRight(
'expedition',
'creer')) {
1088 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1089 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1090 $sql .=
" WHERE rowid = ".((int) $this->
id);
1092 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1093 $resql = $this->db->query($sql);
1095 $this->date_delivery = $delivery_date;
1098 $this->error = $this->db->error();
1116 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1118 global $conf, $langs;
1120 $langs->load(
"deliveries");
1121 $outputlangs->load(
"products");
1126 if ($this->model_pdf) {
1127 $modele = $this->model_pdf;
1133 $modelpath =
"core/modules/delivery/doc/";
1135 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1187 public $element =
'deliverydet';
1192 public $table_element =
'deliverydet';
1202 public $description;
1229 public $qty_shipped;
1232 public $product_desc;
1233 public $product_type;
1234 public $product_ref;
1235 public $product_label;
1239 public $fk_origin_line;
1245 public $origin_line_id;
1252 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