Commit 285bbc82 authored by philippepary's avatar philippepary
Browse files

Fixed move action

parent d51d1355
......@@ -34,7 +34,7 @@ if (in_array("stock_multilocations", $modules)) {
$dateStr = isset($_POST['date']) ? $_POST['date'] : \i18nDate(time());
$time = \i18nRevDate($dateStr);
if (isset($_POST['reason']) && !isset($_POST['sendCsv'])) {
if (isset($_POST['reason']) && $_FILES['csv']['name'] === "") {
$reason = $_POST['reason'];
if ($multilocations) {
$locationId = $_POST['location'];
......@@ -105,7 +105,7 @@ if (isset($_POST['reason']) && !isset($_POST['sendCsv'])) {
}
}
}
} else if (isset($_POST['sendCsv'])) {
} else if (isset($_FILES['csv']['name']) && $_FILES['csv']['name'] !== "") {
$key = array('Quantity', 'Reference');
$csv = new \Pasteque\Csv($_FILES['csv']['tmp_name'], $key, array(),
......@@ -175,34 +175,7 @@ if (!$multilocations) {
array_splice($reasonNames, 3, 1);
}
//Title
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Stock move", PLUGIN_NAME)));
//Informations
\Pasteque\tpl_msg_box($message, $error);
$content = \Pasteque\row(\Pasteque\form_select("reason", \i18n("Operation", PLUGIN_NAME), $reasonIds, $reasonNames, null));
if ($multilocations) {
$content .= \Pasteque\row(\Pasteque\form_select("location", \i18n("Location"), $locIds, $locNames, null));
$content .= \Pasteque\row(\Pasteque\form_select("destination", \i18n("Destination"), $locIds, $locNames, null));
}
$content .= \Pasteque\row(\Pasteque\form_date("date",$dateStr,\i18n("Date", PLUGIN_NAME)));
$content .= \Pasteque\row(\Pasteque\form_file("file","csv",\i18n("Load csv file", PLUGIN_NAME)));
$content .= \Pasteque\row(\Pasteque\form_button(\i18n("Load", PLUGIN_NAME)));
$content .= \Pasteque\row(\Pasteque\vanillaDiv("","catalog-picker"));
$table[0][0] = "";
$table[0][1] = \i18n("Product.reference");
$table[0][2] = \i18n("Product.label");
$table[0][3] = \i18n("Quantity");
$table[0][4] = "";
$content .= \Pasteque\row(\Pasteque\standardTable($table));
$content .= \Pasteque\row(\Pasteque\form_save());
echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(),"post",$content));
\Pasteque\init_catalog("catalog", "catalog-picker", "addProduct",
$categories, $products); ?>
?>
<script type="text/javascript">
addProduct = function(productId) {
var product = catalog.getProduct(productId);
......@@ -241,8 +214,8 @@ echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(),"post",$c
html += "<td class=\"qty-cell\"><input class=\"qty\" id=\"line-" + productId + "-qty\" type=\"number\" name=\"qty-" + productId + "\" value=\"" + qty + "\" />\n";
html += "<td><a class=\"btn-delete\" href=\"\" onClick=\"javascript:deleteLine('" + productId + "');return false;\"><?php \pi18n("Delete"); ?></a></td>\n";
html += "</tr>\n";
jQuery("tobody").append(html);
}
jQuery("tbody").append(html);
}
deleteLine = function(productId) {
if(confirm("<?php \pi18n('confirm'); ?>")) {
......@@ -263,3 +236,35 @@ echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(),"post",$c
reasonChange();
<?php } ?>
</script>
<?php
//Title
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Stock move", PLUGIN_NAME)));
//Informations
\Pasteque\tpl_msg_box($message, $error);
$content = \Pasteque\row(\Pasteque\form_select("reason", \i18n("Operation", PLUGIN_NAME), $reasonIds, $reasonNames, null));
if ($multilocations) {
$content .= \Pasteque\row(\Pasteque\form_select("location", \i18n("Location"), $locIds, $locNames, null));
$content .= \Pasteque\row(\Pasteque\form_select("destination", \i18n("Destination"), $locIds, $locNames, null));
}
$content .= \Pasteque\row(\Pasteque\form_date("date",$dateStr,\i18n("Date", PLUGIN_NAME)));
$content .= \Pasteque\row(\Pasteque\vanillaDiv("","catalog-picker"));
$content .= \Pasteque\row(\Pasteque\form_file("file","csv",\i18n("Load csv file", PLUGIN_NAME)));
$content .= \Pasteque\row(\Pasteque\form_button(\i18n("Load", PLUGIN_NAME)));
$table[0][0] = "";
$table[0][1] = \i18n("Product.reference");
$table[0][2] = \i18n("Product.label");
$table[0][3] = \i18n("Quantity");
$table[0][4] = "";
$content .= \Pasteque\row(\Pasteque\standardTable($table));
$content .= \Pasteque\row(\Pasteque\form_save());
\Pasteque\init_catalog("catalog", "catalog-picker", "addProduct",
$categories, $products);
echo \Pasteque\form_generate(\Pasteque\get_current_url(),"post",$content);
?>
......@@ -27,8 +27,8 @@ $sql = "SELECT "
. "LEFT JOIN PRODUCTS ON STOCKCURRENT.PRODUCT = PRODUCTS.ID "
. "LEFT JOIN STOCKLEVEL ON STOCKCURRENT.PRODUCT = STOCKLEVEL.PRODUCT "
. "LEFT JOIN LOCATIONS ON LOCATIONS.ID = STOCKCURRENT.LOCATION "
. "WHERE (STOCKCURRENT.UNITS < STOCKLEVEL.STOCKSECURITY "
. "OR STOCKCURRENT.UNITS > STOCKLEVEL.STOCKMAXIMUM) "
. "WHERE STOCKCURRENT.UNITS < STOCKLEVEL.STOCKSECURITY "
. "OR STOCKCURRENT.UNITS > STOCKLEVEL.STOCKMAXIMUM "
. "ORDER BY STOCKLEVEL.LOCATION, PRODUCTNAME";
$fields = array("NAME","PRODUCTNAME","UNITS","STOCKSECURITY","STOCKMAXIMUM");
......
......@@ -107,7 +107,7 @@ function form_number($id, $value=null, $label=null, $step=null, $min=null, $max=
function form_date($id, $value, $label=null, $format=null, $class=null, $readonly=false) {
$ret = "<div class=\"form-group row\">\n";
if($label !== null) {
$ret = "\t<label for=\"". $id ."\" class=\"col-sm-2 control-label\">" . $label . "</label>\n";
$ret .= "\t<label for=\"". $id ."\" class=\"col-sm-2 control-label\">" . $label . "</label>\n";
}
$ret .= "\t<div data-date-autoclose=\"true\" data-date-format=\"";
if($format !== null) {
......@@ -137,7 +137,7 @@ function form_date($id, $value, $label=null, $format=null, $class=null, $readonl
function form_file($id, $name="file", $label=null, $class=null) {
$ret = "<div class=\"form-group row\">\n";
if($label !== null) {
$ret = "\t<label for=\"". $id ."\" class=\"col-sm-2 control-label\">" . $label . "</label>\n";
$ret .= "\t<label for=\"". $id ."\" class=\"col-sm-2 control-label\">" . $label . "</label>\n";
}
$ret .= "\t<div class=\"col-sm-10\">\n";
$ret .= "\t\t<input id=\"" . $id . "\" type=\"file\" name=\"" . $name . "\">\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment