From d51c22a012fb4c55751c96b0247e6a1cab371ec5 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 21 Sep 2017 17:28:00 +0200 Subject: [PATCH 1/9] NEW : customizable meteo in value or percentage --- htdocs/admin/delais.php | 239 ++++++++++++++++++++++++++++++++-------- 1 file changed, 196 insertions(+), 43 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index d3ef125f2a7..0b6690cd051 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -136,8 +136,18 @@ if ($action == 'update') } } } - - dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity); + + dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity); + + // For update value with percentage + $plus=''; + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; + // Update values + for($i=0;$i<4;$i++) { + if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity); + } + } @@ -196,13 +206,6 @@ if ($action == 'edit') print ''.$langs->trans("MAIN_DISABLE_METEO").'' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . ''; print ''; - - print '
'; - - print '
'; - print '
'; - - print ''; } else { @@ -244,17 +247,20 @@ else print ''; - print '
'; - - // Boutons d'action - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - } -print '
'; +print '
'; +if($action == 'edit') { + + $str = $langs->trans('StdMod'); + $str = $langs->trans('PercentageMod'); + print ''.$str.''; + print ''; + + print '

'; + +} // Show logo for weather print $langs->trans("DescWeather").'
'; @@ -268,35 +274,182 @@ $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; $text=''; $options='height="60px"'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +if($action == 'edit') { + + + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; + + print '
'; -print img_weather($text,'weather-clear.png',$options); -print '= '.$level0.'         '; -print img_weather($text,'weather-few-clouds.png',$options); -print '<= '.$level1.'         '; -print img_weather($text,'weather-clouds.png',$options); -print '<= '.$level2.'
'; -print img_weather($text,'weather-many-clouds.png',$options); -print '<= '.$level3.'         '; -print img_weather($text,'weather-storm.png',$options); -print '> '.$level3.'                        
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + /*print '';*/ + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '=         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<=         '; + print img_weather($text,'weather-clouds.png',$options); + print '<=
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<=         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + print ''; + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + /*print '';*/ + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '=  %         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<=  %         '; + print img_weather($text,'weather-clouds.png',$options); + print '<=  %
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<=  %         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + print '
'; + +} else { + + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %         '; + print img_weather($text,'weather-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %                        
'; + + } else { + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print img_weather($text,'weather-clear.png',$options); + print '= '.$level0.'         '; + print img_weather($text,'weather-few-clouds.png',$options); + print '<= '.$level1.'         '; + print img_weather($text,'weather-clouds.png',$options); + print '<= '.$level2.'
'; + print img_weather($text,'weather-many-clouds.png',$options); + print '<= '.$level3.'         '; + print img_weather($text,'weather-storm.png',$options); + print '> '.$level3.'                        
'; + + } +} +print ''; + +if($action == 'edit') { + + print '
'; + print '
'; + +} else { + + // Boutons d'action + print '
'; + print ''.$langs->trans("Modify").'
'; + +} -print ''; +?> + + +close(); From 6fa1929d5c66d39a00896ff75f8c2847bac64f20 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 12:26:15 +0200 Subject: [PATCH 2/9] NEW : change description on click --- htdocs/admin/delais.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 0b6690cd051..2ac922a6a0a 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -251,20 +251,26 @@ else print '
'; +// Show logo for weather +print $langs->trans("DescWeather").'
'; + if($action == 'edit') { - $str = $langs->trans('StdMod'); - $str = $langs->trans('PercentageMod'); - print ''.$str.''; + $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod')); + $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod')); + if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; + else $str_mode_enabled = $str_mode_percentage; + print ''.$str_mode_enabled.''; print ''; print '

'; - + +} else { + if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); + else print $langs->trans('MeteoPercentageModEnabled'); + print '

