dolibarr/htdocs/product/stats/card.php

527 lines
20 KiB
PHP
Raw Normal View History

2004-10-20 22:06:49 +02:00
<?php
2011-11-20 11:58:52 +01:00
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
2011-11-20 11:58:52 +01:00
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
2019-11-22 15:49:06 +01:00
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
2003-06-30 01:00:10 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2003-06-30 01:00:10 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2003-06-30 01:00:10 +02:00
*/
/**
* \file htdocs/product/stats/card.php
* \ingroup product
2011-08-08 18:07:47 +02:00
* \brief Page of product statistics
*/
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';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
2003-06-30 01:00:10 +02:00
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380);
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160);
2013-10-27 01:08:37 +02:00
2018-05-27 00:06:49 +02:00
// Load translation files required by the page
$langs->loadLangs(array('companies', 'products', 'stocks', 'bills', 'other'));
$id = GETPOST('id', 'int'); // For this page, id can also be 'all'
$ref = GETPOST('ref', 'alpha');
$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit');
$search_year = GETPOST('search_year', 'int');
$search_categ = GETPOST('search_categ', 'int');
$notab = GETPOST('notab', 'int');
2022-05-11 15:06:11 +02:00
$type = GETPOST('type', 'alpha');
$error = 0;
$mesg = '';
$graphfiles = array();
$socid = GETPOST('socid', 'int');
2021-02-26 14:25:17 +01:00
if (!empty($user->socid)) {
$socid = $user->socid;
}
if ($socid < 0) {
$socid = 0;
}
2012-07-09 12:31:21 +02:00
// Security check
$fieldvalue = ($id > 0 ? $id : $ref);
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
2004-07-29 16:04:05 +02:00
2021-07-27 09:09:42 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('productstatscard', 'globalcard'));
$tmp = dol_getdate(dol_now());
$currentyear = $tmp['year'];
2021-02-26 14:25:17 +01:00
if (empty($search_year)) {
$search_year = $currentyear;
}
2021-10-23 19:09:23 +02:00
$moreforfilter = "";
$object = new Product($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
}
2021-05-21 15:54:11 +02:00
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
/*
* Actions
*/
// None
2003-06-30 01:00:10 +02:00
/*
* View
2003-06-30 01:00:10 +02:00
*/
2017-01-15 15:17:32 +01:00
$form = new Form($db);
$htmlother = new FormOther($db);
2018-10-01 01:10:42 +02:00
if (!($id > 0) && empty($ref) || $notab) {
$notab = 1;
llxHeader("", $langs->trans("ProductStatistics"));
$type = GETPOST('type', 'int');
2021-02-26 14:25:17 +01:00
$helpurl = '';
if ($type == '0') {
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
//$title=$langs->trans("StatisticsOfProducts");
$title = $langs->trans("Statistics");
} elseif ($type == '1') {
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfServices");
$title = $langs->trans("Statistics");
} else {
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfProductsOrServices");
$title = $langs->trans("Statistics");
}
2017-01-15 15:17:32 +01:00
$picto = 'product';
2021-02-26 14:25:17 +01:00
if ($type == 1) {
$picto = 'service';
}
2020-04-13 18:10:20 +02:00
print load_fiche_titre($title, $mesg, $picto);
2020-05-21 15:05:19 +02:00
} else {
$result = $object->fetch($id, $ref);
2017-01-15 15:17:32 +01:00
$title = $langs->trans('ProductServiceCard');
$helpurl = '';
$shortlabel = dol_trunc($object->label, 16);
2020-10-23 21:53:18 +02:00
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
2020-10-23 21:53:18 +02:00
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
2015-11-07 16:25:14 +01:00
}
2017-01-15 15:17:32 +01:00
llxHeader('', $title, $helpurl);
}
2017-01-15 15:17:32 +01:00
2009-03-02 19:25:51 +01:00
if ($result && ($id > 0 || !empty($ref)) && empty($notab)) {
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'stats', $titre, -1, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2017-06-12 18:22:51 +02:00
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1);
print dol_get_fiche_end();
}
if ((!($id > 0) && empty($ref)) || $notab) {
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.((int) $type) : '');
$head[$h][1] = $langs->trans("Chart");
$head[$h][2] = 'chart';
$h++;
$title = $langs->trans("ListProductServiceByPopularity");
if ((string) $type == '1') {
$title = $langs->trans("ListServiceByPopularity");
}
if ((string) $type == '0') {
$title = $langs->trans("ListProductByPopularity");
}
$head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.((int) $type) : '');
$head[$h][1] = $langs->trans("ProductsPerPopularity");
$head[$h][2] = 'popularity';
$h++;
print dol_get_fiche_head($head, 'chart', '', -1);
}
if ($result || !($id > 0)) {
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
if (empty($id) || $notab) {
print '<input type="hidden" name="notab" value="1">';
}
2017-06-12 18:22:51 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2017-06-12 18:22:51 +02:00
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
if (!($id > 0) || $notab) {
// Type
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
$array = array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
2021-12-16 23:53:05 +01:00
print $form->selectarray('type', $array, $type, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
2017-06-12 18:22:51 +02:00
print '</td></tr>';
// Product
print '<tr><td class="titlefield">'.$langs->trans("ProductOrService").'</td><td>';
print img_picto('', 'product', 'class="pictofixedwidth"');
2021-12-16 23:53:05 +01:00
print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', ($conf->dol_optimize_smallscreen ? 1 : 0), array(), 0, '1', 0, 'widthcentpercentminusx maxwidth400');
print '</td></tr>';
2017-06-12 18:22:51 +02:00
// Tag
2022-06-09 22:41:59 +02:00
if (isModEnabled('categorie')) {
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
2021-06-14 01:11:39 +02:00
$moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"');
2021-12-16 23:53:05 +01:00
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth400');
print $moreforfilter;
print '</td></tr>';
}
} else {
print '<input type="hidden" name="id" value="'.$id.'">';
2017-06-12 18:22:51 +02:00
}
2017-01-15 15:17:32 +01:00
2017-06-12 18:22:51 +02:00
// Year
print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>';
$arrayyears = array();
2021-02-26 14:25:17 +01:00
for ($year = $currentyear - 25; $year < $currentyear; $year++) {
$arrayyears[$year] = $year;
}
if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
2017-06-12 18:22:51 +02:00
}
2021-02-26 14:25:17 +01:00
if (!in_array($currentyear, $arrayyears)) {
$arrayyears[$currentyear] = $currentyear;
}
2017-06-12 18:22:51 +02:00
arsort($arrayyears);
2021-03-24 02:25:54 +01:00
print $form->selectarray('search_year', $arrayyears, $search_year, 1, 0, 0, '', 0, 0, 0, '', 'width75');
2017-06-12 18:22:51 +02:00
print '</td></tr>';
// thirdparty
print '<tr><td class="titlefield">'.$langs->trans("ThirdParty").'</td><td>';
print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth400');
print '</td></tr>';
2017-06-12 18:22:51 +02:00
print '</table>';
2021-06-14 01:11:39 +02:00
print '<div class="center"><input type="submit" name="submit" class="button small" value="'.$langs->trans("Refresh").'"></div>';
2021-02-27 02:00:00 +01:00
print '</form><br>';
2017-01-15 15:17:32 +01:00
2017-06-12 18:22:51 +02:00
print '<br>';
2017-01-15 15:17:32 +01:00
$param = '';
$param .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '&id='.$object->id).(($type != '' && $type != '-1') ? '&type='.((int) $type) : '').'&search_year='.((int) $search_year).($notab ? '&notab='.$notab : '');
if ($socid > 0) {
$param .= '&socid='.((int) $socid);
}
// Choice of stats mode (byunit or bynumber)
2021-02-26 14:25:17 +01:00
if (!empty($conf->dol_use_jmobile)) {
print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
}
2017-01-15 15:17:32 +01:00
2021-02-26 14:25:17 +01:00
if ($mode == 'bynumber') {
print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=byunit'.$param.'">';
2021-02-26 14:25:17 +01:00
} else {
2021-10-13 02:35:53 +02:00
print '<span class="a-mesure marginleftonly marginrightonly">';
2021-02-26 14:25:17 +01:00
}
print $langs->trans("StatsByNumberOfUnits");
2021-02-26 14:25:17 +01:00
if ($mode == 'bynumber') {
print '</a>';
} else {
print '</span>';
}
2017-01-15 15:17:32 +01:00
2021-02-26 14:25:17 +01:00
if (!empty($conf->dol_use_jmobile)) {
print '</div>'."\n".'<div class="nowrap">'."\n";
}
2021-02-26 14:25:17 +01:00
if ($mode == 'byunit') {
print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=bynumber'.$param.'">';
2021-02-26 14:25:17 +01:00
} else {
2021-10-13 02:35:53 +02:00
print '<span class="a-mesure marginleftonly marginrightonly">';
2021-02-26 14:25:17 +01:00
}
print $langs->trans("StatsByNumberOfEntities");
2021-02-26 14:25:17 +01:00
if ($mode == 'byunit') {
print '</a>';
} else {
print '</span>';
}
2017-01-15 15:17:32 +01:00
2021-02-26 14:25:17 +01:00
if (!empty($conf->dol_use_jmobile)) {
print '</div></div>';
} else {
print '<br>';
}
print '<br>';
2009-03-02 19:25:51 +01:00
// Generation of graphs
2021-11-30 16:35:46 +01:00
$dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]);
2020-10-23 21:53:18 +02:00
if ($object->id > 0) { // We are on statistics for a dedicated product
if (!file_exists($dir.'/'.$object->id)) {
if (dol_mkdir($dir.'/'.$object->id) < 0) {
$mesg = $langs->trans("ErrorCanNotCreateDir", $dir);
$error++;
}
}
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
if (isModEnabled('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")));
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
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")));
}
2022-06-09 22:41:59 +02:00
if (isModEnabled('mrp')) {
2020-02-28 19:26:52 +01:00
$graphfiles['mrp'] = array('modulepart'=>'productstats_mrp',
'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
2020-02-28 19:26:52 +01:00
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos")));
}
$px = new DolGraph();
2011-08-08 18:07:47 +02:00
2020-10-23 21:53:18 +02:00
if (!$error && count($graphfiles) > 0) {
$mesg = $px->isGraphKo();
2020-10-23 21:53:18 +02:00
if (!$mesg) {
foreach ($graphfiles as $key => $val) {
2021-02-26 14:25:17 +01:00
if (!$graphfiles[$key]['file']) {
continue;
}
$graph_data = array();
2020-10-23 21:53:18 +02:00
if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) {
// TODO Load cachefile $graphfiles[$key]['file']
2020-05-21 15:05:19 +02:00
} else {
$morefilters = '';
if ($search_categ > 0) {
$categ = new Categorie($db);
$categ->fetch($search_categ);
$listofprodids = $categ->getObjectsInCateg('product', 1);
2021-03-22 12:00:41 +01:00
$morefilters = ' AND d.fk_product IN ('.$db->sanitize((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')';
}
if ($search_categ == -2) {
$morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)';
}
2017-06-12 18:22:51 +02:00
2021-02-26 14:25:17 +01:00
if ($key == 'propal') {
$graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'orders') {
$graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'invoices') {
$graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'proposalssuppliers') {
$graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'invoicessuppliers') {
$graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'orderssuppliers') {
$graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'contracts') {
$graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
if ($key == 'mrp') {
$graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
}
// TODO Save cachefile $graphfiles[$key]['file']
}
2020-10-23 21:53:18 +02:00
if (is_array($graph_data)) {
$px->SetData($graph_data);
$px->SetYLabel($graphfiles[$key]['label']);
$px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue());
2020-03-06 09:52:51 +01:00
$px->setShowLegend(0);
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetHorizTickIncrement(1);
$px->SetShading(3);
//print 'x '.$key.' '.$graphfiles[$key]['file'];
$url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.((int) $object->entity).'&file='.urlencode($graphfiles[$key]['file']).($notab ? '&notab='.$notab : '');
$px->draw($dir."/".$graphfiles[$key]['file'], $url);
2019-11-20 12:42:56 +01:00
$graphfiles[$key]['total'] = $px->total();
$graphfiles[$key]['output'] = $px->show();
2020-05-21 15:05:19 +02:00
} else {
dol_print_error($db, 'Error for calculating graph on key='.$key.' - '.$object->error);
}
2013-10-27 00:34:25 +02:00
}
//setEventMessages($langs->trans("ChartGenerated"), null, 'mesgs');
}
}
// Show graphs
$i = 0;
2020-10-23 21:53:18 +02:00
if (count($graphfiles) > 0) {
foreach ($graphfiles as $key => $val) {
2021-02-26 14:25:17 +01:00
if (!$graphfiles[$key]['file']) {
continue;
}
2021-02-26 14:25:17 +01:00
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;
}
2021-10-23 07:13:08 +02:00
if ($graphfiles == 'invoices_suppliers' && empty($user->rights->fournisseur->facture->lire)) {
2021-02-26 14:25:17 +01:00
continue;
}
2021-10-23 07:13:08 +02:00
if ($graphfiles == 'orders_suppliers' && empty($user->rights->fournisseur->commande->lire)) {
2021-02-26 14:25:17 +01:00
continue;
}
if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) {
continue;
}
2020-10-23 21:53:18 +02:00
if ($i % 2 == 0) {
print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
2020-05-21 15:05:19 +02:00
} else {
2021-10-23 17:18:35 +02:00
print "\n".'<div class="fichehalfright">'."\n";
}
// Date generation
2020-10-23 21:53:18 +02:00
if ($graphfiles[$key]['output'] && !$px->isGraphKo()) {
2021-02-26 14:25:17 +01:00
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"));
}
2020-05-21 15:05:19 +02:00
} else {
$dategenerated = ($mesg ? '<span class="error">'.$mesg.'</span>' : $langs->trans("ChartNotGenerated"));
}
$linktoregenerate = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?'.(GETPOSTISSET('id') ? 'id='.GETPOST('id', 'int') : 'id='.$object->id).(((string) $type != '' && $type != '-1') ? '&type='.((int) $type) : '').'&action=recalcul&mode='.urlencode($mode).'&search_year='.((int) $search_year).($search_categ > 0 ? '&search_categ='.((int) $search_categ) : '').'">';
$linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh');
$linktoregenerate .= '</a>';
2017-06-12 18:22:51 +02:00
2021-12-16 23:53:05 +01:00
// Show graph
2021-12-16 23:53:05 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
// Label
print '<tr class="liste_titre"><td>';
print $graphfiles[$key]['label'];
2020-02-28 19:26:52 +01:00
print ' <span class="opacitymedium">('.$graphfiles[$key]['total'].')</span></td>';
print '<td align="right">'.$linktoregenerate.'</td>';
print '</tr>';
// Image
print '<tr class="impair"><td colspan="2" class="nohover" align="center">';
print $graphfiles[$key]['output'];
print '</td></tr>';
print '</table>';
2021-12-16 23:53:05 +01:00
print '</div>';
2020-10-23 21:53:18 +02:00
if ($i % 2 == 0) {
print "\n".'</div>'."\n";
2020-05-21 15:05:19 +02:00
} else {
2021-10-23 17:18:35 +02:00
print "\n".'</div></div>';
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
}
$i++;
2013-10-27 01:08:37 +02:00
}
2015-11-07 16:25:14 +01:00
}
// div not closed
2020-10-23 21:53:18 +02:00
if ($i % 2 == 1) {
2021-10-24 00:37:37 +02:00
print "\n".'<div class="fichehalfright">'."\n";
print "\n".'</div></div>';
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
}
2003-06-30 01:00:10 +02:00
}
if (!($id > 0)) {
print dol_get_fiche_end();
2003-06-30 01:00:10 +02:00
}
2018-08-14 09:55:58 +02:00
// End of page
llxFooter();
2003-06-30 01:00:10 +02:00
$db->close();