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();
125 public $user_author_id;
138 $this->labelStatus[-1] =
'StatusDeliveryCanceled';
139 $this->labelStatus[0] =
'StatusDeliveryDraft';
140 $this->labelStatus[1] =
'StatusDeliveryValidated';
155 if (empty($this->model_pdf)) {
156 $this->model_pdf = $conf->global->DELIVERY_ADDON_PDF;
170 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
174 $sql .=
", ref_customer";
175 $sql .=
", date_creation";
176 $sql .=
", fk_user_author";
177 $sql .=
", date_delivery";
178 $sql .=
", fk_address";
179 $sql .=
", note_private";
180 $sql .=
", note_public";
181 $sql .=
", model_pdf";
182 $sql .=
", fk_incoterms, location_incoterms";
183 $sql .=
") VALUES (";
185 $sql .=
", ".((int) $conf->entity);
186 $sql .=
", ".((int) $this->socid);
187 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
188 $sql .=
", '".$this->db->idate($now).
"'";
189 $sql .=
", ".((int) $user->id);
190 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
191 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
192 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
193 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
194 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
195 $sql .=
", ".(int) $this->fk_incoterms;
196 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
200 $resql = $this->db->query($sql);
202 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
204 $numref =
"(PROV".$this->id.
")";
206 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
207 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
208 $sql .=
" WHERE rowid = ".((int) $this->
id);
211 $resql = $this->db->query($sql);
214 $commande =
new Commande($this->db);
215 $commande->id = $this->commande_id;
216 $commande->fetch_lines();
223 $num = count($this->lines);
224 for ($i = 0; $i < $num; $i++) {
225 $origin_id = $this->lines[$i]->origin_line_id;
227 $origin_id = $this->lines[$i]->commande_ligne_id;
230 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
235 if (!$error && $this->
id && $this->origin_id) {
242 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
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();
266 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
267 $this->db->rollback();
283 public function create_line($origin_id, $qty, $fk_product, $description, $array_options =
null)
287 $idprod = $fk_product;
289 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
290 $sql .=
" fk_product, description, qty)";
291 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
292 $sql .=
" ".($idprod > 0 ? ((int) $idprod) :
"null").
",";
293 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
296 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
297 if (!$this->db->query($sql)) {
301 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
303 if (is_array($array_options) && count($array_options) > 0) {
306 $line->array_options = $array_options;
307 $result = $line->insertExtraFields();
325 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
326 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
327 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
328 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
329 $sql .=
', l.fk_incoterms, l.location_incoterms';
330 $sql .=
", i.libelle as label_incoterms";
331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
332 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
333 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
334 $sql .=
" WHERE l.rowid = ".((int) $id);
336 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
337 $result = $this->db->query($sql);
339 if ($this->db->num_rows($result)) {
340 $obj = $this->db->fetch_object($result);
342 $this->
id = $obj->rowid;
343 $this->date_delivery = $this->db->jdate($obj->date_delivery);
344 $this->date_creation = $this->db->jdate($obj->date_creation);
345 $this->date_valid = $this->db->jdate($obj->date_valid);
346 $this->
ref = $obj->ref;
347 $this->ref_customer = $obj->ref_customer;
348 $this->socid = $obj->fk_soc;
349 $this->
statut = $obj->fk_statut;
350 $this->
status = $obj->fk_statut;
351 $this->user_author_id = $obj->fk_user_author;
352 $this->user_validation_id = $obj->fk_user_valid;
353 $this->fk_delivery_address = $obj->fk_address;
354 $this->note = $obj->note_private;
355 $this->note_private = $obj->note_private;
356 $this->note_public = $obj->note_public;
357 $this->model_pdf = $obj->model_pdf;
358 $this->origin = $obj->origin;
359 $this->origin_id = $obj->origin_id;
362 $this->fk_incoterms = $obj->fk_incoterms;
363 $this->location_incoterms = $obj->location_incoterms;
364 $this->label_incoterms = $obj->label_incoterms;
365 $this->db->free($result);
383 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
384 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
388 $this->error = $this->db->error();
400 public function valid($user, $notrigger = 0)
404 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
412 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
413 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
416 $modName = $conf->global->DELIVERY_ADDON_NUMBER;
418 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
419 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
424 $objMod =
new $modName($this->db);
426 $soc->fetch($this->socid);
428 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
429 $numref = $objMod->delivery_get_num($soc, $this);
431 $numref = $this->ref;
437 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
438 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
439 $sql .=
" AND fk_statut <> 0";
440 $sql .=
" AND entity = ".((int) $conf->entity);
442 $resql = $this->db->query($sql);
444 $num = $this->db->num_rows($resql);
450 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
451 $sql .=
" ref='".$this->db->escape($numref).
"'";
452 $sql .=
", fk_statut = 1";
453 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
454 $sql .=
", fk_user_valid = ".$user->id;
455 $sql .=
" WHERE rowid = ".((int) $this->
id);
456 $sql .=
" AND fk_statut = 0";
458 $resql = $this->db->query($sql);
461 $this->error = $this->db->lasterror();
465 if (!$error && !$notrigger) {
467 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
475 $this->oldref = $this->ref;
478 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
480 $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).
"'";
481 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
482 $resql = $this->db->query($sql);
485 $this->error = $this->db->lasterror();
487 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
488 $sql .=
" WHERE filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
489 $resql = $this->db->query($sql);
492 $this->error = $this->db->lasterror();
498 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
499 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
500 if (!$error && file_exists($dirsource)) {
501 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
503 if (@rename($dirsource, $dirdest)) {
506 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
507 foreach ($listoffiles as $fileentry) {
508 $dirsource = $fileentry[
'name'];
509 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
510 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
511 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
512 @rename($dirsource, $dirdest);
520 $this->
ref = $numref;
531 $this->db->rollback();
539 $this->error =
"NotAllowed";
540 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
564 $this->lines = array();
567 for ($i = 0; $i < $num; $i++) {
569 $line->origin_line_id =
$expedition->lines[$i]->origin_line_id;
571 $line->description =
$expedition->lines[$i]->description;
573 $line->fk_product =
$expedition->lines[$i]->fk_product;
575 $line->array_options =
$expedition->lines[$i]->array_options;
577 $this->lines[$i] = $line;
586 $this->fk_delivery_address =
$expedition->fk_delivery_address;
592 $this->location_incoterms =
$expedition->location_incoterms;
594 return $this->
create($user);
611 if ($id > 0 && !$error && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
613 $line->array_options = $array_options;
615 $result = $line->insertExtraFields();
618 $this->error[] = $line->error;
639 public function addline($origin_id, $qty, $array_options =
null)
643 $num = count($this->lines);
646 $line->origin_id = $origin_id;
648 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
649 $line->array_options = $array_options;
651 $this->lines[$num] = $line;
663 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
664 $sql .=
" WHERE rowid = ".((int) $lineid);
666 if ($this->db->query($sql)) {
684 public function delete($user =
null)
686 global $conf, $langs;
688 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
694 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
695 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
696 if ($this->db->query($sql)) {
704 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
705 $sql .=
" WHERE rowid = ".((int) $this->
id);
706 if ($this->db->query($sql)) {
711 if (!empty($conf->expedition->dir_output)) {
712 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
713 $file = $dir.
'/'.$ref.
'.pdf';
714 if (file_exists($file)) {
719 if (file_exists($dir)) {
721 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
728 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
730 $this->db->rollback();
737 $this->error = $this->db->lasterror().
" - sql=$sql";
738 $this->db->rollback();
742 $this->error = $this->db->lasterror().
" - sql=$sql";
743 $this->db->rollback();
747 $this->error = $this->db->lasterror().
" - sql=$sql";
748 $this->db->rollback();
763 $langs->load(
'deliveries');
767 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
768 $datas[
'picto'] .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
780 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
782 global $langs, $hookmanager;
788 'objecttype' => $this->element,
790 $classfortooltip =
'classfortooltip';
793 $classfortooltip =
'classforajaxtooltip';
794 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
800 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
805 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
806 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
807 $add_save_lastsearch_values = 1;
809 if ($add_save_lastsearch_values) {
810 $url .=
'&save_lastsearch_values=1';
814 $linkstart =
'<a href="'.$url.
'"';
815 $linkstart .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
816 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
820 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
822 if ($withpicto && $withpicto != 2) {
825 $result .= $linkstart.$this->ref.$linkend;
828 $hookmanager->initHooks(array($this->element .
'dao'));
829 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
830 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
832 $result = $hookmanager->resPrint;
834 $result .= $hookmanager->resPrint;
848 $this->lines = array();
850 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
851 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
852 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
853 $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";
854 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
855 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
856 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
857 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
859 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
860 $resql = $this->db->query($sql);
862 $num = $this->db->num_rows($resql);
865 $obj = $this->db->fetch_object($resql);
869 $line->id = $obj->rowid;
870 $line->label = $obj->custom_label;
871 $line->description = $obj->description;
872 $line->fk_product = $obj->fk_product;
873 $line->qty_asked = $obj->qty_asked;
874 $line->qty_shipped = $obj->qty_shipped;
876 $line->product_label = $obj->product_label;
877 $line->product_ref = $obj->product_ref;
878 $line->product_desc = $obj->product_desc;
879 $line->product_type = $obj->fk_product_type;
881 $line->fk_origin_line = $obj->fk_origin_line;
883 $line->price = $obj->subprice;
884 $line->total_ht = $obj->total_ht;
887 $line->weight = $obj->weight;
888 $line->weight_units = $obj->weight_units;
889 $line->width = $obj->width;
890 $line->width_units = $obj->width_units;
891 $line->height = $obj->height;
892 $line->height_units = $obj->height_units;
893 $line->length = $obj->length;
894 $line->length_units = $obj->length_units;
895 $line->surface = $obj->surface;
896 $line->surface_units = $obj->surface_units;
897 $line->volume = $obj->volume;
898 $line->volume_units = $obj->volume_units;
900 $line->fk_unit = $obj->fk_unit;
901 $line->fetch_optionals();
903 $this->lines[$i] = $line;
907 $this->db->free($resql);
940 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
943 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
944 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
945 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
946 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
947 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
948 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
951 $statusType =
'status0';
953 $statusType =
'status5';
956 $statusType =
'status4';
959 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
977 $sql =
"SELECT rowid";
978 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
979 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
980 $sql .=
" AND tosell = 1";
981 $sql .= $this->db->plimit(100);
983 $resql = $this->db->query($sql);
985 $num_prods = $this->db->num_rows($resql);
987 while ($i < $num_prods) {
989 $row = $this->db->fetch_row($resql);
990 $prodids[$i] = $row[0];
996 $this->
ref =
'SPECIMEN';
999 $this->date_delivery = $now;
1000 $this->note_public =
'Public note';
1001 $this->note_private =
'Private note';
1005 $line->fk_product = reset($prodids);
1006 $line->qty_asked = 10;
1007 $line->qty_shipped = 9;
1008 $line->ref =
'REFPROD';
1009 $line->label =
'Specimen';
1010 $line->description =
'Description';
1012 $line->total_ht = 100;
1014 $this->lines[$i] = $line;
1029 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1030 $sqlSourceLine .=
", p.ref, p.label";
1031 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
1032 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1033 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1035 $resultSourceLine = $this->db->query($sqlSourceLine);
1036 if ($resultSourceLine) {
1037 $num_lines = $this->db->num_rows($resultSourceLine);
1040 while ($i < $num_lines) {
1041 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1044 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1045 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1046 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
1047 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
1048 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1049 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1050 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
1051 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
1052 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1053 $sql .=
" GROUP BY ld.fk_origin_line";
1055 $result = $this->db->query($sql);
1056 $row = $this->db->fetch_row($result);
1058 if ($objSourceLine->qty - $row[1] > 0) {
1059 if ($row[0] == $objSourceLine->rowid) {
1060 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1062 $array[$i][
'qty'] = $objSourceLine->qty;
1065 $array[$i][
'ref'] = $objSourceLine->ref;
1066 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1067 } elseif ($objSourceLine->qty - $row[1] < 0) {
1068 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1069 $array[$i][
'ref'] = $objSourceLine->ref;
1070 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1077 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1091 if ($user->hasRight(
'expedition',
'creer')) {
1092 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1093 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1094 $sql .=
" WHERE rowid = ".((int) $this->
id);
1096 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1097 $resql = $this->db->query($sql);
1099 $this->date_delivery = $delivery_date;
1102 $this->error = $this->db->error();
1120 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1122 global $conf, $langs;
1124 $langs->load(
"deliveries");
1125 $outputlangs->load(
"products");
1130 if ($this->model_pdf) {
1131 $modele = $this->model_pdf;
1133 $modele = $conf->global->DELIVERY_ADDON_PDF;
1137 $modelpath =
"core/modules/delivery/doc/";
1139 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1191 public $element =
'deliverydet';
1196 public $table_element =
'deliverydet';
1206 public $description;
1222 public $qty_shipped;
1225 public $product_desc;
1226 public $product_type;
1227 public $product_ref;
1228 public $product_label;
1232 public $fk_origin_line;
1238 public $origin_line_id;
1245 public $commande_ligne_id;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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=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.
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...)
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 a 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.
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut