31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
35if (isModEnabled(
"propal")) {
36 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
38if (isModEnabled(
'commande')) {
39 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
53 public $element =
"delivery";
58 public $fk_element =
"fk_delivery";
63 public $table_element =
"delivery";
68 public $table_element_line =
"deliverydet";
73 public $picto =
'sending';
93 public $date_delivery;
98 public $date_creation;
120 public $lines = array();
133 $this->statuts[-1] =
'StatusDeliveryCanceled';
134 $this->statuts[0] =
'StatusDeliveryDraft';
135 $this->statuts[1] =
'StatusDeliveryValidated';
150 if (empty($this->model_pdf)) {
151 $this->model_pdf = $conf->global->DELIVERY_ADDON_PDF;
165 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
169 $sql .=
", ref_customer";
170 $sql .=
", date_creation";
171 $sql .=
", fk_user_author";
172 $sql .=
", date_delivery";
173 $sql .=
", fk_address";
174 $sql .=
", note_private";
175 $sql .=
", note_public";
176 $sql .=
", model_pdf";
177 $sql .=
", fk_incoterms, location_incoterms";
178 $sql .=
") VALUES (";
180 $sql .=
", ".((int) $conf->entity);
181 $sql .=
", ".((int) $this->socid);
182 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
183 $sql .=
", '".$this->db->idate($now).
"'";
184 $sql .=
", ".((int) $user->id);
185 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
186 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
187 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
188 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
189 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
190 $sql .=
", ".(int) $this->fk_incoterms;
191 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
195 $resql = $this->db->query($sql);
197 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
199 $numref =
"(PROV".$this->id.
")";
201 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
202 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
203 $sql .=
" WHERE rowid = ".((int) $this->
id);
206 $resql = $this->db->query($sql);
209 $commande =
new Commande($this->db);
210 $commande->id = $this->commande_id;
211 $commande->fetch_lines();
218 $num = count($this->lines);
219 for ($i = 0; $i < $num; $i++) {
220 $origin_id = $this->lines[$i]->origin_line_id;
222 $origin_id = $this->lines[$i]->commande_ligne_id;
225 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
230 if (!$error && $this->
id && $this->origin_id) {
237 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
249 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
250 $this->db->rollback();
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();
278 public function create_line($origin_id, $qty, $fk_product, $description, $array_options =
null)
282 $idprod = $fk_product;
284 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
285 $sql .=
" fk_product, description, qty)";
286 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
287 $sql .=
" ".($idprod > 0 ? ((int) $idprod) :
"null").
",";
288 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
291 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
292 if (!$this->db->query($sql)) {
296 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
298 if (is_array($array_options) && count($array_options) > 0) {
301 $line->array_options = $array_options;
302 $result = $line->insertExtraFields();
320 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
321 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
322 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
323 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
324 $sql .=
', l.fk_incoterms, l.location_incoterms';
325 $sql .=
", i.libelle as label_incoterms";
326 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
327 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
328 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
329 $sql .=
" WHERE l.rowid = ".((int) $id);
331 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
332 $result = $this->db->query($sql);
334 if ($this->db->num_rows($result)) {
335 $obj = $this->db->fetch_object($result);
337 $this->
id = $obj->rowid;
338 $this->date_delivery = $this->db->jdate($obj->date_delivery);
339 $this->date_creation = $this->db->jdate($obj->date_creation);
340 $this->date_valid = $this->db->jdate($obj->date_valid);
341 $this->
ref = $obj->ref;
342 $this->ref_customer = $obj->ref_customer;
343 $this->socid = $obj->fk_soc;
344 $this->
statut = $obj->fk_statut;
345 $this->user_author_id = $obj->fk_user_author;
346 $this->user_valid_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->modelpdf = $obj->model_pdf;
353 $this->origin = $obj->origin;
354 $this->origin_id = $obj->origin_id;
357 $this->fk_incoterms = $obj->fk_incoterms;
358 $this->location_incoterms = $obj->location_incoterms;
359 $this->label_incoterms = $obj->label_incoterms;
360 $this->db->free($result);
378 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
379 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
383 $this->error = $this->db->error();
395 public function valid($user, $notrigger = 0)
399 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
407 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
408 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) {
409 if (!empty($conf->global->DELIVERY_ADDON_NUMBER)) {
411 $modName = $conf->global->DELIVERY_ADDON_NUMBER;
413 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
414 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
419 $objMod =
new $modName($this->db);
421 $soc->fetch($this->socid);
423 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
424 $numref = $objMod->delivery_get_num($soc, $this);
426 $numref = $this->ref;
432 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
433 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
434 $sql .=
" AND fk_statut <> 0";
435 $sql .=
" AND entity = ".((int) $conf->entity);
437 $resql = $this->db->query($sql);
439 $num = $this->db->num_rows($resql);
445 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
446 $sql .=
" ref='".$this->db->escape($numref).
"'";
447 $sql .=
", fk_statut = 1";
448 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
449 $sql .=
", fk_user_valid = ".$user->id;
450 $sql .=
" WHERE rowid = ".((int) $this->
id);
451 $sql .=
" AND fk_statut = 0";
453 $resql = $this->db->query($sql);
456 $this->error = $this->db->lasterror();
460 if (!$error && !$notrigger) {
462 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
470 $this->oldref = $this->ref;
473 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
475 $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).
"'";
476 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
477 $resql = $this->db->query($sql);
479 $error++; $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);
485 $error++; $this->error = $this->db->lasterror();
491 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
492 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
493 if (!$error && file_exists($dirsource)) {
494 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
496 if (@rename($dirsource, $dirdest)) {
499 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
500 foreach ($listoffiles as $fileentry) {
501 $dirsource = $fileentry[
'name'];
502 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
503 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
504 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
505 @rename($dirsource, $dirdest);
513 $this->
ref = $numref;
524 $this->db->rollback();
532 $this->error =
"NotAllowed";
533 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
552 $result = $expedition->fetch($sending_id);
557 $this->lines = array();
559 $num = count($expedition->lines);
560 for ($i = 0; $i < $num; $i++) {
562 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
563 $line->label = $expedition->lines[$i]->label;
564 $line->description = $expedition->lines[$i]->description;
565 $line->qty = $expedition->lines[$i]->qty_shipped;
566 $line->fk_product = $expedition->lines[$i]->fk_product;
567 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
568 $line->array_options = $expedition->lines[$i]->array_options;
570 $this->lines[$i] = $line;
573 $this->origin = $expedition->element;
574 $this->origin_id = $expedition->id;
575 $this->note_private = $expedition->note_private;
576 $this->note_public = $expedition->note_public;
577 $this->fk_project = $expedition->fk_project;
578 $this->date_delivery = $expedition->date_delivery;
579 $this->fk_delivery_address = $expedition->fk_delivery_address;
580 $this->socid = $expedition->socid;
581 $this->ref_customer = $expedition->ref_customer;
584 $this->fk_incoterms = $expedition->fk_incoterms;
585 $this->location_incoterms = $expedition->location_incoterms;
587 return $this->
create($user);
604 if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
606 $line->array_options = $array_options;
608 $result = $line->insertExtraFields();
611 $this->error[] = $line->error;
632 public function addline($origin_id, $qty, $array_options =
null)
636 $num = count($this->lines);
639 $line->origin_id = $origin_id;
641 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
642 $line->array_options = $array_options;
644 $this->lines[$num] = $line;
656 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
657 $sql .=
" WHERE rowid = ".((int) $lineid);
659 if ($this->db->query($sql)) {
676 public function delete()
678 global $conf, $langs, $user;
680 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
685 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
686 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
687 if ($this->db->query($sql)) {
695 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
696 $sql .=
" WHERE rowid = ".((int) $this->
id);
697 if ($this->db->query($sql)) {
702 if (!empty($conf->expedition->dir_output)) {
703 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
704 $file = $dir.
'/'.$ref.
'.pdf';
705 if (file_exists($file)) {
710 if (file_exists($dir)) {
712 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
719 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
721 $this->db->rollback();
728 $this->error = $this->db->lasterror().
" - sql=$sql";
729 $this->db->rollback();
733 $this->error = $this->db->lasterror().
" - sql=$sql";
734 $this->db->rollback();
738 $this->error = $this->db->lasterror().
" - sql=$sql";
739 $this->db->rollback();
756 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
757 $datas[
'picto'] .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
769 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
771 global $langs, $hookmanager;
777 'objecttype' => $this->element,
779 $classfortooltip =
'classfortooltip';
782 $classfortooltip =
'classforajaxtooltip';
783 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
789 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
794 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
795 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
796 $add_save_lastsearch_values = 1;
798 if ($add_save_lastsearch_values) {
799 $url .=
'&save_lastsearch_values=1';
803 $linkstart =
'<a href="'.$url.
'"';
804 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
805 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
809 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
811 if ($withpicto && $withpicto != 2) {
814 $result .= $linkstart.$this->ref.$linkend;
817 $hookmanager->initHooks(array($this->element .
'dao'));
818 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
819 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
821 $result = $hookmanager->resPrint;
823 $result .= $hookmanager->resPrint;
837 $this->lines = array();
839 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
840 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
841 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
842 $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";
843 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
844 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
845 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
846 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
848 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
849 $resql = $this->db->query($sql);
851 $num = $this->db->num_rows($resql);
854 $obj = $this->db->fetch_object($resql);
858 $line->id = $obj->rowid;
859 $line->label = $obj->custom_label;
860 $line->description = $obj->description;
861 $line->fk_product = $obj->fk_product;
862 $line->qty_asked = $obj->qty_asked;
863 $line->qty_shipped = $obj->qty_shipped;
865 $line->ref = $obj->product_ref;
866 $line->libelle = $obj->product_label;
867 $line->product_label = $obj->product_label;
868 $line->product_ref = $obj->product_ref;
869 $line->product_desc = $obj->product_desc;
870 $line->product_type = $obj->fk_product_type;
871 $line->fk_origin_line = $obj->fk_origin_line;
873 $line->price = $obj->subprice;
874 $line->total_ht = $obj->total_ht;
877 $line->weight = $obj->weight;
878 $line->weight_units = $obj->weight_units;
879 $line->width = $obj->width;
880 $line->width_units = $obj->width_units;
881 $line->height = $obj->height;
882 $line->height_units = $obj->height_units;
883 $line->length = $obj->length;
884 $line->length_units = $obj->length_units;
885 $line->surface = $obj->surface;
886 $line->surface_units = $obj->surface_units;
887 $line->volume = $obj->volume;
888 $line->volume_units = $obj->volume_units;
890 $line->fk_unit = $obj->fk_unit;
891 $line->fetch_optionals();
893 $this->lines[$i] = $line;
897 $this->db->free($resql);
930 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
933 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
934 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
935 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
936 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
937 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
938 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
941 $statusType =
'status0';
943 $statusType =
'status5';
946 $statusType =
'status4';
949 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
967 $sql =
"SELECT rowid";
968 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
969 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
970 $sql .=
" AND tosell = 1";
971 $sql .= $this->db->plimit(100);
973 $resql = $this->db->query($sql);
975 $num_prods = $this->db->num_rows($resql);
977 while ($i < $num_prods) {
979 $row = $this->db->fetch_row($resql);
980 $prodids[$i] = $row[0];
986 $this->
ref =
'SPECIMEN';
989 $this->date_delivery = $now;
990 $this->note_public =
'Public note';
991 $this->note_private =
'Private note';
995 $line->fk_product = reset($prodids);
996 $line->qty_asked = 10;
997 $line->qty_shipped = 9;
998 $line->ref =
'REFPROD';
999 $line->label =
'Specimen';
1000 $line->description =
'Description';
1002 $line->total_ht = 100;
1004 $this->lines[$i] = $line;
1019 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1020 $sqlSourceLine .=
", p.ref, p.label";
1021 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1022 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1023 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1025 $resultSourceLine = $this->db->query($sqlSourceLine);
1026 if ($resultSourceLine) {
1027 $num_lines = $this->db->num_rows($resultSourceLine);
1030 while ($i < $num_lines) {
1031 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1034 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1035 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1036 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1037 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1038 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1039 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1040 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1041 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1042 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1043 $sql .=
" GROUP BY ld.fk_origin_line";
1045 $result = $this->db->query($sql);
1046 $row = $this->db->fetch_row($result);
1048 if ($objSourceLine->qty - $row[1] > 0) {
1049 if ($row[0] == $objSourceLine->rowid) {
1050 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1052 $array[$i][
'qty'] = $objSourceLine->qty;
1055 $array[$i][
'ref'] = $objSourceLine->ref;
1056 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1057 } elseif ($objSourceLine->qty - $row[1] < 0) {
1058 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1059 $array[$i][
'ref'] = $objSourceLine->ref;
1060 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1067 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1081 if ($user->rights->expedition->creer) {
1082 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1083 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1084 $sql .=
" WHERE rowid = ".((int) $this->
id);
1086 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1087 $resql = $this->db->query($sql);
1089 $this->date_delivery = $delivery_date;
1092 $this->error = $this->db->error();
1110 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1112 global $conf, $langs;
1114 $langs->load(
"deliveries");
1115 $outputlangs->load(
"products");
1120 if ($this->model_pdf) {
1121 $modele = $this->model_pdf;
1122 } elseif (!empty($conf->global->DELIVERY_ADDON_PDF)) {
1123 $modele = $conf->global->DELIVERY_ADDON_PDF;
1127 $modelpath =
"core/modules/delivery/doc/";
1129 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1181 public $element =
'deliverydet';
1186 public $table_element =
'deliverydet';
1196 public $description;
1212 public $qty_shipped;
1215 public $product_desc;
1216 public $product_type;
1217 public $product_ref;
1218 public $product_label;
1222 public $fk_origin_line;
1228 public $origin_line_id;
1235 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...
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='', $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.
update_price($exclspec=0, $roundingadjust='none', $nodatabaseupdate=0, $seller=null)
Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
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.
valid($user, $notrigger=0)
Validate object and update stock if option enabled.
addline($origin_id, $qty, $array_options=null)
Add line.
__construct($db)
Constructor.
static replaceProduct(DoliDB $db, $origin_id, $dest_id)
Function used to replace a product id with another one.
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create object on disk.
fetch($id)
Load a delivery receipt.
create($user)
Create delivery receipt in database.
create_line($origin_id, $qty, $fk_product, $description, $array_options=null)
Create a line.
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.
update_line($id, $array_options=0)
Update a livraison line (only extrafields)
deleteline($lineid)
Delete line.
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...)
print $langs trans("Ref").' m m m statut
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($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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.