From 726b01933e705fbda926f7bec69b7387a3ff3aee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Jul 2006 15:40:29 +0000 Subject: [PATCH] Look: Ajout picto sur charges sociales --- htdocs/chargesociales.class.php | 68 +++++++++++++++++++---- htdocs/compta/sociales/index.php | 95 ++++++++++++++++---------------- 2 files changed, 104 insertions(+), 59 deletions(-) diff --git a/htdocs/chargesociales.class.php b/htdocs/chargesociales.class.php index 9f6226c72cf..504ed568598 100644 --- a/htdocs/chargesociales.class.php +++ b/htdocs/chargesociales.class.php @@ -138,7 +138,9 @@ class ChargeSociales { var $paye; var $periode; - function ChargeSociales($DB) { + + function ChargeSociales($DB) + { $this->db = $DB; return 1; @@ -223,17 +225,61 @@ class ChargeSociales { $return = $this->db->query( $sql); } + /** + * \brief Retourne le libellé du statut d'une charge (impayé, payée) + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long + * \return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->paye,$mode); + } - /** - * \brief Renvoi le staut de la charge sous forme de libellé - * \return string libellé du statut - */ - function getLibStatut() { - global $langs; - - if ($this->paye == 0) { return $langs->trans("Unpayed"); } - else { return $langs->trans("Payed"); } - } + /** + * \brief Renvoi le libellé d'un statut donné + * \param statut Id statut + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libellé du statut + */ + function LibStatut($statut,$mode=0) + { + global $langs; + $langs->load('customers'); + + if ($mode == 0) + { + if ($statut == 0) return $langs->trans("Unpayed"); + if ($statut == 1) return $langs->trans("Payed"); + } + if ($mode == 1) + { + if ($statut == 0) return $langs->trans("Unpayed"); + if ($statut == 1) return $langs->trans("Payed"); + } + if ($mode == 2) + { + if ($statut == 0) return img_picto($langs->trans("Unpayed"), 'statut1').' '.$langs->trans("Unpayed"); + if ($statut == 1) return img_picto($langs->trans("Payed"), 'statut6').' '.$langs->trans("Payed"); + } + if ($mode == 3) + { + if ($statut == 0) return img_picto($langs->trans("Unpayed"), 'statut1'); + if ($statut == 1) return img_picto($langs->trans("Payed"), 'statut6'); + } + if ($mode == 4) + { + if ($statut == 0) return img_picto($langs->trans("Unpayed"), 'statut1').' '.$langs->trans("Unpayed"); + if ($statut == 1) return img_picto($langs->trans("Payed"), 'statut6').' '.$langs->trans("Payed"); + } + if ($mode == 5) + { + if ($statut == 0) return $langs->trans("Unpayed").' '.img_picto($langs->trans("Unpayed"), 'statut1'); + if ($statut == 1) return $langs->trans("Payed").' '.img_picto($langs->trans("Payed"), 'statut6'); + } + + return "Error, mode/status not found"; + } + } ?> diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 86b1dfc1c8f..4f757bd70fe 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -20,15 +20,16 @@ * $Source$ */ -/** +/** \file htdocs/compta/sociales/index.php \ingroup compta \brief Ecran des charges sociales \version $Revision$ */ - require("./pre.inc.php"); +require(DOL_DOCUMENT_ROOT."/chargesociales.class.php"); + $user->getrights('facture'); $user->getrights('compta'); @@ -47,7 +48,7 @@ if ($page < 0) $page = 0; $limit = $conf->liste_limit; $offset = $limit * $page ; - + if (! $sortfield) $sortfield="c.id"; if (! $sortorder) $sortorder="DESC"; @@ -65,7 +66,7 @@ if ($_POST["action"] == 'add') $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) ) { dolibarr_print_error($db); @@ -140,17 +141,17 @@ if ($user->rights->compta->charges->creer) { print ' '; print '
YYYYMMDD'; print '
YYYYMMDD'; - + print ''; print ''; - + print ''; print ''; @@ -200,7 +201,7 @@ if ($filtre) { $sql .= " AND $filtre"; } if ($_GET["sortfield"]) { - $sql .= " ORDER BY ".$_GET["sortfield"]; + $sql .= " ORDER BY ".$_GET["sortfield"]; } else { $sql .= " ORDER BY lower(s.date_ech)"; @@ -213,54 +214,52 @@ else { } +$chargesociale_static=new ChargeSociales($db); -if ( $db->query($sql) ) +$resql=$db->query($sql); +if ($resql) { - $num = $db->num_rows(); - $i = 0; - $var=true; + $num = $db->num_rows($resql); + $i = 0; + $var=true; - while ($i < $num) - { - $obj = $db->fetch_object(); - - $var = !$var; - print ""; - print ''; - print ''.img_file().' '.$obj->id.''; - print ''; - - print ''.dolibarr_print_date($obj->de).''; - print ''; - if ($obj->periode) { - print 'periode).'">'.strftime("%Y",$obj->periode).''; - } else { - print ' '; - } - print ''; - print ''.$obj->type_lib.''.dolibarr_trunc($obj->libelle,36).''; - print ''.price($obj->amount).''; - - if ($obj->paye) + while ($i < $num) { - print 'Payé'; - } else { - print 'Impayé'; + $obj = $db->fetch_object($resql); + + $var = !$var; + print ""; + print ''; + print ''.img_file().' '.$obj->id.''; + print ''; + + print ''.dolibarr_print_date($obj->de).''; + print ''; + if ($obj->periode) { + print 'periode).'">'.strftime("%Y",$obj->periode).''; + } else { + print ' '; + } + print ''; + print ''.$obj->type_lib.''.dolibarr_trunc($obj->libelle,36).''; + print ''.price($obj->amount).''; + + print ''.$chargesociale_static->LibStatut($obj->paye,5).''; + + print ''; + $i++; + } + } + else + { + dolibarr_print_error($db); } - print ''; - $i++; - } -} -else -{ - dolibarr_print_error($db); -} print ''; $db->close(); - + llxFooter("Dernière modification $Date$ révision $Revision$"); ?>