From 1b35380dda4b47606d4ee8172c4152770af65a63 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 4 May 2020 14:55:24 +0200 Subject: [PATCH 1/3] NEW stats invoice graph with 3 bars --- htdocs/compta/facture/stats/index.php | 4 ++-- htdocs/core/class/dolgraph.class.php | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index f5472196cc2..1a771c8e60b 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -58,8 +58,8 @@ if ($user->socid > 0) $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; -//$startyear=$year-2; -$startyear = $year - 1; +if(!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear=$year-2; +else $startyear=$year-1; $endyear = $year; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8af46154223..3f1bfa245fb 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -894,7 +894,15 @@ class DolGraph if ($i > $firstlot) $this->stringtoshow .= ', '."\n"; $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; - if (!isset($this->type[$i]) || $this->type[$i] == 'bars') $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.($i == $firstlot ? 'center' : 'left').'", barWidth: 0.5 }, '; + if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { + if($nblot == 3) { + if($i == $firstlot) $align = 'right'; + else if($i == $firstlot+1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + } + else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; + } if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: '.($this->type[$i] == 'linesnopoint' ? 'false' : 'true').' }, '; $this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $i++; From eab69c3a598e7d826ce1fbf31b8402ad0063d8b3 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 4 May 2020 15:19:45 +0200 Subject: [PATCH 2/3] NEW multiselect categorie client stats facturation --- htdocs/compta/facture/stats/index.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 1a771c8e60b..4c0d23c90e2 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; +if(!empty($conf->category->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); @@ -49,6 +50,7 @@ $categ_id = GETPOST('categ_id', 'categ_id'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); +$custcats = GETPOST('custcats', 'array'); // Security check if ($user->socid > 0) { @@ -66,7 +68,7 @@ $endyear = $year; /* * View */ - +if(!empty($conf->category->enabled)) $langs->load('categories'); $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); @@ -93,6 +95,10 @@ $stats = new FactureStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typ if ($mode == 'customer') { if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; + if (is_array($custcats) && !empty($custcats)) { + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; + $stats->where .= ' AND cat.fk_categorie IN ('.implode(',', $custcats).')'; + } } if ($mode == 'supplier') { @@ -256,6 +262,13 @@ if ($mode == 'customer') $filter = 's.client in (1,2,3)'; if ($mode == 'supplier') $filter = 's.fournisseur = 1'; print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); print ''; +if(!empty($conf->category->enabled) && $mode == 'customer') { + // Customer Category + print ''.$langs->trans("CustomersProspectsCategoriesShort").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); + print ''; + } // ThirdParty Type print ''.$langs->trans("ThirdPartyType").''; $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. From b6aa766c72078988a0e74d8b5305b96eb9d6d509 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 6 May 2020 09:37:17 +0200 Subject: [PATCH 3/3] FIX stickler --- htdocs/compta/facture/stats/index.php | 14 +++++++------- htdocs/core/class/dolgraph.class.php | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 4c0d23c90e2..8606e619740 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -262,13 +262,13 @@ if ($mode == 'customer') $filter = 's.client in (1,2,3)'; if ($mode == 'supplier') $filter = 's.fournisseur = 1'; print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); print ''; -if(!empty($conf->category->enabled) && $mode == 'customer') { - // Customer Category - print ''.$langs->trans("CustomersProspectsCategoriesShort").''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); - print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); - print ''; - } +if(! empty($conf->category->enabled) && $mode == 'customer') { + // Customer Category + print ''.$langs->trans("CustomersProspectsCategoriesShort").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); + print ''; +} // ThirdParty Type print ''.$langs->trans("ThirdPartyType").''; $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 3f1bfa245fb..551fe2b82c0 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -895,11 +895,11 @@ class DolGraph $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { - if($nblot == 3) { - if($i == $firstlot) $align = 'right'; - else if($i == $firstlot+1) $align = 'center'; - else $align = 'left'; - $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + if($nblot == 3) { + if($i == $firstlot) $align = 'right'; + elseif($i == $firstlot + 1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; }