31 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
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);
362 if ($this->statut == 0) {
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();
485 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
486 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
487 if (!$error && file_exists($dirsource)) {
488 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
490 if (@rename($dirsource, $dirdest)) {
493 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
494 foreach ($listoffiles as $fileentry) {
495 $dirsource = $fileentry[
'name'];
496 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
497 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
498 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
499 @rename($dirsource, $dirdest);
507 $this->
ref = $numref;
518 $this->db->rollback();
526 $this->error =
"NotAllowed";
527 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
546 $result = $expedition->fetch($sending_id);
551 $this->lines = array();
553 $num = count($expedition->lines);
554 for ($i = 0; $i < $num; $i++) {
556 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
557 $line->label = $expedition->lines[$i]->label;
558 $line->description = $expedition->lines[$i]->description;
559 $line->qty = $expedition->lines[$i]->qty_shipped;
560 $line->fk_product = $expedition->lines[$i]->fk_product;
561 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
562 $line->array_options = $expedition->lines[$i]->array_options;
564 $this->lines[$i] = $line;
567 $this->origin = $expedition->element;
568 $this->origin_id = $expedition->id;
569 $this->note_private = $expedition->note_private;
570 $this->note_public = $expedition->note_public;
571 $this->fk_project = $expedition->fk_project;
572 $this->date_delivery = $expedition->date_delivery;
573 $this->fk_delivery_address = $expedition->fk_delivery_address;
574 $this->socid = $expedition->socid;
575 $this->ref_customer = $expedition->ref_customer;
578 $this->fk_incoterms = $expedition->fk_incoterms;
579 $this->location_incoterms = $expedition->location_incoterms;
581 return $this->
create($user);
598 if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
600 $line->array_options = $array_options;
602 $result = $line->insertExtraFields();
605 $this->error[] = $line->error;
626 public function addline($origin_id, $qty, $array_options =
null)
630 $num = count($this->lines);
633 $line->origin_id = $origin_id;
635 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
636 $line->array_options = $array_options;
638 $this->lines[$num] = $line;
649 if ($this->statut == 0) {
650 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
651 $sql .=
" WHERE rowid = ".((int) $lineid);
653 if ($this->db->query(
$sql)) {
670 public function delete()
672 global $conf, $langs, $user;
674 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
679 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
680 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
681 if ($this->db->query(
$sql)) {
689 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
690 $sql .=
" WHERE rowid = ".((int) $this->
id);
691 if ($this->db->query(
$sql)) {
696 if (!empty($conf->expedition->dir_output)) {
697 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
698 $file = $dir.
'/'.$ref.
'.pdf';
699 if (file_exists($file)) {
704 if (file_exists($dir)) {
706 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
713 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
715 $this->db->rollback();
722 $this->error = $this->db->lasterror().
" - sql=$sql";
723 $this->db->rollback();
727 $this->error = $this->db->lasterror().
" - sql=$sql";
728 $this->db->rollback();
732 $this->error = $this->db->lasterror().
" - sql=$sql";
733 $this->db->rollback();
750 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
751 $datas[
'picto'] .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
763 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
765 global $langs, $hookmanager;
771 'objecttype' => $this->element,
773 $classfortooltip =
'classfortooltip';
776 $classfortooltip =
'classforajaxtooltip';
777 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
783 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
788 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
789 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
790 $add_save_lastsearch_values = 1;
792 if ($add_save_lastsearch_values) {
793 $url .=
'&save_lastsearch_values=1';
797 $linkstart =
'<a href="'.$url.
'"';
798 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
799 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
803 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
805 if ($withpicto && $withpicto != 2) {
808 $result .= $linkstart.$this->ref.$linkend;
811 $hookmanager->initHooks(array($this->element .
'dao'));
812 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
813 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
815 $result = $hookmanager->resPrint;
817 $result .= $hookmanager->resPrint;
831 $this->lines = array();
833 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
834 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
835 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
836 $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";
837 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
838 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
839 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
840 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
842 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
843 $resql = $this->db->query(
$sql);
845 $num = $this->db->num_rows($resql);
848 $obj = $this->db->fetch_object($resql);
852 $line->id = $obj->rowid;
853 $line->label = $obj->custom_label;
854 $line->description = $obj->description;
855 $line->fk_product = $obj->fk_product;
856 $line->qty_asked = $obj->qty_asked;
857 $line->qty_shipped = $obj->qty_shipped;
859 $line->ref = $obj->product_ref;
860 $line->libelle = $obj->product_label;
861 $line->product_label = $obj->product_label;
862 $line->product_ref = $obj->product_ref;
863 $line->product_desc = $obj->product_desc;
864 $line->product_type = $obj->fk_product_type;
865 $line->fk_origin_line = $obj->fk_origin_line;
867 $line->price = $obj->subprice;
868 $line->total_ht = $obj->total_ht;
871 $line->weight = $obj->weight;
872 $line->weight_units = $obj->weight_units;
873 $line->width = $obj->width;
874 $line->width_units = $obj->width_units;
875 $line->height = $obj->height;
876 $line->height_units = $obj->height_units;
877 $line->length = $obj->length;
878 $line->length_units = $obj->length_units;
879 $line->surface = $obj->surface;
880 $line->surface_units = $obj->surface_units;
881 $line->volume = $obj->volume;
882 $line->volume_units = $obj->volume_units;
884 $line->fk_unit = $obj->fk_unit;
885 $line->fetch_optionals();
887 $this->lines[$i] = $line;
891 $this->db->free($resql);
908 return $this->
LibStatut($this->statut, $mode);
924 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
927 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
928 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
929 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
930 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
931 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
932 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
935 $statusType =
'status0';
937 $statusType =
'status5';
940 $statusType =
'status4';
943 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
961 $sql =
"SELECT rowid";
962 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
963 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
964 $sql .=
" AND tosell = 1";
965 $sql .= $this->db->plimit(100);
967 $resql = $this->db->query(
$sql);
969 $num_prods = $this->db->num_rows($resql);
971 while ($i < $num_prods) {
973 $row = $this->db->fetch_row($resql);
974 $prodids[$i] = $row[0];
980 $this->
ref =
'SPECIMEN';
983 $this->date_delivery = $now;
984 $this->note_public =
'Public note';
985 $this->note_private =
'Private note';
989 $line->fk_product = reset($prodids);
990 $line->qty_asked = 10;
991 $line->qty_shipped = 9;
992 $line->ref =
'REFPROD';
993 $line->label =
'Specimen';
994 $line->description =
'Description';
996 $line->total_ht = 100;
998 $this->lines[$i] = $line;
1013 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1014 $sqlSourceLine .=
", p.ref, p.label";
1015 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1016 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1017 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1019 $resultSourceLine = $this->db->query($sqlSourceLine);
1020 if ($resultSourceLine) {
1021 $num_lines = $this->db->num_rows($resultSourceLine);
1024 while ($i < $num_lines) {
1025 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1028 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1029 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1030 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1031 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1032 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1033 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1034 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1035 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1036 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1037 $sql .=
" GROUP BY ld.fk_origin_line";
1039 $result = $this->db->query(
$sql);
1040 $row = $this->db->fetch_row($result);
1042 if ($objSourceLine->qty - $row[1] > 0) {
1043 if ($row[0] == $objSourceLine->rowid) {
1044 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1046 $array[$i][
'qty'] = $objSourceLine->qty;
1049 $array[$i][
'ref'] = $objSourceLine->ref;
1050 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1051 } elseif ($objSourceLine->qty - $row[1] < 0) {
1052 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1053 $array[$i][
'ref'] = $objSourceLine->ref;
1054 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1061 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1075 if ($user->rights->expedition->creer) {
1076 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1077 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1078 $sql .=
" WHERE rowid = ".((int) $this->
id);
1080 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1081 $resql = $this->db->query(
$sql);
1083 $this->date_delivery = $delivery_date;
1086 $this->error = $this->db->error();
1104 public function generateDocument($modele, $outputlangs =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1106 global $conf, $langs;
1108 $langs->load(
"deliveries");
1109 $outputlangs->load(
"products");
1114 if ($this->model_pdf) {
1115 $modele = $this->model_pdf;
1116 } elseif (!empty($conf->global->DELIVERY_ADDON_PDF)) {
1117 $modele = $conf->global->DELIVERY_ADDON_PDF;
1121 $modelpath =
"core/modules/delivery/doc/";
1123 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1175 public $element =
'deliverydet';
1180 public $table_element =
'deliverydet';
1190 public $description;
1206 public $qty_shipped;
1209 public $product_desc;
1210 public $product_type;
1211 public $product_ref;
1212 public $product_label;
1216 public $fk_origin_line;
1222 public $origin_line_id;
1229 public $commande_ligne_id;