2004-11-29 17:48:53 +01:00
< ? php
2005-04-04 17:03:32 +02:00
/* Copyright ( C ) 2004 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2006-03-16 02:25:19 +01:00
* Copyright ( C ) 2004 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-07-22 18:45:56 +02:00
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
2004-11-29 17:48:53 +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 $
*/
2005-03-20 03:40:18 +01:00
/**
2005-08-31 23:56:05 +02:00
\file htdocs / fourn / commande / fiche . php
\ingroup commande
\brief Fiche commande
\version $Revision $
2004-11-29 17:48:53 +01:00
*/
require ( " ./pre.inc.php " );
2005-10-10 21:48:22 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /project.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /propal.class.php " );
2006-02-17 17:29:58 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /fourn/commande/modules/modules_commandefournisseur.php " );
2004-11-29 17:48:53 +01:00
2005-04-04 17:03:32 +02:00
if ( ! $user -> rights -> fournisseur -> commande -> lire ) accessforbidden ();
2004-11-29 17:48:53 +01:00
2005-08-31 23:56:05 +02:00
// S<> curit<69> acc<63> s client
2005-10-10 21:48:22 +02:00
$socidp = 0 ;
2004-11-29 17:48:53 +01:00
if ( $user -> societe_id > 0 )
{
$action = '' ;
$socidp = $user -> societe_id ;
}
2005-08-31 23:56:05 +02:00
2005-12-25 02:46:38 +01:00
$mesg = '' ;
2005-10-10 21:48:22 +02:00
2004-11-29 17:48:53 +01:00
/*
2005-12-25 02:46:38 +01:00
* Actions
2004-11-29 17:48:53 +01:00
*/
if ( $_POST [ " action " ] == 'classin' )
{
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$commande -> classin ( $_POST [ " projetid " ]);
}
if ( $_POST [ " action " ] == 'setremise' && $user -> rights -> commande -> creer )
{
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $id );
$commande -> set_remise ( $user , $_POST [ " remise " ]);
}
2005-08-31 23:56:05 +02:00
2004-11-29 17:48:53 +01:00
/*
*
*/
2004-11-30 20:09:33 +01:00
if ( $_POST [ " action " ] == 'addligne' && $user -> rights -> fournisseur -> commande -> creer )
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$comf = new CommandeFournisseur ( $db );
$comf -> fetch ( $_GET [ " id " ]);
2004-11-29 17:48:53 +01:00
2005-10-10 21:48:22 +02:00
if ( $_POST [ " p_idprod " ] > 0 )
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$result = $comf -> addline ( $_POST [ " desc " ],
$_POST [ " pu " ],
$_POST [ " pqty " ],
$_POST [ " tva_tx " ],
$_POST [ " p_idprod " ],
$_POST [ " premise " ]);
2004-11-29 17:48:53 +01:00
}
2005-10-10 21:48:22 +02:00
else
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$result = $comf -> addline ( $_POST [ " desc " ],
$_POST [ " pu " ],
$_POST [ " qty " ],
$_POST [ " tva_tx " ],
0 ,
$_POST [ " remise_percent " ]);
2004-11-29 17:48:53 +01:00
}
2005-12-25 02:46:38 +01:00
if ( $result >= 0 )
{
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
}
else
{
$mesg = '<div class="error">' . $comf -> error . '</div>' ;
}
2004-11-29 17:48:53 +01:00
}
if ( $_POST [ " action " ] == 'updateligne' && $user -> rights -> commande -> creer )
{
$commande = new CommandeFournisseur ( $db , " " , $_GET [ " id " ]);
if ( $commande -> fetch ( $_GET [ " id " ]) )
{
2006-07-02 16:45:46 +02:00
$result = $commande -> updateline ( $_POST [ " elrowid " ],
2004-11-29 17:48:53 +01:00
$_POST [ " eldesc " ],
$_POST [ " elprice " ],
$_POST [ " elqty " ],
$_POST [ " elremise_percent " ]);
}
else
{
print " Erreur " ;
}
}
2004-11-30 20:09:33 +01:00
if ( $_GET [ " action " ] == 'deleteline' && $user -> rights -> fournisseur -> commande -> creer )
2004-11-29 17:48:53 +01:00
{
$comf = new CommandeFournisseur ( $db );
$comf -> fetch ( $_GET [ " id " ]);
$result = $comf -> delete_line ( $_GET [ " lineid " ]);
}
2005-10-10 21:48:22 +02:00
if ( $_POST [ " action " ] == 'confirm_valid' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> fournisseur -> commande -> valider )
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$soc = new Societe ( $db );
2006-06-19 22:35:22 +02:00
$soc -> fetch ( $commande -> socidp );
2005-10-10 21:48:22 +02:00
$result = $commande -> valid ( $user );
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
2004-11-29 17:48:53 +01:00
}
2005-10-10 21:48:22 +02:00
if ( $_POST [ " action " ] == 'confirm_approve' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> fournisseur -> commande -> approuver )
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$result = $commande -> approve ( $user );
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
2004-11-29 17:48:53 +01:00
}
2005-10-10 21:48:22 +02:00
if ( $_POST [ " action " ] == 'confirm_refuse' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> fournisseur -> commande -> approuver )
2004-11-29 17:48:53 +01:00
{
2004-11-30 20:09:33 +01:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$result = $commande -> refuse ( $user );
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
}
2005-10-10 21:48:22 +02:00
if ( $_POST [ " action " ] == 'confirm_commande' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> fournisseur -> commande -> commander )
2004-11-30 20:09:33 +01:00
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$result = $commande -> commande ( $user , $_GET [ " datecommande " ], $_GET [ " methode " ]);
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
2004-11-30 20:09:33 +01:00
}
2005-10-10 21:48:22 +02:00
if ( $_POST [ " action " ] == 'confirm_delete' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> fournisseur -> commande -> creer )
2004-11-30 20:09:33 +01:00
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> id = $_GET [ " id " ];
$commande -> delete ();
Header ( " Location: index.php " );
exit ;
2004-11-29 17:48:53 +01:00
}
2005-04-05 11:58:15 +02:00
if ( $_POST [ " action " ] == 'livraison' && $user -> rights -> fournisseur -> commande -> receptionner )
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$date_liv = mktime ( 0 , 0 , 0 , $_POST [ " remonth " ], $_POST [ " reday " ], $_POST [ " reyear " ]);
$result = $commande -> Livraison ( $user , $date_liv , $_POST [ " type " ]);
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
2005-04-05 11:58:15 +02:00
}
2005-04-08 17:06:20 +02:00
if ( $_POST [ " action " ] == 'confirm_cancel' && $_POST [ " confirm " ] == yes && $user -> rights -> fournisseur -> commande -> annuler )
{
2005-10-10 21:48:22 +02:00
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ " id " ]);
$result = $commande -> cancel ( $user );
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
2005-04-08 17:06:20 +02:00
}
2006-02-17 17:29:58 +01:00
/*
* Generation de la commande
* d<EFBFBD> finit dans / fourn / commande / modules / modules_commandefournisseur . php
*/
if ( $_POST [ 'action' ] == 'builddoc' )
{
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
commande_supplier_pdf_create ( $db , $_GET [ 'id' ], $_POST [ 'model' ], $outputlangs );
2006-02-17 17:29:58 +01:00
}
if ( $_GET [ 'action' ] == 'builddoc' )
{
$commande = new CommandeFournisseur ( $db );
$commande -> fetch ( $_GET [ 'id' ]);
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
commande_supplier_pdf_create ( $db , $_GET [ 'id' ], $commande -> modelpdf , $outputlangs );
2006-02-17 17:29:58 +01:00
}
2005-04-04 17:03:32 +02:00
/*
* Cr<EFBFBD> <EFBFBD> une commande
*/
2005-10-10 21:48:22 +02:00
if ( $_GET [ " action " ] == 'create' )
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$fourn = new Fournisseur ( $db );
$fourn -> fetch ( $_GET [ " socid " ]);
2006-02-17 19:27:32 +01:00
$commande -> modelpdf = muscadet ; //test
2004-11-29 17:48:53 +01:00
2005-10-10 21:48:22 +02:00
if ( $fourn -> create_commande ( $user ) > 0 )
{
$idc = $fourn -> single_open_commande ;
Header ( " Location:fiche.php?id= " . $idc );
exit ;
}
else
2004-11-29 17:48:53 +01:00
{
2005-10-10 21:48:22 +02:00
$mesg = $fourn -> error ;
2004-11-29 17:48:53 +01:00
}
}
2005-08-31 23:56:05 +02:00
2004-11-29 17:48:53 +01:00
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
2005-12-25 02:46:38 +01:00
2006-03-16 02:25:19 +01:00
llxHeader ( '' , $langs -> trans ( " OrderCard " ), " CommandeFournisseur " );
$html = new Form ( $db );
2005-04-04 17:03:32 +02:00
if ( $_GET [ " id " ] > 0 )
2004-11-29 17:48:53 +01:00
{
2006-05-06 17:30:34 +02:00
// if ($mesg) print $mesg;
$commande = new CommandeFournisseur ( $db );
if ( $commande -> fetch ( $_GET [ " id " ]) == 0 )
2004-11-29 17:48:53 +01:00
{
2006-05-06 17:30:34 +02:00
$soc = new Societe ( $db );
2006-06-19 22:35:22 +02:00
$soc -> fetch ( $commande -> socidp );
2006-08-07 04:20:57 +02:00
2006-05-06 17:30:34 +02:00
$author = new User ( $db );
$author -> id = $commande -> user_author_id ;
$author -> fetch ();
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $commande -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " OrderCard " );
$a = $h ;
$h ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/fourn/commande/note.php?id=' . $commande -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Note " );
$h ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/fourn/commande/history.php?id=' . $commande -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " OrderFollow " );
$h ++ ;
$title = $langs -> trans ( " SupplierOrder " );
dolibarr_fiche_head ( $head , $a , $title );
/*
* Confirmation de la suppression de la commande
*
*/
if ( $_GET [ " action " ] == 'delete' )
{
2006-08-07 04:20:57 +02:00
$html -> form_confirm ( " fiche.php?id= $commande->id " , $langs -> trans ( " DeleteOrder " ), " Etes-vous s<> r de vouloir supprimer cette commande ? " , " confirm_delete " );
2006-05-06 17:30:34 +02:00
print '<br />' ;
}
/*
* Confirmation de la validation
*
*/
if ( $_GET [ " action " ] == 'valid' )
{
2006-08-07 04:20:57 +02:00
// on v<> rifie si la commande est en num<75> rotation provisoire
$ref = substr ( $commande -> ref , 1 , 4 );
if ( $ref == 'PROV' )
{
$newref = $commande -> getNextNumRef ( $soc );
}
else
{
$newref = $commande -> ref ;
}
$text = $langs -> trans ( 'ConfirmValidateOrder' , $newref );
if ( $conf -> notification -> enabled )
{
require_once ( DOL_DOCUMENT_ROOT . " /notify.class.php " );
$notify = new Notify ( $db );
$text .= '<br>' ;
$text .= $notify -> confirmMessage ( 3 , $commande -> socidp );
}
$html -> form_confirm ( " fiche.php?id= " . $commande -> id , $langs -> trans ( " ValidateOrder " ), $text , " confirm_valid " );
2006-05-06 17:30:34 +02:00
print '<br />' ;
}
/*
* Confirmation de l ' approbation
*
*/
if ( $_GET [ " action " ] == 'approve' )
{
$html -> form_confirm ( " fiche.php?id= $commande->id " , " Approuver la commande " , " Etes-vous s<> r de vouloir approuver cette commande ? " , " confirm_approve " );
print '<br />' ;
}
/*
* Confirmation de l ' approbation
*
*/
if ( $_GET [ " action " ] == 'refuse' )
{
$html -> form_confirm ( " fiche.php?id= $commande->id " , " Refuser la commande " , " Etes-vous s<> r de vouloir refuser cette commande ? " , " confirm_refuse " );
print '<br />' ;
}
/*
* Confirmation de l ' annulation
*
*/
if ( $_GET [ " action " ] == 'cancel' )
{
$html -> form_confirm ( " fiche.php?id= $commande->id " , $langs -> trans ( " Cancel " ), " Etes-vous s<> r de vouloir annuler cette commande ? " , " confirm_cancel " );
print '<br />' ;
}
/*
* Confirmation de l ' envoi de la commande
*
*/
if ( $_GET [ " action " ] == 'commande' )
{
$date_com = mktime ( 0 , 0 , 0 , $_POST [ " remonth " ], $_POST [ " reday " ], $_POST [ " reyear " ]);
$html -> form_confirm ( " fiche.php?id= " . $commande -> id . " &datecommande= " . $date_com . " &methode= " . $_POST [ " methodecommande " ],
" Envoi de la commande " , " Etes-vous s<> r de vouloir confirmer cette commande en date du " . strftime ( " %d/%m/%Y " , $date_com ) . " ? " , " confirm_commande " );
print '<br />' ;
}
/*
* Commande
*/
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td>' ;
2006-08-07 04:20:57 +02:00
print '<td colspan="5">' . $commande -> ref . '</td>' ;
2006-05-06 17:30:34 +02:00
print '</tr>' ;
// Fournisseur
print '<tr><td width="20%">' . $langs -> trans ( " Supplier " ) . " </td> " ;
print '<td colspan="5">' ;
print '<b><a href="' . DOL_URL_ROOT . '/fourn/fiche.php?socid=' . $soc -> id . '">' ;
print img_object ( $langs -> trans ( " ShowSupplier " ), 'company' ) . ' ' . $soc -> nom . '</a></b></td>' ;
print '</tr>' ;
// Statut
print '<tr>' ;
print '<td>' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td width="50%" colspan="5">' ;
print $commande -> getLibStatut ( 4 );
print " </td></tr> " ;
if ( $commande -> methode_commande_id > 0 )
{
print '<tr><td>' . $langs -> trans ( " Date " ) . '</td><td colspan="2">' ;
if ( $commande -> date_commande )
{
print dolibarr_print_date ( $commande -> date_commande , " %A %d %B %Y " ) . " \n " ;
}
print '</td><td width="50%" colspan="3">' ;
if ( $commande -> methode_commande )
{
print " M<EFBFBD> thode : " . $commande -> methode_commande ;
}
print " </td></tr> " ;
}
// Auteur
2006-08-07 04:20:57 +02:00
print '<tr><td>' . $langs -> trans ( " AuthorRequest " ) . '</td>' ;
print '<td colspan="2">' . $author -> getNomUrl ( 1 ) . '</td>' ;
2006-05-06 17:30:34 +02:00
print '<td colspan="3" width="50%">' ;
print " </td></tr> " ;
// Ligne de 3 colonnes
print '<tr><td>' . $langs -> trans ( " AmountHT " ) . '</td>' ;
print '<td align="right"><b>' . price ( $commande -> total_ht ) . '</b></td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td><td colspan="3"> </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " AmountVAT " ) . '</td><td align="right">' . price ( $commande -> total_tva ) . '</td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td><td colspan="3"> </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " AmountTTC " ) . '</td><td align="right">' . price ( $commande -> total_ttc ) . '</td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td><td colspan="3"> </td></tr>' ;
print " </table> " ;
if ( $mesg ) print $mesg ;
else print '<br>' ;
/*
* Lignes de commandes
*/
print '<table class="noborder" width="100%">' ;
$sql = " SELECT l.ref, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commande_fournisseurdet as l " ;
$sql .= " WHERE l.fk_commande = $commande->id " ;
$sql .= " ORDER BY l.rowid " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num_lignes = $db -> num_rows ( $resql );
$i = 0 ; $total = 0 ;
if ( $num_lignes )
2006-02-17 17:29:58 +01:00
{
2006-05-06 17:30:34 +02:00
print '<tr class="liste_titre">' ;
print '<td align="left">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " VAT " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Qty " ) . '</td>' ;
2006-05-21 02:04:52 +02:00
print '<td align="right">' . $langs -> trans ( " ReductionShort " ) . '</td>' ;
2006-05-06 17:30:34 +02:00
print '<td align="right">' . $langs -> trans ( " PriceU " ) . '</td>' ;
print '<td> </td><td width="10%"> </td>' ;
print " </tr> \n " ;
2006-02-17 17:29:58 +01:00
}
2006-05-06 17:30:34 +02:00
$var = false ;
while ( $i < $num_lignes )
{
$objp = $db -> fetch_object ( $resql );
print " <tr $bc[$var] > " ;
2006-08-02 01:54:39 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), 'product' ) . ' ' . $objp -> ref . '</a></td>' ;
print " <td> " . nl2br ( $objp -> description ) . " </td> " ;
2006-05-06 17:30:34 +02:00
print '<td align="center">' . $objp -> tva_tx . '%</td>' ;
print '<td align="center">' . $objp -> qty . '</td>' ;
if ( $objp -> remise_percent > 0 )
{
print '<td align="right">' . $objp -> remise_percent . " %</td> \n " ;
}
else
{
print '<td> </td>' ;
}
print '<td align="right">' . price ( $objp -> subprice ) . " </td> \n " ;
if ( $commande -> statut == 0 && $user -> rights -> fournisseur -> commande -> creer && $_GET [ " action " ] <> 'valid' )
{
print '<td> </td><td align="right"><a href="fiche.php?id=' . $commande -> id . '&action=deleteline&lineid=' . $objp -> rowid . '">' ;
print img_delete ();
print '</a></td>' ;
}
else
{
print '<td> </td><td> </td>' ;
}
print " </tr> " ;
if ( $_GET [ " action " ] == 'editline' && $_GET [ " rowid " ] == $objp -> rowid )
{
print " <form action= \" fiche.php?id= $commande->id\ " method = \ " post \" > " ;
print '<input type="hidden" name="action" value="updateligne">' ;
print '<input type="hidden" name="elrowid" value="' . $_GET [ " rowid " ] . '">' ;
print " <tr $bc[$var] > " ;
print '<td colspan="3"><textarea name="eldesc" cols="60" rows="2">' . stripslashes ( $objp -> description ) . '</textarea></td>' ;
print '<td align="center"><input size="4" type="text" name="elqty" value="' . $objp -> qty . '"></td>' ;
print '<td align="right"><input size="3" type="text" name="elremise_percent" value="' . $objp -> remise_percent . '"> %</td>' ;
print '<td align="right"><input size="8" type="text" name="elprice" value="' . price ( $objp -> subprice ) . '"></td>' ;
print '<td align="right" colspan="2"><input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '"></td>' ;
print '</tr>' . " \n " ;
print " </form> \n " ;
}
$i ++ ;
$var =! $var ;
}
$db -> free ();
}
else
{
print $db -> error ();
}
/*
* Ajouter une ligne
*/
if ( $commande -> statut == 0 && $user -> rights -> fournisseur -> commande -> creer && ( $_GET [ " action " ] <> 'valid' || $_GET [ 'action' ] == 'builddoc' ))
{
print '<form action="fiche.php?id=' . $commande -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="addligne">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="2">' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " VAT " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Qty " ) . '</td>' ;
2006-05-21 02:04:52 +02:00
print '<td align="right">' . $langs -> trans ( " ReductionShort " ) . '</td>' ;
2006-05-06 17:30:34 +02:00
print '<td align="right">' . $langs -> trans ( " PriceU " ) . '</td>' ;
print '<td> </td><td> </td>' . " </tr> \n " ;
$var = false ;
print " <tr $bc[$var] > " . '<td colspan="3">' ;
$html -> select_produits_fournisseurs ( $commande -> fourn_id , '' , 'p_idprod' , $filtre );
print '</td>' ;
print '<td align="center"><input type="text" size="2" name="pqty" value="1"></td>' ;
print '<td align="right"><input type="text" size="3" name="premise" value="0">%</td>' ;
print '<td> </td>' ;
print '<td align="center" colspan="3"><input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '"></td></tr>' ;
print " </tr> \n " ;
print " </form> " ;
}
print " </table> " ;
print '</div>' ;
/**
* Boutons actions
*/
if ( $user -> societe_id == 0 && $commande -> statut < 3 && ( $_GET [ " action " ] <> 'valid' || $_GET [ 'action' ] == 'builddoc' ))
{
print '<div class="tabsAction">' ;
if ( $commande -> statut == 0 && $num_lignes > 0 )
{
if ( $user -> rights -> fournisseur -> commande -> valider )
{
print '<a class="butAction" href="fiche.php?id=' . $commande -> id . '&action=valid">' . $langs -> trans ( " Valid " ) . '</a>' ;
}
}
if ( $commande -> statut == 1 )
{
if ( $user -> rights -> fournisseur -> commande -> approuver )
{
print '<a class="butAction" href="fiche.php?id=' . $commande -> id . '&action=approve">' . $langs -> trans ( " ApproveOrder " ) . '</a>' ;
print '<a class="butAction" href="fiche.php?id=' . $commande -> id . '&action=refuse">' . $langs -> trans ( " RefuseOrder " ) . '</a>' ;
}
if ( $user -> rights -> fournisseur -> commande -> annuler )
{
print '<a class="butActionDelete" href="fiche.php?id=' . $commande -> id . '&action=cancel">' . $langs -> trans ( " CancelOrder " ) . '</a>' ;
}
}
if ( $commande -> statut == 2 )
{
2006-05-06 18:32:47 +02:00
if ( $user -> rights -> fournisseur -> commande -> annuler )
2006-05-06 17:30:34 +02:00
{
2006-05-06 18:32:47 +02:00
print '<a class="butActionDelete" href="fiche.php?id=' . $commande -> id . '&action=cancel">' . $langs -> trans ( " CancelOrder " ) . '</a>' ;
2006-05-06 17:30:34 +02:00
}
}
if ( $commande -> statut == 0 )
{
if ( $user -> rights -> fournisseur -> commande -> creer )
{
print '<a class="butActionDelete" href="fiche.php?id=' . $commande -> id . '&action=delete">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
}
// Build PDF
if ( $commande -> statut > 0 )
{
if ( $user -> rights -> fournisseur -> commande -> creer )
{
print '<a class="butAction" href="fiche.php?id=' . $commande -> id . '&action=builddoc">' . $langs -> trans ( " BuildPDF " ) . '</a>' ;
}
}
print " </div> " ;
}
print '<table width="100%"><tr><td width="50%" valign="top">' ;
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*
*/
$comfournref = sanitize_string ( $commande -> ref );
$file = $conf -> fournisseur -> commande -> dir_output . '/' . $comfournref . '/' . $comfournref . '.pdf' ;
$relativepath = $comfournref . '/' . $comfournref . '.pdf' ;
$filedir = $conf -> fournisseur -> commande -> dir_output . '/' . $comfournref ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $commande -> id ;
$genallowed = $user -> rights -> fournisseur -> commande -> creer ;
$delallowed = $user -> rights -> fournisseur -> commande -> supprimer ;
$var = true ;
/*
if ( file_exists ( $file ))
{
print_titre ( $langs -> trans ( 'Documents' ));
print '<table width="100%" class="border">' ;
print '<tr ' . $bc [ $var ] . '><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>' ;
print '<br>' ;
}
*/
2006-07-02 15:45:06 +02:00
$somethingshown = $html -> show_documents ( 'commande_fournisseur' , $comfournref , $filedir , $urlsource , $commande -> statut > 0 ? 1 : 0 , $delallowed , $commande -> modelpdf );
2006-05-06 17:30:34 +02:00
print '</td><td width="50%" valign="top">' ;
/*
*
*
*/
if ( $_GET [ " action " ] == 'classer' )
{
print '<form method="post" action="fiche.php?id=' . $commande -> id . '">' ;
print '<input type="hidden" name="action" value="classin">' ;
print '<table class="border">' ;
2006-05-06 18:32:47 +02:00
print '<tr><td>' . $langs -> trans ( " Project " ) . '</td><td>' ;
2006-05-06 17:30:34 +02:00
$proj = new Project ( $db );
2006-06-19 22:35:22 +02:00
$html -> select_array ( " projetid " , $proj -> liste_array ( $commande -> socidp ));
2006-05-06 17:30:34 +02:00
print " </td></tr> " ;
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="' . $langs -> trans ( " Send " ) . '"></td></tr></table></form>' ;
}
/*
*
*
*/
if ( $user -> rights -> fournisseur -> commande -> commander && $commande -> statut == 2 )
{
/**
* Commander
*/
$form = new Form ( $db );
print '<br>' ;
print '<form name="commande" action="fiche.php?id=' . $commande -> id . '&action=commande" method="post">' ;
2006-05-06 18:32:47 +02:00
print '<table class="border" width="100%">' ;
print '<tr class="liste_titre"><td colspan="2">' . $langs -> trans ( " ToOrder " ) . '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " OrderDate " ) . '</td><td>' ;
2006-05-06 17:30:34 +02:00
print $form -> select_date ( '' , '' , '' , '' , '' , " commande " );
print '</td></tr>' ;
2006-05-06 18:32:47 +02:00
print '<tr><td>' . $langs -> trans ( " OrderMode " ) . '</td><td>' ;
$html -> select_methodes_commande ( '' , " methodecommande " , 1 );
2006-05-06 17:30:34 +02:00
print '</td></tr>' ;
2006-05-06 18:32:47 +02:00
print '<tr><td>' . $langs -> trans ( " Comment " ) . '</td><td><input size="30" type="text" name="commentaire"></td></tr>' ;
2006-05-06 17:30:34 +02:00
print '<tr><td align="center" colspan="2"><input type="submit" class="button" name="' . $langs -> trans ( " Activate " ) . '"></td></tr>' ;
print '</table>' ;
print '</form>' ;
}
/*
*
*
*/
if ( $user -> rights -> fournisseur -> commande -> receptionner && ( $commande -> statut == 3 || $commande -> statut == 4 ))
{
/**
* R<EFBFBD> ceptionner
2006-02-17 17:29:58 +01:00
*/
2006-05-06 17:30:34 +02:00
$form = new Form ( $db );
print '<br>' ;
print '<form action="fiche.php?id=' . $commande -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="livraison">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre"><td colspan="2">R<> ceptionner</td></tr>' ;
print '<tr><td>Date de livraison</td><td>' ;
print $form -> select_date ( '' , '' , '' , '' , '' , " commande " );
print " </td></tr> \n " ;
print " <tr><td>Livraison</td><td> \n " ;
$liv = array ();
$liv [ 'par' ] = " Partielle " ;
$liv [ 'tot' ] = " Totale " ;
print $form -> select_array ( " type " , $liv );
print '</td></tr>' ;
print '<tr><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>' ;
print '<tr><td align="center" colspan="2"><input type="submit" class="button" name="' . $langs -> trans ( " Activate " ) . '"></td></tr>' ;
print " </table> \n " ;
print " </form> \n " ;
}
print '</td></tr></table>' ;
2004-11-29 17:48:53 +01:00
}
2006-05-06 17:30:34 +02:00
else
2004-11-30 20:09:33 +01:00
{
2006-05-06 17:30:34 +02:00
/* Commande non trouv<75> e */
print " Commande inexistante " ;
2004-11-30 20:09:33 +01:00
}
2006-05-06 17:30:34 +02:00
}
2004-11-29 17:48:53 +01:00
$db -> close ();
2005-08-31 23:56:05 +02:00
llxFooter ( '$Date$ - $Revision$' );
2004-11-29 17:48:53 +01:00
?>