2004-10-19 22:43:23 +02:00
< ? php
2006-02-08 17:51:38 +01:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 - 2006 Regis Houssin < regis . houssin @ cap - networks . 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/fiche.php
2005-04-12 20:21:30 +02:00
/**
\file htdocs / expedition / commande . php
2005-07-09 03:16:31 +02:00
\ingroup 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 " );
2006-01-14 14:45:04 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /project.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /product/stock/entrepot.class.php " );
2006-05-06 21:06:40 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/order.lib.php " );
2005-09-11 18:51:41 +02:00
2006-06-07 01:11:36 +02:00
$langs -> load ( 'orders' );
2006-06-03 16:59:59 +02:00
$langs -> load ( " companies " );
2006-04-29 17:09:44 +02:00
$langs -> load ( " bills " );
2006-06-07 01:11:36 +02:00
$langs -> load ( 'propal' );
2006-06-01 12:40:37 +02:00
$langs -> load ( 'deliveries' );
2006-07-14 13:31:57 +02:00
$langs -> load ( 'stocks' );
2003-11-13 18:36:45 +01:00
$user -> getrights ( 'commande' );
$user -> getrights ( 'expedition' );
if ( ! $user -> rights -> commande -> lire )
2006-01-14 14:45:04 +01:00
accessforbidden ();
2003-11-13 18:36:45 +01:00
2005-07-09 03:16:31 +02:00
// S<> curit<69> acc<63> s client
if ( $user -> societe_id > 0 )
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
$action = '' ;
$socidp = $user -> societe_id ;
2003-11-13 18:36:45 +01:00
}
2005-07-09 03:16:31 +02:00
/*
* Actions
*/
if ( $_POST [ " action " ] == 'confirm_cloture' && $_POST [ " confirm " ] == 'yes' )
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
$commande = new Commande ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$result = $commande -> cloture ( $user );
2003-11-13 18:36:45 +01:00
}
2006-01-14 14:45:04 +01:00
$html = new Form ( $db );
2003-11-13 18:36:45 +01:00
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
2005-09-04 19:13:55 +02:00
llxHeader ( '' , $langs -> trans ( " OrderCard " ));
2005-07-09 03:16:31 +02:00
2003-11-25 12:07:18 +01:00
if ( $_GET [ " id " ] > 0 )
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
$commande = New Commande ( $db );
if ( $commande -> fetch ( $_GET [ " id " ]) > 0 )
{
2006-05-29 16:37:13 +02:00
$commande -> expedition_array ( 1 );
2005-07-09 03:16:31 +02:00
$soc = new Societe ( $db );
2006-06-19 22:35:22 +02:00
$soc -> fetch ( $commande -> socidp );
2005-07-09 03:16:31 +02:00
$author = new User ( $db );
$author -> id = $commande -> user_author_id ;
$author -> fetch ();
2006-05-06 21:06:40 +02:00
$head = commande_prepare_head ( $commande );
dolibarr_fiche_head ( $head , 'shipping' , $langs -> trans ( " CustomerOrder " ));
2005-08-23 21:31:25 +02:00
2005-07-09 03:16:31 +02:00
/*
2005-08-23 21:31:25 +02:00
* Confirmation de la validation
*
*/
2005-07-09 03:16:31 +02:00
if ( $_GET [ " action " ] == 'cloture' )
{
$html -> form_confirm ( " commande.php?id= " . $_GET [ " id " ], " Cl<EFBFBD> turer la commande " , " Etes-vous s<> r de vouloir cl<63> turer cette commande ? " , " confirm_cloture " );
print " <br /> " ;
}
2006-01-14 14:45:04 +01:00
// Onglet commande
2006-04-29 17:09:44 +02:00
$nbrow = 8 ;
if ( $conf -> projet -> enabled ) $nbrow ++ ;
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="18%">' . $langs -> trans ( 'Ref' ) . '</td>' ;
print '<td colspan="3">' . $commande -> ref . '</td>' ;
print '</tr>' ;
// Ref commande client
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>' ;
print $langs -> trans ( 'RefCustomer' ) . '</td><td align="left">' ;
print '</td>' ;
2006-06-01 18:44:09 +02:00
if ( $_GET [ 'action' ] != 'refcdeclient' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=refcdeclient&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'Edit' )) . '</a></td>' ;
2006-04-29 17:09:44 +02:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $user -> rights -> commande -> creer && $_GET [ 'action' ] == 'refcdeclient' )
{
print '<form action="fiche.php?id=' . $id . '" method="post">' ;
print '<input type="hidden" name="action" value="set_ref_client">' ;
print '<input type="text" class="flat" size="20" name="ref_client" value="' . $commande -> ref_client . '">' ;
print ' <input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
print $commande -> ref_client ;
}
print '</td>' ;
print '</tr>' ;
// Soci<63> t<EFBFBD>
print '<tr><td>' . $langs -> trans ( 'Company' ) . '</td>' ;
2006-06-24 16:20:26 +02:00
print '<td colspan="3">' . $soc -> getNomUrl ( 1 ) . '</td>' ;
2006-04-29 17:09:44 +02:00
print '</tr>' ;
2006-06-03 16:59:59 +02:00
// Ligne info remises tiers
print '<tr><td>' . $langs -> trans ( 'Discounts' ) . '</td><td colspan="3">' ;
if ( $soc -> remise_client ) print $langs -> trans ( " CompanyHasRelativeDiscount " , $soc -> remise_client );
else print $langs -> trans ( " CompanyHasNoRelativeDiscount " );
$absolute_discount = $soc -> getCurrentDiscount ();
print '. ' ;
if ( $absolute_discount ) print $langs -> trans ( " CompanyHasAbsoluteDiscount " , $absolute_discount , $langs -> trans ( " Currency " . $conf -> monnaie ));
else print $langs -> trans ( " CompanyHasNoAbsoluteDiscount " );
print '.' ;
print '</td></tr>' ;
// Date
2006-04-29 17:09:44 +02:00
print '<tr><td>' . $langs -> trans ( 'Date' ) . '</td>' ;
print '<td colspan="2">' . dolibarr_print_date ( $commande -> date , '%A %d %B %Y' ) . '</td>' ;
print '<td width="50%">' . $langs -> trans ( 'Source' ) . ' : ' . $commande -> sources [ $commande -> source ] ;
if ( $commande -> source == 0 )
{
// Si source = propal
$propal = new Propal ( $db );
$propal -> fetch ( $commande -> propale_id );
print ' -> <a href="' . DOL_URL_ROOT . '/comm/propal.php?propalid=' . $propal -> id . '">' . $propal -> ref . '</a>' ;
}
print '</td>' ;
print '</tr>' ;
// Date de livraison
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DateDelivery' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editdate_livraison' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdate_livraison&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'SetDateDelivery' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="2">' ;
if ( $_GET [ 'action' ] == 'editdate_livraison' )
{
print '<form name="setdate_livraison" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $commande -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="setdate_livraison">' ;
$html -> select_date ( $commande -> date_livraison , 'liv_' , '' , '' , '' , " setdate_livraison " );
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
print dolibarr_print_date ( $commande -> date_livraison , '%A %d %B %Y' );
}
print '</td>' ;
print '<td rowspan="' . $nbrow . '" valign="top">' . $langs -> trans ( 'NotePublic' ) . ' :<br>' ;
2006-05-26 09:31:09 +02:00
print nl2br ( $commande -> note_public );
2006-04-29 17:09:44 +02:00
print '</td>' ;
print '</tr>' ;
// Adresse de livraison
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DeliveryAddress' );
print '</td>' ;
2006-06-19 22:35:22 +02:00
if ( $_GET [ 'action' ] != 'editdelivery_adress' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdelivery_adress&socid=' . $commande -> socidp . '&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'SetDeliveryAddress' ), 1 ) . '</a></td>' ;
2006-04-29 17:09:44 +02:00
print '</tr></table>' ;
print '</td><td colspan="2">' ;
if ( $_GET [ 'action' ] == 'editdelivery_adress' )
{
$html -> form_adresse_livraison ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> adresse_livraison_id , $_GET [ 'socid' ], 'adresse_livraison_id' , 'commande' , $commande -> id );
}
else
{
$html -> form_adresse_livraison ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> adresse_livraison_id , $_GET [ 'socid' ], 'none' , 'commande' , $commande -> id );
}
print '</td></tr>' ;
// Conditions et modes de r<> glement
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
2006-05-26 09:34:38 +02:00
print $langs -> trans ( 'PaymentConditionsShort' );
2006-04-29 17:09:44 +02:00
print '</td>' ;
if ( $_GET [ 'action' ] != 'editconditions' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="2">' ;
if ( $_GET [ 'action' ] == 'editconditions' )
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> cond_reglement_id , 'cond_reglement_id' );
}
else
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> cond_reglement_id , 'none' );
}
print '</td></tr>' ;
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentMode' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editmode' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="2">' ;
if ( $_GET [ 'action' ] == 'editmode' )
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> mode_reglement_id , 'mode_reglement_id' );
}
else
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> mode_reglement_id , 'none' );
}
print '</td></tr>' ;
// Projet
if ( $conf -> projet -> enabled )
{
$langs -> load ( 'projects' );
print '<tr><td height="10">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'Project' );
print '</td>' ;
2006-06-01 18:44:09 +02:00
if ( $_GET [ 'action' ] != 'classer' && $commande -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classer&id=' . $commande -> id . '">' . img_edit ( $langs -> trans ( 'SetProject' )) . '</a></td>' ;
2006-04-29 17:09:44 +02:00
print '</tr></table>' ;
print '</td><td colspan="2">' ;
if ( $_GET [ 'action' ] == 'classer' )
{
2006-06-19 22:35:22 +02:00
$html -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> socidp , $commande -> projet_id , 'projetid' );
2006-04-29 17:09:44 +02:00
}
else
{
2006-06-19 22:35:22 +02:00
$html -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $commande -> id , $commande -> socidp , $commande -> projet_id , 'none' );
2006-04-29 17:09:44 +02:00
}
print '</td></tr>' ;
}
2005-07-09 03:16:31 +02:00
2006-04-29 17:09:44 +02:00
// Lignes de 3 colonnes
// Total HT
2006-07-01 01:38:12 +02:00
print '<tr><td>' . $langs -> trans ( 'AmountHT' ) . '</td>' ;
2006-04-29 17:09:44 +02:00
print '<td align="right"><b>' . price ( $commande -> total_ht ) . '</b></td>' ;
print '<td>' . $langs -> trans ( 'Currency' . $conf -> monnaie ) . '</td></tr>' ;
// Total TVA
2006-07-01 01:38:12 +02:00
print '<tr><td>' . $langs -> trans ( 'AmountVAT' ) . '</td><td align="right">' . price ( $commande -> total_tva ) . '</td>' ;
2006-04-29 17:09:44 +02:00
print '<td>' . $langs -> trans ( 'Currency' . $conf -> monnaie ) . '</td></tr>' ;
// Total TTC
2006-07-01 01:38:12 +02:00
print '<tr><td>' . $langs -> trans ( 'AmountTTC' ) . '</td><td align="right">' . price ( $commande -> total_ttc ) . '</td>' ;
2006-04-29 17:09:44 +02:00
print '<td>' . $langs -> trans ( 'Currency' . $conf -> monnaie ) . '</td></tr>' ;
// Statut
print '<tr><td>' . $langs -> trans ( 'Status' ) . '</td>' ;
print '<td colspan="2">' . $commande -> getLibStatut ( 4 ) . '</td>' ;
print '</tr>' ;
print '</table><br>' ;
2005-08-23 21:31:25 +02:00
2005-09-04 19:13:55 +02:00
/**
* Lignes de commandes avec quantit<EFBFBD> livr<EFBFBD> es et reste <EFBFBD> livrer
2006-07-14 13:31:57 +02:00
* Les quantit<EFBFBD> s livr<EFBFBD> es sont stock<EFBFBD> es dans $commande -> expeditions [ fk_product ]
2005-08-23 21:31:25 +02:00
*/
2006-04-29 17:09:44 +02:00
echo '<table class="liste" width="100%">' ;
2005-07-09 03:16:31 +02:00
$sql = " SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commandedet as l " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON l.fk_product = p.rowid " ;
$sql .= " WHERE l.fk_commande = " . $commande -> id ;
$sql .= " AND p.fk_product_type <> 1 " ;
$sql .= " ORDER BY l.rowid " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2005-09-22 01:43:07 +02:00
$i = 0 ;
2005-07-09 03:16:31 +02:00
print '<tr class="liste_titre">' ;
2005-09-04 19:13:55 +02:00
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 ( " KeepToShip " ) . '</td>' ;
2005-07-09 03:16:31 +02:00
if ( $conf -> stock -> enabled )
{
2005-09-04 19:13:55 +02:00
print '<td align="center">' . $langs -> trans ( " Stock " ) . '</td>' ;
2005-07-09 03:16:31 +02:00
}
2006-05-01 23:53:00 +02:00
else
{
print '<td> </td>' ;
}
2005-07-09 03:16:31 +02:00
print " </tr> \n " ;
$var = true ;
$reste_a_livrer = array ();
while ( $i < $num )
{
2006-01-14 14:45:04 +01:00
$objp = $db -> fetch_object ( $resql );
2005-07-09 03:16:31 +02:00
$var =! $var ;
print " <tr $bc[$var] > " ;
if ( $objp -> fk_product > 0 )
{
$product = new Product ( $db );
$product -> fetch ( $objp -> fk_product );
print '<td>' ;
2005-09-04 19:13:55 +02:00
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' ;
print img_object ( $langs -> trans ( " Product " ), " product " ) . ' ' . $product -> ref . '</a>' ;
print $product -> libelle ? ' - ' . $product -> libelle : '' ;
print '</td>' ;
2005-07-09 03:16:31 +02:00
}
else
{
2006-07-14 13:31:57 +02:00
print " <td> " . nl2br ( $objp -> description ) . " </td> \n " ;
2005-07-09 03:16:31 +02:00
}
print '<td align="center">' . $objp -> qty . '</td>' ;
print '<td align="center">' ;
2006-05-29 16:41:06 +02:00
$quantite_livree = $commande -> expeditions [ $objp -> fk_product ];
2005-07-09 03:16:31 +02:00
print $quantite_livree ;
print '</td>' ;
$reste_a_livrer [ $objp -> fk_product ] = $objp -> qty - $quantite_livree ;
2006-07-14 13:31:57 +02:00
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer [ $objp -> fk_product ];
2005-07-09 03:16:31 +02:00
print '<td align="center">' ;
print $reste_a_livrer [ $objp -> fk_product ];
print '</td>' ;
if ( $conf -> stock -> enabled )
{
2006-07-14 13:31:57 +02:00
print '<td align="center">' ;
print $product -> stock_reel ;
if ( $product -> stock_reel < $reste_a_livrer [ $objp -> fk_product ])
2005-07-09 03:16:31 +02:00
{
2006-07-14 13:31:57 +02:00
print ' ' . img_warning ( $langs -> trans ( " StockTooLow " ));
2005-07-09 03:16:31 +02:00
}
2006-07-14 13:31:57 +02:00
print '</td>' ;
2005-07-09 03:16:31 +02:00
}
2006-05-01 23:53:00 +02:00
else
{
print '<td> </td>' ;
}
2005-07-09 03:16:31 +02:00
print " </tr> " ;
$i ++ ;
$var =! $var ;
}
$db -> free ();
if ( ! $num )
{
2006-05-01 23:53:00 +02:00
print '<tr ' . $bc [ false ] . '><td colspan="5">' . $langs -> trans ( " NoArticleOfTypeProduct " ) . '<br>' ;
2005-07-09 03:16:31 +02:00
}
2005-09-04 19:13:55 +02:00
2006-05-01 23:53:00 +02:00
print " </table> " ;
2005-07-09 03:16:31 +02:00
}
else
{
dolibarr_print_error ( $db );
2005-04-15 22:54:29 +02:00
}
2005-07-09 03:16:31 +02:00
2005-09-04 19:13:55 +02:00
print '</div>' ;
2005-07-09 03:16:31 +02:00
/*
2005-09-04 19:13:55 +02:00
* Boutons Actions
*/
if ( $user -> societe_id == 0 )
{
print '<div class="tabsAction">' ;
2006-04-29 17:09:44 +02:00
// Bouton expedier sans gestion des stocks
if ( ! $conf -> stock -> enabled && $reste_a_livrer_total > 0 && ! $commande -> brouillon && $user -> rights -> expedition -> creer )
2005-09-04 19:13:55 +02:00
{
print '<a class="butAction" href="' . DOL_URL_ROOT . '/expedition/fiche.php?action=create&commande_id=' . $_GET [ " id " ] . '">' . $langs -> trans ( " NewSending " ) . '</a>' ;
}
print " </div> " ;
}
2006-07-14 15:26:19 +02:00
print '<table width="100%"><tr><td width="50%" valign="top">' ;
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*
*/
$comref = sanitize_string ( $commande -> ref );
$file = $conf -> commande -> dir_output . '/' . $comref . '/' . $comref . '.pdf' ;
$relativepath = $comref . '/' . $comref . '.pdf' ;
$filedir = $conf -> commande -> dir_output . '/' . $comref ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $commande -> id ;
$genallowed = 0 ;
$delallowed = 0 ;
$somethingshown = $html -> show_documents ( 'commande' , $comref , $filedir , $urlsource , $genallowed , $delallowed , $commande -> modelpdf );
print '</td><td valign="top" width="50%">' ;
2006-04-29 17:09:44 +02:00
// Bouton expedier avec gestion des stocks
2006-06-24 19:10:32 +02:00
if ( $conf -> stock -> enabled && $reste_a_livrer_total > 0 && $commande -> statut > 0 && $commande -> statut < 3 && $user -> rights -> expedition -> creer )
2005-07-09 03:16:31 +02:00
{
2006-07-14 15:26:19 +02:00
print_titre ( $langs -> trans ( " NewSending " ));
2005-09-04 19:13:55 +02:00
print '<form method="GET" action="' . DOL_URL_ROOT . '/expedition/fiche.php">' ;
2005-07-09 03:16:31 +02:00
print '<input type="hidden" name="action" value="create">' ;
2005-09-04 19:13:55 +02:00
print '<input type="hidden" name="id" value="' . $commande -> id . '">' ;
2005-07-09 03:16:31 +02:00
print '<input type="hidden" name="commande_id" value="' . $commande -> id . '">' ;
2005-09-04 19:13:55 +02:00
print '<table class="border" width="100%">' ;
2005-07-09 03:16:31 +02:00
$entrepot = new Entrepot ( $db );
$langs -> load ( " stocks " );
2005-09-04 19:13:55 +02:00
print '<tr>' ;
print '<td>' . $langs -> trans ( " Warehouse " ) . '</td>' ;
2005-07-09 03:16:31 +02:00
print '<td>' ;
$html -> select_array ( " entrepot_id " , $entrepot -> list_array ());
if ( sizeof ( $entrepot -> list_array ()) <= 0 )
{
print ' Aucun entrep<65> t d<> finit, <a href="' . DOL_URL_ROOT . '/product/stock/fiche.php?action=create">definissez en un</a>' ;
}
print '</td></tr>' ;
/*
print '<tr><td width="20%">Mode d\'exp<78> dition</td>' ;
print '<td>' ;
$html -> select_array ( " entrepot_id " , $entrepot -> list_array ());
print '</td></tr>' ;
*/
2005-09-04 19:13:55 +02:00
print '<tr><td align="center" colspan="2">' ;
print '<input type="submit" class="button" named="save" value="' . $langs -> trans ( " NewSending " ) . '">' ;
print '</td></tr>' ;
2006-07-14 15:26:19 +02:00
print " </table> " ;
2005-07-09 03:16:31 +02:00
print " </form> \n " ;
2006-07-14 15:26:19 +02:00
$somethingshown = 1 ;
2005-07-09 03:16:31 +02:00
}
2006-07-14 15:26:19 +02:00
print " </td></tr></table> " ;
2005-07-09 03:16:31 +02:00
/*
2006-07-14 15:26:19 +02:00
* Liste des exp<EFBFBD> ditions
2005-07-09 03:16:31 +02:00
*/
2006-01-14 14:45:04 +01:00
$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 " ;
2006-05-31 19:22:09 +02:00
if ( $conf -> livraison -> enabled ) $sql .= " , l.rowid as livraison_id, l.ref as livraison_ref " ;
2006-01-14 14:45:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commandedet as cd " ;
$sql .= " , " . MAIN_DB_PREFIX . " expeditiondet as ed, " . MAIN_DB_PREFIX . " expedition as e " ;
2006-05-31 20:06:04 +02:00
if ( $conf -> livraison -> enabled ) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " livraison as l ON l.fk_expedition = e.rowid " ;
2006-01-14 14:45:04 +01:00
$sql .= " WHERE cd.fk_commande = " . $commande -> id ;
$sql .= " AND cd.rowid = ed.fk_commande_ligne " ;
$sql .= " AND ed.fk_expedition = e.rowid " ;
$sql .= " ORDER BY cd.fk_product " ;
2005-09-22 01:43:07 +02:00
2005-07-09 03:16:31 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2006-01-14 14:45:04 +01:00
$i = 0 ;
2005-07-09 03:16:31 +02:00
if ( $num )
{
2006-07-14 15:26:19 +02:00
if ( $somethingshown ) print '<br>' ;
2006-01-14 14:45:04 +01:00
2006-07-14 15:26:19 +02:00
print_titre ( $langs -> trans ( " SendingsForSameOrder " ));
2006-01-14 14:45:04 +01:00
print '<table class="liste" width="100%">' ;
2005-07-09 03:16:31 +02:00
print '<tr class="liste_titre">' ;
2006-05-06 23:09:26 +02:00
print '<td align="left">' . $langs -> trans ( " Sending " ) . '</td>' ;
2006-07-14 13:31:57 +02:00
print '<td>' . $langs -> trans ( " Product " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " QtyShipped " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Date " ) . '</td>' ;
2006-05-31 20:27:55 +02:00
if ( $conf -> livraison -> enabled )
2006-05-31 20:09:24 +02:00
{
2006-06-01 12:05:04 +02:00
print '<td>' . $langs -> trans ( " DeliveryOrder " ) . '</td>' ;
2006-05-31 20:09:24 +02:00
}
2005-07-09 03:16:31 +02:00
print " </tr> \n " ;
$var = True ;
while ( $i < $num )
{
2005-09-22 01:43:07 +02:00
$var =! $var ;
2006-05-31 19:22:09 +02:00
$objp = $db -> fetch_object ( $resql );
2005-09-04 19:13:55 +02:00
print " <tr $bc[$var] > " ;
2006-05-06 23:09:26 +02:00
print '<td align="left"><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp -> expedition_id . '">' . img_object ( $langs -> trans ( " ShowSending " ), 'sending' ) . ' ' . $objp -> ref . '<a></td>' ;
2006-05-31 19:22:09 +02:00
2005-07-09 03:16:31 +02:00
if ( $objp -> fk_product > 0 )
{
2005-09-22 01:43:07 +02:00
$product = new Product ( $db );
$product -> fetch ( $objp -> fk_product );
print '<td>' ;
2006-01-14 14:45:04 +01:00
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), " product " ) . ' ' . $product -> ref . '</a> - ' . $product -> libelle ;
2006-06-24 22:37:32 +02:00
if ( $objp -> description ) print '<br>' . nl2br ( $objp -> description );
2005-09-22 01:43:07 +02:00
print '</td>' ;
2005-07-09 03:16:31 +02:00
}
else
{
2005-09-22 01:43:07 +02:00
print " <td> " . stripslashes ( nl2br ( $objp -> description )) . " </td> \n " ;
2005-07-09 03:16:31 +02:00
}
print '<td align="center">' . $objp -> qty_livre . '</td>' ;
2005-09-22 01:43:07 +02:00
print '<td align="center">' . dolibarr_print_date ( $objp -> date_expedition ) . '</td>' ;
2006-07-14 13:31:57 +02:00
if ( $conf -> livraison -> enabled )
{
if ( $objp -> livraison_id )
{
print '<td><a href="' . DOL_URL_ROOT . '/livraison/fiche.php?id=' . $objp -> livraison_id . '">' . img_object ( $langs -> trans ( " ShowSending " ), 'generic' ) . ' ' . $objp -> livraison_ref . '<a></td>' ;
}
else
{
print '<td><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp -> expedition_id . '&action=create_delivery">' . $langs -> trans ( " CreateDeliveryOrder " ) . '<a></td>' ;
}
}
print '</tr>' ;
2005-07-09 03:16:31 +02:00
$i ++ ;
}
print '</table>' ;
}
2005-09-22 01:43:07 +02:00
$db -> free ( $resql );
2005-07-09 03:16:31 +02:00
}
2006-06-24 19:10:32 +02:00
else
{
2005-09-04 19:13:55 +02:00
dolibarr_print_error ( $db );
2005-07-09 03:16:31 +02:00
}
2003-11-13 18:36:45 +01:00
}
2005-07-09 03:16:31 +02:00
else
2003-11-13 18:36:45 +01:00
{
2005-07-09 03:16:31 +02:00
/* Commande non trouv<75> e */
print " Commande inexistante " ;
2003-11-13 18:36:45 +01:00
}
2005-07-09 03:16:31 +02:00
}
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
?>