* Copyright (C) 2017 Charlie Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } global $db; if (!empty($form) && !is_object($form)) { $form = new Form($db); } $qtytoconsumeforline = $this->tpl['qty'] / ( !empty($this->tpl['efficiency']) ? $this->tpl['efficiency'] : 1 ); /*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { $qtytoconsumeforline = $qtytoconsumeforline / $this->tpl['qty_bom']; }*/ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS'); $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($db); $res = $tmpbom->fetch($line->fk_bom_child); ?> tpl['strike']) ? '' : ' strikefordisabled').'">'; // Ref or label print ''; if ($res) { print $tmpproduct->getNomUrl(1); if ($tmpbom->id) { print ' ' . $langs->trans("or") . ' '; print $tmpbom->getNomUrl(1); print ' '; print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? img_picto('', 'folder') : img_picto('', 'folder-open')); } print ''; } else { print $this->tpl['label']; } print ''; // Qty print ''.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').''; print ''.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS')); if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) { print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); } print ''; print ''.((empty($this->tpl['virtual_stock']) ? 0 : price2num($this->tpl['virtual_stock'], 'MS'))); if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['virtual_stock'] < $this->tpl['seuil_stock_alerte'])) { print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); } print ''; print ''.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').''; print ''.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').''; //print ''.$this->tpl['efficiency'].''; $selected = 1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { $selected = 0; } if ($tmpbom->id > 0) { print ''; print ''; print ''; } else { print ''; } //print ''; //print ''; //print ''; print ''."\n"; // Select of all the sub-BOM lines $sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; $sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $db->query($sql); if ($resql) { // Loop on all the sub-BOM lines if they exist while ($obj = $db->fetch_object($resql)) { $sub_bom_product = new Product($db); $sub_bom_product->fetch($obj->fk_product); $sub_bom_product->load_stock(); $sub_bom = new BOM($db); $sub_bom->fetch($obj->fk_bom_child); $sub_bom_line = new BOMLine($db); $sub_bom_line->fetch($obj->rowid); //If hidden conf is set, we show directly all the sub-BOM lines if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) { print ''; } else { print ''; } // Product OR BOM print ''; if (!empty($obj->fk_bom_child)) { print $sub_bom_product->getNomUrl(1); print ' '.$langs->trans('or').' '; print $sub_bom->getNomUrl(1); } else { print $sub_bom_product->getNomUrl(1); print ''; } // Qty if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; } // Stock rĂ©el if ($sub_bom_product->stock_reel > 0) { print ''.$sub_bom_product->stock_reel.''; } else { print ' '; } // Stock virtuel if ($sub_bom_product->stock_theorique > 0) { print ''.$sub_bom_product->stock_theorique.''; } else { print ' '; } // Frozen qty if ($sub_bom_line->qty_frozen > 0) { print ''.$langs->trans('Yes').''; } else { print ' '; } // Disable stock change if ($sub_bom_line->disable_stock_change > 0) { print ''.yn($sub_bom_line->disable_stock_change).''; } else { print ' '; } print ''; print ''; } } ?>