print '<td align="right">'; if (empty($conf->global->PRODUIT_MULTI_PRICES)) { print price(price2num($product->price * $obj->reel, 'MT'), 1) . '</td>'; } else { print $langs->trans("Variable"); } print '</tr>'; $total += $obj->reel; if (price2num($product->pmp)) { $totalwithpmp += $obj->reel; } $totalvalue = $totalvalue + $product->pmp * $obj->reel; $totalvaluesell = $totalvaluesell + $product->price * $obj->reel; //Batch Detail if (!empty($conf->productbatch->enabled) && $product->hasbatch()) { $details = Productbatch::findAll($db, $obj->product_stock_id); if ($details < 0) { dol_print_error($db); } foreach ($details as $pdluo) { if ($action == 'editline' && GETPOST('lineid', 'int') == $pdluo->id) { //Current line edit print "\n" . '<tr><td colspan="9">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST"><input type="hidden" name="pdluoid" value="' . $pdluo->id . '"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="' . $id . '"><table class="noborder" width="100%"><tr><td width="10%"></td>'; print '<td align="right" width="10%"><input type="text" name="batch_number" value="' . $pdluo->batch . '"></td>'; print '<td align="center" width="10%">'; $form->select_date($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0, 1); print '</td>'; print '<td align="center" width="10%">'; $form->select_date($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0, 1); print '</td>';
/** * Load information about stock of a product into stock_reel, stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) * * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock, getBatchInfo */ function load_stock() { $this->stock_reel = 0; $this->stock_warehouse = array(); $sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp, ps.rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_stock as ps"; $sql .= ", " . MAIN_DB_PREFIX . "entrepot as w"; $sql .= " WHERE w.entity IN (" . getEntity('stock', 1) . ")"; $sql .= " AND w.rowid = ps.fk_entrepot"; $sql .= " AND ps.fk_product = " . $this->id; dol_syslog(get_class($this) . "::load_stock", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; if ($num > 0) { while ($i < $num) { $row = $this->db->fetch_object($result); $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; if ($this->hasbatch()) { $this->stock_warehouse[$row->fk_entrepot]->detail_batch = Productbatch::findAll($this->db, $row->rowid, 1); } $this->stock_reel += $row->reel; $i++; } } $this->db->free($result); $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... return 1; } else { $this->error = $this->db->lasterror(); return -1; } }