From 9bf544f727ac48f13f33e1de4bd117efb73b62f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Aug 2005 21:45:18 +0000 Subject: [PATCH] New: Ajout d'informations dans le tableau de bord Dolibarr. --- htdocs/adherents/adherent.class.php | 62 ++++++++ htdocs/adherents/liste.php | 2 +- htdocs/client.class.php | 125 ++++++++++----- htdocs/compta/bank/account.class.php | 30 ++++ htdocs/fourn/fournisseur.class.php | 32 ++++ htdocs/index.php | 230 ++++++++++++++++++++++++--- htdocs/master.inc.php | 2 + htdocs/product.class.php | 32 ++++ htdocs/service.class.php | 49 +++++- 9 files changed, 493 insertions(+), 71 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index fc50cce23bc..e1c5d951b3b 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -1280,5 +1280,67 @@ class Adherent if ($statut == 0) return $langs->trans("MemberStatusResiliated"); } + + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf; + + $this->nb=array(); + + $sql = "SELECT count(a.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql.= " WHERE a.statut > 0"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["members"]=$obj->nb; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } + + /** + * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_board() + { + global $conf; + + $this->nbtodo=$this->nbtodolate=0; + $sql = "SELECT a.rowid,".$this->db->pdate("a.datefin")." as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql.= " WHERE a.statut=1"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($obj->datefin < (time() - $conf->adherent->cotisation->warning_delay)) $this->nbtodolate++; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + } ?> diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index 45d2f3779be..c466b5cf0a8 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -97,7 +97,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom","&page=$page&statut=$statut","","",$sortfield); - print_liste_field_titre($langs->trans("DateAbonment"),"liste.php","t.cotisation","&page=$page&statut=$statut","","",$sortfield); + print_liste_field_titre($langs->trans("EndSubscription"),"liste.php","t.cotisation","&page=$page&statut=$statut","","",$sortfield); print_liste_field_titre($langs->trans("EMail"),"liste.php","d.email","&page=$page&statut=$statut","","",$sortfield); print_liste_field_titre($langs->trans("Type"),"liste.php","t.libelle","&page=$page&statut=$statut","","",$sortfield); print_liste_field_titre($langs->trans("Person"),"liste.php","d.morphy","&page=$page&statut=$statut","","",$sortfield); diff --git a/htdocs/client.class.php b/htdocs/client.class.php index 05382e38619..43aa20f66d7 100644 --- a/htdocs/client.class.php +++ b/htdocs/client.class.php @@ -20,63 +20,102 @@ * */ -/*! \file htdocs/client.class.php +/** + \file htdocs/client.class.php \ingroup societe \brief Fichier de la classe des clients \version $Revision$ */ -/*! \class Client - \brief Classe permettant la gestion des clients +/** + \class Client + \brief Classe permettant la gestion des clients */ include_once DOL_DOCUMENT_ROOT."/societe.class.php"; -class Client extends Societe { - var $db; - /** - * \brief Constructeur de la classe - * \param DB handler accès base de données - * \param id id societe (0 par defaut) - */ - - function Client($DB, $id=0) - { - global $config; +class Client extends Societe +{ + var $db; - $this->db = $DB; - $this->id = $id; - $this->factures = array(); - - return 0; - } - - function read_factures() - { - $sql = "SELECT rowid, facnumber"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.fk_soc = ".$this->id; - $sql .= " ORDER BY datef DESC"; - $result = $this->db->query($sql) ; - $i = 0; - if ( $result ) - { - $num = $this->db->num_rows(); - - while ($i < $num ) - { - $row = $this->db->fetch_row(); + /** + * \brief Constructeur de la classe + * \param DB handler accès base de données + * \param id id societe (0 par defaut) + */ + function Client($DB, $id=0) + { + global $config; + + $this->db = $DB; + $this->id = $id; + $this->factures = array(); + + return 0; + } + + function read_factures() + { + $sql = "SELECT rowid, facnumber"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.fk_soc = ".$this->id; + $sql .= " ORDER BY datef DESC"; + + $result = $this->db->query($sql) ; + $i = 0; + if ( $result ) + { + $num = $this->db->num_rows(); + + while ($i < $num ) + { + $row = $this->db->fetch_row(); + + $this->factures[$i][0] = $row[0]; + $this->factures[$i][1] = $row[1]; + + $i++; + } + } + return $result; + } - $this->factures[$i][0] = $row[0]; - $this->factures[$i][1] = $row[1]; + + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf; + + $this->nb=array(); - $i++; - } - } - return $result; - } + $sql = "SELECT count(s.idp) as nb, s.client"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.client in (1,2)"; + $sql.= " GROUP BY s.client"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + if ($obj->client == 1) $this->nb["customers"]=$obj->nb; + if ($obj->client == 2) $this->nb["prospects"]=$obj->nb; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } + } ?> diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 826a11f3422..dd6f0b34595 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -464,6 +464,36 @@ class Account } + /** + * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_board() + { + global $conf; + + $this->nbtodo=$this->nbtodolate=0; + $sql = "SELECT b.rowid,".$this->db->pdate("b.datev")." as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.rappro=0"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($obj->datefin < (time() - $conf->bank->rappro->warning_delay)) $this->nbtodolate++; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + } ?> diff --git a/htdocs/fourn/fournisseur.class.php b/htdocs/fourn/fournisseur.class.php index 5f2c4335192..e71fe0abf2e 100644 --- a/htdocs/fourn/fournisseur.class.php +++ b/htdocs/fourn/fournisseur.class.php @@ -159,6 +159,38 @@ class Fournisseur extends Societe { $commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn); } } + + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf; + + $this->nb=array(); + + $sql = "SELECT count(s.idp) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.fournisseur = 1"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["suppliers"]=$obj->nb; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } + } ?> diff --git a/htdocs/index.php b/htdocs/index.php index dcd6e55b06d..3027db77a85 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -128,15 +128,143 @@ else } */ + +/* + * Dolibarr State Board + */ +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; + +$var=true; + +// Nbre de sociétés clients/prospects +if ($conf->societe->enabled) +{ + include_once("./client.class.php"); + $board=new Client($db); + $board->load_state_board(); + + foreach($board->nb as $key=>$val) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } +} + +// Nbre de sociétés fournisseurs +if ($conf->fournisseur->enabled) +{ + include_once("./fourn/fournisseur.class.php"); + $board=new Fournisseur($db); + $board->load_state_board(); + + foreach($board->nb as $key=>$val) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } +} + +// Nbre d'adhérents +if ($conf->adherent->enabled) +{ + include_once("./adherents/adherent.class.php"); + $board=new Adherent($db); + $board->load_state_board(); + + foreach($board->nb as $key=>$val) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } +} + +// Nbre de produits +if ($conf->produit->enabled) +{ + //include_once("./product.class.php"); + $board=new Product($db); + $board->load_state_board(); + + foreach($board->nb as $key=>$val) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } +} + +// Nbre de services +if ($conf->service->enabled) +{ + include_once("./service.class.php"); + $board=new Service($db); + $board->load_state_board(); + + foreach($board->nb as $key=>$val) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans("DolibarrStateBoard").' 
'.img_object($langs->trans("Customers"),"company").''; + if ($key == "customers") print $langs->trans("Customers"); + if ($key == "prospects") print $langs->trans("Prospects"); + print ''; + if ($key == "customers") print ''; + if ($key == "prospects") print ''; + print $val; + print '
'.img_object($langs->trans("Suppliers"),"company").''; + if ($key == "suppliers") print $langs->trans("Suppliers"); + print ''; + if ($key == "suppliers") print ''; + print $val; + print '
'.img_object($langs->trans("Adherent"),"user").''; + if ($key == "members") print $langs->trans("Adherents"); + print ''; + if ($key == "members") print ''; + print $val; + print '
'.img_object($langs->trans("Producst"),"product").''; + if ($key == "products") print $langs->trans("Products"); + print ''; + if ($key == "products") print ''; + print $val; + print '
'.img_object($langs->trans("Services"),"service").''; + if ($key == "services") print $langs->trans("Services"); + print ''; + if ($key == "services") print ''; + print $val; + print '
'; + + print ''; /* - * Dolibarr Board + * Dolibarr Work Board */ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -151,15 +279,17 @@ if ($conf->commercial->enabled || $conf->compta->enabled) include_once("./actioncomm.class.php"); $board=new ActionComm($db); $board->load_board(); + $board->warning_delay=$conf->actions->warning_delay/60/60/24; + $board->label=$langs->trans("ActionsToDo"); $var=!$var; - print ''; + print ''; print ''; print ''; print ''; } +// Nbre services à activer (en retard) +if ($conf->contrat->enabled && $user->rights->contrat->lire) +{ + $langs->load("contracts"); + + include_once("./contrat/contrat.class.php"); + $board=new Contrat($db); + $board->load_board("inactives"); + + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; +} + +// Nbre services actifs (à renouveler) +if ($conf->contrat->enabled && $user->rights->contrat->lire) +{ + $langs->load("contracts"); + + include_once("./contrat/contrat.class.php"); + $board=new Contrat($db); + $board->load_board("expired"); + + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; +} + // Nbre factures fournisseurs (à payer) if ($conf->fournisseur->enabled && $conf->facture->enabled && $user->rights->facture->lire) { @@ -283,23 +463,23 @@ if ($conf->facture->enabled && $user->rights->facture->lire) print ''; } -// Nbre services à activer (en retard) -if ($conf->contrat->enabled && $user->rights->contrat->lire) +// Nbre ecritures à rapprocher +if ($conf->banque->enabled && $user->rights->banque->lire) { - $langs->load("contracts"); - - include_once("./contrat/contrat.class.php"); - $board=new Contrat($db); - $board->load_board("inactives"); + $langs->load("banks"); + + //include_once("./compta/bank/account.class.php"); + $board=new Account($db); + $board->load_board(); $var=!$var; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } -// Nbre services actifs (à renouveler) -if ($conf->contrat->enabled && $user->rights->contrat->lire) +// Nbre adhérent valides (attente cotisation) +if ($conf->adherent->enabled && $user->rights->adherent->lire) { - $langs->load("contracts"); + $langs->load("members"); - include_once("./contrat/contrat.class.php"); - $board=new Contrat($db); - $board->load_board("expired"); + include_once("./adherents/adherent.class.php"); + $board=new Adherent($db); + $board->load_board(); $var=!$var; - print ''; - print ''; + print ''; + print ''; print ''; print '
'.$langs->trans("DolibarrBoard").''.$langs->trans("DolibarrWorkBoard").''.$langs->trans("Number").''.$langs->trans("Late").' 
'.img_object($langs->trans("Actions"),"task").''.$langs->trans("ActionsToDo").'
'.img_object($langs->trans("Actions"),"task").''.$board->label.''.$board->nbtodo.''; print ''; print $board->nbtodolate; print ''; - print ' (>'.ceil($conf->actions->warning_delay/60/60/24).' '.$langs->trans("days").')'; + print ' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')'; print ''; if ($board->nbtodolate > 0) print img_picto($langs->trans("Late"),"warning"); @@ -237,6 +367,56 @@ if ($conf->propal->enabled && $user->rights->propale->lire) print '
'.img_object($langs->trans("Contract"),"contract").''.$langs->trans("BoardNotActivatedServices").''.$board->nbtodo.''; + print ''; + print $board->nbtodolate; + print ''; + print ' (>'.ceil($conf->contrat->services->inactifs->warning_delay/60/60/24).' '.$langs->trans("days").')'; + print ''; + if ($board->nbtodolate > 0) print img_picto($langs->trans("Late"),"warning"); + else print ' '; + print '
'.img_object($langs->trans("Contract"),"contract").''.$langs->trans("BoardRunningServices").''.$board->nbtodo.''; + print ''; + print $board->nbtodolate; + print ''; + print ' (>'.ceil($conf->contrat->services->expires->warning_delay/60/60/24).' '.$langs->trans("days").')'; + print ''; + if ($board->nbtodolate > 0) print img_picto($langs->trans("Late"),"warning"); + else print ' '; + print '
'.img_object($langs->trans("Contract"),"contract").''.$langs->trans("BoardNotActivatedServices").''.$board->nbtodo.'
'.img_object($langs->trans("TransactionsToConciliate"),"payment").''.$langs->trans("TransactionsToConciliate").''.$board->nbtodo.''; - print ''; + print ''; print $board->nbtodolate; print ''; - print ' (>'.ceil($conf->contrat->services->inactifs->warning_delay/60/60/24).' '.$langs->trans("days").')'; + print ' (>'.ceil($conf->bank->rappro->warning_delay/60/60/24).' '.$langs->trans("days").')'; print ''; if ($board->nbtodolate > 0) print img_picto($langs->trans("Late"),"warning"); @@ -308,23 +488,23 @@ if ($conf->contrat->enabled && $user->rights->contrat->lire) print '
'.img_object($langs->trans("Contract"),"contract").''.$langs->trans("BoardRunningServices").''.$board->nbtodo.'
'.img_object($langs->trans("Members"),"user").''.$langs->trans("Members").''.$board->nbtodo.''; - print ''; + print ''; print $board->nbtodolate; print ''; - print ' (>'.ceil($conf->contrat->services->expires->warning_delay/60/60/24).' '.$langs->trans("days").')'; + print ' (>'.ceil($conf->adherent->cotisation->warning_delay/60/60/24).' '.$langs->trans("days").')'; print ''; if ($board->nbtodolate > 0) print img_picto($langs->trans("Late"),"warning"); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 566f2bacabe..672a9598fe7 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -381,6 +381,8 @@ $conf->facture->fournisseur->warning_delay=2*24*60*60; $conf->facture->client->warning_delay=31*24*60*60; // 1 mois $conf->contrat->services->inactifs->warning_delay=0*24*60*60; $conf->contrat->services->expires->warning_delay=0*24*60*60; +$conf->adherent->cotisation->warning_delay=31*24*60*60; // 1 mois +$conf->bank->rappro->warning_delay=2*31*24*60*60; // 2 mois /* */ diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 150c2c08ce3..8bc0615bc24 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1145,5 +1145,37 @@ class Product return $tabobj; } + + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf; + + $this->nb=array(); + + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= " WHERE p.fk_product_type = 0"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["products"]=$obj->nb; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } + } ?> diff --git a/htdocs/service.class.php b/htdocs/service.class.php index 42bb95ba03f..1a9c3339162 100644 --- a/htdocs/service.class.php +++ b/htdocs/service.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2002 Rodolphe Quiedeville + * Copyright (C) 2004-2005 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 @@ -20,7 +21,21 @@ * */ -class Service { +/** + \file htdocs/service.class.php + \ingroup service + \brief Fichier de la classe des services prédéfinis + \version $Revision$ +*/ + + +/** + \class Service + \brief Classe permettant la gestion des services prédéfinis +*/ + +class Service +{ var $db; var $id; @@ -179,6 +194,36 @@ class Service { } } + /** + * \brief Charge indicateurs this->nb de tableau de bord + * \return int <0 si ko, >0 si ok + */ + function load_state_board() + { + global $conf; + + $this->nb=array(); + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= " WHERE p.fk_product_type = 1"; + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["services"]=$obj->nb; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + + } + } ?>