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')) {
864 $triggerKey =
'SHIPPING_';
865 if ($this->origin ==
'commande') {
866 $triggerKey.=
'ORDER_SHIPMENTONPROCESS';
868 $triggerKey.= strtoupper($this->origin).
'_SHIPMENTONPROCESS';
877 if (!$error && !$notrigger) {
879 $result = $this->
call_trigger(
'SHIPPING_VALIDATE', $user);
887 $this->oldref = $this->ref;
890 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
892 $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).
"'";
893 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'expedition/sending/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
894 $resql = $this->db->query($sql);
897 $this->error = $this->db->lasterror();
899 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'expedition/sending/".$this->db->escape($this->newref).
"'";
900 $sql .=
" WHERE filepath = 'expedition/sending/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
901 $resql = $this->db->query($sql);
904 $this->error = $this->db->lasterror();
910 $dirsource =
$conf->expedition->dir_output.
'/sending/'.$oldref;
911 $dirdest =
$conf->expedition->dir_output.
'/sending/'.$newref;
912 if (!$error && file_exists($dirsource)) {
913 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
915 if (@rename($dirsource, $dirdest)) {
918 $listoffiles =
dol_dir_list(
$conf->expedition->dir_output.
'/sending/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
919 foreach ($listoffiles as $fileentry) {
920 $dirsource = $fileentry[
'name'];
921 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
922 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
923 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
924 @rename($dirsource, $dirdest);
933 $this->
ref = $numref;
942 $this->db->rollback();
961 if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) {
963 include_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
964 $delivery =
new Delivery($this->db);
965 $result = $delivery->create_from_sending($user, $this->
id);
969 $this->error = $delivery->error;
992 public function addline($entrepot_id, $id, $qty, $array_options = [])
994 global
$conf, $langs;
996 $num = count($this->lines);
999 $line->entrepot_id = $entrepot_id;
1000 $line->origin_line_id = $id;
1001 $line->fk_elementdet = $id;
1002 $line->element_type =
'order';
1006 $orderline->fetch($id);
1009 $line->rang = $orderline->rang;
1010 $line->product_type = $orderline->product_type;
1012 if (isModEnabled(
'stock') && !empty($orderline->fk_product)) {
1013 $fk_product = $orderline->fk_product;
1016 $langs->load(
"errors");
1017 $this->error = $langs->trans(
"ErrorWarehouseRequiredIntoShipmentLine");
1022 $product =
new Product($this->db);
1023 $product->fetch($fk_product);
1026 if ($entrepot_id > 0) {
1027 $product->load_stock(
'warehouseopen');
1028 $product_stock = $product->stock_warehouse[$entrepot_id]->real;
1030 $product_stock = $product->stock_reel;
1033 $product_type = $product->type;
1035 $isavirtualproduct = ($product->hasFatherOrChild(1) > 0);
1038 if ($product_stock < $qty) {
1039 $langs->load(
"errors");
1040 $this->error = $langs->trans(
'ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref);
1041 $this->errorhidden =
'ErrorStockIsNotEnoughToAddProductOnShipment';
1043 $this->db->rollback();
1053 if (isModEnabled(
'productbatch') && !empty($orderline->fk_product) && !empty($orderline->product_tobatch)) {
1054 $this->error =
'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH '.$orderline->id.
' '.$orderline->fk_product;
1059 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1060 $line->array_options = $array_options;
1063 $this->lines[$num] = $line;
1079 global
$conf, $langs;
1081 $num = count($this->lines);
1083 if ($dbatch[
'qty'] > 0 || ($dbatch[
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
1086 foreach ($dbatch[
'detail'] as $key => $value) {
1087 if ($value[
'q'] > 0 || ($value[
'q'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
1093 $ret = $linebatch->fetchFromStock($value[
'id_batch']);
1098 $linebatch->qty = $value[
'q'];
1099 if ($linebatch->qty == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) {
1100 $linebatch->batch =
null;
1102 $tab[] = $linebatch;
1105 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
1107 $prod_batch->fetch($value[
'id_batch']);
1109 if ($prod_batch->qty < $linebatch->qty) {
1110 $langs->load(
"errors");
1111 $this->errors[] = $langs->trans(
'ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product);
1112 dol_syslog(get_class($this).
"::addline_batch error=Product ".$prod_batch->batch.
": ".$this->errorsToString(), LOG_ERR);
1113 $this->db->rollback();
1121 if (is_object($linebatch)) {
1122 $line->entrepot_id = $linebatch->entrepot_id;
1124 $line->origin_line_id = $dbatch[
'ix_l'];
1125 $line->fk_elementdet = $dbatch[
'ix_l'];
1126 $line->qty = $dbatch[
'qty'];
1127 $line->detail_batch = $tab;
1130 if (!
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) {
1131 $line->array_options = $array_options;
1135 $this->lines[$num] = $line;
1148 public function update($user =
null, $notrigger = 0)
1155 if (isset($this->
ref)) {
1156 $this->
ref = trim($this->
ref);
1158 if (isset($this->entity)) {
1159 $this->entity = (int) $this->entity;
1161 if (isset($this->ref_customer)) {
1162 $this->ref_customer = trim($this->ref_customer);
1164 if (isset($this->socid)) {
1165 $this->socid = (int) $this->socid;
1167 if (isset($this->fk_user_author)) {
1168 $this->fk_user_author = (int) $this->fk_user_author;
1170 if (isset($this->fk_user_valid)) {
1172 $this->fk_user_valid = (int) $this->fk_user_valid;
1174 if (isset($this->fk_delivery_address)) {
1175 $this->fk_delivery_address = (int) $this->fk_delivery_address;
1177 if (isset($this->shipping_method_id)) {
1178 $this->shipping_method_id = (int) $this->shipping_method_id;
1180 if (isset($this->tracking_number)) {
1181 $this->tracking_number = trim($this->tracking_number);
1183 if (isset($this->statut)) {
1184 $this->statut = (int) $this->statut;
1186 if (isset($this->trueDepth)) {
1187 $this->trueDepth = trim($this->trueDepth);
1189 if (isset($this->trueWidth)) {
1190 $this->trueWidth = trim($this->trueWidth);
1192 if (isset($this->trueHeight)) {
1193 $this->trueHeight = trim($this->trueHeight);
1195 if (isset($this->size_units)) {
1196 $this->size_units = trim($this->size_units);
1198 if (isset($this->weight_units)) {
1199 $this->weight_units = (int) $this->weight_units;
1201 if (isset($this->trueWeight)) {
1202 $this->weight = trim((
string) $this->trueWeight);
1204 if (isset($this->note_private)) {
1205 $this->note_private = trim($this->note_private);
1207 if (isset($this->note_public)) {
1208 $this->note_public = trim($this->note_public);
1210 if (isset($this->model_pdf)) {
1211 $this->model_pdf = trim($this->model_pdf);
1213 if (!empty($this->date_expedition)) {
1214 $this->date_shipping = $this->date_expedition;
1221 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET";
1222 $sql .=
" ref = ".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"null").
",";
1223 $sql .=
" ref_ext = ".(isset($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
",";
1224 $sql .=
" ref_customer = ".(isset($this->ref_customer) ?
"'".$this->db->escape($this->ref_customer).
"'" :
"null").
",";
1225 $sql .=
" fk_soc = ".(isset($this->socid) ? $this->socid :
"null").
",";
1226 $sql .=
" date_creation = ".(dol_strlen($this->date_creation) != 0 ?
"'".$this->db->idate($this->date_creation).
"'" :
'null').
",";
1227 $sql .=
" fk_user_author = ".(isset($this->fk_user_author) ? $this->fk_user_author :
"null").
",";
1228 $sql .=
" date_valid = ".(dol_strlen($this->date_valid) != 0 ?
"'".$this->db->idate($this->date_valid).
"'" :
'null').
",";
1229 $sql .=
" fk_user_valid = ".(isset($this->fk_user_valid) ? $this->fk_user_valid :
"null").
",";
1230 $sql .=
" date_expedition = ".(dol_strlen($this->date_shipping) != 0 ?
"'".$this->db->idate($this->date_shipping).
"'" :
'null').
",";
1231 $sql .=
" date_delivery = ".(dol_strlen($this->date_delivery) != 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
'null').
",";
1232 $sql .=
" fk_address = ".(isset($this->fk_delivery_address) ? $this->fk_delivery_address :
"null").
",";
1233 $sql .=
" fk_shipping_method = ".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id :
"null").
",";
1234 $sql .=
" tracking_number = ".(isset($this->tracking_number) ?
"'".$this->db->escape($this->tracking_number).
"'" :
"null").
",";
1235 $sql .=
" fk_statut = ".(isset($this->statut) ? $this->statut :
"null").
",";
1236 $sql .=
" fk_projet = ".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
1237 $sql .=
" height = ".(($this->trueHeight !=
'') ? $this->trueHeight :
"null").
",";
1238 $sql .=
" width = ".(($this->trueWidth !=
'') ? $this->trueWidth :
"null").
",";
1239 $sql .=
" size_units = ".(isset($this->size_units) ? $this->size_units :
"null").
",";
1240 $sql .=
" size = ".(($this->trueDepth !=
'') ? $this->trueDepth :
"null").
",";
1241 $sql .=
" weight_units = ".(isset($this->weight_units) ? $this->weight_units :
"null").
",";
1242 $sql .=
" weight = ".(($this->trueWeight !=
'') ? $this->trueWeight :
"null").
",";
1243 $sql .=
" note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1244 $sql .=
" note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1245 $sql .=
" model_pdf = ".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1246 $sql .=
" entity = ".((int)
$conf->entity);
1247 $sql .=
" WHERE rowid = ".((int) $this->
id);
1251 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1252 $resql = $this->db->query($sql);
1255 $this->errors[] =
"Error ".$this->db->lasterror();
1266 if (!$error && !$notrigger) {
1268 $result = $this->
call_trigger(
'SHIPPING_MODIFY', $user);
1277 foreach ($this->errors as $errmsg) {
1278 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1279 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1281 $this->db->rollback();
1284 $this->db->commit();
1297 public function cancel($notrigger = 0, $also_update_stock =
false)
1299 global
$conf, $langs, $user;
1301 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1310 if (count($this->linkedObjectsIds) > 0) {
1311 $this->error =
'ErrorThereIsSomeDeliveries';
1315 if (!$error && !$notrigger) {
1317 $result = $this->
call_trigger(
'SHIPPING_CANCEL', $user);
1325 if (!$error && isModEnabled(
'stock') &&
1326 ((
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) ||
1327 (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) {
1328 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1330 $langs->load(
"agenda");
1333 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id";
1334 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
1335 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
1336 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1337 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1339 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1340 $resql = $this->db->query($sql);
1342 $cpt = $this->db->num_rows($resql);
1346 for ($i = 0; $i < $cpt; $i++) {
1347 dol_syslog(get_class($this).
"::delete movement index ".$i);
1348 $obj = $this->db->fetch_object($resql);
1352 $mouvS->origin =
'';
1355 if (isModEnabled(
'productbatch')) {
1356 $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id);
1357 if (!is_array($lotArray)) {
1359 $this->errors[] =
"Error ".$this->db->lasterror();
1363 if (empty($lotArray)) {
1367 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ShipmentCanceledInDolibarr", $this->ref));
1370 $this->errors = array_merge($this->errors, $mouvS->errors);
1376 foreach ($lotArray as $lot) {
1377 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans(
"ShipmentCanceledInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
1380 $this->errors = array_merge($this->errors, $mouvS->errors);
1391 $this->errors[] =
"Error ".$this->db->lasterror();
1396 if (!$error && isModEnabled(
'productbatch')) {
1398 if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
1400 $this->errors[] =
"Error ".$this->db->lasterror();
1406 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expeditiondet";
1407 $sql .=
" WHERE fk_expedition = ".((int) $this->
id);
1409 if ($this->db->query($sql)) {
1418 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"expedition";
1419 $sql .=
" WHERE rowid = ".((int) $this->
id);
1421 if ($this->db->query($sql)) {
1422 if (!empty($this->origin) && $this->origin_id > 0) {
1425 '@phan-var-force Facture|Commande $origin_object';
1437 $this->db->commit();
1441 if (!empty(
$conf->expedition->dir_output)) {
1442 $dir =
$conf->expedition->dir_output.
'/sending/'.$ref;
1443 $file = $dir.
'/'.$ref.
'.pdf';
1444 if (file_exists($file)) {
1449 if (file_exists($dir)) {
1451 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1459 $this->db->rollback();
1463 $this->error = $this->db->lasterror().
" - sql=$sql";
1464 $this->db->rollback();
1468 $this->error = $this->db->lasterror().
" - sql=$sql";
1469 $this->db->rollback();
1473 $this->error = $this->db->lasterror().
" - sql=$sql";
1474 $this->db->rollback();
1478 $this->db->rollback();
1492 public function delete($user =
null, $notrigger = 0, $also_update_stock =
false)
1494 global
$conf, $langs;
1500 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1509 if (count($this->linkedObjectsIds) > 0) {
1510 $this->error =
'ErrorThereIsSomeDeliveries';
1514 if (!$error && !$notrigger) {
1516 $result = $this->
call_trigger(
'SHIPPING_DELETE', $user);
1524 if (!$error && isModEnabled(
'stock') &&
1525 ((
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) ||
1526 (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) {
1527 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
1529 $langs->load(
"agenda");
1535 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id";
1536 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
1537 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
1538 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1539 $sql .=
" AND cd.rowid = ed.fk_elementdet";
1541 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
1542 $resql = $this->db->query($sql);
1544 $cpt = $this->db->num_rows($resql);
1545 for ($i = 0; $i < $cpt; $i++) {
1546 dol_syslog(get_class($this).
"::delete movement index ".$i);
1547 $obj = $this->db->fetch_object($resql);
1551 $mouvS->origin =
'';
1553 $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id);
1554 if (!is_array($lotArray)) {
1556 $this->errors[] =
"Error ".$this->db->lasterror();
1558 if (empty($lotArray)) {
1562 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ShipmentDeletedInDolibarr", $this->ref));
1565 $this->errors = array_merge($this->errors, $mouvS->errors);
1571 foreach ($lotArray as $lot) {
1572 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans(
"ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
1575 $this->errors = array_merge($this->errors, $mouvS->errors);
1586 $this->errors[] =
"Error ".$this->db->lasterror();
1593 if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
1595 $this->errors[] =
"Error ".$this->db->lasterror();
1600 $main = MAIN_DB_PREFIX.
'expeditiondet';
1601 $ef = $main.
"_extrafields";
1602 $sqlef =
"DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".((int) $this->
id).
")";
1604 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expeditiondet";
1605 $sql .=
" WHERE fk_expedition = ".((int) $this->
id);
1607 if ($this->db->query($sqlef) && $this->db->query($sql)) {
1621 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"expedition";
1622 $sql .=
" WHERE rowid = ".((int) $this->
id);
1624 if ($this->db->query($sql)) {
1625 if (!empty($this->origin) && $this->origin_id > 0) {
1628 '@phan-var-force Facture|Commande $origin_object';
1640 $this->db->commit();
1648 if (!empty(
$conf->expedition->dir_output)) {
1649 $dir =
$conf->expedition->dir_output.
'/sending/'.$ref;
1650 $file = $dir.
'/'.$ref.
'.pdf';
1651 if (file_exists($file)) {
1656 if (file_exists($dir)) {
1658 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
1666 $this->db->rollback();
1670 $this->error = $this->db->lasterror().
" - sql=$sql";
1671 $this->db->rollback();
1675 $this->error = $this->db->lasterror().
" - sql=$sql";
1676 $this->db->rollback();
1680 $this->error = $this->db->lasterror().
" - sql=$sql";
1681 $this->db->rollback();
1685 $this->db->rollback();
1701 $this->lines = array();
1706 $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";
1707 $sql .=
", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
1708 $sql .=
", cd.fk_remise_except, cd.fk_product_fournisseur_price as fk_fournprice";
1709 $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";
1710 $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";
1711 $sql .=
", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_element, ed.fk_elementdet, ed.element_type, ed.fk_entrepot";
1712 $sql .=
", p.ref as product_ref, p.label as product_label, p.fk_product_type, p.barcode as product_barcode";
1713 $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";
1714 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed, ".MAIN_DB_PREFIX.
"commandedet as cd";
1715 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = cd.fk_product";
1716 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
1717 $sql .=
" AND ed.fk_elementdet = cd.rowid";
1718 $sql .=
" ORDER BY cd.rang, ed.fk_elementdet";
1720 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
1721 $resql = $this->db->query($sql);
1723 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
1725 $num = $this->db->num_rows($resql);
1730 $this->total_ht = 0;
1731 $this->total_tva = 0;
1732 $this->total_ttc = 0;
1733 $this->total_localtax1 = 0;
1734 $this->total_localtax2 = 0;
1736 $this->multicurrency_total_ht = 0;
1737 $this->multicurrency_total_tva = 0;
1738 $this->multicurrency_total_ttc = 0;
1743 $obj = $this->db->fetch_object($resql);
1746 if ($originline > 0 && $originline == $obj->fk_elementdet) {
1747 '@phan-var-force ExpeditionLigne $line';
1748 $line->entrepot_id = 0;
1749 $line->qty_shipped += $obj->qty_shipped;
1752 $line->entrepot_id = $obj->fk_entrepot;
1753 $line->qty_shipped = $obj->qty_shipped;
1757 $detail_entrepot->entrepot_id = $obj->fk_entrepot;
1758 $detail_entrepot->qty_shipped = $obj->qty_shipped;
1759 $detail_entrepot->line_id = $obj->line_id;
1760 $line->details_entrepot[] = $detail_entrepot;
1762 $line->line_id = $obj->line_id;
1763 $line->rowid = $obj->line_id;
1764 $line->id = $obj->line_id;
1766 $line->fk_origin =
'orderline';
1768 $line->fk_element = $obj->fk_element;
1769 $line->origin_id = $obj->fk_element;
1770 $line->fk_elementdet = $obj->fk_elementdet;
1771 $line->origin_line_id = $obj->fk_elementdet;
1772 $line->element_type = $obj->element_type;
1774 $line->fk_expedition = $this->id;
1776 $line->product_type = $obj->product_type;
1777 $line->fk_product = $obj->fk_product;
1778 $line->fk_product_type = $obj->fk_product_type;
1779 $line->ref = $obj->product_ref;
1780 $line->product_ref = $obj->product_ref;
1781 $line->product_label = $obj->product_label;
1782 $line->libelle = $obj->product_label;
1783 $line->product_barcode = $obj->product_barcode;
1784 $line->product_tosell = $obj->product_tosell;
1785 $line->product_tobuy = $obj->product_tobuy;
1786 $line->product_tobatch = $obj->product_tobatch;
1787 $line->fk_fournprice = $obj->fk_fournprice;
1788 $line->label = $obj->custom_label;
1789 $line->description = $obj->description;
1790 $line->qty_asked = $obj->qty_asked;
1791 $line->rang = $obj->rang;
1792 $line->weight = $obj->weight;
1793 $line->weight_units = $obj->weight_units;
1794 $line->length = $obj->length;
1795 $line->length_units = $obj->length_units;
1796 $line->width = $obj->width;
1797 $line->width_units = $obj->width_units;
1798 $line->height = $obj->height;
1799 $line->height_units = $obj->height_units;
1800 $line->surface = $obj->surface;
1801 $line->surface_units = $obj->surface_units;
1802 $line->volume = $obj->volume;
1803 $line->volume_units = $obj->volume_units;
1804 $line->fk_unit = $obj->fk_unit;
1806 $line->pa_ht = $obj->pa_ht;
1809 $localtax_array = array(0 => $obj->localtax1_type, 1 => $obj->localtax1_tx, 2 => $obj->localtax2_type, 3 => $obj->localtax2_tx);
1810 $localtax1_tx =
get_localtax($obj->tva_tx, 1, $this->thirdparty);
1811 $localtax2_tx =
get_localtax($obj->tva_tx, 2, $this->thirdparty);
1814 $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);
1815 $line->desc = $obj->description;
1816 $line->qty = $line->qty_shipped;
1817 $line->total_ht = (float) $tabprice[0];
1818 $line->total_localtax1 = (float) $tabprice[9];
1819 $line->total_localtax2 = (float) $tabprice[10];
1820 $line->total_ttc = (float) $tabprice[2];
1821 $line->total_tva = (float) $tabprice[1];
1822 $line->vat_src_code = $obj->vat_src_code;
1823 $line->tva_tx = $obj->tva_tx;
1824 $line->localtax1_tx = $obj->localtax1_tx;
1825 $line->localtax2_tx = $obj->localtax2_tx;
1826 $line->info_bits = $obj->info_bits;
1827 $line->price = $obj->price;
1828 $line->subprice = $obj->subprice;
1829 $line->fk_remise_except = $obj->fk_remise_except;
1830 $line->remise_percent = $obj->remise_percent;
1832 $this->total_ht += $tabprice[0];
1833 $this->total_tva += $tabprice[1];
1834 $this->total_ttc += $tabprice[2];
1835 $this->total_localtax1 += $tabprice[9];
1836 $this->total_localtax2 += $tabprice[10];
1838 $line->date_start = $this->db->jdate($obj->date_start);
1839 $line->date_end = $this->db->jdate($obj->date_end);
1842 $this->fk_multicurrency = $obj->fk_multicurrency;
1843 $this->multicurrency_code = $obj->multicurrency_code;
1844 $line->multicurrency_subprice = $obj->multicurrency_subprice;
1845 $line->multicurrency_total_ht = $obj->multicurrency_total_ht;
1846 $line->multicurrency_total_tva = $obj->multicurrency_total_tva;
1847 $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1849 $this->multicurrency_total_ht += $obj->multicurrency_total_ht;
1850 $this->multicurrency_total_tva += $obj->multicurrency_total_tva;
1851 $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc;
1853 if ($originline != $obj->fk_elementdet) {
1854 $line->detail_batch = array();
1858 if (isModEnabled(
'productbatch') && $obj->line_id > 0 && $obj->product_tobatch > 0) {
1859 $newdetailbatch = $shipmentlinebatch->fetchAll($obj->line_id, $obj->fk_product);
1861 if (is_array($newdetailbatch)) {
1862 if ($originline != $obj->fk_elementdet) {
1863 $line->detail_batch = $newdetailbatch;
1865 $line->detail_batch = array_merge($line->detail_batch, $newdetailbatch);
1870 $line->fetch_optionals();
1872 if ($originline != $obj->fk_elementdet) {
1873 $this->lines[$lineindex] = $line;
1876 $line->total_ht += $tabprice[0];
1877 $line->total_localtax1 += $tabprice[9];
1878 $line->total_localtax2 += $tabprice[10];
1879 $line->total_ttc += $tabprice[2];
1880 $line->total_tva += $tabprice[1];
1884 $originline = $obj->fk_elementdet;
1886 $this->db->free($resql);
1889 $this->error = $this->db->error();
1905 if ($this->statut == self::STATUS_DRAFT) {
1911 $line->fetch($lineid);
1913 if ($line->delete($user) > 0) {
1916 $this->db->commit();
1919 $this->db->rollback();
1923 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
1937 global
$conf, $langs;
1939 $langs->load(
'sendings');
1941 $nofetch = !empty($params[
'nofetch']);
1944 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Shipment").
'</u>';
1945 if (isset($this->statut)) {
1946 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1948 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1949 $datas[
'refcustomer'] =
'<br><b>'.$langs->trans(
'RefCustomer').
':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
1951 $langs->load(
'companies');
1952 if (empty($this->thirdparty)) {
1955 $datas[
'customer'] =
'<br><b>'.$langs->trans(
'Customer').
':</b> '.$this->thirdparty->getNomUrl(1,
'', 0, 1);
1972 public function getNomUrl($withpicto = 0, $option =
'', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1)
1974 global $langs, $hookmanager;
1979 'objecttype' => $this->element,
1980 'option' => $option,
1983 $classfortooltip =
'classfortooltip';
1986 $classfortooltip =
'classforajaxtooltip';
1987 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1993 $url = DOL_URL_ROOT.
'/expedition/card.php?id='.$this->id;
1999 if ($option !==
'nolink') {
2001 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2002 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2003 $add_save_lastsearch_values = 1;
2005 if ($add_save_lastsearch_values) {
2006 $url .=
'&save_lastsearch_values=1';
2011 if (empty($notooltip)) {
2013 $label = $langs->trans(
"Shipment");
2014 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
2016 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
2017 $linkclose .= $dataparams.
' class="'.$classfortooltip.
'"';
2020 $linkstart =
'<a href="'.$url.
'"';
2021 $linkstart .= $linkclose.
'>';
2024 $result .= $linkstart;
2026 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
2028 if ($withpicto != 2) {
2029 $result .= $this->ref;
2031 $result .= $linkend;
2033 $hookmanager->initHooks(array($this->element .
'dao'));
2034 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2035 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2037 $result = $hookmanager->resPrint;
2039 $result .= $hookmanager->resPrint;
2052 return $this->
LibStatut($this->statut, $mode);
2068 $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]);
2069 $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]);
2071 $statusType =
'status'.$status;
2072 if ($status == self::STATUS_VALIDATED) {
2073 $statusType =
'status4';
2075 if ($status == self::STATUS_CLOSED) {
2076 $statusType =
'status6';
2078 if ($status == self::STATUS_CANCELED) {
2079 $statusType =
'status9';
2083 $status_label = $this->signed_status ? $labelStatus . $signed_label : $labelStatus;
2084 $status_label_short = $this->signed_status ? $labelStatusShort . $signed_label : $labelStatusShort;
2086 return dolGetStatus($status_label, $status_label_short,
'', $statusType, $mode);
2098 global $langs,
$conf;
2100 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2102 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2103 $return .=
'<div class="info-box info-box-sm">';
2104 $return .=
'<div class="info-box-icon bg-infobox-action">';
2106 $return .=
'</div>';
2107 $return .=
'<div class="info-box-content">';
2108 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
2109 if ($selected >= 0) {
2110 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2112 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
2113 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
2115 if (property_exists($this,
'total_ht')) {
2116 $return .=
'<div class="info-box-ref amount">'.price($this->total_ht, 0, $langs, 0, -1, -1,
$conf->currency).
' '.$langs->trans(
'HT').
'</div>';
2118 if (method_exists($this,
'getLibStatut')) {
2119 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2121 $return .=
'</div>';
2122 $return .=
'</div>';
2123 $return .=
'</div>';
2141 dol_syslog(get_class($this).
"::initAsSpecimen");
2144 $order->initAsSpecimen();
2148 $this->
ref =
'SPECIMEN';
2149 $this->specimen = 1;
2151 $this->livraison_id = 0;
2153 $this->date_creation = $now;
2154 $this->date_valid = $now;
2155 $this->date_delivery = $now + 24 * 3600;
2156 $this->date_expedition = $now + 24 * 3600;
2158 $this->entrepot_id = 0;
2159 $this->fk_delivery_address = 0;
2162 $this->commande_id = 0;
2163 $this->commande = $order;
2165 $this->origin_id = 1;
2166 $this->origin =
'commande';
2168 $this->note_private =
'Private note';
2169 $this->note_public =
'Public note';
2173 while ($xnbp < $nbp) {
2175 $line->product_desc = $langs->trans(
"Description").
" ".$xnbp;
2176 $line->product_label = $langs->trans(
"Description").
" ".$xnbp;
2178 $line->qty_asked = 5;
2179 $line->qty_shipped = 4;
2180 $line->fk_product = $this->commande->lines[$xnbp]->fk_product;
2182 $line->weight = 1.123456;
2183 $line->weight_units = 0;
2185 $line->volume = 2.34567;
2186 $line->volume_unit = 0;
2188 $this->lines[] = $line;
2219 if ($user->hasRight(
'expedition',
'creer')) {
2220 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition";
2221 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
2222 $sql .=
" WHERE rowid = ".((int) $this->
id);
2224 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
2225 $resql = $this->db->query($sql);
2227 $this->date_delivery = $delivery_date;
2230 $this->error = $this->db->error();
2247 if ($user->hasRight(
'expedition',
'creer')) {
2248 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition";
2249 $sql .=
" SET date_expedition = ".($shipping_date ?
"'".$this->db->idate($shipping_date).
"'" :
'null');
2250 $sql .=
" WHERE rowid = ".((int) $this->
id);
2252 dol_syslog(get_class($this).
"::setShippingDate", LOG_DEBUG);
2253 $resql = $this->db->query($sql);
2255 $this->date_shipping = $shipping_date;
2258 $this->error = $this->db->error();
2276 $this->meths = array();
2278 $sql =
"SELECT em.rowid, em.code, em.libelle as label";
2279 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2280 $sql .=
" WHERE em.active = 1";
2281 $sql .=
" ORDER BY em.libelle ASC";
2283 $resql = $this->db->query($sql);
2285 while ($obj = $this->db->fetch_object($resql)) {
2286 $label = $langs->trans(
'SendingMethod'.$obj->code);
2287 $this->meths[$obj->rowid] = ($label !=
'SendingMethod'.$obj->code ? $label : $obj->label);
2304 $this->listmeths = array();
2307 $sql =
"SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active";
2308 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2310 $sql .=
" WHERE em.rowid=".((int) $id);
2313 $resql = $this->db->query($sql);
2315 while ($obj = $this->db->fetch_object($resql)) {
2316 $this->listmeths[$i][
'rowid'] = $obj->rowid;
2317 $this->listmeths[$i][
'code'] = $obj->code;
2318 $label = $langs->trans(
'SendingMethod'.$obj->code);
2319 $this->listmeths[$i][
'libelle'] = ($label !=
'SendingMethod'.$obj->code ? $label : $obj->label);
2320 $this->listmeths[$i][
'description'] = $obj->description;
2321 $this->listmeths[$i][
'tracking'] = $obj->tracking;
2322 $this->listmeths[$i][
'active'] = $obj->active;
2336 if (!empty($this->shipping_method_id)) {
2337 $sql =
"SELECT em.code, em.tracking";
2338 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
2339 $sql .=
" WHERE em.rowid = ".((int) $this->shipping_method_id);
2341 $resql = $this->db->query($sql);
2343 if ($obj = $this->db->fetch_object($resql)) {
2344 $tracking = $obj->tracking;
2349 if (!empty($tracking) && !empty($value)) {
2350 $url = str_replace(
'{TRACKID}', $value, $tracking);
2351 $this->tracking_url = sprintf(
'<a target="_blank" rel="noopener noreferrer" href="%s">%s</a>', $url, ($value ? $value :
'url'));
2353 $this->tracking_url = $value;
2369 if ($this->statut == self::STATUS_CLOSED) {
2375 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"expedition SET fk_statut = ".self::STATUS_CLOSED.
", date_expedition = '".$this->db->escape($this->db->idate(
dol_now())).
"'";
2376 $sql .=
" WHERE rowid = ".((int) $this->
id).
" AND fk_statut > 0";
2378 $resql = $this->db->query($sql);
2381 if ($this->origin ==
'commande' && $this->origin_id > 0) {
2383 $order->fetch($this->origin_id);
2385 $order->loadExpeditions(self::STATUS_CLOSED);
2387 $shipments_match_order = 1;
2388 foreach ($order->lines as $line) {
2389 $lineid = $line->id;
2391 if (($line->product_type == 0 ||
getDolGlobalString(
'STOCK_SUPPORTS_SERVICES')) && $order->expeditions[$lineid] != $qty) {
2392 $shipments_match_order = 0;
2393 $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';
2398 if ($shipments_match_order) {
2399 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');
2401 $order->cloture($user);
2409 if (!$error && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
2418 $result = $this->
call_trigger(
'SHIPPING_CLOSED', $user);
2429 $this->db->commit();
2435 $this->db->rollback();
2455 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/mouvementstock.class.php';
2457 $langs->load(
"agenda");
2460 $sql =
"SELECT cd.fk_product, cd.subprice,";
2461 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2463 $sql .=
" edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock,";
2464 $sql .=
" cd.rowid as cdid, ed.rowid as edid";
2465 $sql .=
" FROM " . MAIN_DB_PREFIX .
"commandedet as cd,";
2466 $sql .=
" " . MAIN_DB_PREFIX .
"expeditiondet as ed";
2467 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
2468 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"expedition as e ON ed.fk_expedition = e.rowid";
2469 $sql .=
" WHERE ed.fk_expedition = " . ((int) $this->
id);
2470 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2472 dol_syslog(get_class($this) .
"::valid select details", LOG_DEBUG);
2473 $resql = $this->db->query($sql);
2475 $cpt = $this->db->num_rows($resql);
2476 for ($i = 0; $i < $cpt; $i++) {
2477 $obj = $this->db->fetch_object($resql);
2478 if (empty($obj->edbrowid)) {
2481 $qty = $obj->edbqty;
2483 if ($qty <= 0 || ($qty < 0 && !
getDolGlobalInt(
'SHIPMENT_ALLOW_NEGATIVE_QTY'))) {
2486 dol_syslog(get_class($this) .
"::valid movement index " . $i .
" ed.rowid=" . $obj->rowid .
" edb.rowid=" . $obj->edbrowid);
2489 $mouvS->origin = &$this;
2490 $mouvS->setOrigin($this->element, $this->
id, $obj->cdid, $obj->edid);
2492 if (empty($obj->edbrowid)) {
2496 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref));
2498 $this->error = $mouvS->error;
2499 $this->errors = $mouvS->errors;
2507 $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);
2509 $this->error = $mouvS->error;
2510 $this->errors = $mouvS->errors;
2518 $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)";
2519 $resqldelete = $this->db->query($sqldelete);
2523 $this->error = $this->db->lasterror();
2524 $this->errors[] = $this->db->lasterror();
2547 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'expedition SET billed = 1';
2548 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2550 $resql = $this->db->query($sql);
2555 $result = $this->
call_trigger(
'SHIPPING_BILLED', $user);
2562 $this->errors[] = $this->db->lasterror;
2565 if (empty($error)) {
2566 $this->db->commit();
2569 $this->db->rollback();
2584 if ($this->statut <= self::STATUS_DRAFT) {
2588 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'SHIPMENT_UNVALIDATE');
2598 global $langs, $user;
2603 if ($this->statut == self::STATUS_VALIDATED) {
2609 $oldbilled = $this->billed;
2611 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'expedition SET fk_statut = 1';
2612 $sql .=
" WHERE rowid = ".((int) $this->
id).
' AND fk_statut > 0';
2614 $resql = $this->db->query($sql);
2621 if (!$error && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
2622 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
2624 $langs->load(
"agenda");
2628 $sql =
"SELECT cd.fk_product, cd.subprice,";
2629 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
2630 $sql .=
" edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";
2631 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd,";
2632 $sql .=
" ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2633 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
2634 $sql .=
" WHERE ed.fk_expedition = ".((int) $this->
id);
2635 $sql .=
" AND cd.rowid = ed.fk_elementdet";
2637 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
2638 $resql = $this->db->query($sql);
2640 $cpt = $this->db->num_rows($resql);
2641 for ($i = 0; $i < $cpt; $i++) {
2642 $obj = $this->db->fetch_object($resql);
2643 if (empty($obj->edbrowid)) {
2646 $qty = $obj->edbqty;
2651 dol_syslog(get_class($this).
"::reopen expedition movement index ".$i.
" ed.rowid=".$obj->rowid.
" edb.rowid=".$obj->edbrowid);
2655 $mouvS->origin = &$this;
2656 $mouvS->setOrigin($this->element, $this->
id);
2658 if (empty($obj->edbrowid)) {
2662 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ShipmentUnClassifyCloseddInDolibarr", $this->ref));
2664 $this->error = $mouvS->error;
2665 $this->errors = $mouvS->errors;
2673 $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);
2675 $this->error = $mouvS->error;
2676 $this->errors = $mouvS->errors;
2683 $this->error = $this->db->lasterror();
2690 $result = $this->
call_trigger(
'SHIPPING_REOPEN', $user);
2697 $this->errors[] = $this->db->lasterror();
2701 $this->db->commit();
2706 $this->billed = $oldbilled;
2707 $this->db->rollback();
2723 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2725 $outputlangs->load(
"products");
2730 if (!empty($this->model_pdf)) {
2731 $modele = $this->model_pdf;
2737 $modelpath =
"core/modules/expedition/doc/";
2741 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_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_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
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.
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, $allowothertags=array())
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.