fix missing fields in box

This commit is contained in:
Frédéric FRANCE 2020-12-05 08:56:17 +01:00
parent fb3c4ab865
commit e9a12b5324
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -84,21 +84,25 @@ class box_produits extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max));
if ($user->rights->produit->lire || $user->rights->service->lire) if ($user->rights->produit->lire || $user->rights->service->lire) {
{
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity";
$sql .= ", p.accountancy_code_sell"; $sql .= ", p.accountancy_code_sell";
$sql .= ", p.accountancy_code_sell_intra"; $sql .= ", p.accountancy_code_sell_intra";
$sql .= ", p.accountancy_code_sell_export"; $sql .= ", p.accountancy_code_sell_export";
$sql .= ", p.accountancy_code_buy"; $sql .= ", p.accountancy_code_buy";
$sql .= ", p.accountancy_code_buy_intra";
$sql .= ", p.accountancy_code_buy_export";
$sql .= ', p.barcode'; $sql .= ', p.barcode';
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; if (empty($user->rights->produit->lire)) {
if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; $sql .= ' AND p.fk_product_type != 0';
}
if (empty($user->rights->service->lire)) {
$sql .= ' AND p.fk_product_type != 1';
}
// Add where from hooks // Add where from hooks
if (is_object($hookmanager)) if (is_object($hookmanager)) {
{
$parameters = array('boxproductlist'=>1); $parameters = array('boxproductlist'=>1);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
@ -107,18 +111,15 @@ class box_produits extends ModeleBoxes
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$line = 0; $line = 0;
while ($line < $num) while ($line < $num) {
{
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$datem = $this->db->jdate($objp->tms); $datem = $this->db->jdate($objp->tms);
// Multilangs // Multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active
{
$sqld = "SELECT label"; $sqld = "SELECT label";
$sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang";
$sqld .= " WHERE fk_product=".$objp->rowid; $sqld .= " WHERE fk_product=".$objp->rowid;
@ -126,13 +127,13 @@ class box_produits extends ModeleBoxes
$sqld .= " LIMIT 1"; $sqld .= " LIMIT 1";
$resultd = $this->db->query($sqld); $resultd = $this->db->query($sqld);
if ($resultd) if ($resultd) {
{
$objtp = $this->db->fetch_object($resultd); $objtp = $this->db->fetch_object($resultd);
if (isset($objtp->label) && $objtp->label != '') if (isset($objtp->label) && $objtp->label != '') {
$objp->label = $objtp->label; $objp->label = $objtp->label;
} }
} }
}
$productstatic->id = $objp->rowid; $productstatic->id = $objp->rowid;
$productstatic->ref = $objp->ref; $productstatic->ref = $objp->ref;
$productstatic->type = $objp->fk_product_type; $productstatic->type = $objp->fk_product_type;
@ -145,6 +146,8 @@ class box_produits extends ModeleBoxes
$productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
$productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
$productstatic->accountancy_code_buy = $objp->accountancy_code_buy; $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
$productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
$productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
@ -167,8 +170,7 @@ class box_produits extends ModeleBoxes
$priceparser = new PriceParser($this->db); $priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProduct($productstatic); $price_result = $priceparser->parseProduct($productstatic);
if ($price_result >= 0) { if ($price_result >= 0) {
if ($objp->price_base_type == 'HT') if ($objp->price_base_type == 'HT') {
{
$price_base_type = $langs->trans("HT"); $price_base_type = $langs->trans("HT");
} else { } else {
$price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); $price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
@ -206,11 +208,12 @@ class box_produits extends ModeleBoxes
$line++; $line++;
} }
if ($num == 0) if ($num == 0) {
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedProducts"), 'text'=>$langs->trans("NoRecordedProducts"),
); );
}
$this->db->free($result); $this->db->free($result);
} else { } else {