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 ' | |