commit
f1cab5aa23
@ -78,20 +78,17 @@ $form = new Form($db);
|
|||||||
$htmlother = new FormOther($db);
|
$htmlother = new FormOther($db);
|
||||||
$object = new Product($db);
|
$object = new Product($db);
|
||||||
|
|
||||||
if (!$id && empty($ref))
|
if (!$id && empty($ref)) {
|
||||||
{
|
|
||||||
llxHeader("", $langs->trans("ProductStatistics"));
|
llxHeader("", $langs->trans("ProductStatistics"));
|
||||||
|
|
||||||
$type = GETPOST('type', 'int');
|
$type = GETPOST('type', 'int');
|
||||||
|
|
||||||
$helpurl = '';
|
$helpurl = '';
|
||||||
if ($type == '0')
|
if ($type == '0') {
|
||||||
{
|
|
||||||
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||||
//$title=$langs->trans("StatisticsOfProducts");
|
//$title=$langs->trans("StatisticsOfProducts");
|
||||||
$title = $langs->trans("Statistics");
|
$title = $langs->trans("Statistics");
|
||||||
} elseif ($type == '1')
|
} elseif ($type == '1') {
|
||||||
{
|
|
||||||
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||||
//$title=$langs->trans("StatisticsOfServices");
|
//$title=$langs->trans("StatisticsOfServices");
|
||||||
$title = $langs->trans("Statistics");
|
$title = $langs->trans("Statistics");
|
||||||
@ -111,13 +108,11 @@ if (!$id && empty($ref))
|
|||||||
$title = $langs->trans('ProductServiceCard');
|
$title = $langs->trans('ProductServiceCard');
|
||||||
$helpurl = '';
|
$helpurl = '';
|
||||||
$shortlabel = dol_trunc($object->label, 16);
|
$shortlabel = dol_trunc($object->label, 16);
|
||||||
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
|
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
|
||||||
{
|
|
||||||
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics');
|
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics');
|
||||||
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||||
}
|
}
|
||||||
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
|
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
|
||||||
{
|
|
||||||
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics');
|
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics');
|
||||||
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||||
}
|
}
|
||||||
@ -126,8 +121,7 @@ if (!$id && empty($ref))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($result && (!empty($id) || !empty($ref)))
|
if ($result && (!empty($id) || !empty($ref))) {
|
||||||
{
|
|
||||||
$head = product_prepare_head($object);
|
$head = product_prepare_head($object);
|
||||||
$titre = $langs->trans("CardProduct".$object->type);
|
$titre = $langs->trans("CardProduct".$object->type);
|
||||||
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
||||||
@ -140,8 +134,7 @@ if ($result && (!empty($id) || !empty($ref)))
|
|||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
}
|
}
|
||||||
if (empty($id) & empty($ref))
|
if (empty($id) && empty($ref)) {
|
||||||
{
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head = array();
|
$head = array();
|
||||||
|
|
||||||
@ -167,16 +160,14 @@ if (empty($id) & empty($ref))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($result || empty($id))
|
if ($result || empty($id)) {
|
||||||
{
|
|
||||||
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
|
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
|
||||||
|
|
||||||
if (empty($id))
|
if (empty($id)) {
|
||||||
{
|
|
||||||
// Type
|
// Type
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("ProductsAndServices").'</td><td>';
|
print '<tr><td class="titlefield">'.$langs->trans("ProductsAndServices").'</td><td>';
|
||||||
$array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
|
$array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
|
||||||
@ -184,8 +175,7 @@ if ($result || empty($id))
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Tag
|
// Tag
|
||||||
if ($conf->categorie->enabled)
|
if ($conf->categorie->enabled) {
|
||||||
{
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
|
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
|
||||||
//$moreforfilter.='<div class="divsearchfield">';
|
//$moreforfilter.='<div class="divsearchfield">';
|
||||||
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1);
|
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1);
|
||||||
@ -198,8 +188,7 @@ 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 - 10; $year < $currentyear + 10; $year++) {
|
||||||
{
|
|
||||||
$arrayyears[$year] = $year;
|
$arrayyears[$year] = $year;
|
||||||
}
|
}
|
||||||
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
||||||
@ -240,12 +229,9 @@ if ($result || empty($id))
|
|||||||
|
|
||||||
// Generation des graphs
|
// Generation des graphs
|
||||||
$dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]);
|
$dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]);
|
||||||
if ($object->id > 0) // We are on statistics for a dedicated product
|
if ($object->id > 0) { // We are on statistics for a dedicated product
|
||||||
{
|
if (!file_exists($dir.'/'.$object->id)) {
|
||||||
if (!file_exists($dir.'/'.$object->id))
|
if (dol_mkdir($dir.'/'.$object->id) < 0) {
|
||||||
{
|
|
||||||
if (dol_mkdir($dir.'/'.$object->id) < 0)
|
|
||||||
{
|
|
||||||
$mesg = $langs->trans("ErrorCanNotCreateDir", $dir);
|
$mesg = $langs->trans("ErrorCanNotCreateDir", $dir);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -302,31 +288,25 @@ if ($result || empty($id))
|
|||||||
|
|
||||||
$px = new DolGraph();
|
$px = new DolGraph();
|
||||||
|
|
||||||
if (!$error && count($graphfiles) > 0)
|
if (!$error && count($graphfiles) > 0) {
|
||||||
{
|
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (!$mesg)
|
if (!$mesg) {
|
||||||
{
|
foreach ($graphfiles as $key => $val) {
|
||||||
foreach ($graphfiles as $key => $val)
|
|
||||||
{
|
|
||||||
if (!$graphfiles[$key]['file']) continue;
|
if (!$graphfiles[$key]['file']) continue;
|
||||||
|
|
||||||
$graph_data = array();
|
$graph_data = array();
|
||||||
|
|
||||||
if (dol_is_file($dir.'/'.$graphfiles[$key]['file']))
|
if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) {
|
||||||
{
|
|
||||||
// TODO Load cachefile $graphfiles[$key]['file']
|
// TODO Load cachefile $graphfiles[$key]['file']
|
||||||
} else {
|
} else {
|
||||||
$morefilters = '';
|
$morefilters = '';
|
||||||
if ($search_categ > 0)
|
if ($search_categ > 0) {
|
||||||
{
|
|
||||||
$categ = new Categorie($db);
|
$categ = new Categorie($db);
|
||||||
$categ->fetch($search_categ);
|
$categ->fetch($search_categ);
|
||||||
$listofprodids = $categ->getObjectsInCateg('product', 1);
|
$listofprodids = $categ->getObjectsInCateg('product', 1);
|
||||||
$morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')';
|
$morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')';
|
||||||
}
|
}
|
||||||
if ($search_categ == -2)
|
if ($search_categ == -2) {
|
||||||
{
|
|
||||||
$morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)';
|
$morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,8 +322,7 @@ if ($result || empty($id))
|
|||||||
// TODO Save cachefile $graphfiles[$key]['file']
|
// TODO Save cachefile $graphfiles[$key]['file']
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($graph_data))
|
if (is_array($graph_data)) {
|
||||||
{
|
|
||||||
$px->SetData($graph_data);
|
$px->SetData($graph_data);
|
||||||
$px->SetYLabel($graphfiles[$key]['label']);
|
$px->SetYLabel($graphfiles[$key]['label']);
|
||||||
$px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
|
$px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
|
||||||
@ -371,10 +350,8 @@ if ($result || empty($id))
|
|||||||
|
|
||||||
// Show graphs
|
// Show graphs
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if (count($graphfiles) > 0)
|
if (count($graphfiles) > 0) {
|
||||||
{
|
foreach ($graphfiles as $key => $val) {
|
||||||
foreach ($graphfiles as $key => $val)
|
|
||||||
{
|
|
||||||
if (!$graphfiles[$key]['file']) continue;
|
if (!$graphfiles[$key]['file']) continue;
|
||||||
|
|
||||||
if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue;
|
if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue;
|
||||||
@ -386,16 +363,14 @@ if ($result || empty($id))
|
|||||||
if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) continue;
|
if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) continue;
|
||||||
|
|
||||||
|
|
||||||
if ($i % 2 == 0)
|
if ($i % 2 == 0) {
|
||||||
{
|
|
||||||
print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
|
print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
|
||||||
} else {
|
} else {
|
||||||
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
|
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date generation
|
// Date generation
|
||||||
if ($graphfiles[$key]['output'] && !$px->isGraphKo())
|
if ($graphfiles[$key]['output'] && !$px->isGraphKo()) {
|
||||||
{
|
|
||||||
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour"));
|
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour"));
|
||||||
else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour"));
|
else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour"));
|
||||||
} else {
|
} else {
|
||||||
@ -417,8 +392,7 @@ if ($result || empty($id))
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
if ($i % 2 == 0)
|
if ($i % 2 == 0) {
|
||||||
{
|
|
||||||
print "\n".'</div>'."\n";
|
print "\n".'</div>'."\n";
|
||||||
} else {
|
} else {
|
||||||
print "\n".'</div></div></div>';
|
print "\n".'</div></div></div>';
|
||||||
@ -429,16 +403,14 @@ if ($result || empty($id))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// div not closed
|
// div not closed
|
||||||
if ($i % 2 == 1)
|
if ($i % 2 == 1) {
|
||||||
{
|
|
||||||
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
|
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
|
||||||
print "\n".'</div></div></div>';
|
print "\n".'</div></div></div>';
|
||||||
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
|
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$id)
|
if (!$id) {
|
||||||
{
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user