2004-10-19 22:43:23 +02:00
< ? php
2008-09-01 15:22:36 +02:00
/* Copyright ( C ) 2003 - 2008 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-05-20 02:09:11 +02:00
* Copyright ( C ) 2005 - 2008 Laurent Destailleur < eldy @ users . sourceforge . net >
2007-05-16 00:47:58 +02:00
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
2008-01-17 11:27:59 +01:00
* Copyright ( C ) 2005 - 2008 R<EFBFBD> gis Houssin < regis @ dolibarr . fr >
2003-11-13 18:36:45 +01: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
* the Free Software Foundation ; either version 2 of the License , or
* ( 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
2008-09-01 15:22:36 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-11-13 18:36:45 +01:00
*/
2004-08-14 15:05:12 +02:00
2005-09-11 18:51:41 +02:00
// Code identique a /expedition/commande.php
2005-07-09 03:16:31 +02:00
/**
2008-09-02 03:42:31 +02:00
* \file htdocs / expedition / fiche . php
* \ingroup expedition
* \brief Fiche descriptive d ' une expedition
* \version $Id $
*/
2004-08-14 15:05:12 +02:00
2003-11-13 18:36:45 +01:00
require ( " ./pre.inc.php " );
2008-01-20 14:53:02 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /html.formfile.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /expedition/mods/pdf/ModelePdfExpedition.class.php " );
2008-05-20 02:09:11 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/sendings.lib.php " );
2007-11-16 23:01:14 +01:00
if ( $conf -> produit -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /product.class.php " );
if ( $conf -> propal -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
2008-01-17 11:27:59 +01:00
if ( $conf -> commande -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /commande/commande.class.php " );
2007-11-16 23:01:14 +01:00
if ( $conf -> stock -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /product/stock/entrepot.class.php " );
2003-11-13 18:36:45 +01:00
2006-06-24 19:10:32 +02:00
$langs -> load ( " companies " );
2005-08-23 21:31:25 +02:00
$langs -> load ( " bills " );
2006-06-01 12:30:47 +02:00
$langs -> load ( 'deliveries' );
2006-06-24 19:10:32 +02:00
$langs -> load ( 'orders' );
2006-07-14 13:31:57 +02:00
$langs -> load ( 'stocks' );
2007-05-16 01:03:08 +02:00
$langs -> load ( 'other' );
2005-04-15 12:34:44 +02:00
2008-05-20 02:09:11 +02:00
if ( ! $user -> rights -> expedition -> lire )
2008-09-02 03:42:31 +02:00
accessforbidden ();
2003-11-13 18:36:45 +01:00
2008-09-01 15:22:36 +02:00
// Security customer access
2006-11-11 01:46:15 +01:00
if ( $user -> societe_id > 0 )
2003-11-13 18:36:45 +01:00
{
2008-09-02 03:42:31 +02:00
$action = '' ;
$socid = $user -> societe_id ;
2003-11-13 18:36:45 +01:00
}
2005-07-09 03:16:31 +02:00
2008-05-17 03:52:24 +02:00
$origin = $_GET [ " origin " ] ? $_GET [ " origin " ] : $_POST [ " origin " ]; // Example: commande, propal
$origin_id = $_GET [ " object_id " ] ? $_GET [ " object_id " ] : $_POST [ " object_id " ]; // Id of order or propal
2005-07-09 03:16:31 +02:00
2003-11-13 18:36:45 +01:00
/*
2005-07-09 03:16:31 +02:00
* Actions
2005-04-16 16:00:07 +02:00
*/
2006-11-11 01:46:15 +01:00
if ( $_POST [ " action " ] == 'add' )
2003-11-13 18:36:45 +01:00
{
2008-09-02 03:42:31 +02:00
$db -> begin ();
// Creation de l'objet expedition
$expedition = new Expedition ( $db );
$expedition -> date_expedition = time ();
$expedition -> note = $_POST [ " note " ];
$expedition -> origin = $origin ;
$expedition -> origin_id = $origin_id ;
// On boucle sur chaque ligne du document d'origine pour compl<70> ter objet expedition
// avec qt<71> <20> livrer
$class = ucfirst ( $expedition -> origin );
$object = new $class ( $db );
$object -> fetch ( $expedition -> origin_id );
//$object->fetch_lines();
$expedition -> socid = $object -> socid ;
$expedition -> expedition_method_id = $_POST [ " expedition_method_id " ];
$expedition -> tracking_number = $_POST [ " tracking_number " ];
for ( $i = 0 ; $i < sizeof ( $object -> lignes ) ; $i ++ )
{
$ent = " entl " . $i ;
$idl = " idl " . $i ;
$qty = " qtyl " . $i ;
$entrepot_id = $_POST [ $ent ] ? $_POST [ $ent ] : $_POST [ " entrepot_id " ];
if ( $_POST [ $qty ] > 0 )
{
$expedition -> addline ( $entrepot_id , $_POST [ $idl ], $_POST [ $qty ]);
}
}
$ret = $expedition -> create ( $user );
if ( $ret > 0 )
{
$db -> commit ();
Header ( " Location: fiche.php?id= " . $expedition -> id );
exit ;
}
else
{
$db -> rollback ();
$mesg = '<div class="error">' . $expedition -> error . '</div>' ;
$_GET [ " commande_id " ] = $_POST [ " commande_id " ];
$_GET [ " action " ] = 'create' ;
}
2003-11-13 18:36:45 +01:00
}
2006-05-30 15:49:03 +02:00
/*
* G<EFBFBD> n<EFBFBD> re un bon de livraison
*/
2008-05-20 02:09:11 +02:00
if ( $_GET [ " action " ] == 'create_delivery' && $conf -> livraison_bon -> enabled && $user -> rights -> expedition -> livraison -> creer )
2006-05-30 15:49:03 +02:00
{
2008-09-02 03:42:31 +02:00
$expedition = new Expedition ( $db );
$expedition -> fetch ( $_GET [ " id " ]);
$result = $expedition -> create_delivery ( $user );
if ( $result > 0 )
{
Header ( " Location: " . DOL_URL_ROOT . '/livraison/fiche.php?id=' . $result );
exit ;
}
else
{
$mesg = $expedition -> error ;
}
2006-05-30 15:49:03 +02:00
}
2005-04-12 20:21:30 +02:00
if ( $_POST [ " action " ] == 'confirm_valid' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> expedition -> valider )
2003-11-13 18:36:45 +01:00
{
2008-09-02 03:42:31 +02:00
$expedition = new Expedition ( $db );
$expedition -> fetch ( $_GET [ " id " ]);
$result = $expedition -> valid ( $user );
//$expedition->PdfWrite();
2003-11-13 18:36:45 +01:00
}
2005-04-12 20:21:30 +02:00
if ( $_POST [ " action " ] == 'confirm_delete' && $_POST [ " confirm " ] == 'yes' )
2003-11-13 18:36:45 +01:00
{
2008-09-02 03:42:31 +02:00
if ( $user -> rights -> expedition -> supprimer )
{
$expedition = new Expedition ( $db );
$expedition -> fetch ( $_GET [ " id " ]);
$expedition -> delete ();
Header ( " Location: liste.php " );
exit ;
}
2003-11-13 18:36:45 +01:00
}
2005-07-09 16:58:25 +02:00
/*
* G<EFBFBD> n<EFBFBD> rer ou reg<EFBFBD> n<EFBFBD> rer le PDF
*/
2006-05-06 23:09:26 +02:00
if ( $_REQUEST [ 'action' ] == 'builddoc' ) // En get ou en post
2005-04-16 16:00:07 +02:00
{
2006-07-14 15:26:19 +02:00
// Sauvegarde le dernier mod<6F> le choisi pour g<> n<EFBFBD> rer un document
$expedition = new Expedition ( $db , 0 , $_REQUEST [ 'id' ]);
$expedition -> fetch ( $_REQUEST [ 'id' ]);
2006-08-26 16:13:37 +02:00
2006-07-14 15:26:19 +02:00
if ( $_REQUEST [ 'model' ])
{
2008-02-24 17:16:34 +01:00
$expedition -> setDocModel ( $user , $_REQUEST [ 'model' ]);
2006-07-14 15:26:19 +02:00
}
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
2008-03-31 17:17:39 +02:00
$outputlangs = new Translate ( " " , $conf );
2006-06-18 17:48:28 +02:00
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-08-26 15:47:10 +02:00
$result = expedition_pdf_create ( $db , $expedition -> id , $expedition -> modelpdf , $outputlangs );
2008-09-02 03:42:31 +02:00
if ( $result <= 0 )
{
dolibarr_print_error ( $db , $result );
exit ;
}
2005-04-16 16:00:07 +02:00
}
2005-07-09 03:16:31 +02:00
2003-11-13 18:36:45 +01:00
/*
2008-08-21 09:39:38 +02:00
* View
2003-11-13 18:36:45 +01:00
*/
2007-11-16 23:01:14 +01:00
llxHeader ( '' , $langs -> trans ( 'Sending' ), 'Expedition' );
2006-06-04 01:53:10 +02:00
2003-11-13 18:36:45 +01:00
$html = new Form ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2003-11-13 18:36:45 +01:00
/*********************************************************************
*
* Mode creation
*
2005-07-09 03:16:31 +02:00
*********************************************************************/
2006-11-11 01:46:15 +01:00
if ( $_GET [ " action " ] == 'create' )
2003-11-13 18:36:45 +01:00
{
2004-02-13 18:13:39 +01:00
2008-09-02 03:42:31 +02:00
$expe = new Expedition ( $db );
print_titre ( $langs -> trans ( " CreateASending " ));
if ( ! $origin )
{
$mesg = '<div class="error">' . $langs -> trans ( " ErrorBadParameters " ) . '</div>' ;
}
if ( $mesg )
{
print $mesg . '<br>' ;
}
if ( $origin )
2006-07-14 13:31:57 +02:00
{
2008-09-02 03:42:31 +02:00
$class = ucfirst ( $origin );
$object = new $class ( $db );
2008-10-17 16:43:33 +02:00
if ( $object -> fetch ( $origin_id ))
2008-09-02 03:42:31 +02:00
{
2008-10-17 16:43:33 +02:00
$soc = new Societe ( $db );
$soc -> fetch ( $object -> socid );
$author = new User ( $db );
$author -> id = $object -> user_author_id ;
$author -> fetch ();
if ( $conf -> stock -> enabled ) $entrepot = new Entrepot ( $db );
/*
* Document source
*/
print '<form action="fiche.php" method="post">' ;
print '<input type="hidden" name="action" value="add">' ;
print '<input type="hidden" name="origin" value="' . $origin . '">' ;
print '<input type="hidden" name="object_id" value="' . $object -> id . '">' ;
if ( $_GET [ " entrepot_id " ])
{
print '<input type="hidden" name="entrepot_id" value="' . $_GET [ " entrepot_id " ] . '">' ;
}
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="30%">' ;
if ( $conf -> commande -> enabled )
{
print $langs -> trans ( " RefOrder " ) . '</td><td colspan="3"><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $object -> id . '">' . img_object ( $langs -> trans ( " ShowOrder " ), 'order' ) . ' ' . $object -> ref ;
}
else
{
print $langs -> trans ( " RefProposal " ) . '</td><td colspan="3"><a href="' . DOL_URL_ROOT . '/comm/fiche.php?propalid=' . $object -> id . '">' . img_object ( $langs -> trans ( " ShowProposal " ), 'propal' ) . ' ' . $object -> ref ;
}
print '</a></td>' ;
print " </tr> \n " ;
// Ref client
print '<tr><td>' ;
print $langs -> trans ( 'RefCustomer' ) . '</td><td colspan="3">' ;
print $object -> ref_client ;
print '</td>' ;
print '</tr>' ;
// Tiers
print '<tr><td>' . $langs -> trans ( 'Company' ) . '</td>' ;
print '<td colspan="3">' . $soc -> getNomUrl ( 1 ) . '</td>' ;
print '</tr>' ;
// Date
print " <tr><td> " . $langs -> trans ( " Date " ) . " </td> " ;
print '<td colspan="3">' . dolibarr_print_date ( $object -> date , " day " ) . " </td></tr> \n " ;
// Entrepot (si forc<72> )
if ( $conf -> stock -> enabled && $_GET [ " entrepot_id " ])
{
print '<tr><td>' . $langs -> trans ( " Warehouse " ) . '</td>' ;
print '<td colspan="3">' ;
$ents = $entrepot -> list_array ();
print '<a href="' . DOL_URL_ROOT . '/product/stock/fiche.php?id=' . $_GET [ " entrepot_id " ] . '">' . img_object ( $langs -> trans ( " ShowWarehouse " ), 'stock' ) . ' ' . $ents [ $_GET [ " entrepot_id " ]] . '</a>' ;
print '</td></tr>' ;
}
if ( $object -> note && ! $user -> societe_id )
{
print '<tr><td colspan="3">' . $langs -> trans ( " NotePrivate " ) . ': ' . nl2br ( $object -> note ) . " </td></tr> " ;
}
// Delivery method
print " <tr><td> " . $langs -> trans ( " DeliveryMethod " ) . " </td> " ;
print '<td colspan="3">' ;
$expe -> fetch_delivery_methods ();
$html -> select_array ( " expedition_method_id " , $expe -> meths );
print " </td></tr> \n " ;
// Tracking number
print " <tr><td> " . $langs -> trans ( " TrackingNumber " ) . " </td> " ;
print '<td colspan="3">' ;
print '<input name="tracking_number" size="20">' ;
print " </td></tr> \n " ;
print " </table> " ;
/*
* Lignes de commandes
*
*/
print '<br><table class="noborder" width="100%">' ;
//$lignes = $object->fetch_lines(1);
$numAsked = sizeof ( $object -> lignes );
/* Lecture des expeditions d<> j<EFBFBD> effectu<74> es */
$object -> loadExpeditions ();
if ( $numAsked )
{
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " QtyOrdered " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " QtyShipped " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " QtyToShip " ) . '</td>' ;
if ( $conf -> stock -> enabled )
{
if ( $_GET [ " entrepot_id " ])
{
print '<td align="right">' . $langs -> trans ( " Stock " ) . '</td>' ;
}
else
{
print '<td align="left">' . $langs -> trans ( " Warehouse " ) . '</td>' ;
}
}
print " </tr> \n " ;
}
$var = true ;
$indiceAsked = 0 ;
while ( $indiceAsked < $numAsked )
{
$ligne = $object -> lignes [ $indiceAsked ];
$var =! $var ;
print " <tr " . $bc [ $var ] . " > \n " ;
if ( $ligne -> fk_product > 0 )
{
$product = new Product ( $db );
$product -> fetch ( $ligne -> fk_product );
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $ligne -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $product -> ref . '</a> - ' . $product -> libelle ;
if ( $ligne -> desc ) print nl2br ( $ligne -> desc );
print '</td>' ;
}
else
{ var_dump ( $ligne );
print " <td> " . nl2br ( $ligne -> desc ) . " </td> \n " ;
}
print '<td align="center">' . $ligne -> qty . '</td>' ;
print '<td align="center">' ;
$quantityDelivered = $object -> expeditions [ $ligne -> id ];
print $quantityDelivered ;
print '</td>' ;
$quantityAsked = $ligne -> qty ;
$quantityToBeDelivered = $quantityAsked - $quantityDelivered ;
if ( $conf -> stock -> enabled )
{
$defaultqty = 0 ;
if ( $_GET [ " entrepot_id " ])
{
$stock = $product -> stock_entrepot [ $_GET [ " entrepot_id " ]];
$stock += 0 ; // Convertit en num<75> rique
$defaultqty = min ( $quantityToBeDelivered , $stock );
if ( $defaultqty < 0 ) $defaultqty = 0 ;
}
// Quantit<69> <20> livrer
print '<td align="center">' ;
print '<input name="idl' . $indiceAsked . '" type="hidden" value="' . $ligne -> id . '">' ;
print '<input name="qtyl' . $indiceAsked . '" type="text" size="4" value="' . $defaultqty . '">' ;
print '</td>' ;
// Stock
if ( $_GET [ " entrepot_id " ])
{
print '<td align="right">' . $stock ;
if ( $stock < $quantityToBeDelivered )
{
print ' ' . img_warning ( $langs -> trans ( " StockTooLow " ));
}
print '</td>' ;
}
else
{
$array = array ();
$sql = " SELECT e.rowid, e.label, ps.reel " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " product_stock as ps, " . MAIN_DB_PREFIX . " entrepot as e " ;
$sql .= " WHERE ps.fk_entrepot = e.rowid AND fk_product = ' " . $product -> id . " ' " ;
$result = $db -> query ( $sql ) ;
if ( $result )
{
$num = $db -> num_rows ( $result );
$i = 0 ;
if ( $num > 0 )
{
while ( $i < $num )
{
$obj = $db -> fetch_object ( $result );
$array [ $obj -> rowid ] = $obj -> label . ' (' . $obj -> reel . ')' ;
$i ++ ;
}
}
$db -> free ( $result );
}
else
{
$this -> error = $db -> error ();
return - 1 ;
}
print '<td align="left">' ;
$html -> select_array ( 'entl' . $i , $array , '' , 1 , 0 , 0 );
print '</td>' ;
}
}
else
{
// Quantit<69> <20> livrer
print '<td align="center">' ;
print '<input name="idl' . $indiceAsked . '" type="hidden" value="' . $ligne -> id . '">' ;
print '<input name="qtyl' . $indiceAsked . '" type="text" size="6" value="' . $quantityToBeDelivered . '">' ;
print '</td>' ;
}
print " </tr> \n " ;
$indiceAsked ++ ;
2008-05-17 03:52:24 +02:00
}
2008-09-02 03:42:31 +02:00
2008-05-17 03:52:24 +02:00
/*
2008-09-01 15:22:36 +02:00
*
*/
2008-09-02 03:42:31 +02:00
2008-05-17 03:52:24 +02:00
print '<tr><td align="center" colspan="5"><br><input type="submit" class="button" value="' . $langs -> trans ( " Create " ) . '"></td></tr>' ;
print " </table> " ;
print '</form>' ;
2008-09-02 03:42:31 +02:00
}
else
{
2008-10-17 16:43:33 +02:00
dolibarr_print_error ( $db );
2008-09-02 03:42:31 +02:00
}
2008-09-01 15:22:36 +02:00
}
2006-07-14 13:31:57 +02:00
}
2006-11-11 01:46:15 +01:00
else
2003-11-13 18:36:45 +01:00
/* *************************************************************************** */
/* */
2008-09-01 15:22:36 +02:00
/* Edit and view mode */
2003-11-13 18:36:45 +01:00
/* */
/* *************************************************************************** */
2006-11-11 01:46:15 +01:00
{
2008-09-02 03:42:31 +02:00
if ( $_GET [ " id " ] > 0 )
2008-09-01 15:22:36 +02:00
{
2008-10-17 16:43:33 +02:00
$expedition = new Expedition ( $db );
2008-09-02 03:42:31 +02:00
$result = $expedition -> fetch ( $_GET [ " id " ]);
if ( $result < 0 )
{
dolibarr_print_error ( $db , $expedition -> error );
exit - 1 ;
}
$lignes = $expedition -> lignes ;
$num_prod = sizeof ( $lignes );
2008-09-01 15:22:36 +02:00
2008-09-02 03:42:31 +02:00
if ( $expedition -> id > 0 )
2008-09-01 15:22:36 +02:00
{
2008-09-11 19:43:04 +02:00
$typeobject = $expedition -> origin ;
2008-09-02 03:42:31 +02:00
$expedition -> fetch_object ();
if ( strlen ( $expedition -> tracking_number ) && strlen ( $expedition -> expedition_method_id )) {
$expedition -> GetUrlTrackingStatus ();
}
$soc = new Societe ( $db );
$soc -> fetch ( $expedition -> socid );
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/fiche.php?id= " . $expedition -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " SendingCard " );
$hselected = $h ;
$h ++ ;
if ( $conf -> livraison_bon -> enabled && $expedition -> livraison_id )
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /livraison/fiche.php?id= " . $expedition -> livraison_id ;
$head [ $h ][ 1 ] = $langs -> trans ( " DeliveryCard " );
$h ++ ;
}
dolibarr_fiche_head ( $head , $hselected , $langs -> trans ( " Sending " ));
if ( $mesg ) print $mesg ;
/*
* Confirmation de la suppression
*
*/
if ( $_GET [ " action " ] == 'delete' )
{
$html -> form_confirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $expedition -> id , $langs -> trans ( 'DeleteSending' ), 'Etes-vous s<> r de vouloir supprimer cette expedition ?' , 'confirm_delete' );
print '<br>' ;
}
/*
* Confirmation de la validation
*
*/
if ( $_GET [ " action " ] == 'valid' )
{
$html -> form_confirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $expedition -> id , $langs -> trans ( 'ValidateSending' ), 'Etes-vous s<> r de vouloir valider cette exp<78> dition ?' , 'confirm_valid' );
print '<br>' ;
}
/*
* Confirmation de l ' annulation
*
*/
if ( $_GET [ " action " ] == 'annuler' )
{
$html -> form_confirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $expedition -> id , $langs -> trans ( 'CancelSending' ), 'Etes-vous s<> r de vouloir annuler cette commande ?' , 'confirm_cancel' );
print '<br>' ;
}
// calcul du poids total et du volume total des produits
//TODO: ajouter conversion pour le poids et le volume et selection de l'unit<69> de mesure la plus utilis<69> e
$totalWeight = '' ;
$totalVolume = '' ;
for ( $i = 0 ; $i < $num_prod ; $i ++ )
{
$totalWeight += $lignes [ $i ] -> weight * $lignes [ $i ] -> qty_shipped ;
$weightUnit = $lignes [ $i ] -> weight_units ;
$totalVolume += $lignes [ $i ] -> volume * $lignes [ $i ] -> qty_shipped ;
$volumeUnit = $lignes [ $i ] -> volume_units ;
}
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td colspan="3">' . $expedition -> ref . '</td></tr>' ;
// Customer
print '<tr><td width="20%">' . $langs -> trans ( " Customer " ) . '</td>' ;
print '<td colspan="3">' . $soc -> getNomUrl ( 1 ) . '</td>' ;
print " </tr> " ;
// Document li<6C> e
print '<tr><td>' ;
if ( $conf -> commande -> enabled )
{
$order = new Commande ( $db );
2008-09-11 19:43:04 +02:00
$order -> fetch ( $expedition -> $typeobject -> id );
2008-09-02 03:42:31 +02:00
print $langs -> trans ( " RefOrder " ) . '</td>' ;
print '<td colspan="3">' ;
print $order -> getNomUrl ( 1 , 4 );
print " </td> \n " ;
}
else
{
$propal = new Propal ( $db );
$propal -> fetch ( $livraison -> origin_id );
print $langs -> trans ( " RefProposal " ) . '</td>' ;
print '<td colspan="3">' ;
print $propal -> getNomUrl ( 1 , 'expedition' );
print " </td> \n " ;
}
print '</tr>' ;
// Ref client
print '<tr><td>' . $langs -> trans ( " RefCustomer " ) . '</td>' ;
print '<td colspan="3">' . $object -> ref_client . " </a></td> \n " ;
print '</tr>' ;
// Date
print '<tr><td>' . $langs -> trans ( " Date " ) . '</td>' ;
2008-10-17 16:43:33 +02:00
print '<td colspan="3">' . dolibarr_print_date ( $expedition -> date , " daytext " ) . " </td> \n " ;
2008-09-02 03:42:31 +02:00
print '</tr>' ;
// Poids Total
print '<tr><td>' . $langs -> trans ( " TotalWeight " ) . '</td>' ;
print '<td colspan="3">' . $totalWeight . ' ' . measuring_units_string ( $weightUnit , " weight " ) . " </td> \n " ;
print '</tr>' ;
// Volume Total
print '<tr><td>' . $langs -> trans ( " TotalVolume " ) . '</td>' ;
print '<td colspan="3">' . $totalVolume . ' ' . measuring_units_string ( $volumeUnit , " volume " ) . " </td> \n " ;
print '</tr>' ;
// Status
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td colspan="3">' . $expedition -> getLibStatut ( 4 ) . " </td> \n " ;
print '</tr>' ;
// Tracking Number
print '<tr><td>' . $langs -> trans ( " TrackingNumber " ) . '</td>' ;
print '<td>' . $expedition -> tracking_number . '</td><td colspan="2">' . $expedition -> tracking_url . " </td> \n " ;
print '</tr>' ;
print " </table> \n " ;
/*
* Lignes produits
*/
print '<br><table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Products " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " QtyOrdered " ) . '</td>' ;
if ( $expedition -> fk_statut <= 1 )
{
print '<td align="center">' . $langs -> trans ( " QtyToShip " ) . '</td>' ;
}
else
{
print '<td align="center">' . $langs -> trans ( " QtyShipped " ) . '</td>' ;
}
print '<td align="center">' . $langs -> trans ( " Weight " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Volume " ) . '</td>' ;
if ( $conf -> stock -> enabled )
{
print '<td align="left">' . $langs -> trans ( " WarehouseSource " ) . '</td>' ;
}
print " </tr> \n " ;
$var = false ;
for ( $i = 0 ; $i < $num_prod ; $i ++ )
{
print " <tr " . $bc [ $var ] . " > " ;
if ( $lignes [ $i ] -> fk_product > 0 )
{
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $lignes [ $i ] -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $lignes [ $i ] -> ref . '</a> - ' . $lignes [ $i ] -> libelle ;
if ( $lignes [ $i ] -> description ) print '<br>' . nl2br ( $lignes [ $i ] -> description );
print '</td>' ;
}
else
{
print " <td> " . nl2br ( $lignes [ $i ] -> description ) . " </td> \n " ;
2006-11-11 01:46:15 +01:00
}
2008-09-02 03:42:31 +02:00
// Qte command<6E>
print '<td align="center">' . $lignes [ $i ] -> qty_asked . '</td>' ;
// Qte a expedier ou expedier
print '<td align="center">' . $lignes [ $i ] -> qty_shipped . '</td>' ;
// Poids
print '<td align="center">' . $lignes [ $i ] -> weight * $lignes [ $i ] -> qty_shipped . ' ' . measuring_units_string ( $lignes [ $i ] -> weight_units , " weight " ) . '</td>' ;
// Volume
print '<td align="center">' . $lignes [ $i ] -> volume * $lignes [ $i ] -> qty_shipped . ' ' . measuring_units_string ( $lignes [ $i ] -> volume_units , " volume " ) . '</td>' ;
// Entrepot source
if ( $conf -> stock -> enabled )
{
$entrepot = new Entrepot ( $db );
$entrepot -> fetch ( $lignes [ $i ] -> entrepot_id );
print '<td align="left">' . $entrepot -> getNomUrl ( 1 ) . '</td>' ;
}
print " </tr> " ;
$var =! $var ;
}
}
print " </table> \n " ;
print " \n </div> \n " ;
/*
* Boutons actions
*/
if ( $user -> societe_id == 0 )
{
print '<div class="tabsAction">' ;
if ( ! eregi ( '^(valid|delete)' , $_REQUEST [ " action " ]))
2008-05-20 02:09:11 +02:00
{
2008-09-02 03:42:31 +02:00
if ( $expedition -> statut == 0 && $user -> rights -> expedition -> valider && $num_prod > 0 )
{
print '<a class="butAction" href="fiche.php?id=' . $expedition -> id . '&action=valid">' . $langs -> trans ( " Validate " ) . '</a>' ;
}
if ( $conf -> livraison_bon -> enabled && $expedition -> statut == 1 && $user -> rights -> expedition -> livraison -> creer && ! $expedition -> livraison_id )
{
print '<a class="butAction" href="fiche.php?id=' . $expedition -> id . '&action=create_delivery">' . $langs -> trans ( " DeliveryOrder " ) . '</a>' ;
}
if ( $expedition -> brouillon && $user -> rights -> expedition -> supprimer )
{
print '<a class="butActionDelete" href="fiche.php?id=' . $expedition -> id . '&action=delete">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
}
print '</div>' ;
}
print " \n " ;
print " <table width= \" 100% \" cellspacing=2><tr><td width= \" 50% \" valign= \" top \" > " ;
/*
2008-10-17 16:43:33 +02:00
* Documents generated
2008-09-02 03:42:31 +02:00
*/
if ( $conf -> expedition_bon -> enabled )
{
$expeditionref = sanitize_string ( $expedition -> ref );
$filedir = $conf -> expedition_bon -> dir_output . " / " . $expeditionref ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $expedition -> id ;
$genallowed = $user -> rights -> expedition -> lire && ( $expedition -> statut > 0 );
$delallowed = $user -> rights -> expedition -> supprimer ;
//$genallowed=1;
//$delallowed=0;
$somethingshown = $formfile -> show_documents ( 'expedition' , $expeditionref , $filedir , $urlsource , $genallowed , $delallowed , $expedition -> modelpdf );
if ( $genallowed && ! $somethingshown ) $somethingshown = 1 ;
}
2008-01-17 11:27:59 +01:00
2008-09-02 03:42:31 +02:00
print '</td><td valign="top" width="50%">' ;
// Rien a droite
2006-05-06 23:09:26 +02:00
2008-09-02 03:42:31 +02:00
print '</td></tr></table>' ;
2006-11-11 01:46:15 +01:00
2008-09-02 03:42:31 +02:00
print '<br>' ;
2008-10-17 16:43:33 +02:00
//show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
show_list_sending_receive ( $expedition -> origin , $expedition -> origin_id );
2008-09-02 03:42:31 +02:00
}
else
{
print " Expedition inexistante ou acc<63> s refus<75> " ;
}
2003-11-13 18:36:45 +01:00
}
$db -> close ();
2005-07-09 03:16:31 +02:00
llxFooter ( '$Date$ - $Revision$' );
2003-11-13 18:36:45 +01:00
?>