33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
39$type =
GETPOST(
"type",
'intcomma');
40if ($type ==
'' && !$user->hasRight(
'produit',
'lire') && $user->hasRight(
'service',
'lire')) {
43if ($type ==
'' && !$user->hasRight(
'service',
'lire') && $user->hasRight(
'produit',
'lire')) {
48$langs->loadLangs(array(
'products',
'stocks'));
51$hookmanager->initHooks(array(
'productindex'));
54$product_static =
new Product($db);
59} elseif ($type ==
'1') {
62 $result =
restrictedArea($user,
'produit|service|expedition|reception');
70 require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
71 $zone =
GETPOST(
'areacode',
'int');
72 $userid =
GETPOST(
'userid',
'int');
73 $boxorder =
GETPOST(
'boxorder',
'aZ09');
74 $boxorder .=
GETPOST(
'boxcombo',
'aZ09');
91$transAreaType = $langs->trans(
"ProductsAndServicesArea");
94if (!GETPOSTISSET(
"type")) {
95 $transAreaType = $langs->trans(
"ProductsAndServicesArea");
96 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
98if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'0') || !isModEnabled(
"service")) {
99 $transAreaType = $langs->trans(
"ProductsArea");
100 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
102if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'1') || !isModEnabled(
"product")) {
103 $transAreaType = $langs->trans(
"ServicesArea");
104 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
107llxHeader(
"", $langs->trans(
"ProductsAndServices"), $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-index');
109print
load_fiche_titre($transAreaType, $resultboxes[
'selectboxlist'],
'product');
113 if (!isset($listofsearchfields) || !is_array($listofsearchfields)) {
115 $listofsearchfields = array();
118 if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
119 $listofsearchfields[
'search_product'] = array(
'text' =>
'ProductOrService');
122 if (count($listofsearchfields)) {
123 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
124 print
'<input type="hidden" name="token" value="'.newToken().
'">';
125 print
'<div class="div-table-responsive-no-min">';
126 print
'<table class="noborder nohover centpercent">';
128 foreach ($listofsearchfields as $key => $value) {
130 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
132 print
'<tr class="oddeven">';
133 print
'<td class="nowrap"><label for="'.$key.
'">'.$langs->trans($value[
"text"]).
'</label></td>';
134 print
'<td><input type="text" class="flat inputsearch" name="'.$key.
'" id="'.$key.
'" size="18"></td>';
136 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
152if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
154 $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
155 $prodser[0][
'sell'] = 0;
156 $prodser[0][
'buy'] = 0;
157 $prodser[0][
'none'] = 0;
158 $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0;
159 $prodser[1][
'sell'] = 0;
160 $prodser[1][
'buy'] = 0;
161 $prodser[1][
'none'] = 0;
163 $sql =
"SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
165 $sql .=
' WHERE p.entity IN ('.getEntity($product_static->element, 1).
')';
167 $parameters = array();
168 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
169 $sql .= $hookmanager->resPrint;
170 $sql .=
" GROUP BY p.fk_product_type, p.tosell, p.tobuy";
171 $result = $db->query($sql);
172 while ($objp = $db->fetch_object($result)) {
174 if (!$objp->tosell && !$objp->tobuy) {
177 if ($objp->tosell && !$objp->tobuy) {
180 if (!$objp->tosell && $objp->tobuy) {
183 $prodser[$objp->fk_product_type][$status] = $objp->total;
185 $prodser[$objp->fk_product_type][
'sell'] += $objp->total;
188 $prodser[$objp->fk_product_type][
'buy'] += $objp->total;
190 if (!$objp->tosell && !$objp->tobuy) {
191 $prodser[$objp->fk_product_type][
'none'] += $objp->total;
195 if ($conf->use_javascript_ajax) {
196 $graph .=
'<div class="div-table-responsive-no-min">';
197 $graph .=
'<table class="noborder centpercent">';
198 $graph .=
'<tr class="liste_titre"><th>'.$langs->trans(
"Statistics").
'</th></tr>';
199 $graph .=
'<tr><td class="center nopaddingleftimp nopaddingrightimp">';
201 $SommeA = $prodser[0][
'sell'];
202 $SommeB = $prodser[0][
'buy'];
203 $SommeC = $prodser[0][
'none'];
204 $SommeD = $prodser[1][
'sell'];
205 $SommeE = $prodser[1][
'buy'];
206 $SommeF = $prodser[1][
'none'];
209 $datalabels = array();
212 $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
213 $dataseries = array();
214 if (isModEnabled(
"product")) {
215 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnSale"), round($SommeA));
216 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnPurchase"), round($SommeB));
217 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsNotOnSell"), round($SommeC));
219 if (isModEnabled(
"service")) {
220 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnSale"), round($SommeD));
221 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnPurchase"), round($SommeE));
222 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesNotOnSell"), round($SommeF));
224 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
226 $dolgraph->SetData($dataseries);
227 $dolgraph->setShowLegend(2);
228 $dolgraph->setShowPercent(0);
229 $dolgraph->SetType(array(
'pie'));
230 $dolgraph->setHeight(
'200');
231 $dolgraph->draw(
'idgraphstatus');
232 $graph .= $dolgraph->show($total ? 0 : 1);
234 $graph .=
'</td></tr>';
235 $graph .=
'</table>';
242if (isModEnabled(
'category') &&
getDolGlobalString(
'CATEGORY_GRAPHSTATS_ON_PRODUCTS') && $user->hasRight(
'categorie',
'read')) {
243 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
245 $graphcat .=
'<div class="div-table-responsive-no-min">';
246 $graphcat .=
'<table class="noborder centpercent">';
247 $graphcat .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
248 $graphcat .=
'<tr><td class="center" colspan="2">';
249 $sql =
"SELECT c.label, count(*) as nb";
250 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_product as cs";
251 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
252 $sql .=
" WHERE c.type = 0";
253 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
254 $sql .=
" GROUP BY c.label";
255 $sql .=
" ORDER BY nb desc";
257 $result = $db->query($sql);
259 $num = $db->num_rows($result);
261 if (!empty($conf->use_javascript_ajax)) {
262 $dataseries = array();
267 $obj = $db->fetch_object($result);
269 $dataseries[] = array($obj->label, round($obj->nb));
277 $dataseries[] = array($langs->transnoentitiesnoconv(
"Other"), round($rest));
279 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
281 $dolgraph->SetData($dataseries);
282 $dolgraph->setShowLegend(2);
283 $dolgraph->setShowPercent(1);
284 $dolgraph->SetType(array(
'pie'));
285 $dolgraph->setHeight(
'200');
286 $dolgraph->draw(
'idstatscategproduct');
287 $graphcat .= $dolgraph->show($total ? 0 : 1);
290 $obj = $db->fetch_object($result);
292 $graphcat .=
'<tr><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
298 $graphcat .=
'</td></tr>';
299 $graphcat .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
301 $graphcat .=
'</td></tr>';
302 $graphcat .=
'</table>';
303 $graphcat .=
'</div>';
311if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
312 $sql =
"SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
313 $sql .=
" p.entity,";
314 $sql .=
" p.tms as datem";
315 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
316 $sql .=
" WHERE p.entity IN (".getEntity($product_static->element, 1).
")";
320 if (!$user->hasRight(
"produit",
"lire")) {
323 if (!$user->hasRight(
"service",
"lire")) {
328 $parameters = array();
329 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
330 $sql .= $hookmanager->resPrint;
331 $sql .= $db->order(
"p.tms",
"DESC");
332 $sql .= $db->plimit($max, 0);
336 $result = $db->query($sql);
338 $num = $db->num_rows($result);
343 $transRecordedType = $langs->trans(
"LastModifiedProductsAndServices", $max);
344 if (!isModEnabled(
'service')) {
345 $transRecordedType = $langs->trans(
"LastRecordedProducts", $max);
347 if (!isModEnabled(
'product')) {
348 $transRecordedType = $langs->trans(
"LastRecordedServices", $max);
351 $lastmodified .=
'<div class="div-table-responsive-no-min">';
352 $lastmodified .=
'<table class="noborder centpercent">';
359 $lastmodified .=
'<tr class="liste_titre"><th colspan="'.$colnb.
'">';
360 $lastmodified .= $transRecordedType;
361 $lastmodified .=
'<a href="'.DOL_URL_ROOT.
'/product/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
362 $lastmodified .=
'<span class="badge marginleftonlyshort">...</span>';
363 $lastmodified .=
'</a>';
372 $lastmodified .=
'</th>';
373 $lastmodified .=
'<th>';
374 $lastmodified .=
'</th>';
375 $lastmodified .=
'<th>';
376 $lastmodified .=
'</th>';
377 $lastmodified .=
'<th>';
378 $lastmodified .=
'</th>';
379 $lastmodified .=
'</tr>';
382 $objp = $db->fetch_object($result);
384 $product_static->id = $objp->rowid;
385 $product_static->ref = $objp->ref;
386 $product_static->label = $objp->label;
387 $product_static->type = $objp->fk_product_type;
388 $product_static->entity = $objp->entity;
389 $product_static->status = $objp->tosell;
390 $product_static->status_buy = $objp->tobuy;
391 $product_static->status_batch = $objp->tobatch;
393 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'read');
394 if ($product_static->isService()) {
395 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'read');
400 $sql =
"SELECT label";
401 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
402 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
403 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
405 $resultd = $db->query($sql);
407 $objtp = $db->fetch_object($resultd);
408 if ($objtp && $objtp->label !=
'') {
409 $objp->label = $objtp->label;
415 $lastmodified .=
'<tr class="oddeven">';
416 $lastmodified .=
'<td class="nowraponall tdoverflowmax100">';
417 $lastmodified .= $product_static->getNomUrl(1);
418 $lastmodified .=
"</td>\n";
419 $lastmodified .=
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->label).
'">'.
dol_escape_htmltag($objp->label).
'</td>';
420 $lastmodified .=
'<td title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($db->jdate($objp->datem),
'dayhour',
'tzuserrel')).
'">';
421 $lastmodified .=
dol_print_date($db->jdate($objp->datem),
'day',
'tzuserrel');
422 $lastmodified .=
"</td>";
425 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
427 $product->fetch($objp->rowid);
429 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
431 $price_result = $priceparser->parseProduct($product);
432 if ($price_result >= 0) {
433 $objp->price = $price_result;
436 $lastmodified .=
'<td class="nowraponall amount right">';
437 if ($usercancreadprice) {
438 if (isset($objp->price_base_type) && $objp->price_base_type ==
'TTC') {
439 $lastmodified .=
price($objp->price_ttc).
' '.$langs->trans(
"TTC");
441 $lastmodified .=
price($objp->price).
' '.$langs->trans(
"HT");
444 $lastmodified .=
'</td>';
446 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefsell">';
447 $lastmodified .= $product_static->LibStatut($objp->tosell, 3, 0);
448 $lastmodified .=
"</span></td>";
449 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefbuy">';
450 $lastmodified .= $product_static->LibStatut($objp->tobuy, 3, 1);
451 $lastmodified .=
"</span></td>";
452 $lastmodified .=
"</tr>\n";
458 $lastmodified .=
"</table>";
459 $lastmodified .=
'</div>';
460 $lastmodified .=
'<br>';
468$latestwarehouse =
'';
469if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'read')) {
470 $sql =
"SELECT e.rowid, e.ref as label, e.lieu, e.statut as status";
471 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
473 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
474 $sql .= $db->order(
'e.tms',
'DESC');
475 $sql .= $db->plimit($max + 1, 0);
477 $result = $db->query($sql);
480 $num = $db->num_rows($result);
482 $latestwarehouse .=
'<div class="div-table-responsive-no-min">';
483 $latestwarehouse .=
'<table class="noborder centpercent">';
484 $latestwarehouse .=
'<tr class="liste_titre">';
485 $latestwarehouse .=
'<th>';
486 $latestwarehouse .= $langs->trans(
"LatestModifiedWarehouses", $max);
491 $latestwarehouse .=
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
492 $latestwarehouse .=
'<span class="badge marginleftonlyshort">...</span>';
493 $latestwarehouse .=
'</a>';
494 $latestwarehouse .=
'</th><th class="right">';
495 $latestwarehouse .=
'</th>';
496 $latestwarehouse .=
'</tr>';
500 while ($i < min($max, $num)) {
501 $objp = $db->fetch_object($result);
503 $warehouse->id = $objp->rowid;
504 $warehouse->statut = $objp->status;
505 $warehouse->label = $objp->label;
506 $warehouse->lieu = $objp->lieu;
508 $latestwarehouse .=
'<tr class="oddeven">';
509 $latestwarehouse .=
'<td>';
510 $latestwarehouse .= $warehouse->getNomUrl(1);
511 $latestwarehouse .=
'</td>'.
"\n";
512 $latestwarehouse .=
'<td class="right">';
513 $latestwarehouse .= $warehouse->getLibStatut(5);
514 $latestwarehouse .=
'</td>';
515 $latestwarehouse .=
"</tr>\n";
520 $latestwarehouse .=
'<tr><td>'.$langs->trans(
"None").
'</td><td></td></tr>';
526 $latestwarehouse .=
"</table>";
527 $latestwarehouse .=
'</div>';
528 $latestwarehouse .=
'<br>';
536if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'read')) {
537 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
539 $sql =
"SELECT p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.tobatch, p.tosell, p.tobuy,";
540 $sql .=
" e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,";
541 $sql .=
" m.rowid as mid, m.label as mlabel, m.inventorycode as mcode, m.value as qty, m.datem, m.batch, m.eatby, m.sellby";
542 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
543 $sql .=
", ".MAIN_DB_PREFIX.
"stock_mouvement as m";
544 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
545 $sql .=
" WHERE m.fk_product = p.rowid";
546 $sql .=
" AND m.fk_entrepot = e.rowid";
547 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
549 $sql .=
" AND p.fk_product_type = ".Product::TYPE_PRODUCT;
551 $sql .= $db->order(
"datem",
"DESC");
552 $sql .= $db->plimit($max, 0);
554 dol_syslog(
"Index:list stock movements", LOG_DEBUG);
556 $resql = $db->query($sql);
558 $num = $db->num_rows($resql);
560 $latestmovement .=
'<div class="div-table-responsive-no-min">';
561 $latestmovement .=
'<table class="noborder centpercent">';
562 $latestmovement .=
'<tr class="liste_titre">';
563 $latestmovement .=
'<th colspan="3">'.$langs->trans(
"LatestStockMovements", min($num, $max));
564 $latestmovement .=
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php">';
565 $latestmovement .=
'<span class="badge marginleftonlyshort">...</span>';
567 $latestmovement .=
'</a>';
568 $latestmovement .=
'</th>';
569 if (isModEnabled(
'productbatch')) {
570 $latestmovement .=
'<th></th>';
572 $latestmovement .=
'<th></th>';
573 $latestmovement .=
'<th class="right">';
574 $latestmovement .=
'</th>';
575 $latestmovement .=
"</tr>\n";
581 while ($i < min($num, $max)) {
582 $objp = $db->fetch_object($resql);
584 $tmpstockmovement->id = $objp->mid;
585 $tmpstockmovement->date = $db->jdate($objp->datem);
586 $tmpstockmovement->label = $objp->mlabel;
587 $tmpstockmovement->inventorycode = $objp->mcode;
588 $tmpstockmovement->qty = $objp->qty;
590 $producttmp->id = $objp->product_id;
591 $producttmp->ref = $objp->product_ref;
592 $producttmp->label = $objp->product_label;
593 $producttmp->status_batch = $objp->tobatch;
594 $producttmp->status_sell = $objp->tosell;
595 $producttmp->status_buy = $objp->tobuy;
597 $warehouse->id = $objp->warehouse_id;
598 $warehouse->ref = $objp->warehouse_ref;
599 $warehouse->statut = $objp->warehouse_status;
600 $warehouse->label = $objp->warehouse_label;
601 $warehouse->lieu = $objp->lieu;
603 $tmplotstatic->batch = $objp->batch;
604 $tmplotstatic->sellby = $objp->sellby;
605 $tmplotstatic->eatby = $objp->eatby;
607 $latestmovement .=
'<tr class="oddeven">';
608 $latestmovement .=
'<td class="nowraponall">';
609 $latestmovement .= $tmpstockmovement->getNomUrl(1);
611 $latestmovement .=
'</td>';
612 $latestmovement .=
'<td class="nowraponall">';
613 $latestmovement .=
dol_print_date($tmpstockmovement->date,
'dayhour',
'tzuserrel');
614 $latestmovement .=
"</td>\n";
615 $latestmovement .=
'<td class="tdoverflowmax150">';
616 $latestmovement .= $producttmp->getNomUrl(1);
617 $latestmovement .=
"</td>\n";
618 if (isModEnabled(
'productbatch')) {
619 $latestmovement .=
'<td>';
620 $latestmovement .= $tmplotstatic->getNomUrl(0,
'nolink');
621 $latestmovement .=
'</td>';
629 $latestmovement .=
'<td class="tdoverflowmax150">';
630 $latestmovement .= $warehouse->getNomUrl(1);
631 $latestmovement .=
"</td>\n";
632 $latestmovement .=
'<td class="right">';
633 if ($objp->qty < 0) {
634 $latestmovement .=
'<span class="stockmovementexit">';
636 if ($objp->qty > 0) {
637 $latestmovement .=
'<span class="stockmovemententry">';
638 $latestmovement .=
'+';
640 $latestmovement .= $objp->qty;
641 $latestmovement .=
'</span>';
642 $latestmovement .=
'</td>';
643 $latestmovement .=
"</tr>\n";
650 if (isModEnabled(
'productbatch')) {
653 $latestmovement .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
656 $latestmovement .=
"</table>";
657 $latestmovement .=
'</div>';
658 $latestmovement .=
'<br>';
668if (isModEnabled(
"invoice") && $user->hasRight(
'facture',
'lire') &&
getDolGlobalString(
'MAIN_SHOW_PRODUCT_ACTIVITY_TRIM')) {
669 if (isModEnabled(
"product")) {
672 if (isModEnabled(
"service")) {
681print
'<div class="clearboth"></div>';
682print
'<div class="fichecenter fichecenterbis">';
684$boxlist =
'<div class="twocolumns">';
686$boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
688$boxlist .= $graphcat;
689$boxlist .= $activity;
691$boxlist .= $resultboxes[
'boxlista'];
692$boxlist .=
"</div>\n";
694$boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
695$boxlist .= $lastmodified;
696$boxlist .= $latestwarehouse;
697$boxlist .= $latestmovement;
698$boxlist .= $resultboxes[
'boxlistb'];
699$boxlist .=
'</div>'.
"\n";
701$boxlist .=
"</div>\n";
707$parameters = array(
'type' => $type,
'user' => $user);
708$reshook = $hookmanager->executeHooks(
'dashboardProductsServices', $parameters, $product_static);
723 global $conf, $langs, $db;
729 $sql =
"SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
730 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"facturedet as fd";
731 $sql .=
" , ".MAIN_DB_PREFIX.
"paiement as p,".MAIN_DB_PREFIX.
"paiement_facture as pf";
732 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
733 $sql .=
" AND f.rowid = fd.fk_facture";
734 $sql .=
" AND pf.fk_facture = f.rowid";
735 $sql .=
" AND pf.fk_paiement = p.rowid";
736 $sql .=
" AND fd.product_type = ".((int) $product_type);
737 $sql .=
" AND p.datep >= '".$db->idate(
dol_get_first_day($yearofbegindate), 1).
"'";
738 $sql .=
" GROUP BY annee, mois ";
739 $sql .=
" ORDER BY annee, mois ";
741 $result = $db->query($sql);
749 $num = $db->num_rows($result);
752 $out .=
'<div class="div-table-responsive-no-min">';
753 $out .=
'<table class="noborder" width="75%">';
755 if ($product_type == 0) {
756 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ProductSellByQuarterHT").
'</td>';
758 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ServiceSellByQuarterHT").
'</td>';
760 $out .=
'<td class=right>'.$langs->trans(
"Quarter1").
'</td>';
761 $out .=
'<td class=right>'.$langs->trans(
"Quarter2").
'</td>';
762 $out .=
'<td class=right>'.$langs->trans(
"Quarter3").
'</td>';
763 $out .=
'<td class=right>'.$langs->trans(
"Quarter4").
'</td>';
764 $out .=
'<td class=right>'.$langs->trans(
"Total").
'</td>';
770 $objp = $db->fetch_object($result);
771 if ($tmpyear != $objp->annee) {
772 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
773 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
774 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
775 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
776 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
777 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
778 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
783 $tmpyear = $objp->annee;
790 if ($objp->mois ==
"01" || $objp->mois ==
"02" || $objp->mois ==
"03") {
791 $trim1 += $objp->Mnttot;
794 if ($objp->mois ==
"04" || $objp->mois ==
"05" || $objp->mois ==
"06") {
795 $trim2 += $objp->Mnttot;
798 if ($objp->mois ==
"07" || $objp->mois ==
"08" || $objp->mois ==
"09") {
799 $trim3 += $objp->Mnttot;
802 if ($objp->mois ==
"10" || $objp->mois ==
"11" || $objp->mois ==
"12") {
803 $trim4 += $objp->Mnttot;
808 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
809 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
810 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
811 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
812 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
813 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
814 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
818 $out .=
'</table></div>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
const STATUS_OPEN_ALL
Warehouse open and any operations are allowed (customer shipping, supplier dispatch,...
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Class to manage stock movements.
Class to parse product price expressions.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class with list of lots and properties.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
activitytrim($product_type)
Print html activity for product type.
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.