2004-10-19 22:35:36 +02:00
< ? php
2004-05-02 18:01:35 +02:00
/* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
*
* 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-10-03 20:31:14 +02:00
2004-11-18 00:15:40 +01:00
/*!
\file htdocs / compta / sociales / charges . php
2004-10-03 20:31:14 +02:00
\ingroup compta
\brief Fiche d ' une charge sociale
\version $Revision $
*/
2004-05-02 18:01:35 +02:00
require ( " ./pre.inc.php " );
2004-10-03 20:31:14 +02:00
$langs -> load ( " compta " );
$langs -> load ( " bills " );
2004-05-02 18:01:35 +02:00
$user -> getrights ( 'compta' );
if ( ! $user -> admin && ! $user -> rights -> compta -> charges )
accessforbidden ();
require ( " ../../chargesociales.class.php " );
llxHeader ();
2004-06-08 16:01:25 +02:00
$chid = isset ( $_GET [ " id " ]) ? $_GET [ " id " ] : $_POST [ " id " ];
2004-06-08 17:09:49 +02:00
/* *************************************************************************** */
/* */
/* Action Classer Pay<61> */
/* */
/* *************************************************************************** */
if ( $_GET [ " action " ] == 'payed' )
{
$cha = new ChargeSociales ( $db );
$result = $cha -> set_payed ( $chid );
}
2004-05-02 18:01:35 +02:00
/* *************************************************************************** */
/* */
/* Mode fiche */
/* */
/* *************************************************************************** */
2004-06-08 16:01:25 +02:00
if ( $chid > 0 )
2004-05-02 18:01:35 +02:00
{
$html = new Form ( $db );
2004-06-08 16:01:25 +02:00
$cha = new ChargeSociales ( $db );
if ( $cha -> fetch ( $chid ) > 0 )
2004-05-02 18:01:35 +02:00
{
/*
* Charge
*/
2004-06-08 16:01:25 +02:00
//$head[0][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head [ 0 ][ 1 ] = " Charge sociale : No $cha->id " ;
$h = 1 ;
$a = 0 ;
dolibarr_fiche_head ( $head , $a );
2004-05-02 18:01:35 +02:00
/*
2004-06-08 16:01:25 +02:00
* Confirmation de la suppression de la charge
2004-05-02 18:01:35 +02:00
*
*/
if ( $_GET [ " action " ] == 'delete' )
{
$html -> form_confirm ( " index.php?id= $cha->id &action=del " , " Supprimer la charge sociale " , " Etes-vous s<> r de vouloir supprimer cette charge sociale ? " , " confirm_delete " );
}
2004-07-30 12:32:27 +02:00
print " <form action= \" charges.php?id= $cha->id &action=update \" method= \" post \" > " ;
2004-05-02 18:01:35 +02:00
2004-10-03 20:31:14 +02:00
print '<table class="border" width="100%">' ;
2004-06-08 16:01:25 +02:00
2004-10-03 20:31:14 +02:00
print " <tr><td> " . $langs -> trans ( " Type " ) . " </td><td> $cha->type_libelle </td><td> " . $langs -> trans ( " Paiements " ) . " </td></tr> " ;
2004-06-08 16:01:25 +02:00
2004-10-03 20:31:14 +02:00
print " <tr><td> " . $langs -> trans ( " Period " ) . " </td><td> " . dolibarr_print_date ( $cha -> periode , " %Y " ) . " </td> " ;
2004-06-08 16:01:25 +02:00
print '<td rowspan="5" valign="top">' ;
/*
* Paiements
*/
$sql = " SELECT " . $db -> pdate ( " datep " ) . " as dp, p.amount, " ;
$sql .= " c.libelle as paiement_type, p.num_paiement, p.rowid " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " paiementcharge as p, " . MAIN_DB_PREFIX . " c_paiement as c " ;
$sql .= " WHERE p.fk_charge = " . $chid . " AND p.fk_typepaiement = c.id " ;
$sql .= " ORDER BY dp DESC " ;
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ; $total = 0 ;
echo '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">' ;
2004-10-03 20:31:14 +02:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Date " ) . '</td><td>' . $langs -> trans ( " Type " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " Amount " ) . '</td><td> </td></tr>' ;
2004-06-08 16:01:25 +02:00
$var = True ;
while ( $i < $num )
{
2004-10-23 18:55:07 +02:00
$objp = $db -> fetch_object ( $result );
2004-06-08 16:01:25 +02:00
$var =! $var ;
print " <tr $bc[$var] ><td> " ;
print dolibarr_print_date ( $objp -> dp ) . " </td> \n " ;
print " <td> $objp->paiement_type $objp->num_paiement </td> \n " ;
2004-12-04 21:19:53 +01:00
print '<td align="right">' . price ( $objp -> amount ) . " </td><td> " . $conf -> monnaie . " </td> \n " ;
2004-06-08 16:01:25 +02:00
print " </tr> " ;
$totalpaye += $objp -> amount ;
$i ++ ;
}
if ( $fac -> paye == 0 )
{
2004-12-04 21:19:53 +01:00
print " <tr><td colspan= \" 2 \" align= \" right \" >Total pay<61> :</td><td align= \" right \" ><b> " . price ( $totalpaye ) . " </b></td><td> " . $conf -> monnaie . " </td></tr> \n " ;
2004-06-08 16:01:25 +02:00
print " <tr><td colspan= \" 2 \" align= \" right \" >R<> clam<61> :</td><td align= \" right \" bgcolor= \" #d0d0d0 \" > " . price ( $cha -> amount ) . " </td><td bgcolor= \" #d0d0d0 \" > " . MAIN_MONNAIE . " </td></tr> \n " ;
$resteapayer = $cha -> amount - $totalpaye ;
print " <tr><td colspan= \" 2 \" align= \" right \" >Reste <20> payer :</td> " ;
2004-12-04 21:19:53 +01:00
print " <td align= \" right \" bgcolor= \" #f0f0f0 \" ><b> " . price ( $resteapayer ) . " </b></td><td bgcolor= \" #f0f0f0 \" > " . $conf -> monnaie . " </td></tr> \n " ;
2004-06-08 16:01:25 +02:00
}
print " </table> " ;
$db -> free ();
} else {
2004-10-03 20:31:14 +02:00
dolibarr_print_error ( $db );
2004-06-08 16:01:25 +02:00
}
print " </td> " ;
print " </tr> " ;
2004-05-02 18:01:35 +02:00
if ( $cha -> paye == 0 ) {
2004-08-29 21:03:50 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td><input type="text" name="desc" size="40" value="' . stripslashes ( $cha -> lib ) . '"></td></tr>' ;
2004-10-03 20:31:14 +02:00
print '<tr><td>' . $langs -> trans ( " DateDue " ) . " </td><td><input type= \" text \" name= \" amount \" value= \" " . strftime ( " %Y%m%d " , $cha -> date_ech ) . " \" ></td></tr> " ;
print '<tr><td>' . $langs -> trans ( " AmountTTC " ) . " </td><td><b><input type= \" text \" name= \" amount \" value= \" $cha->amount\ " ></ b ></ td ></ tr > " ;
2004-05-02 18:01:35 +02:00
}
else {
2004-08-29 21:03:50 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td>' . $cha -> lib . '</td></tr>' ;
2004-10-03 20:31:14 +02:00
print " <tr><td> " . $langs -> trans ( " DateDue " ) . " </td><td> " . dolibarr_print_date ( $cha -> date_ech ) . " </td></tr> " ;
print '<tr><td>' . $langs -> trans ( " AmountTTC " ) . '</td><td><b>' . price ( $cha -> amount ) . '</b></td></tr>' ;
2004-05-02 18:01:35 +02:00
}
2004-06-08 16:01:25 +02:00
2004-08-29 21:03:50 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' . $cha -> getLibStatut () . '</td></tr>' ;
print '</table>' ;
2004-05-02 18:01:35 +02:00
print " </form> \n " ;
2004-10-03 20:31:14 +02:00
print '<br></div>' ;
2004-05-02 18:01:35 +02:00
if ( ! $_GET [ " action " ]) {
/*
* Boutons actions
*/
2004-06-08 16:01:25 +02:00
print " <div class= \" tabsAction \" > \n " ;
2004-05-02 18:01:35 +02:00
// Supprimer
2004-06-08 17:09:49 +02:00
if ( $cha -> paye == 0 && $totalpaye <= 0 && $user -> rights -> compta -> charges )
2004-05-02 18:01:35 +02:00
{
2004-10-03 20:31:14 +02:00
print " <a class= \" tabAction \" href= \" charges.php?id= $cha->id &action=delete \" > " . $langs -> trans ( " Delete " ) . " </a> " ;
2004-05-02 18:01:35 +02:00
}
// Emettre paiement
2004-06-08 17:09:49 +02:00
if ( $cha -> paye == 0 && round ( $resteapayer ) > 0 && $user -> rights -> compta -> charges )
2004-05-02 18:01:35 +02:00
{
2004-10-03 20:31:14 +02:00
print " <a class= \" tabAction \" href= \" ../paiement_charge.php?id= $cha->id &action=create \" > " . $langs -> trans ( " DoPaiement " ) . " </a> " ;
2004-05-02 18:01:35 +02:00
}
// Classer 'pay<61> '
2004-06-08 17:09:49 +02:00
if ( $cha -> paye == 0 && round ( $resteapayer ) <= 0 && $user -> rights -> compta -> charges )
2004-05-02 18:01:35 +02:00
{
2004-10-03 20:31:14 +02:00
print " <a class= \" tabAction \" href= \" charges.php?id= $cha->id &action=payed \" > " . $langs -> trans ( " ClassifyPayed " ) . " </a> " ;
2004-05-02 18:01:35 +02:00
}
print " </div> " ;
}
}
else
{
/* Charge non trouv<75> e */
print " Charge inexistante ou acc<63> s refus<75> " ;
}
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>