Merge pull request #5838 from atm-gauthier/develop_NEW_filter_by_supplier_on_replenishment_card

Develop new filter by supplier on replenishment card
This commit is contained in:
Laurent Destailleur 2016-10-11 20:04:02 +02:00 committed by GitHub
commit 92dc385307
2 changed files with 26 additions and 11 deletions

View File

@ -2340,17 +2340,18 @@ class Form
/**
* Return list of suppliers prices for a product
*
* @param int $productid Id of product
* @param string $htmlname Name of HTML field
* @return string|null
* @param int $productid Id of product
* @param string $htmlname Name of HTML field
* @param int $selected_supplier Pre-selected supplier if more than 1 result
* @return void
*/
function select_product_fourn_price($productid,$htmlname='productfournpriceid')
function select_product_fourn_price($productid, $htmlname='productfournpriceid', $selected_supplier='')
{
global $langs,$conf;
$langs->load('stocks');
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,";
$sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
$sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@ -2387,7 +2388,7 @@ class Form
$opt = '<option value="'.$objp->idprodfournprice.'"';
//if there is only one supplier, preselect it
if($num == 1) {
if($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
$opt .= ' selected';
}
$opt.= '>'.$objp->name.' - '.$objp->ref_fourn.' - ';

View File

@ -3,6 +3,7 @@
* Copyright (C) 2013-2016 Laurent Destaileur <ely@users.sourceforge.net>
* Copyright (C) 2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -54,6 +55,7 @@ $salert = GETPOST('salert', 'alpha');
$mode = GETPOST('mode','alpha');
$fourn_id = GETPOST('fourn_id','int');
$fk_supplier = GETPOST('fk_supplier','int');
$fk_entrepot = GETPOST('fk_entrepot','int');
$texte = '';
@ -279,6 +281,9 @@ $sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p';
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s';
$sql.= ' ON p.rowid = s.fk_product';
if($fk_supplier > 0) {
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')';
}
if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')';
}
@ -417,23 +422,26 @@ if ($usevirtualstock == 1)
{
print $langs->trans("CurentSelectionMode").': ';
print $langs->trans("CurentlyUsingVirtualStock").' - ';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=physical&fk_entrepot='.$fk_entrepot.'">'.$langs->trans("UsePhysicalStock").'</a><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=physical&fk_supplier='.$fk_supplier.'&fk_entrepot='.$fk_entrepot.'">'.$langs->trans("UsePhysicalStock").'</a><br>';
}
if ($usevirtualstock == 0)
{
print $langs->trans("CurentSelectionMode").': ';
print $langs->trans("CurentlyUsingPhysicalStock").' - ';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=virtual&fk_entrepot='.$fk_entrepot.'">'.$langs->trans("UseVirtualStock").'</a><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=virtual&fk_supplier='.$fk_supplier.'&fk_entrepot='.$fk_entrepot.'">'.$langs->trans("UseVirtualStock").'</a><br>';
}
print '<br>'."\n";
print '<form name="formFilterWarehouse" method="GET" action="">';
print '<input type="hidden" name="action" value="filter_warehouse">';
print '<input type="hidden" name="action" value="filter">';
print '<input type="hidden" name="sref" value="'.$sref.'">';
print '<input type="hidden" name="snom" value="'.$snom.'">';
print '<input type="hidden" name="salert" value="'.$salert.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1);
print $langs->trans('Warehouse').' : '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1);
print '<br />';
print $langs->trans('Supplier').' : '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1);
print '<br />';
print ' <input class="button" type="submit" name="valid" value="'.$langs->trans('ToFilter').'">';
print '</form>';
@ -442,6 +450,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
$filters .= '&sall=' . $sall;
$filters .= '&salert=' . $salert;
$filters .= '&mode=' . $mode;
$filters .= '&fk_supplier=' . $fk_supplier;
$filters .= '&fk_entrepot=' . $fk_entrepot;
print_barre_liste(
$texte,
@ -459,6 +468,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
$filters .= (isset($type)?'&type=' . $type:'');
$filters .= '&=' . $salert;
$filters .= '&mode=' . $mode;
$filters .= '&fk_supplier=' . $fk_supplier;
$filters .= '&fk_entrepot=' . $fk_entrepot;
print_barre_liste(
$texte,
@ -478,6 +488,7 @@ $param = (isset($type)? '&type=' . $type : '');
$param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert;
$param .= '&sref=' . $sref;
$param .= '&mode=' . $mode;
$param .= '&fk_supplier=' . $fk_supplier;
$param .= '&fk_entrepot=' . $fk_entrepot;
$stocklabel = $langs->trans('Stock');
@ -486,6 +497,7 @@ if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'.
'<input type="hidden" name="token" value="' .$_SESSION['newtoken'] . '">'.
'<input type="hidden" name="fk_supplier" value="' . $fk_supplier . '">'.
'<input type="hidden" name="fk_entrepot" value="' .$fk_entrepot . '">'.
'<input type="hidden" name="sortfield" value="' . $sortfield . '">'.
'<input type="hidden" name="sortorder" value="' . $sortorder . '">'.
@ -643,7 +655,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
print '<td align="right"><input type="text" size="4" name="tobuy'.$i.'" value="'.$stocktobuy.'"></td>';
// Supplier
print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1).'</td>';
print '<td align="right">'. $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).'</td>';
print '</tr>';
}
@ -660,6 +672,7 @@ if ($num > $conf->liste_limit)
$filters .= '&sall=' . $sall;
$filters .= '&salert=' . $salert;
$filters .= '&mode=' . $mode;
$filters .= '&fk_supplier=' . $fk_supplier;
$filters .= '&fk_entrepot=' . $fk_entrepot;
print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, '');
}
@ -670,6 +683,7 @@ if ($num > $conf->liste_limit)
$filters .= (isset($type)? '&type=' . $type : '');
$filters .= '&salert=' . $salert;
$filters .= '&mode=' . $mode;
$filters .= '&fk_supplier=' . $fk_supplier;
$filters .= '&fk_entrepot=' . $fk_entrepot;
print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, '');
}