31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
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'));
56 $langs->load(
'incoterm');
59 $action =
GETPOST(
'action',
'aZ09');
60 $confirm =
GETPOST(
'confirm',
'alpha');
61 $backtopage =
GETPOST(
'backtopage',
'alpha');
66 $socid = $user->socid;
68 $result =
restrictedArea($user,
'expedition', $id,
'delivery',
'delivery');
74 $extrafields->fetch_name_optionals_label($object->table_element);
77 $extrafields->fetch_name_optionals_label($object->table_element_line);
80 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
83 $hookmanager->initHooks(array(
'deliverycard',
'globalcard'));
93 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
95 $permissiondellink = $user->rights->expedition->delivery->supprimer;
96 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
98 if ($action ==
'add') {
101 $object->date_delivery =
dol_now();
102 $object->note =
GETPOST(
"note",
'restricthtml');
103 $object->note_private =
GETPOST(
"note",
'restricthtml');
104 $object->commande_id =
GETPOST(
"commande_id",
'int');
105 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
114 $commande->fetch($object->commande_id);
115 $commande->fetch_lines();
116 $num = count($commande->lines);
117 for ($i = 0; $i < $num; $i++) {
126 $ret = $object->create($user);
129 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
137 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
138 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
139 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate)))
141 $result = $object->valid($user);
144 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
145 $outputlangs = $langs;
148 $newlang =
GETPOST(
'lang_id',
'aZ09');
151 $newlang = $object->thirdparty->default_lang;
153 if (!empty($newlang)) {
155 $outputlangs->setDefaultLang($newlang);
157 $model = $object->model_pdf;
158 $ret = $object->fetch($id);
160 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
167 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->expedition->delivery->supprimer) {
169 $result = $object->delete();
173 if (!empty($backtopage)) {
174 header(
"Location: ".$backtopage);
176 header(
"Location: ".DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1');
184 if ($action ==
'setdate_delivery' && $user->rights->expedition->delivery->creer) {
185 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
186 $result = $object->setDeliveryDate($user, $datedelivery);
188 $mesg =
'<div class="error">'.$object->error.
'</div>';
190 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm')) {
192 $result = $object->setIncoterms((
int)
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
196 if ($action ==
'update_extras') {
200 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
207 $result = $object->insertExtraFields(
'DELIVERY_MODIFY');
215 $action =
'edit_extras';
220 if ($action ==
'update_extras_line') {
221 $array_options = array();
222 $num = count($object->lines);
224 for ($i = 0; $i < $num; $i++) {
226 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
227 $array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, $i);
229 if (is_array($extralabelsline)) {
231 foreach ($extralabelsline as $key => $value) {
232 unset($_POST[
"options_".$key]);
236 $ret = $object->update_line($object->lines[$i]->id, $array_options[$i]);
238 $mesg =
'<div class="error">'.$object->error.
'</div>';
246 $upload_dir = $conf->expedition->dir_output.
'/receipt';
247 $permissiontoadd = $user->rights->expedition->creer;
248 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
250 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
257 $title = $langs->trans(
'Delivery');
264 if ($action ==
'create') {
268 if ($object->id > 0) {
272 $result = $expedition->fetch($object->origin_id);
273 $typeobject = $expedition->origin;
274 if ($object->origin_id > 0) {
275 $object->fetch_origin();
278 if ($object->id > 0) {
280 $soc->fetch($object->socid);
284 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
285 print
'<input type="hidden" name="token" value="'.newToken().
'">';
286 print
'<input type="hidden" name="action" value="update_extras_line">';
287 print
'<input type="hidden" name="origin" value="'.$object->origin.
'">';
288 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
289 print
'<input type="hidden" name="ref" value="'.$object->ref.
'">';
297 if ($action ==
'delete') {
298 $expedition_id =
GETPOST(
"expid");
299 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);
305 if ($action ==
'valid') {
306 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"ValidateDeliveryReceipt"), $langs->trans(
"ValidateDeliveryReceiptConfirm", $object->ref),
'confirm_valid',
'',
'', 1);
314 if ($typeobject ==
'commande' && $expedition->origin_id > 0 &&
isModEnabled(
'commande')) {
316 $objectsrc->fetch($expedition->origin_id);
318 if ($typeobject ==
'propal' && $expedition->origin_id > 0 &&
isModEnabled(
"propal")) {
319 $objectsrc =
new Propal($db);
320 $objectsrc->fetch($expedition->origin_id);
324 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
326 $morehtmlref =
'<div class="refidno">';
328 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'', $expedition->ref_customer, $expedition, $user->rights->expedition->creer,
'string',
'', 0, 1);
329 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'', $expedition->ref_customer, $expedition, $user->rights->expedition->creer,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE :
''),
'',
null,
null,
'', 1);
330 $morehtmlref .=
'<br>'.$langs->trans(
"RefDeliveryReceipt").
' : '.$object->ref;
332 $morehtmlref .=
'<br>'.$expedition->thirdparty->getNomUrl(1);
335 $langs->load(
"projects");
336 $morehtmlref .=
'<br>';
338 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
339 if ($action !=
'classify') {
340 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
342 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
344 if (!empty($objectsrc->fk_project)) {
346 $proj->fetch($objectsrc->fk_project);
347 $morehtmlref .= $proj->getNomUrl(1);
349 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
354 $morehtmlref .=
'</div>';
356 $morehtmlstatus = $langs->trans(
"StatusReceipt").
' : '.$object->getLibStatut(6).
'<br><br class="small">';
358 dol_banner_tab($expedition,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
361 print
'<div class="fichecenter">';
362 print
'<div class="underbanner clearboth"></div>';
364 print
'<table class="border tableforfield" width="100%">';
394 if ($typeobject ==
'commande' && $expedition->origin_id &&
isModEnabled(
'commande')) {
395 print
'<tr><td class="titlefield">'.$langs->trans(
"RefOrder").
'</td>';
397 $order->fetch($expedition->origin_id);
398 print
'<td colspan="3">';
399 print $order->getNomUrl(1,
'commande');
403 if ($typeobject ==
'propal' && $expedition->origin_id &&
isModEnabled(
"propal")) {
404 $propal =
new Propal($db);
405 $propal->fetch($expedition->origin_id);
406 print
'<tr><td class="titlefield">'.$langs->trans(
"RefProposal").
'</td>';
407 print
'<td colspan="3">';
408 print $propal->getNomUrl(1,
'expedition');
414 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
415 print
'<td colspan="3">'.dol_print_date($object->date_creation,
'dayhour').
"</td>\n";
419 print
'<tr><td height="10">';
420 print
'<table class="nobordernopadding" width="100%"><tr><td>';
421 print $langs->trans(
'DateReceived');
424 if ($action !=
'editdate_delivery') {
425 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>';
427 print
'</tr></table>';
428 print
'</td><td colspan="2">';
429 if ($action ==
'editdate_delivery') {
430 print
'<form name="setdate_delivery" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
431 print
'<input type="hidden" name="token" value="'.newToken().
'">';
432 print
'<input type="hidden" name="action" value="setdate_delivery">';
433 print
$form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_delivery", 1, 1);
434 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
437 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
445 print
'<table class="centpercent nobordernopadding"><tr><td>';
446 print $langs->trans(
'IncotermLabel');
447 print
'<td><td class="right">';
448 if ($user->rights->expedition->delivery->creer) {
449 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/delivery/card.php?id='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
453 print
'</td></tr></table>';
455 print
'<td colspan="3">';
456 if ($action !=
'editincoterm') {
457 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
459 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 $entrepot->fetch($expedition->entrepot_id);
488 print
'<tr><td width="20%">'.$langs->trans(
"Warehouse").
'</td>';
489 print
'<td colspan="3"><a href="'.DOL_URL_ROOT.
'/product/stock/card.php?id='.$entrepot->id.
'">'.$entrepot->label.
'</a></td>';
494 if ($action ==
'create_delivery') {
496 $extrafields->fetch_name_optionals_label($expedition->table_element);
497 if ($expedition->fetch_optionals() > 0) {
498 $object->array_options = array_merge($object->array_options, $expedition->array_options);
502 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
504 print
"</table><br>\n";
512 $num_prod = count($object->lines);
515 print
'<table class="noborder centpercent">';
520 print
'<tr class="liste_titre">';
521 print
'<td>'.$langs->trans(
"Products").
'</td>';
522 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
523 print
'<td class="center">'.$langs->trans(
"QtyReceived").
'</td>';
526 while ($i < $num_prod) {
527 $parameters = array(
'i' => $i,
'line' => $object->lines[$i],
'num' => $num_prod);
528 $reshook = $hookmanager->executeHooks(
'printObjectLine',
$parameters, $object, $action);
533 if (empty($reshook)) {
534 print
'<tr class="oddeven">';
535 if ($object->lines[$i]->fk_product > 0) {
537 $product->fetch($object->lines[$i]->fk_product);
540 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
541 $outputlangs = $langs;
543 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
544 $newlang =
GETPOST(
'lang_id',
'aZ09');
546 if (empty($newlang)) {
547 $newlang = $object->thirdparty->default_lang;
549 if (!empty($newlang)) {
551 $outputlangs->setDefaultLang($newlang);
554 $label = (!empty($product->multilangs[$outputlangs->defaultlang][
"label"])) ? $product->multilangs[$outputlangs->defaultlang][
"label"] : $object->lines[$i]->product_label;
556 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
562 $text =
'<a href="'.DOL_URL_ROOT.
'/product/card.php?id='.$object->lines[$i]->fk_product.
'">';
563 if ($object->lines[$i]->fk_product_type == 1) {
564 $text .=
img_object($langs->trans(
'ShowService'),
'service');
566 $text .=
img_object($langs->trans(
'ShowProduct'),
'product');
568 $text .=
' '.$object->lines[$i]->product_ref.
'</a>';
569 $text .=
' - '.$label;
572 print
$form->textwithtooltip($text, $description, 3,
'',
'', $i);
575 print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ?
'<br>'.dol_htmlentitiesbr($object->lines[$i]->description) :
'';
579 if ($object->lines[$i]->fk_product_type == 1) {
580 $text =
img_object($langs->trans(
'Service'),
'service');
582 $text =
img_object($langs->trans(
'Product'),
'product');
585 if (!empty($object->lines[$i]->label)) {
586 $text .=
' <strong>'.$object->lines[$i]->label.
'</strong>';
587 print
$form->textwithtooltip($text, $object->lines[$i]->description, 3,
'',
'', $i);
589 print $text.
' '.nl2br($object->lines[$i]->description);
596 print
'<td class="center">'.$object->lines[$i]->qty_asked.
'</td>';
597 print
'<td class="center">'.$object->lines[$i]->qty_shipped.
'</td>';
604 $mode = ($object->statut == 0) ?
'edit' :
'view';
606 $object->lines[$i]->fetch_optionals();
608 if ($action ==
'create_delivery') {
611 $extrafields->fetch_name_optionals_label($srcLine->table_element);
612 $srcLine->id = $expedition->lines[$i]->id;
613 $srcLine->fetch_optionals();
615 $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options);
618 $extrafields->fetch_name_optionals_label($srcLine->table_element);
620 print $object->lines[$i]->showOptionals($extrafields, $mode, array(
'style' =>
'class="oddeven"',
'colspan' => $colspan),
'');
641 if ($user->socid == 0) {
642 print
'<div class="tabsAction">';
644 if ($object->statut == 0 && $num_prod > 0) {
645 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
646 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) {
647 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=valid&token='.
newToken().
'&id='.$object->id,
'');
651 if ($user->rights->expedition->delivery->supprimer) {
653 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),
'');
655 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
663 print
'<div class="fichecenter"><div class="fichehalfleft">';
670 $filedir = $conf->expedition->dir_output.
"/receipt/".$objectref;
671 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
673 $genallowed = $user->rights->expedition->delivery->lire;
674 $delallowed = $user->rights->expedition->delivery->creer;
676 print $formfile->showdocuments(
'delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
681 if ($object->origin ==
'expedition') {
683 $shipment->fetch($object->origin_id);
687 $somethingshown =
$form->showLinkedObjectBlock($object,
'');
691 print
'</div><div class="fichehalfright">';
695 print
'</div></div>';
698 print
"Expedition inexistante ou acces refuse";
702 print
"Expedition inexistante ou acces refuse";
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.
Classe 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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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...
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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.