30 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
52 public $element =
"delivery";
57 public $fk_element =
"fk_delivery";
62 public $table_element =
"delivery";
67 public $table_element_line =
"deliverydet";
72 public $picto =
'sending';
92 public $date_delivery;
97 public $date_creation;
111 public $lines = array();
124 $this->statuts[-1] =
'StatusDeliveryCanceled';
125 $this->statuts[0] =
'StatusDeliveryDraft';
126 $this->statuts[1] =
'StatusDeliveryValidated';
141 if (empty($this->model_pdf)) {
142 $this->model_pdf = $conf->global->DELIVERY_ADDON_PDF;
156 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
160 $sql .=
", ref_customer";
161 $sql .=
", date_creation";
162 $sql .=
", fk_user_author";
163 $sql .=
", date_delivery";
164 $sql .=
", fk_address";
165 $sql .=
", note_private";
166 $sql .=
", note_public";
167 $sql .=
", model_pdf";
168 $sql .=
", fk_incoterms, location_incoterms";
169 $sql .=
") VALUES (";
171 $sql .=
", ".((int) $conf->entity);
172 $sql .=
", ".((int) $this->socid);
173 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
174 $sql .=
", '".$this->db->idate($now).
"'";
175 $sql .=
", ".((int) $user->id);
176 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
177 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
178 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
179 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
180 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
181 $sql .=
", ".(int) $this->fk_incoterms;
182 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
188 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
190 $numref =
"(PROV".$this->id.
")";
192 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
193 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
194 $sql .=
" WHERE rowid = ".((int) $this->
id);
199 if (!$conf->expedition_bon->enabled) {
201 $commande->id = $this->commande_id;
202 $commande->fetch_lines();
209 $num = count($this->lines);
210 for ($i = 0; $i < $num; $i++) {
211 $origin_id = $this->lines[$i]->origin_line_id;
213 $origin_id = $this->lines[$i]->commande_ligne_id;
216 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
221 if (!$error && $this->
id && $this->origin_id) {
227 if (!$conf->expedition_bon->enabled) {
229 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
241 $this->error = $this->
db->lasterror().
" - sql=".$this->
db->lastqueryerror;
242 $this->
db->rollback();
247 $this->error = $this->
db->lasterror().
" - sql=".$this->
db->lastqueryerror;
248 $this->
db->rollback();
253 $this->error = $this->
db->lasterror().
" - sql=".$this->
db->lastqueryerror;
254 $this->
db->rollback();
270 public function create_line($origin_id, $qty, $fk_product, $description, $array_options =
null)
274 $idprod = $fk_product;
277 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
278 $sql .=
" fk_product, description, qty)";
279 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
280 $sql .=
" ".($idprod > 0 ? ((int) $idprod) :
"null").
",";
281 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
284 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
285 if (!$this->
db->query($sql)) {
289 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
291 if (is_array($array_options) && count($array_options) > 0) {
294 $line->array_options = $array_options;
295 $result = $line->insertExtraFields();
313 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
314 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
315 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
316 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
317 $sql .=
', l.fk_incoterms, l.location_incoterms';
318 $sql .=
", i.libelle as label_incoterms";
319 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
320 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->
db->escape($this->element).
"'";
321 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
322 $sql .=
" WHERE l.rowid = ".((int) $id);
324 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
325 $result = $this->
db->query($sql);
327 if ($this->
db->num_rows($result)) {
328 $obj = $this->
db->fetch_object($result);
330 $this->
id = $obj->rowid;
331 $this->date_delivery = $this->
db->jdate($obj->date_delivery);
332 $this->date_creation = $this->
db->jdate($obj->date_creation);
333 $this->date_valid = $this->
db->jdate($obj->date_valid);
334 $this->
ref = $obj->ref;
335 $this->ref_customer = $obj->ref_customer;
336 $this->socid = $obj->fk_soc;
337 $this->statut = $obj->fk_statut;
338 $this->user_author_id = $obj->fk_user_author;
339 $this->user_valid_id = $obj->fk_user_valid;
340 $this->fk_delivery_address = $obj->fk_address;
341 $this->note = $obj->note_private;
342 $this->note_private = $obj->note_private;
343 $this->note_public = $obj->note_public;
344 $this->model_pdf = $obj->model_pdf;
345 $this->modelpdf = $obj->model_pdf;
346 $this->origin = $obj->origin;
347 $this->origin_id = $obj->origin_id;
350 $this->fk_incoterms = $obj->fk_incoterms;
351 $this->location_incoterms = $obj->location_incoterms;
352 $this->label_incoterms = $obj->label_incoterms;
353 $this->
db->free($result);
355 if ($this->statut == 0) {
371 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
372 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
376 $this->error = $this->
db->error();
388 public function valid($user, $notrigger = 0)
390 global $conf, $langs;
391 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
399 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
400 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) {
401 if (!empty($conf->global->DELIVERY_ADDON_NUMBER)) {
403 $modName = $conf->global->DELIVERY_ADDON_NUMBER;
405 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
406 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
411 $objMod =
new $modName($this->
db);
413 $soc->fetch($this->socid);
415 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
416 $numref = $objMod->delivery_get_num($soc, $this);
418 $numref = $this->ref;
424 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
425 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
426 $sql .=
" AND fk_statut <> 0";
427 $sql .=
" AND entity = ".((int) $conf->entity);
437 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
438 $sql .=
" ref='".$this->db->escape($numref).
"'";
439 $sql .=
", fk_statut = 1";
440 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
441 $sql .=
", fk_user_valid = ".$user->id;
442 $sql .=
" WHERE rowid = ".((int) $this->
id);
443 $sql .=
" AND fk_statut = 0";
448 $this->error = $this->
db->lasterror();
452 if (!$error && !$notrigger) {
454 $result = $this->
call_trigger(
'DELIVERY_VALIDATE', $user);
462 $this->oldref = $this->ref;
465 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
467 $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).
"'";
468 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->
db->escape($this->
ref).
"' and entity = ".((int) $conf->entity);
471 $error++; $this->error = $this->
db->lasterror();
477 $dirsource = $conf->expedition->dir_output.
'/receipt/'.$oldref;
478 $dirdest = $conf->expedition->dir_output.
'/receipt/'.$newref;
479 if (!$error && file_exists($dirsource)) {
480 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
482 if (@rename($dirsource, $dirdest)) {
485 $listoffiles =
dol_dir_list($conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
486 foreach ($listoffiles as $fileentry) {
487 $dirsource = $fileentry[
'name'];
488 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
489 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
490 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
491 @rename($dirsource, $dirdest);
499 $this->
ref = $numref;
510 $this->
db->rollback();
516 $this->error =
"Non autorise";
517 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
536 $result = $expedition->fetch($sending_id);
538 $this->lines = array();
540 $num = count($expedition->lines);
541 for ($i = 0; $i < $num; $i++) {
543 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
544 $line->label = $expedition->lines[$i]->label;
545 $line->description = $expedition->lines[$i]->description;
546 $line->qty = $expedition->lines[$i]->qty_shipped;
547 $line->fk_product = $expedition->lines[$i]->fk_product;
548 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
549 $line->array_options = $expedition->lines[$i]->array_options;
551 $this->lines[$i] = $line;
554 $this->origin = $expedition->element;
555 $this->origin_id = $expedition->id;
556 $this->note_private = $expedition->note_private;
557 $this->note_public = $expedition->note_public;
558 $this->fk_project = $expedition->fk_project;
559 $this->date_delivery = $expedition->date_delivery;
560 $this->fk_delivery_address = $expedition->fk_delivery_address;
561 $this->socid = $expedition->socid;
562 $this->ref_customer = $expedition->ref_customer;
565 $this->fk_incoterms = $expedition->fk_incoterms;
566 $this->location_incoterms = $expedition->location_incoterms;
568 return $this->
create($user);
585 if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
587 $line->array_options = $array_options;
589 $result = $line->insertExtraFields();
592 $this->error[] = $line->error;
613 public function addline($origin_id, $qty, $array_options =
null)
617 $num = count($this->lines);
620 $line->origin_id = $origin_id;
622 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
623 $line->array_options = $array_options;
625 $this->lines[$num] = $line;
636 if ($this->statut == 0) {
637 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
638 $sql .=
" WHERE rowid = ".((int) $lineid);
640 if ($this->
db->query($sql)) {
655 public function delete()
657 global $conf, $langs, $user;
659 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
664 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
665 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
666 if ($this->
db->query($sql)) {
674 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
675 $sql .=
" WHERE rowid = ".((int) $this->
id);
676 if ($this->
db->query($sql)) {
681 if (!empty($conf->expedition->dir_output)) {
682 $dir = $conf->expedition->dir_output.
'/receipt/'.$ref;
683 $file = $dir.
'/'.$ref.
'.pdf';
684 if (file_exists($file)) {
689 if (file_exists($dir)) {
691 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
698 $result = $this->
call_trigger(
'DELIVERY_DELETE', $user);
700 $this->
db->rollback();
707 $this->error = $this->
db->lasterror().
" - sql=$sql";
708 $this->
db->rollback();
712 $this->error = $this->
db->lasterror().
" - sql=$sql";
713 $this->
db->rollback();
717 $this->error = $this->
db->lasterror().
" - sql=$sql";
718 $this->
db->rollback();
730 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
732 global $langs, $hookmanager;
736 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
737 $label .=
'<b>'.$langs->trans(
"Status").
'</b>: '.$this->ref;
739 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
744 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
745 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
746 $add_save_lastsearch_values = 1;
748 if ($add_save_lastsearch_values) {
749 $url .=
'&save_lastsearch_values=1';
754 $linkstart =
'<a href="'.$url.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
758 $result .= ($linkstart.img_object($label, $this->picto,
'class="classfortooltip"').$linkend);
760 if ($withpicto && $withpicto != 2) {
763 $result .= $linkstart.$this->ref.$linkend;
766 $hookmanager->initHooks(array($this->element .
'dao'));
767 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
768 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
770 $result = $hookmanager->resPrint;
772 $result .= $hookmanager->resPrint;
786 $this->lines = array();
788 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ";
789 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
790 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
791 $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";
792 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
793 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
794 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
795 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
797 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
803 $obj = $this->
db->fetch_object(
$resql);
807 $line->id = $obj->rowid;
808 $line->label = $obj->custom_label;
809 $line->description = $obj->description;
810 $line->fk_product = $obj->fk_product;
811 $line->qty_asked = $obj->qty_asked;
812 $line->qty_shipped = $obj->qty_shipped;
814 $line->ref = $obj->product_ref;
815 $line->libelle = $obj->product_label;
816 $line->product_label = $obj->product_label;
817 $line->product_ref = $obj->product_ref;
818 $line->product_desc = $obj->product_desc;
819 $line->product_type = $obj->fk_product_type;
820 $line->fk_origin_line = $obj->fk_origin_line;
822 $line->price = $obj->price;
823 $line->total_ht = $obj->total_ht;
826 $line->weight = $obj->weight;
827 $line->weight_units = $obj->weight_units;
828 $line->width = $obj->width;
829 $line->width_units = $obj->width_units;
830 $line->height = $obj->height;
831 $line->height_units = $obj->height_units;
832 $line->length = $obj->length;
833 $line->length_units = $obj->length_units;
834 $line->surface = $obj->surface;
835 $line->surface_units = $obj->surface_units;
836 $line->volume = $obj->volume;
837 $line->volume_units = $obj->volume_units;
839 $line->fk_unit = $obj->fk_unit;
840 $line->fetch_optionals();
842 $this->lines[$i] = $line;
863 return $this->
LibStatut($this->statut, $mode);
879 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
882 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
883 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
884 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
885 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
886 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
887 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
890 $statusType =
'status0';
892 $statusType =
'status5';
895 $statusType =
'status4';
898 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
911 global $user, $langs, $conf;
918 $sql =
"SELECT rowid";
919 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
920 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
921 $sql .=
" AND tosell = 1";
922 $sql .= $this->
db->plimit(100);
926 $num_prods = $this->
db->num_rows(
$resql);
928 while ($i < $num_prods) {
930 $row = $this->
db->fetch_row(
$resql);
931 $prodids[$i] = $row[0];
937 $this->
ref =
'SPECIMEN';
940 $this->date_delivery = $now;
941 $this->note_public =
'Public note';
942 $this->note_private =
'Private note';
946 $line->fk_product = $prodids[0];
947 $line->qty_asked = 10;
948 $line->qty_shipped = 9;
949 $line->ref =
'REFPROD';
950 $line->label =
'Specimen';
951 $line->description =
'Description';
953 $line->total_ht = 100;
955 $this->lines[$i] = $line;
972 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
973 $sqlSourceLine .=
", p.ref, p.label";
974 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0][
'type'].
"det as st";
975 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
976 $sqlSourceLine .=
" WHERE fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
978 $resultSourceLine = $this->
db->query($sqlSourceLine);
979 if ($resultSourceLine) {
980 $num_lines = $this->
db->num_rows($resultSourceLine);
983 while ($i < $num_lines) {
984 $objSourceLine = $this->
db->fetch_object($resultSourceLine);
987 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
988 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
989 $sql .=
" ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
" as c";
990 $sql .=
", ".MAIN_DB_PREFIX.$this->linked_objects[0][
'type'].
"det as cd";
991 $sql .=
" WHERE ld.fk_delivery = l.rowid";
992 $sql .=
" AND ld.fk_origin_line = cd.rowid";
993 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = c.rowid";
994 $sql .=
" AND cd.fk_".$this->linked_objects[0][
'type'].
" = ".((int) $this->linked_objects[0][
'linkid']);
995 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
996 $sql .=
" GROUP BY ld.fk_origin_line";
998 $result = $this->
db->query($sql);
999 $row = $this->
db->fetch_row($result);
1001 if ($objSourceLine->qty - $row[1] > 0) {
1002 if ($row[0] == $objSourceLine->rowid) {
1003 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1005 $array[$i][
'qty'] = $objSourceLine->qty;
1008 $array[$i][
'ref'] = $objSourceLine->ref;
1009 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1010 } elseif ($objSourceLine->qty - $row[1] < 0) {
1011 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1012 $array[$i][
'ref'] = $objSourceLine->ref;
1013 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1020 $this->error = $this->
db->error().
" - sql=$sqlSourceLine";
1034 if ($user->rights->expedition->creer) {
1035 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1036 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1037 $sql .=
" WHERE rowid = ".((int) $this->
id);
1039 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1042 $this->date_delivery = $delivery_date;
1045 $this->error = $this->
db->error();
1063 public function generateDocument($modele, $outputlangs =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1065 global $conf, $user, $langs;
1067 $langs->load(
"deliveries");
1068 $outputlangs->load(
"products");
1073 if ($this->model_pdf) {
1074 $modele = $this->model_pdf;
1075 } elseif (!empty($conf->global->DELIVERY_ADDON_PDF)) {
1076 $modele = $conf->global->DELIVERY_ADDON_PDF;
1080 $modelpath =
"core/modules/delivery/doc/";
1082 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1135 public $element =
'deliverydet';
1140 public $table_element =
'deliverydet';
1150 public $description;
1166 public $qty_shipped;
1169 public $product_desc;
1170 public $product_type;
1171 public $product_ref;
1172 public $product_label;
1174 public $fk_origin_line;
1179 public $origin_line_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).
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
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 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.
generateDocument($modele, $outputlangs='', $hidedetails=0, $hidedesc=0, $hideref=0)
Create object on disk.
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.
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.
getLibStatut($mode=0)
Retourne le libelle du statut d'une expedition.
LibStatut($status, $mode)
Renvoi le libelle d'un statut donne.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid 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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.