diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 98d971acbd0..1f8ae82dcbd 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -1725,17 +1725,15 @@ class Adherent extends CommonObject
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user)
{
- global $conf;
-
- $now=dol_now();
+ global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
- $this->nbtodo=$this->nbtodolate=0;
+ $now=dol_now();
$sql = "SELECT a.rowid, a.datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
@@ -1746,12 +1744,24 @@ class Adherent extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
+ $langs->load("members");
+
+ $response = new BoardResponse();
+ $response->warning_delay=$conf->adherent->cotisation->warning_delay/60/60/24;
+ $response->label=$langs->trans("MembersWithSubscriptionToReceive");
+ $response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1';
+ $response->img=img_object($langs->trans("Members"),"user");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if ($this->db->jdate($obj->datefin) < ($now - $conf->adherent->cotisation->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+
+ if ($this->db->jdate($obj->datefin) < ($now - $conf->adherent->cotisation->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index b20a3afa3ea..d13f32f157c 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -712,18 +712,14 @@ class ActionComm extends CommonObject
}
/**
- * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
+ * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
- * @param User $user Objet user
- * @return int <0 if KO, >0 if OK
+ * @param User $user Objet user
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user)
{
- global $conf, $user;
-
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
+ global $conf, $user, $langs;
$sql = "SELECT a.id, a.datep as dp";
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
@@ -739,13 +735,25 @@ class ActionComm extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
+ $now = dol_now();
+
+ $response = new BoardResponse();
+ $response->warning_delay = $conf->actions->warning_delay/60/60/24;
+ $response->label = $langs->trans("ActionsToDo");
+ $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
+ $response->img = img_object($langs->trans("Actions"),"action");
+
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if (isset($obj->dp) && $this->db->jdate($obj->dp) < ($now - $conf->actions->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+
+ if (isset($obj->dp) && $this->db->jdate($obj->dp) < ($now - $conf->actions->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index 267fde415f6..1a574fa434a 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -140,9 +140,7 @@ if (empty($reshook))
{
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
- //TODO: What is this for?
- // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
- // on affiche donc juste un message
+ // As security measure, we don't allow send from the GUI
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings');
setEventMessage('', 'warnings');
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings');
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 8fae698ba94..2c20e5ea1c7 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -116,10 +116,6 @@ class Propal extends CommonObject
var $labelstatut=array();
var $labelstatut_short=array();
- // Pour board
- var $nbtodo;
- var $nbtodolate;
-
var $specimen;
@@ -2349,15 +2345,12 @@ class Propal extends CommonObject
*
* @param User $user Object user
* @param int $mode "opened" for proposal to close, "signed" for proposal to invoice
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user,$mode)
{
- global $conf, $user;
+ global $conf, $user, $langs;
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";
$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin";
@@ -2376,25 +2369,43 @@ class Propal extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
- if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay;
- if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay;
+ $langs->load("propal");
+ $now=dol_now();
+
+ if ($mode == 'opened') {
+ $delay_warning=$conf->propal->cloture->warning_delay;
+ $statut = 1;
+ $label = $langs->trans("PropalsToClose");
+ }
+ if ($mode == 'signed') {
+ $delay_warning=$conf->propal->facturation->warning_delay;
+ $statut = 2;
+ $label = $langs->trans("PropalsToBill");
+ }
+
+ $response = new BoardResponse();
+ $response->warning_delay = $delay_warning;
+ $response->label = $label;
+ $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut;
+ $response->img = img_object($langs->trans("Propals"),"propal");
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
+ $response->nbtodo++;
if ($mode == 'opened')
{
$datelimit = $this->db->jdate($obj->datefin);
if ($datelimit < ($now - $delay_warning))
{
- $this->nbtodolate++;
+ $response->nbtodolate++;
}
}
// TODO Definir regle des propales a facturer en retard
// if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++;
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 27c320b3326..511af75a967 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -106,10 +106,6 @@ class Commande extends CommonOrder
var $lines = array();
- // Pour board
- var $nbtodo;
- var $nbtodolate;
-
/**
* Constructor
@@ -2729,15 +2725,12 @@ class Commande extends CommonOrder
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Object user
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user)
{
- global $conf, $user;
+ global $conf, $user, $langs;
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";
$sql = "SELECT c.rowid, c.date_creation as datec, c.date_livraison as delivery_date, c.fk_statut";
@@ -2756,14 +2749,26 @@ class Commande extends CommonOrder
$resql=$this->db->query($sql);
if ($resql)
{
+ $now=dol_now();
+
+ $response = new BoardResponse();
+ $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
+ $response->label=$langs->trans("OrdersToProcess");
+ $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3';
+ $response->img=img_object($langs->trans("Orders"),"order");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
+ $response->nbtodo++;
$date_to_test = empty($obj->delivery_date) ? $obj->datec : $obj->delivery_date;
- if ($obj->fk_statut != 3 && $this->db->jdate($date_to_test) < ($now - $conf->commande->client->warning_delay)) $this->nbtodolate++;
+
+ if ($obj->fk_statut != 3 && $this->db->jdate($date_to_test) < ($now - $conf->commande->client->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 598ccc2c8d8..c2929fb33a4 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -881,18 +881,14 @@ class Account extends CommonObject
*
* @param User $user Objet user
* @param int $filteraccountid To get info for a particular account id
- * @return int <0 if KO, 0=Nothing to show, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user,$filteraccountid=0)
{
- global $conf;
+ global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
-
$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
@@ -902,17 +898,27 @@ class Account extends CommonObject
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
- //print $sql;
$resql=$this->db->query($sql);
if ($resql)
{
- $num=$this->db->num_rows($resql);
+ $langs->load("banks");
+ $now=dol_now();
+
+ $response = new BoardResponse();
+ $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
+ $response->label=$langs->trans("TransactionsToConciliate");
+ $response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
+ $response->img=img_object($langs->trans("TransactionsToConciliate"),"payment");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+ if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return $num;
+
+ return $response;
}
else
{
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5c645783cc1..3bbf76c79fe 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -117,9 +117,6 @@ class Facture extends CommonInvoice
var $lines=array();
var $line;
var $extraparams=array();
- //! Pour board
- var $nbtodo;
- var $nbtodolate;
var $specimen;
var $fac_rec;
@@ -3088,15 +3085,12 @@ class Facture extends CommonInvoice
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Object user
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user)
{
- global $conf, $user;
+ global $conf, $user, $langs;
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";
$sql = "SELECT f.rowid, f.date_lim_reglement as datefin";
@@ -3115,12 +3109,25 @@ class Facture extends CommonInvoice
$resql=$this->db->query($sql);
if ($resql)
{
+ $langs->load("bills");
+ $now=dol_now();
+
+ $response = new BoardResponse();
+ $response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
+ $response->label=$langs->trans("CustomerBillsUnpaid");
+ $response->url=DOL_URL_ROOT.'/compta/facture/impayees.php';
+ $response->img=img_object($langs->trans("Bills"),"bill");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if ($this->db->jdate($obj->datefin) < ($now - $conf->facture->client->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+
+ if ($this->db->jdate($obj->datefin) < ($now - $conf->facture->client->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index 11a61874e7e..6bb1429d0a0 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -432,18 +432,14 @@ class RemiseCheque extends CommonObject
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user)
{
- global $conf;
+ global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
-
$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
@@ -456,12 +452,25 @@ class RemiseCheque extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
+ $langs->load("banks");
+ $now=dol_now();
+
+ $response = new BoardResponse();
+ $response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
+ $response->label=$langs->trans("BankChecksToReceipt");
+ $response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=accountancy';
+ $response->img=img_object($langs->trans("BankChecksToReceipt"),"payment");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+
+ if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index bbecab53a30..19001edf92c 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -1881,15 +1881,11 @@ class Contrat extends CommonObject
*
* @param User $user Objet user
* @param string $mode "inactive" pour services a activer, "expired" pour services expires
- * @return int <0 if KO, >0 if OK
+ * @return BoardResponse|int <0 if KO, BoardResponse if OK
*/
function load_board($user,$mode)
{
- global $conf, $user;
-
- $now=dol_now();
-
- $this->nbtodo=$this->nbtodolate=0;
+ global $conf, $user, $langs;
$this->from = " FROM ".MAIN_DB_PREFIX."contrat as c";
$this->from.= ", ".MAIN_DB_PREFIX."contratdet as cd";
@@ -1920,15 +1916,35 @@ class Contrat extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
+ $langs->load("contracts");
+ $now=dol_now();
+
+ if ($mode == 'inactives') {
+ $warning_delay = $conf->contrat->services->inactifs->warning_delay;
+ $label = $langs->trans("BoardNotActivatedServices");
+ $url = DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=0';
+ } else {
+ $warning_delay = $conf->contrat->services->expires->warning_delay;
+ $url = DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired';
+ $label = $langs->trans("BoardRunningServices");
+ }
+
+ $response = new BoardResponse();
+ $response->warning_delay = $warning_delay/60/60/24;
+ $response->label = $label;
+ $response->url = $url;
+ $response->img = img_object($langs->trans("Contract"),"contract");
+
while ($obj=$this->db->fetch_object($resql))
{
- $this->nbtodo++;
- if ($mode == 'inactives')
- if ($obj->datefin && $this->db->jdate($obj->datefin) < ($now - $conf->contrat->services->inactifs->warning_delay)) $this->nbtodolate++;
- if ($mode == 'expired')
- if ($obj->datefin && $this->db->jdate($obj->datefin) < ($now - $conf->contrat->services->expires->warning_delay)) $this->nbtodolate++;
+ $response->nbtodo++;
+
+ if ($obj->datefin && $this->db->jdate($obj->datefin) < ($now - $warning_delay)) {
+ $response->nbtodolate++;
+ }
}
- return 1;
+
+ return $response;
}
else
{
diff --git a/htdocs/core/class/BoardResponse.class.php b/htdocs/core/class/BoardResponse.class.php
new file mode 100644
index 00000000000..9cf12e7a702
--- /dev/null
+++ b/htdocs/core/class/BoardResponse.class.php
@@ -0,0 +1,69 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
| '.$board->img.' | '.$board->label.' | '; print ''.$board->nbtodo.' | '; @@ -531,8 +440,6 @@ foreach($dashboardlines as $key => $board) if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements print showWeather($totallate,$text,$options); - //print showWeather(0,''); - //print showWeather(40,$text); print ''; $showweather=0; }