2002-04-30 12:44:42 +02:00
< ? PHP
2004-01-30 11:16:56 +01:00
/* Copyright ( C ) 2002 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-01-18 20:56:52 +01:00
* Copyright ( C ) 2004 <EFBFBD> ric Seigne < eric . seigne @ ryxeo . com >
2004-01-27 23:57:18 +01:00
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2002-04-30 12:44:42 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* 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 .
*
2002-07-03 14:46:00 +02:00
* $Id $
* $Source $
2003-06-22 12:58:04 +02:00
*
2002-04-30 12:44:42 +02:00
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
2003-08-06 14:38:46 +02:00
$user -> getrights ( 'facture' );
2003-08-06 14:40:29 +02:00
if ( ! $user -> rights -> facture -> lire )
2003-08-06 14:38:46 +02:00
accessforbidden ();
2003-09-11 22:18:51 +02:00
require ( " ../facture.class.php " );
require ( " ../lib/CMailFile.class.php " );
2003-04-14 18:24:14 +02:00
require ( " ../paiement.class.php " );
2003-09-11 22:18:51 +02:00
require ( " ../project.class.php " );
require ( " ../propal.class.php " );
2003-05-13 22:39:13 +02:00
require ( " ./bank/account.class.php " );
2003-08-03 19:58:09 +02:00
require ( " ../contrat/contrat.class.php " );
2003-11-24 11:15:11 +01:00
require ( " ../commande/commande.class.php " );
2002-04-30 12:44:42 +02:00
llxHeader ();
2002-05-11 20:53:13 +02:00
2003-03-23 16:53:03 +01:00
/*
* S<EFBFBD> curit<EFBFBD> acc<EFBFBD> s client
*/
if ( $user -> societe_id > 0 )
{
$action = '' ;
$socidp = $user -> societe_id ;
}
2003-10-22 17:38:43 +02:00
/*
*
2004-01-08 23:58:10 +01:00
*/
2003-10-22 17:38:43 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'classin' )
{
$facture = new Facture ( $db );
$facture -> fetch ( $facid );
$facture -> classin ( $HTTP_POST_VARS [ " projetid " ]);
}
2003-03-23 16:53:03 +01:00
/*
*
*/
2003-09-09 18:06:22 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'add' )
{
2003-11-24 11:15:11 +01:00
$datefacture = mktime ( 12 , 0 , 0 , $HTTP_POST_VARS [ " remonth " ], $HTTP_POST_VARS [ " reday " ], $HTTP_POST_VARS [ " reyear " ]);
2003-09-09 18:06:22 +02:00
2003-11-24 11:15:11 +01:00
$facture = new Facture ( $db , $HTTP_POST_VARS [ " socid " ]);
2003-09-09 18:06:22 +02:00
$facture -> number = $HTTP_POST_VARS [ " facnumber " ];
$facture -> date = $datefacture ;
$facture -> note = $HTTP_POST_VARS [ " note " ];
2003-10-12 16:41:22 +02:00
if ( $HTTP_POST_VARS [ " fac_rec " ] > 0 )
{
/*
* Facture r<EFBFBD> currente
*/
$facture -> fac_rec = $HTTP_POST_VARS [ " fac_rec " ];
2003-09-09 18:06:22 +02:00
$facid = $facture -> create ( $user );
}
else
{
2003-10-12 16:41:22 +02:00
$facture -> projetid = $HTTP_POST_VARS [ " projetid " ];
$facture -> cond_reglement = $HTTP_POST_VARS [ " condid " ];
$facture -> amount = $HTTP_POST_VARS [ " amount " ];
$facture -> remise = $HTTP_POST_VARS [ " remise " ];
$facture -> remise_percent = $HTTP_POST_VARS [ " remise_percent " ];
2003-11-24 11:15:11 +01:00
if ( ! $HTTP_POST_VARS [ " propalid " ] && ! $HTTP_POST_VARS [ " commandeid " ])
2003-10-12 16:41:22 +02:00
{
$facture -> add_product ( $HTTP_POST_VARS [ " idprod1 " ], $HTTP_POST_VARS [ " qty1 " ], $HTTP_POST_VARS [ " remise_percent1 " ]);
$facture -> add_product ( $HTTP_POST_VARS [ " idprod2 " ], $HTTP_POST_VARS [ " qty2 " ], $HTTP_POST_VARS [ " remise_percent2 " ]);
$facture -> add_product ( $HTTP_POST_VARS [ " idprod3 " ], $HTTP_POST_VARS [ " qty3 " ], $HTTP_POST_VARS [ " remise_percent3 " ]);
$facture -> add_product ( $HTTP_POST_VARS [ " idprod4 " ], $HTTP_POST_VARS [ " qty4 " ], $HTTP_POST_VARS [ " remise_percent4 " ]);
$facid = $facture -> create ( $user );
}
else
2003-09-09 18:06:22 +02:00
{
2003-11-24 11:15:11 +01:00
/*
* Propale
*/
if ( $HTTP_POST_VARS [ " propalid " ])
{
$facture -> propalid = $HTTP_POST_VARS [ " propalid " ];
2003-10-12 16:41:22 +02:00
2003-11-24 11:15:11 +01:00
$facid = $facture -> create ( $user );
if ( $facid )
{
$prop = New Propal ( $db );
if ( $prop -> fetch ( $HTTP_POST_VARS [ " propalid " ]) )
{
for ( $i = 0 ; $i < sizeof ( $prop -> lignes ) ; $i ++ )
{
2004-01-18 20:56:52 +01:00
print " <pre>la propale pr<70> c<EFBFBD> dente en ligne " . $prop -> lignes [ $i ] -> libelle . " avait comme prix : " . $prop -> lignes [ $i ] -> price . " !</pre> \n " ;
2003-11-24 11:15:11 +01:00
$result = $facture -> addline ( $facid ,
addslashes ( $prop -> lignes [ $i ] -> libelle ),
$prop -> lignes [ $i ] -> subprice ,
$prop -> lignes [ $i ] -> qty ,
$prop -> lignes [ $i ] -> tva_tx ,
$prop -> lignes [ $i ] -> product_id ,
$prop -> lignes [ $i ] -> remise_percent );
}
}
else
{
print " Erreur " ;
}
}
}
/*
* Commande
*/
if ( $HTTP_POST_VARS [ " commandeid " ])
2003-09-09 18:06:22 +02:00
{
2003-11-25 13:52:48 +01:00
$facture -> commandeid = $HTTP_POST_VARS [ " commandeid " ];
2003-11-24 11:15:11 +01:00
$facid = $facture -> create ( $user );
if ( $facid )
2003-10-12 16:41:22 +02:00
{
2003-11-24 11:15:11 +01:00
$comm = New Commande ( $db );
if ( $comm -> fetch ( $HTTP_POST_VARS [ " commandeid " ]) )
2003-10-12 16:41:22 +02:00
{
2003-11-24 11:15:11 +01:00
$lines = $comm -> fetch_lignes ();
2003-11-25 13:13:53 +01:00
2003-11-24 11:15:11 +01:00
for ( $i = 0 ; $i < sizeof ( lines ) ; $i ++ )
{
$result = $facture -> addline ( $facid ,
addslashes ( $lines [ $i ] -> description ),
$lines [ $i ] -> subprice ,
$lines [ $i ] -> qty ,
$lines [ $i ] -> tva_tx ,
$lines [ $i ] -> product_id ,
$lines [ $i ] -> remise_percent );
}
}
else
{
print " Erreur " ;
2003-10-12 16:41:22 +02:00
}
}
else
2003-09-09 18:06:22 +02:00
{
2004-01-24 19:34:18 +01:00
print " <p><b>Erreur : la facture n'a pas <20> t<EFBFBD> cr<63> <72> e, v<> rifier le num<75> ro !</b> " ;
print " <p>Retour <20> la <a href= \" propal.php?propalid= $propalid\ " > propale </ a > " ;
print $db -> error ();
2003-09-09 18:06:22 +02:00
}
}
2003-11-24 11:15:11 +01:00
2003-09-09 18:06:22 +02:00
}
}
2003-04-14 18:24:14 +02:00
2003-09-09 18:06:22 +02:00
$action = '' ;
}
/*
*
*/
2003-05-25 18:44:11 +02:00
if ( $action == 'add_paiement' )
{
2003-07-15 13:30:58 +02:00
$datepaye = $db -> idate ( mktime ( 12 , 0 , 0 , $HTTP_POST_VARS [ " remonth " ], $HTTP_POST_VARS [ " reday " ], $HTTP_POST_VARS [ " reyear " ]));
2003-04-14 18:24:14 +02:00
$paiement = new Paiement ( $db );
2003-07-15 13:30:58 +02:00
$paiement -> facid = $HTTP_POST_VARS [ " facid " ];
2003-04-14 18:24:14 +02:00
$paiement -> datepaye = $datepaye ;
2003-07-15 13:30:58 +02:00
$paiement -> amount = $HTTP_POST_VARS [ " amount " ];
$paiement -> author = $HTTP_POST_VARS [ " author " ];
$paiement -> paiementid = $HTTP_POST_VARS [ " paiementid " ];
$paiement -> num_paiement = $HTTP_POST_VARS [ " num_paiement " ];
$paiement -> note = $HTTP_POST_VARS [ " note " ];
2003-04-14 18:24:14 +02:00
2004-01-18 20:56:52 +01:00
//A ne pas m<> langer avec paiementid !
2003-10-21 18:35:33 +02:00
$paiement_id = $paiement -> create ();
2003-04-14 18:24:14 +02:00
$action = '' ;
2003-05-25 18:44:11 +02:00
2003-07-15 13:30:58 +02:00
$fac = new Facture ( $db );
$fac -> fetch ( $HTTP_POST_VARS [ " facid " ]);
2003-10-21 18:35:33 +02:00
$fac -> fetch_client ();
2003-07-15 13:30:58 +02:00
2004-01-26 23:29:34 +01:00
$label = " R<EFBFBD> glement facture " ;
2004-01-18 20:56:52 +01:00
//On ajoute une ligne dans la table llx_bank pour qu'ensuite on puisse rapprocher le compte !
2003-05-25 18:44:11 +02:00
$acc = new Account ( $db , $HTTP_POST_VARS [ " accountid " ]);
2004-01-18 20:56:52 +01:00
//paiementid est correct, il contient "CHQ ou VIR par exemple"
2003-10-21 18:35:33 +02:00
$bank_line_id = $acc -> addline ( $datepaye , $paiementid , $label , $amount , $num_paiement );
$acc -> add_url_line ( $bank_line_id , $fac -> id , DOL_URL_ROOT . '/compta/facture.php?facid=' , $fac -> ref );
$acc -> add_url_line ( $bank_line_id , $fac -> client -> id , DOL_URL_ROOT . '/compta/fiche.php?socid=' , $fac -> client -> nom );
2003-07-08 22:59:01 +02:00
}
/*
*
*/
2003-08-12 15:21:49 +02:00
if ( $action == 'del_paiement' && $user -> rights -> facture -> paiement )
2003-07-08 22:59:01 +02:00
{
$paiement = new Paiement ( $db );
$paiement -> id = $paiementid ;
$paiement -> delete ();
2003-05-25 18:44:11 +02:00
2003-07-08 22:59:01 +02:00
$action = '' ;
2004-01-18 20:56:52 +01:00
//Attention: bug 18.01.2004 on oublie d'effacer la ligne correspondante dans llx_bank !
$acc = new Account ( $db , $HTTP_POST_VARS [ " accountid " ]);
//paiementid est correct, il contient "CHQ ou VIR par exemple"
$acc -> deleteline ( $paiementid );
2003-04-14 18:24:14 +02:00
}
/*
*
*/
2003-10-21 13:44:01 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'confirm_valid' && $HTTP_POST_VARS [ " confirm " ] == yes && $user -> rights -> facture -> valider )
2002-12-14 17:25:46 +01:00
{
$fac = new Facture ( $db );
2003-07-07 12:04:42 +02:00
$fac -> fetch ( $facid );
2003-09-23 19:50:20 +02:00
$soc = new Societe ( $db );
$soc -> fetch ( $fac -> socidp );
$result = $fac -> set_valid ( $facid , $user , $soc );
2003-04-13 16:47:33 +02:00
if ( $result )
{
facture_pdf_create ( $db , $facid );
}
2002-04-30 12:44:42 +02:00
}
2003-08-12 15:21:49 +02:00
if ( $action == 'payed' && $user -> rights -> facture -> paiement )
2002-12-14 17:25:46 +01:00
{
$fac = new Facture ( $db );
$result = $fac -> set_payed ( $facid );
2002-04-30 12:44:42 +02:00
}
2003-09-06 02:31:41 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'setremise' && $user -> rights -> facture -> creer )
{
$fac = new Facture ( $db );
$fac -> fetch ( $facid );
$fac -> set_remise ( $user , $HTTP_POST_VARS [ " remise " ]);
}
2003-08-11 21:58:31 +02:00
if ( $action == 'addligne' && $user -> rights -> facture -> creer )
2003-02-01 20:45:45 +01:00
{
$fac = new Facture ( $db );
2003-08-04 20:07:59 +02:00
$fac -> fetch ( $facid );
2003-05-16 15:30:46 +02:00
$result = $fac -> addline ( $facid ,
$HTTP_POST_VARS [ " desc " ],
$HTTP_POST_VARS [ " pu " ],
$HTTP_POST_VARS [ " qty " ],
2003-09-23 19:50:20 +02:00
$HTTP_POST_VARS [ " tva_tx " ],
2003-10-21 13:44:01 +02:00
0 ,
2003-09-23 19:50:20 +02:00
$HTTP_POST_VARS [ " remise_percent " ]);
2003-02-01 20:45:45 +01:00
}
2003-08-11 21:58:31 +02:00
if ( $action == 'updateligne' && $user -> rights -> facture -> creer )
2003-02-01 22:12:52 +01:00
{
$fac = new Facture ( $db , " " , $facid );
2003-08-04 20:07:59 +02:00
$fac -> fetch ( $facid );
$result = $fac -> updateline ( $rowid ,
$HTTP_POST_VARS [ " desc " ],
$HTTP_POST_VARS [ " price " ],
2003-09-23 19:50:20 +02:00
$HTTP_POST_VARS [ " qty " ],
$HTTP_POST_VARS [ " remise_percent " ]);
2003-02-01 22:12:52 +01:00
}
2003-08-11 21:58:31 +02:00
if ( $action == 'deleteline' && $user -> rights -> facture -> creer )
2003-02-01 20:45:45 +01:00
{
2003-02-01 22:12:52 +01:00
$fac = new Facture ( $db , " " , $facid );
2003-08-04 20:07:59 +02:00
$fac -> fetch ( $facid );
2003-02-01 20:45:45 +01:00
$result = $fac -> deleteline ( $rowid );
}
2003-10-21 13:44:01 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'confirm_delete' && $HTTP_POST_VARS [ " confirm " ] == yes )
2002-12-14 17:25:46 +01:00
{
2003-10-21 13:44:01 +02:00
if ( $user -> rights -> facture -> supprimer )
{
$fac = new Facture ( $db );
2003-11-24 11:15:11 +01:00
$fac -> delete ( $_GET [ " facid " ]);
$_GET [ " facid " ] = 0 ;
2003-10-21 13:44:01 +02:00
}
2002-04-30 12:44:42 +02:00
}
2003-02-02 16:01:56 +01:00
/*
*
*/
if ( $action == 'send' )
{
$fac = new Facture ( $db , " " , $facid );
$fac -> fetch ( $facid );
$soc = new Societe ( $db , $fac -> socidp );
2003-06-22 12:58:04 +02:00
$file = FAC_OUTPUTDIR . " / " . $fac -> ref . " / " . $fac -> ref . " .pdf " ;
2003-02-02 16:01:56 +01:00
if ( file_exists ( $file ))
{
$sendto = $soc -> contact_get_email ( $HTTP_POST_VARS [ " destinataire " ]);
2003-02-02 16:14:50 +01:00
$sendtoid = $HTTP_POST_VARS [ " destinataire " ];
2003-02-02 16:01:56 +01:00
if ( strlen ( $sendto ))
{
$subject = " Facture $fac->ref " ;
$message = " Veuillez trouver ci-joint la facture $fac->ref\n\nCordialement\n\n " ;
$filename = " $fac->ref .pdf " ;
2004-01-09 00:20:05 +01:00
2003-02-02 16:01:56 +01:00
$replyto = $HTTP_POST_VARS [ " replytoname " ] . " < " . $HTTP_POST_VARS [ " replytomail " ] . " > " ;
2004-01-09 00:20:05 +01:00
2003-02-02 16:01:56 +01:00
$mailfile = new CMailFile ( $subject , $sendto , $replyto , $message , $file , " application/pdf " , $filename );
2004-01-09 00:20:05 +01:00
2003-02-02 16:01:56 +01:00
if ( $mailfile -> sendfile () )
{
2003-02-02 16:14:50 +01:00
$sendto = htmlentities ( $sendto );
2003-02-02 16:01:56 +01:00
2004-01-30 11:16:56 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm (datea,fk_action,fk_soc,note,fk_facture, fk_contact,fk_user_author, label, percent) VALUES (now(), '9' ,' $fac->socidp ' ,'Envoy<6F> e <20> $sendto ',' $fac->id ',' $sendtoid ',' $user->id ', 'Envoi Facture par mail',100); " ;
2003-02-02 16:01:56 +01:00
if ( ! $db -> query ( $sql ) )
{
print $db -> error ();
print " <p> $sql </p> " ;
}
}
else
{
print " <b>!! erreur d'envoi<br> $sendto <br> $replyto <br> $filename " ;
}
}
else
{
print " Can't get email $sendto " ;
}
}
}
2003-07-24 13:05:57 +02:00
/*
*
*/
if ( $HTTP_POST_VARS [ " action " ] == 'relance' )
{
$fac = new Facture ( $db , " " , $facid );
$fac -> fetch ( $facid );
$fac -> send_relance ( $HTTP_POST_VARS [ " destinataire " ],
$HTTP_POST_VARS [ " replytoname " ],
$HTTP_POST_VARS [ " replytomail " ],
$user );
}
2003-02-02 16:01:56 +01:00
2003-07-24 13:05:57 +02:00
/*
*
*/
2003-04-13 16:47:33 +02:00
if ( $action == 'pdf' )
{
/*
* Generation de la facture
2003-06-22 12:58:04 +02:00
* d<EFBFBD> finit dans / includes / modules / facture / modules_facture . php
2003-04-13 16:47:33 +02:00
*/
2003-09-09 19:05:18 +02:00
facture_pdf_create ( $db , $facid );
2003-04-13 16:47:33 +02:00
}
2003-05-16 15:30:46 +02:00
$html = new Form ( $db );
2003-04-13 16:47:33 +02:00
2003-09-03 16:00:35 +02:00
/*********************************************************************
2002-05-11 20:53:13 +02:00
*
* Mode creation
*
*
*
2003-09-03 16:00:35 +02:00
************************************************************************/
2003-11-24 11:15:11 +01:00
if ( $_GET [ " action " ] == 'create' )
2002-12-14 17:25:46 +01:00
{
2002-05-11 20:53:13 +02:00
print_titre ( " Emettre une facture " );
2003-08-11 21:58:31 +02:00
if ( $propalid )
2002-12-14 17:25:46 +01:00
{
2003-09-06 02:31:41 +02:00
$sql = " SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, " . $db -> pdate ( " p.datep " ) . " as dp, c.id as statut, c.label as lst " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c " ;
2003-05-16 22:35:47 +02:00
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id " ;
2002-12-14 17:25:46 +01:00
$sql .= " AND p.rowid = $propalid " ;
2003-03-12 20:08:57 +01:00
}
else
{
2002-12-14 17:25:46 +01:00
$sql = " SELECT s.nom, s.prefix_comm, s.idp " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2003-11-24 11:15:11 +01:00
$sql .= " WHERE s.idp = " . $_GET [ " socidp " ];
2002-12-14 17:25:46 +01:00
}
2002-05-11 20:53:13 +02:00
2003-11-24 11:15:11 +01:00
if ( $_GET [ " commandeid " ])
{
$commande = New Commande ( $db );
$commande -> fetch ( $_GET [ " commandeid " ]);
$societe_id = $commande -> soc_id ;
}
2004-01-08 23:58:10 +01:00
if ( $db -> query ( $sql ) )
2002-12-14 17:25:46 +01:00
{
$num = $db -> num_rows ();
2003-08-11 21:58:31 +02:00
if ( $num )
{
$obj = $db -> fetch_object ( 0 );
2003-08-27 13:21:08 +02:00
$soc = new Societe ( $db );
2004-01-09 00:20:05 +01:00
$soc -> fetch ( $obj -> idp );
2003-08-27 13:21:08 +02:00
2003-08-11 21:58:31 +02:00
print '<form action="' . $PHP_SELF . '" method="post">' ;
print '<input type="hidden" name="action" value="add">' ;
2004-01-09 00:20:05 +01:00
print '<input type="hidden" name="socid" value="' . $obj -> idp . '">' . " \n " ;
2003-09-14 10:19:55 +02:00
print '<input type="hidden" name="remise_percent" value="0">' ;
2003-10-12 16:41:22 +02:00
print '<table class="border" cellspacing="0" cellpadding="3" width="100%">' ;
2003-08-11 21:58:31 +02:00
2003-11-24 11:15:11 +01:00
print '<tr><td>Client :</td><td>' . $soc -> nom . '</td>' ;
2003-10-12 16:41:22 +02:00
print '<td class="border">Commentaire</td></tr>' ;
2003-09-14 10:19:55 +02:00
2003-08-11 21:58:31 +02:00
print " <tr><td>Auteur :</td><td> " . $user -> fullname . " </td> " ;
2003-08-13 01:05:01 +02:00
print '<td rowspan="6" valign="top">' ;
2003-08-11 21:58:31 +02:00
print '<textarea name="note" wrap="soft" cols="60" rows="8"></textarea></td></tr>' ;
print " <tr><td>Date :</td><td> " ;
2002-12-14 17:25:46 +01:00
2003-08-11 21:58:31 +02:00
print_date_select ( time ());
2003-05-16 22:35:47 +02:00
2003-08-11 21:58:31 +02:00
print " </td></tr> " ;
2003-09-23 19:50:20 +02:00
print " <tr><td>Num<75> ro :</td><td>Provisoire</td></tr> " ;
print '<input name="facnumber" type="hidden" value="provisoire">' ;
2003-08-11 21:58:31 +02:00
print " <tr><td>Conditions de r<> glement :</td><td> " ;
2004-01-30 11:16:56 +01:00
$sql = " SELECT rowid, libelle FROM " . MAIN_DB_PREFIX . " cond_reglement ORDER BY sortorder " ;
2003-08-11 21:58:31 +02:00
$result = $db -> query ( $sql );
$conds = array ();
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$conds [ $objp -> rowid ] = $objp -> libelle ;
$i ++ ;
}
$db -> free ();
}
$html -> select_array ( " condid " , $conds );
print " </td></tr> " ;
print " <tr><td>Projet :</td><td> " ;
$proj = new Project ( $db );
$html -> select_array ( " projetid " , $proj -> liste_array ( $socidp ));
print " </td></tr> " ;
2003-11-24 11:15:11 +01:00
if ( $_GET [ " propalid " ] > 0 )
2003-08-11 21:58:31 +02:00
{
2003-09-06 02:31:41 +02:00
$amount = ( $obj -> price );
print '<input type="hidden" name="amount" value="' . $amount . '">' . " \n " ;
print '<input type="hidden" name="total" value="' . $obj -> total . '">' . " \n " ;
print '<input type="hidden" name="remise" value="' . $obj -> remise . '">' . " \n " ;
print '<input type="hidden" name="remise_percent" value="' . $obj -> remise_percent . '">' . " \n " ;
print '<input type="hidden" name="tva" value="' . $obj -> tva . '">' . " \n " ;
2003-08-11 21:58:31 +02:00
print '<input type="hidden" name="propalid" value="' . $propalid . '">' ;
print '<tr><td>Proposition</td><td colspan="2">' . $obj -> ref . '</td></tr>' ;
print '<tr><td>Montant HT</td><td colspan="2">' . price ( $amount ) . '</td></tr>' ;
print '<tr><td>TVA</td><td colspan="2">' . price ( $obj -> tva ) . " </td></tr> " ;
2003-11-24 11:15:11 +01:00
print '<tr><td>Total TTC</td><td colspan="2">' . price ( $obj -> total ) . " </td></tr> " ;
}
elseif ( $_GET [ " commandeid " ] > 0 )
{
print '<input type="hidden" name="commandeid" value="' . $commande -> id . '">' ;
print '<tr><td>Commande</td><td colspan="2">' . $commande -> ref . '</td></tr>' ;
print '<tr><td>Montant HT</td><td colspan="2">' . price ( $commande -> total_ht ) . '</td></tr>' ;
print '<tr><td>TVA</td><td colspan="2">' . price ( $commande -> total_tva ) . " </td></tr> " ;
print '<tr><td>Total TTC</td><td colspan="2">' . price ( $commande -> total_ttc ) . " </td></tr> " ;
}
2003-08-13 01:05:01 +02:00
else
2003-08-11 21:58:31 +02:00
{
2004-01-24 20:09:04 +01:00
print '<tr><td colspan="2"> </td></tr>' ;
2003-08-13 01:05:01 +02:00
print '<tr><td colspan="3">' ;
2003-08-11 21:58:31 +02:00
/*
*
* Liste des elements
*
*/
2004-01-30 11:16:56 +01:00
$sql = " SELECT p.rowid,p.label,p.ref,p.price FROM " . MAIN_DB_PREFIX . " product as p " ;
2003-08-11 21:58:31 +02:00
$sql .= " WHERE envente = 1 " ;
2004-01-08 23:58:10 +01:00
$sql .= " ORDER BY p.nbvente DESC LIMIT 20 " ;
2003-08-11 21:58:31 +02:00
if ( $db -> query ( $sql ) )
{
$opt = " <option value= \" 0 \" SELECTED></option> " ;
if ( $result )
{
$num = $db -> num_rows (); $i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$opt .= " <option value= \" $objp->rowid\ " > [ $objp -> ref ] $objp -> label : $objp -> price </ option > \n " ;
$i ++ ;
}
}
$db -> free ();
}
else
{
print $db -> error ();
}
2003-08-13 01:05:01 +02:00
2003-10-12 16:41:22 +02:00
print '<table class="noborder" cellspacing="0">' ;
2004-01-24 20:09:04 +01:00
print '<tr><td>Services/Produits pr<70> d<EFBFBD> finis</td><td>Quan.</td><td>Remise</td></tr>' ;
2003-08-11 21:58:31 +02:00
for ( $i = 1 ; $i < 5 ; $i ++ )
{
print '<tr><td><select name="idprod' . $i . '">' . $opt . '</select></td>' ;
2003-10-10 20:35:42 +02:00
print '<td><input type="text" size="3" name="qty' . $i . '" value="1"></td>' ;
print '<td><input type="text" size="4" name="remise_percent' . $i . '" value="0"> %</td></tr>' ;
2003-10-12 16:41:22 +02:00
}
2003-08-13 01:05:01 +02:00
print '</table>' ;
print '</td></tr>' ;
2003-08-11 21:58:31 +02:00
}
2003-10-12 16:41:22 +02:00
/*
* Factures r<EFBFBD> currentes
*
*/
2003-11-24 11:15:11 +01:00
if ( $_GET [ " propalid " ] == 0 && $_GET [ " commandeid " ] == 0 )
2003-10-12 16:41:22 +02:00
{
2004-01-30 11:16:56 +01:00
$sql = " SELECT r.rowid, r.titre, r.amount FROM " . MAIN_DB_PREFIX . " facture_rec as r " ;
2003-11-24 11:15:11 +01:00
$sql .= " WHERE r.fk_soc = " . $soc -> id ;
2003-10-12 16:41:22 +02:00
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
$i = 0 ;
if ( $num > 0 )
{
print '<tr><td colspan="3">Factures r<> currentes : <select name="fac_rec">' ;
print '<option value="0" selected></option>' ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
print " <option value= \" $objp->rowid\ " > $objp -> titre : $objp -> amount </ option > \n " ;
$i ++ ;
}
print '</select></td></tr>' ;
}
$db -> free ();
}
else
{
print " $sql " ;
}
}
/*
*
*/
2003-08-13 01:05:01 +02:00
print '<tr><td colspan="3" align="center"><input type="submit" value="Cr<43> er"></td></tr>' ;
print " </form> \n " ;
print " </table> \n " ;
2003-09-09 18:06:22 +02:00
2003-11-24 11:15:11 +01:00
if ( $_GET [ " propalid " ])
2003-09-09 18:06:22 +02:00
{
/*
* Produits
*/
print_titre ( " Produits " );
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">' ;
print '<tr class="liste_titre"><td>R<> f</td><td>Produit</td>' ;
2003-10-11 15:45:58 +02:00
print '<td align="right">Prix</td><td align="center">Remise</td><td align="center">Qt<51> .</td></tr>' ;
2003-09-09 18:06:22 +02:00
2003-10-11 15:45:58 +02:00
$sql = " SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propaldet as pt, " . MAIN_DB_PREFIX . " product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid " ;
2003-09-23 19:59:50 +02:00
$sql .= " ORDER BY pt.rowid ASC " ;
2003-09-09 18:06:22 +02:00
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ;
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
2003-10-11 15:45:58 +02:00
print " <tr $bc[$var] ><td>[ $objp->ref ]</td> \n " ;
2003-09-09 18:06:22 +02:00
print '<td>' . $objp -> product . '</td>' ;
print " <td align= \" right \" > " . price ( $objp -> price ) . " </TD> " ;
2003-10-11 15:45:58 +02:00
print '<td align="center">' . $objp -> remise_percent . ' %</td>' ;
2003-09-09 18:06:22 +02:00
print " <td align= \" center \" > " . $objp -> qty . " </td></tr> \n " ;
$i ++ ;
}
}
2003-10-11 15:45:58 +02:00
$sql = " SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propaldet as pt WHERE pt.fk_propal = $propalid AND pt.fk_product = 0 " ;
2003-10-11 15:45:58 +02:00
$sql .= " ORDER BY pt.rowid ASC " ;
if ( $db -> query ( $sql ))
{
$num = $db -> num_rows ();
$i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <tr $bc[$var] ><td> </td> \n " ;
print '<td>' . $objp -> product . '</td>' ;
print '<td align="right">' . price ( $objp -> price ) . '</td>' ;
print '<td align="center">' . $objp -> remise_percent . ' %</td>' ;
print " <td align= \" center \" > " . $objp -> qty . " </td></tr> \n " ;
$i ++ ;
}
}
else
{
print $sql ;
}
2003-09-09 18:06:22 +02:00
print '</table>' ;
2003-11-24 11:15:11 +01:00
}
/*
* Produits dans la commande
*
*/
if ( $_GET [ " commandeid " ])
{
print_titre ( " Produits " );
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">' ;
print '<tr class="liste_titre"><td>R<> f</td><td>Produit</td>' ;
print '<td align="right">Prix</td><td align="center">Remise</td><td align="center">Qt<51> .</td></tr>' ;
$sql = " SELECT pt.rowid, p.label as product, p.ref, pt.subprice, pt.qty, p.rowid as prodid, pt.remise_percent " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commandedet as pt, " . MAIN_DB_PREFIX . " product as p WHERE pt.fk_product = p.rowid AND pt.fk_commande = " . $commande -> id ;
2003-11-24 11:15:11 +01:00
$sql .= " ORDER BY pt.rowid ASC " ;
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ;
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <tr $bc[$var] ><td>[ $objp->ref ]</td> \n " ;
print '<td>' . $objp -> product . '</td>' ;
print " <td align= \" right \" > " . price ( $objp -> subprice ) . " </TD> " ;
print '<td align="center">' . $objp -> remise_percent . ' %</td>' ;
print " <td align= \" center \" > " . $objp -> qty . " </td></tr> \n " ;
$i ++ ;
}
}
else
{
print $sql ;
}
print '</table>' ;
}
2003-08-11 21:58:31 +02:00
}
2002-12-14 17:25:46 +01:00
}
else
{
print $db -> error ();
2002-04-30 12:44:42 +02:00
}
2002-12-14 17:25:46 +01:00
}
else
/* *************************************************************************** */
/* */
2003-11-21 19:25:03 +01:00
/* Mode fiche */
2002-12-14 17:25:46 +01:00
/* */
/* *************************************************************************** */
{
2003-11-21 19:25:03 +01:00
if ( $_GET [ " facid " ] > 0 )
{
2003-07-12 12:33:55 +02:00
$fac = New Facture ( $db );
2003-11-21 19:25:03 +01:00
if ( $fac -> fetch ( $_GET [ " facid " ], $user -> societe_id ) > 0 )
2003-09-09 18:06:22 +02:00
{
$soc = new Societe ( $db , $fac -> socidp );
$soc -> fetch ( $fac -> socidp );
$author = new User ( $db );
$author -> id = $fac -> user_author ;
$author -> fetch ();
print_titre ( " Facture : " . $fac -> ref );
2003-10-21 13:44:01 +02:00
/*
* Confirmation de la suppression de la facture
*
*/
2003-11-24 11:15:11 +01:00
if ( $_GET [ " action " ] == 'delete' )
2003-10-21 13:44:01 +02:00
{
2003-11-21 19:25:03 +01:00
$html -> form_confirm ( " $PHP_SELF ?facid= $fac->id " , " Supprimer la facture " , " Etes-vous s<> r de vouloir supprimer cette facture ? " , " confirm_delete " );
2003-10-21 13:44:01 +02:00
}
2003-09-09 18:06:22 +02:00
2003-10-21 13:44:01 +02:00
/*
* Confirmation de la validation
*
*/
if ( $action == 'valid' )
{
$numfa = facture_get_num ( $soc );
2003-11-21 19:25:03 +01:00
$html -> form_confirm ( " $PHP_SELF ?facid= $fac->id " , " Valider la facture " , " Etes-vous s<> r de vouloir valider cette facture avec le num<75> ro $numfa ? " , " confirm_valid " );
2003-10-21 13:44:01 +02:00
}
2003-09-09 18:06:22 +02:00
/*
* Facture
*/
2003-10-12 22:12:23 +02:00
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">' ;
2003-09-09 18:06:22 +02:00
print " <tr><td>Client</td> " ;
print " <td colspan= \" 3 \" > " ;
2003-09-11 22:18:51 +02:00
print '<b><a href="fiche.php?socid=' . $soc -> id . '">' . $soc -> nom . '</a></b></td>' ;
2003-09-09 18:06:22 +02:00
print " <td>Conditions de r<> glement : " . $fac -> cond_reglement . " </td></tr> " ;
print " <tr><td>Date</td> " ;
print " <td colspan= \" 3 \" > " . strftime ( " %A %d %B %Y " , $fac -> date ) . " </td> \n " ;
print " <td>Date limite de r<> glement : " . strftime ( " %d %B %Y " , $fac -> date_lim_reglement ) . " </td></tr> " ;
2003-10-22 16:24:13 +02:00
print '<tr><td>Projet</td><td colspan="3">' ;
if ( $fac -> projetid > 0 )
{
$projet = New Project ( $db );
$projet -> fetch ( $fac -> projetid );
print '<a href="' . DOL_URL_ROOT . '/projet/fiche.php?id=' . $fac -> projetid . '">' . $projet -> title . '</a>' ;
}
2003-10-22 17:38:43 +02:00
else
{
2003-11-21 19:25:03 +01:00
print '<a href="facture.php?facid=' . $fac -> id . '&action=classer">Classer la facture</a>' ;
2003-10-22 17:38:43 +02:00
}
2003-10-22 16:24:13 +02:00
print " </td><td>Paiements</td></tr> " ;
2003-09-09 18:06:22 +02:00
print " <tr><td>Auteur</td><td colspan= \" 3 \" > $author->fullname </td> " ;
if ( $fac -> remise_percent > 0 )
{
print '<td rowspan="5" valign="top">' ;
}
else
{
print '<td rowspan="4" valign="top">' ;
}
2003-10-11 15:45:58 +02:00
2003-09-09 18:06:22 +02:00
/*
* Paiements
*/
2003-03-23 16:53:03 +01:00
$sql = " SELECT " . $db -> pdate ( " datep " ) . " as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " paiement as p, " . MAIN_DB_PREFIX . " c_paiement as c WHERE p.fk_facture = " . $fac -> id . " AND p.fk_paiement = c.id " ;
2003-03-23 16:53:03 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ; $total = 0 ;
2003-10-12 22:12:23 +02:00
echo '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">' ;
2003-10-22 16:24:13 +02:00
print '<tr class="liste_titre"><td>Date</td><td>Type</td>' ;
2003-03-23 16:53:03 +01:00
print " <td align= \" right \" >Montant</TD><td> </td> " ;
2003-09-09 18:06:22 +02:00
if ( ! $fac -> paye )
2003-07-08 22:59:01 +02:00
{
print " <td> </td> " ;
}
2003-03-23 16:53:03 +01:00
print " </TR> \n " ;
2003-02-01 20:45:45 +01:00
2003-03-23 16:53:03 +01:00
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] > " ;
print " <TD> " . strftime ( " %d %B %Y " , $objp -> dp ) . " </TD> \n " ;
print " <TD> $objp->paiement_type $objp->num_paiement </TD> \n " ;
2003-07-08 22:59:01 +02:00
print '<td align="right">' . price ( $objp -> amount ) . " </TD><td> $_MONNAIE </td> \n " ;
2003-09-09 18:06:22 +02:00
if ( ! $fac -> paye && $user -> rights -> facture -> paiement )
2003-07-08 22:59:01 +02:00
{
2003-11-21 19:25:03 +01:00
print '<td><a href="facture.php?facid=' . $fac -> id . '&action=del_paiement&paiementid=' . $objp -> rowid . '">Del</a>' ;
2003-07-08 22:59:01 +02:00
}
2003-03-23 16:53:03 +01:00
print " </tr> " ;
$total = $total + $objp -> amount ;
$i ++ ;
}
2003-02-01 20:45:45 +01:00
2003-09-09 18:06:22 +02:00
if ( $fac -> paye == 0 )
2003-03-23 16:53:03 +01:00
{
print " <tr><td colspan= \" 2 \" align= \" right \" >Total :</td><td align= \" right \" ><b> " . price ( $total ) . " </b></td><td> $_MONNAIE </td></tr> \n " ;
2003-09-09 18:06:22 +02:00
print " <tr><td colspan= \" 2 \" align= \" right \" >Factur<75> :</td><td align= \" right \" bgcolor= \" #d0d0d0 \" > " . price ( $fac -> total_ttc ) . " </td><td bgcolor= \" #d0d0d0 \" > $_MONNAIE </td></tr> \n " ;
2003-03-23 16:53:03 +01:00
2003-09-09 18:06:22 +02:00
$resteapayer = price ( $fac -> total_ttc - $total );
2002-04-30 12:44:42 +02:00
2003-05-13 22:39:13 +02:00
print " <tr><td colspan= \" 2 \" align= \" right \" >Reste <20> payer :</td> " ;
2003-09-09 18:06:22 +02:00
print " <td align= \" right \" bgcolor= \" #f0f0f0 \" ><b> " . price ( $fac -> total_ttc - $total ) . " </b></td><td bgcolor= \" #f0f0f0 \" > $_MONNAIE </td></tr> \n " ;
2003-03-23 16:53:03 +01:00
}
print " </table> " ;
$db -> free ();
} else {
print $db -> error ();
}
print " </td></tr> " ;
2003-07-21 15:05:24 +02:00
print '<tr><td>Montant</td>' ;
print '<td align="right" colspan="2"><b>' . price ( $fac -> total_ht ) . '</b></td>' ;
2003-10-11 15:45:58 +02:00
print '<td>' . MAIN_MONNAIE . ' HT</td></tr>' ;
2003-09-06 02:31:41 +02:00
if ( $fac -> remise_percent > 0 )
{
print '<tr><td>Remise</td>' ;
print '<td align="right" colspan="2">' . $fac -> remise_percent . '</td>' ;
print '<td>%</td></tr>' ;
}
2003-07-21 15:05:24 +02:00
print '<tr><td>TVA</td><td align="right" colspan="2">' . price ( $fac -> total_tva ) . '</td>' ;
2003-10-11 15:45:58 +02:00
print '<td>' . MAIN_MONNAIE . '</td></tr>' ;
2003-07-21 15:05:24 +02:00
print '<tr><td>Total</td><td align="right" colspan="2">' . price ( $fac -> total_ttc ) . '</td>' ;
2003-10-11 15:45:58 +02:00
print '<td>' . MAIN_MONNAIE . ' TTC</td></tr>' ;
2003-07-21 15:05:24 +02:00
if ( $fac -> note )
2003-05-17 17:59:23 +02:00
{
2003-09-09 18:06:22 +02:00
print '<tr><td colspan="5">Note : ' . nl2br ( $fac -> note ) . " </td></tr> " ;
2003-05-17 17:59:23 +02:00
}
2003-07-21 15:05:24 +02:00
2003-09-06 02:31:41 +02:00
print " </table><br> " ;
2003-10-14 13:02:31 +02:00
if ( $fac -> brouillon == 1 && $user -> rights -> facture -> creer )
2003-09-06 02:31:41 +02:00
{
2003-11-21 19:25:03 +01:00
print '<form action="facture.php?facid=' . $fac -> id . '" method="post">' ;
2003-09-06 02:31:41 +02:00
print '<input type="hidden" name="action" value="setremise">' ;
print '<table cellpadding="3" cellspacing="0" border="1"><tr><td>Remise</td><td align="right">' ;
print '<input type="text" name="remise" size="3" value="' . $fac -> remise_percent . '">%' ;
print '<input type="submit" value="Appliquer">' ;
print '</td></tr></table></form>' ;
}
2003-03-23 16:53:03 +01:00
/*
* Lignes de factures
*
*/
2003-09-23 19:50:20 +02:00
$sql = " SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " facturedet as l WHERE l.fk_facture = $fac->id ORDER BY l.rowid " ;
2003-03-23 16:53:03 +01:00
$result = $db -> query ( $sql );
if ( $result )
2003-02-02 16:01:56 +01:00
{
2003-03-23 16:53:03 +01:00
$num = $db -> num_rows ();
2003-02-02 16:01:56 +01:00
$i = 0 ; $total = 0 ;
2003-03-23 16:53:03 +01:00
echo '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">' ;
2003-05-17 17:59:23 +02:00
if ( $num )
{
print " <TR class= \" liste_titre \" > " ;
2003-09-23 19:50:20 +02:00
print '<td width="54%">Description</td>' ;
print '<td width="8%" align="center">Tva</td>' ;
2003-05-17 17:59:23 +02:00
print '<td width="8%" align="center">Quantit<69> </td>' ;
2003-09-23 19:50:20 +02:00
print '<td width="8%" align="right">Remise</td>' ;
print '<td width="12%" align="right">P.U.</td>' ;
2003-05-17 17:59:23 +02:00
print '<td width="10%"> </td><td width="10%"> </td>' ;
print " </TR> \n " ;
}
2003-02-02 16:01:56 +01:00
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] > " ;
2003-10-12 16:41:22 +02:00
if ( $objp -> fk_product > 0 )
2003-06-27 18:11:55 +02:00
{
2003-09-11 22:18:51 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' . stripslashes ( nl2br ( $objp -> description )) . '</a></td>' ;
2003-06-27 18:11:55 +02:00
}
else
{
print " <td> " . stripslashes ( nl2br ( $objp -> description )) . " </TD> \n " ;
}
2003-04-13 16:47:33 +02:00
print '<TD align="center">' . $objp -> tva_taux . ' %</TD>' ;
2003-03-23 16:53:03 +01:00
print '<TD align="center">' . $objp -> qty . '</TD>' ;
2003-09-23 19:50:20 +02:00
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 " ;
2003-10-14 13:02:31 +02:00
if ( $fac -> statut == 0 && $user -> rights -> facture -> creer )
2003-03-23 16:53:03 +01:00
{
2003-11-21 19:25:03 +01:00
print '<td align="right"><a href="' . $PHPSELF . '?facid=' . $fac -> id . '&action=editline&rowid=' . $objp -> rowid . '">' ;
2003-11-07 11:03:37 +01:00
print img_edit ();
print '</a></td>' ;
2003-11-21 19:25:03 +01:00
print '<td align="right"><a href="' . $PHPSELF . '?facid=' . $fac -> id . '&action=deleteline&rowid=' . $objp -> rowid . '">' ;
2003-11-07 11:03:37 +01:00
print img_delete ();
print '</a></td>' ;
2003-03-23 16:53:03 +01:00
}
else
{
print '<td> </td><td> </td>' ;
}
2003-02-02 16:01:56 +01:00
print " </tr> " ;
2003-03-23 16:53:03 +01:00
if ( $action == 'editline' && $rowid == $objp -> rowid )
{
2003-11-21 19:25:03 +01:00
print " <form action= \" $PHP_SELF ?facid= $fac->id\ " method = \ " post \" > " ;
2003-03-23 16:53:03 +01:00
print '<input type="hidden" name="action" value="updateligne">' ;
print '<input type="hidden" name="rowid" value="' . $rowid . '">' ;
print " <TR $bc[$var] > " ;
2003-09-23 19:50:20 +02:00
print '<TD colspan="2"><textarea name="desc" cols="60" rows="2">' . stripslashes ( $objp -> description ) . '</textarea></TD>' ;
2003-08-04 14:46:47 +02:00
print '<TD align="center"><input size="4" type="text" name="qty" value="' . $objp -> qty . '"></TD>' ;
2003-09-23 19:50:20 +02:00
print '<TD align="right"><input size="3" type="text" name="remise_percent" value="' . $objp -> remise_percent . '"> %</td>' ;
print '<TD align="right"><input size="8" type="text" name="price" value="' . price ( $objp -> subprice ) . '"></td>' ;
2003-08-04 14:46:47 +02:00
print '<td align="right" colspan="2"><input type="submit" value="Enregistrer"></td>' ;
2003-03-23 16:53:03 +01:00
print '</tr>' . " \n " ;
print " </form> \n " ;
}
$total = $total + ( $objp -> qty * $objp -> price );
2003-02-02 16:01:56 +01:00
$i ++ ;
}
2003-03-23 16:53:03 +01:00
$db -> free ();
2003-04-13 21:23:35 +02:00
// print "</table>";
2003-03-23 16:53:03 +01:00
}
else
{
print $db -> error ();
2003-02-02 16:01:56 +01:00
}
2003-02-01 20:45:45 +01:00
2003-03-23 16:53:03 +01:00
/*
* Ajouter une ligne
*
*/
2003-10-14 13:02:31 +02:00
if ( $fac -> statut == 0 && $user -> rights -> facture -> creer )
2003-03-23 16:53:03 +01:00
{
2004-01-24 20:09:04 +01:00
print " <form action= \" $PHP_SELF ?facid= $fac->id\ " method = \ " post \" > " ;
2003-04-13 21:23:35 +02:00
// echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="1">';
2003-03-23 16:53:03 +01:00
print " <TR class= \" liste_titre \" > " ;
2003-09-23 19:50:20 +02:00
print '<td width="54%">Description</td>' ;
print '<td width="8%" align="center">Tva</td>' ;
2003-04-13 21:23:35 +02:00
print '<td width="8%" align="center">Quantit<69> </td>' ;
2003-09-23 19:50:20 +02:00
print '<td width="8%" align="right">Remise</td>' ;
print '<td width="12%" align="right">P.U.</TD>' ;
2003-04-13 21:23:35 +02:00
print '<td> </td>' ;
print '<td> </td>' ;
2003-03-23 16:53:03 +01:00
print " </TR> \n " ;
print '<input type="hidden" name="action" value="addligne">' ;
2003-09-23 19:50:20 +02:00
print '<tr><td><textarea name="desc" cols="60" rows="2"></textarea></td>' ;
2003-05-16 15:30:46 +02:00
print '<td align="center">' ;
print $html -> select_tva ( " tva_tx " );
print '</td>' ;
2003-09-23 19:50:20 +02:00
print '<td align="center"><input type="text" name="qty" value="1" size="2"></td>' ;
print '<td align="right"><input type="text" name="remise_percent" size="4" value="0"> %</td>' ;
2003-04-13 21:23:35 +02:00
print '<td align="right"><input type="text" name="pu" size="8"></td>' ;
2003-05-17 17:59:23 +02:00
print '<td align="center" colspan="3"><input type="submit" value="Ajouter"></td></tr>' ;
2003-03-23 16:53:03 +01:00
print " </form> " ;
}
2003-04-13 21:23:35 +02:00
print " </table> " ;
2003-03-23 16:53:03 +01:00
/*
* Fin Ajout ligne
*
*/
2003-10-09 01:14:20 +02:00
if ( $user -> societe_id == 0 )
2003-03-23 16:53:03 +01:00
{
2003-10-14 13:22:36 +02:00
print '<p><table id="actions" width="100%"><tr>' ;
2003-02-02 16:01:56 +01:00
2003-09-09 18:06:22 +02:00
if ( $fac -> statut == 0 && $user -> rights -> facture -> supprimer )
2003-03-23 16:53:03 +01:00
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" $PHP_SELF ?facid= $fac->id &action=delete \" >Supprimer</a></td> " ;
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
elseif ( $fac -> statut == 1 && abs ( $resteapayer ) > 0 && $user -> rights -> facture -> envoyer )
2003-03-23 16:53:03 +01:00
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" $PHP_SELF ?facid= $fac->id &action=presend \" >Envoyer</a></td> " ;
2003-03-23 16:53:03 +01:00
}
else
{
2003-10-09 01:14:20 +02:00
print " <td align= \" center \" width= \" 20% \" >-</td> " ;
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
if ( $fac -> statut == 1 && $resteapayer > 0 && $user -> rights -> facture -> paiement )
2003-03-23 16:53:03 +01:00
{
2003-11-24 11:15:11 +01:00
print '<td align="center" width="20%">' ;
print '<a href="paiement.php?facid=' . $fac -> id . '&action=create">Emettre un paiement</a></td>' ;
2003-03-23 16:53:03 +01:00
}
else
{
2003-11-24 11:15:11 +01:00
print '<td align="center" width="20%">-</td>' ;
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
if ( $fac -> statut == 1 && abs ( $resteapayer ) == 0 && $fac -> paye == 0 )
2003-03-23 16:53:03 +01:00
{
2003-08-12 15:21:49 +02:00
if ( $user -> rights -> facture -> paiement )
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" $PHP_SELF ?facid= $fac->id &action=payed \" >Classer 'Pay<61> e'</a></td> " ;
2003-08-12 15:21:49 +02:00
}
else
{
2003-10-09 01:14:20 +02:00
print '<td align="center" width="20%">-</td>' ;
2003-08-12 15:21:49 +02:00
}
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
elseif ( $fac -> statut == 1 && $resteapayer > 0 && $user -> rights -> facture -> envoyer )
2003-07-24 13:05:57 +02:00
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" $PHP_SELF ?facid= $fac->id &action=prerelance \" >Envoyer une relance</a></td> " ;
2003-11-09 18:24:14 +01:00
}
else
{
print '<td align="center" width="20%">-</td>' ;
}
if ( $fac -> statut > 0 )
{
2003-11-21 19:25:03 +01:00
print '<td align="center" width="20%"><a href="facture/fiche-rec.php?facid=' . $fac -> id . '&action=create">R<> currente</a></td>' ;
2003-07-24 13:05:57 +02:00
}
2003-03-23 16:53:03 +01:00
else
{
2003-10-09 01:14:20 +02:00
print '<td align="center" width="20%">-</td>' ;
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
if ( $fac -> statut == 0 && $fac -> total_ht > 0 )
2003-03-23 16:53:03 +01:00
{
2003-08-12 15:21:49 +02:00
if ( $user -> rights -> facture -> valider )
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" $PHP_SELF ?facid= $fac->id &action=valid \" >Valider</a></td> " ;
2003-08-12 15:21:49 +02:00
}
else
{
2003-10-09 01:14:20 +02:00
print '<td align="center" width="20%">-</td>' ;
2003-08-12 15:21:49 +02:00
}
2003-03-23 16:53:03 +01:00
}
2003-09-09 18:06:22 +02:00
elseif ( $fac -> statut == 1 && $fac -> paye == 0 )
2003-03-23 16:53:03 +01:00
{
2003-08-12 15:21:49 +02:00
if ( $user -> rights -> facture -> creer )
{
2003-11-21 19:25:03 +01:00
print " <td align= \" center \" width= \" 20% \" ><a href= \" facture.php?facid= $fac->id &action=pdf \" >G<> n<EFBFBD> rer la facture</a></td> " ;
2003-08-12 15:21:49 +02:00
}
else
{
2003-10-09 01:14:20 +02:00
print '<td align="center" width="20%">-</td>' ;
2003-08-12 15:21:49 +02:00
}
2003-03-23 16:53:03 +01:00
}
2003-04-13 16:47:33 +02:00
else
{
2003-10-09 01:14:20 +02:00
print '<td align="center" width="20%">-</td>' ;
2003-04-13 16:47:33 +02:00
}
2003-10-09 01:14:20 +02:00
2003-03-23 16:53:03 +01:00
print " </tr></table> " ;
}
print " <p> \n " ;
2003-04-13 16:47:33 +02:00
2003-03-23 16:53:03 +01:00
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*
*/
2003-09-09 19:05:18 +02:00
$file = FAC_OUTPUTDIR . " / " . $fac -> ref . " / " . $fac -> ref . " .pdf " ;
2003-03-23 16:53:03 +01:00
if ( file_exists ( $file ))
{
2003-09-23 19:50:20 +02:00
print " <table width= \" 100% \" cellspacing=2><tr><td width= \" 50% \" valign= \" top \" > " ;
print_titre ( " Documents " );
2003-10-22 16:24:13 +02:00
print '<table width="100%" cellspacing="0" class="border" cellpadding="3">' ;
2003-09-23 19:50:20 +02:00
2003-10-14 17:20:42 +02:00
print " <tr $bc[0] ><td>Facture PDF</td> " ;
2003-09-09 19:05:18 +02:00
print '<td><a href="' . FAC_OUTPUT_URL . " / " . $fac -> ref . " / " . $fac -> ref . '.pdf">' . $fac -> ref . '.pdf</a></td>' ;
2003-03-23 16:53:03 +01:00
print '<td align="right">' . filesize ( $file ) . ' bytes</td>' ;
print '<td align="right">' . strftime ( " %d %b %Y %H:%M:%S " , filemtime ( $file )) . '</td>' ;
print '</tr>' ;
2003-09-23 19:50:20 +02:00
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 " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a WHERE a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_facture = $fac->id " ;
2003-03-23 16:53:03 +01:00
2003-09-23 19:50:20 +02:00
$result = $db -> query ( $sql );
if ( $result )
2003-03-23 16:53:03 +01:00
{
2003-09-23 19:50:20 +02:00
$num = $db -> num_rows ();
if ( $num )
2003-03-23 16:53:03 +01:00
{
2003-09-23 19:50:20 +02:00
$i = 0 ; $total = 0 ;
print '<table border="1" cellspacing="0" cellpadding="4" width="100%">' ;
print " <tr $bc[$var] ><td>Date</td><td>Action</td></tr> \n " ;
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$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> " ;
2003-03-23 16:53:03 +01:00
}
}
2003-09-23 19:50:20 +02:00
else
{
print $db -> error ();
}
/*
*
*
*/
print " </td></tr></table> " ;
2003-03-23 16:53:03 +01:00
}
/*
*
*
*/
2003-10-22 17:38:43 +02:00
if ( $action == 'classer' )
{
2003-11-21 19:25:03 +01:00
print " <p><form method= \" post \" action= \" $PHP_SELF ?facid= $fac->id\ " > \n " ;
2003-10-22 17:38:43 +02:00
print '<input type="hidden" name="action" value="classin">' ;
print '<table cellspacing="0" class="border" cellpadding="3">' ;
print '<tr><td>Projet</td><td>' ;
$proj = new Project ( $db );
$html -> select_array ( " projetid " , $proj -> liste_array ( $socidp ));
print " </td></tr> " ;
print '<tr><td colspan="2" align="center"><input type="submit" value="Envoyer"></td></tr></table></form></p>' ;
}
/*
*
*
*/
2003-03-23 16:53:03 +01:00
if ( $action == 'presend' )
{
2003-04-13 21:37:14 +02:00
$replytoname = $user -> fullname ;
2003-03-23 16:53:03 +01:00
$from_name = $replytoname ;
2003-04-13 21:37:14 +02:00
$replytomail = $user -> email ;
2003-03-23 16:53:03 +01:00
$from_mail = $replytomail ;
2003-11-21 19:25:03 +01:00
print " <form method= \" post \" action= \" $PHP_SELF ?facid= $fac->id &action=send \" > \n " ;
2003-07-24 13:05:57 +02:00
print '<input type="hidden" name="replytoname" value="' . $replytoname . '">' ;
print '<input type="hidden" name="replytomail" value="' . $replytomail . '">' ;
2003-03-23 16:53:03 +01:00
print " <p><b>Envoyer la facture par mail</b> " ;
print " <table cellspacing=0 border=1 cellpadding=3> " ;
print '<tr><td>Destinataire</td><td colspan="5">' ;
2003-07-24 13:05:57 +02:00
$form = new Form ( $db );
$form -> select_array ( " destinataire " , $soc -> contact_email_array ());
2003-09-09 18:06:22 +02:00
print " </td><td><input size= \" 30 \" name= \" sendto \" value= \" $fac->email\ " ></ td ></ tr > " ;
2004-01-24 20:09:04 +01:00
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><td> $replytomail </td></tr> " ;
print " </table> " ;
2003-07-24 13:05:57 +02:00
print " <input type= \" submit \" value= \" Envoyer \" ></form> " ;
}
if ( $action == 'prerelance' )
{
$replytoname = $user -> fullname ;
$from_name = $replytoname ;
$replytomail = $user -> email ;
$from_mail = $replytomail ;
2003-11-21 19:25:03 +01:00
print " <form method= \" post \" action= \" $PHP_SELF ?facid= $fac->id\ " > \n " ;
2003-07-24 13:05:57 +02:00
print '<input type="hidden" name="action" value="relance">' ;
print '<input type="hidden" name="replytoname" value="' . $replytoname . '">' ;
print '<input type="hidden" name="replytomail" value="' . $replytomail . '">' ;
print_titre ( " Envoyer une relance " );
print " <table cellspacing=0 border=1 cellpadding=3> " ;
print '<tr><td>Destinataire</td><td colspan="5">' ;
2003-03-23 16:53:03 +01:00
2003-07-24 13:05:57 +02:00
$form = new Form ( $db );
2003-03-23 16:53:03 +01:00
$form -> select_array ( " destinataire " , $soc -> contact_email_array ());
2003-09-09 18:06:22 +02:00
print " </td><td><input size= \" 30 \" name= \" sendto \" value= \" $fac->email\ " ></ td ></ tr > " ;
2003-03-23 16:53:03 +01:00
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> " ;
2003-07-24 13:05:57 +02:00
print " <td> $replytomail </td></tr></table> " ;
2003-03-23 16:53:03 +01:00
2003-07-24 13:05:57 +02:00
print " <input type= \" submit \" value= \" Envoyer \" ></form> " ;
2003-03-23 16:53:03 +01:00
}
/*
* Propales
*/
$sql = " SELECT " . $db -> pdate ( " p.datep " ) . " as dp, p.price, p.ref, p.rowid as propalid " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id " ;
2002-04-30 12:44:42 +02:00
2003-03-23 16:53:03 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
if ( $num )
{
$i = 0 ; $total = 0 ;
2003-06-24 22:53:03 +02:00
print " <p> " ;
if ( $num > 1 )
{
print_titre ( " Propositions commerciales associ<63> es " );
}
else
{
print_titre ( " Proposition commerciale associ<63> e " );
}
2003-10-12 22:12:23 +02:00
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">' ;
2003-06-24 22:53:03 +02:00
print '<tr class="liste_titre">' ;
print " <td>Num<75> ro</td> " ;
2003-03-23 16:53:03 +01:00
print " <td>Date</td> " ;
2003-06-24 22:53:03 +02:00
print '<td align="right">Prix</td>' ;
2003-03-23 16:53:03 +01:00
print " </TR> \n " ;
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] > " ;
2003-09-11 22:18:51 +02:00
print " <TD><a href= \" propal.php?propalid= $objp->propalid\ " > $objp -> ref </ a ></ TD > \n " ;
2003-03-23 16:53:03 +01:00
print " <TD> " . strftime ( " %d %B %Y " , $objp -> dp ) . " </TD> \n " ;
print '<TD align="right">' . price ( $objp -> price ) . '</TD>' ;
print " </tr> " ;
$total = $total + $objp -> price ;
$i ++ ;
}
print " <tr><td align= \" right \" colspan= \" 3 \" >Total : <b> " . price ( $total ) . " </b> $_MONNAIE HT</td></tr> \n " ;
print " </table> " ;
}
} else {
print $db -> error ();
}
}
else
{
/* Facture non trouv<75> e */
print " Facture inexistante ou acc<63> s refus<75> " ;
2002-05-11 20:53:13 +02:00
}
2002-04-30 12:44:42 +02:00
} else {
2003-09-03 16:00:35 +02:00
/***************************************************************************
* *
* Mode Liste *
* *
* *
***************************************************************************/
2003-05-13 22:39:13 +02:00
if ( $page == - 1 )
{
$page = 0 ;
}
2003-08-06 14:38:46 +02:00
if ( $user -> rights -> facture -> lire )
2003-06-18 14:44:52 +02:00
{
2003-08-06 14:38:46 +02:00
$limit = $conf -> liste_limit ;
$offset = $limit * $page ;
2003-06-18 14:44:52 +02:00
2003-08-06 14:38:46 +02:00
if ( $sortorder == " " )
$sortorder = " DESC " ;
2003-07-22 18:05:14 +02:00
2003-08-06 14:38:46 +02:00
if ( $sortfield == " " )
$sortfield = " f.datef " ;
2004-01-24 20:09:04 +01:00
$sql = " SELECT s.nom,s.idp,f.facnumber,f.total,f.total_ttc, " . $db -> pdate ( " f.datef " ) . " as df,f.paye,f.rowid as facid, f.fk_statut, sum(p.amount) as am " ;
2004-01-30 11:16:56 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture as f left join " . MAIN_DB_PREFIX . " paiement as p on f.rowid=p.fk_facture WHERE f.fk_soc = s.idp " ;
2003-08-06 14:38:46 +02:00
if ( $socidp )
$sql .= " AND s.idp = $socidp " ;
if ( $month > 0 )
$sql .= " AND date_format(f.datef, '%m') = $month " ;
if ( $filtre )
2003-07-22 18:05:14 +02:00
{
2003-08-06 14:38:46 +02:00
$filtrearr = split ( " , " , $filtre );
foreach ( $filtrearr as $fil )
{
$filt = split ( " : " , $fil );
$sql .= " AND " . $filt [ 0 ] . " = " . $filt [ 1 ];
}
2003-07-22 18:05:14 +02:00
}
2003-08-06 14:38:46 +02:00
if ( $year > 0 )
$sql .= " AND date_format(f.datef, '%Y') = $year " ;
2003-09-03 16:00:35 +02:00
if ( strlen ( $HTTP_POST_VARS [ " sf_ref " ]) > 0 )
{
$sql .= " AND f.facnumber like '% " . $HTTP_POST_VARS [ " sf_ref " ] . " %' " ;
}
2004-01-24 20:09:04 +01:00
$sql .= " GROUP BY f.facnumber " ;
$sql .= " ORDER BY $sortfield $sortorder , f.rowid DESC " ;
2003-08-06 14:38:46 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
$result = $db -> query ( $sql );
2003-07-22 18:05:14 +02:00
}
2003-07-10 15:07:56 +02:00
if ( $result )
{
$num = $db -> num_rows ();
2004-01-24 20:09:04 +01:00
print_barre_liste ( " Factures clients " , $page , $PHP_SELF , " &socidp= $socidp " , $sortfield , $sortorder , '' , $num );
2003-07-10 15:07:56 +02:00
$i = 0 ;
print " <TABLE border= \" 0 \" width= \" 100% \" cellspacing= \" 0 \" cellpadding= \" 4 \" > " ;
print '<TR class="liste_titre">' ;
print '<TD>Numéro</TD>' ;
2004-01-24 20:09:04 +01:00
print '<TD align="center">' ;
print_liste_field_titre ( " Date facturation " , $PHP_SELF , " f.datef " , " " , " &socidp= $socidp " );
print '</td>' ;
print '<td>' ;
print_liste_field_titre ( " Soci<EFBFBD> t<EFBFBD> " , $PHP_SELF , " s.nom " , " " , " &socidp= $socidp " );
print '</td>' ;
print '<td align="right">' ;
print_liste_field_titre ( " Montant HT " , $PHP_SELF , " s.nom " , " " , " &socidp= $socidp " );
print '</td>' ;
print '<td align="right">' ;
print_liste_field_titre ( " Montant TTC " , $PHP_SELF , " s.nom " , " " , " &socidp= $socidp " );
print '</td>' ;
print '<TD align="right">Re<52> u</TD>' ;
print '<td align="center">Status</td>' ;
2003-07-10 15:07:56 +02:00
print " </TR> \n " ;
2003-07-12 12:33:55 +02:00
if ( $num > 0 )
{
$var = True ;
2004-01-24 20:09:04 +01:00
$total = 0 ;
$totalrecu = 0 ;
2003-07-12 12:33:55 +02:00
while ( $i < min ( $num , $limit ))
2003-07-10 15:07:56 +02:00
{
2003-07-21 15:05:24 +02:00
$objp = $db -> fetch_object ( $i );
2003-07-12 12:33:55 +02:00
$var =! $var ;
2003-07-21 15:05:24 +02:00
print " <tr $bc[$var] > " ;
2003-07-12 12:33:55 +02:00
if ( $objp -> paye )
{
2003-07-22 18:05:14 +02:00
$class = " normal " ;
2003-07-12 12:33:55 +02:00
}
else
{
2003-07-22 18:05:14 +02:00
if ( $objp -> fk_statut == 0 )
{
$class = " normal " ;
}
else
{
$class = " impayee " ;
}
2003-07-12 12:33:55 +02:00
}
2003-07-22 18:05:14 +02:00
2004-01-24 20:09:04 +01:00
print '<td><a href="facture.php?facid=' . $objp -> facid . '">' . $objp -> facnumber ;
2003-07-12 12:33:55 +02:00
print " </a></TD> \n " ;
if ( $objp -> df > 0 )
{
2004-01-24 20:09:04 +01:00
print " <TD align= \" center \" > " ;
2003-07-12 12:33:55 +02:00
$y = strftime ( " %Y " , $objp -> df );
$m = strftime ( " %m " , $objp -> df );
print strftime ( " %d " , $objp -> df ) . " \n " ;
2004-01-24 20:09:04 +01:00
print ' <a href="facture.php?year=' . $y . '&month=' . $m . '">' ;
print substr ( strftime ( " %B " , $objp -> df ), 0 , 3 ) . " </a> \n " ;
print ' <a href="facture.php?year=' . $y . '">' ;
2003-07-12 12:33:55 +02:00
print strftime ( " %Y " , $objp -> df ) . " </a></TD> \n " ;
}
else
{
2004-01-24 20:09:04 +01:00
print " <TD align= \" center \" ><b>!!!</b></TD> \n " ;
2003-07-12 12:33:55 +02:00
}
2004-01-24 20:09:04 +01:00
print '<TD><a href="fiche.php?socid=' . $objp -> idp . '">' . $objp -> nom . '</a></td>' ;
2003-07-12 12:33:55 +02:00
2004-01-24 20:09:04 +01:00
print " <TD align= \" right \" > " . price ( $objp -> total ) . " </TD> " ;
print " <TD align= \" right \" > " . price ( $objp -> total_ttc ) . " </TD> " ;
print " <TD align= \" right \" > " . price ( $objp -> am ) . " </TD> " ;
2003-07-12 12:33:55 +02:00
if ( ! $objp -> paye )
{
2003-07-21 15:05:24 +02:00
if ( $objp -> fk_statut == 0 )
{
print '<td align="center">brouillon</td>' ;
}
else
{
2004-01-24 20:09:04 +01:00
print '<td align="center"><a class="' . $class . '" href="facture.php?filtre=paye:0,fk_statut:1">' . ( $objp -> am ? " commenc<EFBFBD> " : " impay<EFBFBD> e " ) . '</a></td>' ;
2003-07-21 15:05:24 +02:00
}
2003-07-12 12:33:55 +02:00
}
else
{
2004-01-24 20:09:04 +01:00
print '<td align="center">pay<61> e</td>' ;
2003-07-12 12:33:55 +02:00
}
print " </TR> \n " ;
2004-01-24 20:09:04 +01:00
$total += $objp -> total ;
$total_ttc += $objp -> total_ttc ;
$totalrecu += $objp -> am ;
2003-07-12 12:33:55 +02:00
$i ++ ;
}
2004-01-24 20:09:04 +01:00
if ( $num <= $limit ) {
// Print total
print " <tr " . $bc [ ! $var ] . " > " ;
print " <TD colspan=3 align= \" left \" >Total : </TD> " ;
print " <TD align= \" right \" ><b> " . price ( $total ) . " </b></TD> " ;
print " <TD align= \" right \" ><b> " . price ( $total_ttc ) . " </b></TD> " ;
print " <TD align= \" right \" ><b> " . price ( $totalrecu ) . " </b></TD> " ;
print '<td align="center"> </td>' ;
print " </tr> \n " ;
}
2002-04-30 12:44:42 +02:00
}
2002-05-11 20:53:13 +02:00
2003-07-21 15:05:24 +02:00
print " </table> " ;
2003-07-12 12:33:55 +02:00
$db -> free ();
2002-04-30 12:44:42 +02:00
}
2003-07-12 12:33:55 +02:00
else
{
2003-07-22 18:05:14 +02:00
print $db -> error () . " <br> " . $sql ;
2003-07-21 15:05:24 +02:00
}
2002-04-30 12:44:42 +02:00
}
2003-07-12 12:33:55 +02:00
2002-04-30 12:44:42 +02:00
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>