39require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40require_once DOL_DOCUMENT_ROOT.
"/expedition/class/expeditionligne.class.php";
41require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
42if (isModEnabled(
"propal")) {
43 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
45if (isModEnabled(
'order')) {
46 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expeditionlinebatch.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/commonsignedobject.class.php';
60 use CommonSignedObject;
65 public $element =
"shipping";
70 public $fk_element =
"fk_expedition";
75 public $table_element =
"expedition";
80 public $table_element_line =
"expeditiondet";
85 public $picto =
'dolly';
91 public $fields = array();
96 public $user_author_id;
101 public $fk_user_author;
118 public $ref_customer;
128 public $tracking_number;
133 public $tracking_url;
146 public $weight_units;
162 public $height_units;
179 public $livraison_id;
184 public $multicurrency_subprice;
214 public $date_delivery;
228 public $date_expedition;
234 public $date_shipping;
263 public $lines = array();
269 public $fk_multicurrency;
274 public $multicurrency_code;
278 public $multicurrency_tx;
282 public $multicurrency_total_ht;
286 public $multicurrency_total_tva;
290 public $multicurrency_total_ttc;
338 $this->ismultientitymanaged = 1;
339 $this->isextrafieldmanaged = 1;
342 $this->labelStatus = array();
343 $this->labelStatus[-1] =
'StatusSendingCanceled';
344 $this->labelStatus[0] =
'StatusSendingDraft';
345 $this->labelStatus[1] =
'StatusSendingValidated';
346 $this->labelStatus[2] =
'StatusSendingProcessed';
349 $this->labelStatusShort = array();
350 $this->labelStatusShort[-1] =
'StatusSendingCanceledShort';
351 $this->labelStatusShort[0] =
'StatusSendingDraftShort';
352 $this->labelStatusShort[1] =
'StatusSendingValidatedShort';
353 $this->labelStatusShort[2] =
'StatusSendingProcessedShort';
364 global $langs,
$conf;
365 $langs->load(
"sendings");
374 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
376 foreach ($dirmodels as $reldir) {
380 $mybool = ((bool) @include_once $dir.$file) || $mybool;
388 $obj =
new $classname();
389 '@phan-var-force ModelNumRefExpedition $obj';
390 $numref = $obj->getNextValue($soc, $this);
395 dol_print_error($this->db, get_class($this).
"::getNextNumRef ".$obj->error);
399 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_EXPEDITION_ADDON_NUMBER_NotDefined");
411 public function create($user, $notrigger = 0)
413 global
$conf, $hookmanager;
417 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
422 if (empty($this->fk_project)) {
423 $this->fk_project = 0;
425 if (empty($this->date_shipping) && !empty($this->date_expedition)) {
426 $this->date_shipping = $this->date_expedition;
434 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"expedition (";
437 $sql .=
", ref_customer";
439 $sql .=
", date_creation";
440 $sql .=
", fk_user_author";
441 $sql .=
", date_expedition";
442 $sql .=
", date_delivery";
444 $sql .=
", fk_projet";
445 $sql .=
", fk_address";
446 $sql .=
", fk_shipping_method";
447 $sql .=
", tracking_number";
452 $sql .=
", weight_units";
453 $sql .=
", size_units";
454 $sql .=
", note_private";
455 $sql .=
", note_public";
456 $sql .=
", model_pdf";
457 $sql .=
", fk_incoterms, location_incoterms";
458 $sql .=
", signed_status";
459 $sql .=
") VALUES (";
461 $sql .=
", ".((int) $this->entity);
462 $sql .=
", ".($this->ref_customer ?
"'".$this->db->escape($this->ref_customer).
"'" :
"null");
463 $sql .=
", ".($this->ref_ext ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null");
464 $sql .=
", '".$this->db->idate($now).
"'";
465 $sql .=
", ".((int) $user->id);
466 $sql .=
", ".($this->date_shipping > 0 ?
"'".$this->db->idate($this->date_shipping).
"'" :
"null");
467 $sql .=
", ".($this->date_delivery > 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
468 $sql .=
", ".($this->socid > 0 ? ((int) $this->socid) :
"null");
469 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null");
470 $sql .=
", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address :
"null");
471 $sql .=
", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) :
"null");
472 $sql .=
", '".$this->db->escape($this->tracking_number).
"'";
473 $sql .=
", ".(is_numeric($this->weight) ? $this->weight :
'NULL');
474 $sql .=
", ".(is_numeric($this->sizeS) ? $this->sizeS :
'NULL');
475 $sql .=
", ".(is_numeric($this->sizeW) ? $this->sizeW :
'NULL');
476 $sql .=
", ".(is_numeric($this->sizeH) ? $this->sizeH :
'NULL');
477 $sql .=
", ".($this->weight_units !=
'' ? (int) $this->weight_units :
'NULL');
478 $sql .=
", ".($this->size_units !=
'' ? (int) $this->size_units :
'NULL');
479 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
480 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
481 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
482 $sql .=
", ".(int) $this->fk_incoterms;
483 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
484 $sql .=
", ".($this->signed_status);
487 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
488 $resql = $this->db->query($sql);
490 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"expedition");
492 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition";
493 $sql .=
" SET ref = '(PROV".$this->id.
")'";
494 $sql .=
" WHERE rowid = ".((int) $this->
id);
496 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
497 if ($this->db->query($sql)) {
499 $num = count($this->lines);
500 for ($i = 0; $i < $num; $i++) {
502 if (!isset($this->lines[$i]->detail_batch)) {
503 if ($this->
create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) <= 0) {
507 if ($this->
create_line_batch($this->lines[$i], $this->lines[$i]->array_options) <= 0) {
514 if (!$error && $this->
id && $this->origin_id) {
529 if (!$error && !$notrigger) {
531 $result = $this->
call_trigger(
'SHIPPING_CREATE', $user);
541 foreach ($this->errors as $errmsg) {
542 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
543 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
545 $this->db->rollback();
550 $this->db->rollback();
555 $this->error = $this->db->lasterror().
" - sql=$sql";
556 $this->db->rollback();
561 $this->error = $this->db->error().
" - sql=$sql";
562 $this->db->rollback();
578 public function create_line($entrepot_id, $origin_line_id, $qty, $rang = 0, $array_options = [])
584 $expeditionline->fk_expedition = $this->id;
585 $expeditionline->entrepot_id = $entrepot_id;
586 $expeditionline->fk_elementdet = $origin_line_id;
587 $expeditionline->element_type = $this->origin;
588 $expeditionline->qty = $qty;
589 $expeditionline->rang = $rang;
590 $expeditionline->array_options = $array_options;
592 if (($lineId = $expeditionline->insert($user)) < 0) {
593 $this->errors[] = $expeditionline->error;
611 $stockLocationQty = array();
613 $tab = $line_ext->detail_batch;
615 foreach ($tab as $detbatch) {
616 if (!empty($detbatch->entrepot_id)) {
617 if (empty($stockLocationQty[$detbatch->entrepot_id])) {
618 $stockLocationQty[$detbatch->entrepot_id] = 0;
620 $stockLocationQty[$detbatch->entrepot_id] += $detbatch->qty;
624 foreach ($stockLocationQty as $stockLocation => $qty) {
625 $line_id = $this->
create_line($stockLocation, $line_ext->origin_line_id, $qty, $line_ext->rang, $array_options);
630 foreach ($tab as $detbatch) {
631 if ($detbatch->entrepot_id == $stockLocation) {
632 if (!($detbatch->create($line_id) > 0)) {
633 $this->errors = $detbatch->errors;
657 public function fetch($id, $ref =
'', $ref_ext =
'', $notused =
'')
662 if (empty($id) && empty($ref) && empty($ref_ext)) {
666 $sql =
"SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.fk_user_author, e.fk_statut, e.signed_status, e.fk_projet as fk_project, e.billed";
667 $sql .=
", e.date_valid";
668 $sql .=
", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
669 $sql .=
", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery";
670 $sql .=
", e.fk_shipping_method, e.tracking_number";
671 $sql .=
", e.note_private, e.note_public";
672 $sql .=
', e.fk_incoterms, e.location_incoterms';
673 $sql .=
', e.signed_status';
674 $sql .=
', i.libelle as label_incoterms';
675 $sql .=
', s.libelle as shipping_method';
676 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin_type";
677 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
678 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element).
"'";
679 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON e.fk_incoterms = i.rowid';
680 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_shipment_mode as s ON e.fk_shipping_method = s.rowid';
681 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
683 $sql .=
" AND e.rowid = ".((int) $id);
686 $sql .=
" AND e.ref='".$this->db->escape($ref).
"'";
689 $sql .=
" AND e.ref_ext='".$this->db->escape($ref_ext).
"'";
692 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
693 $result = $this->db->query($sql);
695 if ($this->db->num_rows($result)) {
696 $obj = $this->db->fetch_object($result);
698 $this->
id = $obj->rowid;
699 $this->entity = $obj->entity;
700 $this->
ref = $obj->ref;
701 $this->socid = $obj->socid;
702 $this->ref_customer = $obj->ref_customer;
703 $this->ref_ext = $obj->ref_ext;
704 $this->
status = $obj->fk_statut;
705 $this->statut = $this->status;
706 $this->signed_status = $obj->signed_status;
707 $this->user_author_id = $obj->fk_user_author;
708 $this->fk_user_author = $obj->fk_user_author;
709 $this->date_creation = $this->db->jdate($obj->date_creation);
710 $this->date_valid = $this->db->jdate($obj->date_valid);
711 $this->date = $this->db->jdate($obj->date_expedition);
712 $this->date_expedition = $this->db->jdate($obj->date_expedition);
713 $this->date_shipping = $this->db->jdate($obj->date_expedition);
714 $this->date_delivery = $this->db->jdate($obj->date_delivery);
715 $this->fk_delivery_address = $obj->fk_address;
716 $this->model_pdf = $obj->model_pdf;
717 $this->shipping_method_id = $obj->fk_shipping_method;
718 $this->shipping_method = $obj->shipping_method;
719 $this->tracking_number = $obj->tracking_number;
720 $this->origin = ($obj->origin_type ? $obj->origin_type :
'commande');
721 $this->origin_type = ($obj->origin_type ? $obj->origin_type :
'commande');
722 $this->origin_id = $obj->origin_id;
723 $this->billed = $obj->billed;
724 $this->fk_project = $obj->fk_project;
725 $this->signed_status = $obj->signed_status;
726 $this->trueWeight = $obj->weight;
727 $this->weight_units = $obj->weight_units;
729 $this->trueWidth = $obj->width;
730 $this->width_units = $obj->size_units;
731 $this->trueHeight = $obj->height;
732 $this->height_units = $obj->size_units;
733 $this->trueDepth = $obj->size;
734 $this->depth_units = $obj->size_units;
736 $this->note_public = $obj->note_public;
737 $this->note_private = $obj->note_private;
740 $this->trueSize = $obj->size.
"x".$obj->width.
"x".$obj->height;
741 $this->size_units = $obj->size_units;
744 $this->fk_incoterms = $obj->fk_incoterms;
745 $this->location_incoterms = $obj->location_incoterms;
746 $this->label_incoterms = $obj->label_incoterms;
748 $this->db->free($result);
760 if (isModEnabled(
'multicurrency')) {
761 if (!empty($this->multicurrency_code)) {
762 $this->multicurrency_code = $this->thirdparty->multicurrency_code;
764 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($this->thirdparty->multicurrency_tx)) {
765 $this->multicurrency_tx = $this->thirdparty->multicurrency_tx;
779 dol_syslog(get_class($this).
'::Fetch no expedition found', LOG_ERR);
780 $this->error =
'Shipment with id '.$id.
' not found';
784 $this->error = $this->db->error();
796 public function valid($user, $notrigger = 0)
800 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
806 dol_syslog(get_class($this).
"::valid not in draft status", LOG_WARNING);
810 if (!((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
811 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))) {
812 $this->error =
'Permission denied';
813 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
823 $soc->fetch($this->socid);
826 $result = $soc->setAsCustomer();
829 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
831 } elseif (!empty($this->
ref)) {
832 $numref = $this->ref;
834 $numref =
"EXP".$this->id;
841 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET";
842 $sql .=
" ref='".$this->db->escape($numref).
"'";
843 $sql .=
", fk_statut = 1";
844 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
845 $sql .=
", fk_user_valid = ".((int) $user->id);
846 $sql .=
" WHERE rowid = ".((int) $this->
id);
848 dol_syslog(get_class($this).
"::valid update expedition", LOG_DEBUG);
849 $resql = $this->db->query($sql);
851 $this->error = $this->db->lasterror();
856 if (!$error && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT')) {
869 if (!$error && !$notrigger) {
871 $result = $this->
call_trigger(
'SHIPPING_VALIDATE', $user);
879 $this->oldref = $this->ref;
882 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
884 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'expedition/sending/".$this->db->escape($this->newref).
"'";
885 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/sending/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
886 $resql = $this->db->query($sql);
889 $this->error = $this->db->lasterror();
891 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/sending/".$this->db->escape($this->newref).
"'";
892 $sql .=
" WHERE filepath = 'expedition/sending/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
893 $resql = $this->db->query($sql);
896 $this->error = $this->db->lasterror();
902 $dirsource =
$conf->expedition->dir_output.
'/sending/'.$oldref;
903 $dirdest =
$conf->expedition->dir_output.
'/sending/'.$newref;
904 if (!$error && file_exists($dirsource)) {
905 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
907 if (@rename($dirsource, $dirdest)) {
910 $listoffiles =
dol_dir_list(
$conf->expedition->dir_output.
'/sending/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
911 foreach ($listoffiles as $fileentry) {
912 $dirsource = $fileentry[
'name'];
913 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
914 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
915 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
916 @rename($dirsource, $dirdest);
925 $this->
ref = $numref;
934 $this->db->rollback();
953 if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) {
955 include_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
956 $delivery =
new Delivery($this->db);
957 $result = $delivery->create_from_sending($user, $this->
id);
961 $this->error = $delivery->error;
984 public function addline($entrepot_id, $id, $qty, $array_options = [])
986 global
$conf, $langs;
988 $num = count($this->lines);
991 $line->entrepot_id = $entrepot_id;
992 $line->origin_line_id = $id;
993 $line->fk_elementdet = $id;
994 $line->element_type =
'order';
998 $orderline->fetch($id);
1001 $line->rang = $orderline->rang;
1002 $line->product_type = $orderline->product_type;
1004 if (isModEnabled(
'stock') && !empty($orderline->fk_product)) {
1005 $fk_product = $orderline->fk_product;
1008 $langs->load(
"errors");
1009 $this->error = $langs->trans(
"ErrorWarehouseRequiredIntoShipmentLine");
1014 $product =
new Product($this->db);
1015 $product->fetch($fk_product);
1018 if ($entrepot_id > 0) {
1019 $product->load_stock(
'warehouseopen');
1020 $product_stock = $product->stock_warehouse[$entrepot_id]->real;
1022 $product_stock = $product->stock_reel;
1025 $product_type = $product->type;
1027 $isavirtualproduct = ($product->hasFatherOrChild(1) > 0);
1030 if ($product_stock < $qty) {
1031 $langs->load(
"errors");
1032 $this->error = $langs->trans(
'ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref);
1033 $this->errorhidden =
'ErrorStockIsNotEnoughToAddProductOnShipment';
1035 $this->db->rollback();
1045 if (isModEnabled(
'productbatch') && !empty($orderline->fk_product) && !empty($orderline->product_tobatch)) {
1046 $this->error =
'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH '.$orderline->id.
' '.$orderline->fk_product;
1051 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1052 $line->array_options = $array_options;
1055 $this->lines[$num] = $line;
1071 global
$conf, $langs;
1073 $num = count($this->lines);
1075 if ($dbatch[
'qty'] > 0 || ($dbatch[
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
1078 foreach ($dbatch[
'detail'] as $key => $value) {
1079 if ($value[
'q'] > 0 || ($value[
'q'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
1085 $ret = $linebatch->fetchFromStock($value[
'id_batch']);
1090 $linebatch->qty = $value[
'q'];
1091 if ($linebatch->qty == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) {
1092 $linebatch->batch =
null;
1094 $tab[] = $linebatch;
1097 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
1099 $prod_batch->fetch($value[
'id_batch']);
1101 if ($prod_batch->qty < $linebatch->qty) {
1102 $langs->load(
"errors");
1103 $this->errors[] = $langs->trans(
'ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product);
1104 dol_syslog(get_class($this).
"::addline_batch error=Product ".$prod_batch->batch.
": ".$this->errorsToString(), LOG_ERR);
1105 $this->db->rollback();
1113 if (is_object($linebatch)) {
1114 $line->entrepot_id = $linebatch->entrepot_id;
1116 $line->origin_line_id = $dbatch[
'ix_l'];
1117 $line->fk_elementdet = $dbatch[
'ix_l'];
1118 $line->qty = $dbatch[
'qty'];
1119 $line->detail_batch = $tab;
1122 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1123 $line->array_options = $array_options;
1127 $this->lines[$num] = $line;
1140 public function update($user =
null, $notrigger = 0)
1147 if (isset($this->
ref)) {
1148 $this->
ref = trim($this->
ref);
1150 if (isset($this->entity)) {
1151 $this->entity = (int) $this->entity;
1153 if (isset($this->ref_customer)) {
1154 $this->ref_customer = trim($this->ref_customer);
1156 if (isset($this->socid)) {
1157 $this->socid = (int) $this->socid;
1159 if (isset($this->fk_user_author)) {
1160 $this->fk_user_author = (int) $this->fk_user_author;
1162 if (isset($this->fk_user_valid)) {
1164 $this->fk_user_valid = (int) $this->fk_user_valid;
1166 if (isset($this->fk_delivery_address)) {
1167 $this->fk_delivery_address = (int) $this->fk_delivery_address;
1169 if (isset($this->shipping_method_id)) {
1170 $this->shipping_method_id = (int) $this->shipping_method_id;
1172 if (isset($this->tracking_number)) {
1173 $this->tracking_number = trim($this->tracking_number);
1175 if (isset($this->statut)) {
1176 $this->statut = (int) $this->statut;
1178 if (isset($this->trueDepth)) {
1179 $this->trueDepth = trim($this->trueDepth);
1181 if (isset($this->trueWidth)) {
1182 $this->trueWidth = trim($this->trueWidth);
1184 if (isset($this->trueHeight)) {
1185 $this->trueHeight = trim($this->trueHeight);
1187 if (isset($this->size_units)) {
1188 $this->size_units = trim($this->size_units);
1190 if (isset($this->weight_units)) {
1191 $this->weight_units = (int) $this->weight_units;
1193 if (isset($this->trueWeight)) {
1194 $this->weight = trim((
string) $this->trueWeight);
1196 if (isset($this->note_private)) {
1197 $this->note_private = trim($this->note_private);
1199 if (isset($this->note_public)) {
1200 $this->note_public = trim($this->note_public);
1202 if (isset($this->model_pdf)) {
1203 $this->model_pdf = trim($this->model_pdf);
1205 if (!empty($this->date_expedition)) {
1206 $this->date_shipping = $this->date_expedition;
1213 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET";
1214 $sql .=
" ref = ".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"null").
",";
1215 $sql .=
" ref_ext = ".(isset($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
",";
1216 $sql .=
" ref_customer = ".(isset($this->ref_customer) ?
"'".$this->db->escape($this->ref_customer).
"'" :
"null").
",";
1217 $sql .=
" fk_soc = ".(isset($this->socid) ? $this->socid :
"null").
",";
1218 $sql .=
" date_creation = ".(dol_strlen($this->date_creation) != 0 ?
"'".$this->db->idate($this->date_creation).
"'" :
'null').
",";
1219 $sql .=
" fk_user_author = ".(isset($this->fk_user_author) ? $this->fk_user_author :
"null").
",";
1220 $sql .=
" date_valid = ".(dol_strlen($this->date_valid) != 0 ?
"'".$this->db->idate($this->date_valid).
"'" :
'null').
",";
1221 $sql .=
" fk_user_valid = ".(isset($this->fk_user_valid) ? $this->fk_user_valid :
"null").
",";
1222 $sql .=
" date_expedition = ".(dol_strlen($this->date_shipping) != 0 ?
"'".$this->db->idate($this->date_shipping).
"'" :
'null').
",";
1223 $sql .=
" date_delivery = ".(dol_strlen($this->date_delivery) != 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
'null').
",";
1224 $sql .=
" fk_address = ".(isset($this->fk_delivery_address) ? $this->fk_delivery_address :
"null").
",";
1225 $sql .=
" fk_shipping_method = ".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id :
"null").
",";
1226 $sql .=
" tracking_number = ".(isset($this->tracking_number) ?
"'".$this->db->escape($this->tracking_number).
"'" :
"null").
",";
1227 $sql .=
" fk_statut = ".(isset($this->statut) ? $this->statut :
"null").
",";
1228 $sql .=
" fk_projet = ".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
1229 $sql .=
" height = ".(($this->trueHeight !=
'') ? $this->trueHeight :
"null").
",";
1230 $sql .=
" width = ".(($this->trueWidth !=
'') ? $this->trueWidth :
"null").
",";
1231 $sql .=
" size_units = ".(isset($this->size_units) ? $this->size_units :
"null").
",";
1232 $sql .=
" size = ".(($this->trueDepth !=
'') ? $this->trueDepth :
"null").
",";
1233 $sql .=
" weight_units = ".(isset($this->weight_units) ? $this->weight_units :
"null").
",";
1234 $sql .=
" weight = ".(($this->trueWeight !=
'') ? $this->trueWeight :
"null").
",";
1235 $sql .=
" note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1236 $sql .=
" note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1237 $sql .=
" model_pdf = ".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1238 $sql .=
" entity = ".((int)
$conf->entity);
1239 $sql .=
" WHERE rowid = ".((int) $this->
id);
1243 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1244 $resql = $this->db->query($sql);
1247 $this->errors[] =
"Error ".$this->db->lasterror();
1258 if (!$error && !$notrigger) {
1260 $result = $this->
call_trigger(
'SHIPPING_MODIFY', $user);
1269 foreach ($this->errors as $errmsg) {
1270 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1271 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1273 $this->db->rollback();
1276 $this->db->commit();
1289 public function cancel($notrigger = 0, $also_update_stock =
false)
1291 global
$conf, $langs, $user;
1293 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1302 if (count($this->linkedObjectsIds) > 0) {
1303 $this->error =
'ErrorThereIsSomeDeliveries';
1307 if (!$error && !$notrigger) {
1309 $result = $this->
call_trigger(
'SHIPPING_CANCEL', $user);
1317 if (!$error && isModEnabled(
'stock') &&
1318 ((
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) ||
1319 (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) {
1320 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1322 $langs->load(
"agenda");
1325 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id";
1326 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
1327 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
1328 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1329 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1331 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1332 $resql = $this->db->query($sql);
1334 $cpt = $this->db->num_rows($resql);
1338 for ($i = 0; $i < $cpt; $i++) {
1339 dol_syslog(get_class($this).
"::delete movement index ".$i);
1340 $obj = $this->db->fetch_object($resql);
1344 $mouvS->origin =
'';
1347 if (isModEnabled(
'productbatch')) {
1348 $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id);
1349 if (!is_array($lotArray)) {
1351 $this->errors[] =
"Error ".$this->db->lasterror();
1355 if (empty($lotArray)) {
1359 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ShipmentCanceledInDolibarr", $this->ref));
1362 $this->errors = array_merge($this->errors, $mouvS->errors);
1368 foreach ($lotArray as $lot) {
1369 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans(
"ShipmentCanceledInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
1372 $this->errors = array_merge($this->errors, $mouvS->errors);
1383 $this->errors[] =
"Error ".$this->db->lasterror();
1388 if (!$error && isModEnabled(
'productbatch')) {
1390 if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
1392 $this->errors[] =
"Error ".$this->db->lasterror();
1398 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expeditiondet";
1399 $sql .=
" WHERE fk_expedition = ".((int) $this->
id);
1401 if ($this->db->query($sql)) {
1410 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"expedition";
1411 $sql .=
" WHERE rowid = ".((int) $this->
id);
1413 if ($this->db->query($sql)) {
1414 if (!empty($this->origin) && $this->origin_id > 0) {
1417 '@phan-var-force Facture|Commande $origin_object';
1429 $this->db->commit();
1433 if (!empty(
$conf->expedition->dir_output)) {
1434 $dir =
$conf->expedition->dir_output.
'/sending/'.$ref;
1435 $file = $dir.
'/'.$ref.
'.pdf';
1436 if (file_exists($file)) {
1441 if (file_exists($dir)) {
1443 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1451 $this->db->rollback();
1455 $this->error = $this->db->lasterror().
" - sql=$sql";
1456 $this->db->rollback();
1460 $this->error = $this->db->lasterror().
" - sql=$sql";
1461 $this->db->rollback();
1465 $this->error = $this->db->lasterror().
" - sql=$sql";
1466 $this->db->rollback();
1470 $this->db->rollback();
1484 public function delete($user =
null, $notrigger = 0, $also_update_stock =
false)
1486 global
$conf, $langs;
1492 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1501 if (count($this->linkedObjectsIds) > 0) {
1502 $this->error =
'ErrorThereIsSomeDeliveries';
1506 if (!$error && !$notrigger) {
1508 $result = $this->
call_trigger(
'SHIPPING_DELETE', $user);
1516 if (!$error && isModEnabled(
'stock') &&
1517 ((
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) ||
1518 (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) {
1519 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1521 $langs->load(
"agenda");
1527 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id";
1528 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
1529 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
1530 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1531 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1533 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1534 $resql = $this->db->query($sql);
1536 $cpt = $this->db->num_rows($resql);
1537 for ($i = 0; $i < $cpt; $i++) {
1538 dol_syslog(get_class($this).
"::delete movement index ".$i);
1539 $obj = $this->db->fetch_object($resql);
1543 $mouvS->origin =
'';
1545 $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id);
1546 if (!is_array($lotArray)) {
1548 $this->errors[] =
"Error ".$this->db->lasterror();
1550 if (empty($lotArray)) {
1554 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ShipmentDeletedInDolibarr", $this->ref));
1557 $this->errors = array_merge($this->errors, $mouvS->errors);
1563 foreach ($lotArray as $lot) {
1564 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans(
"ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
1567 $this->errors = array_merge($this->errors, $mouvS->errors);
1578 $this->errors[] =
"Error ".$this->db->lasterror();
1585 if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
1587 $this->errors[] =
"Error ".$this->db->lasterror();
1592 $main = MAIN_DB_PREFIX.
'expeditiondet';
1593 $ef = $main.
"_extrafields";
1594 $sqlef =
"DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".((int) $this->
id).
")";
1596 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expeditiondet";
1597 $sql .=
" WHERE fk_expedition = ".((int) $this->
id);
1599 if ($this->db->query($sqlef) && $this->db->query($sql)) {
1613 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expedition";
1614 $sql .=
" WHERE rowid = ".((int) $this->
id);
1616 if ($this->db->query($sql)) {
1617 if (!empty($this->origin) && $this->origin_id > 0) {
1620 '@phan-var-force Facture|Commande $origin_object';
1632 $this->db->commit();
1640 if (!empty(
$conf->expedition->dir_output)) {
1641 $dir =
$conf->expedition->dir_output.
'/sending/'.$ref;
1642 $file = $dir.
'/'.$ref.
'.pdf';
1643 if (file_exists($file)) {
1648 if (file_exists($dir)) {
1650 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1658 $this->db->rollback();
1662 $this->error = $this->db->lasterror().
" - sql=$sql";
1663 $this->db->rollback();
1667 $this->error = $this->db->lasterror().
" - sql=$sql";
1668 $this->db->rollback();
1672 $this->error = $this->db->lasterror().
" - sql=$sql";
1673 $this->db->rollback();
1677 $this->db->rollback();
1693 $this->lines = array();
1698 $sql =
"SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type, cd.fk_unit";
1699 $sql .=
", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
1700 $sql .=
", cd.fk_remise_except, cd.fk_product_fournisseur_price as fk_fournprice";
1701 $sql .=
", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht";
1702 $sql .=
", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang, cd.date_start, cd.date_end";
1703 $sql .=
", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_element, ed.fk_elementdet, ed.element_type, ed.fk_entrepot";
1704 $sql .=
", p.ref as product_ref, p.label as product_label, p.fk_product_type, p.barcode as product_barcode";
1705 $sql .=
", p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch";
1706 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed, ".MAIN_DB_PREFIX.
"commandedet as cd";
1707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = cd.fk_product";
1708 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1709 $sql .=
" AND ed.fk_elementdet = cd.rowid";
1710 $sql .=
" ORDER BY cd.rang, ed.fk_elementdet";
1712 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
1713 $resql = $this->db->query($sql);
1715 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
1717 $num = $this->db->num_rows($resql);
1722 $this->total_ht = 0;
1723 $this->total_tva = 0;
1724 $this->total_ttc = 0;
1725 $this->total_localtax1 = 0;
1726 $this->total_localtax2 = 0;
1728 $this->multicurrency_total_ht = 0;
1729 $this->multicurrency_total_tva = 0;
1730 $this->multicurrency_total_ttc = 0;
1735 $obj = $this->db->fetch_object($resql);
1738 if ($originline > 0 && $originline == $obj->fk_elementdet) {
1739 '@phan-var-force ExpeditionLigne $line';
1740 $line->entrepot_id = 0;
1741 $line->qty_shipped += $obj->qty_shipped;
1744 $line->entrepot_id = $obj->fk_entrepot;
1745 $line->qty_shipped = $obj->qty_shipped;
1749 $detail_entrepot->entrepot_id = $obj->fk_entrepot;
1750 $detail_entrepot->qty_shipped = $obj->qty_shipped;
1751 $detail_entrepot->line_id = $obj->line_id;
1752 $line->details_entrepot[] = $detail_entrepot;
1754 $line->line_id = $obj->line_id;
1755 $line->rowid = $obj->line_id;
1756 $line->id = $obj->line_id;
1758 $line->fk_origin =
'orderline';
1760 $line->fk_element = $obj->fk_element;
1761 $line->origin_id = $obj->fk_element;
1762 $line->fk_elementdet = $obj->fk_elementdet;
1763 $line->origin_line_id = $obj->fk_elementdet;
1764 $line->element_type = $obj->element_type;
1766 $line->fk_expedition = $this->id;
1768 $line->product_type = $obj->product_type;
1769 $line->fk_product = $obj->fk_product;
1770 $line->fk_product_type = $obj->fk_product_type;
1771 $line->ref = $obj->product_ref;
1772 $line->product_ref = $obj->product_ref;
1773 $line->product_label = $obj->product_label;
1774 $line->libelle = $obj->product_label;
1775 $line->product_barcode = $obj->product_barcode;
1776 $line->product_tosell = $obj->product_tosell;
1777 $line->product_tobuy = $obj->product_tobuy;
1778 $line->product_tobatch = $obj->product_tobatch;
1779 $line->fk_fournprice = $obj->fk_fournprice;
1780 $line->label = $obj->custom_label;
1781 $line->description = $obj->description;
1782 $line->qty_asked = $obj->qty_asked;
1783 $line->rang = $obj->rang;
1784 $line->weight = $obj->weight;
1785 $line->weight_units = $obj->weight_units;
1786 $line->length = $obj->length;
1787 $line->length_units = $obj->length_units;
1788 $line->width = $obj->width;
1789 $line->width_units = $obj->width_units;
1790 $line->height = $obj->height;
1791 $line->height_units = $obj->height_units;
1792 $line->surface = $obj->surface;
1793 $line->surface_units = $obj->surface_units;
1794 $line->volume = $obj->volume;
1795 $line->volume_units = $obj->volume_units;
1796 $line->fk_unit = $obj->fk_unit;
1798 $line->pa_ht = $obj->pa_ht;
1801 $localtax_array = array(0 => $obj->localtax1_type, 1 => $obj->localtax1_tx, 2 => $obj->localtax2_type, 3 => $obj->localtax2_tx);
1802 $localtax1_tx =
get_localtax($obj->tva_tx, 1, $this->thirdparty);
1803 $localtax2_tx =
get_localtax($obj->tva_tx, 2, $this->thirdparty);
1806 $tabprice =
calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0,
'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array);
1807 $line->desc = $obj->description;
1808 $line->qty = $line->qty_shipped;
1809 $line->total_ht = (float) $tabprice[0];
1810 $line->total_localtax1 = (float) $tabprice[9];
1811 $line->total_localtax2 = (float) $tabprice[10];
1812 $line->total_ttc = (float) $tabprice[2];
1813 $line->total_tva = (float) $tabprice[1];
1814 $line->vat_src_code = $obj->vat_src_code;
1815 $line->tva_tx = $obj->tva_tx;
1816 $line->localtax1_tx = $obj->localtax1_tx;
1817 $line->localtax2_tx = $obj->localtax2_tx;
1818 $line->info_bits = $obj->info_bits;
1819 $line->price = $obj->price;
1820 $line->subprice = $obj->subprice;
1821 $line->fk_remise_except = $obj->fk_remise_except;
1822 $line->remise_percent = $obj->remise_percent;
1824 $this->total_ht += $tabprice[0];
1825 $this->total_tva += $tabprice[1];
1826 $this->total_ttc += $tabprice[2];
1827 $this->total_localtax1 += $tabprice[9];
1828 $this->total_localtax2 += $tabprice[10];
1830 $line->date_start = $this->db->jdate($obj->date_start);
1831 $line->date_end = $this->db->jdate($obj->date_end);
1834 $this->fk_multicurrency = $obj->fk_multicurrency;
1835 $this->multicurrency_code = $obj->multicurrency_code;
1836 $line->multicurrency_subprice = $obj->multicurrency_subprice;
1837 $line->multicurrency_total_ht = $obj->multicurrency_total_ht;
1838 $line->multicurrency_total_tva = $obj->multicurrency_total_tva;
1839 $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1841 $this->multicurrency_total_ht += $obj->multicurrency_total_ht;
1842 $this->multicurrency_total_tva += $obj->multicurrency_total_tva;
1843 $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc;
1845 if ($originline != $obj->fk_elementdet) {
1846 $line->detail_batch = array();
1850 if (isModEnabled(
'productbatch') && $obj->line_id > 0 && $obj->product_tobatch > 0) {
1851 $newdetailbatch = $shipmentlinebatch->fetchAll($obj->line_id, $obj->fk_product);
1853 if (is_array($newdetailbatch)) {
1854 if ($originline != $obj->fk_elementdet) {
1855 $line->detail_batch = $newdetailbatch;
1857 $line->detail_batch = array_merge($line->detail_batch, $newdetailbatch);
1862 $line->fetch_optionals();
1864 if ($originline != $obj->fk_elementdet) {
1865 $this->lines[$lineindex] = $line;
1868 $line->total_ht += $tabprice[0];
1869 $line->total_localtax1 += $tabprice[9];
1870 $line->total_localtax2 += $tabprice[10];
1871 $line->total_ttc += $tabprice[2];
1872 $line->total_tva += $tabprice[1];
1876 $originline = $obj->fk_elementdet;
1878 $this->db->free($resql);
1881 $this->error = $this->db->error();
1897 if ($this->statut == self::STATUS_DRAFT) {
1903 $line->fetch($lineid);
1905 if ($line->delete($user) > 0) {
1908 $this->db->commit();
1911 $this->db->rollback();
1915 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
1929 global
$conf, $langs;
1931 $langs->load(
'sendings');
1933 $nofetch = !empty($params[
'nofetch']);
1936 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Shipment").
'</u>';
1937 if (isset($this->statut)) {
1938 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1940 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1941 $datas[
'refcustomer'] =
'<br><b>'.$langs->trans(
'RefCustomer').
':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
1943 $langs->load(
'companies');
1944 if (empty($this->thirdparty)) {
1947 $datas[
'customer'] =
'<br><b>'.$langs->trans(
'Customer').
':</b> '.$this->thirdparty->getNomUrl(1,
'', 0, 1);
1964 public function getNomUrl($withpicto = 0, $option =
'', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1)
1966 global $langs, $hookmanager;
1971 'objecttype' => $this->element,
1972 'option' => $option,
1975 $classfortooltip =
'classfortooltip';
1978 $classfortooltip =
'classforajaxtooltip';
1979 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1985 $url = DOL_URL_ROOT.
'/expedition/card.php?id='.$this->id;
1991 if ($option !==
'nolink') {
1993 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1994 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1995 $add_save_lastsearch_values = 1;
1997 if ($add_save_lastsearch_values) {
1998 $url .=
'&save_lastsearch_values=1';
2003 if (empty($notooltip)) {
2005 $label = $langs->trans(
"Shipment");
2006 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2008 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2009 $linkclose .= $dataparams.
' class="'.$classfortooltip.
'"';
2012 $linkstart =
'<a href="'.$url.
'"';
2013 $linkstart .= $linkclose.
'>';
2016 $result .= $linkstart;
2018 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
2020 if ($withpicto != 2) {
2021 $result .= $this->ref;
2023 $result .= $linkend;
2025 $hookmanager->initHooks(array($this->element .
'dao'));
2026 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2027 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2029 $result = $hookmanager->resPrint;
2031 $result .= $hookmanager->resPrint;
2044 return $this->
LibStatut($this->statut, $mode);
2060 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
2061 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]);
2063 $statusType =
'status'.$status;
2064 if ($status == self::STATUS_VALIDATED) {
2065 $statusType =
'status4';
2067 if ($status == self::STATUS_CLOSED) {
2068 $statusType =
'status6';
2070 if ($status == self::STATUS_CANCELED) {
2071 $statusType =
'status9';
2075 $status_label = $this->signed_status ? $labelStatus . $signed_label : $labelStatus;
2076 $status_label_short = $this->signed_status ? $labelStatusShort . $signed_label : $labelStatusShort;
2078 return dolGetStatus($status_label, $status_label_short,
'', $statusType, $mode);
2090 global $langs,
$conf;
2092 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2094 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2095 $return .=
'<div class="info-box info-box-sm">';
2096 $return .=
'<div class="info-box-icon bg-infobox-action">';
2098 $return .=
'</div>';
2099 $return .=
'<div class="info-box-content">';
2100 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
2101 if ($selected >= 0) {
2102 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2104 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
2105 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
2107 if (property_exists($this,
'total_ht')) {
2108 $return .=
'<div class="info-box-ref amount">'.price($this->total_ht, 0, $langs, 0, -1, -1,
$conf->currency).
' '.$langs->trans(
'HT').
'</div>';
2110 if (method_exists($this,
'getLibStatut')) {
2111 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2113 $return .=
'</div>';
2114 $return .=
'</div>';
2115 $return .=
'</div>';
2133 dol_syslog(get_class($this).
"::initAsSpecimen");
2136 $order->initAsSpecimen();
2140 $this->
ref =
'SPECIMEN';
2141 $this->specimen = 1;
2143 $this->livraison_id = 0;
2145 $this->date_creation = $now;
2146 $this->date_valid = $now;
2147 $this->date_delivery = $now + 24 * 3600;
2148 $this->date_expedition = $now + 24 * 3600;
2150 $this->entrepot_id = 0;
2151 $this->fk_delivery_address = 0;
2154 $this->commande_id = 0;
2155 $this->commande = $order;
2157 $this->origin_id = 1;
2158 $this->origin =
'commande';
2160 $this->note_private =
'Private note';
2161 $this->note_public =
'Public note';
2165 while ($xnbp < $nbp) {
2167 $line->product_desc = $langs->trans(
"Description").
" ".$xnbp;
2168 $line->product_label = $langs->trans(
"Description").
" ".$xnbp;
2170 $line->qty_asked = 5;
2171 $line->qty_shipped = 4;
2172 $line->fk_product = $this->commande->lines[$xnbp]->fk_product;
2174 $line->weight = 1.123456;
2175 $line->weight_units = 0;
2177 $line->volume = 2.34567;
2178 $line->volume_unit = 0;
2180 $this->lines[] = $line;
2211 if ($user->hasRight(
'expedition',
'creer')) {
2212 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition";
2213 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
2214 $sql .=
" WHERE rowid = ".((int) $this->
id);
2216 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
2217 $resql = $this->db->query($sql);
2219 $this->date_delivery = $delivery_date;
2222 $this->error = $this->db->error();
2239 if ($user->hasRight(
'expedition',
'creer')) {
2240 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition";
2241 $sql .=
" SET date_expedition = ".($shipping_date ?
"'".$this->db->idate($shipping_date).
"'" :
'null');
2242 $sql .=
" WHERE rowid = ".((int) $this->
id);
2244 dol_syslog(get_class($this).
"::setShippingDate", LOG_DEBUG);
2245 $resql = $this->db->query($sql);
2247 $this->date_shipping = $shipping_date;
2250 $this->error = $this->db->error();
2268 $this->meths = array();
2270 $sql =
"SELECT em.rowid, em.code, em.libelle as label";
2271 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2272 $sql .=
" WHERE em.active = 1";
2273 $sql .=
" ORDER BY em.libelle ASC";
2275 $resql = $this->db->query($sql);
2277 while ($obj = $this->db->fetch_object($resql)) {
2278 $label = $langs->trans(
'SendingMethod'.$obj->code);
2279 $this->meths[$obj->rowid] = ($label !=
'SendingMethod'.$obj->code ? $label : $obj->label);
2296 $this->listmeths = array();
2299 $sql =
"SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active";
2300 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2302 $sql .=
" WHERE em.rowid=".((int) $id);
2305 $resql = $this->db->query($sql);
2307 while ($obj = $this->db->fetch_object($resql)) {
2308 $this->listmeths[$i][
'rowid'] = $obj->rowid;
2309 $this->listmeths[$i][
'code'] = $obj->code;
2310 $label = $langs->trans(
'SendingMethod'.$obj->code);
2311 $this->listmeths[$i][
'libelle'] = ($label !=
'SendingMethod'.$obj->code ? $label : $obj->label);
2312 $this->listmeths[$i][
'description'] = $obj->description;
2313 $this->listmeths[$i][
'tracking'] = $obj->tracking;
2314 $this->listmeths[$i][
'active'] = $obj->active;
2328 if (!empty($this->shipping_method_id)) {
2329 $sql =
"SELECT em.code, em.tracking";
2330 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2331 $sql .=
" WHERE em.rowid = ".((int) $this->shipping_method_id);
2333 $resql = $this->db->query($sql);
2335 if ($obj = $this->db->fetch_object($resql)) {
2336 $tracking = $obj->tracking;
2341 if (!empty($tracking) && !empty($value)) {
2342 $url = str_replace(
'{TRACKID}', $value, $tracking);
2343 $this->tracking_url = sprintf(
'<a target="_blank" rel="noopener noreferrer" href="%s">%s</a>', $url, ($value ? $value :
'url'));
2345 $this->tracking_url = $value;
2361 if ($this->statut == self::STATUS_CLOSED) {
2367 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET fk_statut = ".self::STATUS_CLOSED.
", date_expedition = '".$this->db->escape($this->db->idate(
dol_now())).
"'";
2368 $sql .=
" WHERE rowid = ".((int) $this->
id).
" AND fk_statut > 0";
2370 $resql = $this->db->query($sql);
2373 if ($this->origin ==
'commande' && $this->origin_id > 0) {
2375 $order->fetch($this->origin_id);
2377 $order->loadExpeditions(self::STATUS_CLOSED);
2379 $shipments_match_order = 1;
2380 foreach ($order->lines as $line) {
2381 $lineid = $line->id;
2383 if (($line->product_type == 0 ||
getDolGlobalString(
'STOCK_SUPPORTS_SERVICES')) && $order->expeditions[$lineid] != $qty) {
2384 $shipments_match_order = 0;
2385 $text =
'Qty for order line id '.$lineid.
' is '.$qty.
'. However in the shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.
' we have qty = '.$order->expeditions[$lineid].
', so we can t close order';
2390 if ($shipments_match_order) {
2391 dol_syslog(
"Qty for the ".count($order->lines).
" lines of the origin order is same than qty for lines in the shipment we close (shipments_match_order is true), with new status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.
', so we close order');
2393 $order->cloture($user);
2401 if (!$error && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
2410 $result = $this->
call_trigger(
'SHIPPING_CLOSED', $user);
2421 $this->db->commit();
2427 $this->db->rollback();
2447 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/mouvementstock.class.php';
2449 $langs->load(
"agenda");
2452 $sql =
"SELECT cd.fk_product, cd.subprice,";
2453 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2455 $sql .=
" edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock,";
2456 $sql .=
" cd.rowid as cdid, ed.rowid as edid";
2457 $sql .=
" FROM " . MAIN_DB_PREFIX .
"commandedet as cd,";
2458 $sql .=
" " . MAIN_DB_PREFIX .
"expeditiondet as ed";
2459 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
2460 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"expedition as e ON ed.fk_expedition = e.rowid";
2461 $sql .=
" WHERE ed.fk_expedition = " . ((int) $this->
id);
2462 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2464 dol_syslog(get_class($this) .
"::valid select details", LOG_DEBUG);
2465 $resql = $this->db->query($sql);
2467 $cpt = $this->db->num_rows($resql);
2468 for ($i = 0; $i < $cpt; $i++) {
2469 $obj = $this->db->fetch_object($resql);
2470 if (empty($obj->edbrowid)) {
2473 $qty = $obj->edbqty;
2475 if ($qty <= 0 || ($qty < 0 && !
getDolGlobalInt(
'SHIPMENT_ALLOW_NEGATIVE_QTY'))) {
2478 dol_syslog(get_class($this) .
"::valid movement index " . $i .
" ed.rowid=" . $obj->rowid .
" edb.rowid=" . $obj->edbrowid);
2481 $mouvS->origin = &$this;
2482 $mouvS->setOrigin($this->element, $this->
id, $obj->cdid, $obj->edid);
2484 if (empty($obj->edbrowid)) {
2488 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref));
2490 $this->error = $mouvS->error;
2491 $this->errors = $mouvS->errors;
2499 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref),
'', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
2501 $this->error = $mouvS->error;
2502 $this->errors = $mouvS->errors;
2510 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX.
"product_batch as pb)";
2511 $resqldelete = $this->db->query($sqldelete);
2515 $this->error = $this->db->lasterror();
2516 $this->errors[] = $this->db->lasterror();
2539 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'expedition SET billed = 1';
2540 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2542 $resql = $this->db->query($sql);
2547 $result = $this->
call_trigger(
'SHIPPING_BILLED', $user);
2554 $this->errors[] = $this->db->lasterror;
2557 if (empty($error)) {
2558 $this->db->commit();
2561 $this->db->rollback();
2576 if ($this->statut <= self::STATUS_DRAFT) {
2580 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'SHIPMENT_UNVALIDATE');
2590 global $langs, $user;
2595 if ($this->statut == self::STATUS_VALIDATED) {
2601 $oldbilled = $this->billed;
2603 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'expedition SET fk_statut = 1';
2604 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2606 $resql = $this->db->query($sql);
2613 if (!$error && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
2614 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2616 $langs->load(
"agenda");
2620 $sql =
"SELECT cd.fk_product, cd.subprice,";
2621 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2622 $sql .=
" edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";
2623 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
2624 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2625 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
2626 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
2627 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2629 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2630 $resql = $this->db->query($sql);
2632 $cpt = $this->db->num_rows($resql);
2633 for ($i = 0; $i < $cpt; $i++) {
2634 $obj = $this->db->fetch_object($resql);
2635 if (empty($obj->edbrowid)) {
2638 $qty = $obj->edbqty;
2643 dol_syslog(get_class($this).
"::reopen expedition movement index ".$i.
" ed.rowid=".$obj->rowid.
" edb.rowid=".$obj->edbrowid);
2647 $mouvS->origin = &$this;
2648 $mouvS->setOrigin($this->element, $this->
id);
2650 if (empty($obj->edbrowid)) {
2654 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ShipmentUnClassifyCloseddInDolibarr", $this->ref));
2656 $this->error = $mouvS->error;
2657 $this->errors = $mouvS->errors;
2665 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ShipmentUnClassifyCloseddInDolibarr", $this->ref),
'', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
2667 $this->error = $mouvS->error;
2668 $this->errors = $mouvS->errors;
2675 $this->error = $this->db->lasterror();
2682 $result = $this->
call_trigger(
'SHIPPING_REOPEN', $user);
2689 $this->errors[] = $this->db->lasterror();
2693 $this->db->commit();
2698 $this->billed = $oldbilled;
2699 $this->db->rollback();
2715 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2717 $outputlangs->load(
"products");
2722 if (!empty($this->model_pdf)) {
2723 $modele = $this->model_pdf;
2729 $modelpath =
"core/modules/expedition/doc/";
2733 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_VALIDATED
Validated status.
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...
deleteEcmFiles($mode=0)
Delete related files of object in database.
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.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
setErrorsFromObject($object)
setErrorsFromObject
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='fk_statut')
Set status of an object.
deleteExtraFields()
Delete all extra fields values for the current object.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
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.
fetch_origin()
Read linked origin object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage receptions.
Class to manage Dolibarr database access.
getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
Return clickable link of object (with eventually picto)
create_delivery($user)
Create a delivery receipt from a shipment.
setDraft($user, $notrigger=0)
Set draft status.
const STATUS_SHIPMENT_IN_PROGRESS
Expedition in progress -> package exit the warehouse and is now in the truck or into the hand of the ...
getUrlTrackingStatus($value='')
Forge an set tracking url.
setClosed()
Classify the shipping as closed (this records also the stock movement)
__construct($db)
Constructor.
create($user, $notrigger=0)
Create expedition en base.
LibStatut($status, $mode)
Return label of a status.
setBilled()
Classify the shipping as invoiced (used for example by trigger when WORKFLOW_SHIPPING_CLASSIFY_BILLED...
addline($entrepot_id, $id, $qty, $array_options=[])
Add an expedition line.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
getTooltipContentArray($params)
getTooltipContentArray
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
create_line($entrepot_id, $origin_line_id, $qty, $rang=0, $array_options=[])
Create a expedition line.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
setShippingDate($user, $shipping_date)
Set the shipping date.
const STATUS_DRAFT
Draft status.
const STATUS_CANCELED
Canceled status.
getLibStatut($mode=0)
Return status label.
set_date_livraison($user, $delivery_date)
Set delivery date.
initAsSpecimen()
Initialise an instance with random values.
addline_batch($dbatch, $array_options=[])
Add a shipment line with batch record.
getNextNumRef($soc)
Return next expedition ref.
const STATUS_CLOSED
Closed status -> parcel was received by customer / end of process prev status : validated or shipment...
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
create_line_batch($line_ext, $array_options=[])
Create the detail of the expedition line.
manageStockMvtOnEvt($user, $labelmovement='ShipmentClassifyClosedInDolibarr')
Manage Stock MVt onb Close or valid Shipment.
valid($user, $notrigger=0)
Validate object and update stock if option enabled.
update($user=null, $notrigger=0)
Update database.
cancel($notrigger=0, $also_update_stock=false)
Cancel shipment.
fetch_delivery_methods()
Fetch deliveries method and return an array.
fetch($id, $ref='', $ref_ext='', $notused='')
Get object and lines from database.
reOpen()
Classify the shipping as validated/opened.
deleteLine($user, $lineid)
Delete detail line.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
list_delivery_methods($id=0)
Fetch all deliveries method and return an array.
Class to manage lines of shipment.
CRUD class for batch number management within shipment.
Class to manage stock movements.
Class to manage order lines.
Class to manage products or services.
const TYPE_SERVICE
Service.
Manage record for batch number management.
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...
getLibSignedStatus(int $mode=0)
Returns the label for signed status.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
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_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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEntity($currentobject)
Set entity id to use when to create an object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller='', $localtaxes_array=[], $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code='')
Calculate totals (net, vat, ...) of a line.
$conf db user
Active Directory does not allow anonymous connections.