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');
107 if (!$conf->expedition_bon->enabled &&
isModEnabled(
'stock')) {
108 $expedition->entrepot_id =
GETPOST(
'entrepot_id',
'int');
113 $commande->fetch($object->commande_id);
114 $commande->fetch_lines();
115 $num = count($commande->lines);
116 for ($i = 0; $i < $num; $i++) {
125 $ret = $object->create($user);
128 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
136 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
137 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
138 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate)))
140 $result = $object->valid($user);
143 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
144 $outputlangs = $langs;
147 $newlang =
GETPOST(
'lang_id',
'aZ09');
150 $newlang = $object->thirdparty->default_lang;
152 if (!empty($newlang)) {
154 $outputlangs->setDefaultLang($newlang);
156 $model = $object->model_pdf;
157 $ret = $object->fetch($id);
159 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
166 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->expedition->delivery->supprimer) {
168 $result = $object->delete();
172 if (!empty($backtopage)) {
173 header(
"Location: ".$backtopage);
175 header(
"Location: ".DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1');
183 if ($action ==
'setdate_delivery' && $user->rights->expedition->delivery->creer) {
184 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
185 $result = $object->setDeliveryDate($user, $datedelivery);
187 $mesg =
'<div class="error">'.$object->error.
'</div>';
189 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm')) {
191 $result = $object->setIncoterms((
int)
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
195 if ($action ==
'update_extras') {
199 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
206 $result = $object->insertExtraFields(
'DELIVERY_MODIFY');
214 $action =
'edit_extras';
219 if ($action ==
'update_extras_line') {
220 $array_options = array();
221 $num = count($object->lines);
223 for ($i = 0; $i < $num; $i++) {
225 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
226 $array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, $i);
228 if (is_array($extralabelsline)) {
230 foreach ($extralabelsline as $key => $value) {
231 unset($_POST[
"options_".$key]);
235 $ret = $object->update_line($object->lines[$i]->id, $array_options[$i]);
237 $mesg =
'<div class="error">'.$object->error.
'</div>';
245 $upload_dir = $conf->expedition->dir_output.
'/receipt';
246 $permissiontoadd = $user->rights->expedition->creer;
247 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
249 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
256 $title = $langs->trans(
'Delivery');
263 if ($action ==
'create') {
267 if ($object->id > 0) {
271 $result = $expedition->fetch($object->origin_id);
272 $typeobject = $expedition->origin;
273 if ($object->origin_id > 0) {
274 $object->fetch_origin();
277 if ($object->id > 0) {
279 $soc->fetch($object->socid);
283 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
285 print
'<input type="hidden" name="action" value="update_extras_line">';
286 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
287 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
288 print
'<input type="hidden" name="ref" value="'.$object->ref.
'">';
296 if ($action ==
'delete') {
297 $expedition_id =
GETPOST(
"expid");
298 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);
304 if ($action ==
'valid') {
305 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"ValidateDeliveryReceipt"), $langs->trans(
"ValidateDeliveryReceiptConfirm", $object->ref),
'confirm_valid',
'',
'', 1);
313 if ($typeobject ==
'commande' && $expedition->origin_id > 0 &&
isModEnabled(
'commande')) {
315 $objectsrc->fetch($expedition->origin_id);
317 if ($typeobject ==
'propal' && $expedition->origin_id > 0 &&
isModEnabled(
"propal")) {
318 $objectsrc =
new Propal($db);
319 $objectsrc->fetch($expedition->origin_id);
323 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
325 $morehtmlref =
'<div class="refidno">';
327 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'', $expedition->ref_customer, $expedition, $user->rights->expedition->creer,
'string',
'', 0, 1);
328 $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);
329 $morehtmlref .=
'<br>'.$langs->trans(
"RefDeliveryReceipt").
' : '.$object->ref;
331 $morehtmlref .=
'<br>'.$expedition->thirdparty->getNomUrl(1);
334 $langs->load(
"projects");
335 $morehtmlref .=
'<br>';
337 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
338 if ($action !=
'classify') {
339 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
341 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
343 if (!empty($objectsrc->fk_project)) {
345 $proj->fetch($objectsrc->fk_project);
346 $morehtmlref .= $proj->getNomUrl(1);
348 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
353 $morehtmlref .=
'</div>';
355 $morehtmlstatus = $langs->trans(
"StatusReceipt").
' : '.$object->getLibStatut(6).
'<br><br class="small">';
357 dol_banner_tab($expedition,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'', $morehtmlstatus);
360 print
'<div class="fichecenter">';
361 print
'<div class="underbanner clearboth"></div>';
363 print
'<table class="border tableforfield" width="100%">';
393 if ($typeobject ==
'commande' && $expedition->origin_id &&
isModEnabled(
'commande')) {
394 print
'<tr><td class="titlefield">'.$langs->trans(
"RefOrder").
'</td>';
396 $order->fetch($expedition->origin_id);
397 print
'<td colspan="3">';
398 print $order->getNomUrl(1,
'commande');
402 if ($typeobject ==
'propal' && $expedition->origin_id &&
isModEnabled(
"propal")) {
403 $propal =
new Propal($db);
404 $propal->fetch($expedition->origin_id);
405 print
'<tr><td class="titlefield">'.$langs->trans(
"RefProposal").
'</td>';
406 print
'<td colspan="3">';
407 print $propal->getNomUrl(1,
'expedition');
413 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
414 print
'<td colspan="3">'.dol_print_date($object->date_creation,
'dayhour').
"</td>\n";
418 print
'<tr><td height="10">';
419 print
'<table class="nobordernopadding" width="100%"><tr><td>';
420 print $langs->trans(
'DateReceived');
423 if ($action !=
'editdate_delivery') {
424 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>';
426 print
'</tr></table>';
427 print
'</td><td colspan="2">';
428 if ($action ==
'editdate_delivery') {
429 print
'<form name="setdate_delivery" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
430 print
'<input type="hidden" name="token" value="'.newToken().
'">';
431 print
'<input type="hidden" name="action" value="setdate_delivery">';
432 print
$form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_delivery", 1, 1);
433 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
436 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
444 print
'<table width="100%" class="nobordernopadding"><tr><td>';
445 print $langs->trans(
'IncotermLabel');
446 print
'<td><td class="right">';
447 if ($user->rights->expedition->delivery->creer) {
448 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/delivery/card.php?id='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
452 print
'</td></tr></table>';
454 print
'<td colspan="3">';
455 if ($action !=
'editincoterm') {
456 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
458 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
482 if (!$conf->expedition_bon->enabled &&
isModEnabled(
'stock')) {
485 $entrepot->fetch($object->entrepot_id);
486 print
'<tr><td width="20%">'.$langs->trans(
"Warehouse").
'</td>';
487 print
'<td colspan="3"><a href="'.DOL_URL_ROOT.
'/product/stock/card.php?id='.$entrepot->id.
'">'.$entrepot->label.
'</a></td>';
492 if ($action ==
'create_delivery') {
494 $extrafields->fetch_name_optionals_label($expedition->table_element);
495 if ($expedition->fetch_optionals() > 0) {
496 $object->array_options = array_merge($object->array_options, $expedition->array_options);
500 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
502 print
"</table><br>\n";
510 $num_prod = count($object->lines);
513 print
'<table class="noborder centpercent">';
518 print
'<tr class="liste_titre">';
519 print
'<td>'.$langs->trans(
"Products").
'</td>';
520 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
521 print
'<td class="center">'.$langs->trans(
"QtyReceived").
'</td>';
524 while ($i < $num_prod) {
525 $parameters = array(
'i' => $i,
'line' => $object->lines[$i],
'num' => $num_prod);
526 $reshook = $hookmanager->executeHooks(
'printObjectLine',
$parameters, $object, $action);
531 if (empty($reshook)) {
532 print
'<tr class="oddeven">';
533 if ($object->lines[$i]->fk_product > 0) {
535 $product->fetch($object->lines[$i]->fk_product);
538 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
539 $outputlangs = $langs;
541 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
542 $newlang =
GETPOST(
'lang_id',
'aZ09');
544 if (empty($newlang)) {
545 $newlang = $object->thirdparty->default_lang;
547 if (!empty($newlang)) {
549 $outputlangs->setDefaultLang($newlang);
552 $label = (!empty($product->multilangs[$outputlangs->defaultlang][
"label"])) ? $product->multilangs[$outputlangs->defaultlang][
"label"] : $object->lines[$i]->product_label;
554 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
560 $text =
'<a href="'.DOL_URL_ROOT.
'/product/card.php?id='.$object->lines[$i]->fk_product.
'">';
561 if ($object->lines[$i]->fk_product_type == 1) {
562 $text .=
img_object($langs->trans(
'ShowService'),
'service');
564 $text .=
img_object($langs->trans(
'ShowProduct'),
'product');
566 $text .=
' '.$object->lines[$i]->product_ref.
'</a>';
567 $text .=
' - '.$label;
570 print
$form->textwithtooltip($text, $description, 3,
'',
'', $i);
571 print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
573 print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ?
'<br>'.dol_htmlentitiesbr($object->lines[$i]->description) :
'';
577 if ($object->lines[$i]->fk_product_type == 1) {
578 $text =
img_object($langs->trans(
'Service'),
'service');
580 $text =
img_object($langs->trans(
'Product'),
'product');
583 if (!empty($object->lines[$i]->label)) {
584 $text .=
' <strong>'.$object->lines[$i]->label.
'</strong>';
585 print
$form->textwithtooltip($text, $object->lines[$i]->description, 3,
'',
'', $i);
587 print $text.
' '.nl2br($object->lines[$i]->description);
594 print
'<td class="center">'.$object->lines[$i]->qty_asked.
'</td>';
595 print
'<td class="center">'.$object->lines[$i]->qty_shipped.
'</td>';
602 $mode = ($object->statut == 0) ?
'edit' :
'view';
604 $object->lines[$i]->fetch_optionals();
606 if ($action ==
'create_delivery') {
609 $extrafields->fetch_name_optionals_label($srcLine->table_element);
610 $srcLine->id = $expedition->lines[$i]->id;
611 $srcLine->fetch_optionals();
613 $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options);
616 $extrafields->fetch_name_optionals_label($srcLine->table_element);
618 print $object->lines[$i]->showOptionals($extrafields, $mode, array(
'style' =>
'class="oddeven"',
'colspan' => $colspan),
'');
639 if ($user->socid == 0) {
640 print
'<div class="tabsAction">';
642 if ($object->statut == 0 && $num_prod > 0) {
643 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer))
644 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) {
645 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=valid&token='.
newToken().
'&id='.$object->id,
'');
649 if ($user->rights->expedition->delivery->supprimer) {
650 if ($conf->expedition_bon->enabled) {
651 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),
'');
653 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
661 print
'<div class="fichecenter"><div class="fichehalfleft">';
668 $filedir = $conf->expedition->dir_output.
"/receipt/".$objectref;
669 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
671 $genallowed = $user->rights->expedition->delivery->lire;
672 $delallowed = $user->rights->expedition->delivery->creer;
674 print $formfile->showdocuments(
'delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
679 if ($object->origin ==
'expedition') {
681 $shipment->fetch($object->origin_id);
685 $somethingshown =
$form->showLinkedObjectBlock($object,
'');
689 print
'</div><div class="fichehalfright">';
693 print
'</div></div>';
696 print
"Expedition inexistante ou acces refuse";
700 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='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
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.