*/ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { if (($_POST['qty'] || $_POST['pqty']) && ($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc']) || $_POST['idprodfournprice'])) { $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); exit; } $ret = $object->fetch_thirdparty(); // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit if ($_POST["idprodfournprice"]) { $qty = $_POST['qty'] ? $_POST['qty'] : $_POST['pqty']; $product = new ProductFournisseur($db); $idprod = $product->get_buyprice($_POST['idprodfournprice'], $qty); //$societe=''; /*if ($object->socid) { $societe=new Societe($db); $societe->fetch($object->socid); }*/ if ($idprod > 0) { $res = $product->fetch($idprod); // cas special pour lequel on a les meme reference que le fournisseur // $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle; $label = $product->libelle; $desc = $product->description; $desc .= $product->description && $_POST['np_desc'] ? "\n" : ""; $desc .= $_POST['np_desc']; $remise_percent = $_POST["remise_percent"] ? $_POST["remise_percent"] : $_POST["p_remise_percent"];
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } if (GETPOST('prod_entry_mode') != 'free') { $idprod = 0; $productsupplier = new ProductFournisseur($db); if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') { $idprod = -2; } // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) if (GETPOST('idprodfournprice') > 0) { $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. } //Replaces $fk_unit with the product's if ($idprod > 0) { $result = $productsupplier->fetch($idprod); $label = $productsupplier->label; $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) { $desc = dol_concatdesc($desc, $product_desc); } $tvatx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']); $npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']); $localtax1_tx = get_localtax($tvatx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tvatx, 2, $mysoc, $object->thirdparty); $type = $productsupplier->type;
} llxHeader("","",$langs->trans("CardProduct0")); /* * Fiche produit */ if ($_GET["id"]) { if ($_GET["action"] <> 're-edit') { $product = new ProductFournisseur($db); $result = $product->fetch($_GET["id"], $_GET["id_fourn"]); $product->get_buyprice($_GET["id_fourn"],1); } if ( $result == 0) { /* * En mode visu */ $h=0; $head[$h][0] = DOL_URL_ROOT."/fourn/product/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("ProductCard"); $h++;