Fix filter on date on statistics of products
This commit is contained in:
parent
5943e784ec
commit
47dfe633f9
@ -3188,7 +3188,7 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($year)) {
|
if (empty($year) || $year == -1) {
|
||||||
$year = strftime('%Y', time());
|
$year = strftime('%Y', time());
|
||||||
$month = strftime('%m', 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 = '')
|
public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf, $user;
|
||||||
global $user;
|
|
||||||
|
|
||||||
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
|
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
|
||||||
if ($mode == 'bynumber') {
|
if ($mode == 'bynumber') {
|
||||||
|
|||||||
@ -208,14 +208,14 @@ if ($result || empty($id))
|
|||||||
// Year
|
// Year
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>';
|
print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>';
|
||||||
$arrayyears = array();
|
$arrayyears = array();
|
||||||
for ($year = $currentyear - 10; $year < $currentyear + 10; $year++)
|
for ($year = $currentyear - 25; $year < $currentyear; $year++)
|
||||||
{
|
{
|
||||||
$arrayyears[$year] = $year;
|
$arrayyears[$year] = $year;
|
||||||
}
|
}
|
||||||
if (!in_array($year, $arrayyears)) $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);
|
arsort($arrayyears);
|
||||||
print $form->selectarray('search_year', $arrayyears, $search_year, 0);
|
print $form->selectarray('search_year', $arrayyears, $search_year, 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<div class="center"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></div>';
|
print '<div class="center"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></div>';
|
||||||
@ -262,49 +262,49 @@ if ($result || empty($id))
|
|||||||
|
|
||||||
if ($conf->propal->enabled) {
|
if ($conf->propal->enabled) {
|
||||||
$graphfiles['propal'] = array('modulepart'=>'productstats_proposals',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->supplier_proposal->enabled) {
|
if ($conf->supplier_proposal->enabled) {
|
||||||
$graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->order->enabled) {
|
if ($conf->order->enabled) {
|
||||||
$graphfiles['orders'] = array('modulepart'=>'productstats_orders',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->supplier_order->enabled) {
|
if ($conf->supplier_order->enabled) {
|
||||||
$graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->facture->enabled) {
|
if ($conf->facture->enabled) {
|
||||||
$graphfiles['invoices'] = array('modulepart'=>'productstats_invoices',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->supplier_invoice->enabled) {
|
if ($conf->supplier_invoice->enabled) {
|
||||||
$graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->contrat->enabled) {
|
if ($conf->contrat->enabled) {
|
||||||
$graphfiles['contracts'] = array('modulepart'=>'productstats_contracts',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->mrp->enabled) {
|
if ($conf->mrp->enabled) {
|
||||||
$graphfiles['mrp'] = array('modulepart'=>'productstats_mrp',
|
$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")));
|
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user