2004-10-19 22:35:36 +02:00
< ? php
2005-01-11 21:29:43 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-01-31 18:29:54 +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-09-14 22:46:09 +02:00
2005-01-11 21:29:43 +01:00
/** \file htdocs / compta / paiement / fiche . php
2004-09-14 22:46:09 +02:00
\ingroup facture
\brief Onglet paiement d ' un paiement
\version $Revision $
*/
2004-01-31 18:29:54 +01:00
require ( " ./pre.inc.php " );
require ( " ../../paiement.class.php " );
2004-12-28 15:08:50 +01:00
require ( " ../../facture.class.php " );
2004-01-31 18:29:54 +01:00
2004-02-10 16:28:00 +01:00
$user -> getrights ( 'facture' );
2004-09-14 22:46:09 +02:00
$langs -> load ( " bills " );
$langs -> load ( " companies " );
2005-01-11 21:29:43 +01:00
2004-07-21 18:08:31 +02:00
if ( $_POST [ " action " ] == 'confirm_delete' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> facture -> creer )
2004-02-10 16:28:00 +01:00
{
$paiement = new Paiement ( $db );
$paiement -> id = $_GET [ " id " ];
if ( $paiement -> delete () )
{
Header ( " Location: liste.php " );
}
}
2004-12-16 14:26:13 +01:00
if ( $_POST [ " action " ] == 'confirm_valide' && $_POST [ " confirm " ] == 'yes' && $user -> rights -> facture -> creer )
{
$paiement = new Paiement ( $db );
$paiement -> id = $_GET [ " id " ];
if ( $paiement -> valide () == 0 )
{
Header ( " Location: fiche.php?id= " . $paiement -> id );
}
}
2005-01-11 21:29:43 +01:00
2004-01-31 18:29:54 +01:00
/*
*
*
*/
llxHeader ();
print '<div class="tabs">' ;
2004-09-14 22:46:09 +02:00
print '<a href="fiche.php?id=' . $_GET [ " id " ] . '" id="active" class="tab">' . $langs -> trans ( " Payment " ) . '</a>' ;
print '<a class="tab" href="info.php?id=' . $_GET [ " id " ] . '">' . $langs -> trans ( " Info " ) . '</a>' ;
2004-01-31 18:29:54 +01:00
print '</div>' ;
print '<div class="tabBar">' ;
2004-02-10 16:28:00 +01:00
/*
* Visualisation de la fiche
*
*/
$paiement = new Paiement ( $db );
$paiement -> fetch ( $_GET [ " id " ]);
$html = new Form ( $db );
/*
2004-12-16 14:26:13 +01:00
* Confirmation de la suppression du paiement
2004-02-10 16:28:00 +01:00
*
*/
2005-01-11 21:29:43 +01:00
if ( $_GET [ " action " ] == 'delete' )
2004-02-10 16:28:00 +01:00
{
2004-12-16 14:26:13 +01:00
print '<br>' ;
2004-07-21 18:08:31 +02:00
$html -> form_confirm ( " fiche.php?id= $paiement->id " , " Supprimer le paiement " , " Etes-vous s<> r de vouloir supprimer ce paiement ? " , " confirm_delete " );
2004-12-16 14:26:13 +01:00
print '<br>' ;
2004-02-10 16:28:00 +01:00
}
2005-01-11 21:29:43 +01:00
if ( $_GET [ " action " ] == 'valide' )
2004-12-16 14:26:13 +01:00
{
print '<br>' ;
$html -> form_confirm ( " fiche.php?id= $paiement->id " , " Valider le paiement " , " Etes-vous s<> r de vouloir valider ce paiment, auncune modification n'est possible une fois le paiement valid<69> ? " , " confirm_valide " );
print '<br>' ;
}
2004-12-28 15:08:50 +01:00
print '<br>' ;
2004-02-10 16:28:00 +01:00
print '<table class="noborder" width="100%">' ;
2004-09-14 22:46:09 +02:00
print '<tr><td valign="top">' ;
2005-01-11 21:29:43 +01:00
if ( $paiement -> bank_account ) {
// Si compte renseign<67> , on affiche libelle
$bank = new Account ( $db );
$bank -> fetch ( $paiement -> bank_account );
print $langs -> trans ( " BankAccount " ) . ' : ' . $bank -> label . '<br>' ;
}
2004-12-28 15:08:50 +01:00
print $langs -> trans ( " Date " ) . ' : ' . dolibarr_print_date ( $paiement -> date ) . " <br> " ;
2004-09-14 22:46:09 +02:00
print $langs -> trans ( " Type " ) . ' : ' . $paiement -> type_libelle . " <br> " ;
2004-12-28 15:08:50 +01:00
if ( $paiement -> numero ) { print $langs -> trans ( " Numero " ) . ' : ' . $paiement -> numero . " <br> " ; }
2004-12-04 21:19:53 +01:00
print $langs -> trans ( " Amount " ) . ' : ' . $paiement -> montant . " " . $conf -> monnaie . " <br> " ;
2004-02-10 16:28:00 +01:00
print '</td></tr>' ;
print " </table> " ;
2004-01-31 18:29:54 +01:00
2004-02-10 16:28:00 +01:00
print nl2br ( $paiement -> note );
2004-01-31 18:29:54 +01:00
2004-02-10 16:28:00 +01:00
/*
*
*
*/
$allow_delete = 1 ;
2004-12-28 15:08:50 +01:00
$sql = " SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp " ;
2004-02-10 16:28:00 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " paiement_facture as pf, " . MAIN_DB_PREFIX . " facture as f, " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.idp " ;
$sql .= " AND pf.fk_paiement = " . $paiement -> id ;
if ( $db -> query ( $sql ))
{
$num = $db -> num_rows ();
$i = 0 ;
2004-11-22 16:29:01 +01:00
$total = 0 ;
2004-09-14 22:46:09 +02:00
print '<br><table class="noborder" width="100%">' ;
2004-02-10 16:28:00 +01:00
print '<tr class="liste_titre">' ;
2004-09-14 22:46:09 +02:00
print '<td>' . $langs -> trans ( " Bill " ) . '</td><td>' . $langs -> trans ( " Company " ) . '</td>' ;
2004-12-28 15:08:50 +01:00
print '<td align="right">' . $langs -> trans ( " AmountTTC " ) . '</td><td align="center">' . $langs -> trans ( " Status " ) . '</td>' ;
2004-02-10 16:28:00 +01:00
print " </tr> \n " ;
if ( $num > 0 )
{
$var = True ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$objp = $db -> fetch_object ();
2004-02-10 16:28:00 +01:00
$var =! $var ;
2004-02-14 15:25:51 +01:00
print " <tr $bc[$var] > " ;
print '<td><a href="' . DOL_URL_ROOT . '/compta/facture.php?facid=' . $objp -> facid . '">' . img_file () . '</a>' ;
print ' <a href="' . DOL_URL_ROOT . '/compta/facture.php?facid=' . $objp -> facid . '">' . $objp -> facnumber ;
2004-02-10 16:28:00 +01:00
print " </a></td> \n " ;
print '<td><a href="' . DOL_URL_ROOT . '/compta/fiche.php?socid=' . $objp -> idp . '">' . $objp -> nom . '</a></td>' ;
2004-12-28 15:08:50 +01:00
print '<td align="right">' . price ( $objp -> amount ) . '</td>' ;
$fac = new Facture ( $db );
print '<td align="center">' . $fac -> LibStatut ( $objp -> paye , $objp -> fk_statut ) . '</td>' ;
2004-02-10 16:28:00 +01:00
print " </tr> \n " ;
if ( $objp -> paye == 1 )
{
$allow_delete = 0 ;
}
2004-11-22 16:29:01 +01:00
$total = $total + $objp -> amount ;
2004-02-10 16:28:00 +01:00
$i ++ ;
}
}
2004-11-22 16:29:01 +01:00
$var =! $var ;
print " <tr $bc[$var] > " ;
print '<td> </td>' ;
2004-12-28 15:08:50 +01:00
print '<td align="right">' . $langs -> trans ( " Total " ) . '</td>' ;
2004-11-22 16:42:37 +01:00
print '<td align="right">' . price ( $total ) . '</td><td> </td>' ;
2004-11-22 16:29:01 +01:00
print " </tr> \n " ;
2004-02-10 16:28:00 +01:00
print " </table> \n " ;
$db -> free ();
}
2004-12-28 15:08:50 +01:00
else {
dolibarr_print_error ( $db );
}
2004-02-10 16:28:00 +01:00
/*
*
*
*/
2004-12-16 14:26:13 +01:00
print " <br></div> " ;
print '<div class="tabsAction">' ;
2004-01-31 18:29:54 +01:00
2004-12-16 14:26:13 +01:00
if ( $user -> societe_id == 0 && $paiement -> statut == 0 && $_GET [ " action " ] == '' )
{
2004-12-28 15:08:50 +01:00
print '<a class="tabAction" href="fiche.php?id=' . $_GET [ " id " ] . '&action=valide">' . $langs -> trans ( " Valid " ) . '</a>' ;
2004-12-16 14:26:13 +01:00
}
2004-01-31 18:29:54 +01:00
2004-12-16 14:26:13 +01:00
if ( $user -> societe_id == 0 && $allow_delete && $paiement -> statut == 0 && $_GET [ " action " ] == '' )
{
print '<a class="butDelete" href="fiche.php?id=' . $_GET [ " id " ] . '&action=delete">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
print " </div> " ;
$db -> close ();
2004-01-31 18:29:54 +01:00
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>