Supplier proposal was missing
This commit is contained in:
parent
0e040b166d
commit
7bbb3a7da1
@ -157,11 +157,13 @@ StatsByNumberOfEntities=Statistics in number of referring entities
|
||||
NumberOfProposals=Number of proposals on last 12 month
|
||||
NumberOfCustomerOrders=Number of customer orders on last 12 month
|
||||
NumberOfCustomerInvoices=Number of customer invoices on last 12 month
|
||||
NumberOfSupplierProposals=Number of supplier proposals on last 12 month
|
||||
NumberOfSupplierOrders=Number of supplier orders on last 12 month
|
||||
NumberOfSupplierInvoices=Number of supplier invoices on last 12 month
|
||||
NumberOfUnitsProposals=Number of units on proposals on last 12 month
|
||||
NumberOfUnitsCustomerOrders=Number of units on customer orders on last 12 month
|
||||
NumberOfUnitsCustomerInvoices=Number of units on customer invoices on last 12 month
|
||||
NumberOfUnitsSupplierProposals=Number of units on supplier proposals on last 12 month
|
||||
NumberOfUnitsSupplierOrders=Number of units on supplier orders on last 12 month
|
||||
NumberOfUnitsSupplierInvoices=Number of units on supplier invoices on last 12 month
|
||||
EMailTextInterventionValidated=The intervention %s has been validated.
|
||||
|
||||
@ -2280,6 +2280,7 @@ class Product extends CommonObject
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE f.rowid = d.fk_facture";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture', 1).")";
|
||||
@ -2312,6 +2313,7 @@ class Product extends CommonObject
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE f.rowid = d.fk_facture_fourn";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")";
|
||||
@ -2344,6 +2346,7 @@ class Product extends CommonObject
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE p.rowid = d.fk_propal";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND p.fk_soc = s.rowid";
|
||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
||||
@ -2355,6 +2358,38 @@ class Product extends CommonObject
|
||||
return $this->_get_stats($sql,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nb of units or 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 int $filteronproducttype 0=To filter on product only, 1=To filter on services only
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
*/
|
||||
function get_nb_propalsupplier($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf;
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE p.rowid = d.fk_supplier_proposal";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND p.fk_soc = s.rowid";
|
||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid;
|
||||
$sql.= " GROUP BY date_format(p.date_valid,'%Y%m')";
|
||||
$sql.= " ORDER BY date_format(p.date_valid,'%Y%m') DESC";
|
||||
|
||||
return $this->_get_stats($sql,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nb of units or orders in which product is included
|
||||
*
|
||||
@ -2374,6 +2409,7 @@ class Product extends CommonObject
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE c.rowid = d.fk_commande";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
||||
@ -2404,6 +2440,7 @@ class Product extends CommonObject
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE c.rowid = d.fk_commande";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
else $sql.=" AND d.fk_product > 0";
|
||||
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
|
||||
$sql.= " AND c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")";
|
||||
|
||||
@ -210,15 +210,20 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
'propal' =>array('modulepart'=>'productstats_proposals',
|
||||
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))),
|
||||
'proposalssuppliers'=>array('modulepart'=>'productstats_proposalssuppliers',
|
||||
'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals"):$langs->transnoentitiesnoconv("NumberOfSupplierProposals"))),
|
||||
|
||||
'orders' =>array('modulepart'=>'productstats_orders',
|
||||
'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))),
|
||||
'invoices' =>array('modulepart'=>'productstats_invoices',
|
||||
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))),
|
||||
'orderssuppliers'=>array('modulepart'=>'productstats_orderssuppliers',
|
||||
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))),
|
||||
|
||||
'invoices' =>array('modulepart'=>'productstats_invoices',
|
||||
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))),
|
||||
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
|
||||
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))),
|
||||
@ -243,11 +248,12 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'proposalssuppliers') $graph_data = $object->get_nb_propalsupplier($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1));
|
||||
|
||||
// TODO Save cachefile $graphfiles[$key]['file']
|
||||
}
|
||||
@ -289,6 +295,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue;
|
||||
if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue;
|
||||
if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue;
|
||||
if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue;
|
||||
if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue;
|
||||
if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user