New: More surface control on stock correction page
This commit is contained in:
parent
e3ed088355
commit
5d9f16ca20
@ -30,6 +30,7 @@ For users:
|
|||||||
- New: [ task #454 ]: Add "No category" into filters on category.
|
- New: [ task #454 ]: Add "No category" into filters on category.
|
||||||
- New: Update language files (de, tr, pt, ca_ES, es_ES).
|
- New: Update language files (de, tr, pt, ca_ES, es_ES).
|
||||||
- New: Auto check box on page to edit interface options of user.
|
- New: Auto check box on page to edit interface options of user.
|
||||||
|
- New: More surface control on stock correction page.
|
||||||
- New: Add great britain provinces.
|
- New: Add great britain provinces.
|
||||||
- New: Update libs/tools/logo for DoliWamp.
|
- New: Update libs/tools/logo for DoliWamp.
|
||||||
- Fix: No images into product description lines as PDF generation does
|
- Fix: No images into product description lines as PDF generation does
|
||||||
|
|||||||
@ -3472,6 +3472,7 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
|
|||||||
*/
|
*/
|
||||||
function setEventMessage($mesgstring, $style='mesgs')
|
function setEventMessage($mesgstring, $style='mesgs')
|
||||||
{
|
{
|
||||||
|
if (! in_array($style,array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter for setEventMessage');
|
||||||
$_SESSION['dol_events'][$style][] = $mesgstring;
|
$_SESSION['dol_events'][$style][] = $mesgstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ $cancel=GETPOST('cancel');
|
|||||||
// Security check
|
// Security check
|
||||||
$id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
|
$id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
|
||||||
$ref = GETPOST('ref');
|
$ref = GETPOST('ref');
|
||||||
|
$stocklimit = GETPOST('stocklimit');
|
||||||
|
$cancel = GETPOST('cancel');
|
||||||
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid);
|
$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid);
|
||||||
@ -59,34 +61,46 @@ if ($cancel) $action='';
|
|||||||
if ($action == 'setstocklimit')
|
if ($action == 'setstocklimit')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($_POST['id']);
|
$result=$product->fetch($id);
|
||||||
$product->seuil_stock_alerte=$_POST["stocklimit"];
|
$product->seuil_stock_alerte=$stocklimit;
|
||||||
$result=$product->update($product->id,$user,1,0,1);
|
$result=$product->update($product->id,$user,1,0,1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$mesg=join(',',$product->errors);
|
$mesg=join(',',$product->errors);
|
||||||
}
|
}
|
||||||
$POST["action"]="";
|
$action='';
|
||||||
$id=$_POST["id"];
|
|
||||||
$_GET["id"]=$_POST["id"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct stock
|
// Correct stock
|
||||||
if ($action == "correct_stock" && ! $_POST["cancel"])
|
if ($action == "correct_stock" && ! $cancel)
|
||||||
{
|
{
|
||||||
//if ($_POST["price"] == '') $_POST["price"] = 0;
|
if (! (GETPOST("id_entrepot") > 0))
|
||||||
if (isset($_POST["price"])) $priceunit=price2num($_POST["price"]);
|
{
|
||||||
if (is_numeric($_POST["nbpiece"]) && $id)
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Warehouse")), 'errors');
|
||||||
|
$error++;
|
||||||
|
$action='correction';
|
||||||
|
}
|
||||||
|
if (! GETPOST("nbpiece"))
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("NumberOfUnit")), 'errors');
|
||||||
|
$error++;
|
||||||
|
$action='correction';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$priceunit=price2num(GETPOST("price"));
|
||||||
|
if (is_numeric(GETPOST("nbpiece")) && $id)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($id);
|
$result=$product->fetch($id);
|
||||||
|
|
||||||
$result=$product->correct_stock(
|
$result=$product->correct_stock(
|
||||||
$user,
|
$user,
|
||||||
$_POST["id_entrepot"],
|
GETPOST("id_entrepot"),
|
||||||
$_POST["nbpiece"],
|
GETPOST("nbpiece"),
|
||||||
$_POST["mouvement"],
|
GETPOST("mouvement"),
|
||||||
$_POST["label"],
|
GETPOST("label"),
|
||||||
$priceunit
|
$priceunit
|
||||||
); // We do not change value of stock for a correction
|
); // We do not change value of stock for a correction
|
||||||
|
|
||||||
@ -97,13 +111,29 @@ if ($action == "correct_stock" && ! $_POST["cancel"])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer stock from a warehouse to another warehouse
|
// Transfer stock from a warehouse to another warehouse
|
||||||
if ($action == "transfert_stock" && ! $_POST["cancel"])
|
if ($action == "transfert_stock" && ! $cancel)
|
||||||
{
|
{
|
||||||
if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
|
if (! (GETPOST("id_entrepot_source") > 0) || ! (GETPOST("id_entrepot_destination") > 0))
|
||||||
{
|
{
|
||||||
if (is_numeric($_POST["nbpiece"]) && $id)
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Warehouse")), 'errors');
|
||||||
|
$error++;
|
||||||
|
$action='transfert';
|
||||||
|
}
|
||||||
|
if (! GETPOST("nbpiece"))
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("NumberOfUnit")), 'errors');
|
||||||
|
$error++;
|
||||||
|
$action='transfert';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
if (GETPOST("id_entrepot_source") <> GETPOST("id_entrepot_destination"))
|
||||||
|
{
|
||||||
|
if (is_numeric(GETPOST("nbpiece")) && $id)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($id);
|
$result=$product->fetch($id);
|
||||||
@ -114,7 +144,7 @@ if ($action == "transfert_stock" && ! $_POST["cancel"])
|
|||||||
|
|
||||||
// Define value of products moved
|
// Define value of products moved
|
||||||
$pricesrc=0;
|
$pricesrc=0;
|
||||||
if (isset($product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp)) $pricesrc=$product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp;
|
if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp;
|
||||||
$pricedest=$pricesrc;
|
$pricedest=$pricesrc;
|
||||||
|
|
||||||
//print 'price src='.$pricesrc.', price dest='.$pricedest;exit;
|
//print 'price src='.$pricesrc.', price dest='.$pricedest;exit;
|
||||||
@ -122,20 +152,20 @@ if ($action == "transfert_stock" && ! $_POST["cancel"])
|
|||||||
// Remove stock
|
// Remove stock
|
||||||
$result1=$product->correct_stock(
|
$result1=$product->correct_stock(
|
||||||
$user,
|
$user,
|
||||||
$_POST["id_entrepot_source"],
|
GETPOST("id_entrepot_source"),
|
||||||
$_POST["nbpiece"],
|
GETPOST("nbpiece"),
|
||||||
1,
|
1,
|
||||||
$_POST["label"],
|
GETPOST("label"),
|
||||||
$pricesrc
|
$pricesrc
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add stock
|
// Add stock
|
||||||
$result2=$product->correct_stock(
|
$result2=$product->correct_stock(
|
||||||
$user,
|
$user,
|
||||||
$_POST["id_entrepot_destination"],
|
GETPOST("id_entrepot_destination"),
|
||||||
$_POST["nbpiece"],
|
GETPOST("nbpiece"),
|
||||||
0,
|
0,
|
||||||
$_POST["label"],
|
GETPOST("label"),
|
||||||
$pricedest
|
$pricedest
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -153,6 +183,7 @@ if ($action == "transfert_stock" && ! $_POST["cancel"])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -162,11 +193,11 @@ if ($action == "transfert_stock" && ! $_POST["cancel"])
|
|||||||
$formproduct=new FormProduct($db);
|
$formproduct=new FormProduct($db);
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["id"] || $_GET["ref"])
|
if ($id > 0 || $ref)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
if ($ref) $result = $product->fetch('',$ref);
|
||||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
if ($id > 0) $result = $product->fetch($id);
|
||||||
|
|
||||||
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||||
llxHeader("",$langs->trans("CardProduct".$product->type),$help_url);
|
llxHeader("",$langs->trans("CardProduct".$product->type),$help_url);
|
||||||
@ -180,7 +211,8 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
print($mesg);
|
if ($mesg) print($mesg);
|
||||||
|
dol_htmloutput_events();
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -329,6 +361,20 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
*/
|
*/
|
||||||
if ($action == "correction")
|
if ($action == "correction")
|
||||||
{
|
{
|
||||||
|
print '<script type="text/javascript" language="javascript">
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
function init_price()
|
||||||
|
{
|
||||||
|
if (jQuery("#mouvement").val() == \'0\') jQuery("#unitprice").removeAttr(\'disabled\');
|
||||||
|
else jQuery("#unitprice").attr(\'disabled\',\'disabled\');
|
||||||
|
}
|
||||||
|
init_price();
|
||||||
|
jQuery("#mouvement").change(function() {
|
||||||
|
init_price();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
|
||||||
print_titre($langs->trans("StockCorrection"));
|
print_titre($langs->trans("StockCorrection"));
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'" method="post">'."\n";
|
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'" method="post">'."\n";
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
@ -339,23 +385,23 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
|
print '<td width="20%" class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
|
||||||
print '<td width="20%">';
|
print '<td width="20%">';
|
||||||
print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1);
|
print $formproduct->selectWarehouses(($_GET["dwid"]?$_GET["dwid"]:GETPOST('id_entrepot')),'id_entrepot','',1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td width="20%">';
|
print '<td width="20%">';
|
||||||
print '<select name="mouvement" class="flat">';
|
print '<select name="mouvement" id="mouvement" class="flat">';
|
||||||
print '<option value="0">'.$langs->trans("Add").'</option>';
|
print '<option value="0">'.$langs->trans("Add").'</option>';
|
||||||
print '<option value="1">'.$langs->trans("Delete").'</option>';
|
print '<option value="1">'.$langs->trans("Delete").'</option>';
|
||||||
print '</select></td>';
|
print '</select></td>';
|
||||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
|
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" id="nbpiece" size="10" value="'.GETPOST("nbpiece").'"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print '<input type="text" name="label" size="40" value="">';
|
print '<input type="text" name="label" size="40" value="'.GETPOST("label").'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td width="20%">'.$langs->trans("UnitPurchaseValue").'</td><td width="20%"><input class="flat" name="price" size="10" value=""></td>';
|
print '<td width="20%">'.$langs->trans("UnitPurchaseValue").'</td><td width="20%"><input class="flat" name="price" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -378,19 +424,19 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseSource").'</td><td width="20%">';
|
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseSource").'</td><td width="20%">';
|
||||||
print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot_source','',1);
|
print $formproduct->selectWarehouses(($_GET["dwid"]?$_GET["dwid"]:GETPOST('id_entrepot_source')),'id_entrepot_source','',1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
|
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
|
||||||
print $formproduct->selectWarehouses('','id_entrepot_destination','',1);
|
print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'),'id_entrepot_destination','',1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
|
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value="'.GETPOST("nbpiece").'"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
||||||
print '<td colspan="5">';
|
print '<td colspan="5">';
|
||||||
print '<input type="text" name="label" size="40" value="">';
|
print '<input type="text" name="label" size="40" value="'.GETPOST("label").'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -536,9 +582,7 @@ print "</tr>";
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user