New: Ajout d'une fiche de Charges Sociales permettant de modifier une saisie de charge (montant, libellé) tant qu'elle n'est pas payé.

Il reste à gérer le paiement pour avoir une entrée sur le compte automatiquement (comme pour les factures).
This commit is contained in:
Laurent Destailleur 2004-05-02 16:01:35 +00:00
parent af6db0b09b
commit 245d8721e6
2 changed files with 172 additions and 4 deletions

View File

@ -0,0 +1,139 @@
<?PHP
/* 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$
*
*/
require("./pre.inc.php");
$user->getrights('facture');
$user->getrights('compta');
if (!$user->admin && !$user->rights->compta->charges)
accessforbidden();
require("../../chargesociales.class.php");
require("../../paiement.class.php");
require("../bank/account.class.php");
llxHeader();
/* *************************************************************************** */
/* */
/* Mode fiche */
/* */
/* *************************************************************************** */
if ($_GET["id"] > 0)
{
$html = new Form($db);
$cha = New ChargeSociales($db);
if ( $cha->fetch($_GET["id"]) > 0)
{
/*
* Charge
*/
print_titre("Charge sociale : ".$cha->id);
print "<br>";
/*
* Confirmation de la suppression de la facture
*
*/
if ($_GET["action"] == 'delete')
{
$html->form_confirm("index.php?id=$cha->id&amp;action=del","Supprimer la charge sociale","Etes-vous sûr de vouloir supprimer cette charge sociale ?","confirm_delete");
}
print "<form action=\"$PHP_SELF?id=$cha->id&amp;action=update\" method=\"post\">";
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
print "<tr><td>Type</td><td colspan=\"3\">$cha->type_libelle</td></tr>";
print "<tr><td>Période</td><td colspan=\"3\">NA</td></tr>";
if ($cha->paye==0) {
print '<tr><td>Libellé</td><td colspan=\3\"><input type="text" name="desc" size="60" value='.stripslashes($cha->lib).'></td></tr>';
print "<tr><td>Date d'échéance</td><td><input type=\"text\" name=\"amount\" value=\"".strftime("%Y%m%d",$cha->date_ech)."\"></td><td>Date de paiement</td><td>NA</td>";
print "<tr><td>Montant</td><td><b><input type=\"text\" name=\"amount\" value=\"$cha->amount\"></b></td><td colspan=\"2\">&nbsp;</td></tr>";
}
else {
print '<tr><td>Libellé</td><td colspan=\3\">'.stripslashes($cha->lib).'</td></tr>';
print "<tr><td>Date d'échéance</td><td>".strftime("%Y%m%d",$cha->date_ech)."</td><td>Date de paiement</td><td>".strftime("%Y%m%d",$cha->date_pai)."</td>";
print "<tr><td>Montant</td><td><b>$cha->amount</b></td><td colspan=\"2\">&nbsp;</td></tr>";
}
print "<tr><td>Statut</td><td>".($cha->paye==0?"Non paye":"Payé")."</td><td colspan=\"2\">&nbsp;</td></tr>";
print "</table>";
print "</form>\n";
if (! $_GET["action"]) {
/*
* Boutons actions
*/
print "<br><div class=\"tabsAction\">\n";
// Supprimer
if ($cha->paye == 0 && $user->rights->facture->supprimer)
{
print "<a class=\"tabAction\" href=\"$PHP_SELF?id=$cha->id&amp;action=delete\">Supprimer</a>";
}
// Emettre paiement
if ($cha->paye == 0 && $user->rights->facture->paiement)
{
print "<a class=\"tabAction\" href=\"$PHP_SELF?id=$cha->id&amp;action=create\">Emettre paiement</a>";
}
// Classer 'payé'
if ($cha->paye == 0 && $user->rights->facture->paiement)
{
print "<a class=\"tabAction\" href=\"$PHP_SELF?id=$cha->id&amp;action=payed\">Classer 'Payée'</a>";
}
print "</div>";
}
if ($_GET["action"] == 'create')
{
print "Cette fonction n'a pas encore été implémentée";
}
if ($_GET["action"] == 'payed')
{
print "Cette fonction n'a pas encore été implémentée";
}
}
else
{
/* Charge non trouvée */
print "Charge inexistante ou accés refusé";
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -22,6 +22,13 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
$user->getrights('facture');
$user->getrights('compta');
if (!$user->admin && !$user->rights->compta->charges)
accessforbidden();
llxHeader(); llxHeader();
function valeur($sql) function valeur($sql)
@ -75,9 +82,16 @@ print_titre("Charges sociales $year");
print "<br>\n"; print "<br>\n";
//if ($filtre) {
// print_titre("Filtre : ".$_GET["filtrelib"]);
// print "<br>\n";
//}
print "<table class=\"noborder\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">"; print "<table class=\"noborder\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print '<td>'; print '<td>';
print_liste_field_titre("Num",$PHP_SELF,"id");
print '</td><td>';
print_liste_field_titre("Echéance/Date",$PHP_SELF,"de"); print_liste_field_titre("Echéance/Date",$PHP_SELF,"de");
print '</td><td>'; print '</td><td>';
print_liste_field_titre("Période",$PHP_SELF,"periode"); print_liste_field_titre("Période",$PHP_SELF,"periode");
@ -93,7 +107,7 @@ print '</td><td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$sql = "SELECT s.rowid as id, c.libelle as type, s.amount,".$db->pdate("s.date_ech")." as de, s.date_pai, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,".$db->pdate("s.date_pai")." as dp"; $sql = "SELECT s.rowid as id, s.fk_type as type, c.libelle as type_lib, s.amount,".$db->pdate("s.date_ech")." as de, s.date_pai, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,".$db->pdate("s.date_pai")." as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql .= " WHERE s.fk_type = c.id"; $sql .= " WHERE s.fk_type = c.id";
if ($year > 0) if ($year > 0)
@ -104,7 +118,20 @@ if ($filtre) {
$filtre=ereg_replace(":","=",$filtre); $filtre=ereg_replace(":","=",$filtre);
$sql .= " AND $filtre"; $sql .= " AND $filtre";
} }
$sql .= " ORDER BY lower(s.date_ech) DESC"; if ($_GET["sortfield"]) {
$sql .= " ORDER BY ".$_GET["sortfield"];
}
else {
$sql .= " ORDER BY lower(s.date_ech)";
}
if ($_GET["sortorder"]) {
$sql .= " ".$_GET["sortorder"];
}
else {
$sql .= " DESC";
}
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
@ -117,6 +144,7 @@ if ( $db->query($sql) )
$var = !$var; $var = !$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td width="80"><a href="charges.php?id='.$obj->id.'">'.$obj->id.'</a></td>';
print '<td>'.strftime("%d %b %y",$obj->de).'</td>'; print '<td>'.strftime("%d %b %y",$obj->de).'</td>';
print '<td>'; print '<td>';
if ($obj->periode) { if ($obj->periode) {
@ -125,7 +153,7 @@ if ( $db->query($sql) )
print '&nbsp;'; print '&nbsp;';
} }
print '</td>'; print '</td>';
print '<td>'.$obj->type.'</td><td>'.$obj->libelle.'</td>'; print '<td>'.$obj->type_lib.'</td><td>'.$obj->libelle.'</td>';
print '<td align="right">'.price($obj->amount).'</td>'; print '<td align="right">'.price($obj->amount).'</td>';
if ($obj->paye) if ($obj->paye)
@ -143,7 +171,7 @@ if ( $db->query($sql) )
} }
else else
{ {
print $db->error(); print "Error :".$db->error()." - $sql";
} }
/* /*
@ -152,6 +180,7 @@ else
*/ */
print '<tr class="form"><form method="post" action="index.php">'; print '<tr class="form"><form method="post" action="index.php">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<td>&nbsp;</td>';
print '<td><input type="text" size="8" name="date"> YYYYMMDD</td>'; print '<td><input type="text" size="8" name="date"> YYYYMMDD</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';