New: Can correct stock of a warehouse from warehouse card.
This commit is contained in:
parent
bfee1630a0
commit
6f8ad124a1
@ -21,6 +21,7 @@ For users:
|
|||||||
- New: Add link to third party into sells and purchase journal.
|
- New: Add link to third party into sells and purchase journal.
|
||||||
- New: Suggest a method to generate a backup file for user with no access
|
- New: Suggest a method to generate a backup file for user with no access
|
||||||
to mysqldump binary.
|
to mysqldump binary.
|
||||||
|
- New: Can correct stock of a warehouse from warehouse card.
|
||||||
- Fix: No images into product description lines as PDF generation does
|
- Fix: No images into product description lines as PDF generation does
|
||||||
not work with this.
|
not work with this.
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ require("../../main.inc.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
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.formother.class.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/stock.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/stock.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||||
@ -37,6 +38,9 @@ $langs->load("stocks");
|
|||||||
if (!$user->rights->produit->lire) accessforbidden();
|
if (!$user->rights->produit->lire) accessforbidden();
|
||||||
|
|
||||||
$id=GETPOST('id','int');
|
$id=GETPOST('id','int');
|
||||||
|
$product_id=GETPOST("product_id");
|
||||||
|
$action=GETPOST('action');
|
||||||
|
$cancel=GETPOST('cancel');
|
||||||
$idproduct = isset($_GET["idproduct"])?$_GET["idproduct"]:$_PRODUCT["idproduct"];
|
$idproduct = isset($_GET["idproduct"])?$_GET["idproduct"]:$_PRODUCT["idproduct"];
|
||||||
$year = isset($_GET["year"])?$_GET["year"]:$_POST["year"];
|
$year = isset($_GET["year"])?$_GET["year"]:$_POST["year"];
|
||||||
$month = isset($_GET["month"])?$_GET["month"]:$_POST["month"];
|
$month = isset($_GET["month"])?$_GET["month"]:$_POST["month"];
|
||||||
@ -65,6 +69,39 @@ if (GETPOST("button_removefilter"))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($cancel) $action='';
|
||||||
|
|
||||||
|
// Correct stock
|
||||||
|
if ($action == "correct_stock" && ! $_POST["cancel"])
|
||||||
|
{
|
||||||
|
if (is_numeric($_POST["nbpiece"]) && $product_id)
|
||||||
|
{
|
||||||
|
$product = new Product($db);
|
||||||
|
$result=$product->fetch($product_id);
|
||||||
|
|
||||||
|
$result=$product->correct_stock(
|
||||||
|
$user,
|
||||||
|
$id,
|
||||||
|
$_POST["nbpiece"],
|
||||||
|
$_POST["mouvement"],
|
||||||
|
$_POST["label"],
|
||||||
|
0
|
||||||
|
); // We do not change value of stock for a correction
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $action='';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -74,6 +111,7 @@ $warehousestatic=new Entrepot($db);
|
|||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$formother=new FormOther($db);
|
$formother=new FormOther($db);
|
||||||
|
$formproduct=new FormProduct($db);
|
||||||
|
|
||||||
$sql = "SELECT p.rowid, p.label as produit, p.fk_product_type as type,";
|
$sql = "SELECT p.rowid, p.label as produit, p.fk_product_type as type,";
|
||||||
$sql.= " e.label as stock, e.rowid as entrepot_id,";
|
$sql.= " e.label as stock, e.rowid as entrepot_id,";
|
||||||
@ -238,6 +276,110 @@ if ($resql)
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Correct stock
|
||||||
|
*/
|
||||||
|
if ($action == "correction")
|
||||||
|
{
|
||||||
|
print_titre($langs->trans("StockCorrection"));
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="correct_stock">';
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
// Warehouse
|
||||||
|
print '<tr>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Product").'</td>';
|
||||||
|
print '<td width="20%">';
|
||||||
|
print $form->select_produits(GETPOST('productid'),'product_id',(empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''));
|
||||||
|
print '</td>';
|
||||||
|
print '<td width="20%">';
|
||||||
|
print '<select name="mouvement" class="flat">';
|
||||||
|
print '<option value="0">'.$langs->trans("Add").'</option>';
|
||||||
|
print '<option value="1">'.$langs->trans("Delete").'</option>';
|
||||||
|
print '</select></td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
print '<tr>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
||||||
|
print '<td colspan="4">';
|
||||||
|
print '<input type="text" name="label" size="40" value="">';
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Transfer of units
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if ($action == "transfert")
|
||||||
|
{
|
||||||
|
print_titre($langs->trans("Transfer"));
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="transfert_stock">';
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Product").'</td>';
|
||||||
|
print '<td width="20%">';
|
||||||
|
print $form->select_produits(GETPOST('productid'),'product_id');
|
||||||
|
print '</td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
|
||||||
|
print $formproduct->selectWarehouses('','id_entrepot_destination','',1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
|
print '<tr>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
||||||
|
print '<td colspan="5">';
|
||||||
|
print '<input type="text" name="label" size="40" value="">';
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Barre d'action */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
if (empty($action) && $id)
|
||||||
|
{
|
||||||
|
print "<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
|
if ($user->rights->stock->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=correction">'.$langs->trans("StockCorrection").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if ($user->rights->stock->mouvement->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=transfert">'.$langs->trans("StockMovement").'</a>';
|
||||||
|
}*/
|
||||||
|
print '</div><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$param='';
|
$param='';
|
||||||
if ($id) $param.='&id='.$id;
|
if ($id) $param.='&id='.$id;
|
||||||
if ($search_movement) $param.='&search_movement='.urlencode($search_movement);
|
if ($search_movement) $param.='&search_movement='.urlencode($search_movement);
|
||||||
|
|||||||
@ -36,11 +36,12 @@ $langs->load("orders");
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
|
|
||||||
|
$action=GETPOST("action");
|
||||||
|
$cancel=GETPOST('cancel');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
$id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
|
||||||
{
|
$ref = GETPOST('ref');
|
||||||
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
|
|
||||||
}
|
|
||||||
$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','','',$fieldid);
|
$result=restrictedArea($user,'produit&stock',$id,'product','','',$fieldid);
|
||||||
@ -52,8 +53,10 @@ $mesg = '';
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ($cancel) $action='';
|
||||||
|
|
||||||
// Set stock limit
|
// Set stock limit
|
||||||
if ($_POST['action'] == 'setstocklimit')
|
if ($action == 'setstocklimit')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($_POST['id']);
|
$result=$product->fetch($_POST['id']);
|
||||||
@ -69,12 +72,12 @@ if ($_POST['action'] == 'setstocklimit')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Correct stock
|
// Correct stock
|
||||||
if ($_POST["action"] == "correct_stock" && ! $_POST["cancel"])
|
if ($action == "correct_stock" && ! $_POST["cancel"])
|
||||||
{
|
{
|
||||||
if (is_numeric($_POST["nbpiece"]))
|
if (is_numeric($_POST["nbpiece"]) && $id)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($_GET["id"]);
|
$result=$product->fetch($id);
|
||||||
|
|
||||||
$result=$product->correct_stock(
|
$result=$product->correct_stock(
|
||||||
$user,
|
$user,
|
||||||
@ -87,21 +90,21 @@ if ($_POST["action"] == "correct_stock" && ! $_POST["cancel"])
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
header("Location: product.php?id=".$product->id);
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer stock from a warehouse to another warehouse
|
// Transfer stock from a warehouse to another warehouse
|
||||||
if ($_POST["action"] == "transfert_stock" && ! $_POST["cancel"])
|
if ($action == "transfert_stock" && ! $_POST["cancel"])
|
||||||
{
|
{
|
||||||
if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
|
if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
|
||||||
{
|
{
|
||||||
if (is_numeric($_POST["nbpiece"]))
|
if (is_numeric($_POST["nbpiece"]) && $id)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($_GET["id"]);
|
$result=$product->fetch($id);
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
@ -321,10 +324,10 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
/*
|
/*
|
||||||
* Correct stock
|
* Correct stock
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == "correction")
|
if ($action == "correction")
|
||||||
{
|
{
|
||||||
print_titre($langs->trans("StockCorrection"));
|
print_titre($langs->trans("StockCorrection"));
|
||||||
print "<form action=\"product.php?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'].'">';
|
||||||
print '<input type="hidden" name="action" value="correct_stock">';
|
print '<input type="hidden" name="action" value="correct_stock">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
@ -356,16 +359,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"> ';
|
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"> ';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transfer of units
|
* Transfer of units
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == "transfert")
|
if ($action == "transfert")
|
||||||
{
|
{
|
||||||
print_titre($langs->trans("Transfer"));
|
print_titre($langs->trans("Transfer"));
|
||||||
print "<form action=\"product.php?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'].'">';
|
||||||
print '<input type="hidden" name="action" value="transfert_stock">';
|
print '<input type="hidden" name="action" value="transfert_stock">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
@ -394,7 +396,6 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -430,21 +431,23 @@ else
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
print "<div class=\"tabsAction\">\n";
|
|
||||||
|
|
||||||
//if (empty($_GET["action"]))
|
if (empty($action) && $product->id)
|
||||||
//{
|
{
|
||||||
|
print "<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
if ($user->rights->stock->creer)
|
if ($user->rights->stock->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="product.php?id='.$product->id.'&action=correction">'.$langs->trans("StockCorrection").'</a>';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=correction">'.$langs->trans("StockCorrection").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->rights->stock->mouvement->creer)
|
if ($user->rights->stock->mouvement->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="product.php?id='.$product->id.'&action=transfert">'.$langs->trans("StockMovement").'</a>';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=transfert">'.$langs->trans("StockMovement").'</a>';
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user