dolibarr 22.0.5
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (c) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
6 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
8 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
37require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39
48$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', '380');
49$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', '160');
50
51// Load translation files required by the page
52$langs->loadLangs(array('companies', 'products', 'stocks', 'bills', 'other'));
53
54$id = GETPOSTINT('id'); // For this page, id can also be 'all'
55$ref = GETPOST('ref', 'alpha');
56$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit');
57$search_year = GETPOSTINT('search_year');
58$search_categ = GETPOSTINT('search_categ');
59$notab = GETPOSTINT('notab');
60$type = GETPOST('type', 'alpha');
61
62$error = 0;
63$mesg = '';
64$graphfiles = array();
65
66$socid = GETPOSTINT('socid');
67if (!empty($user->socid)) {
68 $socid = $user->socid;
69}
70if ($socid < 0) {
71 $socid = 0;
72}
73
74// Security check
75$fieldvalue = ($id > 0 ? $id : $ref);
76$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
77
78// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
79$hookmanager->initHooks(array('productstatscard', 'globalcard'));
80
81$tmp = dol_getdate(dol_now());
82$currentyear = $tmp['year'];
83if (empty($search_year)) {
84 $search_year = $currentyear;
85}
86$moreforfilter = "";
87
88$object = new Product($db);
89if ($id > 0 || !empty($ref)) {
90 $result = $object->fetch($id, $ref);
91}
92
93$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
94
95
96/*
97 * Actions
98 */
99
100// None
101
102
103/*
104 * View
105 */
106
107$form = new Form($db);
108$htmlother = new FormOther($db);
109
110if (!($id > 0) && empty($ref) || $notab) {
111 $notab = 1;
112
113 llxHeader("", $langs->trans("ProductStatistics"), '', '', 0, 0, '', '', '', 'mod-product page-stats_card_general');
114
115 $type = GETPOSTINT('type');
116
117 $helpurl = '';
118 if ($type == '0') {
119 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
120 //$title=$langs->trans("StatisticsOfProducts");
121 $title = $langs->trans("Statistics");
122 } else {
123 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
124 //$title=$langs->trans("StatisticsOfProductsOrServices");
125 $title = $langs->trans("Statistics");
126 }
127
128 $picto = 'product';
129 if ($type == 1) {
130 $picto = 'service';
131 }
132
133 print load_fiche_titre($title, $mesg, $picto);
134} else {
135 $result = $object->fetch($id, $ref);
136
137 $title = $langs->trans('ProductServiceCard');
138 $helpurl = '';
139 $shortlabel = dol_trunc($object->label, 16);
140 if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
141 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics');
142 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
143 }
144 if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
145 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics');
146 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
147 }
148
149 //HERE
150 llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-product page-stats_card_by_product');
151}
152
153
154if ($result && ($id > 0 || !empty($ref)) && empty($notab)) {
156 $titre = $langs->trans("CardProduct".$object->type);
157 $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
158
159 print dol_get_fiche_head($head, 'stats', $titre, -1, $picto);
160
161 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
162 $object->next_prev_filter = "(te.fk_product_type:=:".((int) $object->type).")";
163
164 dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1);
165
166 print dol_get_fiche_end();
167}
168if ((!($id > 0) && empty($ref)) || $notab) {
169 $h = 0;
170 $head = array();
171
172 $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.((int) $type) : '');
173 $head[$h][1] = $langs->trans("Chart");
174 $head[$h][2] = 'chart';
175 $h++;
176
177 $title = $langs->trans("ListProductServiceByPopularity");
178 if ((string) $type == '0') {
179 $title = $langs->trans("ListProductByPopularity");
180 }
181 if ((string) $type == '1') {
182 $title = $langs->trans("ListServiceByPopularity");
183 }
184
185
186 $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.((int) $type) : '');
187 $head[$h][1] = $langs->trans("ProductsServicesPerPopularity");
188 if ((string) $type == '0') {
189 $head[$h][1] = $langs->trans("ProductsPerPopularity");
190 }
191 if ((string) $type == '1') {
192 $head[$h][1] = $langs->trans("ServicesPerPopularity");
193 }
194 $head[$h][2] = 'popularity';
195 $h++;
196
197 print dol_get_fiche_head($head, 'chart', '', -1);
198}
199
200
201if ($result || !($id > 0)) {
202 print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
203 print '<input type="hidden" name="token" value="'.newToken().'">';
204 if (empty($id) || $notab) {
205 print '<input type="hidden" name="notab" value="1">';
206 }
207
208 print '<table class="noborder centpercent">';
209 print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Filter").'</td><td></td></tr>';
210
211 if (!($id > 0) || $notab) {
212 // Type
213 print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Type").'</td><td>';
214 $array = array('-1' => '&nbsp;', '0' => $langs->trans('Product'), '1' => $langs->trans('Service'));
215 print $form->selectarray('type', $array, $type, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
216 print '</td></tr>';
217
218 // Product
219 print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("ProductOrService").'</td><td>';
220 print img_picto('', 'product', 'class="pictofixedwidth"');
221 print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', 0, array(), 0, $langs->trans("RefOrLabel"), 0, 'widthcentpercentminusx maxwidth400');
222 print '</td></tr>';
223
224 // Tag
225 if (isModEnabled('category')) {
226 print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
227 $moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"');
228 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth400');
229 print $moreforfilter;
230 print '</td></tr>';
231 }
232 } else {
233 print '<input type="hidden" name="id" value="'.$id.'">';
234 }
235 print '<input type="hidden" name="mode" value="'.$mode.'">';
236
237 // Year
238 print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Year").'</td><td>';
239 $arrayyears = array();
240 for ($year = $currentyear - 25; $year < $currentyear; $year++) {
241 $arrayyears[$year] = (string) $year;
242 }
243 if (!in_array($year, $arrayyears)) {
244 $arrayyears[$year] = (string) $year;
245 }
246 if (!in_array($currentyear, $arrayyears)) {
247 $arrayyears[$currentyear] = (string) $currentyear;
248 }
249 arsort($arrayyears);
250 print $form->selectarray('search_year', $arrayyears, $search_year, 1, 0, 0, '', 0, 0, 0, '', 'width75');
251 print '</td></tr>';
252
253 // thirdparty
254 print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("ThirdParty").'</td><td>';
255 print img_picto('', 'company', 'class="pictofixedwidth"');
256 print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth400');
257 print '</td></tr>';
258
259 print '</table>';
260 print '<div class="center"><input type="submit" name="submit" class="button small" value="'.$langs->trans("Refresh").'"></div>';
261 print '</form><br>';
262
263 print '<br>';
264
265
266 $param = '';
267 $param .= (GETPOSTISSET('id') ? '&id='.GETPOSTINT('id') : '&id='.$object->id).(($type != '' && $type != '-1') ? '&type='.((int) $type) : '').'&search_year='.((int) $search_year).($notab ? '&notab='.$notab : '');
268 if ($socid > 0) {
269 $param .= '&socid='.((int) $socid);
270 }
271 if (!empty($search_categ)) {
272 $param .= '&search_categ='.((int) $search_categ);
273 }
274
275 // Choice of stats mode (byunit or bynumber)
276
277 if (!empty($conf->dol_use_jmobile)) {
278 print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
279 }
280
281 if ($mode != 'byunit') {
282 print '<a class="a-mesure-disabled marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=byunit'.$param.'">';
283 } else {
284 print '<span class="a-mesure marginrightonly">';
285 }
286 if ($type == '0') {
287 print $langs->trans("StatsByNumberOfUnitsProducts");
288 } elseif ($type == '1') {
289 print $langs->trans("StatsByNumberOfUnitsServices");
290 } else {
291 print $langs->trans("StatsByNumberOfUnits");
292 }
293 if ($mode != 'byunit') {
294 print '</a>';
295 } else {
296 print '</span>';
297 }
298
299 if (!empty($conf->dol_use_jmobile)) {
300 print '</div>'."\n".'<div class="nowrap">'."\n";
301 }
302
303 if ($mode != 'bynumber') {
304 print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=bynumber'.$param.'">';
305 } else {
306 print '<span class="a-mesure marginleftonly marginrightonly">';
307 }
308 print $langs->trans("StatsByNumberOfEntities");
309 if ($mode != 'bynumber') {
310 print '</a>';
311 } else {
312 print '</span>';
313 }
314
315 if (!empty($conf->dol_use_jmobile)) {
316 print '</div>'."\n".'<div class="nowrap">'."\n";
317 }
318
319 if ($mode != 'byamount') {
320 print '<a class="a-mesure-disabled marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?mode=byamount'.$param.'">';
321 } else {
322 print '<span class="a-mesure marginleftonly marginrightonly">';
323 }
324 if ($type == '0') {
325 print $langs->trans("StatsByAmountProducts");
326 } elseif ($type == '1') {
327 print $langs->trans("StatsByAmountServices");
328 } else {
329 print $langs->trans("StatsByAmount");
330 }
331 if ($mode != 'byamount') {
332 print '</a>';
333 } else {
334 print '</span>';
335 }
336
337 // End of choices
338 if (!empty($conf->dol_use_jmobile)) {
339 print '</div></div>';
340 } else {
341 print '<br>';
342 }
343 print '<br>';
344
345 // Generation of graphs
346 $dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]);
347 if ($object->id > 0) { // We are on statistics for a dedicated product
348 if (!file_exists($dir.'/'.$object->id)) {
349 if (dol_mkdir($dir.'/'.$object->id) < 0) {
350 $mesg = $langs->trans("ErrorCanNotCreateDir", $dir);
351 $error++;
352 }
353 }
354 }
355
356 $arrayforlabel = array('byunit' => 'NumberOfUnits', 'bynumber' => 'NumberOf', 'byamount' => 'AmountIn');
357
358 if (isModEnabled('propal')) {
359 $langs->load("propal");
360 $graphfiles['propal'] = array('modulepart' => 'productstats_proposals',
361 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
362 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Proposals")));
363 }
364
365 if (isModEnabled('supplier_proposal')) {
366 $langs->load("supplier_proposal");
367 $graphfiles['proposalssuppliers'] = array('modulepart' => 'productstats_proposalssuppliers',
368 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
369 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierProposals")));
370 }
371
372 if (isModEnabled('order')) {
373 $langs->load("orders");
374 $graphfiles['orders'] = array('modulepart' => 'productstats_orders',
375 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
376 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Orders")));
377 }
378
379 if (isModEnabled('supplier_order')) {
380 $langs->load("orders");
381 $graphfiles['orderssuppliers'] = array('modulepart' => 'productstats_orderssuppliers',
382 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
383 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SuppliersOrders")));
384 }
385
386 if (isModEnabled('invoice')) {
387 $graphfiles['invoices'] = array('modulepart' => 'productstats_invoices',
388 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
389 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Invoices")));
390 }
391
392 if (isModEnabled('supplier_invoice')) {
393 $graphfiles['invoicessuppliers'] = array('modulepart' => 'productstats_invoicessuppliers',
394 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
395 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierInvoices")));
396 }
397
398 if (isModEnabled('contract')) {
399 $graphfiles['contracts'] = array('modulepart' => 'productstats_contracts',
400 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
401 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Contracts")));
402 }
403
404 if (isModEnabled('mrp') && $mode != 'byamount') {
405 $graphfiles['mrp'] = array('modulepart' => 'productstats_mrp',
406 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png',
407 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode]."Mos"));
408 }
409
410 $px = new DolGraph();
411
412 if (!$error && count($graphfiles) > 0) {
413 $mesg = $px->isGraphKo();
414 if (!$mesg) {
415 foreach ($graphfiles as $key => $val) {
416 if (!$graphfiles[$key]['file']) {
417 continue;
418 }
419
420 $graph_data = array();
421
422 if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) {
423 // TODO Load cachefile $graphfiles[$key]['file']
424 } else {
425 $morefilters = '';
426 if ($search_categ > 0) {
427 $categ = new Categorie($db);
428 $categ->fetch($search_categ);
429 $listofprodids = $categ->getObjectsInCateg('product', 1);
430 $morefilters = ' AND d.fk_product IN ('.$db->sanitize((is_array($listofprodids) && count($listofprodids)) ? implode(',', $listofprodids) : '0').')';
431 }
432 if ($search_categ == -2) {
433 $morefilters = ' AND NOT EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE d.fk_product = cp.fk_product)';
434 }
435
436 if ($key == 'propal') {
437 $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
438 }
439 if ($key == 'orders') {
440 $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
441 }
442 if ($key == 'invoices') {
443 $graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
444 }
445 if ($key == 'proposalssuppliers') {
446 $graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
447 }
448 if ($key == 'invoicessuppliers') {
449 $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
450 }
451 if ($key == 'orderssuppliers') {
452 $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
453 }
454 if ($key == 'contracts') {
455 $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
456 }
457 if ($key == 'mrp') {
458 $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
459 }
460
461 // TODO Save cachefile $graphfiles[$key]['file']
462 }
463
464 if (is_array($graph_data)) {
465 $px->SetData($graph_data);
466 $px->SetYLabel($graphfiles[$key]['label']);
467 $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
468 $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue());
469 $px->setShowLegend(0);
470 $px->SetWidth($WIDTH);
471 $px->SetHeight($HEIGHT);
472 $px->SetHorizTickIncrement(1);
473 $px->SetShading(3);
474 //print 'x '.$key.' '.$graphfiles[$key]['file'];
475
476 $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.((int) $object->entity).'&file='.urlencode($graphfiles[$key]['file']).($notab ? '&notab='.$notab : '');
477 $px->draw($dir."/".$graphfiles[$key]['file'], $url);
478
479 $graphfiles[$key]['total'] = $px->total();
480 $graphfiles[$key]['output'] = $px->show();
481 } else {
482 dol_print_error($db, 'Error for calculating graph on key='.$key.' - '.$object->error);
483 }
484 }
485
486 //setEventMessages($langs->trans("ChartGenerated"), null, 'mesgs');
487 }
488 }
489
490 // Show graphs
491 $i = 0;
492 if (count($graphfiles) > 0) {
493 foreach ($graphfiles as $key => $val) {
494 if (!$graphfiles[$key]['file']) {
495 continue;
496 }
497
498 if ($key == 'propal' && !$user->hasRight('propal', 'lire')) {
499 continue;
500 }
501 if ($key == 'order' && !$user->hasRight('commande', 'lire')) {
502 continue;
503 }
504 if ($key == 'invoices' && !$user->hasRight('facture', 'lire')) {
505 continue;
506 }
507 if ($key == 'proposals_suppliers' && !$user->hasRight('supplier_proposal', 'lire')) {
508 continue;
509 }
510 if ($key == 'invoices_suppliers' && !$user->hasRight('fournisseur', 'facture', 'lire')) {
511 continue;
512 }
513 if ($key == 'orders_suppliers' && !$user->hasRight('fournisseur', 'commande', 'lire')) {
514 continue;
515 }
516 if ($key == 'mrp' && !$user->hasRight('mrp', 'read')) {
517 continue;
518 }
519
520
521 if (($i % 2) == 0) {
522 print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
523 } else {
524 print "\n".'<div class="fichehalfright">'."\n";
525 }
526
527 // Date generation
528 if ($graphfiles[$key]['output'] && !$px->isGraphKo()) {
529 if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) {
530 $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour"));
531 } else {
532 $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour"));
533 }
534 } else {
535 $dategenerated = ($mesg ? '<span class="error">'.$mesg.'</span>' : $langs->trans("ChartNotGenerated"));
536 }
537 $linktoregenerate = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?'.(GETPOSTISSET('id') ? 'id='.GETPOSTINT('id') : '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) : '').'">';
538 $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh');
539 $linktoregenerate .= '</a>';
540
541
542 // Show graph
543 print '<div class="div-table-responsive-no-min">';
544 print '<table class="noborder centpercent">';
545 // Label
546 print '<tr class="liste_titre"><td>';
547 print $graphfiles[$key]['label'];
548 print ' <span class="opacitymedium">('.$graphfiles[$key]['total'].')</span></td>';
549 print '<td align="right">'.$linktoregenerate.'</td>';
550 print '</tr>';
551 // Image
552 print '<tr><td colspan="2" class="nohover" align="center">';
553 print $graphfiles[$key]['output'];
554 print '</td></tr>';
555 print '</table>';
556 print '</div>';
557
558 if ($i % 2 == 0) {
559 print "\n".'</div>'."\n";
560 } else {
561 print "\n".'</div></div>';
562 print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
563 }
564
565 $i++;
566 }
567 }
568 // div not closed
569 if ($i % 2 == 1) {
570 print "\n".'<div class="fichehalfright">'."\n";
571 print "\n".'</div></div>';
572 print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
573 }
574}
575
576if (!($id > 0)) {
577 print dol_get_fiche_end();
578}
579
580// End of page
581llxFooter();
582$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage categories.
Class to build graphs.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
dol_is_file($pathoffile)
Return if path is a file.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.