/** * Return product info * @param int $idProd Id of Product * @return array Product info */ public static function getProductbyId($idProd, $idCust) { global $db, $conf; if ($conf->global->PRODUIT_MULTIPRICES) { $sql = "SELECT price_level"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; $sql .= " WHERE rowid = " . $idCust; $res = $db->query($sql); if ($res) { $obj = $db->fetch_object($res); if ($obj->price_level == NULL) { $pricelevel = 1; } else { $pricelevel = $obj->price_level; } } } else { $pricelevel = 1; } $function = "getProductbyId"; $objp = new Product($db); $objp->fetch($idProd); $ret[0]["id"] = $objp->id; $ret[0]["ref"] = $objp->ref; $ret[0]["label"] = $objp->label; $ret[0]["description"] = $objp->description; $ret[0]["fk_product_type"] = $objp->type; $ret[0]["diff_price"] = 0; if (!empty($objp->multiprices[$pricelevel]) && $objp->multiprices[$pricelevel] > 0) { $ret[0]["tva_tx"] = $objp->multiprices_tva_tx[$pricelevel]; $ret[0]["price_base_type"] = $objp->multiprices_base_type[$pricelevel]; $ret[0]["price"] = $objp->multiprices[$pricelevel]; $ret[0]["price_ttc"] = $objp->multiprices_ttc[$pricelevel]; $ret[0]["price_min"] = $objp->multiprices_min[$pricelevel]; $ret[0]["price_min_ttc"] = $objp->multiprices_min_ttc[$pricelevel]; } else { if ($conf->global->PRODUIT_CUSTOMER_PRICES) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); $filter = array('t.fk_product' => $objp->id, 't.fk_soc' => $idCust); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result >= 0) { if (count($prodcustprice->lines) > 0) { $ret[0]["price"] = $prodcustprice->lines[0]->price; $ret[0]["price_ttc"] = $prodcustprice->lines[0]->price_ttc; $ret[0]["price_min"] = $prodcustprice->lines[0]->price_min; $ret[0]["price_min_ttc"] = $prodcustprice->lines[0]->price_min_ttc; $ret[0]["price_base_type"] = $prodcustprice->lines[0]->price_base_type; $ret[0]["tva_tx"] = $prodcustprice->lines[0]->tva_tx; } else { $ret[0]["price"] = $objp->price; $ret[0]["price_ttc"] = $objp->price_ttc; $ret[0]["price_min"] = $objp->price_min; $ret[0]["price_min_ttc"] = $objp->price_base_type; $ret[0]["price_base_type"] = $objp->price_base_type; $ret[0]["tva_tx"] = $objp->tva_tx; } } } else { $ret[0]["tva_tx"] = $objp->tva_tx; $ret[0]["price_base_type"] = $objp->price_base_type; $ret[0]["price"] = $objp->price; $ret[0]["price_ttc"] = $objp->price_ttc; $ret[0]["price_min"] = $objp->price_min; $ret[0]["price_min_ttc"] = $objp->price_min_ttc; if ($conf->global->PRODUIT_MULTIPRICES) { $ret[0]["diff_price"] = 1; } } } $ret[0]["localtax1_tx"] = $objp->localtax1_tx; $ret[0]["localtax2_tx"] = $objp->localtax2_tx; $ret[0]["image"] = self::getImageProduct($objp->id, false); $ret[0]["thumb"] = self::getImageProduct($objp->id, true); return Errorcontrol($ret, $function); }
/** * Return product info * @param int $idProd Id of Product * @return array Product info */ public static function getProductbyIdFk($idProd, $idCust) { global $db, $conf; $function = "getProductbyId"; $objp = new Product($db); $objp->fetch($idProd); $ret[0]["id"] = $objp->id; $ret[0]["ref"] = $objp->ref; $ret[0]["label"] = $objp->label; $ret[0]["description"] = $objp->description; $ret[0]["fk_product_type"] = $objp->type; $ret[0]["diff_price"] = 0; $ret[0]["tva_tx"] = $objp->tva_tx; $ret[0]["price_base_type"] = $objp->price_base_type; $ret[0]["price"] = $objp->price; $ret[0]["price_ttc"] = $objp->price_ttc; $ret[0]["price_min"] = $objp->price_min; $ret[0]["price_min_ttc"] = $objp->price_min_ttc; $ret[0]["localtax1_tx"] = $objp->localtax1_tx; $ret[0]["localtax2_tx"] = $objp->localtax2_tx; $ret[0]["image"] = self::getImageProduct($objp->id, false); $ret[0]["thumb"] = self::getImageProduct($objp->id, true); return Errorcontrol($ret, $function); }
/** * Return product info * @param int $idProd Id of Product * @return array Product info */ public static function getProductbyIdFk($idProd, $idCust) { global $db, $conf; $function = "getProductbyId"; //$objp = new Product($db); //$objp->fetch_reducido($idProd); //include_once "../../../conf/conf.php"; define('DB_SERVER', 'localhost'); define('DB_NAME', 'elcanelo_doli1'); define('DB_USER', 'elcanelo_doli1'); define('DB_PASS', 'N#zC&vK*Sl51(^4'); function connectDB() { error_reporting(E_ERROR); $con = mysql_connect(DB_SERVER, DB_USER, DB_PASS); mysql_set_charset('utf8', $con); mysql_select_db(DB_NAME, $con) or die('ERROR con la conexión: ' . mysql_error()); } connectDB(); $sql = "SELECT p.rowid as id, p.ref, p.label, p.fk_product_type as type, pp.tva_tx, pp.price_base_type, pp.price, pp.price_ttc, \n\t\t\t\tpp.price_min, pp.price_min_ttc, pp.localtax1_tx, pp.localtax2_tx \n\t\t\t\tFROM doli_product p LEFT JOIN doli_product_price pp ON pp.fk_product = p.rowid \n\t\t\t\tWHERE p.rowid = " . $idProd . " ORDER BY pp.rowid DESC"; $resql = mysql_query($sql); if ($resql) { if ($objp = mysql_fetch_object($resql)) { $ret[0]["id"] = $objp->id; $ret[0]["ref"] = $objp->ref; $ret[0]["label"] = $objp->label; //$ret[0]["description"] = $objp->description; $ret[0]["fk_product_type"] = $objp->type; $ret[0]["diff_price"] = 0; $ret[0]["tva_tx"] = $objp->tva_tx; $ret[0]["price_base_type"] = $objp->price_base_type; $ret[0]["price"] = $objp->price; $ret[0]["price_ttc"] = $objp->price_ttc; $ret[0]["price_min"] = $objp->price_min; $ret[0]["price_min_ttc"] = $objp->price_min_ttc; $ret[0]["localtax1_tx"] = $objp->localtax1_tx; $ret[0]["localtax2_tx"] = $objp->localtax2_tx; } } // else echo "No entro"; // Checkpoint: se quitan las imagenes, se reducen 3 segundos. //$ret[0]["image"] = self::getImageProduct($objp->id, false); //$ret[0]["thumb"] = self::getImageProduct($objp->id, true); return Errorcontrol($ret, $function); }
public static function getProductbyIdFkUsado($idProd, $idCust, $ticket) { global $db, $conf; $function = "getProductbyId"; $sql = "SELECT pt.fk_product as id, p.ref, pt.tva_tx, pt.subprice, pt.price\n\t\t\t\tFROM doli_pos_ticketdet pt LEFT JOIN doli_product p ON p.rowid = pt.fk_product \n\t\t\t\tWHERE pt.fk_product = " . $idProd . " AND pt.fk_ticket = " . $ticket; $resql = $db->query($sql); if ($resql) { if ($objp = $db->fetch_object($resql)) { $ret[0]["id"] = $objp->id; $ret[0]["ref"] = $objp->ref; $ret[0]["label"] = 'Producto usado'; //$ret[0]["description"] = $objp->description; $ret[0]["fk_product_type"] = 0; $ret[0]["diff_price"] = 0; $ret[0]["tva_tx"] = $objp->tva_tx; $ret[0]["price_base_type"] = 'TTC'; $ret[0]["price"] = $objp->subprice; $ret[0]["price_ttc"] = $objp->price; $ret[0]["price_min"] = 0; $ret[0]["price_min_ttc"] = 0; $ret[0]["localtax1_tx"] = 0; $ret[0]["localtax2_tx"] = 0; } } // else echo "No entro"; // Checkpoint: se quitan las imagenes, se reducen 3 segundos. //$ret[0]["image"] = self::getImageProduct($objp->id, false); //$ret[0]["thumb"] = self::getImageProduct($objp->id, true); return Errorcontrol($ret, $function); }