NEW : filter by supplier on replenish.php
This commit is contained in:
parent
0b49d6316e
commit
9c8ecdc8d8
@ -2266,13 +2266,13 @@ class Form
|
||||
* @param string $htmlname Name of HTML field
|
||||
* @return void
|
||||
*/
|
||||
function select_product_fourn_price($productid,$htmlname='productfournpriceid')
|
||||
function select_product_fourn_price($productid, $selected_supplier='', $htmlname='productfournpriceid')
|
||||
{
|
||||
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";
|
||||
@ -2309,7 +2309,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.' - ';
|
||||
|
||||
@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
require_once './lib/replenishment.lib.php';
|
||||
|
||||
$langs->load("products");
|
||||
@ -52,6 +53,7 @@ $salert = GETPOST('salert', 'alpha');
|
||||
$mode = GETPOST('mode','alpha');
|
||||
|
||||
$fourn_id = GETPOST('fourn_id','int');
|
||||
$fk_supplier = GETPOST('fk_supplier','int');
|
||||
$texte = '';
|
||||
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
@ -226,6 +228,7 @@ if ($action == 'order' && isset($_POST['valid']))
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
|
||||
$virtualdiffersfromphysical=0;
|
||||
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
|
||||
@ -251,6 +254,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.')';
|
||||
}
|
||||
$sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')';
|
||||
if ($sall) {
|
||||
$sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" ';
|
||||
@ -374,16 +380,6 @@ $head[1][2] = 'replenishorders';
|
||||
|
||||
print load_fiche_titre($langs->trans('Replenishment'), '', 'title_generic.png');
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'.
|
||||
'<input type="hidden" name="token" value="' .$_SESSION['newtoken'] . '">'.
|
||||
'<input type="hidden" name="sortfield" value="' . $sortfield . '">'.
|
||||
'<input type="hidden" name="sortorder" value="' . $sortorder . '">'.
|
||||
'<input type="hidden" name="type" value="' . $type . '">'.
|
||||
'<input type="hidden" name="linecount" value="' . $num . '">'.
|
||||
'<input type="hidden" name="action" value="order">'.
|
||||
'<input type="hidden" name="mode" value="' . $mode . '">';
|
||||
|
||||
dol_fiche_head($head, 'replenish', '', 0, '');
|
||||
|
||||
print $langs->trans("ReplenishmentStatusDesc").'<br>'."\n";
|
||||
@ -391,21 +387,32 @@ if ($usevirtualstock == 1)
|
||||
{
|
||||
print $langs->trans("CurentSelectionMode").': ';
|
||||
print $langs->trans("CurentlyUsingVirtualStock").' - ';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=physical">'.$langs->trans("UsePhysicalStock").'</a><br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=physical&fk_supplier='.$fk_supplier.'">'.$langs->trans("UsePhysicalStock").'</a><br>';
|
||||
}
|
||||
if ($usevirtualstock == 0)
|
||||
{
|
||||
print $langs->trans("CurentSelectionMode").': ';
|
||||
print $langs->trans("CurentlyUsingPhysicalStock").' - ';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=virtual">'.$langs->trans("UseVirtualStock").'</a><br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=virtual&fk_supplier='.$fk_supplier.'">'.$langs->trans("UseVirtualStock").'</a><br>';
|
||||
}
|
||||
print '<br>'."\n";
|
||||
|
||||
print '<form name="formFilterWarehouse" method="GET" action="">';
|
||||
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 'Fournisseur : '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1);
|
||||
print ' <input class="button" type="submit" name="valid" value="'.$langs->trans('ToFilter').'">';
|
||||
print '</form>';
|
||||
|
||||
if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
|
||||
$filters = '&sref=' . $sref . '&snom=' . $snom;
|
||||
$filters .= '&sall=' . $sall;
|
||||
$filters .= '&salert=' . $salert;
|
||||
$filters .= '&mode=' . $mode;
|
||||
$filters .= '&fk_supplier=' . $fk_supplier;
|
||||
print_barre_liste(
|
||||
$texte,
|
||||
$page,
|
||||
@ -422,6 +429,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
|
||||
$filters .= (isset($type)?'&type=' . $type:'');
|
||||
$filters .= '&=' . $salert;
|
||||
$filters .= '&mode=' . $mode;
|
||||
$filters .= '&fk_supplier=' . $fk_supplier;
|
||||
print_barre_liste(
|
||||
$texte,
|
||||
$page,
|
||||
@ -440,12 +448,24 @@ $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;
|
||||
|
||||
$stocklabel = $langs->trans('Stock');
|
||||
if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock');
|
||||
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="sortfield" value="' . $sortfield . '">'.
|
||||
'<input type="hidden" name="sortorder" value="' . $sortorder . '">'.
|
||||
'<input type="hidden" name="type" value="' . $type . '">'.
|
||||
'<input type="hidden" name="linecount" value="' . $num . '">'.
|
||||
'<input type="hidden" name="action" value="order">'.
|
||||
'<input type="hidden" name="mode" value="' . $mode . '">';
|
||||
|
||||
|
||||
// Lines of title
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre('<input type="checkbox" onClick="toggle(this)" />', $_SERVER["PHP_SELF"], '');
|
||||
@ -592,7 +612,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, $fk_supplier, 'fourn'.$i).'</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
@ -609,6 +629,7 @@ if ($num > $conf->liste_limit)
|
||||
$filters .= '&sall=' . $sall;
|
||||
$filters .= '&salert=' . $salert;
|
||||
$filters .= '&mode=' . $mode;
|
||||
$filters .= '&fk_supplier=' . $fk_supplier;
|
||||
print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, '');
|
||||
}
|
||||
else
|
||||
@ -618,6 +639,7 @@ if ($num > $conf->liste_limit)
|
||||
$filters .= (isset($type)? '&type=' . $type : '');
|
||||
$filters .= '&salert=' . $salert;
|
||||
$filters .= '&mode=' . $mode;
|
||||
$filters .= '&fk_supplier=' . $fk_supplier;
|
||||
print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, '');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user