2006-05-29 15:53:20 +02:00
< ? php
2012-08-25 15:21:34 +02:00
/* Copyright ( C ) 2003 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2014 Regis Houssin < regis . houssin @ inodbox . com >
2012-08-25 15:21:34 +02:00
* Copyright ( C ) 2007 Franky Van Liedekerke < franky . van . liedekerke @ telenet . be >
2013-04-09 17:18:07 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2018-07-18 16:13:13 +02:00
* Copyright ( C ) 2015 Claudio Aschieri < c . aschieri @ 19. coop >
2006-05-29 15:53:20 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2006-05-29 15:53:20 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2006-05-29 15:53:20 +02:00
*/
/**
2020-10-05 15:32:29 +02:00
* \file htdocs / delivery / card . php
2008-10-17 16:43:33 +02:00
* \ingroup livraison
2020-01-28 02:21:39 +01:00
* \brief Page to describe a delivery receipt
2008-08-05 10:41:54 +02:00
*/
2006-05-29 15:53:20 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2020-10-05 13:59:06 +02:00
require_once DOL_DOCUMENT_ROOT . '/delivery/class/delivery.class.php' ;
2020-10-06 13:32:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/delivery/modules_delivery.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/sendings.lib.php' ;
2016-10-29 16:18:39 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2021-02-25 22:15:04 +01:00
if ( ! empty ( $conf -> product -> enabled ) || ! empty ( $conf -> service -> enabled )) {
2012-08-25 15:21:34 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
2021-02-25 22:15:04 +01:00
}
if ( ! empty ( $conf -> expedition_bon -> enabled )) {
2012-08-25 15:21:34 +02:00
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php' ;
2021-02-25 22:15:04 +01:00
}
if ( ! empty ( $conf -> stock -> enabled )) {
2012-08-25 15:21:34 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
2021-02-25 22:15:04 +01:00
}
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2020-10-28 17:49:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2016-10-30 10:13:55 +01:00
}
2017-10-03 16:00:52 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2020-04-10 10:59:32 +02:00
$langs -> loadLangs ( array ( " sendings " , " bills " , 'deliveries' , 'orders' ));
2009-04-27 22:37:50 +02:00
2021-02-25 22:15:04 +01:00
if ( ! empty ( $conf -> incoterm -> enabled )) {
$langs -> load ( 'incoterm' );
}
2006-05-29 15:53:20 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2012-08-05 20:34:51 +02:00
2008-10-17 16:43:33 +02:00
// Security check
2012-08-25 15:21:34 +02:00
$id = GETPOST ( 'id' , 'int' );
2021-02-25 22:15:04 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
2020-10-25 17:19:15 +01:00
$result = restrictedArea ( $user , 'expedition' , $id , 'delivery' , 'delivery' );
2006-05-29 15:53:20 +02:00
2020-10-05 13:59:06 +02:00
$object = new Delivery ( $db );
2015-12-16 16:18:29 +01:00
$extrafields = new ExtraFields ( $db );
2006-05-29 15:53:20 +02:00
2015-12-16 16:18:29 +01:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2015-12-16 16:18:29 +01:00
// fetch optionals attributes lines and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element_line );
2015-12-16 16:18:29 +01:00
// Load object. Make an object->fetch
2019-11-13 19:35:39 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once
2014-09-29 20:31:48 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-11-13 19:35:39 +01:00
$hookmanager -> initHooks ( array ( 'deliverycard' , 'globalcard' ));
2010-07-23 02:17:46 +02:00
2020-10-27 18:53:03 +01:00
$error = 0 ;
2018-05-10 14:15:52 +02:00
2006-05-29 15:53:20 +02:00
/*
* Actions
*/
2018-05-10 14:15:52 +02:00
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2022-03-18 22:01:56 +01:00
// Delete Link
$permissiondellink = $user -> rights -> expedition -> delivery -> supprimer ; // Used by the include of actions_dellink.inc.php
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php' ; // Must be include, not include_once
2006-05-29 15:53:20 +02:00
2021-02-25 22:15:04 +01:00
if ( $action == 'add' ) {
2008-08-05 10:41:54 +02:00
$db -> begin ();
2020-10-27 18:53:03 +01:00
$object -> date_delivery = dol_now ();
$object -> note = GETPOST ( " note " , 'restricthtml' );
$object -> note_private = GETPOST ( " note " , 'restricthtml' );
$object -> commande_id = GETPOST ( " commande_id " , 'int' );
2015-02-23 09:16:14 +01:00
$object -> fk_incoterms = GETPOST ( 'incoterm_id' , 'int' );
2015-05-19 00:01:30 +02:00
2020-10-27 18:53:03 +01:00
if ( ! $conf -> expedition_bon -> enabled && ! empty ( $conf -> stock -> enabled )) {
2022-01-24 16:38:25 +01:00
$expedition -> entrepot_id = GETPOST ( 'entrepot_id' , 'int' );
2008-08-05 10:41:54 +02:00
}
2020-10-27 18:53:03 +01:00
// We loop on each line of order to complete object delivery with qty to delivery
2008-08-05 10:41:54 +02:00
$commande = new Commande ( $db );
2014-09-29 20:31:48 +02:00
$commande -> fetch ( $object -> commande_id );
2008-08-05 10:41:54 +02:00
$commande -> fetch_lines ();
2019-11-13 19:35:39 +01:00
$num = count ( $commande -> lines );
2021-02-25 22:15:04 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2008-08-05 10:41:54 +02:00
$qty = " qtyl " . $i ;
$idl = " idl " . $i ;
2020-10-27 18:53:03 +01:00
$qtytouse = price2num ( GETPOST ( $qty ));
2021-02-25 22:15:04 +01:00
if ( $qtytouse > 0 ) {
2021-10-23 22:21:50 +02:00
$object -> addline ( GETPOST ( $idl ), price2num ( $qtytouse ), $arrayoptions );
2008-08-05 10:41:54 +02:00
}
}
2019-11-13 19:35:39 +01:00
$ret = $object -> create ( $user );
2020-10-27 18:53:03 +01:00
if ( $ret > 0 ) {
2008-08-05 10:41:54 +02:00
$db -> commit ();
2014-09-29 20:31:48 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
2008-08-05 10:41:54 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2015-12-11 09:54:30 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2008-08-05 10:41:54 +02:00
$db -> rollback ();
2012-08-25 15:21:34 +02:00
2019-11-13 19:35:39 +01:00
$action = 'create' ;
2008-08-05 10:41:54 +02:00
}
2020-05-21 15:05:19 +02:00
} elseif ( $action == 'confirm_valid' && $confirm == 'yes' &&
2020-10-28 17:49:52 +01:00
(( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! empty ( $user -> rights -> expedition -> delivery -> creer ))
|| ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! empty ( $user -> rights -> expedition -> delivery_advance -> validate )))
2021-02-25 22:15:04 +01:00
) {
2011-12-02 19:57:20 +01:00
$result = $object -> valid ( $user );
2010-02-27 14:37:13 +01:00
// Define output language
2021-02-25 22:15:04 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_PDF_AUTOUPDATE )) {
2014-10-27 19:37:30 +01:00
$outputlangs = $langs ;
$newlang = '' ;
2021-02-25 22:15:04 +01:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && GETPOST ( 'lang_id' , 'aZ09' )) {
$newlang = GETPOST ( 'lang_id' , 'aZ09' );
}
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) {
$newlang = $object -> thirdparty -> default_lang ;
}
2019-11-13 19:35:39 +01:00
if ( ! empty ( $newlang )) {
2014-10-27 19:37:30 +01:00
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( $newlang );
}
2020-09-10 01:49:09 +02:00
$model = $object -> model_pdf ;
2014-10-27 19:37:30 +01:00
$ret = $object -> fetch ( $id ); // Reload to get new records
2014-12-25 23:08:07 +01:00
2019-11-13 19:35:39 +01:00
$result = $object -> generateDocument ( $model , $outputlangs , $hidedetails , $hidedesc , $hideref );
2021-02-25 22:15:04 +01:00
if ( $result < 0 ) {
dol_print_error ( $db , $result );
}
2010-02-27 14:37:13 +01:00
}
2006-05-29 15:53:20 +02:00
}
2021-02-25 22:15:04 +01:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $user -> rights -> expedition -> delivery -> supprimer ) {
2009-07-15 22:10:28 +02:00
$db -> begin ();
2019-11-13 19:35:39 +01:00
$result = $object -> delete ();
2009-07-15 22:10:28 +02:00
2021-02-25 22:15:04 +01:00
if ( $result > 0 ) {
2009-07-15 22:10:28 +02:00
$db -> commit ();
2021-02-25 22:15:04 +01:00
if ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
} else {
header ( " Location: " . DOL_URL_ROOT . '/expedition/list.php?restore_lastsearch_values=1' );
}
2010-08-29 00:54:23 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2009-07-15 22:10:28 +02:00
$db -> rollback ();
}
2006-05-29 15:53:20 +02:00
}
2021-02-25 22:15:04 +01:00
if ( $action == 'setdate_delivery' && $user -> rights -> expedition -> delivery -> creer ) {
2020-10-31 14:32:18 +01:00
$datedelivery = dol_mktime ( GETPOST ( 'liv_hour' , 'int' ), GETPOST ( 'liv_min' , 'int' ), 0 , GETPOST ( 'liv_month' , 'int' ), GETPOST ( 'liv_day' , 'int' ), GETPOST ( 'liv_year' , 'int' ));
$result = $object -> setDeliveryDate ( $user , $datedelivery );
2021-02-25 22:15:04 +01:00
if ( $result < 0 ) {
2020-10-31 14:32:18 +01:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
}
2021-02-25 22:15:04 +01:00
} elseif ( $action == 'set_incoterms' && ! empty ( $conf -> incoterm -> enabled )) {
// Set incoterm
2020-10-27 18:53:03 +01:00
$result = $object -> setIncoterms (( int ) GETPOST ( 'incoterm_id' , 'int' ), GETPOST ( 'location_incoterms' , 'alpha' ));
2015-02-23 09:16:14 +01:00
}
2015-12-16 16:18:29 +01:00
// Update extrafields
2021-02-25 22:15:04 +01:00
if ( $action == 'update_extras' ) {
2018-02-23 16:11:00 +01:00
$object -> oldcopy = dol_clone ( $object );
2015-12-16 16:18:29 +01:00
// Fill array 'array_options' with data from update form
2020-09-18 01:29:17 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , GETPOST ( 'attribute' , 'restricthtml' ));
2021-02-25 22:15:04 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2015-12-16 16:18:29 +01:00
2021-02-25 22:15:04 +01:00
if ( ! $error ) {
2018-04-10 12:03:01 +02:00
// Actions on extra fields
$result = $object -> insertExtraFields ( 'DELIVERY_MODIFY' );
2021-02-25 22:15:04 +01:00
if ( $result < 0 ) {
2018-04-10 12:03:01 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-12-16 16:18:29 +01:00
$error ++ ;
2018-04-10 12:03:01 +02:00
}
2015-12-16 16:18:29 +01:00
}
2021-02-25 22:15:04 +01:00
if ( $error ) {
2015-12-16 16:18:29 +01:00
$action = 'edit_extras' ;
2021-02-25 22:15:04 +01:00
}
2015-12-16 16:18:29 +01:00
}
// Extrafields line
2021-02-25 22:15:04 +01:00
if ( $action == 'update_extras_line' ) {
2019-11-13 19:35:39 +01:00
$array_options = array ();
$num = count ( $object -> lines );
2017-10-03 16:00:52 +02:00
2021-02-25 22:15:04 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2015-12-16 16:18:29 +01:00
// Extrafields
2019-10-06 14:41:52 +02:00
$extralabelsline = $extrafields -> fetch_name_optionals_label ( $object -> table_element_line );
$array_options [ $i ] = $extrafields -> getOptionalsFromPost ( $extralabelsline , $i );
2015-12-16 16:18:29 +01:00
// Unset extrafield
if ( is_array ( $extralabelsline )) {
// Get extra fields
foreach ( $extralabelsline as $key => $value ) {
2019-11-13 19:35:39 +01:00
unset ( $_POST [ " options_ " . $key ]);
2015-12-16 16:18:29 +01:00
}
}
2017-10-03 16:00:52 +02:00
2019-11-13 19:35:39 +01:00
$ret = $object -> update_line ( $object -> lines [ $i ] -> id , $array_options [ $i ]); // extrafields update
2021-02-25 22:15:04 +01:00
if ( $ret < 0 ) {
2019-11-13 19:35:39 +01:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
2015-12-16 16:18:29 +01:00
$error ++ ;
}
}
}
2018-05-10 14:15:52 +02:00
// Actions to build doc
$upload_dir = $conf -> expedition -> dir_output . '/receipt' ;
2019-11-05 19:41:30 +01:00
$permissiontoadd = $user -> rights -> expedition -> creer ;
2018-05-10 14:15:52 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2018-10-23 22:10:30 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php' ;
2006-05-29 15:53:20 +02:00
2020-01-28 02:21:39 +01:00
2006-05-29 15:53:20 +02:00
/*
2008-08-05 10:41:54 +02:00
* View
2006-05-29 15:53:20 +02:00
*/
2021-06-14 14:11:21 +02:00
$title = $langs -> trans ( 'Delivery' );
llxHeader ( '' , $title , 'Livraison' );
2007-11-16 23:01:14 +01:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2006-05-29 15:53:20 +02:00
2022-09-06 01:42:48 +02:00
if ( $action == 'create' ) {
// Create. Seems to no be used
} else {
// View
2021-02-25 22:15:04 +01:00
if ( $object -> id > 0 ) {
2016-10-30 10:13:55 +01:00
// Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment).
2014-05-06 13:15:37 +02:00
// However, origin of shipment in future may differs (commande, proposal, ...)
2019-11-13 19:35:39 +01:00
$expedition = new Expedition ( $db );
2014-09-29 20:31:48 +02:00
$result = $expedition -> fetch ( $object -> origin_id );
2019-11-13 19:35:39 +01:00
$typeobject = $expedition -> origin ; // example: commande
2021-02-25 22:15:04 +01:00
if ( $object -> origin_id > 0 ) {
2014-09-29 20:31:48 +02:00
$object -> fetch_origin ();
2008-08-05 10:41:54 +02:00
}
2021-02-25 22:15:04 +01:00
if ( $object -> id > 0 ) {
2008-08-05 10:41:54 +02:00
$soc = new Societe ( $db );
2014-09-29 20:31:48 +02:00
$soc -> fetch ( $object -> socid );
2008-10-17 16:43:33 +02:00
2019-11-13 19:35:39 +01:00
$head = delivery_prepare_head ( $object );
2008-08-05 10:41:54 +02:00
2016-01-13 20:41:32 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-01-13 20:41:32 +01:00
print '<input type="hidden" name="action" value="update_extras_line">' ;
print '<input type="hidden" name="origin" value="' . $origin . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="ref" value="' . $object -> ref . '">' ;
2017-10-03 16:00:52 +02:00
2022-01-24 16:38:25 +01:00
print dol_get_fiche_head ( $head , 'delivery' , $langs -> trans ( " Shipment " ), - 1 , 'dolly' );
2017-10-03 16:00:52 +02:00
2008-08-05 10:41:54 +02:00
/*
* Confirmation de la suppression
*
*/
2021-02-25 22:15:04 +01:00
if ( $action == 'delete' ) {
2014-05-06 13:15:37 +02:00
$expedition_id = GETPOST ( " expid " );
2019-01-27 11:55:16 +01:00
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 );
2008-08-05 10:41:54 +02:00
}
/*
* Confirmation de la validation
*/
2021-02-25 22:15:04 +01:00
if ( $action == 'valid' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $langs -> trans ( " ValidateDeliveryReceipt " ), $langs -> trans ( " ValidateDeliveryReceiptConfirm " , $object -> ref ), 'confirm_valid' , '' , '' , 1 );
2008-08-05 10:41:54 +02:00
}
/*
2020-10-05 13:59:06 +02:00
* Delivery
2008-08-05 10:41:54 +02:00
*/
2017-10-03 16:00:52 +02:00
2021-02-25 22:15:04 +01:00
if ( $typeobject == 'commande' && $expedition -> origin_id > 0 && ! empty ( $conf -> commande -> enabled )) {
2020-10-28 17:49:52 +01:00
$objectsrc = new Commande ( $db );
$objectsrc -> fetch ( $expedition -> origin_id );
2016-10-29 16:18:39 +02:00
}
2021-02-25 22:15:04 +01:00
if ( $typeobject == 'propal' && $expedition -> origin_id > 0 && ! empty ( $conf -> propal -> enabled )) {
2020-10-28 17:49:52 +01:00
$objectsrc = new Propal ( $db );
$objectsrc -> fetch ( $expedition -> origin_id );
2016-10-29 16:18:39 +02:00
}
2016-10-30 10:13:55 +01:00
2016-10-29 16:18:39 +02:00
// Shipment card
2019-11-13 19:35:39 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/expedition/list.php?restore_lastsearch_values=1' . ( ! empty ( $socid ) ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-10-03 16:00:52 +02:00
2019-11-13 19:35:39 +01:00
$morehtmlref = '<div class="refidno">' ;
2016-10-29 16:18:39 +02:00
// Ref customer shipment
2019-11-13 19:35:39 +01:00
$morehtmlref .= $form -> editfieldkey ( " RefCustomer " , '' , $expedition -> ref_customer , $expedition , $user -> rights -> expedition -> creer , 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " RefCustomer " , '' , $expedition -> ref_customer , $expedition , $user -> rights -> expedition -> creer , 'string' , '' , null , null , '' , 1 );
$morehtmlref .= '<br>' . $langs -> trans ( " RefDeliveryReceipt " ) . ' : ' . $object -> ref ;
2016-10-29 16:18:39 +02:00
// Thirdparty
2019-11-13 19:35:39 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $expedition -> thirdparty -> getNomUrl ( 1 );
2016-10-29 16:18:39 +02:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2020-10-28 17:49:52 +01:00
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
if ( 0 ) { // Do not change on shipment
if ( $action != 'classify' ) {
2021-09-18 22:09:55 +02:00
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&token=' . newToken () . '&id=' . $expedition -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'SetProject' )) . '</a> : ' ;
2020-10-28 17:49:52 +01:00
}
if ( $action == 'classify' ) {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $expedition -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects ( $expedition -> socid , $expedition -> fk_project , 'projectid' , $maxlength , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 );
2021-08-24 17:04:17 +02:00
$morehtmlref .= '<input type="submit" class="button button-edit" value="' . $langs -> trans ( " Modify " ) . '">' ;
2020-10-28 17:49:52 +01:00
$morehtmlref .= '</form>' ;
} else {
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $expedition -> id , $expedition -> socid , $expedition -> fk_project , 'none' , 0 , 0 , 0 , 1 );
}
} else {
$morehtmlref .= ' : ' ;
if ( ! empty ( $objectsrc -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $objectsrc -> fk_project );
2021-10-29 09:40:38 +02:00
$morehtmlref .= ' : ' . $proj -> getNomUrl ( 1 );
if ( $proj -> title ) {
$morehtmlref .= ' - ' . $proj -> title ;
}
2020-10-28 17:49:52 +01:00
} else {
$morehtmlref .= '' ;
}
}
2016-10-29 16:18:39 +02:00
}
2019-11-13 19:35:39 +01:00
$morehtmlref .= '</div>' ;
2017-10-03 16:00:52 +02:00
2022-10-07 21:36:30 +02:00
$morehtmlstatus = $langs -> trans ( " StatusReceipt " ) . ' : ' . $object -> getLibStatut ( 6 ) . '<br><br class="small">' ;
2017-10-03 16:00:52 +02:00
2022-10-07 21:36:30 +02:00
dol_banner_tab ( $expedition , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref , '' , 0 , '' , $morehtmlstatus );
2017-10-03 16:00:52 +02:00
2016-10-29 16:18:39 +02:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-10-03 16:00:52 +02:00
2020-10-28 17:49:52 +01:00
print '<table class="border tableforfield" width="100%">' ;
2017-10-03 16:00:52 +02:00
2014-05-06 13:15:37 +02:00
// Shipment
2016-10-29 16:18:39 +02:00
/*
2014-09-29 20:31:48 +02:00
if (( $object -> origin == 'shipment' || $object -> origin == 'expedition' ) && $object -> origin_id > 0 )
2014-05-06 13:15:37 +02:00
{
2019-12-05 15:22:06 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/expedition/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2014-09-04 18:58:33 +02:00
2014-05-07 10:42:13 +02:00
// Ref
print '<tr><td width="20%">' . $langs -> trans ( " RefSending " ) . '</td>' ;
print '<td colspan="3">' ;
2014-05-06 13:15:37 +02:00
// Nav is hidden because on a delivery receipt of a shipment, if we go on next shipment, we may find no tab (a shipment may not have delivery receipt yet)
2016-03-25 15:53:44 +01:00
//print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref');
print $form -> showrefnav ( $expedition , 'refshipment' , $linkback , 0 , 'ref' , 'ref' );
2014-05-07 10:42:13 +02:00
print '</td></tr>' ;
2014-09-04 18:58:33 +02:00
}
2008-08-05 10:41:54 +02:00
// Ref
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td>' ;
2021-02-25 22:15:04 +01:00
print '<td colspan="3">' ;
print $object -> ref ;
print '</td></tr>' ;
2008-08-05 10:41:54 +02:00
// Client
print '<tr><td width="20%">' . $langs -> trans ( " Customer " ) . '</td>' ;
2019-03-03 09:10:26 +01:00
print '<td colspan="3">' . $soc -> getNomUrl ( 1 ) . '</td>' ;
2008-08-05 10:41:54 +02:00
print " </tr> " ;
2021-02-25 22:15:04 +01:00
*/
2017-10-03 16:00:52 +02:00
2008-08-05 10:41:54 +02:00
// Document origine
2021-02-25 22:15:04 +01:00
if ( $typeobject == 'commande' && $expedition -> origin_id && ! empty ( $conf -> commande -> enabled )) {
2016-10-29 16:18:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " RefOrder " ) . '</td>' ;
2019-11-13 19:35:39 +01:00
$order = new Commande ( $db );
2008-10-17 16:43:33 +02:00
$order -> fetch ( $expedition -> origin_id );
2008-08-05 10:41:54 +02:00
print '<td colspan="3">' ;
2019-01-27 11:55:16 +01:00
print $order -> getNomUrl ( 1 , 'commande' );
2008-08-05 10:41:54 +02:00
print " </td> \n " ;
print '</tr>' ;
}
2021-02-25 22:15:04 +01:00
if ( $typeobject == 'propal' && $expedition -> origin_id && ! empty ( $conf -> propal -> enabled )) {
2019-11-13 19:35:39 +01:00
$propal = new Propal ( $db );
2009-07-30 09:24:18 +02:00
$propal -> fetch ( $expedition -> origin_id );
2016-10-29 16:18:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " RefProposal " ) . '</td>' ;
2008-08-05 10:41:54 +02:00
print '<td colspan="3">' ;
2019-01-27 11:55:16 +01:00
print $propal -> getNomUrl ( 1 , 'expedition' );
2008-08-05 10:41:54 +02:00
print " </td> \n " ;
print '</tr>' ;
}
// Date
2016-10-29 16:18:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " DateCreation " ) . '</td>' ;
2019-01-27 11:55:16 +01:00
print '<td colspan="3">' . dol_print_date ( $object -> date_creation , 'dayhour' ) . " </td> \n " ;
2010-03-13 17:23:43 +01:00
print '</tr>' ;
2010-03-27 01:33:28 +01:00
2010-05-13 01:03:33 +02:00
// Date delivery real / Received
2013-08-07 15:08:30 +02:00
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DateReceived' );
print '</td>' ;
2021-02-25 22:15:04 +01:00
if ( $action != 'editdate_delivery' ) {
2021-09-27 12:24:01 +02:00
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>' ;
2021-02-25 22:15:04 +01:00
}
2013-08-07 15:08:30 +02:00
print '</tr></table>' ;
print '</td><td colspan="2">' ;
2021-02-25 22:15:04 +01:00
if ( $action == 'editdate_delivery' ) {
2020-10-27 18:53:03 +01:00
print '<form name="setdate_delivery" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2020-10-27 18:53:03 +01:00
print '<input type="hidden" name="action" value="setdate_delivery">' ;
print $form -> selectDate ( $object -> date_delivery ? $object -> date_delivery : - 1 , 'liv_' , 1 , 1 , '' , " setdate_delivery " , 1 , 1 );
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button button-edit" value="' . $langs -> trans ( 'Modify' ) . '">' ;
2013-08-07 15:08:30 +02:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print $object -> date_delivery ? dol_print_date ( $object -> date_delivery , 'dayhour' ) : ' ' ;
2013-08-07 15:08:30 +02:00
}
print '</td>' ;
2008-08-05 10:41:54 +02:00
print '</tr>' ;
2013-08-07 15:08:30 +02:00
2015-02-23 09:16:14 +01:00
// Incoterms
2021-02-25 22:15:04 +01:00
if ( ! empty ( $conf -> incoterm -> enabled )) {
2015-02-23 09:16:14 +01:00
print '<tr><td>' ;
2020-10-28 17:49:52 +01:00
print '<table width="100%" class="nobordernopadding"><tr><td>' ;
print $langs -> trans ( 'IncotermLabel' );
print '<td><td class="right">' ;
2021-02-25 22:15:04 +01:00
if ( $user -> rights -> expedition -> delivery -> creer ) {
2021-09-27 12:24:01 +02:00
print '<a class="editfielda" href="' . DOL_URL_ROOT . '/delivery/card.php?id=' . $object -> id . '&action=editincoterm&token=' . newToken () . '">' . img_edit () . '</a>' ;
2021-02-25 22:15:04 +01:00
} else {
print ' ' ;
}
2020-10-28 17:49:52 +01:00
print '</td></tr></table>' ;
print '</td>' ;
print '<td colspan="3">' ;
2021-02-25 22:15:04 +01:00
if ( $action != 'editincoterm' ) {
2019-06-25 13:00:02 +02:00
print $form -> textwithpicto ( $object -> display_incoterms (), $object -> label_incoterms , 1 );
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
print $form -> select_incoterms (( ! empty ( $object -> fk_incoterms ) ? $object -> fk_incoterms : '' ), ( ! empty ( $object -> location_incoterms ) ? $object -> location_incoterms : '' ), $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id );
2015-02-23 09:16:14 +01:00
}
2020-10-28 17:49:52 +01:00
print '</td></tr>' ;
2015-02-23 09:16:14 +01:00
}
2017-10-03 16:00:52 +02:00
/* A delivery note should be just more properties of a shipment , so notes are on shipment
2013-08-07 15:08:30 +02:00
// Note Public
2021-02-25 22:15:04 +01:00
print '<tr><td>' . $langs -> trans ( " NotePublic " ) . '</td>' ;
print '<td colspan="3">' ;
print nl2br ( $object -> note_public );
print " </td></tr> " ;
2013-08-07 15:08:30 +02:00
2013-04-09 17:18:07 +02:00
// Note Private
2021-02-25 22:15:04 +01:00
print '<tr><td>' . $langs -> trans ( " NotePrivate " ) . '</td>' ;
print '<td colspan="3">' ;
print nl2br ( $object -> note_private );
print " </td></tr> " ;
*/
2008-08-05 10:41:54 +02:00
// Statut
2016-10-29 16:18:39 +02:00
/* print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
2014-09-29 20:31:48 +02:00
print '<td colspan="3">' . $object -> getLibStatut ( 4 ) . " </td> \n " ;
2016-10-29 16:18:39 +02:00
print '</tr>' ; */
2008-08-05 10:41:54 +02:00
2021-02-25 22:15:04 +01:00
if ( ! $conf -> expedition_bon -> enabled && ! empty ( $conf -> stock -> enabled )) {
2008-08-05 10:41:54 +02:00
// Entrepot
$entrepot = new Entrepot ( $db );
2014-09-29 20:31:48 +02:00
$entrepot -> fetch ( $object -> entrepot_id );
2008-08-05 10:41:54 +02:00
print '<tr><td width="20%">' . $langs -> trans ( " Warehouse " ) . '</td>' ;
2019-11-02 12:59:38 +01:00
print '<td colspan="3"><a href="' . DOL_URL_ROOT . '/product/stock/card.php?id=' . $entrepot -> id . '">' . $entrepot -> label . '</a></td>' ;
2008-08-05 10:41:54 +02:00
print '</tr>' ;
}
2017-10-03 16:00:52 +02:00
2015-12-16 16:18:29 +01:00
// Other attributes
2019-08-05 13:10:26 +02:00
if ( $action == 'create_delivery' ) {
2017-09-19 18:44:49 +02:00
// copy from expedition
2020-03-27 16:02:58 +01:00
$extrafields -> fetch_name_optionals_label ( $expedition -> table_element );
if ( $expedition -> fetch_optionals () > 0 ) {
2017-09-19 18:44:49 +02:00
$object -> array_options = array_merge ( $object -> array_options , $expedition -> array_options );
}
}
2015-12-16 16:18:29 +01:00
$cols = 2 ;
2019-11-13 19:35:39 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2008-08-05 10:41:54 +02:00
2009-02-04 23:12:23 +01:00
print " </table><br> \n " ;
2008-08-05 10:41:54 +02:00
2016-10-29 16:18:39 +02:00
print '</div>' ;
2017-10-03 16:00:52 +02:00
2008-08-05 10:41:54 +02:00
/*
2018-07-18 16:13:13 +02:00
* Products lines
2008-08-05 10:41:54 +02:00
*/
2014-09-29 20:31:48 +02:00
$num_prod = count ( $object -> lines );
2009-02-04 23:12:23 +01:00
$i = 0 ; $total = 0 ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2008-08-05 10:41:54 +02:00
2021-02-25 22:15:04 +01:00
if ( $num_prod ) {
2008-08-05 10:41:54 +02:00
$i = 0 ;
2009-02-04 23:12:23 +01:00
2008-08-05 10:41:54 +02:00
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Products " ) . '</td>' ;
2019-03-03 09:10:26 +01:00
print '<td class="center">' . $langs -> trans ( " QtyOrdered " ) . '</td>' ;
print '<td class="center">' . $langs -> trans ( " QtyReceived " ) . '</td>' ;
2008-08-05 10:41:54 +02:00
print " </tr> \n " ;
2009-02-04 23:12:23 +01:00
}
2021-02-25 22:15:04 +01:00
while ( $i < $num_prod ) {
2019-03-12 11:28:36 +01:00
$parameters = array ( 'i' => $i , 'line' => $object -> lines [ $i ], 'num' => $num_prod );
$reshook = $hookmanager -> executeHooks ( 'printObjectLine' , $parameters , $object , $action );
2021-02-25 22:15:04 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2009-02-04 23:12:23 +01:00
2021-02-25 22:15:04 +01:00
if ( empty ( $reshook )) {
2019-03-12 11:28:36 +01:00
print '<tr class="oddeven">' ;
2021-02-25 22:15:04 +01:00
if ( $object -> lines [ $i ] -> fk_product > 0 ) {
2019-03-12 11:28:36 +01:00
$product = new Product ( $db );
$product -> fetch ( $object -> lines [ $i ] -> fk_product );
// Define output language
2021-02-25 22:15:04 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ) && ! empty ( $conf -> global -> PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE )) {
2019-03-12 11:28:36 +01:00
$outputlangs = $langs ;
$newlang = '' ;
2021-05-17 07:27:02 +02:00
if ( empty ( $newlang ) && GETPOST ( 'lang_id' , 'aZ09' )) {
$newlang = GETPOST ( 'lang_id' , 'aZ09' );
2021-02-25 22:15:04 +01:00
}
if ( empty ( $newlang )) {
$newlang = $object -> thirdparty -> default_lang ;
}
if ( ! empty ( $newlang )) {
2019-03-12 11:28:36 +01:00
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( $newlang );
}
$label = ( ! empty ( $product -> multilangs [ $outputlangs -> defaultlang ][ " label " ])) ? $product -> multilangs [ $outputlangs -> defaultlang ][ " label " ] : $object -> lines [ $i ] -> product_label ;
2020-05-21 15:05:19 +02:00
} else {
2019-03-12 11:28:36 +01:00
$label = ( ! empty ( $object -> lines [ $i ] -> label ) ? $object -> lines [ $i ] -> label : $object -> lines [ $i ] -> product_label );
2019-03-14 19:06:21 +01:00
}
2019-03-14 23:27:50 +01:00
2019-03-12 11:28:36 +01:00
print '<td>' ;
// Affiche ligne produit
2019-11-13 19:35:39 +01:00
$text = '<a href="' . DOL_URL_ROOT . '/product/card.php?id=' . $object -> lines [ $i ] -> fk_product . '">' ;
2021-02-25 22:15:04 +01:00
if ( $object -> lines [ $i ] -> fk_product_type == 1 ) {
$text .= img_object ( $langs -> trans ( 'ShowService' ), 'service' );
} else {
$text .= img_object ( $langs -> trans ( 'ShowProduct' ), 'product' );
}
2019-11-13 19:35:39 +01:00
$text .= ' ' . $object -> lines [ $i ] -> product_ref . '</a>' ;
$text .= ' - ' . $label ;
2019-03-12 11:28:36 +01:00
$description = ( ! empty ( $conf -> global -> PRODUIT_DESC_IN_FORM ) ? '' : dol_htmlentitiesbr ( $object -> lines [ $i ] -> description ));
//print $description;
print $form -> textwithtooltip ( $text , $description , 3 , '' , '' , $i );
print_date_range ( $object -> lines [ $i ] -> date_start , $object -> lines [ $i ] -> date_end );
2021-02-25 22:15:04 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_DESC_IN_FORM )) {
2019-11-13 19:35:39 +01:00
print ( ! empty ( $object -> lines [ $i ] -> description ) && $object -> lines [ $i ] -> description != $object -> lines [ $i ] -> product_label ) ? '<br>' . dol_htmlentitiesbr ( $object -> lines [ $i ] -> description ) : '' ;
2012-08-25 15:21:34 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-03-12 11:28:36 +01:00
print " <td> " ;
2021-02-25 22:15:04 +01:00
if ( $object -> lines [ $i ] -> fk_product_type == 1 ) {
$text = img_object ( $langs -> trans ( 'Service' ), 'service' );
} else {
$text = img_object ( $langs -> trans ( 'Product' ), 'product' );
}
2019-03-12 11:28:36 +01:00
if ( ! empty ( $object -> lines [ $i ] -> label )) {
2019-11-13 19:35:39 +01:00
$text .= ' <strong>' . $object -> lines [ $i ] -> label . '</strong>' ;
2019-03-12 11:28:36 +01:00
print $form -> textwithtooltip ( $text , $object -> lines [ $i ] -> description , 3 , '' , '' , $i );
} else {
2019-11-13 19:35:39 +01:00
print $text . ' ' . nl2br ( $object -> lines [ $i ] -> description );
2019-03-12 11:28:36 +01:00
}
2012-08-25 15:21:34 +02:00
2019-03-12 11:28:36 +01:00
print_date_range ( $objp -> date_start , $objp -> date_end );
print " </td> \n " ;
}
2008-08-05 10:41:54 +02:00
2019-11-13 19:35:39 +01:00
print '<td class="center">' . $object -> lines [ $i ] -> qty_asked . '</td>' ;
print '<td class="center">' . $object -> lines [ $i ] -> qty_shipped . '</td>' ;
2019-03-12 11:28:36 +01:00
print " </tr> " ;
2019-03-14 19:06:21 +01:00
// Display lines extrafields
2021-10-23 22:21:50 +02:00
//if (!empty($extrafields)) {
2019-03-12 11:28:36 +01:00
$colspan = 2 ;
$mode = ( $object -> statut == 0 ) ? 'edit' : 'view' ;
2019-10-06 14:41:52 +02:00
2020-03-27 16:02:58 +01:00
$object -> lines [ $i ] -> fetch_optionals ();
2021-10-23 22:37:07 +02:00
if ( $action == 'create_delivery' ) {
$srcLine = new ExpeditionLigne ( $db );
2019-10-06 14:41:52 +02:00
2021-10-23 22:37:07 +02:00
$extrafields -> fetch_name_optionals_label ( $srcLine -> table_element );
$srcLine -> id = $expedition -> lines [ $i ] -> id ;
$srcLine -> fetch_optionals ();
2019-10-06 14:41:52 +02:00
2021-10-23 22:37:07 +02:00
$object -> lines [ $i ] -> array_options = array_merge ( $object -> lines [ $i ] -> array_options , $srcLine -> array_options );
} else {
$srcLine = new DeliveryLine ( $db );
$extrafields -> fetch_name_optionals_label ( $srcLine -> table_element );
2017-09-19 18:44:49 +02:00
}
2021-10-23 22:21:50 +02:00
print $object -> lines [ $i ] -> showOptionals ( $extrafields , $mode , array ( 'style' => 'class="oddeven"' , 'colspan' => $colspan ), '' );
//}
2015-12-16 16:18:29 +01:00
}
2008-08-05 10:41:54 +02:00
2009-02-04 23:12:23 +01:00
$i ++ ;
2008-08-05 10:41:54 +02:00
}
print " </table> \n " ;
2017-10-03 16:00:52 +02:00
2020-10-31 14:32:18 +01:00
print dol_get_fiche_end ();
2008-08-05 10:41:54 +02:00
2016-01-13 20:41:32 +01:00
//if ($object->statut == 0) // only if draft
2021-08-24 16:10:20 +02:00
// print $form->buttonsSaveCancel("Save", '');
2017-10-03 16:00:52 +02:00
2016-01-13 20:41:32 +01:00
print '</form>' ;
2017-10-03 16:00:52 +02:00
2008-08-05 10:41:54 +02:00
/*
* Boutons actions
*/
2021-02-25 22:15:04 +01:00
if ( $user -> socid == 0 ) {
2008-08-05 10:41:54 +02:00
print '<div class="tabsAction">' ;
2010-03-27 01:33:28 +01:00
2021-02-25 22:15:04 +01:00
if ( $object -> statut == 0 && $num_prod > 0 ) {
2020-10-06 16:10:48 +02:00
if (( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! empty ( $user -> rights -> expedition -> delivery -> creer ))
2021-02-25 22:15:04 +01:00
|| ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! empty ( $user -> rights -> expedition -> delivery_advance -> validate ))) {
2022-03-22 10:52:58 +01:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Validate' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?action=valid&token=' . newToken () . '&id=' . $object -> id , '' );
2015-08-29 16:52:10 +02:00
}
2010-03-01 18:38:35 +01:00
}
2009-02-04 23:12:23 +01:00
2021-02-25 22:15:04 +01:00
if ( $user -> rights -> expedition -> delivery -> supprimer ) {
if ( $conf -> expedition_bon -> enabled ) {
2022-03-22 10:52:58 +01:00
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 ), '' );
2020-05-21 15:05:19 +02:00
} else {
2022-03-22 14:18:48 +01:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Delete' ), 'delete' , $_SERVER [ " PHP_SELF " ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id , '' );
2008-08-05 10:41:54 +02:00
}
2010-03-01 18:38:35 +01:00
}
2009-02-04 23:12:23 +01:00
2008-08-05 10:41:54 +02:00
print '</div>' ;
}
print " \n " ;
2008-10-17 16:43:33 +02:00
2021-04-30 15:22:17 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2008-10-17 16:43:33 +02:00
2008-08-05 10:41:54 +02:00
/*
2021-02-25 22:15:04 +01:00
* Documents generated
2008-08-05 10:41:54 +02:00
*/
2014-09-29 20:31:48 +02:00
$objectref = dol_sanitizeFileName ( $object -> ref );
2019-11-13 19:35:39 +01:00
$filedir = $conf -> expedition -> dir_output . " /receipt/ " . $objectref ;
2014-09-29 20:31:48 +02:00
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
2008-08-05 10:41:54 +02:00
2020-10-06 16:10:48 +02:00
$genallowed = $user -> rights -> expedition -> delivery -> lire ;
$delallowed = $user -> rights -> expedition -> delivery -> creer ;
2008-08-05 10:41:54 +02:00
2020-10-06 15:57:50 +02:00
print $formfile -> showdocuments ( 'delivery' , $objectref , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf , 1 , 0 , 0 , 28 , 0 , '' , '' , '' , $soc -> default_lang );
2013-08-07 15:08:30 +02:00
/*
2021-02-25 22:15:04 +01:00
* Linked object block ( of linked shipment )
*/
if ( $object -> origin == 'expedition' ) {
2013-08-07 15:08:30 +02:00
$shipment = new Expedition ( $db );
2014-09-29 20:31:48 +02:00
$shipment -> fetch ( $object -> origin_id );
2013-08-07 15:08:30 +02:00
2020-10-28 17:49:52 +01:00
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form -> showLinkedObjectBlock ( $object , '' );
2013-08-07 15:08:30 +02:00
}
2008-08-05 10:41:54 +02:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2006-05-29 15:53:20 +02:00
2021-04-30 15:22:17 +02:00
// Nothing on right
2009-02-04 23:12:23 +01:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2009-07-15 22:10:28 +02:00
/* Expedition non trouvee */
print " Expedition inexistante ou acces refuse " ;
2008-01-31 15:23:57 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2009-07-15 22:10:28 +02:00
/* Expedition non trouvee */
print " Expedition inexistante ou acces refuse " ;
2008-08-05 10:41:54 +02:00
}
2006-05-29 15:53:20 +02:00
}
2018-08-13 11:25:48 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-08-25 15:21:34 +02:00
$db -> close ();