34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
40$type =
GETPOST(
"type",
'intcomma');
41if ($type ==
'' && !$user->hasRight(
'produit',
'lire') && $user->hasRight(
'service',
'lire')) {
44if ($type ==
'' && !$user->hasRight(
'service',
'lire') && $user->hasRight(
'produit',
'lire')) {
49$langs->loadLangs(array(
'products',
'stocks'));
52$hookmanager->initHooks(array(
'productindex'));
55$product_static =
new Product($db);
60} elseif ($type ==
'1') {
63 $result =
restrictedArea($user,
'produit|service|expedition|reception');
71 require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
74 $boxorder =
GETPOST(
'boxorder',
'aZ09');
75 $boxorder .=
GETPOST(
'boxcombo',
'aZ09');
92$transAreaType = $langs->trans(
"ProductsAndServicesArea");
95if (!GETPOSTISSET(
"type")) {
96 $transAreaType = $langs->trans(
"ProductsAndServicesArea");
97 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
99if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'0') || !isModEnabled(
"service")) {
100 $transAreaType = $langs->trans(
"ProductsArea");
101 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
103if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'1') || !isModEnabled(
"product")) {
104 $transAreaType = $langs->trans(
"ServicesArea");
105 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
108llxHeader(
"", $langs->trans(
"ProductsAndServices"), $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-index');
110print
load_fiche_titre($transAreaType, $resultboxes[
'selectboxlist'],
'product');
114 if (!isset($listofsearchfields) || !is_array($listofsearchfields)) {
116 $listofsearchfields = array();
119 if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
120 $listofsearchfields[
'search_product'] = array(
'text' =>
'ProductOrService');
123 if (count($listofsearchfields)) {
124 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
125 print
'<input type="hidden" name="token" value="'.newToken().
'">';
126 print
'<div class="div-table-responsive-no-min">';
127 print
'<table class="noborder nohover centpercent">';
129 foreach ($listofsearchfields as $key => $value) {
131 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
133 print
'<tr class="oddeven">';
134 print
'<td class="nowrap"><label for="'.$key.
'">'.$langs->trans($value[
"text"]).
'</label></td>';
135 print
'<td><input type="text" class="flat inputsearch" name="'.$key.
'" id="'.$key.
'" size="18"></td>';
137 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
153if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
155 $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
156 $prodser[0][
'sell'] = 0;
157 $prodser[0][
'buy'] = 0;
158 $prodser[0][
'none'] = 0;
159 $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0;
160 $prodser[1][
'sell'] = 0;
161 $prodser[1][
'buy'] = 0;
162 $prodser[1][
'none'] = 0;
164 $sql =
"SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
165 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
166 $sql .=
' WHERE p.entity IN ('.getEntity($product_static->element, 1).
')';
168 $parameters = array();
169 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
170 $sql .= $hookmanager->resPrint;
171 $sql .=
" GROUP BY p.fk_product_type, p.tosell, p.tobuy";
172 $result = $db->query($sql);
173 while ($objp = $db->fetch_object($result)) {
175 if (!$objp->tosell && !$objp->tobuy) {
178 if ($objp->tosell && !$objp->tobuy) {
181 if (!$objp->tosell && $objp->tobuy) {
184 $prodser[$objp->fk_product_type][$status] = $objp->total;
186 $prodser[$objp->fk_product_type][
'sell'] += $objp->total;
189 $prodser[$objp->fk_product_type][
'buy'] += $objp->total;
191 if (!$objp->tosell && !$objp->tobuy) {
192 $prodser[$objp->fk_product_type][
'none'] += $objp->total;
196 if ($conf->use_javascript_ajax) {
197 $graph .=
'<div class="div-table-responsive-no-min">';
198 $graph .=
'<table class="noborder centpercent">';
199 $graph .=
'<tr class="liste_titre"><th>'.$langs->trans(
"Statistics").
'</th></tr>';
200 $graph .=
'<tr><td class="center nopaddingleftimp nopaddingrightimp">';
202 $SommeA = $prodser[0][
'sell'];
203 $SommeB = $prodser[0][
'buy'];
204 $SommeC = $prodser[0][
'none'];
205 $SommeD = $prodser[1][
'sell'];
206 $SommeE = $prodser[1][
'buy'];
207 $SommeF = $prodser[1][
'none'];
210 $datalabels = array();
213 $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
214 $dataseries = array();
215 if (isModEnabled(
"product")) {
216 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnSale"), round($SommeA));
217 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnPurchase"), round($SommeB));
218 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsNotOnSell"), round($SommeC));
220 if (isModEnabled(
"service")) {
221 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnSale"), round($SommeD));
222 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnPurchase"), round($SommeE));
223 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesNotOnSell"), round($SommeF));
225 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
227 $dolgraph->SetData($dataseries);
228 $dolgraph->setShowLegend(2);
229 $dolgraph->setShowPercent(0);
230 $dolgraph->SetType(array(
'pie'));
231 $dolgraph->setHeight(
'200');
232 $dolgraph->draw(
'idgraphstatus');
233 $graph .= $dolgraph->show($total ? 0 : 1);
235 $graph .=
'</td></tr>';
236 $graph .=
'</table>';
243if (isModEnabled(
'category') &&
getDolGlobalString(
'CATEGORY_GRAPHSTATS_ON_PRODUCTS') && $user->hasRight(
'categorie',
'read')) {
244 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
246 $graphcat .=
'<div class="div-table-responsive-no-min">';
247 $graphcat .=
'<table class="noborder centpercent">';
248 $graphcat .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
249 $graphcat .=
'<tr><td class="center" colspan="2">';
250 $sql =
"SELECT c.label, count(*) as nb";
251 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_product as cs";
252 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
253 $sql .=
" WHERE c.type = 0";
254 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
255 $sql .=
" GROUP BY c.label";
256 $sql .=
" ORDER BY nb desc";
258 $result = $db->query($sql);
260 $num = $db->num_rows($result);
262 if (!empty($conf->use_javascript_ajax)) {
263 $dataseries = array();
268 $obj = $db->fetch_object($result);
270 $dataseries[] = array($obj->label, round($obj->nb));
278 $dataseries[] = array($langs->transnoentitiesnoconv(
"Other"), round($rest));
280 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
282 $dolgraph->SetData($dataseries);
283 $dolgraph->setShowLegend(2);
284 $dolgraph->setShowPercent(1);
285 $dolgraph->SetType(array(
'pie'));
286 $dolgraph->setHeight(
'200');
287 $dolgraph->draw(
'idstatscategproduct');
288 $graphcat .= $dolgraph->show($total ? 0 : 1);
291 $obj = $db->fetch_object($result);
293 $graphcat .=
'<tr><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
299 $graphcat .=
'</td></tr>';
300 $graphcat .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
302 $graphcat .=
'</td></tr>';
303 $graphcat .=
'</table>';
304 $graphcat .=
'</div>';
312if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
313 $sql =
"SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
314 $sql .=
" p.entity,";
315 $sql .=
" p.tms as datem";
316 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
317 $sql .=
" WHERE p.entity IN (".getEntity($product_static->element, 1).
")";
321 if (!$user->hasRight(
"produit",
"lire")) {
324 if (!$user->hasRight(
"service",
"lire")) {
329 $parameters = array();
330 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
331 $sql .= $hookmanager->resPrint;
332 $sql .= $db->order(
"p.tms",
"DESC");
333 $sql .= $db->plimit($max, 0);
337 $result = $db->query($sql);
339 $num = $db->num_rows($result);
344 $transRecordedType = $langs->trans(
"LastModifiedProductsAndServices", $max);
345 if (!isModEnabled(
'service')) {
346 $transRecordedType = $langs->trans(
"LastRecordedProducts", $max);
348 if (!isModEnabled(
'product')) {
349 $transRecordedType = $langs->trans(
"LastRecordedServices", $max);
352 $lastmodified .=
'<div class="div-table-responsive-no-min">';
353 $lastmodified .=
'<table class="noborder centpercent">';
360 $lastmodified .=
'<tr class="liste_titre"><th colspan="'.$colnb.
'">';
361 $lastmodified .= $transRecordedType;
362 $lastmodified .=
'<a href="'.DOL_URL_ROOT.
'/product/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
363 $lastmodified .=
'<span class="badge marginleftonlyshort">...</span>';
364 $lastmodified .=
'</a>';
373 $lastmodified .=
'</th>';
374 $lastmodified .=
'<th>';
375 $lastmodified .=
'</th>';
376 $lastmodified .=
'<th>';
377 $lastmodified .=
'</th>';
378 $lastmodified .=
'<th>';
379 $lastmodified .=
'</th>';
380 $lastmodified .=
'</tr>';
383 $objp = $db->fetch_object($result);
385 $product_static->id = $objp->rowid;
386 $product_static->ref = $objp->ref;
387 $product_static->label = $objp->label;
388 $product_static->type = $objp->fk_product_type;
389 $product_static->entity = $objp->entity;
390 $product_static->status = $objp->tosell;
391 $product_static->status_buy = $objp->tobuy;
392 $product_static->status_batch = $objp->tobatch;
394 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'read');
395 if ($product_static->isService()) {
396 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'read');
401 $sql =
"SELECT label";
402 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
403 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
404 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
406 $resultd = $db->query($sql);
408 $objtp = $db->fetch_object($resultd);
409 if ($objtp && $objtp->label !=
'') {
410 $objp->label = $objtp->label;
416 $lastmodified .=
'<tr class="oddeven">';
417 $lastmodified .=
'<td class="nowraponall tdoverflowmax100">';
418 $lastmodified .= $product_static->getNomUrl(1);
419 $lastmodified .=
"</td>\n";
420 $lastmodified .=
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->label).
'">'.
dol_escape_htmltag($objp->label).
'</td>';
421 $lastmodified .=
'<td title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($db->jdate($objp->datem),
'dayhour',
'tzuserrel')).
'">';
422 $lastmodified .=
dol_print_date($db->jdate($objp->datem),
'day',
'tzuserrel');
423 $lastmodified .=
"</td>";
426 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
428 $product->fetch($objp->rowid);
430 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
432 $price_result = $priceparser->parseProduct($product);
433 if ($price_result >= 0) {
434 $objp->price = $price_result;
437 $lastmodified .=
'<td class="nowraponall amount right">';
438 if ($usercancreadprice) {
439 if (isset($objp->price_base_type) && $objp->price_base_type ==
'TTC') {
440 $lastmodified .=
price($objp->price_ttc).
' '.$langs->trans(
"TTC");
442 $lastmodified .=
price($objp->price).
' '.$langs->trans(
"HT");
445 $lastmodified .=
'</td>';
447 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefsell">';
448 $lastmodified .= $product_static->LibStatut($objp->tosell, 3, 0);
449 $lastmodified .=
"</span></td>";
450 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefbuy">';
451 $lastmodified .= $product_static->LibStatut($objp->tobuy, 3, 1);
452 $lastmodified .=
"</span></td>";
453 $lastmodified .=
"</tr>\n";
459 $lastmodified .=
"</table>";
460 $lastmodified .=
'</div>';
461 $lastmodified .=
'<br>';
469$latestwarehouse =
'';
470if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'read')) {
471 $sql =
"SELECT e.rowid, e.ref as label, e.lieu, e.statut as status";
472 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
474 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
475 $sql .= $db->order(
'e.tms',
'DESC');
476 $sql .= $db->plimit($max + 1, 0);
478 $result = $db->query($sql);
481 $num = $db->num_rows($result);
483 $latestwarehouse .=
'<div class="div-table-responsive-no-min">';
484 $latestwarehouse .=
'<table class="noborder centpercent">';
485 $latestwarehouse .=
'<tr class="liste_titre">';
486 $latestwarehouse .=
'<th>';
487 $latestwarehouse .= $langs->trans(
"LatestModifiedWarehouses", $max);
492 $latestwarehouse .=
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
493 $latestwarehouse .=
'<span class="badge marginleftonlyshort">...</span>';
494 $latestwarehouse .=
'</a>';
495 $latestwarehouse .=
'</th><th class="right">';
496 $latestwarehouse .=
'</th>';
497 $latestwarehouse .=
'</tr>';
501 while ($i < min($max, $num)) {
502 $objp = $db->fetch_object($result);
504 $warehouse->id = $objp->rowid;
505 $warehouse->statut = $objp->status;
506 $warehouse->label = $objp->label;
507 $warehouse->lieu = $objp->lieu;
509 $latestwarehouse .=
'<tr class="oddeven">';
510 $latestwarehouse .=
'<td>';
511 $latestwarehouse .= $warehouse->getNomUrl(1);
512 $latestwarehouse .=
'</td>'.
"\n";
513 $latestwarehouse .=
'<td class="right">';
514 $latestwarehouse .= $warehouse->getLibStatut(5);
515 $latestwarehouse .=
'</td>';
516 $latestwarehouse .=
"</tr>\n";
521 $latestwarehouse .=
'<tr><td>'.$langs->trans(
"None").
'</td><td></td></tr>';
527 $latestwarehouse .=
"</table>";
528 $latestwarehouse .=
'</div>';
529 $latestwarehouse .=
'<br>';
537if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'read')) {
538 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
540 $sql =
"SELECT p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.tobatch, p.tosell, p.tobuy,";
541 $sql .=
" e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,";
542 $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";
543 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
544 $sql .=
", ".MAIN_DB_PREFIX.
"stock_mouvement as m";
545 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
546 $sql .=
" WHERE m.fk_product = p.rowid";
547 $sql .=
" AND m.fk_entrepot = e.rowid";
548 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
550 $sql .=
" AND p.fk_product_type = ".Product::TYPE_PRODUCT;
552 $sql .= $db->order(
"datem",
"DESC");
553 $sql .= $db->plimit($max, 0);
555 dol_syslog(
"Index:list stock movements", LOG_DEBUG);
557 $resql = $db->query($sql);
559 $num = $db->num_rows($resql);
561 $latestmovement .=
'<div class="div-table-responsive-no-min">';
562 $latestmovement .=
'<table class="noborder centpercent">';
563 $latestmovement .=
'<tr class="liste_titre">';
564 $latestmovement .=
'<th colspan="3">'.$langs->trans(
"LatestStockMovements", min($num, $max));
565 $latestmovement .=
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php">';
566 $latestmovement .=
'<span class="badge marginleftonlyshort">...</span>';
568 $latestmovement .=
'</a>';
569 $latestmovement .=
'</th>';
570 if (isModEnabled(
'productbatch')) {
571 $latestmovement .=
'<th></th>';
573 $latestmovement .=
'<th></th>';
574 $latestmovement .=
'<th class="right">';
575 $latestmovement .=
'</th>';
576 $latestmovement .=
"</tr>\n";
582 while ($i < min($num, $max)) {
583 $objp = $db->fetch_object($resql);
585 $tmpstockmovement->id = $objp->mid;
586 $tmpstockmovement->date = $db->jdate($objp->datem);
587 $tmpstockmovement->label = $objp->mlabel;
588 $tmpstockmovement->inventorycode = $objp->mcode;
589 $tmpstockmovement->qty = $objp->qty;
591 $producttmp->id = $objp->product_id;
592 $producttmp->ref = $objp->product_ref;
593 $producttmp->label = $objp->product_label;
594 $producttmp->status_batch = $objp->tobatch;
595 $producttmp->status_sell = $objp->tosell;
596 $producttmp->status_buy = $objp->tobuy;
598 $warehouse->id = $objp->warehouse_id;
599 $warehouse->ref = $objp->warehouse_ref;
600 $warehouse->statut = $objp->warehouse_status;
601 $warehouse->label = $objp->warehouse_label;
602 $warehouse->lieu = $objp->lieu;
604 $tmplotstatic->batch = $objp->batch;
605 $tmplotstatic->sellby = $objp->sellby;
606 $tmplotstatic->eatby = $objp->eatby;
608 $latestmovement .=
'<tr class="oddeven">';
609 $latestmovement .=
'<td class="nowraponall">';
610 $latestmovement .= $tmpstockmovement->getNomUrl(1);
612 $latestmovement .=
'</td>';
613 $latestmovement .=
'<td class="nowraponall">';
614 $latestmovement .=
dol_print_date($tmpstockmovement->date,
'dayhour',
'tzuserrel');
615 $latestmovement .=
"</td>\n";
616 $latestmovement .=
'<td class="tdoverflowmax150">';
617 $latestmovement .= $producttmp->getNomUrl(1);
618 $latestmovement .=
"</td>\n";
619 if (isModEnabled(
'productbatch')) {
620 $latestmovement .=
'<td>';
621 $latestmovement .= $tmplotstatic->getNomUrl(0,
'nolink');
622 $latestmovement .=
'</td>';
630 $latestmovement .=
'<td class="tdoverflowmax150">';
631 $latestmovement .= $warehouse->getNomUrl(1);
632 $latestmovement .=
"</td>\n";
633 $latestmovement .=
'<td class="right">';
634 if ($objp->qty < 0) {
635 $latestmovement .=
'<span class="stockmovementexit">';
637 if ($objp->qty > 0) {
638 $latestmovement .=
'<span class="stockmovemententry">';
639 $latestmovement .=
'+';
641 $latestmovement .= $objp->qty;
642 $latestmovement .=
'</span>';
643 $latestmovement .=
'</td>';
644 $latestmovement .=
"</tr>\n";
651 if (isModEnabled(
'productbatch')) {
654 $latestmovement .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
657 $latestmovement .=
"</table>";
658 $latestmovement .=
'</div>';
659 $latestmovement .=
'<br>';
669if (isModEnabled(
"invoice") && $user->hasRight(
'facture',
'lire') &&
getDolGlobalString(
'MAIN_SHOW_PRODUCT_ACTIVITY_TRIM')) {
670 if (isModEnabled(
"product")) {
673 if (isModEnabled(
"service")) {
682print
'<div class="clearboth"></div>';
683print
'<div class="fichecenter fichecenterbis">';
685$boxlist =
'<div class="twocolumns">';
687$boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
689$boxlist .= $graphcat;
690$boxlist .= $activity;
692$boxlist .= $resultboxes[
'boxlista'];
693$boxlist .=
"</div>\n";
695$boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
696$boxlist .= $lastmodified;
697$boxlist .= $latestwarehouse;
698$boxlist .= $latestmovement;
699$boxlist .= $resultboxes[
'boxlistb'];
700$boxlist .=
'</div>'.
"\n";
702$boxlist .=
"</div>\n";
708$parameters = array(
'type' => $type,
'user' => $user);
709$reshook = $hookmanager->executeHooks(
'dashboardProductsServices', $parameters, $product_static);
724 global $conf, $langs, $db;
730 $sql =
"SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
731 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"facturedet as fd";
732 $sql .=
" , ".MAIN_DB_PREFIX.
"paiement as p,".MAIN_DB_PREFIX.
"paiement_facture as pf";
733 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
734 $sql .=
" AND f.rowid = fd.fk_facture";
735 $sql .=
" AND pf.fk_facture = f.rowid";
736 $sql .=
" AND pf.fk_paiement = p.rowid";
737 $sql .=
" AND fd.product_type = ".((int) $product_type);
738 $sql .=
" AND p.datep >= '".$db->idate(
dol_get_first_day($yearofbegindate), 1).
"'";
739 $sql .=
" GROUP BY annee, mois ";
740 $sql .=
" ORDER BY annee, mois ";
742 $result = $db->query($sql);
750 $num = $db->num_rows($result);
753 $out .=
'<div class="div-table-responsive-no-min">';
754 $out .=
'<table class="noborder" width="75%">';
756 if ($product_type == 0) {
757 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ProductSellByQuarterHT").
'</td>';
759 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ServiceSellByQuarterHT").
'</td>';
761 $out .=
'<td class=right>'.$langs->trans(
"Quarter1").
'</td>';
762 $out .=
'<td class=right>'.$langs->trans(
"Quarter2").
'</td>';
763 $out .=
'<td class=right>'.$langs->trans(
"Quarter3").
'</td>';
764 $out .=
'<td class=right>'.$langs->trans(
"Quarter4").
'</td>';
765 $out .=
'<td class=right>'.$langs->trans(
"Total").
'</td>';
771 $objp = $db->fetch_object($result);
772 if ($tmpyear != $objp->annee) {
773 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
774 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
775 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
776 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
777 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
778 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
779 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
784 $tmpyear = $objp->annee;
791 if ($objp->mois ==
"01" || $objp->mois ==
"02" || $objp->mois ==
"03") {
792 $trim1 += $objp->Mnttot;
795 if ($objp->mois ==
"04" || $objp->mois ==
"05" || $objp->mois ==
"06") {
796 $trim2 += $objp->Mnttot;
799 if ($objp->mois ==
"07" || $objp->mois ==
"08" || $objp->mois ==
"09") {
800 $trim3 += $objp->Mnttot;
803 if ($objp->mois ==
"10" || $objp->mois ==
"11" || $objp->mois ==
"12") {
804 $trim4 += $objp->Mnttot;
809 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
810 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
811 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
812 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
813 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
814 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
815 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
819 $out .=
'</table></div>';
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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 a 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.