32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54 public $element =
"delivery";
60 public $TRIGGER_PREFIX =
'DELIVERY';
65 public $fk_element =
"fk_delivery";
70 public $table_element =
"delivery";
75 public $table_element_line =
"deliverydet";
80 public $picto =
'sending';
100 public $date_delivery;
120 public $lines = array();
125 public $user_author_id;
128 const STATUS_DRAFT = 0;
129 const STATUS_VALIDATED = 1;
130 const STATUS_CANCELED = -1;
143 $this->labelStatus[-1] =
'StatusDeliveryCanceled';
144 $this->labelStatus[0] =
'StatusDeliveryDraft';
145 $this->labelStatus[1] =
'StatusDeliveryValidated';
160 if (empty($this->model_pdf)) {
166 $this->ref_customer = trim((
string) $this->ref_customer);
175 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"delivery (";
179 $sql .=
", ref_customer";
180 $sql .=
", date_creation";
181 $sql .=
", fk_user_author";
182 $sql .=
", date_delivery";
183 $sql .=
", fk_address";
184 $sql .=
", note_private";
185 $sql .=
", note_public";
186 $sql .=
", model_pdf";
187 $sql .=
", fk_incoterms, location_incoterms";
188 $sql .=
") VALUES (";
190 $sql .=
", ".((int)
$conf->entity);
191 $sql .=
", ".((int) $this->socid);
192 $sql .=
", '".$this->db->escape($this->ref_customer).
"'";
193 $sql .=
", '".$this->db->idate($now).
"'";
194 $sql .=
", ".((int) $user->id);
195 $sql .=
", ".($this->date_delivery ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
196 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
197 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
198 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
199 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
200 $sql .=
", ".(int) $this->fk_incoterms;
201 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
206 $resql = $this->db->query($sql);
208 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"delivery");
210 $numref =
"(PROV".$this->id.
")";
212 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery ";
213 $sql .=
"SET ref = '".$this->db->escape($numref).
"'";
214 $sql .=
" WHERE rowid = ".((int) $this->
id);
217 $resql = $this->db->query($sql);
220 $commande =
new Commande($this->db);
221 $commande->id = $this->commande_id;
222 $commande->fetch_lines();
229 $num = count($this->lines);
230 for ($i = 0; $i < $num; $i++) {
231 $origin_id = $this->lines[$i]->origin_line_id;
233 $origin_id = $this->lines[$i]->commande_ligne_id;
236 if (!$this->
create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->
description, $this->lines[$i]->array_options)) {
241 if (!$error && $this->
id && $this->origin_id) {
248 $ret = $this->
setStatut(2, $this->origin_id, $this->origin);
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();
272 $this->error = $this->db->lasterror().
" - sql=".$this->db->lastqueryerror;
273 $this->db->rollback();
289 public function create_line($origin_id, $qty, $fk_product, $description, $array_options = [])
294 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deliverydet (fk_delivery, fk_origin_line,";
295 $sql .=
" fk_product, description, qty)";
296 $sql .=
" VALUES (".$this->id.
",".((int) $origin_id).
",";
297 $sql .=
" ".($fk_product > 0 ? ((int) $fk_product) :
"null").
",";
298 $sql .=
" ".($description ?
"'".$this->db->escape($description).
"'" :
"null").
",";
301 dol_syslog(get_class($this).
"::create_line", LOG_DEBUG);
302 if (!$this->db->query($sql)) {
306 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deliverydet");
308 if (is_array($array_options) && count($array_options) > 0) {
311 $line->array_options = $array_options;
312 $result = $line->insertExtraFields();
330 $sql =
"SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
331 $sql .=
" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
332 $sql .=
", l.date_delivery, l.fk_address, l.model_pdf";
333 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
334 $sql .=
', l.fk_incoterms, l.location_incoterms';
335 $sql .=
", i.libelle as label_incoterms";
336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery as l";
337 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
338 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON l.fk_incoterms = i.rowid';
339 $sql .=
" WHERE l.rowid = ".((int) $id);
341 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
342 $result = $this->db->query($sql);
344 if ($this->db->num_rows($result)) {
345 $obj = $this->db->fetch_object($result);
347 $this->
id = $obj->rowid;
348 $this->date_delivery = $this->db->jdate($obj->date_delivery);
349 $this->date_creation = $this->db->jdate($obj->date_creation);
350 $this->date_valid = $this->db->jdate($obj->date_valid);
351 $this->
ref = $obj->ref;
352 $this->ref_customer = $obj->ref_customer;
353 $this->socid = $obj->fk_soc;
354 $this->statut = $obj->fk_statut;
355 $this->
status = $obj->fk_statut;
356 $this->user_author_id = $obj->fk_user_author;
357 $this->user_validation_id = $obj->fk_user_valid;
358 $this->fk_delivery_address = $obj->fk_address;
359 $this->note = $obj->note_private;
360 $this->note_private = $obj->note_private;
361 $this->note_public = $obj->note_public;
362 $this->model_pdf = $obj->model_pdf;
363 $this->origin = $obj->origin;
364 $this->origin_type = $obj->origin;
365 $this->origin_id = $obj->origin_id;
368 $this->fk_incoterms = $obj->fk_incoterms;
369 $this->location_incoterms = $obj->location_incoterms;
370 $this->label_incoterms = $obj->label_incoterms;
371 $this->db->free($result);
389 $this->error =
'Delivery with id '.$id.
' not found sql='.$sql;
390 dol_syslog(get_class($this).
'::fetch Error '.$this->error, LOG_ERR);
394 $this->error = $this->db->error();
406 public function valid($user, $notrigger = 0)
410 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
414 if (!isset($this->socid)) {
415 dol_syslog(get_class($this).
"::can't valid socid not set", LOG_WARNING);
423 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
424 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
429 if (is_readable(DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php')) {
430 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/'.$modName.
'.php';
435 $objMod =
new $modName($this->db);
436 '@phan-var-force ModeleNumRefDeliveryOrder $objMod';
439 $soc->fetch($this->socid);
441 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
442 $numref = $objMod->getNextValue($soc, $this);
450 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
451 $sql .=
" WHERE ref = '".$this->db->escape($numref).
"'";
452 $sql .=
" AND fk_statut <> 0";
453 $sql .=
" AND entity = ".((int)
$conf->entity);
455 $resql = $this->db->query($sql);
457 $num = $this->db->num_rows($resql);
463 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery SET";
464 $sql .=
" ref = '".$this->db->escape($numref).
"'";
465 $sql .=
", fk_statut = 1";
466 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
467 if (!empty($this->date_delivery)) {
468 $sql .=
", date_delivery = '".$this->db->idate($this->date_delivery).
"'";
470 $sql .=
", fk_user_valid = ".((int) $user->id);
471 $sql .=
" WHERE rowid = ".((int) $this->
id);
472 $sql .=
" AND fk_statut = 0";
474 $resql = $this->db->query($sql);
477 $this->error = $this->db->lasterror();
481 if (!$error && !$notrigger) {
483 $result = $this->call_trigger(
'DELIVERY_VALIDATE', $user);
491 $this->oldref = $this->ref;
494 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
496 $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).
"'";
497 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
498 $resql = $this->db->query($sql);
501 $this->error = $this->db->lasterror();
503 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/receipt/".$this->db->escape($this->newref).
"'";
504 $sql .=
" WHERE filepath = 'expedition/receipt/".$this->db->escape($this->
ref).
"' and entity = ".
$conf->entity;
505 $resql = $this->db->query($sql);
508 $this->error = $this->db->lasterror();
514 $dirsource =
$conf->expedition->dir_output.
'/receipt/'.$oldref;
515 $dirdest =
$conf->expedition->dir_output.
'/receipt/'.$newref;
516 if (!$error && file_exists($dirsource)) {
517 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
519 if (@rename($dirsource, $dirdest)) {
522 $listoffiles =
dol_dir_list(
$conf->expedition->dir_output.
'/receipt/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
523 foreach ($listoffiles as $fileentry) {
524 $dirsource = $fileentry[
'name'];
525 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
526 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
527 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
528 @rename($dirsource, $dirdest);
536 $this->
ref = $numref;
547 $this->db->rollback();
555 $this->error =
"NotAllowed";
556 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
575 $result = $expedition->fetch($sending_id);
580 $this->lines = array();
582 $num = count($expedition->lines);
583 for ($i = 0; $i < $num; $i++) {
585 $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
586 $line->label = $expedition->lines[$i]->label;
587 $line->description = $expedition->lines[$i]->description;
588 $line->qty = $expedition->lines[$i]->qty_shipped;
589 $line->fk_product = $expedition->lines[$i]->fk_product;
590 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) {
591 $line->array_options = $expedition->lines[$i]->array_options;
593 $this->lines[$i] = $line;
596 $this->origin = $expedition->element;
597 $this->origin_id = $expedition->id;
598 $this->note_private = $expedition->note_private;
599 $this->note_public = $expedition->note_public;
600 $this->fk_project = $expedition->fk_project;
601 $this->date_delivery =
'';
602 $this->fk_delivery_address = $expedition->fk_delivery_address;
603 $this->socid = $expedition->socid;
604 $this->ref_customer = $expedition->ref_customer;
607 $this->fk_incoterms = $expedition->fk_incoterms;
608 $this->location_incoterms = $expedition->location_incoterms;
610 return $this->
create($user);
627 if ($id > 0 && !$error && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
629 $line->array_options = $array_options;
631 $result = $line->insertExtraFields();
634 $this->errors[] = $line->error;
655 public function addline($origin_id, $qty, $array_options = [])
657 $num = count($this->lines);
660 $line->origin_id = $origin_id;
662 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
663 $line->array_options = $array_options;
665 $this->lines[$num] = $line;
677 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commandedet";
678 $sql .=
" WHERE rowid = ".((int) $lineid);
680 if ($this->db->query($sql)) {
698 public function delete($user =
null)
700 global
$conf, $langs;
702 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
708 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deliverydet";
709 $sql .=
" WHERE fk_delivery = ".((int) $this->
id);
710 if ($this->db->query($sql)) {
718 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"delivery";
719 $sql .=
" WHERE rowid = ".((int) $this->
id);
720 if ($this->db->query($sql)) {
725 if (!empty(
$conf->expedition->dir_output)) {
726 $dir =
$conf->expedition->dir_output.
'/receipt/'.$ref;
727 $file = $dir.
'/'.$ref.
'.pdf';
728 if (file_exists($file)) {
733 if (file_exists($dir)) {
735 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
742 $result = $this->call_trigger(
'DELIVERY_DELETE', $user);
744 $this->db->rollback();
751 $this->error = $this->db->lasterror().
" - sql=$sql";
752 $this->db->rollback();
756 $this->error = $this->db->lasterror().
" - sql=$sql";
757 $this->db->rollback();
761 $this->error = $this->db->lasterror().
" - sql=$sql";
762 $this->db->rollback();
777 $langs->load(
'sendings');
781 $datas[
'picto'] =
img_picto(
'', $this->picto,
'', 0, 0, 0,
'',
'paddingrightonly').
' <u>'.$langs->trans(
"ShowReceiving").
'</u>:<br>';
782 $datas[
'ref'] =
'<b>'.$langs->trans(
"Ref").
'</b>: '.$this->ref;
794 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1)
796 global $langs, $hookmanager;
802 'objecttype' => $this->element,
804 $classfortooltip =
'classfortooltip';
807 $classfortooltip =
'classforajaxtooltip';
808 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
814 $url = DOL_URL_ROOT.
'/delivery/card.php?id='.$this->id;
819 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
820 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
821 $add_save_lastsearch_values = 1;
823 if ($add_save_lastsearch_values) {
824 $url .=
'&save_lastsearch_values=1';
828 $linkstart =
'<a href="'.$url.
'"';
829 $linkstart .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
830 $linkstart .= $dataparams.
' class="'.$classfortooltip.
'">';
834 $result .= ($linkstart.img_object($label, $this->picto, $dataparams.
' class="'.$classfortooltip.
'"').$linkend);
836 if ($withpicto && $withpicto != 2) {
839 $result .= $linkstart.$this->ref.$linkend;
842 $hookmanager->initHooks(array($this->element .
'dao'));
843 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
844 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
846 $result = $hookmanager->resPrint;
848 $result .= $hookmanager->resPrint;
862 $this->lines = array();
864 $sql =
"SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, ld.extraparams,";
865 $sql .=
" cd.qty as qty_asked, cd.label as custom_label, cd.fk_unit,";
866 $sql .=
" p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc,";
867 $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";
868 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd, ".MAIN_DB_PREFIX.
"deliverydet as ld";
869 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p on p.rowid = ld.fk_product";
870 $sql .=
" WHERE ld.fk_origin_line = cd.rowid";
871 $sql .=
" AND ld.fk_delivery = ".((int) $this->
id);
873 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
874 $resql = $this->db->query($sql);
876 $num = $this->db->num_rows($resql);
879 $obj = $this->db->fetch_object($resql);
883 $line->id = $obj->rowid;
884 $line->label = $obj->custom_label;
885 $line->description = $obj->description;
886 $line->fk_product = $obj->fk_product;
887 $line->qty_asked = $obj->qty_asked;
888 $line->qty_shipped = $obj->qty_shipped;
890 $line->product_label = $obj->product_label;
891 $line->product_ref = $obj->product_ref;
892 $line->product_desc = $obj->product_desc;
893 $line->product_type = $obj->fk_product_type;
895 $line->fk_origin_line = $obj->fk_origin_line;
897 $line->price = $obj->subprice;
898 $line->total_ht = $obj->total_ht;
901 $line->weight = $obj->weight;
902 $line->weight_units = $obj->weight_units;
903 $line->width = $obj->width;
904 $line->width_units = $obj->width_units;
905 $line->height = $obj->height;
906 $line->height_units = $obj->height_units;
907 $line->length = $obj->length;
908 $line->length_units = $obj->length_units;
909 $line->surface = $obj->surface;
910 $line->surface_units = $obj->surface_units;
911 $line->volume = $obj->volume;
912 $line->volume_units = $obj->volume_units;
914 $line->fk_unit = $obj->fk_unit;
915 $line->fetch_optionals();
917 $line->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams,
true) : array();
919 $this->lines[$i] = $line;
923 $this->db->free($resql);
956 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
959 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
960 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
961 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
962 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
'StatusDeliveryCanceled');
963 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'StatusDeliveryDraft');
964 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'StatusDeliveryValidated');
967 $statusType =
'status0';
969 $statusType =
'status5';
972 $statusType =
'status4';
975 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
993 $sql =
"SELECT rowid";
994 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
995 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
996 $sql .=
" AND tosell = 1";
997 $sql .= $this->db->plimit(100);
999 $resql = $this->db->query($sql);
1001 $num_prods = $this->db->num_rows($resql);
1003 while ($i < $num_prods) {
1005 $row = $this->db->fetch_row($resql);
1006 $prodids[$i] = $row[0];
1012 $this->
ref =
'SPECIMEN';
1013 $this->specimen = 1;
1015 $this->date_delivery = $now;
1016 $this->note_public =
'Public note';
1017 $this->note_private =
'Private note';
1021 $line->fk_product = reset($prodids);
1022 $line->qty_asked = 10;
1023 $line->qty_shipped = 9;
1024 $line->product_ref =
'REFPROD';
1025 $line->label =
'Specimen';
1026 $line->description =
'Description';
1028 $line->total_ht = 100;
1030 $this->lines[$i] = $line;
1047 $sqlSourceLine =
"SELECT st.rowid, st.description, st.qty";
1048 $sqlSourceLine .=
", p.ref, p.label";
1049 $sqlSourceLine .=
" FROM ".MAIN_DB_PREFIX.$this->db->sanitize($this->linkedObjectsIds[0][
'type']).
"det as st";
1050 $sqlSourceLine .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON st.fk_product = p.rowid";
1051 $sqlSourceLine .=
" WHERE fk_".$this->db->sanitize($this->linked_objects[0][
'type']).
" = ".((int) $this->linked_objects[0][
'linkid']);
1053 $resultSourceLine = $this->db->query($sqlSourceLine);
1054 if ($resultSourceLine) {
1055 $num_lines = $this->db->num_rows($resultSourceLine);
1058 while ($i < $num_lines) {
1059 $objSourceLine = $this->db->fetch_object($resultSourceLine);
1062 $sql =
"SELECT ld.fk_origin_line, sum(ld.qty) as qty";
1063 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deliverydet as ld, ".MAIN_DB_PREFIX.
"delivery as l,";
1064 $sql .=
" ".MAIN_DB_PREFIX.$this->db->sanitize($this->linked_objects[0][
'type']).
" as c";
1065 $sql .=
", ".MAIN_DB_PREFIX.$this->db->sanitize($this->linked_objects[0][
'type']).
"det as cd";
1066 $sql .=
" WHERE ld.fk_delivery = l.rowid";
1067 $sql .=
" AND ld.fk_origin_line = cd.rowid";
1068 $sql .=
" AND cd.fk_".$this->db->sanitize($this->linked_objects[0][
'type']).
" = c.rowid";
1069 $sql .=
" AND cd.fk_".$this->db->sanitize($this->linked_objects[0][
'type']).
" = ".((int) $this->linked_objects[0][
'linkid']);
1070 $sql .=
" AND ld.fk_origin_line = ".((int) $objSourceLine->rowid);
1071 $sql .=
" GROUP BY ld.fk_origin_line";
1073 $result = $this->db->query($sql);
1074 $row = $this->db->fetch_row($result);
1076 if ($objSourceLine->qty - $row[1] > 0) {
1077 if ($row[0] == $objSourceLine->rowid) {
1078 $array[$i][
'qty'] = $objSourceLine->qty - $row[1];
1080 $array[$i][
'qty'] = $objSourceLine->qty;
1083 $array[$i][
'ref'] = $objSourceLine->ref;
1084 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1085 } elseif ($objSourceLine->qty - $row[1] < 0) {
1086 $array[$i][
'qty'] = $objSourceLine->qty - $row[1].
" Erreur livraison !";
1087 $array[$i][
'ref'] = $objSourceLine->ref;
1088 $array[$i][
'label'] = $objSourceLine->label ? $objSourceLine->label : $objSourceLine->description;
1095 $this->error = $this->db->error().
" - sql=$sqlSourceLine";
1109 if ($user->hasRight(
'expedition',
'creer')) {
1110 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"delivery";
1111 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1112 $sql .=
" WHERE rowid = ".((int) $this->
id);
1114 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1115 $resql = $this->db->query($sql);
1117 $this->date_delivery = $delivery_date;
1120 $this->error = $this->db->error();
1138 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1142 $langs->load(
"sendings");
1143 $outputlangs->load(
"products");
1148 if ($this->model_pdf) {
1149 $modele = $this->model_pdf;
1155 $modelpath =
"core/modules/delivery/doc/";
1157 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1209 public $element =
'deliverydet';
1214 public $table_element =
'deliverydet';
1224 public $description;
1253 public $qty_shipped;
1262 public $product_desc;
1266 public $product_type;
1270 public $product_ref;
1274 public $product_label;
1284 public $fk_origin_line;
1293 public $origin_line_id;
1300 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...
update_price($exclspec=0, $roundingadjust='auto', $nodatabaseupdate=0, $seller=null)
Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='')
Set status of an object.
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.
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.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage receptions.
create_line($origin_id, $qty, $fk_product, $description, $array_options=[])
Create a line.
__construct($db)
Constructor.
static replaceProduct(DoliDB $db, $origin_id, $dest_id)
Function used to replace a product id with another one.
deleteLine($lineid)
Delete line.
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create object on disk.
update_line($id, $array_options=[])
Update a livraison line (only extrafields)
addline($origin_id, $qty, $array_options=[])
Add line.
fetch($id)
Load a delivery receipt.
create($user)
Create delivery receipt in database.
initAsSpecimen()
Initialise an instance with random values.
create_from_sending($user, $sending_id)
Creating the delivery slip from an existing shipment.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
getTooltipContentArray($params)
getTooltipContentArray
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode)
Return the label of a given status.
fetch_lines()
Load lines insto $this->lines.
getRemainingDelivered()
Get data list of Products remaining to be delivered for an order (with qty)
getNomUrl($withpicto=0, $save_lastsearch_value=-1)
Return clickable name (with picto eventually)
Management class of delivery note lines.
__construct($db)
Constructor.
Class to manage Dolibarr database access.
Class to manage third parties objects (customers, suppliers, prospects...)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db user
Active Directory does not allow anonymous connections.