2008-05-20 02:09:11 +02:00
< ? php
2012-10-31 09:50:20 +01:00
/* Copyright ( C ) 2008 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2012 Regis Houssin < regis . houssin @ inodbox . com >
2008-05-20 02:09:11 +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
2008-05-20 02:09:11 +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 />.
2008-05-20 02:09:11 +02:00
*/
/**
2011-10-24 12:59:44 +02:00
* \file htdocs / core / lib / sendings . lib . php
2008-10-17 16:43:33 +02:00
* \ingroup expedition
* \brief Library for expedition module
2008-05-20 02:09:11 +02:00
*/
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php' ;
2016-10-29 16:18:39 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
2008-05-20 02:09:11 +02:00
2012-02-04 10:48:47 +01:00
/**
* Prepare array with list of tabs
*
* @ param Object $object Object related to tabs
2014-08-30 05:30:37 +02:00
* @ return array Array of tabs to show
2012-02-04 10:48:47 +01:00
*/
2010-03-13 16:52:30 +01:00
function shipping_prepare_head ( $object )
{
2016-10-24 20:52:21 +02:00
global $db , $langs , $conf , $user ;
2010-05-08 18:45:47 +02:00
2018-09-11 17:30:43 +02:00
// Load translation files required by the page
2020-10-28 17:49:52 +01:00
$langs -> loadLangs ( array ( " sendings " , " deliveries " ));
2010-03-13 16:52:30 +01:00
$h = 0 ;
$head = array ();
2014-09-18 21:18:25 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/card.php?id= " . $object -> id ;
2010-03-13 16:52:30 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " SendingCard " );
$head [ $h ][ 2 ] = 'shipping' ;
$h ++ ;
2021-02-23 22:03:23 +01:00
if ( $conf -> delivery_note -> enabled && $user -> rights -> expedition -> delivery -> lire ) {
2012-07-02 19:30:37 +02:00
// delivery link
2019-01-27 11:55:16 +01:00
$object -> fetchObjectLinked ( $object -> id , $object -> element );
2021-02-23 22:03:23 +01:00
if ( is_array ( $object -> linkedObjectsIds [ 'delivery' ]) && count ( $object -> linkedObjectsIds [ 'delivery' ]) > 0 ) { // If there is a delivery
2020-10-28 17:49:52 +01:00
// Take first one element of array
$tmp = reset ( $object -> linkedObjectsIds [ 'delivery' ]);
2017-12-02 10:43:01 +01:00
2020-10-05 15:32:29 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /delivery/card.php?id= " . $tmp ;
2012-07-02 19:30:37 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " DeliveryCard " );
$head [ $h ][ 2 ] = 'delivery' ;
2012-07-02 17:07:37 +02:00
$h ++ ;
}
2010-03-13 16:52:30 +01:00
}
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_CONTACTS_TAB )) {
2020-10-28 17:49:52 +01:00
$objectsrc = $object ;
2021-02-23 22:03:23 +01:00
if ( $object -> origin == 'commande' && $object -> origin_id > 0 ) {
2020-10-28 17:49:52 +01:00
$objectsrc = new Commande ( $db );
$objectsrc -> fetch ( $object -> origin_id );
}
$nbContact = count ( $objectsrc -> liste_contact ( - 1 , 'internal' )) + count ( $objectsrc -> liste_contact ( - 1 , 'external' ));
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/contact.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " ContactsAddresses " );
2021-02-23 22:03:23 +01:00
if ( $nbContact > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . $nbContact . '</span>' ;
}
2020-10-28 17:49:52 +01:00
$head [ $h ][ 2 ] = 'contact' ;
$h ++ ;
2016-06-06 12:29:15 +02:00
}
2017-12-02 10:43:01 +01:00
2018-02-07 15:56:14 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2020-10-28 17:49:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php' ;
2021-01-02 17:42:33 +01:00
$upload_dir = $conf -> expedition -> dir_output . " /sending/ " . dol_sanitizeFileName ( $object -> ref );
2019-01-27 11:55:16 +01:00
$nbFiles = count ( dol_dir_list ( $upload_dir , 'files' , 0 , '' , '(\.meta|_preview.*\.png)$' ));
2020-10-28 17:49:52 +01:00
$nbLinks = Link :: count ( $db , $object -> element , $object -> id );
2018-02-07 15:56:14 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/expedition/document.php?id=' . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( 'Documents' );
2021-02-23 22:03:23 +01:00
if (( $nbFiles + $nbLinks ) > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . ( $nbFiles + $nbLinks ) . '</span>' ;
}
2018-02-07 15:56:14 +01:00
$head [ $h ][ 2 ] = 'documents' ;
$h ++ ;
2020-10-28 17:49:52 +01:00
$nbNote = 0 ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $object -> note_private )) {
$nbNote ++ ;
}
if ( ! empty ( $object -> note_public )) {
$nbNote ++ ;
}
2013-04-09 17:18:07 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/note.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Notes " );
2021-02-23 22:03:23 +01:00
if ( $nbNote > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' ;
}
2013-04-09 17:18:07 +02:00
$head [ $h ][ 2 ] = 'note' ;
$h ++ ;
2012-03-14 14:00:20 +01:00
2012-02-04 10:48:47 +01:00
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
2020-10-28 17:49:52 +01:00
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'delivery' );
2010-03-13 16:52:30 +01:00
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'delivery' , 'remove' );
2012-12-01 15:45:05 +01:00
2012-02-04 10:48:47 +01:00
return $head ;
2010-03-13 16:52:30 +01:00
}
2011-01-25 00:35:21 +01:00
2012-02-04 10:48:47 +01:00
/**
* Prepare array with list of tabs
*
* @ param Object $object Object related to tabs
2014-08-30 05:30:37 +02:00
* @ return array Array of tabs to show
2012-02-04 10:48:47 +01:00
*/
2010-03-13 16:52:30 +01:00
function delivery_prepare_head ( $object )
{
2020-01-28 02:21:39 +01:00
global $langs , $db , $conf , $user ;
2010-05-08 18:45:47 +02:00
2018-09-11 17:30:43 +02:00
// Load translation files required by the page
2020-10-28 17:49:52 +01:00
$langs -> loadLangs ( array ( " sendings " , " deliveries " ));
2010-03-13 16:52:30 +01:00
$h = 0 ;
$head = array ();
2021-02-23 22:03:23 +01:00
if ( $conf -> expedition_bon -> enabled && $user -> rights -> expedition -> lire ) {
2014-09-18 21:18:25 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/card.php?id= " . $object -> origin_id ;
2010-03-13 16:52:30 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " SendingCard " );
$head [ $h ][ 2 ] = 'shipping' ;
$h ++ ;
}
2020-10-05 15:32:29 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /delivery/card.php?id= " . $object -> id ;
2010-03-13 16:52:30 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " DeliveryCard " );
$head [ $h ][ 2 ] = 'delivery' ;
$h ++ ;
2020-01-28 02:21:39 +01:00
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
// complete_head_from_modules use $object->id for this link so we temporary change it
$savObjectId = $object -> id ;
// Get parent object
$tmpobject = null ;
if ( $object -> origin ) {
$tmpobject = new Expedition ( $db );
$tmpobject -> fetch ( $object -> origin_id );
} else {
$tmpobject = $object ;
}
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_CONTACTS_TAB )) {
2020-10-25 17:19:15 +01:00
$objectsrc = $tmpobject ;
2021-02-23 22:03:23 +01:00
if ( $tmpobject -> origin == 'commande' && $tmpobject -> origin_id > 0 ) {
2020-10-25 17:19:15 +01:00
$objectsrc = new Commande ( $db );
$objectsrc -> fetch ( $tmpobject -> origin_id );
}
$nbContact = count ( $objectsrc -> liste_contact ( - 1 , 'internal' )) + count ( $objectsrc -> liste_contact ( - 1 , 'external' ));
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/contact.php?id= " . $tmpobject -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " ContactsAddresses " );
2021-02-23 22:03:23 +01:00
if ( $nbContact > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . $nbContact . '</span>' ;
}
2020-10-25 17:19:15 +01:00
$head [ $h ][ 2 ] = 'contact' ;
$h ++ ;
}
2020-01-28 02:21:39 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php' ;
2022-01-24 16:38:25 +01:00
$upload_dir = $conf -> expedition -> dir_output . " /sending/ " . dol_sanitizeFileName ( $object -> ref );
2020-01-28 02:21:39 +01:00
$nbFiles = count ( dol_dir_list ( $upload_dir , 'files' , 0 , '' , '(\.meta|_preview.*\.png)$' ));
2020-04-10 10:59:32 +02:00
$nbLinks = Link :: count ( $db , $tmpobject -> element , $tmpobject -> id );
2020-01-28 02:21:39 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/expedition/document.php?id=' . $tmpobject -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( 'Documents' );
2021-02-23 22:03:23 +01:00
if (( $nbFiles + $nbLinks ) > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . ( $nbFiles + $nbLinks ) . '</span>' ;
}
2020-01-28 02:21:39 +01:00
$head [ $h ][ 2 ] = 'documents' ;
$h ++ ;
$nbNote = 0 ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $tmpobject -> note_private )) {
$nbNote ++ ;
}
if ( ! empty ( $tmpobject -> note_public )) {
$nbNote ++ ;
}
2020-01-28 02:21:39 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/note.php?id= " . $tmpobject -> id ;
2013-08-07 15:08:30 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Notes " );
2021-02-23 22:03:23 +01:00
if ( $nbNote > 0 ) {
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' ;
}
2013-08-07 15:08:30 +02:00
$head [ $h ][ 2 ] = 'note' ;
2014-05-06 13:15:37 +02:00
$h ++ ;
2013-08-07 15:08:30 +02:00
2020-01-28 02:21:39 +01:00
$object -> id = $tmpobject -> id ;
2013-08-07 15:08:30 +02:00
2020-10-28 17:49:52 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'delivery' );
2010-03-13 16:52:30 +01:00
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'delivery' , 'remove' );
2013-08-07 15:08:30 +02:00
2020-01-28 02:21:39 +01:00
$object -> id = $savObjectId ;
2012-02-04 10:48:47 +01:00
return $head ;
2010-03-13 16:52:30 +01:00
}
2008-05-20 02:09:11 +02:00
/**
* List sendings and receive receipts
*
2012-02-04 14:39:47 +01:00
* @ param string $origin Origin ( 'commande' , ... )
2011-09-12 19:08:02 +02:00
* @ param int $origin_id Origin id
* @ param string $filter Filter
2012-01-04 21:23:50 +01:00
* @ return int < 0 if KO , > 0 if OK
2008-05-20 02:09:11 +02:00
*/
2019-01-27 15:20:16 +01:00
function show_list_sending_receive ( $origin , $origin_id , $filter = '' )
2008-05-20 02:09:11 +02:00
{
2019-04-23 12:32:08 +02:00
global $db , $conf , $langs ;
2011-11-08 10:18:45 +01:00
global $form ;
2009-04-05 21:01:43 +02:00
2020-04-10 10:59:32 +02:00
$product_static = new Product ( $db );
$expedition = new Expedition ( $db );
$warehousestatic = new Entrepot ( $db );
2017-12-02 10:43:01 +01:00
2016-11-14 14:34:15 +01:00
$sql = " SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end, " ;
2020-04-10 10:59:32 +02:00
$sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id, " ;
$sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, " ;
2020-10-06 15:57:50 +02:00
//if ($conf->delivery_note->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
2020-04-10 10:59:32 +02:00
$sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,' ;
$sql .= ' p.description as product_desc' ;
$sql .= " FROM " . MAIN_DB_PREFIX . " expeditiondet as ed " ;
$sql .= " , " . MAIN_DB_PREFIX . " expedition as e " ;
$sql .= " , " . MAIN_DB_PREFIX . $origin . " det as obj " ;
2020-10-06 15:57:50 +02:00
//if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line";
2020-04-10 10:59:32 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON obj.fk_product = p.rowid " ;
2016-11-14 14:34:15 +01:00
//TODO Add link to expeditiondet_batch
2020-04-10 10:59:32 +02:00
$sql .= " WHERE e.entity IN ( " . getEntity ( 'expedition' ) . " ) " ;
2021-06-09 15:36:47 +02:00
$sql .= " AND obj.fk_ " . $origin . " = " . (( int ) $origin_id );
2020-04-10 10:59:32 +02:00
$sql .= " AND obj.rowid = ed.fk_origin_line " ;
$sql .= " AND ed.fk_expedition = e.rowid " ;
2021-02-23 22:03:23 +01:00
if ( $filter ) {
$sql .= $filter ;
}
2012-03-14 14:00:20 +01:00
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY obj.fk_product " ;
2008-05-20 02:09:11 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( " show_list_sending_receive " , LOG_DEBUG );
2008-05-20 02:09:11 +02:00
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2008-05-20 02:09:11 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $num ) {
if ( $filter ) {
print load_fiche_titre ( $langs -> trans ( " OtherSendingsForSameOrder " ));
} else {
print load_fiche_titre ( $langs -> trans ( " SendingsAndReceivingForSameOrder " ));
}
2009-04-05 21:01:43 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="liste centpercent">' ;
2008-05-20 02:09:11 +02:00
print '<tr class="liste_titre">' ;
2019-01-19 12:40:17 +01:00
//print '<td class="left">'.$langs->trans("QtyOrdered").'</td>';
2019-04-23 12:32:08 +02:00
print '<td>' . $langs -> trans ( " SendingSheet " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
2019-03-14 14:20:32 +01:00
print '<td class="center">' . $langs -> trans ( " DateCreation " ) . '</td>' ;
print '<td class="center">' . $langs -> trans ( " DateDeliveryPlanned " ) . '</td>' ;
print '<td class="center">' . $langs -> trans ( " QtyPreparedOrShipped " ) . '</td>' ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
2020-10-28 17:49:52 +01:00
print '<td>' . $langs -> trans ( " Warehouse " ) . '</td>' ;
2016-10-29 16:18:39 +02:00
}
2016-11-14 14:34:15 +01:00
/* TODO Add link to expeditiondet_batch
if ( ! empty ( $conf -> productbatch -> enabled ))
{
2021-02-23 22:03:23 +01:00
print '<td>' ;
print '</td>' ;
2016-11-14 14:34:15 +01:00
} */
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> delivery_note -> enabled )) {
2012-02-04 10:48:47 +01:00
print '<td>' . $langs -> trans ( " DeliveryOrder " ) . '</td>' ;
2019-03-14 14:20:32 +01:00
//print '<td class="center">'.$langs->trans("QtyReceived").'</td>';
print '<td class="right">' . $langs -> trans ( " DeliveryDate " ) . '</td>' ;
2012-02-04 10:48:47 +01:00
}
2008-05-20 02:09:11 +02:00
print " </tr> \n " ;
2021-02-23 22:03:23 +01:00
while ( $i < $num ) {
2008-05-20 02:09:11 +02:00
$objp = $db -> fetch_object ( $resql );
2018-04-22 19:27:37 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2009-04-05 21:01:43 +02:00
2010-05-17 16:13:03 +02:00
// Sending id
2019-03-14 14:20:32 +01:00
print '<td class="nowrap left">' ;
2019-01-27 11:55:16 +01:00
print '<a href="' . DOL_URL_ROOT . '/expedition/card.php?id=' . $objp -> expedition_id . '">' . img_object ( $langs -> trans ( " ShowSending " ), 'sending' ) . ' ' . $objp -> exp_ref . '<a>' ;
2016-11-14 14:34:15 +01:00
print '</td>' ;
2010-05-17 16:13:03 +02:00
// Description
2021-02-23 22:03:23 +01:00
if ( $objp -> fk_product > 0 ) {
2012-02-04 10:48:47 +01:00
// Define output language
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ) && ! empty ( $conf -> global -> PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE )) {
2012-02-04 10:48:47 +01:00
$object = new $origin ( $db );
$object -> fetch ( $origin_id );
$object -> fetch_thirdparty ();
2014-03-12 01:21:18 +01:00
$prod = new Product ( $db );
2020-04-10 10:59:32 +02:00
$prod -> id = $objp -> fk_product ;
2014-03-12 01:21:18 +01:00
$prod -> getMultiLangs ();
2012-02-04 10:48:47 +01:00
$outputlangs = $langs ;
2020-04-10 10:59:32 +02:00
$newlang = '' ;
2021-05-17 07:27:02 +02:00
if ( empty ( $newlang ) && GETPOST ( 'lang_id' , 'aZ09' )) {
$newlang = GETPOST ( 'lang_id' , 'aZ09' );
2021-02-23 22:03:23 +01:00
}
if ( empty ( $newlang )) {
$newlang = $object -> thirdparty -> default_lang ;
}
if ( ! empty ( $newlang )) {
2019-01-27 11:55:16 +01:00
$outputlangs = new Translate ( " " , $conf );
2012-02-04 10:48:47 +01:00
$outputlangs -> setDefaultLang ( $newlang );
}
2020-04-10 10:59:32 +02:00
$label = ( ! empty ( $prod -> multilangs [ $outputlangs -> defaultlang ][ " label " ])) ? $prod -> multilangs [ $outputlangs -> defaultlang ][ " label " ] : $objp -> product_label ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$label = ( ! empty ( $objp -> label ) ? $objp -> label : $objp -> product_label );
2012-02-04 10:48:47 +01:00
}
2012-01-17 12:03:05 +01:00
2008-05-20 02:09:11 +02:00
print '<td>' ;
2009-04-05 21:01:43 +02:00
// Show product and description
2020-04-10 10:59:32 +02:00
$product_static -> type = $objp -> fk_product_type ;
$product_static -> id = $objp -> fk_product ;
$product_static -> ref = $objp -> ref ;
$product_static -> status_batch = $objp -> product_tobatch ;
$text = $product_static -> getNomUrl ( 1 );
$text .= ' - ' . $label ;
$description = ( ! empty ( $conf -> global -> PRODUIT_DESC_IN_FORM ) ? '' : dol_htmlentitiesbr ( $objp -> description ));
2019-01-27 11:55:16 +01:00
print $form -> textwithtooltip ( $text , $description , 3 , '' , '' , $i );
2009-04-05 21:01:43 +02:00
// Show range
2019-01-27 11:55:16 +01:00
print_date_range ( $objp -> date_start , $objp -> date_end );
2009-04-05 21:01:43 +02:00
// Add description in form
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_DESC_IN_FORM )) {
2020-04-10 10:59:32 +02:00
print ( ! empty ( $objp -> description ) && $objp -> description != $objp -> product ) ? '<br>' . dol_htmlentitiesbr ( $objp -> description ) : '' ;
2009-04-05 21:01:43 +02:00
}
2008-05-20 02:09:11 +02:00
print '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2009-04-05 21:01:43 +02:00
print " <td> " ;
2021-02-23 22:03:23 +01:00
if ( $objp -> fk_product_type == 1 ) {
$text = img_object ( $langs -> trans ( 'Service' ), 'service' );
} else {
$text = img_object ( $langs -> trans ( 'Product' ), 'product' );
}
2012-08-25 15:21:34 +02:00
2020-04-10 10:59:32 +02:00
if ( ! empty ( $objp -> label )) {
$text .= ' <strong>' . $objp -> label . '</strong>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithtooltip ( $text , $objp -> description , 3 , '' , '' , $i );
2012-08-25 15:21:34 +02:00
} else {
print $text . ' ' . nl2br ( $objp -> description );
}
2009-04-05 21:01:43 +02:00
// Show range
2019-01-27 11:55:16 +01:00
print_date_range ( $objp -> date_start , $objp -> date_end );
2009-04-05 21:01:43 +02:00
print " </td> \n " ;
2008-05-20 02:09:11 +02:00
}
2008-10-17 16:43:33 +02:00
2019-03-14 14:20:32 +01:00
//print '<td class="center">'.$objp->qty_asked.'</td>';
2009-04-05 21:01:43 +02:00
2010-05-27 00:54:48 +02:00
// Date creation
2019-03-14 14:20:32 +01:00
print '<td class="nowrap center">' . dol_print_date ( $db -> jdate ( $objp -> date_creation ), 'day' ) . '</td>' ;
2009-04-05 21:01:43 +02:00
2010-05-27 00:54:48 +02:00
// Date shipping creation
2019-03-14 14:20:32 +01:00
print '<td class="nowrap center">' . dol_print_date ( $db -> jdate ( $objp -> date_delivery ), 'day' ) . '</td>' ;
2010-05-13 01:03:33 +02:00
2010-05-27 00:54:48 +02:00
// Qty shipped
2019-03-14 14:20:32 +01:00
print '<td class="center">' . $objp -> qty_shipped . '</td>' ;
2010-05-13 01:03:33 +02:00
2016-10-29 16:18:39 +02:00
// Warehouse
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
2020-10-28 17:49:52 +01:00
print '<td>' ;
2021-02-23 22:03:23 +01:00
if ( $objp -> warehouse_id > 0 ) {
2020-10-28 17:49:52 +01:00
$warehousestatic -> fetch ( $objp -> warehouse_id );
print $warehousestatic -> getNomUrl ( 1 );
}
print '</td>' ;
2016-10-29 16:18:39 +02:00
}
2017-12-02 10:43:01 +01:00
2016-11-14 14:34:15 +01:00
// Batch number managment
/* TODO Add link to expeditiondet_batch
if ( ! empty ( $conf -> productbatch -> enabled ))
{
2021-02-23 22:03:23 +01:00
var_dump ( $objp -> edrowid );
$lines [ $i ] -> detail_batch
if ( isset ( $lines [ $i ] -> detail_batch ))
{
print '<td>' ;
if ( $lines [ $i ] -> product_tobatch )
{
$detail = '' ;
foreach ( $lines [ $i ] -> detail_batch as $dbatch )
{
2017-12-02 10:43:01 +01:00
$detail .= $langs -> trans ( " Batch " ) . ': ' . $dbatch -> batch ;
$detail .= ' - ' . $langs -> trans ( " SellByDate " ) . ': ' . dol_print_date ( $dbatch -> sellby , " day " );
2017-12-02 11:34:56 +01:00
$detail .= ' - ' . $langs -> trans ( " EatByDate " ) . ': ' . dol_print_date ( $dbatch -> eatby , " day " );
2018-10-11 11:56:52 +02:00
$detail .= ' - ' . $langs -> trans ( " Qty " ) . ': ' . $dbatch -> qty ;
2017-12-02 10:43:01 +01:00
$detail .= '<br>' ;
2021-02-23 22:03:23 +01:00
}
print $form -> textwithtooltip ( img_picto ( '' , 'object_barcode' ) . ' ' . $langs -> trans ( " DetailBatchNumber " ), $detail );
}
else
{
print $langs -> trans ( " NA " );
}
print '</td>' ;
} else {
print '<td></td>' ;
}
2017-12-02 10:43:01 +01:00
} */
2010-05-27 00:54:48 +02:00
// Informations on receipt
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> delivery_note -> enabled )) {
2020-10-05 13:59:06 +02:00
include_once DOL_DOCUMENT_ROOT . '/delivery/class/delivery.class.php' ;
2020-04-10 10:59:32 +02:00
$expedition -> id = $objp -> sendingid ;
2019-01-27 11:55:16 +01:00
$expedition -> fetchObjectLinked ( $expedition -> id , $expedition -> element );
2011-05-06 20:27:18 +02:00
//var_dump($expedition->linkedObjects);
2016-07-01 02:06:30 +02:00
2020-04-10 10:59:32 +02:00
$receiving = '' ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $expedition -> linkedObjects [ 'delivery' ])) {
$receiving = reset ( $expedition -> linkedObjects [ 'delivery' ]); // Take first link
}
2010-05-27 00:54:48 +02:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $receiving )) {
2010-05-27 00:54:48 +02:00
// $expedition->fk_origin_line = id of det line of order
// $receiving->fk_origin_line = id of det line of order
// $receiving->origin may be 'shipping'
// $receiving->origin_id may be id of shipping
2010-05-13 01:03:33 +02:00
// Ref
2010-05-27 00:54:48 +02:00
print '<td>' ;
print $receiving -> getNomUrl ( $db );
2020-10-05 15:32:29 +02:00
//print '<a href="'.DOL_URL_ROOT.'/delivery/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
2010-05-27 00:54:48 +02:00
print '</td>' ;
2010-05-13 01:03:33 +02:00
// Qty received
2019-03-14 14:20:32 +01:00
//print '<td class="center">';
2010-05-27 00:54:48 +02:00
// TODO No solution for the moment to link a line det of receipt with a line det of shipping,
// so no way to know the qty received for this line of shipping.
//print $langs->trans("FeatureNotYetAvailable");
//print '</td>';
2010-05-13 01:03:33 +02:00
// Date shipping real
2019-03-14 14:20:32 +01:00
print '<td class="right">' ;
2019-01-27 11:55:16 +01:00
print dol_print_date ( $receiving -> date_delivery , 'day' );
2010-05-27 00:54:48 +02:00
print '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2010-07-23 00:51:00 +02:00
//print '<td> </td>';
2008-10-17 16:43:33 +02:00
print '<td> </td>' ;
print '<td> </td>' ;
2008-05-20 02:09:11 +02:00
}
}
print '</tr>' ;
$i ++ ;
}
print '</table>' ;
}
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-05-20 02:09:11 +02:00
}
return 1 ;
}