2004-10-19 22:43:23 +02:00
< ? php
2005-04-15 12:34:44 +02:00
/* Copyright ( C ) 2003 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2005-04-12 20:21:30 +02:00
* Copyright ( C ) 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-07-09 16:58:25 +02:00
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
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
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
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
/**
\file htdocs / expedition / fiche . php
\ingroup expedition
\brief Fiche descriptive d ' une expedition
\version $Revision $
2004-08-14 15:05:12 +02:00
*/
2003-11-13 18:36:45 +01:00
require ( " ./pre.inc.php " );
2005-09-11 18:51:41 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /product.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /product/stock/entrepot.class.php " );
2003-11-13 18:36:45 +01:00
2005-08-23 21:31:25 +02:00
$langs -> load ( " bills " );
2005-04-15 12:34:44 +02:00
2006-01-14 14:45:04 +01:00
$user -> getrights ( 'expedition' );
2003-11-13 18:36:45 +01:00
if ( ! $user -> rights -> expedition -> lire )
accessforbidden ();
2005-07-09 03:16:31 +02:00
// S<> curit<69> acc<63> s client
2003-11-13 18:36:45 +01:00
if ( $user -> societe_id > 0 )
{
$action = '' ;
$socidp = $user -> societe_id ;
}
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
*/
2004-07-27 11:25:20 +02:00
if ( $_POST [ " action " ] == 'add' )
2003-11-13 18:36:45 +01:00
{
2005-09-22 01:43:07 +02:00
$db -> begin ();
// Creation de l'objet expedition
2005-07-09 03:16:31 +02:00
$expedition = new Expedition ( $db );
$expedition -> date_expedition = time ();
$expedition -> note = $_POST [ " note " ];
$expedition -> commande_id = $_POST [ " commande_id " ];
$expedition -> entrepot_id = $_POST [ " entrepot_id " ];
2005-09-22 01:43:07 +02:00
// On boucle sur chaque ligne de commande pour compl<70> ter objet expedition
// avec qt<71> <20> livrer
2005-07-09 03:16:31 +02:00
$commande = new Commande ( $db );
$commande -> fetch ( $expedition -> commande_id );
$commande -> fetch_lignes ();
for ( $i = 0 ; $i < sizeof ( $commande -> lignes ) ; $i ++ )
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
$qty = " qtyl " . $i ;
$idl = " idl " . $i ;
if ( $_POST [ $qty ] > 0 )
{
$expedition -> addline ( $_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
}
}
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
{
$expedition = new Expedition ( $db );
$expedition -> fetch ( $_GET [ " id " ]);
$result = $expedition -> valid ( $user );
2005-04-16 16:00:07 +02:00
$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
{
if ( $user -> rights -> expedition -> supprimer )
{
$expedition = new Expedition ( $db );
$expedition -> id = $_GET [ " id " ];
$expedition -> delete ();
Header ( " Location: liste.php " );
}
}
2005-07-09 16:58:25 +02:00
/*
* G<EFBFBD> n<EFBFBD> rer ou reg<EFBFBD> n<EFBFBD> rer le PDF
*/
2005-04-16 16:00:07 +02:00
if ( $_GET [ " action " ] == 'pdf' )
{
$expedition = new Expedition ( $db );
$expedition -> fetch ( $_GET [ " id " ]);
$expedition -> PdfWrite ();
}
2005-07-09 03:16:31 +02:00
2003-11-13 18:36:45 +01:00
/*
*
*/
$html = new Form ( $db );
/*********************************************************************
*
* Mode creation
*
2005-07-09 03:16:31 +02:00
*********************************************************************/
if ( $_GET [ " action " ] == 'create' )
2003-11-13 18:36:45 +01:00
{
2004-02-13 18:13:39 +01:00
llxHeader ( '' , 'Fiche expedition' , 'ch-expedition.html' , $form_search );
2005-07-09 03:16:31 +02:00
print_titre ( $langs -> trans ( " CreateASending " ));
2003-11-13 18:36:45 +01:00
2005-07-09 03:16:31 +02:00
if ( $mesg )
{
print $mesg . '<br>' ;
}
2003-11-13 18:36:45 +01:00
$commande = new Commande ( $db );
$commande -> livraison_array ();
2005-07-09 03:16:31 +02:00
if ( $commande -> fetch ( $_GET [ " commande_id " ]))
2003-11-13 18:36:45 +01:00
{
$soc = new Societe ( $db );
$soc -> fetch ( $commande -> soc_id );
$author = new User ( $db );
$author -> id = $commande -> user_author_id ;
$author -> fetch ();
$entrepot = new Entrepot ( $db );
/*
* Commande
*/
print '<form action="fiche.php" method="post">' ;
print '<input type="hidden" name="action" value="add">' ;
print '<input type="hidden" name="commande_id" value="' . $commande -> id . '">' ;
2005-07-09 03:16:31 +02:00
print '<input type="hidden" name="entrepot_id" value="' . $_GET [ " entrepot_id " ] . '">' ;
print '<table class="border" width="100%">' ;
print '<tr><td width="20%">' . $langs -> trans ( " Customer " ) . '</td>' ;
2003-11-19 16:16:32 +01:00
print '<td width="30%"><b><a href="' . DOL_URL_ROOT . '/comm/fiche.php?socid=' . $soc -> id . '">' . $soc -> nom . '</a></b></td>' ;
2003-11-13 18:36:45 +01:00
2003-11-19 16:16:32 +01:00
print '<td width="50%" colspan="2">' ;
2003-11-13 18:36:45 +01:00
print " </td></tr> " ;
2005-07-09 03:16:31 +02:00
print " <tr><td> " . $langs -> trans ( " Date " ) . " </td> " ;
2003-11-13 18:36:45 +01:00
print " <td> " . strftime ( " %A %d %B %Y " , $commande -> date ) . " </td> \n " ;
2005-09-22 01:43:07 +02:00
print '<td>' . $langs -> trans ( " Order " ) . '</td><td><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $commande -> id . '">' . img_object ( $langs -> trans ( " ShowOrder " ), 'order' ) . ' ' . $commande -> ref . '</a>' ;
2003-11-13 18:36:45 +01:00
print " </td></tr> \n " ;
2005-07-09 03:16:31 +02:00
print '<tr><td>' . $langs -> trans ( " Warehouse " ) . '</td>' ;
2003-11-13 18:36:45 +01:00
print '<td>' ;
$ents = $entrepot -> list_array ();
2005-09-22 01:43:07 +02:00
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>' ;
2003-11-13 18:36:45 +01:00
print '</td>' ;
2004-08-02 04:12:01 +02:00
print " <td> " . $langs -> trans ( " Author " ) . " </td><td> $author->fullname </td> \n " ;
2003-11-13 18:36:45 +01:00
if ( $commande -> note )
{
print '<tr><td colspan="3">Note : ' . nl2br ( $commande -> note ) . " </td></tr> " ;
}
print " </table> " ;
/*
* Lignes de commandes
*
*/
2005-07-09 03:16:31 +02:00
echo '<br><table class="noborder" width="100%">' ;
2003-11-13 18:36:45 +01:00
2003-11-27 12:32:08 +01:00
$lignes = $commande -> fetch_lignes ( 1 );
2003-11-13 18:36:45 +01:00
2005-04-15 12:34:44 +02:00
/* Lecture des livraisons d<> j<EFBFBD> effectu<74> es */
$commande -> livraison_array ();
2003-11-13 18:36:45 +01:00
$num = sizeof ( $commande -> lignes );
2005-04-15 12:34:44 +02:00
$i = 0 ;
2003-11-13 18:36:45 +01:00
if ( $num )
{
print '<tr class="liste_titre">' ;
2004-08-29 21:03:50 +02:00
print '<td width="54%">' . $langs -> trans ( " Description " ) . '</td>' ;
2003-11-13 18:36:45 +01:00
print '<td align="center">Quan. command<6E> e</td>' ;
print '<td align="center">Quan. livr<76> e</td>' ;
print '<td align="center">Quan. <20> livrer</td>' ;
2005-07-09 03:16:31 +02:00
if ( $conf -> stock -> enabled )
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
print '<td width="12%" align="center">' . $langs -> trans ( " Stock " ) . '</td>' ;
2003-11-13 18:36:45 +01:00
}
print " </tr> \n " ;
}
2005-07-09 03:16:31 +02:00
$var = true ;
2003-11-13 18:36:45 +01:00
while ( $i < $num )
{
$ligne = $commande -> lignes [ $i ];
2005-07-09 03:16:31 +02:00
$var =! $var ;
2003-11-13 18:36:45 +01:00
print " <tr $bc[$var] > \n " ;
if ( $ligne -> product_id > 0 )
{
$product = new Product ( $db );
$product -> fetch ( $ligne -> product_id );
print '<td>' ;
2005-09-22 01:43:07 +02:00
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $ligne -> product_id . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $product -> ref . '</a> - ' . $product -> libelle ;
if ( $ligne -> description ) print nl2br ( $ligne -> description );
print '</td>' ;
2003-11-13 18:36:45 +01:00
}
else
{
2005-07-09 03:16:31 +02:00
print " <td> " . nl2br ( $ligne -> description ) . " </td> \n " ;
2003-11-13 18:36:45 +01:00
}
print '<td align="center">' . $ligne -> qty . '</td>' ;
/*
*
*/
print '<td align="center">' ;
$quantite_livree = $commande -> livraisons [ $ligne -> product_id ];
print $quantite_livree ;;
print '</td>' ;
2005-09-22 01:43:07 +02:00
2003-11-13 18:36:45 +01:00
$quantite_commandee = $ligne -> qty ;
$quantite_a_livrer = $quantite_commandee - $quantite_livree ;
2005-09-22 01:43:07 +02:00
if ( $conf -> stock -> enabled )
{
$stock = $product -> stock_entrepot [ $_GET [ " entrepot_id " ]];
$stock += 0 ; // Convertit en num<75> rique
// Quantit<69> <20> livrer
print '<td align="center">' ;
print '<input name="idl' . $i . '" type="hidden" value="' . $ligne -> id . '">' ;
print '<input name="qtyl' . $i . '" type="text" size="6" value="' . min ( $quantite_a_livrer , $stock ) . '">' ;
print '</td>' ;
// Stock
if ( $stock < $quantite_a_livrer )
{
print '<td align="center" class="alerte">' . $stock . '</td>' ;
}
else
{
print '<td align="center">' . $stock . '</td>' ;
}
}
else
{
// Quantit<69> <20> livrer
print '<td align="center">' ;
print '<input name="idl' . $i . '" type="hidden" value="' . $ligne -> id . '">' ;
print '<input name="qtyl' . $i . '" type="text" size="6" value="' . $quantite_a_livrer . '">' ;
print '</td>' ;
}
2003-11-13 18:36:45 +01:00
print " </tr> \n " ;
$i ++ ;
$var =! $var ;
}
/*
*
*/
2006-01-14 14:45:04 +01:00
print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="' . $langs -> trans ( " Create " ) . '"></td></tr>' ;
2003-11-13 18:36:45 +01:00
print " </table> " ;
print '</form>' ;
}
else
{
2005-07-09 03:16:31 +02:00
dolibarr_print_error ( $db );
2003-11-13 18:36:45 +01:00
}
}
else
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
{
2006-01-14 14:45:04 +01:00
if ( $_GET [ " id " ] > 0 )
2003-11-13 18:36:45 +01:00
{
2006-01-14 14:45:04 +01:00
$expedition = New Expedition ( $db );
$result = $expedition -> fetch ( $_GET [ " id " ]);
if ( $expedition -> id > 0 )
2005-09-22 01:43:07 +02:00
{
2006-01-14 14:45:04 +01:00
$author = new User ( $db );
$author -> id = $expedition -> user_author_id ;
$author -> fetch ();
llxHeader ( '' , 'Fiche expedition' , 'ch-expedition.html' , $form_search , $author );
$commande = New Commande ( $db );
$commande -> fetch ( $expedition -> commande_id );
$soc = new Societe ( $db );
$soc -> fetch ( $commande -> soc_id );
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /expedition/fiche.php?id= " . $expedition -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " SendingCard " );
$hselected = $h ;
$h ++ ;
dolibarr_fiche_head ( $head , $hselected , $langs -> trans ( " Sending " ));
/*
* Confirmation de la suppression
*
*/
if ( $_GET [ " action " ] == 'delete' )
{
$html -> form_confirm ( " fiche.php?id= $expedition->id " , " Supprimer l'expedition " , " Etes-vous s<> r de vouloir supprimer cette expedition ? " , " confirm_delete " );
print '<br>' ;
}
/*
* Confirmation de la validation
*
*/
if ( $_GET [ " action " ] == 'valid' )
{
$html -> form_confirm ( " fiche.php?id= $expedition->id " , " Valider l'exp<78> dition " , " Etes-vous s<> r de vouloir valider cette exp<78> dition ? " , " confirm_valid " );
print '<br>' ;
}
/*
* Confirmation de l ' annulation
*
*/
if ( $_GET [ " action " ] == 'annuler' )
2005-09-22 01:43:07 +02:00
{
2006-01-14 14:45:04 +01:00
$html -> form_confirm ( " fiche.php?id= $expedition->id " , $langs -> trans ( " Cancel " ), " Etes-vous s<> r de vouloir annuler cette commande ? " , " confirm_cancel " );
2005-09-22 01:43:07 +02:00
print '<br>' ;
2006-01-14 14:45:04 +01:00
}
/*
* Commande
*/
if ( $commande -> brouillon == 1 && $user -> rights -> commande -> creer )
{
print '<form action="fiche.php?id=' . $expedition -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="setremise">' ;
}
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td colspan="3">' . $expedition -> ref . '</td></tr>' ;
// Client
print '<tr><td width="20%">' . $langs -> trans ( " Customer " ) . '</td>' ;
print '<td width="30%">' ;
print '<b><a href="' . DOL_URL_ROOT . '/comm/fiche.php?socid=' . $soc -> id . '">' . $soc -> nom . '</a></b></td>' ;
// Auteur
print '<td width="20%">' . $langs -> trans ( " Author " ) . '</td><td width="30%">' . $author -> fullname . '</td>' ;
print " </tr> " ;
// Commande li<6C> e
print '<tr><td>' . $langs -> trans ( " Order " ) . '</td>' ;
print '<td><a href="' . DOL_URL_ROOT . '/expedition/commande.php?id=' . $commande -> id . '">' . $commande -> ref . " </a></td> \n " ;
print '<td> </td><td> </td></tr>' ;
// Date
print '<tr><td>' . $langs -> trans ( " Date " ) . '</td>' ;
print " <td> " . strftime ( " %A %d %B %Y " , $expedition -> date ) . " </td> \n " ;
// Entrepot
$entrepot = new Entrepot ( $db );
$entrepot -> fetch ( $expedition -> entrepot_id );
print '<td width="20%">' . $langs -> trans ( " Warehouse " ) . '</td><td><a href="' . DOL_URL_ROOT . '/product/stock/fiche.php?id=' . $entrepot -> id . '">' . $entrepot -> libelle . '</a></td></tr>' ;
print " </table> \n " ;
/*
* Lignes produits
*/
echo '<br><table class="noborder" width="100%">' ;
$sql = " SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande " ;
$sql .= " , ed.qty as qty_livre " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commandedet as cd , " . MAIN_DB_PREFIX . " expeditiondet as ed " ;
$sql .= " WHERE ed.fk_expedition = $expedition->id AND cd.rowid = ed.fk_commande_ligne " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num_prod = $db -> num_rows ( $resql );
$i = 0 ;
2005-09-22 01:43:07 +02:00
print '<tr class="liste_titre">' ;
2006-01-14 14:45:04 +01:00
print '<td width="54%">' . $langs -> trans ( " Products " ) . '</td>' ;
print '<td align="center">Quan. command<6E> e</td>' ;
2005-09-22 01:43:07 +02:00
print '<td align="center">Quan. livr<76> e</td>' ;
print " </tr> \n " ;
2006-01-14 14:45:04 +01:00
$var = true ;
while ( $i < $num_prod )
2005-09-22 01:43:07 +02:00
{
$objp = $db -> fetch_object ( $resql );
2006-01-14 14:45:04 +01:00
$var =! $var ;
2005-09-22 01:43:07 +02:00
print " <tr $bc[$var] > " ;
if ( $objp -> fk_product > 0 )
{
2006-01-14 14:45:04 +01:00
$product = new Product ( $db );
$product -> fetch ( $objp -> fk_product );
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $product -> ref . '</a> - ' . $product -> libelle ;
if ( $objp -> description ) print nl2br ( $objp -> description );
print '</td>' ;
2005-09-22 01:43:07 +02:00
}
else
{
print " <td> " . stripslashes ( nl2br ( $objp -> description )) . " </td> \n " ;
}
2006-01-14 14:45:04 +01:00
print '<td align="center">' . $objp -> qty_commande . '</td>' ;
2005-09-22 01:43:07 +02:00
print '<td align="center">' . $objp -> qty_livre . '</td>' ;
2006-01-14 14:45:04 +01:00
print " </tr> " ;
2005-09-22 01:43:07 +02:00
$i ++ ;
2006-01-14 14:45:04 +01:00
$var =! $var ;
2005-09-22 01:43:07 +02:00
}
2006-01-14 14:45:04 +01:00
$db -> free ( $resql );
}
else
{
dolibarr_print_error ( $db );
}
print " </table> \n " ;
print " \n </div> \n " ;
/*
* Boutons actions
*/
if ( $user -> societe_id == 0 )
{
print '<div class="tabsAction">' ;
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>' ;
}
print '<a class="butAction" href="fiche.php?id=' . $expedition -> id . '&action=pdf">' . $langs -> trans ( 'BuildPDF' ) . '</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>' ;
}
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*/
$filename = sanitize_string ( $expedition -> id );
$filedir = $conf -> expedition -> dir_output . " / " . get_exdir ( $expedition -> id );
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $expedition -> id ;
//$genallowed=$user->rights->expedition->creer;
//$delallowed=$user->rights->expedition->supprimer;
$genallowed = 0 ;
$delallowed = 0 ;
$var = true ;
print " <br> \n " ;
$html -> show_documents ( 'expedition' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $expedition -> modelpdf );
/*
* D<EFBFBD> j<EFBFBD> livre
*/
$sql = " SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande " ;
$sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id " ;
$sql .= " , " . $db -> pdate ( " e.date_expedition " ) . " as date_expedition " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commandedet as cd " ;
$sql .= " , " . MAIN_DB_PREFIX . " expeditiondet as ed, " . MAIN_DB_PREFIX . " expedition as e " ;
$sql .= " WHERE cd.fk_commande = " . $expedition -> commande_id ;
$sql .= " AND e.rowid <> " . $expedition -> id ;
$sql .= " AND cd.rowid = ed.fk_commande_ligne " ;
$sql .= " AND ed.fk_expedition = e.rowid " ;
$sql .= " AND e.fk_statut > 0 " ;
$sql .= " ORDER BY cd.fk_product " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
if ( $num )
{
print '<br>' ;
print_titre ( $langs -> trans ( " OtherSendingsForSameOrder " ));
print '<table class="liste" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td width="54%">' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="center">Quan. livr<76> e</td>' ;
print '<td align="center">' . $langs -> trans ( " Sending " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Date " ) . '</td>' ;
print " </tr> \n " ;
$var = True ;
while ( $i < $num )
{
$var =! $var ;
$objp = $db -> fetch_object ( $resql );
print " <tr $bc[$var] > " ;
if ( $objp -> fk_product > 0 )
{
$product = new Product ( $db );
$product -> fetch ( $objp -> fk_product );
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $product -> ref . '</a> - ' . $product -> libelle ;
if ( $objp -> description ) print nl2br ( $objp -> description );
print '</td>' ;
}
else
{
print " <td> " . stripslashes ( nl2br ( $objp -> description )) . " </td> \n " ;
}
print '<td align="center">' . $objp -> qty_livre . '</td>' ;
print '<td align="center"><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp -> expedition_id . '">' . img_object ( $langs -> trans ( " ShowSending " ), 'sending' ) . ' ' . $objp -> ref . '<a></td>' ;
print '<td align="center">' . dolibarr_print_date ( $objp -> date_expedition ) . '</td>' ;
$i ++ ;
}
print '</table>' ;
}
$db -> free ( $resql );
}
else {
dolibarr_print_error ( $db );
}
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*
*/
$file = $conf -> commande -> dir_output . " / " . $commande -> ref . " / " . $commande -> ref . " .pdf " ;
$relativepath = $commande -> ref . " / " . $commande -> ref . " .pdf " ;
$var = true ;
if ( file_exists ( $file ))
{
print " <table width= \" 100% \" cellspacing=2><tr><td width= \" 50% \" valign= \" top \" > " ;
print_titre ( " Documents " );
print '<table width="100%" class="border">' ;
print " <tr $bc[$true] ><td> " . $langs -> trans ( " Order " ) . " PDF</td> " ;
print '<td><a href="' . DOL_URL_ROOT . '/document.php?modulepart=commande&file=' . urlencode ( $relativepath ) . '">' . $commande -> ref . '.pdf</a></td>' ;
print '<td align="right">' . filesize ( $file ) . ' bytes</td>' ;
print '<td align="right">' . strftime ( " %d %b %Y %H:%M:%S " , filemtime ( $file )) . '</td>' ;
print '</tr>' ;
print " </table> \n " ;
print '</td><td valign="top" width="50%">' ;
print_titre ( " Actions " );
/*
* Liste des actions
*
*/
$sql = " SELECT " . $db -> pdate ( " a.datea " ) . " as da, a.note " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
$sql .= " WHERE a.fk_soc = $commande->socidp AND a.fk_action in (9,10) " ;
$sql .= " AND a.fk_commande = $expedition->id " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
if ( $num )
{
$i = 0 ;
print '<table class="border" width="100%">' ;
print " <tr $bc[$var] ><td> " . $langs -> trans ( " Date " ) . " </td><td> " . $langs -> trans ( " Action " ) . " </td></tr> \n " ;
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
$var =! $var ;
print " <tr $bc[$var] > " ;
print " <td> " . strftime ( " %d %B %Y " , $objp -> da ) . " </td> \n " ;
print '<td>' . stripslashes ( $objp -> note ) . '</td>' ;
print " </tr> " ;
$i ++ ;
}
print " </table> " ;
}
$db -> free ( $resql );
}
else
{
dolibarr_print_error ( $db );
}
/*
*
*
*/
print " </td></tr></table> " ;
}
/*
*
*
*/
if ( $action == 'presend' )
{
$replytoname = $user -> fullname ;
$from_name = $replytoname ;
$replytomail = $user -> email ;
$from_mail = $replytomail ;
print " <form method= \" post \" action= \" fiche.php?id= $expedition->id &action=send \" > \n " ;
print '<input type="hidden" name="replytoname" value="' . $replytoname . '">' ;
print '<input type="hidden" name="replytomail" value="' . $replytomail . '">' ;
print " <p><b>Envoyer la commande par mail</b> " ;
print " <table cellspacing=0 border=1 cellpadding=3> " ;
print '<tr><td>Destinataire</td><td colspan="5">' ;
$form = new Form ( $db );
$form -> select_array ( " destinataire " , $soc -> contact_email_array ());
print " </td><td><input size= \" 30 \" name= \" sendto \" value= \" $commande->email\ " ></ td ></ tr > " ;
print " <tr><td>Exp<78> diteur</td><td colspan= \" 5 \" > $from_name </td><td> $from_mail </td></tr> " ;
print " <tr><td>Reply-to</td><td colspan= \" 5 \" > $replytoname </td> " ;
print " <td> $replytomail </td></tr></table> " ;
print " <input type= \" submit \" value= \" Envoyer \" ></form> " ;
2005-09-22 01:43:07 +02:00
}
}
2006-01-14 14:45:04 +01:00
else
{
/* Expedition non trouv<75> e */
llxHeader ( '' , 'Fiche expedition' , 'ch-expedition.html' , $form_search );
print " Expedition inexistante ou acc<63> s refus<75> " ;
}
2005-04-15 12:34:44 +02:00
}
2006-01-14 14:45:04 +01:00
else
2005-04-15 12:34:44 +02:00
{
2006-01-14 14:45:04 +01:00
/* Expedition non trouv<75> e */
llxHeader ( '' , 'Fiche expedition' , 'ch-expedition.html' , $form_search );
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
?>