commit
1776349a30
@ -2106,7 +2106,29 @@ class CommandeFournisseur extends CommonOrder
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the max number delivery delay in day
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getMaxDeliveryTimeDay($langs)
|
||||
{
|
||||
if (empty($this->lines)) return $langs->trans('Undefined');
|
||||
|
||||
$nb = 0;
|
||||
foreach ($this->lines as $line) {
|
||||
$obj = new ProductFournisseur($this->db);
|
||||
$idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty);
|
||||
if ($idp) {
|
||||
$obj->fetch($idp);
|
||||
if ($obj->delivery_time_days > $nb) $nb = $obj->delivery_time_days;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($nb === 0) return $langs->trans('Undefined');
|
||||
else return $nb.' '.$langs->trans('Days');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
var $id; // product id
|
||||
var $fourn_ref; // deprecated
|
||||
var $delivery_time_days;
|
||||
var $ref_supplier; // ref supplier (can be set by get_buyprice)
|
||||
var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
|
||||
|
||||
@ -155,7 +156,7 @@ class ProductFournisseur extends Product
|
||||
* @param int $newnpr Set NPR or not
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0)
|
||||
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -165,6 +166,7 @@ class ProductFournisseur extends Product
|
||||
if (empty($charges)) $charges=0;
|
||||
if (empty($availability)) $availability=0;
|
||||
if (empty($remise_percent)) $remise_percent=0;
|
||||
if (empty($delivery_time_days)) $delivery_time_days=0;
|
||||
if ($price_base_type == 'TTC')
|
||||
{
|
||||
//$ttx = get_default_tva($fourn,$mysoc,$this->id); // We must use the VAT rate defined by user and not calculate it
|
||||
@ -198,7 +200,8 @@ class ProductFournisseur extends Product
|
||||
$sql.= " fk_availability = ".$availability.",";
|
||||
$sql.= " entity = ".$conf->entity.",";
|
||||
$sql.= " info_bits = ".$newnpr.",";
|
||||
$sql.= " charges = ".$charges;
|
||||
$sql.= " charges = ".$charges.",";
|
||||
$sql.= " delivery_time_days = ".$delivery_time_days;
|
||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||
// TODO Add price_base_type and price_ttc
|
||||
|
||||
@ -241,7 +244,7 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
// Add price for this quantity to supplier
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
|
||||
$sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity)";
|
||||
$sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity, delivery_time_days)";
|
||||
$sql.= " values('".$this->db->idate($now)."',";
|
||||
$sql.= " ".$this->id.",";
|
||||
$sql.= " ".$fourn->id.",";
|
||||
@ -257,7 +260,8 @@ class ProductFournisseur extends Product
|
||||
$sql.= " ".$unitCharges.",";
|
||||
$sql.= " ".$availability.",";
|
||||
$sql.= " ".$newnpr.",";
|
||||
$sql.= $conf->entity;
|
||||
$sql.= $conf->entity.",";
|
||||
$sql.= $this->delivery_time_days;
|
||||
$sql.=")";
|
||||
|
||||
dol_syslog(get_class($this)."::update_buyprice", LOG_DEBUG);
|
||||
@ -330,7 +334,7 @@ class ProductFournisseur extends Product
|
||||
function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
|
||||
{
|
||||
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,";
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE pfp.rowid = ".$rowid;
|
||||
|
||||
@ -354,6 +358,7 @@ class ProductFournisseur extends Product
|
||||
$this->product_id = $obj->fk_product; // deprecated
|
||||
$this->fk_product = $obj->fk_product;
|
||||
$this->fk_availability = $obj->fk_availability;
|
||||
$this->delivery_time_days = $obj->delivery_time_days;
|
||||
//$this->fourn_tva_npr = $obj->fourn_tva_npr; // FIXME this field not exist in llx_product_fournisseur_price
|
||||
$this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
|
||||
|
||||
@ -403,7 +408,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
|
||||
@ -431,12 +436,13 @@ class ProductFournisseur extends Product
|
||||
$prodfourn->fourn_remise_percent = $record["remise_percent"];
|
||||
$prodfourn->fourn_remise = $record["remise"];
|
||||
$prodfourn->fourn_unitprice = $record["unitprice"];
|
||||
$prodfourn->fourn_charges = $record["charges"];
|
||||
$prodfourn->fourn_unitcharges = $record["unitcharges"];
|
||||
$prodfourn->fourn_charges = $record["charges"];
|
||||
$prodfourn->fourn_unitcharges = $record["unitcharges"];
|
||||
$prodfourn->fourn_tva_tx = $record["tva_tx"];
|
||||
$prodfourn->fourn_id = $record["fourn_id"];
|
||||
$prodfourn->fourn_name = $record["supplier_name"];
|
||||
$prodfourn->fk_availability = $record["fk_availability"];
|
||||
$prodfourn->delivery_time_days = $record["delivery_time_days"];
|
||||
$prodfourn->id = $prodid;
|
||||
$prodfourn->fourn_tva_npr = $record["info_bits"];
|
||||
$prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
@ -496,12 +502,13 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_unitprice = '';
|
||||
$this->fourn_id = '';
|
||||
$this->fourn_name = '';
|
||||
$this->delivery_time_days = '';
|
||||
$this->id = '';
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, ";
|
||||
$sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression";
|
||||
$sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
||||
$sql.= " AND pfp.fk_product = ".$prodid;
|
||||
@ -562,6 +569,7 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_tva_tx = $record["tva_tx"];
|
||||
$this->fourn_id = $record["fourn_id"];
|
||||
$this->fourn_name = $record["supplier_name"];
|
||||
$this->delivery_time_days = $record["delivery_time_days"];
|
||||
$this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
|
||||
$this->id = $prodid;
|
||||
$min = $this->fourn_unitprice;
|
||||
|
||||
@ -1601,6 +1601,13 @@ elseif (! empty($object->id))
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Delai livraison jours
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').'</td>';
|
||||
print '<td>'.$object->getMaxDeliveryTimeDay($langs).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
@ -99,3 +99,5 @@ create table llx_contratdet_extrafields
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_contratdet_extrafields ADD INDEX idx_contratdet_extrafields (fk_object);
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN delivery_time_days integer;
|
||||
|
||||
@ -41,4 +41,6 @@ ListOfSupplierProductForSupplier=List of products and prices for supplier <b>%s<
|
||||
NoneOrBatchFileNeverRan=None or batch <b>%s</b> not ran recently
|
||||
SentToSuppliers=Sent to suppliers
|
||||
ListOfSupplierOrders=List of supplier orders
|
||||
MenuOrdersSupplierToBill=Supplier orders to invoice
|
||||
MenuOrdersSupplierToBill=Supplier orders to invoice
|
||||
NbDaysToDelivery=Delivery delay in days
|
||||
DescNbDaysToDelivery=The biggest delay is display among order product list
|
||||
@ -42,3 +42,5 @@ NoneOrBatchFileNeverRan=Aucun ou traitement par lot <b>%s</b> non exécuté réc
|
||||
SentToSuppliers=Envoyés aux fournisseurs
|
||||
ListOfSupplierOrders=Liste des commandes fournisseurs
|
||||
MenuOrdersSupplierToBill=Commandes fournisseurs en facture
|
||||
NbDaysToDelivery=Delai de livraison en jours
|
||||
DescNbDaysToDelivery=Le délai le plus long est affiché parmis la liste des produits de la commande
|
||||
@ -109,6 +109,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
|
||||
$tva_tx = str_replace('*','', GETPOST('tva_tx','alpha'));
|
||||
$tva_tx = price2num($tva_tx);
|
||||
$price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
|
||||
$delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
|
||||
|
||||
if ($tva_tx == '')
|
||||
{
|
||||
@ -181,7 +182,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
|
||||
if (isset($_POST['ref_fourn_price_id']))
|
||||
$product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']);
|
||||
|
||||
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr);
|
||||
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days);
|
||||
if ($ret < 0)
|
||||
{
|
||||
|
||||
@ -322,7 +323,7 @@ if ($id || $ref)
|
||||
$supplier->fetch($socid);
|
||||
print $supplier->getNomUrl(1);
|
||||
print '<input type="hidden" name="id_fourn" value="'.$socid.'">';
|
||||
print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">';
|
||||
print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">';
|
||||
print '<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.'">';
|
||||
}
|
||||
else
|
||||
@ -379,8 +380,7 @@ if ($id || $ref)
|
||||
{
|
||||
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Vat rate
|
||||
$default_vat='';
|
||||
@ -450,6 +450,13 @@ if ($id || $ref)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Delai livraison jours
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('NbDaysToDelivery').'</td>';
|
||||
print '<td><input class="flat" name="delivery_time_days" size="4" value="'.($rowid ? $product->delivery_time_days : '').'"> '.$langs->trans('days').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Charges ????
|
||||
if ($conf->global->PRODUCT_CHARGES)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user