'; } -// Show logo for weather -print $langs->trans("DescWeather").'
'; - $offset=0; $cursor=10; // By default //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; @@ -432,16 +438,20 @@ if($action == 'edit') { $(document).ready(function() { $("#change_mode").click(function() { - use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE"); - + var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE"); + var str_mode_std = ""; + var str_mode_percentage = ""; + if(use_percent.val() == 1) { use_percent.val(0); $("#standard").show(); $("#percentage").hide(); + $(this).html(str_mode_std); } else { use_percent.val(1); $("#standard").hide(); $("#percentage").show(); + $(this).html(str_mode_percentage); } }); From 3db52aed78e02ab8d6fb841111ab9403faae5aa1 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 17:13:50 +0200 Subject: [PATCH 3/9] NEW : calcul percentage ok --- htdocs/admin/delais.php | 61 ++++++++++----------- htdocs/index.php | 114 ++++++++++++++++++++++++++++++++-------- 2 files changed, 122 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 2ac922a6a0a..0d9e80f5326 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -350,6 +350,36 @@ if($action == 'edit') { print ''; + ?> + + + + global->MAIN_USE_METEO_WITH_PERCENTAGE)) { @@ -416,6 +446,7 @@ if($action == 'edit') { } } + print ''; if($action == 'edit') { @@ -431,35 +462,5 @@ if($action == 'edit') { } -?> - - - -close(); diff --git a/htdocs/index.php b/htdocs/index.php index 597d41423e5..c2b77d24222 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -384,7 +384,12 @@ if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $board=new Project($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['projects']; + } + $dashboardlines[] = $wb_res; } // Number of tasks to do (late) @@ -400,9 +405,17 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board=new Propal($db); - $dashboardlines[] = $board->load_board($user,"opened"); + $wb_res = $board->load_board($user,"opened"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['proposals']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[] = $board->load_board($user,"signed"); + $wb_res = $board->load_board($user,"signed"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of commercial proposals opened (expired) @@ -410,9 +423,17 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos { include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; $board=new SupplierProposal($db); - $dashboardlines[] = $board->load_board($user,"opened"); + $wb_res = $board->load_board($user,"opened"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['askprice']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; // Number of commercial proposals CLOSED signed (billed) - $dashboardlines[] = $board->load_board($user,"signed"); + $wb_res = $board->load_board($user,"signed"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of customer orders a deal @@ -420,7 +441,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $board=new Commande($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['orders']; + } + $dashboardlines[] = $wb_res; } // Number of suppliers orders a deal @@ -428,7 +454,12 @@ if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->comma { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $board=new CommandeFournisseur($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['supplier_orders']; + } + $dashboardlines[] = $wb_res; } // Number of services enabled (delayed) @@ -436,16 +467,29 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $board=new Contrat($db); - $dashboardlines[] = $board->load_board($user,"inactives"); - // Number of active services (expired) - $dashboardlines[] = $board->load_board($user,"expired"); + $wb_res = $board->load_board($user,"inactives"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $nbtotal = (int)$board->nb['Contracts']; + $wb_res->nbtotal = $nbtotal; + } + $dashboardlines[] = $wb_res; + // Number of active services (expired) + $wb_res = $board->load_board($user,"expired"); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; + $dashboardlines[] = $wb_res; } // Number of invoices customers (has paid) if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $board=new Facture($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['invoices']; + } + $dashboardlines[] = $wb_res; } // Number of supplier invoices (has paid) @@ -453,7 +497,12 @@ if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fourniss { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $board=new FactureFournisseur($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['supplier_invoices']; + } + $dashboardlines[] = $wb_res; } // Number of transactions to conciliate @@ -481,7 +530,12 @@ if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $use { include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $board=new Adherent($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['members']; + } + $dashboardlines[] = $wb_res; } // Number of expense reports to approve @@ -489,7 +543,12 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->appr { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'toapprove'); + $wb_res = $board->load_board($user,'toapprove'); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['expensereports']; + } + $dashboardlines[] = $wb_res; } // Number of expense reports to pay @@ -497,11 +556,16 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'topay'); + $wb_res = $board->load_board($user,'topay'); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['expensereports']; + } + $dashboardlines[] = $wb_res; } // Calculate total nb of late -$totallate=0; +$totallate=$totalglobal=0; $var=true; //Remove any invalid response @@ -516,11 +580,13 @@ foreach($dashboardlines as $tmp) foreach($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totalglobal += $board->nbtotal; $totallate += $board->nbtodolate; } } - - +//var_dump($totallate, $totalglobal); +if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = $totallate / $totalglobal * 100; +//var_dump($totallate); $boxwork=''; $boxwork.='
'; $boxwork.=''."\n"; @@ -686,15 +752,17 @@ $db->close(); function showWeather($totallate,$text,$options) { global $conf; - + $out=''; $offset=0; $factor=10; // By default - $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; - $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; - $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; - $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; + $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL'; + + $level0=$offset; if (! empty($conf->global->{$used_conf.'0'})) $level0=$conf->global->{$used_conf.'0'}; + $level1=$offset+1*$factor; if (! empty($conf->global->{$used_conf.'1'})) $level1=$conf->global->{$used_conf.'1'}; + $level2=$offset+2*$factor; if (! empty($conf->global->{$used_conf.'2'})) $level2=$conf->global->{$used_conf.'2'}; + $level3=$offset+3*$factor; if (! empty($conf->global->{$used_conf.'3'})) $level3=$conf->global->{$used_conf.'3'}; if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); From 3cec3085862e911bfd7dbb824d3998cbfe4a4a3b Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 25 Sep 2017 17:19:56 +0200 Subject: [PATCH 4/9] NEW : langs --- htdocs/langs/en_US/admin.lang | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1e855abc41a..a7a0c6f645f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1089,6 +1089,11 @@ ShowProfIdInAddress=Show professionnal id with addresses on documents ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents TranslationUncomplete=Partial translation MAIN_DISABLE_METEO=Disable meteo view +MeteoStdMod=Standard mode +MeteoStdModEnabled=Standard mode enabled +MeteoPercentageMod=Percentage mode +MeteoPercentageModEnabled=Percentage mode enabled +MeteoUseMod=Click to use %s TestLoginToAPI=Test login to API ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it. ExternalAccess=External access From 7f938bc517f1ae1e3766f5c68e6519ce6c71fd6d Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 12:32:58 +0200 Subject: [PATCH 5/9] NEW : unexistant function load_state_board() on several objects --- htdocs/comm/action/class/actioncomm.class.php | 132 +++++++++----- htdocs/compta/bank/class/account.class.php | 128 ++++++++----- .../cheque/class/remisecheque.class.php | 65 +++++-- htdocs/index.php | 29 ++- htdocs/projet/class/task.class.php | 171 +++++++++++------- 5 files changed, 356 insertions(+), 169 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ec1c84dd652..ff5b2aca769 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -907,7 +907,7 @@ class ActionComm extends CommonObject return $db->lasterror(); } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -916,50 +916,92 @@ class ActionComm extends CommonObject */ function load_board($user) { - global $conf, $langs; - - $sql = "SELECT a.id, a.datep as dp"; - $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= ")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; - $sql.= " AND a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; - if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - - $resql=$this->db->query($sql); - if ($resql) - { - $agenda_static = new ActionComm($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay/60/60/24; - $response->label = $langs->trans("ActionsToDo"); - $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; - $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); - - // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - - $agenda_static->datep = $this->db->jdate($obj->dp); - - if ($agenda_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + $sql = "SELECT a.id, a.datep as dp"; + $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= ")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; + $sql.= " AND a.entity IN (".getEntity('agenda').")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; + if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $agenda_static = new ActionComm($this->db); + + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay/60/60/24; + $response->label = $langs->trans("ActionsToDo"); + $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; + $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + + $agenda_static->datep = $this->db->jdate($obj->dp); + + if ($agenda_static->hasDelay()) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + $this->nb=array(); + + $sql = "SELECT count(a.id) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= ")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; + if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $agenda_static = new ActionComm($this->db); + + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["actionscomm"]=$obj->nb; + } + + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cb59862e005..4de089f767b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1151,7 +1151,7 @@ class Account extends CommonObject return $solde; } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1161,50 +1161,88 @@ class Account extends CommonObject */ function load_board(User $user, $filteraccountid = 0) { - global $conf, $langs; - - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - - $sql = "SELECT b.rowid, b.datev as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.rappro=0"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; - - $resql=$this->db->query($sql); - if ($resql) - { - $langs->load("banks"); - $now=dol_now(); - - require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; - - $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('',"payment"); - - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT b.rowid, b.datev as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.rappro=0"; + $sql.= " AND b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql.= " AND clos = 0"; + if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + + $resql=$this->db->query($sql); + if ($resql) + { + $langs->load("banks"); + $now=dol_now(); + + require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; + + $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('',"payment"); + + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board($filteraccountid = 0) + { + global $user; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT count(b.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql.= " AND clos = 0"; + if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["banklines"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 808d2cbb00b..8f5f51f36e9 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -478,20 +478,20 @@ class RemiseCheque extends CommonObject return ""; } } - - + + /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { global $conf, $langs; - + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - + $sql = "SELECT b.rowid, b.datev as datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; @@ -500,28 +500,28 @@ class RemiseCheque extends CommonObject $sql.= " AND b.fk_type = 'CHQ'"; $sql.= " AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; - + $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=bank'; $response->img=img_object('',"payment"); - + while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) { $response->nbtodolate++; } } - + return $response; } else @@ -531,6 +531,45 @@ class RemiseCheque extends CommonObject return -1; } } + + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $sql = "SELECT count(b.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE b.fk_account = ba.rowid"; + $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql.= " AND b.fk_type = 'CHQ'"; + $sql.= " AND b.amount > 0"; + + $resql=$this->db->query($sql); + if ($resql) + { + + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["cheques"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } /** diff --git a/htdocs/index.php b/htdocs/index.php index c2b77d24222..9298e9c411f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -375,8 +375,12 @@ 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); - - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['actionscomm']; + } + $dashboardlines[] = $wb_res; } // Number of project opened @@ -397,7 +401,12 @@ if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) { include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $board=new Task($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['tasks']; + } + $dashboardlines[] = $wb_res; } // Number of commercial proposals opened (expired) @@ -513,7 +522,12 @@ if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->s $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate if ($nb > 0) { - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['banklines']; + } + $dashboardlines[] = $wb_res; } } @@ -522,7 +536,12 @@ if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->s { include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $board=new RemiseCheque($db); - $dashboardlines[] = $board->load_board($user); + $wb_res = $board->load_board($user); + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $board->load_state_board(); + $wb_res->nbtotal = (int)$board->nb['cheques']; + } + $dashboardlines[] = $wb_res; } // Number of foundation members diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 10a78e017c8..32ae678b016 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1693,8 +1693,8 @@ class Task extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - - + + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1703,65 +1703,114 @@ class Task extends CommonObject */ function load_board($user) { - global $conf, $langs; - - $mine=0; $socid=$user->societe_id; - - $projectstatic = new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - - // List of tasks (does not care about permissions. Filtering will be done later) - $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; - $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; - // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - //print $sql; - $resql=$this->db->query($sql); - if ($resql) - { - $task_static = new Task($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; - $response->label = $langs->trans("OpenedTasks"); - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; - else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; - $response->img = img_object('',"task"); - - // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) - { - $response->nbtodo++; - - $task_static->projectstatus = $obj->projectstatus; - $task_static->progress = $obj->progress; - $task_static->fk_statut = $obj->status; - $task_static->date_end = $this->db->jdate($obj->datee); - - if ($task_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } + global $conf, $langs; + + $mine=0; $socid=$user->societe_id; + + $projectstatic = new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); + + // List of tasks (does not care about permissions. Filtering will be done later) + $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; + $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; + $sql.= " t.dateo as date_start, t.datee as datee"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND p.fk_statut = 1"; + $sql.= " AND t.fk_projet = p.rowid"; + $sql.= " AND t.progress < 100"; // tasks to do + if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + //print $sql; + $resql=$this->db->query($sql); + if ($resql) + { + $task_static = new Task($this->db); + + $response = new WorkboardResponse(); + $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; + $response->label = $langs->trans("OpenedTasks"); + if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; + else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; + $response->img = img_object('',"task"); + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $response->nbtodo++; + + $task_static->projectstatus = $obj->projectstatus; + $task_static->progress = $obj->progress; + $task_static->fk_statut = $obj->status; + $task_static->date_end = $this->db->jdate($obj->datee); + + if ($task_static->hasDelay()) { + $response->nbtodolate++; + } + } + + return $response; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $user; + + $mine=0; $socid=$user->societe_id; + + $projectstatic = new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); + + // List of tasks (does not care about permissions. Filtering will be done later) + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND t.fk_projet = p.rowid"; // tasks to do + if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + $resql=$this->db->query($sql); + if ($resql) + { + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["tasks"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } } /** From 8de9c5cd36d454eeb71e1fda311e010b9c8d5b03 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 14:18:26 +0200 Subject: [PATCH 6/9] FIX : forgotten php doc on function parameter --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4de089f767b..2eedf341178 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1209,7 +1209,7 @@ class Account extends CommonObject /** * Charge indicateurs this->nb de tableau de bord - * + * @param int id of bank acount for filter * @return int <0 if ko, >0 if ok */ function load_state_board($filteraccountid = 0) From d270a8e0093aeae5b57613b58445fc1c4ebb077c Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Sep 2017 16:09:40 +0200 Subject: [PATCH 7/9] FIX : same than precedent commit --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 2eedf341178..53e84b036d4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1209,7 +1209,7 @@ class Account extends CommonObject /** * Charge indicateurs this->nb de tableau de bord - * @param int id of bank acount for filter + * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ function load_state_board($filteraccountid = 0) From 1694737e0bc37d676da556d5ea848a7ca7a1a370 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Sep 2017 10:09:21 +0200 Subject: [PATCH 8/9] NEW : new param on load_board() function in ActionComm class to avoid duplicate code --- htdocs/comm/action/class/actioncomm.class.php | 87 ++++++------------- htdocs/index.php | 2 +- 2 files changed, 27 insertions(+), 62 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ff5b2aca769..12c11f863f1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -911,19 +911,25 @@ class ActionComm extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Objet user + * @param User $user Objet user + * @param int $load_state_board Charge indicateurs this->nb de tableau de bord * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + function load_board($user, $load_state_board=0) { global $conf, $langs; - $sql = "SELECT a.id, a.datep as dp"; + if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; + else { + $this->nb=array(); + $sql = "SELECT count(a.id) as nb"; + } $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; + $sql.= " WHERE 1"; + if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; @@ -932,69 +938,28 @@ class ActionComm extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $agenda_static = new ActionComm($this->db); - - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay/60/60/24; - $response->label = $langs->trans("ActionsToDo"); - $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; - $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); - + if(empty($load_state_board)) { + $agenda_static = new ActionComm($this->db); + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay/60/60/24; + $response->label = $langs->trans("ActionsToDo"); + $response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; + $response->img = img_object('',"action",'class="inline-block valigntextmiddle"'); + } // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { - $response->nbtodo++; - - $agenda_static->datep = $this->db->jdate($obj->dp); - - if ($agenda_static->hasDelay()) { - $response->nbtodolate++; - } - } - - return $response; - } - else - { - $this->error=$this->db->error(); - return -1; - } - } - - /** - * Charge indicateurs this->nb de tableau de bord - * - * @return int <0 if ko, >0 if ok - */ - function load_state_board() - { - global $user; - - $this->nb=array(); - - $sql = "SELECT count(a.id) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= ")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; - if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - - $resql=$this->db->query($sql); - if ($resql) - { - $agenda_static = new ActionComm($this->db); - - while ($obj=$this->db->fetch_object($resql)) - { - $this->nb["actionscomm"]=$obj->nb; + if(empty($load_state_board)) { + $response->nbtodo++; + $agenda_static->datep = $this->db->jdate($obj->dp); + if ($agenda_static->hasDelay()) $response->nbtodolate++; + } else $this->nb["actionscomm"]=$obj->nb; } $this->db->free($resql); - return 1; + if(empty($load_state_board)) return $response; + else return 1; } else { diff --git a/htdocs/index.php b/htdocs/index.php index 9298e9c411f..1d5f9c5350b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -377,7 +377,7 @@ if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) $board=new ActionComm($db); $wb_res = $board->load_board($user); if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); + $board->load_board($user, 1); $wb_res->nbtotal = (int)$board->nb['actionscomm']; } $dashboardlines[] = $wb_res; From 4084da28d19e0134089cd21e5106f7e6382987ef Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Sep 2017 15:21:36 +0200 Subject: [PATCH 9/9] FIX : revert wrong code --- htdocs/index.php | 205 ++++++++++++++--------------------------------- 1 file changed, 61 insertions(+), 144 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 1d5f9c5350b..f8e90919c6a 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -373,218 +373,135 @@ 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); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_board($user, 1); - $wb_res->nbtotal = (int)$board->nb['actionscomm']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $board=new ActionComm($db); + + $dashboardlines[] = $board->load_board($user); } // Number of project opened if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $board=new Project($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['projects']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $board=new Project($db); + $dashboardlines[] = $board->load_board($user); } // Number of tasks to do (late) if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $board=new Task($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['tasks']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + $board=new Task($db); + $dashboardlines[] = $board->load_board($user); } // Number of commercial proposals opened (expired) if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $board=new Propal($db); - $wb_res = $board->load_board($user,"opened"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['proposals']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of commercial proposals CLOSED signed (billed) - $wb_res = $board->load_board($user,"signed"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $board=new Propal($db); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of commercial proposals opened (expired) if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $board=new SupplierProposal($db); - $wb_res = $board->load_board($user,"opened"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['askprice']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of commercial proposals CLOSED signed (billed) - $wb_res = $board->load_board($user,"signed"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; + $board=new SupplierProposal($db); + $dashboardlines[] = $board->load_board($user,"opened"); + // Number of commercial proposals CLOSED signed (billed) + $dashboardlines[] = $board->load_board($user,"signed"); } // Number of customer orders a deal if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $board=new Commande($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['orders']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $board=new Commande($db); + $dashboardlines[] = $board->load_board($user); } // Number of suppliers orders a deal if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $board=new CommandeFournisseur($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['supplier_orders']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $board=new CommandeFournisseur($db); + $dashboardlines[] = $board->load_board($user); } // Number of services enabled (delayed) if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $board=new Contrat($db); - $wb_res = $board->load_board($user,"inactives"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $nbtotal = (int)$board->nb['Contracts']; - $wb_res->nbtotal = $nbtotal; - } - $dashboardlines[] = $wb_res; - // Number of active services (expired) - $wb_res = $board->load_board($user,"expired"); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $wb_res->nbtotal = $nbtotal; - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + $board=new Contrat($db); + $dashboardlines[] = $board->load_board($user,"inactives"); + // 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) { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $board=new Facture($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['invoices']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $board=new Facture($db); + $dashboardlines[] = $board->load_board($user); } // Number of supplier invoices (has paid) if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fournisseur->facture->lire)) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $board=new FactureFournisseur($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['supplier_invoices']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $board=new FactureFournisseur($db); + $dashboardlines[] = $board->load_board($user); } // Number of transactions to conciliate if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) { - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $board=new Account($db); - $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate - if ($nb > 0) - { - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['banklines']; - } - $dashboardlines[] = $wb_res; - } + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $board=new Account($db); + $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate + if ($nb > 0) + { + $dashboardlines[] = $board->load_board($user); + } } // Number of cheque to send if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $board=new RemiseCheque($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['cheques']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; + $board=new RemiseCheque($db); + $dashboardlines[] = $board->load_board($user); } // Number of foundation members if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id) { - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $board=new Adherent($db); - $wb_res = $board->load_board($user); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['members']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $board=new Adherent($db); + $dashboardlines[] = $board->load_board($user); } // Number of expense reports to approve if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $board=new ExpenseReport($db); - $wb_res = $board->load_board($user,'toapprove'); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['expensereports']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $board=new ExpenseReport($db); + $dashboardlines[] = $board->load_board($user,'toapprove'); } // Number of expense reports to pay if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $board=new ExpenseReport($db); - $wb_res = $board->load_board($user,'topay'); - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $board->load_state_board(); - $wb_res->nbtotal = (int)$board->nb['expensereports']; - } - $dashboardlines[] = $wb_res; + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $board=new ExpenseReport($db); + $dashboardlines[] = $board->load_board($user,'topay'); } // Calculate total nb of late -$totallate=$totalglobal=0; +$totallate=$totaltodo=0; $var=true; //Remove any invalid response @@ -599,12 +516,12 @@ foreach($dashboardlines as $tmp) foreach($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totalglobal += $board->nbtotal; + if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totaltodo += $board->nbtodo; $totallate += $board->nbtodolate; } } -//var_dump($totallate, $totalglobal); -if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = $totallate / $totalglobal * 100; +//var_dump($totallate, $totaltodo); +if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = round($totallate / $totaltodo * 100, 2); //var_dump($totallate); $boxwork=''; $boxwork.='
'; @@ -618,7 +535,7 @@ if ($showweather) $boxwork.='
'; $boxwork.='
'; $text=''; - if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; + if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; $text.='. '.$langs->trans("LateDesc"); //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); $options='height="64px"';