NEW Add statistics by amount on statistics of products.
This commit is contained in:
parent
dc464d09f6
commit
db9498262b
@ -187,23 +187,12 @@ AuthenticationDoesNotAllowSendNewPassword=Authentication mode is <b>%s</b>.<br>I
|
||||
EnableGDLibraryDesc=Install or enable GD library on your PHP installation to use this option.
|
||||
ProfIdShortDesc=<b>Prof Id %s</b> is an information depending on third party country.<br>For example, for country <b>%s</b>, it's code <b>%s</b>.
|
||||
DolibarrDemo=Dolibarr ERP/CRM demo
|
||||
StatsByAmount=Statistics on amount of products/services
|
||||
StatsByNumberOfUnits=Statistics for sum of qty of products/services
|
||||
StatsByNumberOfEntities=Statistics for number of referring entities (no. of invoices, or orders...)
|
||||
NumberOfProposals=Number of proposals
|
||||
NumberOfCustomerOrders=Number of sales orders
|
||||
NumberOfCustomerInvoices=Number of customer invoices
|
||||
NumberOfSupplierProposals=Number of vendor proposals
|
||||
NumberOfSupplierOrders=Number of purchase orders
|
||||
NumberOfSupplierInvoices=Number of vendor invoices
|
||||
NumberOfContracts=Number of contracts
|
||||
NumberOfMos=Number of manufacturing orders
|
||||
NumberOfUnitsProposals=Number of units on proposals
|
||||
NumberOfUnitsCustomerOrders=Number of units on sales orders
|
||||
NumberOfUnitsCustomerInvoices=Number of units on customer invoices
|
||||
NumberOfUnitsSupplierProposals=Number of units on vendor proposals
|
||||
NumberOfUnitsSupplierOrders=Number of units on purchase orders
|
||||
NumberOfUnitsSupplierInvoices=Number of units on vendor invoices
|
||||
NumberOfUnitsContracts=Number of units on contracts
|
||||
NumberOf=Number of %s
|
||||
NumberOfUnits=Number of units on %s
|
||||
AmountIn=Amount in %s
|
||||
NumberOfUnitsMos=Number of units to produce in manufacturing orders
|
||||
EMailTextInterventionAddedContact=A new intervention %s has been assigned to you.
|
||||
EMailTextInterventionValidated=The intervention %s has been validated.
|
||||
|
||||
@ -3753,6 +3753,11 @@ class Product extends CommonObject
|
||||
$tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[0]; // 1st field
|
||||
} elseif ($mode == 'bynumber') {
|
||||
$tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[2]; // 3rd field
|
||||
} elseif ($mode == 'byamount') {
|
||||
$tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[2]; // 3rd field
|
||||
} else {
|
||||
// Bad value for $mode
|
||||
return -1;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -3812,10 +3817,11 @@ class Product extends CommonObject
|
||||
global $conf;
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(f.datef, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT f.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."facturedet as d, ".$this->db->prefix()."facture as f, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as p";
|
||||
@ -3865,10 +3871,11 @@ class Product extends CommonObject
|
||||
global $conf;
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(f.datef, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT f.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."facture_fourn_det as d, ".$this->db->prefix()."facture_fourn as f, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as p";
|
||||
@ -3905,7 +3912,7 @@ class Product extends CommonObject
|
||||
* Return nb of units in proposals in which product is included
|
||||
*
|
||||
* @param int $socid Limit count on a particular third party id
|
||||
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
|
||||
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities, 'byamount'=amount
|
||||
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
|
||||
* @param int $year Year (0=last 12 month, -1=all years)
|
||||
* @param string $morefilter More sql filters
|
||||
@ -3916,10 +3923,11 @@ class Product extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(p.datep, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT p.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."propaldet as d, ".$this->db->prefix()."propal as p, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as prod";
|
||||
@ -3968,10 +3976,11 @@ class Product extends CommonObject
|
||||
global $conf;
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(p.date_valid, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT p.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."supplier_proposaldet as d, ".$this->db->prefix()."supplier_proposal as p, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as prod";
|
||||
@ -4019,10 +4028,11 @@ class Product extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(c.date_commande, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT c.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."commandedet as d, ".$this->db->prefix()."commande as c, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as p";
|
||||
@ -4070,10 +4080,11 @@ class Product extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(c.date_commande, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT c.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."commande_fournisseurdet as d, ".$this->db->prefix()."commande_fournisseur as c, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as p";
|
||||
@ -4121,10 +4132,11 @@ class Product extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(c.date_contrat, '%Y%m')";
|
||||
$sql = "SELECT sum(d.qty) as qty, date_format(c.date_contrat, '%Y%m')";
|
||||
if ($mode == 'bynumber') {
|
||||
$sql .= ", count(DISTINCT c.rowid)";
|
||||
}
|
||||
$sql .= ", sum(d.total_ht) as total_ht";
|
||||
$sql .= " FROM ".$this->db->prefix()."contratdet as d, ".$this->db->prefix()."contrat as c, ".$this->db->prefix()."societe as s";
|
||||
if ($filteronproducttype >= 0) {
|
||||
$sql .= ", ".$this->db->prefix()."product as p";
|
||||
|
||||
@ -254,17 +254,18 @@ if ($result || !($id > 0)) {
|
||||
}
|
||||
|
||||
// Choice of stats mode (byunit or bynumber)
|
||||
|
||||
if (!empty($conf->dol_use_jmobile)) {
|
||||
print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
|
||||
}
|
||||
|
||||
if ($mode == 'bynumber') {
|
||||
if ($mode != 'byunit') {
|
||||
print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=byunit'.$param.'">';
|
||||
} else {
|
||||
print '<span class="a-mesure marginleftonly marginrightonly">';
|
||||
}
|
||||
print $langs->trans("StatsByNumberOfUnits");
|
||||
if ($mode == 'bynumber') {
|
||||
if ($mode != 'byunit') {
|
||||
print '</a>';
|
||||
} else {
|
||||
print '</span>';
|
||||
@ -274,18 +275,35 @@ if ($result || !($id > 0)) {
|
||||
print '</div>'."\n".'<div class="nowrap">'."\n";
|
||||
}
|
||||
|
||||
if ($mode == 'byunit') {
|
||||
if ($mode != 'bynumber') {
|
||||
print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=bynumber'.$param.'">';
|
||||
} else {
|
||||
print '<span class="a-mesure marginleftonly marginrightonly">';
|
||||
}
|
||||
print $langs->trans("StatsByNumberOfEntities");
|
||||
if ($mode == 'byunit') {
|
||||
if ($mode != 'bynumber') {
|
||||
print '</a>';
|
||||
} else {
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
if (!empty($conf->dol_use_jmobile)) {
|
||||
print '</div>'."\n".'<div class="nowrap">'."\n";
|
||||
}
|
||||
|
||||
if ($mode != 'byamount') {
|
||||
print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=byamount'.$param.'">';
|
||||
} else {
|
||||
print '<span class="a-mesure marginleftonly marginrightonly">';
|
||||
}
|
||||
print $langs->trans("StatsByAmount");
|
||||
if ($mode != 'byamount') {
|
||||
print '</a>';
|
||||
} else {
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
// End of choices
|
||||
if (!empty($conf->dol_use_jmobile)) {
|
||||
print '</div></div>';
|
||||
} else {
|
||||
@ -304,52 +322,55 @@ if ($result || !($id > 0)) {
|
||||
}
|
||||
}
|
||||
|
||||
$arrayforlabel = array('byunit' => 'NumberOfUnits', 'bynumber' => 'NumberOf', 'byamount' => 'AmountIn');
|
||||
|
||||
if (isModEnabled('propal')) {
|
||||
$graphfiles['propal'] = array('modulepart'=>'productstats_proposals',
|
||||
'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")));
|
||||
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Proposals")));
|
||||
}
|
||||
|
||||
if (isModEnabled('supplier_proposal')) {
|
||||
$langs->load("supplier_proposal");
|
||||
$graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers',
|
||||
'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")));
|
||||
'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierProposals")));
|
||||
}
|
||||
|
||||
if (isModEnabled('order')) {
|
||||
$graphfiles['orders'] = array('modulepart'=>'productstats_orders',
|
||||
'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")));
|
||||
'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Orders")));
|
||||
}
|
||||
|
||||
if (isModEnabled('supplier_order')) {
|
||||
$graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers',
|
||||
'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")));
|
||||
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SuppliersOrders")));
|
||||
}
|
||||
|
||||
if (isModEnabled('facture')) {
|
||||
$graphfiles['invoices'] = array('modulepart'=>'productstats_invoices',
|
||||
'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")));
|
||||
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Invoices")));
|
||||
}
|
||||
|
||||
if (isModEnabled('supplier_invoice')) {
|
||||
$graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers',
|
||||
'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")));
|
||||
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
|
||||
'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierInvoices")));
|
||||
}
|
||||
|
||||
if (isModEnabled('contrat')) {
|
||||
$graphfiles['contracts'] = array('modulepart'=>'productstats_contracts',
|
||||
'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' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Contracts")));
|
||||
}
|
||||
|
||||
if (isModEnabled('mrp')) {
|
||||
if (isModEnabled('mrp') && $mode != 'byamount') {
|
||||
$graphfiles['mrp'] = array('modulepart'=>'productstats_mrp',
|
||||
'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' => $langs->transnoentitiesnoconv($arrayforlabel[$mode]."Mos"));
|
||||
}
|
||||
|
||||
$px = new DolGraph();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user