/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $productstatic = new Product($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte,"; $sql .= " SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ") as total_stock"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as s on p.rowid = s.fk_product"; $sql .= ' WHERE p.entity IN (' . getEntity($productstatic->element, 1) . ')'; $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; if (empty($user->rights->produit->lire)) { $sql .= ' AND p.fk_product_type != 0'; } if (empty($user->rights->service->lire)) { $sql .= ' AND p.fk_product_type != 1'; } $sql .= " GROUP BY p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte"; $sql .= " HAVING SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ") < p.seuil_stock_alerte"; $sql .= $db->order('p.seuil_stock_alerte', 'DESC'); $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $langs->load("stocks"); $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $datem = $db->jdate($objp->tms); // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) { $sqld = "SELECT label"; $sqld .= " FROM " . MAIN_DB_PREFIX . "product_lang"; $sqld .= " WHERE fk_product=" . $objp->rowid; $sqld .= " AND lang='" . $langs->getDefaultLang() . "'"; $sqld .= " LIMIT 1"; $resultd = $db->query($sqld); if ($resultd) { $objtp = $db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') { $objp->label = $objtp->label; } } } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $objp->fk_product_type == 1 ? 'object_service' : 'object_product', 'url' => DOL_URL_ROOT . "/product/card.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->label, 'url' => DOL_URL_ROOT . "/product/card.php?id=" . $objp->rowid); if ($objp->price_base_type == 'HT') { $price = price($objp->price); $price_base_type = $langs->trans("HT"); } else { $price = price($objp->price_ttc); $price_base_type = $langs->trans("TTC"); } $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $price); $this->info_box_contents[$i][3] = array('td' => 'align="left" class="nowrap"', 'text' => $price_base_type); $this->info_box_contents[$i][4] = array('td' => 'align="center"', 'text' => $objp->total_stock . ' / ' . $objp->seuil_stock_alerte, 'text2' => img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit"))); $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tosell, 3, 0)); $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tobuy, 3, 1)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoTooLowStockProducts")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
if ($objp->fk_product_type != 1) { $product_static->id = $objp->rowid; $product_static->load_stock(); print '<td align="right">'; print $objp->desiredstock; print '</td>'; print '<td align="right">'; if ($product_static->stock_reel < $objp->seuil_stock_alerte) { print img_warning($langs->trans("StockTooLow")) . ' '; } print $product_static->stock_reel; print '</td>'; } } // Status (to buy) print '<td align="center" class="nowrap">' . $product_static->LibStatut($objp->tosell, 5, 0) . '</td>'; // Status (to sell) print '<td align="center" class="nowrap">' . $product_static->LibStatut($objp->tobuy, 5, 1) . '</td>'; print '<td> </td>'; print "</tr>\n"; $i++; } $param = "&sref=" . $sref . ($sbarcode ? "&sbarcode=" . $sbarcode : "") . "&snom=" . $snom . "&sall=" . $sall . "&tosell=" . $tosell . "&tobuy=" . $tobuy; $param .= $fourn_id ? "&fourn_id=" . $fourn_id : ""; $param .= $search_categ ? "&search_categ=" . $search_categ : ""; $param .= isset($type) ? "&type=" . $type : ""; print_barre_liste('', $page, "liste.php", $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); $db->free($resql); print "</table>"; print '</form>'; }
print '<td>' . dol_trunc($objp->label, 32) . '</td>'; print "<td>"; print dol_print_date($db->jdate($objp->datem), 'day'); print "</td>"; // Sell price if (empty($conf->global->PRODUIT_MULTIPRICES)) { print '<td align="right">'; if ($objp->price_base_type == 'TTC') { print price($objp->price_ttc) . ' ' . $langs->trans("TTC"); } else { print price($objp->price) . ' ' . $langs->trans("HT"); } print '</td>'; } print '<td align="right" class="nowrap">'; print $product_static->LibStatut($objp->tosell, 5, 0); print "</td>"; print '<td align="right" class="nowrap">'; print $product_static->LibStatut($objp->tobuy, 5, 1); print "</td>"; print "</tr>\n"; $i++; } $db->free(); print "</table>"; } } else { dol_print_error($db); } // TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter" // Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover":
} else { print $objp->duration; } print '</td>'; } //print '<td align="right">'.$objp->stock_theorique.'</td>'; print '<td align="right">' . $objp->seuil_stock_alerte . '</td>'; print '<td align="right">' . $objp->desiredstock . '</td>'; print '<td align="right">'; if ($objp->seuil_stock_alerte && $objp->stock_physique < $objp->seuil_stock_alerte) { print img_warning($langs->trans("StockTooLow")) . ' '; } print $objp->stock_physique; print '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/product/stock/mouvement.php?idproduct=' . $product_static->id . '">' . $langs->trans("Movements") . '</a></td>'; print '<td align="right" class="nowrap">' . $product_static->LibStatut($objp->statut, 5, 0) . '</td>'; print '<td align="right" class="nowrap">' . $product_static->LibStatut($objp->tobuy, 5, 1) . '</td>'; print "</tr>\n"; $i++; } print "</table>"; print '</form>'; if ($num > $conf->liste_limit) { if ($sref || $snom || $sall || GETPOST('search')) { print_barre_liste('', $page, "reassort.php", "&sref=" . $sref . "&snom=" . $snom . "&sall=" . $sall . "&tosell=" . $tosell . "&tobuy=" . $tobuy . (!empty($search_categ) ? '&search_categ=' . $search_categ : '') . (!empty($toolowstock) ? '&toolowstock=' . $toolowstock : ''), $sortfield, $sortorder, '', $num, 0, ''); } else { print_barre_liste('', $page, "reassort.php", "&sref={$sref}&snom={$snom}&fourn_id={$fourn_id}" . (isset($type) ? "&type={$type}" : "") . "&tosell=" . $tosell . "&tobuy=" . $tobuy . (!empty($search_categ) ? '&search_categ=' . $search_categ : '') . (!empty($toolowstock) ? '&toolowstock=' . $toolowstock : ''), $sortfield, $sortorder, '', $num, 0, ''); } } $db->free($resql); } else {
/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $productstatic = new Product($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= ' WHERE p.entity IN (' . getEntity($productstatic->element, 1) . ')'; if (empty($user->rights->produit->lire)) { $sql .= ' AND p.fk_product_type != 0'; } if (empty($user->rights->service->lire)) { $sql .= ' AND p.fk_product_type != 1'; } $sql .= $db->order('p.datec', 'DESC'); $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $datem = $db->jdate($objp->tms); // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) { $sqld = "SELECT label"; $sqld .= " FROM " . MAIN_DB_PREFIX . "product_lang"; $sqld .= " WHERE fk_product=" . $objp->rowid; $sqld .= " AND lang='" . $langs->getDefaultLang() . "'"; $sqld .= " LIMIT 1"; $resultd = $db->query($sqld); if ($resultd) { $objtp = $db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') { $objp->label = $objtp->label; } } } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $objp->fk_product_type == 1 ? 'object_service' : 'object_product', 'url' => DOL_URL_ROOT . "/product/fiche.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->label, 'url' => DOL_URL_ROOT . "/product/fiche.php?id=" . $objp->rowid); if ($objp->price_base_type == 'HT') { $price = price($objp->price); $price_base_type = $langs->trans("HT"); } else { $price = price($objp->price_ttc); $price_base_type = $langs->trans("TTC"); } $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $price); $this->info_box_contents[$i][3] = array('td' => 'align="left" class="nowrap"', 'text' => $price_base_type); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datem, 'day')); $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tosell, 3, 0)); $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tobuy, 3, 1)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProducts")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }