print_liste_field_titre($langs->trans("QtyMin"), $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], '', '', $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("PriceQtyMinHT"), $_SERVER["PHP_SELF"], '', '', $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("DiscountQtyMin"), $_SERVER["PHP_SELF"], '', '', $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("NbDaysToDelivery"), $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, 'align="right"', $sortfield, $sortorder); // Charges ???? if ($conf->global->PRODUCT_CHARGES) { if (!empty($conf->margin->enabled)) { print_liste_field_titre($langs->trans("UnitCharges")); } } print_liste_field_titre(''); print "</tr>\n"; $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder); if (count($product_fourn_list) > 0) { $var = true; foreach ($product_fourn_list as $productfourn) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>' . $productfourn->getSocNomUrl(1, 'supplier') . '</td>'; // Supplier print '<td align="left">' . $productfourn->fourn_ref . '</td>'; //Availability if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $form->load_cache_availability(); $availability = $form->cache_availability[$productfourn->fk_availability]['label']; print '<td align="left">' . $availability . '</td>'; } // Quantity
/** * Return minimum product recommended price * * @return int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE */ function min_recommended_price() { global $conf; $maxpricesupplier = 0; if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; $product_fourn = new ProductFournisseur($this->db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', ''); if (is_array($product_fourn_list) && count($product_fourn_list) > 0) { foreach ($product_fourn_list as $productfourn) { if ($productfourn->fourn_unitprice > $maxpricesupplier) { $maxpricesupplier = $productfourn->fourn_unitprice; } } $maxpricesupplier *= $conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE; } } return $maxpricesupplier; }
$idprod = GETPOST('idprod', 'int'); $prices = array(); $langs->load('stocks'); /* * View */ top_httphead(); //print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; if ($idprod > 0) { $producttmp = new ProductFournisseur($db); $producttmp->fetch($idprod); $sorttouse = 's.nom, pfp.quantity, pfp.price'; if (GETPOST('bestpricefirst')) { $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; } $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. if (is_array($productSupplierArray)) { foreach ($productSupplierArray as $productSupplier) { $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100); $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100); $title = $productSupplier->fourn_name . ' - ' . $productSupplier->fourn_ref . ' - '; if ($productSupplier->fourn_qty == 1) { $title .= price($price, 0, $langs, 0, 0, -1, $conf->currency) . "/"; } $title .= $productSupplier->fourn_qty . ' ' . ($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); if ($productSupplier->fourn_qty > 1) { $title .= " - "; $title .= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit"); $price = $unitprice; }
print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td>'; if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder); print '<td class="liste_titre" align="right">'.$langs->trans("VATRate").'</td>'; print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>'; // Charges ???? if (! empty($conf->margin->enabled)) print '<td align="right">'.$langs->trans("Charges").'</td>'; print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder); // Charges ???? if (! empty($conf->margin->enabled)) print '<td align="right">'.$langs->trans("UnitCharges").'</td>'; print '<td class="liste_titre"></td>'; print "</tr>\n"; $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($product->id); if (count($product_fourn_list)>0) { $var=true; foreach($product_fourn_list as $productfourn) { $var=!$var; print "<tr ".$bc[$var].">"; print '<td>'.$productfourn->getSocNomUrl(1).'</td>'; // Supplier print '<td align="left">'.$productfourn->fourn_ref.'</td>';
if ($status_code == "NOT_FOUND") { setEventMessages($line_id . $langs->trans("SupplierMissingRef") . " '" . $ref_supplier . "'", null, 'warnings'); } else { setEventMessages($line_id . $langs->trans("ResponseNonOK") . " '" . $status_code . "' - '" . $result_product["result"]["result_label"] . "'", null, 'errors'); $error_occurred = true; break; } } } // Ensure that price is equal and warn user if it's not $supplier_price = price($result_product["product"]["price_net"]); //Price of client tab in supplier dolibarr $local_price = NULL; //Price of supplier as stated in product suppliers tab on this dolibarr, NULL if not found $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); if (count($product_fourn_list) > 0) { foreach ($product_fourn_list as $product_fourn_line) { //Only accept the line where the supplier is the same at this order and has the same ref if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { $local_price = price($product_fourn_line->fourn_price); } } } if ($local_price != NULL && $local_price != $supplier_price) { setEventMessages($line_id . $langs->trans("RemotePriceMismatch") . " " . $supplier_price . " - " . $local_price, null, 'warnings'); } // Check if is in sale if (empty($result_product["product"]["status_tosell"])) { setEventMessages($line_id . $langs->trans("ProductStatusNotOnSellShort") . " '" . $ref_supplier . "'", null, 'warnings'); }
/** * * @param unknown $object * @return boolean */ static function checkContractFourn(&$object) { global $conf, $langs, $db; if (empty($conf->global->GRAPEFRUIT_CONTRACT_DEFAUL_FOURN) || $conf->global->GRAPEFRUIT_CONTRACT_DEFAUL_FOURN < 0) { return true; } dol_include_once('/fourn/class/fournisseur.product.class.php'); foreach ($object->lines as &$line) { if (empty($line->fk_fournprice) && $line->fk_product > 0) { $p_static = new ProductFournisseur($db); $TPrice = $p_static->list_product_fournisseur_price($line->fk_product); foreach ($TPrice as &$price) { if ($price->fourn_id == $conf->global->GRAPEFRUIT_CONTRACT_DEFAUL_FOURN) { // TODO AA updateline sur contrat, là j'ai la flemme, no comment $db->query("UPDATE " . MAIN_DB_PREFIX . "contratdet\n\t\t\t\t\t\tSET fk_product_fournisseur_price=" . $price->product_fourn_price_id . ",buy_price_ht=" . $price->fourn_price / $price->fourn_qty . "\n\t\t\t\t\t\tWHERE rowid=" . $line->id); break; } } } } }