From b26e85a935de00032bd554c29608522a7eb8ccac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Jun 2004 13:33:23 +0000 Subject: [PATCH] Fix: Correction gestion de la 'periode' pour les charges sociales --- htdocs/compta/charges/index.php | 7 ++++- htdocs/compta/sociales/index.php | 41 ++++++++++++++++++++--------- mysql/migration/1.1.0-1.2.0-RC1.sql | 2 ++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index f5f94874bbb..a0b14f221ef 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -51,7 +51,12 @@ $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."charge $sql .= " WHERE s.fk_type = c.id"; if ($year > 0) { - $sql .= " AND date_format(s.date_ech, '%Y') = $year"; + $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 + $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 .= ")"; } $sql .= " GROUP BY lower(c.libelle) ASC"; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 15ef9dec937..23a1b745291 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -52,13 +52,22 @@ function valeur($sql) if ($action == 'add') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, amount) "; - $sql .= " VALUES (".$_POST["type"].",'".addslashes($_POST["libelle"])."','".$_POST["date"]."','".$_POST["amount"]."');"; + if (! $_POST["date"] || ! $_POST["periode"] || ! $_POST["amount"]) { + $mesg="
Erreur: Tous les champs date et montant doivent etre renseignés avec une valeur non vide.
"; + } + else { - if (! $db->query($sql) ) - { - print $db->error(); - } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount) "; + $sql .= " VALUES (".$_POST["type"].",'".addslashes($_POST["libelle"])."','".$_POST["date"]."','".$_POST["periode"]."','".$_POST["amount"]."');"; + + if (! $db->query($sql) ) + { + print $db->error(); + } + else { + $mesg="
La charge a été ajoutée.
"; + } + } } /* @@ -84,9 +93,12 @@ $filtre=$_GET["filtre"]; */ print_titre("Charges sociales $year"); - print "
\n"; +if ($mesg) { + print "$mesg
"; +} + //if ($filtre) { // print_titre("Filtre : ".$_GET["filtrelib"]); // print "
\n"; @@ -100,7 +112,7 @@ print ''; print ''; print_liste_field_titre("Echéance",$PHP_SELF,"de"); print ''; -print ' '; +print_liste_field_titre("Période",$PHP_SELF,"periode"); print ''; print_liste_field_titre("Type",$PHP_SELF,"type"); print ''; @@ -118,7 +130,12 @@ $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."charge $sql .= " WHERE s.fk_type = c.id"; if ($year > 0) { - $sql .= " AND date_format(s.periode, '%Y') = $year"; + $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 + $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); @@ -184,11 +201,11 @@ else * Forumalaire d'ajout d'une charge * */ -print '
'; +print ''; print ''; print ' '; -print ' YYYYMMDD'; -print ' '; +print '
YYYYMMDD'; +print '
YYYYMMDD'; print '