35 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobjectline.class.php";
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
38 if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
39 if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
52 public $element =
"reception";
57 public $fk_element =
"fk_reception";
58 public $table_element =
"reception";
59 public $table_element_line =
"commande_fournisseur_dispatch";
60 public $ismultientitymanaged = 1;
65 public $picto =
'dollyrevert';
78 public $tracking_number;
94 public $date_delivery;
100 public $date_reception;
105 public $date_creation;
115 public $lines = array();
118 const STATUS_DRAFT = 0;
119 const STATUS_VALIDATED = 1;
120 const STATUS_CLOSED = 2;
134 $this->statuts = array();
135 $this->statuts[-1] =
'StatusReceptionCanceled';
136 $this->statuts[0] =
'StatusReceptionDraft';
137 $this->statuts[1] =
'StatusReceptionValidated';
138 $this->statuts[2] =
'StatusReceptionProcessed';
141 $this->statutshorts = array();
142 $this->statutshorts[-1] =
'StatusReceptionCanceledShort';
143 $this->statutshorts[0] =
'StatusReceptionDraftShort';
144 $this->statutshorts[1] =
'StatusReceptionValidatedShort';
145 $this->statutshorts[2] =
'StatusReceptionProcessedShort';
156 global $langs, $conf;
157 $langs->load(
"receptions");
159 if (!empty($conf->global->RECEPTION_ADDON_NUMBER))
163 $file = $conf->global->RECEPTION_ADDON_NUMBER.
".php";
164 $classname = $conf->global->RECEPTION_ADDON_NUMBER;
167 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
169 foreach ($dirmodels as $reldir) {
173 $mybool |= @include_once $dir.$file;
182 $obj =
new $classname();
185 $numref = $obj->getNextValue($soc, $this);
195 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_RECEPTION_ADDON_NUMBER_NotDefined");
207 public function create($user, $notrigger = 0)
209 global $conf, $hookmanager;
213 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
217 $this->brouillon = 1;
219 if (empty($this->fk_project)) $this->fk_project = 0;
220 if (empty($this->weight_units)) $this->weight_units = 0;
221 if (empty($this->size_units)) $this->size_units = 0;
228 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"reception (";
231 $sql .=
", ref_supplier";
232 $sql .=
", date_creation";
233 $sql .=
", fk_user_author";
234 $sql .=
", date_reception";
235 $sql .=
", date_delivery";
237 $sql .=
", fk_projet";
238 $sql .=
", fk_shipping_method";
239 $sql .=
", tracking_number";
244 $sql .=
", weight_units";
245 $sql .=
", size_units";
246 $sql .=
", note_private";
247 $sql .=
", note_public";
248 $sql .=
", model_pdf";
249 $sql .=
", fk_incoterms, location_incoterms";
250 $sql .=
") VALUES (";
252 $sql .=
", ".$conf->entity;
253 $sql .=
", ".($this->ref_supplier ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null");
254 $sql .=
", '".$this->db->idate($now).
"'";
255 $sql .=
", ".$user->id;
256 $sql .=
", ".($this->date_reception > 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
"null");
257 $sql .=
", ".($this->date_delivery > 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
"null");
258 $sql .=
", ".$this->socid;
259 $sql .=
", ".$this->fk_project;
260 $sql .=
", ".($this->shipping_method_id > 0 ? $this->shipping_method_id :
"null");
261 $sql .=
", '".$this->db->escape($this->tracking_number).
"'";
262 $sql .=
", ".$this->weight;
263 $sql .=
", ".$this->sizeS;
264 $sql .=
", ".$this->sizeW;
265 $sql .=
", ".$this->sizeH;
266 $sql .=
", ".$this->weight_units;
267 $sql .=
", ".$this->size_units;
268 $sql .=
", ".(!empty($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
269 $sql .=
", ".(!empty($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
270 $sql .=
", ".(!empty($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null");
271 $sql .=
", ".(int) $this->fk_incoterms;
272 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
275 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
281 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"reception");
283 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
284 $sql .=
" SET ref = '(PROV".$this->id.
")'";
285 $sql .=
" WHERE rowid = ".$this->id;
287 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
288 if ($this->
db->query($sql))
291 $num = count($this->lines);
292 for ($i = 0; $i < $num; $i++)
294 $this->lines[$i]->fk_reception = $this->id;
296 if (!$this->lines[$i]->
create($user) > 0)
302 if (!$error && $this->
id && $this->origin_id)
315 if ($result < 0) $error++;
318 if (!$error && !$notrigger)
321 $result = $this->
call_trigger(
'RECEPTION_CREATE', $user);
322 if ($result < 0) { $error++; }
331 foreach ($this->errors as $errmsg)
333 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
334 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
336 $this->
db->rollback();
341 $this->error = $this->
db->lasterror().
" - sql=$sql";
342 $this->
db->rollback();
347 $this->error = $this->
db->error().
" - sql=$sql";
348 $this->
db->rollback();
364 public function fetch($id, $ref =
'', $ref_ext =
'', $notused =
'')
369 if (empty($id) && empty($ref) && empty($ref_ext))
return -1;
371 $sql =
"SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut";
372 $sql .=
", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
373 $sql .=
", e.date_reception as date_reception, e.model_pdf, e.date_delivery";
374 $sql .=
", e.fk_shipping_method, e.tracking_number";
375 $sql .=
", el.fk_source as origin_id, el.sourcetype as origin";
376 $sql .=
", e.note_private, e.note_public";
377 $sql .=
', e.fk_incoterms, e.location_incoterms';
378 $sql .=
', i.libelle as label_incoterms';
379 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception as e";
380 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->
db->escape($this->element).
"'";
381 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON e.fk_incoterms = i.rowid';
382 $sql .=
" WHERE e.entity IN (".getEntity(
'reception').
")";
383 if ($id) $sql .=
" AND e.rowid=".$id;
384 if ($ref) $sql .=
" AND e.ref='".$this->db->escape($ref).
"'";
385 if ($ref_ext) $sql .=
" AND e.ref_ext='".$this->db->escape($ref_ext).
"'";
386 if ($notused) $sql .=
" AND e.ref_int='".$this->db->escape($notused).
"'";
388 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
389 $result = $this->
db->query($sql);
392 if ($this->
db->num_rows($result))
394 $obj = $this->
db->fetch_object($result);
396 $this->
id = $obj->rowid;
397 $this->ref = $obj->ref;
398 $this->socid = $obj->socid;
399 $this->ref_supplier = $obj->ref_supplier;
400 $this->ref_ext = $obj->ref_ext;
401 $this->
statut = $obj->fk_statut;
402 $this->user_author_id = $obj->fk_user_author;
403 $this->date_creation = $this->
db->jdate($obj->date_creation);
404 $this->date = $this->
db->jdate($obj->date_reception);
405 $this->date_reception = $this->
db->jdate($obj->date_reception);
406 $this->date_reception = $this->
db->jdate($obj->date_reception);
407 $this->date_delivery = $this->
db->jdate($obj->date_delivery);
408 $this->model_pdf = $obj->model_pdf;
409 $this->modelpdf = $obj->model_pdf;
410 $this->shipping_method_id = $obj->fk_shipping_method;
411 $this->tracking_number = $obj->tracking_number;
412 $this->origin = ($obj->origin ? $obj->origin :
'commande');
413 $this->origin_id = $obj->origin_id;
414 $this->billed = ($obj->fk_statut == 2 ? 1 : 0);
416 $this->trueWeight = $obj->weight;
417 $this->weight_units = $obj->weight_units;
419 $this->trueWidth = $obj->width;
420 $this->width_units = $obj->size_units;
421 $this->trueHeight = $obj->height;
422 $this->height_units = $obj->size_units;
423 $this->trueDepth = $obj->size;
424 $this->depth_units = $obj->size_units;
426 $this->note_public = $obj->note_public;
427 $this->note_private = $obj->note_private;
430 $this->trueSize = $obj->size.
"x".$obj->width.
"x".$obj->height;
431 $this->size_units = $obj->size_units;
434 $this->fk_incoterms = $obj->fk_incoterms;
435 $this->location_incoterms = $obj->location_incoterms;
436 $this->label_incoterms = $obj->label_incoterms;
438 $this->
db->free($result);
440 if ($this->
statut == 0) $this->brouillon = 1;
442 $file = $conf->reception->dir_output.
"/".
get_exdir($this->
id, 2, 0, 0, $this,
'reception').
"/".$this->
id.
".pdf";
443 $this->pdf_filename = $file;
456 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
458 $extrafields->fetch_name_optionals_label($this->table_element,
true);
472 dol_syslog(get_class($this).
'::Fetch no reception found', LOG_ERR);
473 $this->error =
'Delivery with id '.$id.
' not found';
477 $this->error = $this->
db->error();
489 public function valid($user, $notrigger = 0)
491 global $conf, $langs;
493 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
500 dol_syslog(get_class($this).
"::valid no draft status", LOG_WARNING);
504 if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer))
505 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))))
507 $this->error =
'Permission denied';
508 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
518 $soc->fetch($this->socid);
522 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->ref) || empty($this->ref)))
526 $numref = $this->ref;
534 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
535 $sql .=
" ref='".$this->db->escape($numref).
"'";
536 $sql .=
", fk_statut = 1";
537 $sql .=
", date_valid = '".$this->db->idate($now).
"'";
538 $sql .=
", fk_user_valid = ".$user->id;
539 $sql .=
" WHERE rowid = ".$this->id;
540 dol_syslog(get_class($this).
"::valid update reception", LOG_DEBUG);
544 $this->error = $this->
db->lasterror();
549 if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
551 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
553 $langs->load(
"agenda");
557 $sql =
"SELECT cd.fk_product, cd.subprice,";
558 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
559 $sql .=
" ed.eatby, ed.sellby, ed.batch";
560 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
561 $sql .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as ed";
562 $sql .=
" WHERE ed.fk_reception = ".$this->id;
563 $sql .=
" AND cd.rowid = ed.fk_commandefourndet";
565 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
570 for ($i = 0; $i < $cpt; $i++)
572 $obj = $this->
db->fetch_object(
$resql);
576 if ($qty <= 0)
continue;
577 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid.
" edb.rowid=".$obj->edbrowid);
581 $mouvS->origin = &$this;
583 if (empty($obj->batch))
588 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans(
"ReceptionValidatedInDolibarr", $numref));
591 $this->errors[] = $mouvS->error;
592 $this->errors = array_merge($this->errors, $mouvS->errors);
600 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans(
"ReceptionValidatedInDolibarr", $numref), $this->
db->jdate($obj->eatby), $this->
db->jdate($obj->sellby), $obj->batch);
603 $this->errors[] = $mouvS->error;
604 $this->errors = array_merge($this->errors, $mouvS->errors);
610 $this->
db->rollback();
611 $this->error = $this->
db->error();
617 $ret = $this->
setStatut(4, $this->origin_id,
'commande_fournisseur');
624 if (!$error && !$notrigger)
627 $result = $this->
call_trigger(
'RECEPTION_VALIDATE', $user);
628 if ($result < 0) { $error++; }
634 $this->oldref = $this->ref;
637 if (preg_match(
'/^[\(]?PROV/i', $this->ref))
640 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->
db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->ref) + 1).
")), filepath = 'reception/".$this->
db->escape($this->newref).
"'";
641 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->ref).
"%' AND filepath = 'reception/".$this->
db->escape($this->ref).
"' and entity = ".$conf->entity;
643 if (!
$resql) { $error++; $this->error = $this->
db->lasterror(); }
648 $dirsource = $conf->reception->dir_output.
'/'.$oldref;
649 $dirdest = $conf->reception->dir_output.
'/'.$newref;
650 if (!$error && file_exists($dirsource))
652 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
654 if (@rename($dirsource, $dirdest))
658 $listoffiles =
dol_dir_list($conf->reception->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
659 foreach ($listoffiles as $fileentry)
661 $dirsource = $fileentry[
'name'];
662 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
663 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
664 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
665 @rename($dirsource, $dirdest);
675 $this->ref = $numref;
684 foreach ($this->errors as $errmsg)
686 dol_syslog(get_class($this).
"::valid ".$errmsg, LOG_ERR);
687 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
689 $this->
db->rollback();
711 public function addline($entrepot_id, $id, $qty, $array_options = 0, $comment =
'', $eatby =
'', $sellby =
'', $batch =
'')
713 global $conf, $langs, $user;
715 $num = count($this->lines);
718 $line->fk_entrepot = $entrepot_id;
719 $line->fk_commandefourndet = $id;
723 $supplierorderline->fetch($id);
725 if (!empty($conf->stock->enabled) && !empty($supplierorderline->fk_product))
727 $fk_product = $supplierorderline->fk_product;
729 if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS))
731 $langs->load(
"errors");
732 $this->error = $langs->trans(
"ErrorWarehouseRequiredIntoReceptionLine");
738 $line->array_options = $supplierorderline->array_options;
739 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0)
741 foreach ($array_options as $key => $value) {
742 $line->array_options[$key] = $value;
746 $line->fk_product = $fk_product;
747 $line->fk_commande = $supplierorderline->fk_commande;
748 $line->fk_user = $user->id;
749 $line->comment = $comment;
750 $line->batch = $batch;
751 $line->eatby = $eatby;
752 $line->sellby = $sellby;
754 $line->fk_reception = $this->id;
756 $this->lines[$num] = $line;
769 public function update($user = null, $notrigger = 0)
776 if (isset($this->ref)) $this->ref = trim($this->ref);
777 if (isset($this->entity)) $this->entity = trim($this->entity);
778 if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier);
779 if (isset($this->socid)) $this->socid = trim($this->socid);
780 if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author);
781 if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid);
782 if (isset($this->shipping_method_id)) $this->shipping_method_id = trim($this->shipping_method_id);
783 if (isset($this->tracking_number)) $this->tracking_number = trim($this->tracking_number);
785 if (isset($this->trueDepth)) $this->trueDepth = trim($this->trueDepth);
786 if (isset($this->trueWidth)) $this->trueWidth = trim($this->trueWidth);
787 if (isset($this->trueHeight)) $this->trueHeight = trim($this->trueHeight);
788 if (isset($this->size_units)) $this->size_units = trim($this->size_units);
789 if (isset($this->weight_units)) $this->weight_units = trim($this->weight_units);
790 if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight);
791 if (isset($this->note_private)) $this->note_private = trim($this->note_private);
792 if (isset($this->note_public)) $this->note_public = trim($this->note_public);
793 if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
800 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception SET";
802 $sql .=
" ref=".(isset($this->ref) ?
"'".$this->db->escape($this->ref).
"'" :
"null").
",";
803 $sql .=
" ref_supplier=".(isset($this->ref_supplier) ?
"'".$this->db->escape($this->ref_supplier).
"'" :
"null").
",";
804 $sql .=
" fk_soc=".(isset($this->socid) ? $this->socid :
"null").
",";
805 $sql .=
" date_creation=".(dol_strlen($this->date_creation) != 0 ?
"'".$this->db->idate($this->date_creation).
"'" :
'null').
",";
806 $sql .=
" fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author :
"null").
",";
807 $sql .=
" date_valid=".(dol_strlen($this->date_valid) != 0 ?
"'".$this->db->idate($this->date_valid).
"'" :
'null').
",";
808 $sql .=
" fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid :
"null").
",";
809 $sql .=
" date_reception=".(dol_strlen($this->date_reception) != 0 ?
"'".$this->db->idate($this->date_reception).
"'" :
'null').
",";
810 $sql .=
" date_delivery=".(dol_strlen($this->date_delivery) != 0 ?
"'".$this->db->idate($this->date_delivery).
"'" :
'null').
",";
811 $sql .=
" fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id :
"null").
",";
812 $sql .=
" tracking_number=".(isset($this->tracking_number) ?
"'".$this->db->escape($this->tracking_number).
"'" :
"null").
",";
813 $sql .=
" fk_statut=".(isset($this->
statut) ? $this->
statut :
"null").
",";
814 $sql .=
" height=".(($this->trueHeight !=
'') ? $this->trueHeight :
"null").
",";
815 $sql .=
" width=".(($this->trueWidth !=
'') ? $this->trueWidth :
"null").
",";
816 $sql .=
" size_units=".(isset($this->size_units) ? $this->size_units :
"null").
",";
817 $sql .=
" size=".(($this->trueDepth !=
'') ? $this->trueDepth :
"null").
",";
818 $sql .=
" weight_units=".(isset($this->weight_units) ? $this->weight_units :
"null").
",";
819 $sql .=
" weight=".(($this->trueWeight !=
'') ? $this->trueWeight :
"null").
",";
820 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
821 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
822 $sql .=
" model_pdf=".(isset($this->modelpdf) ?
"'".$this->db->escape($this->modelpdf).
"'" :
"null").
",";
823 $sql .=
" entity=".$conf->entity;
825 $sql .=
" WHERE rowid=".$this->id;
829 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
831 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
838 $result = $this->
call_trigger(
'RECEPTION_MODIFY', $user);
839 if ($result < 0) { $error++; }
847 foreach ($this->errors as $errmsg)
849 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
850 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
852 $this->
db->rollback();
866 public function delete(
User $user)
868 global $conf, $langs, $user;
869 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
878 if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_RECEPTION && $this->statut > 0)
880 require_once DOL_DOCUMENT_ROOT.
"/product/stock/class/mouvementstock.class.php";
882 $langs->load(
"agenda");
885 $sql =
"SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.eatby, ed.sellby, ed.batch, ed.rowid as commande_fournisseur_dispatch_id";
886 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
887 $sql .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as ed";
888 $sql .=
" WHERE ed.fk_reception = ".$this->id;
889 $sql .=
" AND cd.rowid = ed.fk_commandefourndet";
891 dol_syslog(get_class($this).
"::delete select details", LOG_DEBUG);
896 for ($i = 0; $i < $cpt; $i++)
898 dol_syslog(get_class($this).
"::delete movement index ".$i);
899 $obj = $this->
db->fetch_object(
$resql);
903 $mouvS->origin = null;
905 $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans(
"ReceptionDeletedInDolibarr", $this->ref),
'', $obj->eatby, $obj->sellby, $obj->batch);
908 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
914 $main = MAIN_DB_PREFIX.
'commande_fournisseur_dispatch';
915 $ef = $main.
"_extrafields";
916 $sqlef =
"DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = ".$this->id.
")";
918 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch";
919 $sql .=
" WHERE fk_reception = ".$this->id;
921 if ($this->
db->query($sqlef) && $this->
db->query($sql))
925 if ($res < 0) $error++;
929 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"reception";
930 $sql .=
" WHERE rowid = ".$this->id;
932 if ($this->
db->query($sql))
935 $result = $this->
call_trigger(
'RECEPTION_DELETE', $user);
936 if ($result < 0) { $error++; }
939 if (!empty($this->origin) && $this->origin_id > 0)
942 $origin = $this->origin;
943 if ($this->$origin->statut == 4)
946 $this->$origin->loadReceptions();
948 if (count($this->$origin->receptions) <= 0)
950 $this->$origin->setStatut(3);
961 if (!empty($conf->reception->dir_output))
963 $dir = $conf->reception->dir_output.
'/'.$ref;
964 $file = $dir.
'/'.$ref.
'.pdf';
965 if (file_exists($file))
972 if (file_exists($dir))
976 $this->error = $langs->trans(
"ErrorCanNotDeleteDir", $dir);
984 $this->
db->rollback();
988 $this->error = $this->
db->lasterror().
" - sql=$sql";
989 $this->
db->rollback();
993 $this->error = $this->
db->lasterror().
" - sql=$sql";
994 $this->
db->rollback();
998 $this->error = $this->
db->lasterror().
" - sql=$sql";
999 $this->
db->rollback();
1003 $this->
db->rollback();
1018 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'commande_fournisseur_dispatch WHERE fk_reception='.$this->id;
1022 $this->lines = array();
1023 while ($obj = $this->
db->fetch_object(
$resql)) {
1025 $line->fetch($obj->rowid);
1026 $line->fetch_product();
1027 $sql_commfourndet =
'SELECT qty, ref, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet;
1028 $resql_commfourndet = $this->
db->query($sql_commfourndet);
1029 if (!empty($resql_commfourndet)) {
1030 $obj = $this->
db->fetch_object($resql_commfourndet);
1031 $line->qty_asked = $obj->qty;
1032 $line->description = $line->comment;
1033 $line->desc = $line->comment;
1034 $line->tva_tx = $obj->tva_tx;
1035 $line->vat_src_code = $obj->vat_src_code;
1036 $line->subprice = $obj->subprice;
1037 $line->multicurrency_subprice = $obj->multicurrency_subprice;
1038 $line->remise_percent = $obj->remise_percent;
1039 $line->label = !empty($obj->label) ? $obj->label : $line->product->label;
1040 $line->ref_supplier = $obj->ref;
1042 $line->qty_asked = 0;
1043 $line->description =
'';
1044 $line->label = $obj->label;
1047 $pu_ht = ($line->subprice * $line->qty) * (100 - $line->remise_percent) / 100;
1048 $tva = $pu_ht * $line->tva_tx / 100;
1049 $this->total_ht += $pu_ht;
1050 $this->total_tva += $pu_ht * $line->tva_tx / 100;
1052 $this->total_ttc += $pu_ht + $tva;
1055 $this->lines[] = $line;
1074 public function getNomUrl($withpicto = 0, $option = 0, $max = 0, $short = 0, $notooltip = 0)
1076 global $conf, $langs;
1078 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Reception").
'</u>';
1079 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1080 $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client);
1082 $url = DOL_URL_ROOT.
'/reception/card.php?id='.$this->id;
1084 if ($short)
return $url;
1087 if (empty($notooltip))
1089 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1091 $label = $langs->trans(
"Reception");
1092 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1094 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1095 $linkclose .=
' class="classfortooltip"';
1098 $linkstart =
'<a href="'.$url.
'"';
1099 $linkstart .= $linkclose.
'>';
1102 if ($withpicto) $result .= ($linkstart.img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
1103 if ($withpicto && $withpicto != 2) $result .=
' ';
1104 $result .= $linkstart.$this->ref.$linkend;
1132 $labelStatus = $langs->trans($this->statuts[$status]);
1133 $labelStatusShort = $langs->trans($this->statutshorts[$status]);
1135 $statusType =
'status'.$status;
1136 if ($status == self::STATUS_VALIDATED) $statusType =
'status4';
1137 if ($status == self::STATUS_CLOSED) $statusType =
'status6';
1139 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
1153 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1154 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
1157 dol_syslog(get_class($this).
"::initAsSpecimen");
1162 $sql =
"SELECT rowid";
1163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
1164 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
1165 $sql .= $this->
db->plimit(100);
1170 $num_prods = $this->
db->num_rows(
$resql);
1172 while ($i < $num_prods)
1175 $row = $this->
db->fetch_row(
$resql);
1176 $prodids[$i] = $row[0];
1181 $order->initAsSpecimen();
1185 $this->ref =
'SPECIMEN';
1186 $this->specimen = 1;
1188 $this->livraison_id = 0;
1190 $this->date_creation = $now;
1191 $this->date_valid = $now;
1192 $this->date_delivery = $now;
1193 $this->date_reception = $now + 24 * 3600;
1195 $this->entrepot_id = 0;
1198 $this->commande_id = 0;
1199 $this->commande = $order;
1201 $this->origin_id = 1;
1202 $this->origin =
'commande';
1204 $this->note_private =
'Private note';
1205 $this->note_public =
'Public note';
1209 while ($xnbp < $nbp)
1212 $line->desc = $langs->trans(
"Description").
" ".$xnbp;
1213 $line->libelle = $langs->trans(
"Description").
" ".$xnbp;
1216 $line->fk_product = $this->commande->lines[$xnbp]->fk_product;
1218 $this->lines[] = $line;
1233 if ($user->rights->reception->creer)
1235 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1236 $sql .=
" SET date_delivery = ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1237 $sql .=
" WHERE rowid = ".$this->id;
1239 dol_syslog(get_class($this).
"::setDeliveryDate", LOG_DEBUG);
1243 $this->date_delivery = $delivery_date;
1246 $this->error = $this->
db->error();
1264 $this->meths = array();
1266 $sql =
"SELECT em.rowid, em.code, em.libelle";
1267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
1268 $sql .=
" WHERE em.active = 1";
1269 $sql .=
" ORDER BY em.libelle ASC";
1274 while ($obj = $this->
db->fetch_object(
$resql))
1276 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
1277 $this->meths[$obj->rowid] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
1294 $this->listmeths = array();
1297 $sql =
"SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
1298 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
1299 if ($id !=
'') $sql .=
" WHERE em.rowid=".$id;
1303 while ($obj = $this->
db->fetch_object(
$resql)) {
1304 $this->listmeths[$i][
'rowid'] = $obj->rowid;
1305 $this->listmeths[$i][
'code'] = $obj->code;
1306 $label = $langs->trans(
'ReceptionMethod'.$obj->code);
1307 $this->listmeths[$i][
'libelle'] = ($label !=
'ReceptionMethod'.$obj->code ? $label : $obj->libelle);
1308 $this->listmeths[$i][
'description'] = $obj->description;
1309 $this->listmeths[$i][
'tracking'] = $obj->tracking;
1310 $this->listmeths[$i][
'active'] = $obj->active;
1329 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"c_shipment_mode (code, libelle, description, tracking)";
1330 $sql .=
" VALUES ('".$this->db->escape($this->
update[
'code']).
"','".$this->
db->escape($this->
update[
'libelle']).
"','".$this->
db->escape($this->
update[
'description']).
"','".$this->
db->escape($this->
update[
'tracking']).
"')";
1333 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"c_shipment_mode SET";
1334 $sql .=
" code='".$this->db->escape($this->
update[
'code']).
"'";
1335 $sql .=
",libelle='".$this->db->escape($this->
update[
'libelle']).
"'";
1336 $sql .=
",description='".$this->db->escape($this->
update[
'description']).
"'";
1337 $sql .=
",tracking='".$this->db->escape($this->
update[
'tracking']).
"'";
1338 $sql .=
" WHERE rowid=".$id;
1355 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'c_shipment_mode SET active=1';
1356 $sql .=
' WHERE rowid='.$id;
1372 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'c_shipment_mode SET active=0';
1373 $sql .=
' WHERE rowid='.$id;
1387 if (!empty($this->shipping_method_id))
1389 $sql =
"SELECT em.code, em.tracking";
1390 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as em";
1391 $sql .=
" WHERE em.rowid = ".$this->shipping_method_id;
1396 if ($obj = $this->
db->fetch_object(
$resql))
1398 $tracking = $obj->tracking;
1403 if (!empty($tracking) && !empty($value))
1405 $url = str_replace(
'{TRACKID}', $value, $tracking);
1406 $this->tracking_url = sprintf(
'<a target="_blank" href="%s">'.($value ? $value :
'url').
'</a>', $url, $url);
1408 $this->tracking_url = $value;
1419 global $conf, $langs, $user;
1425 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut='.self::STATUS_CLOSED;
1426 $sql .=
' WHERE rowid = '.$this->id.
' AND fk_statut > 0';
1432 if ($this->origin ==
'order_supplier' && $this->origin_id > 0)
1435 $order->fetch($this->origin_id);
1437 $order->loadReceptions(self::STATUS_CLOSED);
1439 $receptions_match_order = 1;
1440 foreach ($order->lines as $line)
1442 $lineid = $line->id;
1444 if (($line->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->receptions[$lineid] < $qty)
1446 $receptions_match_order = 0;
1447 $text =
'Qty for order line id '.$lineid.
' is '.$qty.
'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.
' we have qty = '.$order->receptions[$lineid].
', so we can t close order';
1452 if ($receptions_match_order)
1454 dol_syslog(
"Qty for the ".count($order->lines).
" lines of order have same value for receptions with status Reception::STATUS_CLOSED=".self::STATUS_CLOSED.
', so we close order');
1455 $order->Livraison($user,
dol_now(),
'tot',
'Reception '.$this->ref);
1459 $this->
statut = self::STATUS_CLOSED;
1463 if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))
1465 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
1467 $langs->load(
"agenda");
1471 $sql =
"SELECT cd.fk_product, cd.subprice,";
1472 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
1473 $sql .=
" ed.eatby, ed.sellby, ed.batch";
1474 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
1475 $sql .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as ed";
1476 $sql .=
" WHERE ed.fk_reception = ".$this->id;
1477 $sql .=
" AND cd.rowid = ed.fk_commandefourndet";
1479 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
1484 $cpt = $this->
db->num_rows(
$resql);
1485 for ($i = 0; $i < $cpt; $i++)
1487 $obj = $this->
db->fetch_object(
$resql);
1491 if ($qty <= 0)
continue;
1492 dol_syslog(get_class($this).
"::valid movement index ".$i.
" ed.rowid=".$obj->rowid.
" edb.rowid=".$obj->edbrowid);
1495 $mouvS->origin = &$this;
1497 if (empty($obj->batch))
1502 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans(
"ReceptionClassifyClosedInDolibarr", $numref));
1504 $this->error = $mouvS->error;
1505 $this->errors = $mouvS->errors;
1512 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans(
"ReceptionClassifyClosedInDolibarr", $numref), $this->
db->jdate($obj->eatby), $this->
db->jdate($obj->sellby), $obj->batch);
1515 $this->error = $mouvS->error;
1516 $this->errors = $mouvS->errors;
1522 $this->error = $this->
db->lasterror();
1530 $result = $this->
call_trigger(
'RECEPTION_CLOSED', $user);
1542 $this->
db->commit();
1545 $this->
db->rollback();
1566 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET billed=1';
1567 $sql .=
' WHERE rowid = '.$this->id.
' AND fk_statut > 0';
1576 $result = $this->
call_trigger(
'RECEPTION_BILLED', $user);
1582 $this->errors[] = $this->
db->lasterror;
1585 if (empty($error)) {
1586 $this->
db->commit();
1589 $this->
db->rollback();
1601 global $conf, $langs, $user;
1607 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'reception SET fk_statut=1, billed=0';
1608 $sql .=
' WHERE rowid = '.$this->id.
' AND fk_statut > 0';
1617 if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))
1619 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
1620 $numref = $this->ref;
1621 $langs->load(
"agenda");
1625 $sql =
"SELECT ed.fk_product, cd.subprice,";
1626 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
1627 $sql .=
" ed.eatby, ed.sellby, ed.batch";
1628 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
1629 $sql .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as ed";
1630 $sql .=
" WHERE ed.fk_reception = ".$this->id;
1631 $sql .=
" AND cd.rowid = ed.fk_commandefourndet";
1633 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
1637 $cpt = $this->
db->num_rows(
$resql);
1638 for ($i = 0; $i < $cpt; $i++)
1640 $obj = $this->
db->fetch_object(
$resql);
1644 if ($qty <= 0)
continue;
1646 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid);
1650 $mouvS->origin = &$this;
1652 if (empty($obj->batch))
1657 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ReceptionUnClassifyCloseddInDolibarr", $numref));
1659 $this->error = $mouvS->error;
1660 $this->errors = $mouvS->errors;
1667 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ReceptionUnClassifyCloseddInDolibarr", $numref), $this->
db->jdate($obj->eatby), $this->
db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
1669 $this->error = $mouvS->error;
1670 $this->errors = $mouvS->errors;
1676 $this->error = $this->
db->lasterror();
1684 $result = $this->
call_trigger(
'RECEPTION_REOPEN', $user);
1690 if ($this->origin ==
'order_supplier') {
1692 $commande->fetch($this->origin_id);
1693 $commande->setStatus($user, 4);
1697 $this->errors[] = $this->
db->lasterror();
1702 $this->
db->commit();
1705 $this->
db->rollback();
1719 global $conf, $langs;
1724 if ($this->
statut <= self::STATUS_DRAFT)
1729 if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer))
1730 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))))
1732 $this->error =
'Permission denied';
1738 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"reception";
1739 $sql .=
" SET fk_statut = ".self::STATUS_DRAFT;
1740 $sql .=
" WHERE rowid = ".$this->id;
1743 if ($this->
db->query($sql))
1746 if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
1748 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
1750 $langs->load(
"agenda");
1754 $sql =
"SELECT cd.fk_product, cd.subprice,";
1755 $sql .=
" ed.rowid, ed.qty, ed.fk_entrepot,";
1756 $sql .=
" ed.eatby, ed.sellby, ed.batch";
1757 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd,";
1758 $sql .=
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as ed";
1759 $sql .=
" WHERE ed.fk_reception = ".$this->id;
1760 $sql .=
" AND cd.rowid = ed.fk_commandefourndet";
1762 dol_syslog(get_class($this).
"::valid select details", LOG_DEBUG);
1766 $cpt = $this->
db->num_rows(
$resql);
1767 for ($i = 0; $i < $cpt; $i++)
1769 $obj = $this->
db->fetch_object(
$resql);
1774 if ($qty <= 0)
continue;
1775 dol_syslog(get_class($this).
"::reopen reception movement index ".$i.
" ed.rowid=".$obj->rowid.
" edb.rowid=".$obj->edbrowid);
1779 $mouvS->origin = &$this;
1781 if (empty($obj->batch))
1786 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ReceptionBackToDraftInDolibarr", $this->ref));
1788 $this->error = $mouvS->error;
1789 $this->errors = $mouvS->errors;
1797 $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans(
"ReceptionBackToDraftInDolibarr", $this->ref), $this->
db->jdate($obj->eatby), $this->
db->jdate($obj->sellby), $obj->batch);
1799 $this->error = $mouvS->error;
1800 $this->errors = $mouvS->errors;
1806 $this->error = $this->
db->lasterror();
1813 $result = $this->
call_trigger(
'RECEPTION_UNVALIDATE', $user);
1814 if ($result < 0) $error++;
1816 if ($this->origin ==
'order_supplier')
1818 if (!empty($this->origin) && $this->origin_id > 0)
1821 $origin = $this->origin;
1822 if ($this->$origin->statut == 4)
1825 $this->$origin->fetchObjectLinked();
1827 if (!empty($this->$origin->linkedObjects[
'reception']))
1829 foreach ($this->$origin->linkedObjects[
'reception'] as $rcption)
1831 if ($rcption->statut > 0)
1840 $this->$origin->setStatut(3);
1848 $this->
statut = self::STATUS_DRAFT;
1849 $this->
db->commit();
1852 $this->
db->rollback();
1856 $this->error = $this->
db->error();
1857 $this->
db->rollback();
1872 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1874 global $conf, $langs;
1876 $langs->load(
"receptions");
1880 $modele =
'squille';
1882 if ($this->model_pdf) {
1883 $modele = $this->model_pdf;
1884 } elseif (!empty($conf->global->RECEPTION_ADDON_PDF)) {
1885 $modele = $conf->global->RECEPTION_ADDON_PDF;
1889 $modelpath =
"core/modules/reception/doc/";
1893 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1906 $tables = array(
'reception');
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
Class to manage stock movements.
LibStatut($status, $mode)
Return label of a status.
getLibStatut($mode=0)
Return status label.
disable_delivery_method($id)
DesActivate delivery method.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
activ_delivery_method($id)
Activate delivery method.
setClosed()
Classify the reception as closed.
getUrlTrackingStatus($value= '')
Forge an set tracking url.
update($user=null, $notrigger=0)
Update database.
Class to manage table commandefournisseurdispatch.
reOpen()
Classify the reception as validated/opened.
setDeliveryDate($user, $delivery_date)
Set the planned delivery date.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
list_delivery_methods($id= '')
Fetch all deliveries method and return an array.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
fetch($id, $ref= '', $ref_ext= '', $notused= '')
Get object and lines from database.
fetch_origin()
Read linked origin object.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
update_delivery_method($id= '')
Update/create delivery method.
$conf db
API class for accounts.
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create a document onto disk according to template module.
Class to manage third parties objects (customers, suppliers, prospects...)
getNomUrl($withpicto=0, $option=0, $max=0, $short=0, $notooltip=0)
Return clicable link of object (with eventually picto)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
setDraft($user)
Set draft status.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
set_billed()
Classify the reception as invoiced (used when WORKFLOW_BILL_ON_RECEPTION is on)
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage receptions.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
addline($entrepot_id, $id, $qty, $array_options=0, $comment= '', $eatby= '', $sellby= '', $batch= '')
Add an reception line.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=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)
Remove a file or several files with a mask.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
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...
Class to manage predefined suppliers products.
deleteObjectLinked($sourceid=null, $sourcetype= '', $targetid=null, $targettype= '', $rowid= '')
Delete all links between an object $this.
getNextNumRef($soc)
Return next contract ref.
create($user, $notrigger=0)
Create reception en base.
trait CommonIncoterm
Superclass for incoterm classes.
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
print
Draft customers invoices.
call_trigger($triggerName, $user)
Call trigger based on this instance.
__construct($db)
Constructor.
setStatut($status, $elementId=null, $elementType= '', $trigkey= '')
Set status of an object.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
add_object_linked($origin=null, $origin_id=null)
Add objects linked in llx_element_element.
initAsSpecimen()
Initialise an instance with random values.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
valid($user, $notrigger=0)
Validate object and update stock if option enabled.
fetch_delivery_methods()
Fetch deliveries method and return an array.
Class to manage line orders.