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';
48$type =
GETPOST(
"type",
'intcomma');
49if ($type ==
'' && !$user->hasRight(
'produit',
'lire') && $user->hasRight(
'service',
'lire')) {
52if ($type ==
'' && !$user->hasRight(
'service',
'lire') && $user->hasRight(
'produit',
'lire')) {
57$langs->loadLangs(array(
'products',
'stocks'));
60$hookmanager->initHooks(array(
'productindex'));
63$product_static =
new Product($db);
68} elseif ($type ==
'1') {
71 $result =
restrictedArea($user,
'produit|service|expedition|reception');
79 require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
82 $boxorder =
GETPOST(
'boxorder',
'aZ09');
83 $boxorder .=
GETPOST(
'boxcombo',
'aZ09');
100$transAreaType = $langs->trans(
"ProductsAndServicesArea");
103if (!GETPOSTISSET(
"type")) {
104 $transAreaType = $langs->trans(
"ProductsAndServicesArea");
105 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
107if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'0') || !isModEnabled(
"service")) {
108 $transAreaType = $langs->trans(
"ProductsArea");
109 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
111if ((GETPOSTISSET(
"type") &&
GETPOST(
"type") ==
'1') || !isModEnabled(
"product")) {
112 $transAreaType = $langs->trans(
"ServicesArea");
113 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
116llxHeader(
"", $langs->trans(
"ProductsAndServices"), $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-index');
118print
load_fiche_titre($transAreaType, $resultboxes[
'selectboxlist'],
'product');
122 if (!isset($listofsearchfields) || !is_array($listofsearchfields)) {
124 $listofsearchfields = array();
127 if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
128 $listofsearchfields[
'search_product'] = array(
'text' =>
'ProductOrService');
131 if (count($listofsearchfields)) {
132 print
'<form method="post" action="'.DOL_URL_ROOT.
'/core/search.php">';
133 print
'<input type="hidden" name="token" value="'.newToken().
'">';
134 print
'<div class="div-table-responsive-no-min">';
135 print
'<table class="noborder nohover centpercent">';
137 foreach ($listofsearchfields as $key => $value) {
139 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Search").
'</td></tr>';
141 print
'<tr class="oddeven">';
142 print
'<td class="nowrap"><label for="'.$key.
'">'.$langs->trans($value[
"text"]).
'</label></td>';
143 print
'<td><input type="text" class="flat inputsearch" name="'.$key.
'" id="'.$key.
'" size="18"></td>';
145 print
'<td rowspan="'.count($listofsearchfields).
'"><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
161if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
163 $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
164 $prodser[0][
'sell'] = 0;
165 $prodser[0][
'buy'] = 0;
166 $prodser[0][
'none'] = 0;
167 $prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0;
168 $prodser[1][
'sell'] = 0;
169 $prodser[1][
'buy'] = 0;
170 $prodser[1][
'none'] = 0;
172 $sql =
"SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
173 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
174 $sql .=
' WHERE p.entity IN ('.getEntity($product_static->element, 1).
')';
176 $parameters = array();
177 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
178 $sql .= $hookmanager->resPrint;
179 $sql .=
" GROUP BY p.fk_product_type, p.tosell, p.tobuy";
180 $result = $db->query($sql);
181 while ($objp = $db->fetch_object($result)) {
183 if (!$objp->tosell && !$objp->tobuy) {
186 if ($objp->tosell && !$objp->tobuy) {
189 if (!$objp->tosell && $objp->tobuy) {
192 $prodser[$objp->fk_product_type][$status] = $objp->total;
194 $prodser[$objp->fk_product_type][
'sell'] += $objp->total;
197 $prodser[$objp->fk_product_type][
'buy'] += $objp->total;
199 if (!$objp->tosell && !$objp->tobuy) {
200 $prodser[$objp->fk_product_type][
'none'] += $objp->total;
204 if (
$conf->use_javascript_ajax) {
205 $graph .=
'<div class="div-table-responsive-no-min">';
206 $graph .=
'<table class="noborder centpercent">';
207 $graph .=
'<tr class="liste_titre"><th>'.$langs->trans(
"Statistics").
'</th></tr>';
208 $graph .=
'<tr><td class="center nopaddingleftimp nopaddingrightimp">';
210 $SommeA = $prodser[0][
'sell'];
211 $SommeB = $prodser[0][
'buy'];
212 $SommeC = $prodser[0][
'none'];
213 $SommeD = $prodser[1][
'sell'];
214 $SommeE = $prodser[1][
'buy'];
215 $SommeF = $prodser[1][
'none'];
218 $datalabels = array();
221 $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
222 $dataseries = array();
223 if (isModEnabled(
"product")) {
224 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnSale"), round($SommeA));
225 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsOnPurchase"), round($SommeB));
226 $dataseries[] = array($langs->transnoentitiesnoconv(
"ProductsNotOnSell"), round($SommeC));
228 if (isModEnabled(
"service")) {
229 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnSale"), round($SommeD));
230 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesOnPurchase"), round($SommeE));
231 $dataseries[] = array($langs->transnoentitiesnoconv(
"ServicesNotOnSell"), round($SommeF));
233 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
235 $dolgraph->SetData($dataseries);
236 $dolgraph->setShowLegend(2);
237 $dolgraph->setShowPercent(0);
238 $dolgraph->SetType(array(
'pie'));
239 $dolgraph->setHeight(
'200');
240 $dolgraph->draw(
'idgraphstatus');
241 $graph .= $dolgraph->show($total ? 0 : 1);
243 $graph .=
'</td></tr>';
244 $graph .=
'</table>';
251if (isModEnabled(
'category') &&
getDolGlobalString(
'CATEGORY_GRAPHSTATS_ON_PRODUCTS') && $user->hasRight(
'categorie',
'read')) {
252 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
254 $graphcat .=
'<div class="div-table-responsive-no-min">';
255 $graphcat .=
'<table class="noborder centpercent">';
256 $graphcat .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
257 $graphcat .=
'<tr><td class="center" colspan="2">';
258 $sql =
"SELECT c.label, count(*) as nb";
259 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_product as cs";
260 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
261 $sql .=
" WHERE c.type = 0";
262 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
263 $sql .=
" GROUP BY c.label";
264 $sql .=
" ORDER BY nb desc";
266 $result = $db->query($sql);
268 $num = $db->num_rows($result);
270 if (!empty(
$conf->use_javascript_ajax)) {
271 $dataseries = array();
276 $obj = $db->fetch_object($result);
278 $dataseries[] = array($obj->label, round($obj->nb));
286 $dataseries[] = array($langs->transnoentitiesnoconv(
"Other"), round($rest));
288 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
290 $dolgraph->SetData($dataseries);
291 $dolgraph->setShowLegend(2);
292 $dolgraph->setShowPercent(1);
293 $dolgraph->SetType(array(
'pie'));
294 $dolgraph->setHeight(
'200');
295 $dolgraph->draw(
'idstatscategproduct');
296 $graphcat .= $dolgraph->show($total ? 0 : 1);
299 $obj = $db->fetch_object($result);
301 $graphcat .=
'<tr><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
307 $graphcat .=
'</td></tr>';
308 $graphcat .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
310 $graphcat .=
'</td></tr>';
311 $graphcat .=
'</table>';
312 $graphcat .=
'</div>';
320if ((isModEnabled(
"product") || isModEnabled(
"service")) && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
321 $sql =
"SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
322 $sql .=
" p.entity,";
323 $sql .=
" p.tms as datem";
324 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
325 $sql .=
" WHERE p.entity IN (".getEntity($product_static->element, 1).
")";
329 if (!$user->hasRight(
"produit",
"lire")) {
332 if (!$user->hasRight(
"service",
"lire")) {
337 $parameters = array();
338 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $product_static);
339 $sql .= $hookmanager->resPrint;
340 $sql .= $db->order(
"p.tms",
"DESC");
341 $sql .= $db->plimit($max, 0);
345 $result = $db->query($sql);
347 $num = $db->num_rows($result);
352 $transRecordedType = $langs->trans(
"LastModifiedProductsAndServices", $max);
353 if (!isModEnabled(
'service')) {
354 $transRecordedType = $langs->trans(
"LastRecordedProducts", $max);
356 if (!isModEnabled(
'product')) {
357 $transRecordedType = $langs->trans(
"LastRecordedServices", $max);
360 $lastmodified .=
'<div class="div-table-responsive-no-min">';
361 $lastmodified .=
'<table class="noborder centpercent">';
368 $lastmodified .=
'<tr class="liste_titre"><th colspan="'.$colnb.
'">';
369 $lastmodified .= $transRecordedType;
370 $lastmodified .=
'<a href="'.DOL_URL_ROOT.
'/product/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
371 $lastmodified .=
'<span class="badge marginleftonlyshort">...</span>';
372 $lastmodified .=
'</a>';
381 $lastmodified .=
'</th>';
382 $lastmodified .=
'<th>';
383 $lastmodified .=
'</th>';
384 $lastmodified .=
'<th>';
385 $lastmodified .=
'</th>';
386 $lastmodified .=
'<th>';
387 $lastmodified .=
'</th>';
388 $lastmodified .=
'</tr>';
391 $objp = $db->fetch_object($result);
393 $product_static->id = $objp->rowid;
394 $product_static->ref = $objp->ref;
395 $product_static->label = $objp->label;
396 $product_static->type = $objp->fk_product_type;
397 $product_static->entity = $objp->entity;
398 $product_static->status = $objp->tosell;
399 $product_static->status_buy = $objp->tobuy;
400 $product_static->status_batch = $objp->tobatch;
402 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'read');
403 if ($product_static->isService()) {
404 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'read');
409 $sql =
"SELECT label";
410 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
411 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
412 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
414 $resultd = $db->query($sql);
416 $objtp = $db->fetch_object($resultd);
417 if ($objtp && $objtp->label !=
'') {
418 $objp->label = $objtp->label;
424 $lastmodified .=
'<tr class="oddeven">';
425 $lastmodified .=
'<td class="nowraponall tdoverflowmax100">';
426 $lastmodified .= $product_static->getNomUrl(1);
427 $lastmodified .=
"</td>\n";
428 $lastmodified .=
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->label).
'">'.
dol_escape_htmltag($objp->label).
'</td>';
429 $lastmodified .=
'<td title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($db->jdate($objp->datem),
'dayhour',
'tzuserrel')).
'">';
430 $lastmodified .=
dol_print_date($db->jdate($objp->datem),
'day',
'tzuserrel');
431 $lastmodified .=
"</td>";
434 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
436 $product->fetch($objp->rowid);
438 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
440 $price_result = $priceparser->parseProduct($product);
441 if ($price_result >= 0) {
442 $objp->price = $price_result;
445 $lastmodified .=
'<td class="nowraponall amount right">';
446 if ($usercancreadprice) {
447 if (isset($objp->price_base_type) && $objp->price_base_type ==
'TTC') {
448 $lastmodified .=
price($objp->price_ttc).
' '.$langs->trans(
"TTC");
450 $lastmodified .=
price($objp->price).
' '.$langs->trans(
"HT");
453 $lastmodified .=
'</td>';
455 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefsell">';
456 $lastmodified .= $product_static->LibStatut($objp->tosell, 3, 0);
457 $lastmodified .=
"</span></td>";
458 $lastmodified .=
'<td class="right nowrap width25"><span class="statusrefbuy">';
459 $lastmodified .= $product_static->LibStatut($objp->tobuy, 3, 1);
460 $lastmodified .=
"</span></td>";
461 $lastmodified .=
"</tr>\n";
467 $lastmodified .=
"</table>";
468 $lastmodified .=
'</div>';
469 $lastmodified .=
'<br>';
477$latestwarehouse =
'';
478if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'read')) {
479 $sql =
"SELECT e.rowid, e.ref as label, e.lieu, e.statut as status";
480 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
482 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
483 $sql .= $db->order(
'e.tms',
'DESC');
484 $sql .= $db->plimit($max + 1, 0);
486 $result = $db->query($sql);
489 $num = $db->num_rows($result);
491 $latestwarehouse .=
'<div class="div-table-responsive-no-min">';
492 $latestwarehouse .=
'<table class="noborder centpercent">';
493 $latestwarehouse .=
'<tr class="liste_titre">';
494 $latestwarehouse .=
'<th>';
495 $latestwarehouse .= $langs->trans(
"LatestModifiedWarehouses", $max);
500 $latestwarehouse .=
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?sortfield=p.tms&sortorder=DESC" title="'.$langs->trans(
"FullList").
'">';
501 $latestwarehouse .=
'<span class="badge marginleftonlyshort">...</span>';
502 $latestwarehouse .=
'</a>';
503 $latestwarehouse .=
'</th><th class="right">';
504 $latestwarehouse .=
'</th>';
505 $latestwarehouse .=
'</tr>';
509 while ($i < min($max, $num)) {
510 $objp = $db->fetch_object($result);
512 $warehouse->id = $objp->rowid;
513 $warehouse->statut = $objp->status;
514 $warehouse->label = $objp->label;
515 $warehouse->lieu = $objp->lieu;
517 $latestwarehouse .=
'<tr class="oddeven">';
518 $latestwarehouse .=
'<td>';
519 $latestwarehouse .= $warehouse->getNomUrl(1);
520 $latestwarehouse .=
'</td>'.
"\n";
521 $latestwarehouse .=
'<td class="right">';
522 $latestwarehouse .= $warehouse->getLibStatut(5);
523 $latestwarehouse .=
'</td>';
524 $latestwarehouse .=
"</tr>\n";
529 $latestwarehouse .=
'<tr><td>'.$langs->trans(
"None").
'</td><td></td></tr>';
535 $latestwarehouse .=
"</table>";
536 $latestwarehouse .=
'</div>';
537 $latestwarehouse .=
'<br>';
545if (isModEnabled(
'stock') && $user->hasRight(
'stock',
'mouvement',
'read')) {
546 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
548 $sql =
"SELECT p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.tobatch, p.tosell, p.tobuy,";
549 $sql .=
" e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,";
550 $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";
551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e";
552 $sql .=
", ".MAIN_DB_PREFIX.
"stock_mouvement as m";
553 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
554 $sql .=
" WHERE m.fk_product = p.rowid";
555 $sql .=
" AND m.fk_entrepot = e.rowid";
556 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
558 $sql .=
" AND p.fk_product_type = ".Product::TYPE_PRODUCT;
560 $sql .= $db->order(
"datem",
"DESC");
561 $sql .= $db->plimit($max, 0);
563 dol_syslog(
"Index:list stock movements", LOG_DEBUG);
565 $resql = $db->query($sql);
567 $num = $db->num_rows($resql);
569 $latestmovement .=
'<div class="div-table-responsive-no-min">';
570 $latestmovement .=
'<table class="noborder centpercent">';
571 $latestmovement .=
'<tr class="liste_titre">';
572 $latestmovement .=
'<th colspan="3">'.$langs->trans(
"LatestStockMovements", min($num, $max));
573 $latestmovement .=
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php">';
574 $latestmovement .=
'<span class="badge marginleftonlyshort">...</span>';
576 $latestmovement .=
'</a>';
577 $latestmovement .=
'</th>';
578 if (isModEnabled(
'productbatch')) {
579 $latestmovement .=
'<th></th>';
581 $latestmovement .=
'<th></th>';
582 $latestmovement .=
'<th class="right">';
583 $latestmovement .=
'</th>';
584 $latestmovement .=
"</tr>\n";
590 while ($i < min($num, $max)) {
591 $objp = $db->fetch_object($resql);
593 $tmpstockmovement->id = $objp->mid;
594 $tmpstockmovement->date = $db->jdate($objp->datem);
595 $tmpstockmovement->label = $objp->mlabel;
596 $tmpstockmovement->inventorycode = $objp->mcode;
597 $tmpstockmovement->qty = $objp->qty;
599 $producttmp->id = $objp->product_id;
600 $producttmp->ref = $objp->product_ref;
601 $producttmp->label = $objp->product_label;
602 $producttmp->status_batch = $objp->tobatch;
603 $producttmp->status_sell = $objp->tosell;
604 $producttmp->status_buy = $objp->tobuy;
606 $warehouse->id = $objp->warehouse_id;
607 $warehouse->ref = $objp->warehouse_ref;
608 $warehouse->statut = $objp->warehouse_status;
609 $warehouse->label = $objp->warehouse_label;
610 $warehouse->lieu = $objp->lieu;
612 $tmplotstatic->batch = $objp->batch;
613 $tmplotstatic->sellby = $objp->sellby;
614 $tmplotstatic->eatby = $objp->eatby;
616 $latestmovement .=
'<tr class="oddeven">';
617 $latestmovement .=
'<td class="nowraponall">';
618 $latestmovement .= $tmpstockmovement->getNomUrl(1);
620 $latestmovement .=
'</td>';
621 $latestmovement .=
'<td class="nowraponall">';
622 $latestmovement .=
dol_print_date($tmpstockmovement->date,
'dayhour',
'tzuserrel');
623 $latestmovement .=
"</td>\n";
624 $latestmovement .=
'<td class="tdoverflowmax150">';
625 $latestmovement .= $producttmp->getNomUrl(1);
626 $latestmovement .=
"</td>\n";
627 if (isModEnabled(
'productbatch')) {
628 $latestmovement .=
'<td>';
629 $latestmovement .= $tmplotstatic->getNomUrl(0,
'nolink');
630 $latestmovement .=
'</td>';
638 $latestmovement .=
'<td class="tdoverflowmax150">';
639 $latestmovement .= $warehouse->getNomUrl(1);
640 $latestmovement .=
"</td>\n";
641 $latestmovement .=
'<td class="right">';
642 if ($objp->qty < 0) {
643 $latestmovement .=
'<span class="stockmovementexit">';
645 if ($objp->qty > 0) {
646 $latestmovement .=
'<span class="stockmovemententry">';
647 $latestmovement .=
'+';
649 $latestmovement .= $objp->qty;
650 $latestmovement .=
'</span>';
651 $latestmovement .=
'</td>';
652 $latestmovement .=
"</tr>\n";
659 if (isModEnabled(
'productbatch')) {
662 $latestmovement .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
665 $latestmovement .=
"</table>";
666 $latestmovement .=
'</div>';
667 $latestmovement .=
'<br>';
677if (isModEnabled(
"invoice") && $user->hasRight(
'facture',
'lire') &&
getDolGlobalString(
'MAIN_SHOW_PRODUCT_ACTIVITY_TRIM')) {
678 if (isModEnabled(
"product")) {
681 if (isModEnabled(
"service")) {
690print
'<div class="clearboth"></div>';
691print
'<div class="fichecenter fichecenterbis">';
693$boxlist =
'<div class="twocolumns">';
695$boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
697$boxlist .= $graphcat;
698$boxlist .= $activity;
700$boxlist .= $resultboxes[
'boxlista'];
701$boxlist .=
"</div>\n";
703$boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
704$boxlist .= $lastmodified;
705$boxlist .= $latestwarehouse;
706$boxlist .= $latestmovement;
707$boxlist .= $resultboxes[
'boxlistb'];
708$boxlist .=
'</div>'.
"\n";
710$boxlist .=
"</div>\n";
716$parameters = array(
'type' => $type,
'user' => $user);
717$reshook = $hookmanager->executeHooks(
'dashboardProductsServices', $parameters, $product_static);
732 global
$conf, $langs, $db;
738 $sql =
"SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
739 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"facturedet as fd";
740 $sql .=
" , ".MAIN_DB_PREFIX.
"paiement as p,".MAIN_DB_PREFIX.
"paiement_facture as pf";
741 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
742 $sql .=
" AND f.rowid = fd.fk_facture";
743 $sql .=
" AND pf.fk_facture = f.rowid";
744 $sql .=
" AND pf.fk_paiement = p.rowid";
745 $sql .=
" AND fd.product_type = ".((int) $product_type);
746 $sql .=
" AND p.datep >= '".$db->idate(
dol_get_first_day($yearofbegindate), 1).
"'";
747 $sql .=
" GROUP BY annee, mois ";
748 $sql .=
" ORDER BY annee, mois ";
750 $result = $db->query($sql);
758 $num = $db->num_rows($result);
761 $out .=
'<div class="div-table-responsive-no-min">';
762 $out .=
'<table class="noborder" width="75%">';
764 if ($product_type == 0) {
765 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ProductSellByQuarterHT").
'</td>';
767 $out .=
'<tr class="liste_titre"><td class=left>'.$langs->trans(
"ServiceSellByQuarterHT").
'</td>';
769 $out .=
'<td class=right>'.$langs->trans(
"Quarter1").
'</td>';
770 $out .=
'<td class=right>'.$langs->trans(
"Quarter2").
'</td>';
771 $out .=
'<td class=right>'.$langs->trans(
"Quarter3").
'</td>';
772 $out .=
'<td class=right>'.$langs->trans(
"Quarter4").
'</td>';
773 $out .=
'<td class=right>'.$langs->trans(
"Total").
'</td>';
779 $objp = $db->fetch_object($result);
780 if ($tmpyear != $objp->annee) {
781 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
782 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
783 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
784 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
785 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
786 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
787 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
792 $tmpyear = $objp->annee;
799 if ($objp->mois ==
"01" || $objp->mois ==
"02" || $objp->mois ==
"03") {
800 $trim1 += $objp->Mnttot;
803 if ($objp->mois ==
"04" || $objp->mois ==
"05" || $objp->mois ==
"06") {
804 $trim2 += $objp->Mnttot;
807 if ($objp->mois ==
"07" || $objp->mois ==
"08" || $objp->mois ==
"09") {
808 $trim3 += $objp->Mnttot;
811 if ($objp->mois ==
"10" || $objp->mois ==
"11" || $objp->mois ==
"12") {
812 $trim4 += $objp->Mnttot;
817 if ($trim1 + $trim2 + $trim3 + $trim4 > 0) {
818 $out .=
'<tr class="oddeven"><td class=left>'.$tmpyear.
'</td>';
819 $out .=
'<td class="nowrap right">'.price($trim1).
'</td>';
820 $out .=
'<td class="nowrap right">'.price($trim2).
'</td>';
821 $out .=
'<td class="nowrap right">'.price($trim3).
'</td>';
822 $out .=
'<td class="nowrap right">'.price($trim4).
'</td>';
823 $out .=
'<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).
'</td>';
827 $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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.