diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 98d971acbd0821df353f77f4a6c31398776f89a5..9a385becff3265b07cb1f906b652a7606fe7da42 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -1725,17 +1726,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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 +1745,24 @@ class Adherent extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $langs->load("members"); + + $response = new WorkboardResponse(); + $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 b20a3afa3eabd0281b6d98fec48c737a33856856..5cfe1dc731036574f4b424f5923611d90745aacd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -712,18 +713,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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 +736,25 @@ class ActionComm extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $now = dol_now(); + + $response = new WorkboardResponse(); + $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 267fde415f6aa4ff450f1a70c68af45ccee7ae66..1a574fa434ac5103d4aa625c4eebcff648cdc49c 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('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', '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 8fae698ba946448f7de822592a5bc57f3c63fdb7..edc6d7bfd9452dbf9480fbbe2139291d4fbaa7fa 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 WorkboardResponse(); + $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 27c320b33264ffdc7d5aff8b91160ae73b06368c..d5c6b3f771516a19db735a876624fa0293f5be4f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2011 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -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 WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { - global $conf, $user; - - $now=dol_now(); + global $conf, $user, $langs; - $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 WorkboardResponse(); + $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 598ccc2c8d845085deebd703ee75cac6d06cdef1..a2d9aec8ad4cba3b3b542780bcf166bfceb5fbd1 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com> * Copytight (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -881,18 +882,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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 +899,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 WorkboardResponse(); + $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 5c645783cc1bcb76b66d6f101b2d79ecd049e686..50a68b2c66a268e6dbab00cf3af2754614c8d857 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr> - * Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr> @@ -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 WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { - global $conf, $user; - - $now=dol_now(); + global $conf, $user, $langs; - $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 WorkboardResponse(); + $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 11a61874e7ecbe25d92fa41bd78323bfc3a510b9..ddda11bb556f3f73a2903837ed2f8ddfef4093e6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -432,18 +433,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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 +453,25 @@ class RemiseCheque extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $langs->load("banks"); + $now=dol_now(); + + $response = new WorkboardResponse(); + $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 bbecab53a30d88f3738184a1b60945b139625fa4..3cd35db15b5a2ec7f3595d9ac368c9be90a601a4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -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 WorkboardResponse|int <0 if KO, WorkboardResponse 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 WorkboardResponse(); + $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/WorkboardResponse.class.php b/htdocs/core/class/WorkboardResponse.class.php new file mode 100644 index 0000000000000000000000000000000000000000..c36b50b421e84636ee0715e48a095cf8b0d01d53 --- /dev/null +++ b/htdocs/core/class/WorkboardResponse.class.php @@ -0,0 +1,69 @@ +<?php + +/* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +/** + * \file htdocs/core/class/WorkboardResponse.class.php + * \brief Class that represents response of load_board functions + */ + +class WorkboardResponse +{ + + /** + * Image URL to represent the board item + * @var string + */ + public $img; + + /** + * Label of the warning + * @var string + */ + public $label; + + /** + * URL to list to do items + * @var string + */ + public $url; + + /** + * (optional) If set, to do late items will link to this url + * @var string + */ + public $url_late; + + /** + * Delay time to mark an item as late + * @var int + */ + public $warning_delay; + + /** + * Number of items to do + * @var int + */ + public $nbtodo = 0; + + /** + * Number of to do items which are late + * @var int + */ + public $nbtodolate = 0; + +} \ No newline at end of file diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 0f86f01693ca66bf515a4849f8fd568ba364a76f..e2d938da71054cc9fc162dc8fac1a512e13abc32 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2007 Simon Desee <simon@dedisoft.com> + * Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr> * * 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 @@ -146,7 +147,7 @@ class DoliDBMssql extends DoliDB */ function select_db($database) { - return mssql_select_db($database, $this->db); + return @mssql_select_db($database, $this->db); } /** @@ -171,6 +172,15 @@ class DoliDBMssql extends DoliDB // les nouvelles version de Dolibarr car force par l'install Dolibarr. //$this->query('SET NAMES '.$this->forcecharset); //print "Resultat fonction connect: ".$this->db; + $set_options=array('SET ANSI_PADDING ON;', + "SET ANSI_NULLS ON;", + "SET ANSI_WARNINGS ON;", + "SET ARITHABORT ON;", + "SET CONCAT_NULL_YIELDS_NULL ON;", + "SET QUOTED_IDENTIFIER ON;" + ); + mssql_query(implode(' ',$set_options),$this->db); + return $this->db; } @@ -224,19 +234,22 @@ class DoliDBMssql extends DoliDB */ function begin() { - if (! $this->transaction_opened) + + $res=mssql_query('select @@TRANCOUNT'); + $this->transaction_opened=mssql_result($res, 0, 0); + + if ($this->transaction_opened == 0) { - $ret=$this->query("BEGIN TRANSACTION"); + //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess + $ret=mssql_query("SET IMPLICIT_TRANSACTIONS OFF;BEGIN TRANSACTION;",$this->db); if ($ret) { - $this->transaction_opened++; dol_syslog("BEGIN Transaction",LOG_DEBUG); } return $ret; } else { - $this->transaction_opened++; return 1; } } @@ -249,12 +262,15 @@ class DoliDBMssql extends DoliDB */ function commit($log='') { - if ($this->transaction_opened <= 1) + $res=mssql_query('select @@TRANCOUNT'); + $this->transaction_opened=mssql_result($res, 0, 0); + + if ($this->transaction_opened == 1) { - $ret=$this->query("COMMIT TRANSACTION"); + //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTION ON' generate also a mess + $ret=mssql_query("COMMIT TRANSACTION",$this->db); if ($ret) { - $this->transaction_opened=0; dol_syslog("COMMIT Transaction",LOG_DEBUG); return 1; } @@ -263,11 +279,11 @@ class DoliDBMssql extends DoliDB return 0; } } - else + elseif ($this->transaction_opened > 1) { - $this->transaction_opened--; return 1; - } + } else + trigger_error("Commit requested but no transaction remain"); } /** @@ -278,18 +294,20 @@ class DoliDBMssql extends DoliDB */ function rollback($log='') { - if ($this->transaction_opened<=1) + $res=mssql_query('select @@TRANCOUNT'); + $this->transaction_opened=mssql_result($res, 0, 0); + + if ($this->transaction_opened == 1) { - $ret=$this->query("ROLLBACK TRANSACTION"); - $this->transaction_opened=0; + $ret=mssql_query("ROLLBACK TRANSACTION",$this->db); dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG); return $ret; } - else + elseif ($this->transaction_opened > 1) { - $this->transaction_opened--; return 1; - } + } else + trigger_error("Rollback requested but no transaction remain"); } /** @@ -304,54 +322,98 @@ class DoliDBMssql extends DoliDB function query($query,$usesavepoint=0,$type='auto') { $query = trim($query); + + if (preg_match('/^--/',$query)) return true; // Conversion syntaxe MySql vers MSDE. $query = str_ireplace("now()", "getdate()", $query); // Erreur SQL: cannot update timestamp field $query = str_ireplace(", tms = tms", "", $query); - // Voir si l'on peut directement utiliser $query = str_ireplace("file", "[file]", $query); - // au lieu des 3 lignes ci-dessous - $query = str_ireplace(".file", ".[file]", $query); - $query = str_ireplace(" file ", " [file] ", $query); - $query = str_ireplace(" file,", " [file],", $query); - // Idem file - $query = str_ireplace(".percent", ".[percent]", $query); - $query = str_ireplace(" percent ", " [percent] ", $query); - $query = str_ireplace("percent,", "[percent],", $query); - $query = str_ireplace("percent=", "[percent]=", $query); - $query = str_ireplace("\'", "''", $query); - - - $itemfound = stripos($query, " limit "); - if ($itemfound !== false) { - // Extraire le nombre limite - $number = stristr($query, " limit "); - $number = substr($number, 7); - // Inserer l'instruction TOP et le nombre limite - $query = str_ireplace("select ", "select top ".$number." ", $query); - // Supprimer l'instruction MySql - $query = str_ireplace(" limit ".$number, "", $query); - } - $itemfound = stripos($query, " week("); - if ($itemfound !== false) { - // Recreer une requete sans instruction Mysql - $positionMySql = stripos($query, " week("); - $newquery = substr($query, 0, $positionMySql); - - // Recuperer la date passee en parametre - $extractvalue = stristr($query, " week("); - $extractvalue = substr($extractvalue, 6); - $positionMySql = stripos($extractvalue, ")"); - // Conserver la fin de la requete - $endofquery = substr($extractvalue, $positionMySql); - $extractvalue = substr($extractvalue, 0, $positionMySql); - - // Remplacer l'instruction MySql en Sql Server - // Inserer la date en parametre et le reste de la requete - $query = $newquery." DATEPART(week, ".$extractvalue.$endofquery; + $query=preg_replace("/([. ,\t(])(percent|file|public)([. ,=\t)])/","$1[$2]$3",$query); + + if ($type=="auto" || $type='dml') + { + $query=preg_replace('/AUTO_INCREMENT/i','IDENTITY',$query); + $query=preg_replace('/double/i','float',$query); + $query=preg_replace('/float\((.*)\)/','numeric($1)',$query); + $query=preg_replace('/([ \t])unsigned|IF NOT EXISTS[ \t]/i','$1',$query); + $query=preg_replace('/([ \t])(MEDIUM|TINY|LONG){0,1}TEXT([ \t,])/i',"$1VARCHAR(MAX)$3",$query); + + $matches=array(); + $original_query=''; + if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+(?:(UNIQUE)|INDEX)\h+(?:INDEX)?\h*(\w+?)\h*\((.+)\)/is', $query,$matches)) + { + $original_query=$query; + $query="CREATE ".trim($matches[2])." INDEX [".trim($matches[3])."] ON [".trim($matches[1])."] (".trim($matches[4]).")"; + if ($matches[2]) { + //check if columun is nullable cause Sql server only allow 1 null value if unique index. + $fields=explode(",",trim($matches[4])); + $fields_clear=array_map('trim',$fields); + $infos=$this->GetFieldInformation(trim($matches[1]), $fields_clear); + $query_comp=array(); + foreach($infos as $fld) { + if ($fld->IS_NULLABLE == 'YES') { + $query_comp[]=$fld->COLUMN_NAME." IS NOT NULL"; + } + } + if ($query_comp) + $query.=" WHERE ".implode(" AND ",$query_comp); + } + } + else + { + if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) + { + $original_query=$query; + $query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")"; + } + } + } + if ($type=="auto" || $type='ddl') + { + $itemfound = stripos($query, " limit "); + if ($itemfound !== false) { + // Extraire le nombre limite + $number = stristr($query, " limit "); + $number = substr($number, 7); + // Inserer l'instruction TOP et le nombre limite + $query = str_ireplace("select ", "select top ".$number." ", $query); + // Supprimer l'instruction MySql + $query = str_ireplace(" limit ".$number, "", $query); + } + + $itemfound = stripos($query, " week("); + if ($itemfound !== false) { + // Recreer une requete sans instruction Mysql + $positionMySql = stripos($query, " week("); + $newquery = substr($query, 0, $positionMySql); + + // Recuperer la date passee en parametre + $extractvalue = stristr($query, " week("); + $extractvalue = substr($extractvalue, 6); + $positionMySql = stripos($extractvalue, ")"); + // Conserver la fin de la requete + $endofquery = substr($extractvalue, $positionMySql); + $extractvalue = substr($extractvalue, 0, $positionMySql); + + // Remplacer l'instruction MySql en Sql Server + // Inserer la date en parametre et le reste de la requete + $query = $newquery." DATEPART(week, ".$extractvalue.$endofquery; + } + if (preg_match('/^insert\h+(?:INTO)?\h*(\w+?)\h*\(.*\b(?:row)?id\b.*\)\h+VALUES/i',$query,$matches)) + { + //var_dump($query); + //var_dump($matches); + if (stripos($query,'llx_c_departements') !== false) var_dump($query); + $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;'; + @mssql_query($sql, $this->db); + $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;'; + + } + } //print "<!--".$query."-->"; if (! in_array($query,array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); @@ -365,6 +427,11 @@ class DoliDBMssql extends DoliDB { $ret = mssql_query($query, $this->db); } + + if (!empty($post_query)) + { + @mssql_query($post_query, $this->db); + } if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query)) { @@ -379,6 +446,7 @@ class DoliDBMssql extends DoliDB $this->lasterrno = $row["code"]; dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + if ($original_query) dol_syslog(get_class($this)."::query SQL Original query: ".$original_query, LOG_ERR); dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); } $this->lastquery=$query; @@ -539,7 +607,8 @@ class DoliDBMssql extends DoliDB 1146 => 'DB_ERROR_NOSUCHTABLE', 1216 => 'DB_ERROR_NO_PARENT', 1217 => 'DB_ERROR_CHILD_EXISTS', - 1451 => 'DB_ERROR_CHILD_EXISTS' + 1451 => 'DB_ERROR_CHILD_EXISTS', + 1913 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ); if (isset($errorcode_map[$this->lasterrno])) @@ -563,7 +632,7 @@ class DoliDBMssql extends DoliDB return 'Not connected. Check setup parameters in conf/conf.php file and your mssql client and server versions'; } else { - return mssql_get_last_message($this->db); + return mssql_get_last_message(); } } @@ -655,21 +724,27 @@ class DoliDBMssql extends DoliDB */ function DDLCreateDb($database,$charset='',$collation='',$owner='') { - if (empty($charset)) $charset=$this->forcecharset; + /*if (empty($charset)) $charset=$this->forcecharset; if (empty($collation)) $collation=$this->forcecollate; + */ - // ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci - $sql = 'CREATE DATABASE '.$database; - $sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation; + $sql = 'CREATE DATABASE '.$this->EscapeFieldName($database); + //TODO: Check if we need to force a charset + //$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation; $ret=$this->query($sql); - if (! $ret) - { - // On reessaie pour compatibilite avec mssql < 5.0 - $sql = 'CREATE DATABASE '.$database; - $ret=$this->query($sql); - } - - return $ret; + + $this->select_db($database); + $sql="CREATE USER [$owner] FOR LOGIN [$owner]"; + mssql_query($sql,$this->db); + $sql="ALTER ROLE [db_owner] ADD MEMBER [$owner]"; + mssql_query($sql,$this->db); + + $sql="ALTER DATABASE [$database] SET ANSI_NULL_DEFAULT ON;"; + @mssql_query($sql,$this->db); + $sql="ALTER DATABASE [$database] SET ANSI_NULL ON;"; + @mssql_query($sql,$this->db); + + return $ret; } /** @@ -884,12 +959,40 @@ class DoliDBMssql extends DoliDB */ function DDLCreateUser($dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name) { - // FIXME: Dummy method - // TODO: Implement - // May help: http://msdn.microsoft.com/fr-fr/library/ms173463.aspx - - // Always fail for now - return -1; + $sql = "CREATE LOGIN ".$this->EscapeFieldName($dolibarr_main_db_user)." WITH PASSWORD='$dolibarr_main_db_pass'"; + dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log + $resql=$this->query($sql); + if (! $resql) + { + if ($this->lasterrno != '15025') + { + return -1; + } + else + { + // If user already exists, we continue to set permissions + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); + } + } + $sql="SELECT name from sys.databases where name='".$dolibarr_main_db_name."'"; + $ressql=$this->query($sql); + if (! $ressql) + { + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); + return -1; + } + else + { + if ($num) + { + $this->select_db($dolibarr_main_db_name); + $sql="CREATE USER [$dolibarr_main_db_user] FOR LOGIN [$dolibarr_main_db_user]"; + $this->query($sql); + $sql="ALTER ROLE [db_owner] ADD MEMBER [$dolibarr_main_db_user]"; + $this->query($sql); + } + } + return 1; } /** @@ -1003,5 +1106,49 @@ class DoliDBMssql extends DoliDB return array(); } + + /** + * Escape a field name according to escape's syntax + * + * @param string $fieldname Field's name to escape + * @return string field's name escaped + */ + function EscapeFieldName($fieldname) { + return "[".$fieldname."]"; + } + + + /** + * Get information on field + * + * @param string $table Table name which contains fields + * @param mixed $fields String for one field or array of string for multiple field + * @return boolean|multitype:object + */ + function GetFieldInformation($table,$fields) { + $sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME"; + if (is_array($fields)) + { + $where=" IN ('".implode("','",$fields)."')"; + } + else + { + $where="='".$this->escape($fields)."'"; + } + $result=array(); + $ret=mssql_query($sql.$where,$this->db); + if ($ret) + { + while($obj=mssql_fetch_object($ret)) + { + $result[]=$obj; + } + } + else + return false; + + return $result; + } + } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b4312e45997fbc6c375a65fd361183b8f9b35c51..0b02b3ddc2908863afae5a47ece69c55495b3e60 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2014 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * @@ -2009,15 +2009,12 @@ class CommandeFournisseur extends CommonOrder * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user - * @return int <0 if KO, >0 if OK + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { - global $conf, $user; - - $now=dol_now(); + global $conf, $user, $langs; - $this->nbtodo=$this->nbtodolate=0; $clause = " WHERE"; $sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut,c.date_livraison as delivery_date"; @@ -2035,14 +2032,25 @@ class CommandeFournisseur extends CommonOrder $resql=$this->db->query($sql); if ($resql) { + $now=dol_now(); + + $response = new WorkboardResponse(); + $response->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24; + $response->label=$langs->trans("SuppliersOrdersToProcess"); + $response->url=DOL_URL_ROOT.'/fourn/commande/index.php'; + $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->fournisseur->warning_delay)) $this->nbtodolate++; + if ($obj->fk_statut != 3 && $this->db->jdate($date_to_test) < ($now - $conf->commande->fournisseur->warning_delay)) { + $response->nbtodolate++; + } } - return 1; + + return $response; } else { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 71e5c320dfa18ea24ba84ca6307c347546ee659f..d7252d188db55a7e294a413afa00855a9a32b093 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -1421,15 +1421,12 @@ class FactureFournisseur 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 WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { - global $conf, $user; + global $conf, $user, $langs; - $now=dol_now(); - - $this->nbtodo=$this->nbtodolate=0; $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1442,13 +1439,24 @@ class FactureFournisseur extends CommonInvoice $resql=$this->db->query($sql); if ($resql) { + $langs->load("bills"); + $now=dol_now(); + + $response = new WorkboardResponse(); + $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; + $response->label=$langs->trans("SupplierBillsToPay"); + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0'; + $response->img=img_object($langs->trans("Bills"),"bill"); + while ($obj=$this->db->fetch_object($resql)) { - $this->nbtodo++; - if (! empty($obj->datefin) && $this->db->jdate($obj->datefin) < ($now - $conf->facture->fournisseur->warning_delay)) $this->nbtodolate++; + $response->nbtodo++; + if (! empty($obj->datefin) && $this->db->jdate($obj->datefin) < ($now - $conf->facture->fournisseur->warning_delay)) { + $response->nbtodolate++; + } } $this->db->free($resql); - return 1; + return $response; } else { diff --git a/htdocs/index.php b/htdocs/index.php index 55252f6533fc4d404ad71e4d7fd29e489c3a6f0d..32b13c7a63f2eca970a3986306d443cef0afc0ac 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * * 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 @@ -291,7 +292,8 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; * Dolibarr Working Board with weather */ $showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0; -$rowspan=0; + +//Array that contains all WorkboardResponse classes to process them $dashboardlines=array(); print '<table class="noborder" width="100%">'."\n"; @@ -309,18 +311,14 @@ print '</tr>'."\n"; // Do not include sections without management permission // +require DOL_DOCUMENT_ROOT.'/core/class/WorkboardResponse.class.php'; + // Number of actions to do (late) if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $board=new ActionComm($db); - $board->load_board($user); - $board->warning_delay=$conf->actions->warning_delay/60/60/24; - $board->label=$langs->trans("ActionsToDo"); - $board->url=DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; - $board->img=img_object($langs->trans("Actions"),"action"); - $rowspan++; - $dashboardlines[]=$board; + $dashboardlines[] = $board->load_board($user); } // Number of customer orders a deal @@ -328,13 +326,8 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $board=new Commande($db); - $board->load_board($user); - $board->warning_delay=$conf->commande->client->warning_delay/60/60/24; - $board->label=$langs->trans("OrdersToProcess"); - $board->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3'; - $board->img=img_object($langs->trans("Orders"),"order"); - $rowspan++; - $dashboardlines[]=$board; + + $dashboardlines[] = $board->load_board($user); } // Number of suppliers orders a deal @@ -342,172 +335,91 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $board=new CommandeFournisseur($db); - $board->load_board($user); - $board->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24; - $board->label=$langs->trans("SuppliersOrdersToProcess"); - $board->url=DOL_URL_ROOT.'/fourn/commande/index.php'; - $board->img=img_object($langs->trans("Orders"),"order"); - $rowspan++; - $dashboardlines[]=$board; + + $dashboardlines[] = $board->load_board($user); } // Number of commercial proposals opened (expired) if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { - $langs->load("propal"); - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board=new Propal($db); - $board->load_board($user,"opened"); - $board->warning_delay=$conf->propal->cloture->warning_delay/60/60/24; - $board->label=$langs->trans("PropalsToClose"); - $board->url=DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1'; - $board->img=img_object($langs->trans("Propals"),"propal"); - $rowspan++; - $dashboardlines[]=$board; -} - -// Number of commercial proposals CLOSED signed (billed) -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) -{ - $langs->load("propal"); + $dashboardlines[] = $board->load_board($user,"opened"); - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $board=new Propal($db); - $board->load_board($user,"signed"); - $board->warning_delay=$conf->propal->facturation->warning_delay/60/60/24; - $board->label=$langs->trans("PropalsToBill"); - $board->url=DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=2'; - $board->img=img_object($langs->trans("Propals"),"propal"); - $rowspan++; - $dashboardlines[]=$board; + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of services enabled (delayed) if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $langs->load("contracts"); - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $board=new Contrat($db); - $board->load_board($user,"inactives"); - $board->warning_delay=$conf->contrat->services->inactifs->warning_delay/60/60/24; - $board->label=$langs->trans("BoardNotActivatedServices"); - $board->url=DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=0'; - $board->img=img_object($langs->trans("Contract"),"contract"); - $rowspan++; - $dashboardlines[]=$board; -} + $dashboardlines[] = $board->load_board($user,"inactives"); -// Number of active services (expired) -if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) -{ - $langs->load("contracts"); - - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $board=new Contrat($db); - $board->load_board($user,"expired"); - $board->warning_delay=$conf->contrat->services->expires->warning_delay/60/60/24; - $board->label=$langs->trans("BoardRunningServices"); - $board->url=DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired'; - $board->img=img_object($langs->trans("Contract"),"contract"); - $rowspan++; - $dashboardlines[]=$board; + // Number of active services (expired) + $dashboardlines[] = $board->load_board($user,"expired"); } // Number of invoices customers (has paid) if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { - $langs->load("bills"); - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $board=new Facture($db); - $board->load_board($user); - $board->warning_delay=$conf->facture->client->warning_delay/60/60/24; - $board->label=$langs->trans("CustomerBillsUnpaid"); - $board->url=DOL_URL_ROOT.'/compta/facture/impayees.php'; - $board->img=img_object($langs->trans("Bills"),"bill"); - $rowspan++; - $dashboardlines[]=$board; + $dashboardlines[] = $board->load_board($user); } // Number of supplier invoices (has paid) if (! empty($conf->fournisseur->enabled) && ! empty($conf->facture->enabled) && $user->rights->facture->lire) { - $langs->load("bills"); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $board=new FactureFournisseur($db); - $board->load_board($user); - $board->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; - $board->label=$langs->trans("SupplierBillsToPay"); - $board->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0'; - $board->img=img_object($langs->trans("Bills"),"bill"); - $rowspan++; - $dashboardlines[]=$board; + $dashboardlines[] = $board->load_board($user); } // Number of transactions to conciliate if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) { - $langs->load("banks"); - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $board=new Account($db); - $found=$board->load_board($user); - if ($found > 0) - { - $board->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; - $board->label=$langs->trans("TransactionsToConciliate"); - $board->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank'; - $board->img=img_object($langs->trans("TransactionsToConciliate"),"payment"); - $rowspan++; - $dashboardlines[]=$board; - } + $dashboardlines[] = $board->load_board($user); } // Number of cheque to send if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) { - $langs->load("banks"); - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $board=new RemiseCheque($db); - $board->load_board($user); - $board->warning_delay=$conf->bank->cheque->warning_delay/60/60/24; - $board->label=$langs->trans("BankChecksToReceipt"); - $board->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=accountancy'; - $board->img=img_object($langs->trans("BankChecksToReceipt"),"payment"); - $rowspan++; - $dashboardlines[]=$board; + $dashboardlines[] = $board->load_board($user); } // Number of foundation members if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id) { - $langs->load("members"); - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $board=new Adherent($db); - $board->load_board($user); - $board->warning_delay=$conf->adherent->cotisation->warning_delay/60/60/24; - $board->label=$langs->trans("MembersWithSubscriptionToReceive"); - $board->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1'; - $board->img=img_object($langs->trans("Members"),"user"); - $rowspan++; - $dashboardlines[]=$board; + $dashboardlines[] = $board->load_board($user); } // Calculate total nb of late $totallate=0; -foreach($dashboardlines as $key => $board) -{ - if ($board->nbtodolate > 0) $totallate+=$board->nbtodolate; -} - -// Show dashboard $var=true; -foreach($dashboardlines as $key => $board) + +//Remove any invalid response +//load_board can return an integer if failed or WorkboardResponse if OK +$valid_dashboardlines = array_filter($dashboardlines, function ($board) { + return $board instanceof WorkboardResponse; +}); + +$rowspan = count($valid_dashboardlines); + +foreach($valid_dashboardlines as $board) { + if ($board->nbtodolate > 0) { + $totallate += $board->nbtodolate; + } + + // Show dashboard + $var=!$var; print '<tr '.$bc[$var].'><td width="16">'.$board->img.'</td><td>'.$board->label.'</td>'; print '<td align="right"><a href="'.$board->url.'">'.$board->nbtodo.'</a></td>'; @@ -531,8 +443,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 '</td>'; $showweather=0; } diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 20450760127b54dd4fcbcd02e84034b9f6247c83..50d5ee27b550ddd8b389ad6a9d2654401eb252c5 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -175,7 +175,7 @@ if (! $error) } else { - $databasefortest='mssql'; + $databasefortest='master'; } } //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"]; @@ -486,7 +486,7 @@ if (! $error && $db->connected && $action == "set") } else if ($conf->db->type == 'mssql') { - $databasefortest='mssql'; + $databasefortest='master'; } // Creation handler de base, verification du support et connexion diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index f97f1afaa9c08b53550b240c9faf878bdda8fb93..1f6c5244d84a693abc3db1f074a03bbf587ffa08 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr> * * 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 @@ -192,6 +193,11 @@ if ($action == "set") { $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer); } + else if ($conf->db->type == 'mssql') + { + $buffer=preg_replace('/type=innodb/i','',$buffer); + $buffer=preg_replace('/ENGINE=innodb/i','',$buffer); + } // Replace the prefix tables if ($dolibarr_main_db_prefix != 'llx_') @@ -219,7 +225,7 @@ if ($action == "set") else { print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name); - print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer; + print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery; print "\n</td>"; print '<td><font class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</font></td></tr>'; $error++; diff --git a/htdocs/install/mssql/functions/functions.sql b/htdocs/install/mssql/functions/functions.sql deleted file mode 100644 index 1c2c76996dc312cc2440a2329d46530adb815d7c..0000000000000000000000000000000000000000 Binary files a/htdocs/install/mssql/functions/functions.sql and /dev/null differ diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index a6c0efc77a6dddeaee8f47e7702a0a283b5cdb11..9c83b70502ac0ceaf5d04e5e172db9282f070993 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -270,4 +270,4 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Monténégro',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (245,'BL','BLM','Saint-Barthélemy',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (246,'MF','MAF','Saint-Martin',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (247,'BU', null, 'Burundi',1,0); + diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 4415f5711bf0405be8fd762e547dd7833f688754..e16643843233110d1ba92b0b82999a5842ad3956 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -270,5 +270,3 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) v INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 12, 1215, '', 0, 'Laâyoune-Boujdour-Sakia el Hamra', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 12, 1216, '', 0, 'Oued Ed-Dahab Lagouira', 1); --- Regions Tunisia (id country=10) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 10, 1001, '', 0, 'Algerie', 1); diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index e3f7e56cdc641cab2c1eddb0db3d134ddc64296c..7b42efdae0ee3797f833e17341473a602e6683eb 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -187,8 +187,8 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (17 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1734, 173, '0','0','VAT Rate 0', 1); -- PERU (id country=181) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1841, 181, '18','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1843, 181, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1811, 181, '18','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1812, 181, '0','0','VAT Rate 0',1); -- POLAND (id country=184) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1841, 184, '20','0','VAT standard rate',1); diff --git a/htdocs/install/mysql/tables/llx_c_regions.sql b/htdocs/install/mysql/tables/llx_c_regions.sql index 9c677ee44f7ad9ea3e89346b50c6dc220b3786e2..768a234dbbdd1e6b8347df9d7b395eea88aa878e 100644 --- a/htdocs/install/mysql/tables/llx_c_regions.sql +++ b/htdocs/install/mysql/tables/llx_c_regions.sql @@ -24,7 +24,7 @@ create table llx_c_regions fk_pays integer NOT NULL, cheflieu varchar(50), tncc integer, - nom varchar(50), + nom varchar(100), active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_rights_def.sql b/htdocs/install/mysql/tables/llx_rights_def.sql index 8bf85add1249599bb5c83959c79649a0299dc0cf..297772730c75832312639df3077a19395fbcf706 100644 --- a/htdocs/install/mysql/tables/llx_rights_def.sql +++ b/htdocs/install/mysql/tables/llx_rights_def.sql @@ -19,7 +19,7 @@ create table llx_rights_def ( - id integer, + id integer NOT NULL, libelle varchar(255), module varchar(64), entity integer DEFAULT 1 NOT NULL,