diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 99590e27a36..ba63afdab44 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3188,7 +3188,7 @@ class Product extends CommonObject
return -1;
}
- if (empty($year)) {
+ if (empty($year) || $year == -1) {
$year = strftime('%Y', time());
$month = strftime('%m', time());
}
@@ -3339,8 +3339,7 @@ class Product extends CommonObject
public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
{
// phpcs:enable
- global $conf;
- global $user;
+ global $conf, $user;
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
if ($mode == 'bynumber') {
diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php
index 4600baa1597..6c6d2b80cf8 100644
--- a/htdocs/product/stats/card.php
+++ b/htdocs/product/stats/card.php
@@ -208,14 +208,14 @@ if ($result || empty($id))
// Year
print '
| '.$langs->trans("Year").' | ';
$arrayyears = array();
- for ($year = $currentyear - 10; $year < $currentyear + 10; $year++)
+ for ($year = $currentyear - 25; $year < $currentyear; $year++)
{
$arrayyears[$year] = $year;
}
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
- if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
+ if (!in_array($currentyear, $arrayyears)) $arrayyears[$currentyear] = $currentyear;
arsort($arrayyears);
- print $form->selectarray('search_year', $arrayyears, $search_year, 0);
+ print $form->selectarray('search_year', $arrayyears, $search_year, 1);
print ' |
';
print '';
print '';
@@ -262,49 +262,49 @@ if ($result || empty($id))
if ($conf->propal->enabled) {
$graphfiles['propal'] = array('modulepart'=>'productstats_proposals',
- 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals")));
}
if ($conf->supplier_proposal->enabled) {
$graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers',
- 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals")));
}
if ($conf->order->enabled) {
$graphfiles['orders'] = array('modulepart'=>'productstats_orders',
- 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders")));
}
if ($conf->supplier_order->enabled) {
$graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers',
- 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders")));
}
if ($conf->facture->enabled) {
$graphfiles['invoices'] = array('modulepart'=>'productstats_invoices',
- 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices")));
}
if ($conf->supplier_invoice->enabled) {
$graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers',
- 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices")));
}
if ($conf->contrat->enabled) {
$graphfiles['contracts'] = array('modulepart'=>'productstats_contracts',
- 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts")));
}
if ($conf->mrp->enabled) {
$graphfiles['mrp'] = array('modulepart'=>'productstats_mrp',
- 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
+ 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos")));
}