NEW Statistic graphs on products offer a filter on product type (product
/ service or both)
This commit is contained in:
parent
b5c9602da4
commit
24dff1d842
@ -98,12 +98,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__);
|
||||
-- Product - Services
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__);
|
||||
-- Product - Stocks
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__);
|
||||
|
||||
@ -2193,11 +2193,12 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Return nb of units or customers invoices 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
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
* @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_vente($socid,$mode)
|
||||
function get_nb_vente($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf;
|
||||
global $user;
|
||||
@ -2205,9 +2206,11 @@ class Product extends CommonObject
|
||||
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
|
||||
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;
|
||||
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).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
@ -2222,11 +2225,12 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Return nb of units or supplier invoices 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
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
* @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_achat($socid,$mode)
|
||||
function get_nb_achat($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf;
|
||||
global $user;
|
||||
@ -2234,9 +2238,11 @@ class Product extends CommonObject
|
||||
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
|
||||
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;
|
||||
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).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
@ -2251,11 +2257,12 @@ class Product extends CommonObject
|
||||
/**
|
||||
* 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
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
* @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_propal($socid,$mode)
|
||||
function get_nb_propal($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf;
|
||||
global $user;
|
||||
@ -2263,9 +2270,11 @@ class Product extends CommonObject
|
||||
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal 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_propal";
|
||||
if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
|
||||
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;
|
||||
@ -2279,20 +2288,23 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Return nb of units or orders 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
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
* @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_order($socid,$mode)
|
||||
function get_nb_order($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
|
||||
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;
|
||||
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).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
@ -2306,20 +2318,23 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Return nb of units or orders 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
|
||||
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
|
||||
* @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_ordersupplier($socid,$mode)
|
||||
function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
|
||||
if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
|
||||
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;
|
||||
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).")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
|
||||
@ -204,19 +205,19 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
|
||||
$graphfiles=array(
|
||||
'propal' =>array('modulepart'=>'productstats_proposals',
|
||||
'file' => $object->id.'/propal12m.png',
|
||||
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))),
|
||||
'orders' =>array('modulepart'=>'productstats_orders',
|
||||
'file' => $object->id.'/orders12m.png',
|
||||
'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.png',
|
||||
'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.png',
|
||||
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))),
|
||||
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
|
||||
'file' => $object->id.'/invoicessuppliers12m.png',
|
||||
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png',
|
||||
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))),
|
||||
);
|
||||
|
||||
@ -233,13 +234,21 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
|
||||
$graph_data = array();
|
||||
|
||||
// TODO Test si deja existant et recent, on ne genere pas
|
||||
if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode);
|
||||
if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode);
|
||||
if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode);
|
||||
if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode);
|
||||
if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode);
|
||||
|
||||
if (dol_is_file($dir . '/' . $graphfiles[$key]['file']))
|
||||
{
|
||||
// TODO Load cachefile $graphfiles[$key]['file']
|
||||
}
|
||||
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));
|
||||
|
||||
// TODO Save cachefile $graphfiles[$key]['file']
|
||||
}
|
||||
|
||||
if (is_array($graph_data))
|
||||
{
|
||||
$px->SetData($graph_data);
|
||||
@ -312,7 +321,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
|
||||
{
|
||||
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
|
||||
}
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user