Fix: Partial payment on social contributions not shown on main page.

New: Can filter on social contribution type in list.
This commit is contained in:
Laurent Destailleur 2009-03-02 23:43:17 +00:00
parent 05a48da313
commit 8476a218e5
6 changed files with 105 additions and 63 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 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
@ -59,9 +59,10 @@ print "<td align=\"right\">".$langs->trans("Amount")."</td>";
print "<td align=\"right\">".$langs->trans("AlreadyPayed")."</td>";
print "</tr>\n";
$sql = "SELECT c.libelle as lib, s.fk_type as type,";
$sql.=" count(s.rowid) as nb, sum(s.amount) as total, sum(IF(paye=1,s.amount,0)) as totalpaye";
$sql = "SELECT c.id, c.libelle as lib, s.fk_type as type,";
$sql.=" count(s.rowid) as nb, sum(s.amount) as total, sum(pc.amount) as totalpaye";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = s.rowid";
$sql.= " WHERE s.fk_type = c.id";
if ($year > 0)
{
@ -72,8 +73,10 @@ if ($year > 0)
$sql .= "or (s.periode is null and date_format(s.date_ech, '%Y') = $year)";
$sql .= ")";
}
$sql .= " GROUP BY c.libelle ASC";
$sql.= " GROUP BY c.id, c.libelle, s.fk_type";
$sql.= " ORDER BY c.libelle ASC";
dol_syslog("compta/charges/index.php: select payment sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
@ -114,11 +117,11 @@ print '</table>';
if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
{
print "<br>";
$tva = new Tva($db);
print_titre($langs->trans("VATPayments"));
$sql = "SELECT rowid, amount, label, ".$db->pdate("f.datev")." as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f ";
if ($year > 0)
@ -128,12 +131,12 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
$sql .= " WHERE date_format(f.datev, '%Y') = ".$year;
}
$sql .= " ORDER BY dm DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$i = 0;
$total = 0 ;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -150,15 +153,15 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
print '<td align="left">'.dol_print_date($obj->dm,'day')."</td>\n";
print "<td>".$obj->label."</td>\n";
$total = $total + $obj->amount;
print "<td align=\"right\">".price($obj->amount)."</td>";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>';
print '<td align="right"><b>'.price($total)."</b></td></tr>";
print "</table>";
$db->free($result);
}
@ -170,6 +173,6 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -45,6 +45,9 @@ $offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* View
*/
llxHeader();
@ -67,11 +70,6 @@ if ($action == 'note')
$result = $db->query($sql);
}
/*
* Recherche
*
*/
if ($mode == 'search') {
if ($mode-search == 'soc') {
$sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s ";
@ -155,7 +153,7 @@ if ($result)
}
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
@ -209,7 +207,7 @@ if ($result)
print "</table>";
print '</form>';
$db->free();
}
else

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2009 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
@ -88,7 +88,7 @@ if ($_POST["action"] == 'confirm_delete')
}
}
/*
* Ajout d'une charge sociale
*/
@ -114,13 +114,13 @@ if ($_POST["action"] == 'add' && $user->rights->tax->charges->creer)
else
{
$chargesociales=new ChargeSociales($db);
$chargesociales->type=$_POST["actioncode"];
$chargesociales->lib=$_POST["label"];
$chargesociales->date_ech=$dateech;
$chargesociales->periode=$_POST["period"];
$chargesociales->amount=$_POST["amount"];
$chid=$chargesociales->create($user);
if ($chid > 0)
{
@ -151,11 +151,11 @@ if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->cha
{
$chargesociales=new ChargeSociales($db);
$result=$chargesociales->fetch($_GET["id"]);
$chargesociales->lib=$_POST["label"];
$chargesociales->date_ech=$dateech;
$chargesociales->periode=$_POST["period"];
$result=$chargesociales->update($user);
if ($result > 0)
{
@ -167,7 +167,7 @@ if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->cha
}
}
}
llxHeader();
$html = new Form($db);
@ -180,9 +180,9 @@ if ($_GET["action"] == 'create')
{
print_fiche_titre($langs->trans("NewSocialContribution"));
print "<br>\n";
if ($mesg) print $mesg.'<br>';
$var=false;
print '<form name="charge" method="post" action="'.DOL_URL_ROOT.'/compta/sociales/charges.php">';
@ -245,7 +245,7 @@ if ($chid > 0)
if ($cha->fetch($chid) > 0)
{
if ($mesg) print $mesg.'<br>';
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$cha->id;
$head[$h][1] = $langs->trans('Card');
@ -291,7 +291,7 @@ if ($chid > 0)
print dol_print_date($cha->periode,"%Y");
}
print "</td>";
print '<td rowspan="5" valign="top">';
/*
@ -363,10 +363,10 @@ if ($chid > 0)
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($cha->date_ech,'day')."</td></tr>";
}
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($cha->amount).'</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$cha->getLibStatut(4).'</td></tr>';
if ($_GET['action'] == 'edit')
if ($_GET['action'] == 'edit')
{
print '<tr><td colspan="3" align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
@ -374,7 +374,7 @@ if ($chid > 0)
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
}
print '</table>';
if ($_GET['action'] == 'edit') print "</form>\n";

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 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
@ -18,11 +18,11 @@
*/
/**
\file htdocs/compta/sociales/index.php
\ingroup tax
\brief Ecran des charges sociales
\version $Id$
*/
* \file htdocs/compta/sociales/index.php
* \ingroup tax
* \brief Ecran des charges sociales
* \version $Id$
*/
require("./pre.inc.php");
require(DOL_DOCUMENT_ROOT."/chargesociales.class.php");
@ -50,7 +50,20 @@ $limit = $conf->liste_limit;
$offset = $limit * $page ;
//if (! $year) { $year=date("Y", time()); }
if (empty($_REQUEST['typeid']))
{
$newfiltre=eregi_replace('filtre=','',$filtre);
$filterarray=split('-',$newfiltre);
foreach($filterarray as $val)
{
$part=split(':',$val);
if ($part[0] == 's.fk_type') $typeid=$part[1];
}
}
else
{
$typeid=$_REQUEST['typeid'];
}
/*
@ -59,6 +72,8 @@ $offset = $limit * $page ;
llxHeader();
$html = new Form($db);
$sql = "SELECT s.rowid as id, s.fk_type as type, ";
$sql.= " s.amount,".$db->pdate("s.date_ech")." as de, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,";
@ -68,15 +83,18 @@ $sql.= " WHERE s.fk_type = c.id";
if ($year > 0)
{
$sql .= " AND (";
// Si period renseign<EFBFBD> on l'utilise comme critere de date, sinon on prend date <20>ch<63>ance,
// ceci afin d'etre compatible avec les cas ou la p<EFBFBD>riode n'etait pas obligatoire
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
$sql .= " (s.periode is not null and date_format(s.periode, '%Y') = $year) ";
$sql .= "or (s.periode is null and date_format(s.date_ech, '%Y') = $year)";
$sql .= ")";
}
if ($filtre) {
$filtre=ereg_replace(":","=",$filtre);
$sql .= " AND $filtre";
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND s.fk_type=".$typeid;
}
if ($_GET["sortfield"]) {
$sql .= " ORDER BY ".$_GET["sortfield"];
@ -103,8 +121,9 @@ if ($resql)
$var=true;
$param='';
if ($year) $param.='&amp;year='.$year;
if ($year) $param.='&amp;year='.$year;
if ($typeid) $param.='&amp;typeid='.$typeid;
if ($year)
{
print_fiche_titre($langs->trans("SocialContributions"),($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":""));
@ -113,15 +132,16 @@ if ($resql)
{
print_barre_liste($langs->trans("SocialContributions"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
}
print "<br>\n";
if ($mesg)
{
print $mesg."<br>";
}
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"index.php","id","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),"index.php","de","",$param,"",$sortfield,$sortorder);
@ -129,9 +149,22 @@ if ($resql)
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"index.php","s.libelle","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),"index.php","s.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
print "<tr class=\"liste_titre\">";
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="left">';
$html->select_type_socialcontrib($typeid,'typeid',1,16,0);
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
print '</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{
@ -139,28 +172,28 @@ if ($resql)
$var = !$var;
print "<tr $bc[$var]>";
print '<td width="60">';
print '<a href="charges.php?id='.$obj->id.'">'.img_file().' '.$obj->id.'</a>';
print '</td>';
print '<td width="110">'.dol_print_date($obj->de, 'day').'</td>';
print '<td align="center">';
if ($obj->periode)
if ($obj->periode)
{
print '<a href="index.php?year='.strftime("%Y",$obj->periode).'">'.strftime("%Y",$obj->periode).'</a>';
}
else
else
{
print '&nbsp;';
}
print '</td>';
print '<td>'.dol_trunc($obj->type_lib,16).'</td>';
print '<td>'.dol_trunc($obj->libelle,42).'</td>';
print '<td align="right" width="100">'.price($obj->amount).'</td>';
print '<td align="right" nowrap="nowrap">'.$chargesociale_static->LibStatut($obj->paye,5).'</a></td>';
@ -168,13 +201,16 @@ if ($resql)
print '</tr>';
$i++;
}
print '</table>';
print '</form>';
}
else
{
dol_print_error($db);
}
print '</table>';

View File

@ -57,7 +57,7 @@ if ($result)
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td nowrap align="left">'.$langs->trans("Ref").'</td>';

View File

@ -323,8 +323,11 @@ class Form
* \brief Return list of social contributions
* \param selected Preselected type
* \param htmlname Name of field in form
* \param useempty Set to 1 if we want an empty value
* \param maxlen Max length of text in combo box
* \param help Add or not the admin help picto
*/
function select_type_socialcontrib($selected='',$htmlname='actioncode')
function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
{
global $db,$langs,$user;
@ -341,16 +344,18 @@ class Form
$num = $db->num_rows($resql);
$i = 0;
if ($useempty) print '<option value="0">&nbsp;</option>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->id.'"';
if ($obj->id == $selected) print ' selected="true"';
print '>'.$obj->type;
print '>'.dol_trunc($obj->type,$maxlen);
$i++;
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{