31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
38if (isModEnabled(
"product") || isModEnabled(
"service")) {
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41if (isModEnabled(
'shipping')) {
42 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
44if (isModEnabled(
'stock')) {
45 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
47if (isModEnabled(
'project')) {
48 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
53$langs->loadLangs(array(
'bills',
'deliveries',
'orders',
'sendings'));
55if (isModEnabled(
'incoterm')) {
56 $langs->load(
'incoterm');
59$action =
GETPOST(
'action',
'aZ09');
60$confirm =
GETPOST(
'confirm',
'alpha');
61$backtopage =
GETPOST(
'backtopage',
'alpha');
68$extrafields->fetch_name_optionals_label(
$object->table_element);
71$extrafields->fetch_name_optionals_label(
$object->table_element_line);
74include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
77$hookmanager->initHooks(array(
'deliverycard',
'globalcard'));
83 $socid = $user->socid;
85$result =
restrictedArea($user,
'expedition', $id,
'delivery',
'delivery');
87$permissiontoread = $user->hasRight(
'expedition',
'delivery',
'read');
88$permissiontoadd = $user->hasRight(
'expedition',
'delivery',
'creer');
89$permissiontodelete = $user->hasRight(
'expedition',
'delivery',
'supprimer') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
90$permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate')));
91$permissionnote = $user->hasRight(
'expedition',
'delivery',
'creer');
92$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'creer');
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
102$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'supprimer');
103include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
105if ($action ==
'add' && $permissiontoadd) {
121 $commande->fetch(
$object->commande_id);
122 $commande->fetch_lines();
123 $num = count($commande->lines);
124 for ($i = 0; $i < $num; $i++) {
136 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
144} elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $permissiontovalidate) {
145 $result =
$object->valid($user);
149 $outputlangs = $langs;
152 $newlang =
GETPOST(
'lang_id',
'aZ09');
155 $newlang =
$object->thirdparty->default_lang;
157 if (!empty($newlang)) {
159 $outputlangs->setDefaultLang($newlang);
164 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
171if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
173 $result =
$object->delete($user);
177 if (!empty($backtopage)) {
178 header(
"Location: ".$backtopage);
180 header(
"Location: ".DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1');
188if ($action ==
'setdate_delivery' && $permissiontoadd) {
190 $result =
$object->setDeliveryDate($user, $datedelivery);
192 $mesg =
'<div class="error">'.$object->error.
'</div>';
194} elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm')) {
200if ($action ==
'update_extras' && $permissiontoadd) {
204 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
211 $result =
$object->insertExtraFields(
'DELIVERY_MODIFY');
219 $action =
'edit_extras';
224if ($action ==
'update_extras_line' && $permissiontoadd) {
225 $array_options = array();
228 for ($i = 0; $i < $num; $i++) {
230 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
231 $array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, $i);
233 if (is_array($extralabelsline)) {
235 foreach ($extralabelsline as $key => $value) {
236 unset($_POST[
"options_".$key]);
240 $ret =
$object->update_line(
$object->lines[$i]->id, $array_options[$i]);
242 $mesg =
'<div class="error">'.$object->error.
'</div>';
250$upload_dir = $conf->expedition->dir_output.
'/receipt';
251include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
253include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
260$title = $langs->trans(
'Delivery');
262llxHeader(
'', $title,
'Livraison',
'', 0, 0,
'',
'',
'',
'mod-delivery page-card');
264$form =
new Form($db);
267if ($action ==
'create') {
275 $result = $expedition->fetch(
$object->origin_id);
276 $typeobject = $expedition->origin;
287 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
288 print
'<input type="hidden" name="token" value="'.newToken().
'">';
289 print
'<input type="hidden" name="action" value="update_extras_line">';
290 print
'<input type="hidden" name="origin" value="'.$object->origin.
'">';
291 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
292 print
'<input type="hidden" name="ref" value="'.$object->ref.
'">';
300 if ($action ==
'delete') {
301 $expedition_id =
GETPOST(
"expid");
302 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&expid='.$expedition_id.
'&backtopage='.urlencode($backtopage), $langs->trans(
"DeleteDeliveryReceipt"), $langs->trans(
"DeleteDeliveryReceiptConfirm",
$object->ref),
'confirm_delete',
'',
'', 1);
308 if ($action ==
'valid') {
309 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
"ValidateDeliveryReceipt"), $langs->trans(
"ValidateDeliveryReceiptConfirm",
$object->ref),
'confirm_valid',
'',
'', 1);
317 if ($typeobject ==
'commande' && $expedition->origin_id > 0 && isModEnabled(
'order')) {
319 $objectsrc->fetch($expedition->origin_id);
321 if ($typeobject ==
'propal' && $expedition->origin_id > 0 && isModEnabled(
"propal")) {
322 $objectsrc =
new Propal($db);
323 $objectsrc->fetch($expedition->origin_id);
327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
329 $morehtmlref =
'<div class="refidno">';
331 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'', $expedition->ref_customer, $expedition, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
332 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'', $expedition->ref_customer, $expedition, $user->hasRight(
'expedition',
'creer'),
'string'.(getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
333 $morehtmlref .=
'<br>'.$langs->trans(
"RefDeliveryReceipt").
' : '.
$object->ref;
335 $morehtmlref .=
'<br>'.$expedition->thirdparty->getNomUrl(1);
337 if (isModEnabled(
'project')) {
338 $langs->load(
"projects");
339 $morehtmlref .=
'<br>';
341 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
342 if ($action !=
'classify') {
343 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
345 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
347 if (!empty($objectsrc->fk_project)) {
349 $proj->fetch($objectsrc->fk_project);
350 $morehtmlref .= $proj->getNomUrl(1);
352 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
357 $morehtmlref .=
'</div>';
359 $morehtmlstatus = $langs->trans(
"StatusReceipt").
' : '.
$object->getLibStatut(6).
'<br><br class="small">';
361 dol_banner_tab($expedition,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
364 print
'<div class="fichecenter">';
365 print
'<div class="underbanner clearboth"></div>';
367 print
'<table class="border tableforfield" width="100%">';
397 if ($typeobject ==
'commande' && $expedition->origin_id && isModEnabled(
'order')) {
398 print
'<tr><td class="titlefield">'.$langs->trans(
"RefOrder").
'</td>';
400 $order->fetch($expedition->origin_id);
401 print
'<td colspan="3">';
402 print $order->getNomUrl(1,
'commande');
406 if ($typeobject ==
'propal' && $expedition->origin_id && isModEnabled(
"propal")) {
407 $propal =
new Propal($db);
408 $propal->fetch($expedition->origin_id);
409 print
'<tr><td class="titlefield">'.$langs->trans(
"RefProposal").
'</td>';
410 print
'<td colspan="3">';
411 print $propal->getNomUrl(1,
'expedition');
417 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
418 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
'dayhour').
"</td>\n";
422 print
'<tr><td height="10">';
423 print
'<table class="nobordernopadding" width="100%"><tr><td>';
424 print $langs->trans(
'DateReceived');
427 if ($action !=
'editdate_delivery') {
428 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate_delivery&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetDeliveryDate'), 1).
'</a></td>';
430 print
'</tr></table>';
431 print
'</td><td colspan="2">';
432 if ($action ==
'editdate_delivery') {
433 print
'<form name="setdate_delivery" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
434 print
'<input type="hidden" name="token" value="'.newToken().
'">';
435 print
'<input type="hidden" name="action" value="setdate_delivery">';
436 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_delivery", 1, 1);
437 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
446 if (isModEnabled(
'incoterm')) {
448 print
'<table class="centpercent nobordernopadding"><tr><td>';
449 print $langs->trans(
'IncotermLabel');
450 print
'<td><td class="right">';
451 if ($user->hasRight(
'expedition',
'delivery',
'creer')) {
452 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/delivery/card.php?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
456 print
'</td></tr></table>';
458 print
'<td colspan="3">';
459 if ($action !=
'editincoterm') {
460 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
462 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
487 if (!
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && isModEnabled(
'stock')) {
490 $entrepot->fetch($expedition->entrepot_id);
491 print
'<tr><td width="20%">'.$langs->trans(
"Warehouse").
'</td>';
492 print
'<td colspan="3"><a href="'.DOL_URL_ROOT.
'/product/stock/card.php?id='.$entrepot->id.
'">'.$entrepot->label.
'</a></td>';
497 if ($action ==
'create_delivery') {
499 $extrafields->fetch_name_optionals_label($expedition->table_element);
500 if ($expedition->fetch_optionals() > 0) {
501 $object->array_options = array_merge(
$object->array_options, $expedition->array_options);
505 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
507 print
"</table><br>\n";
515 $num_prod = count(
$object->lines);
519 print
'<table class="noborder centpercent">';
524 print
'<tr class="liste_titre">';
525 print
'<td>'.$langs->trans(
"Products").
'</td>';
526 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
527 print
'<td class="center">'.$langs->trans(
"QtyReceived").
'</td>';
530 while ($i < $num_prod) {
531 $parameters = array(
'i' => $i,
'line' =>
$object->lines[$i],
'num' => $num_prod);
532 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
537 if (empty($reshook)) {
538 print
'<tr class="oddeven">';
539 if (
$object->lines[$i]->fk_product > 0) {
541 $product->fetch(
$object->lines[$i]->fk_product);
545 $outputlangs = $langs;
547 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
548 $newlang =
GETPOST(
'lang_id',
'aZ09');
550 if (empty($newlang)) {
551 $newlang =
$object->thirdparty->default_lang;
553 if (!empty($newlang)) {
555 $outputlangs->setDefaultLang($newlang);
558 $label = (!empty($product->multilangs[$outputlangs->defaultlang][
"label"])) ? $product->multilangs[$outputlangs->defaultlang][
"label"] :
$object->lines[$i]->product_label;
560 $label = (!empty(
$object->lines[$i]->label) ?
$object->lines[$i]->label :
$object->lines[$i]->product_label);
566 $text =
'<a href="'.DOL_URL_ROOT.
'/product/card.php?id='.
$object->lines[$i]->fk_product.
'">';
567 if (
$object->lines[$i]->fk_product_type == 1) {
568 $text .=
img_object($langs->trans(
'ShowService'),
'service');
570 $text .=
img_object($langs->trans(
'ShowProduct'),
'product');
572 $text .=
' '.$object->lines[$i]->product_ref.
'</a>';
573 $text .=
' - '.$label;
576 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
579 print (!empty(
$object->lines[$i]->description) &&
$object->lines[$i]->description !=
$object->lines[$i]->product_label) ?
'<br>'.dol_htmlentitiesbr(
$object->lines[$i]->description) :
'';
583 if (
$object->lines[$i]->fk_product_type == 1) {
584 $text =
img_object($langs->trans(
'Service'),
'service');
586 $text =
img_object($langs->trans(
'Product'),
'product');
589 if (!empty(
$object->lines[$i]->label)) {
590 $text .=
' <strong>'.$object->lines[$i]->label.
'</strong>';
591 print $form->textwithtooltip($text,
$object->lines[$i]->description, 3,
'',
'', $i);
593 print $text.
' '.nl2br(
$object->lines[$i]->description);
600 print
'<td class="center">'.$object->lines[$i]->qty_asked.
'</td>';
601 print
'<td class="center">'.$object->lines[$i]->qty_shipped.
'</td>';
608 $mode = (
$object->statut == 0) ?
'edit' :
'view';
610 $object->lines[$i]->fetch_optionals();
612 if ($action ==
'create_delivery') {
615 $extrafields->fetch_name_optionals_label($srcLine->table_element);
616 $srcLine->id = $expedition->lines[$i]->id;
617 $srcLine->fetch_optionals();
619 $object->lines[$i]->array_options = array_merge(
$object->lines[$i]->array_options, $srcLine->array_options);
622 $extrafields->fetch_name_optionals_label($srcLine->table_element);
624 print
$object->lines[$i]->showOptionals($extrafields, $mode, array(
'style' =>
'class="oddeven"',
'colspan' => $colspan),
'');
645 if ($user->socid == 0) {
646 print
'<div class="tabsAction">';
648 if (
$object->statut == 0 && $num_prod > 0) {
649 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery',
'creer'))
650 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'delivery_advance',
'validate'))) {
655 if ($user->hasRight(
'expedition',
'delivery',
'supprimer')) {
657 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&expid='.
$object->origin_id.
'&action=delete&token='.
newToken().
'&backtopage='.urlencode(DOL_URL_ROOT.
'/expedition/card.php?id='.
$object->origin_id),
'');
667 print
'<div class="fichecenter"><div class="fichehalfleft">';
674 $filedir = $conf->expedition->dir_output.
"/receipt/".$objectref;
675 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
677 $genallowed = $user->hasRight(
'expedition',
'delivery',
'lire');
678 $delallowed = $user->hasRight(
'expedition',
'delivery',
'creer');
680 print $formfile->showdocuments(
'delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
685 if (
$object->origin ==
'expedition') {
687 $shipment->fetch(
$object->origin_id);
691 $somethingshown = $form->showLinkedObjectBlock(
$object,
'');
695 print
'</div><div class="fichehalfright">';
699 print
'</div></div>';
702 print
"Expedition inexistante ou access refuse";
706 print
"Expedition inexistante ou access refuse";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage customers orders.
Class to manage receptions.
Management class of delivery note lines.
Class to manage warehouses.
Class to manage shipments.
Class to manage lines of shipment.
Class to manage products or services.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
delivery_prepare_head($object)
Prepare array with list of tabs.