diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 00475c92fe7..8d590ba7317 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 "".$langs->trans("Amount").""; print "".$langs->trans("AlreadyPayed").""; print "\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 ''; if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') { print "
"; - + $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 ''; print ''; @@ -150,15 +153,15 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') print '\n"; print "\n"; $total = $total + $obj->amount; - + print ""; print "\n"; - + $i++; } print ''; print '"; - + print "
'.dol_print_date($obj->dm,'day')."".$obj->label."".price($obj->amount)."
'.$langs->trans("Total").''.price($total)."
"; $db->free($result); } @@ -170,6 +173,6 @@ if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly') $db->close(); - + llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index abca12b441e..f002f7b2657 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -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 '
'; - + print ''; print ''; @@ -209,7 +207,7 @@ if ($result) print "
"; print '
'; - + $db->free(); } else diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 1d8a0ce1590..b9ad2a878a8 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2009 Laurent Destailleur * * 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 "
\n"; - + if ($mesg) print $mesg.'
'; - + $var=false; print '
'; @@ -245,7 +245,7 @@ if ($chid > 0) if ($cha->fetch($chid) > 0) { if ($mesg) print $mesg.'
'; - + $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 ""; - + print ''; /* @@ -363,10 +363,10 @@ if ($chid > 0) print "".$langs->trans("DateDue")."".dol_print_date($cha->date_ech,'day').""; } print ''.$langs->trans("AmountTTC").''.price($cha->amount).''; - + print ''.$langs->trans("Status").''.$cha->getLibStatut(4).''; - if ($_GET['action'] == 'edit') + if ($_GET['action'] == 'edit') { print ''; print ''; @@ -374,7 +374,7 @@ if ($chid > 0) print ''; print ''; } - + print ''; if ($_GET['action'] == 'edit') print "
\n"; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index af074c5ebed..97e714f17ba 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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� on l'utilise comme critere de date, sinon on prend date �ch�ance, - // ceci afin d'etre compatible avec les cas ou la p�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.='&year='.$year; - + if ($year) $param.='&year='.$year; + if ($typeid) $param.='&typeid='.$typeid; + if ($year) { print_fiche_titre($langs->trans("SocialContributions"),($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); @@ -113,15 +132,16 @@ if ($resql) { print_barre_liste($langs->trans("SocialContributions"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines); } - print "
\n"; - + if ($mesg) { print $mesg."
"; } - + + print '
'; + print ""; - + print ""; 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 "\n"; + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; - while ($i < min($num,$limit)) { @@ -139,28 +172,28 @@ if ($resql) $var = !$var; print ""; - + print ''; print ''; - + print ''; print ''; - + print ''; - + print ''; print ''; @@ -168,13 +201,16 @@ if ($resql) print ''; $i++; } + + print '
   '; + $html->select_type_socialcontrib($typeid,'typeid',1,16,0); + print '  '; + print ''; + print '
'; print ''.img_file().' '.$obj->id.''; print ''.dol_print_date($obj->de, 'day').''; - if ($obj->periode) + if ($obj->periode) { print 'periode).'">'.strftime("%Y",$obj->periode).''; } - else + else { print ' '; } print ''.dol_trunc($obj->type_lib,16).''.dol_trunc($obj->libelle,42).''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye,5).'
'; + + print '
'; } else { dol_print_error($db); } -print ''; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 108e8833438..3d0163080be 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -57,7 +57,7 @@ if ($result) $num = $db->num_rows($result); $i = 0; $total = 0 ; - print '
'; + print ''; print ''; print ''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 6f2e2ef4fbb..06e795df7ca 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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 ''; + while ($i < $num) { $obj = $db->fetch_object($resql); print '
'.$langs->trans("Ref").'