Commit a573858a authored by Cédric Houbart's avatar Cédric Houbart
Browse files

Multiple locations for inventory

parent 323d9eb7
......@@ -166,6 +166,22 @@ function form_input($form_id, $class, $object, $field, $type, $args = array()) {
echo "</div>";
}
/** Create a select with given labels. For relation in a model use form_input
* with type pick */
function form_select($id, $label, $values, $labels, $currentValue) {
echo "<label for=\"" . $id ."\">" . $label . "</label>";
echo "<select id=\"" . $id . "\" name=\"" . $id . "\">>";
for ($i = 0; $i < count($values); $i++) {
$selected = "";
if ($values[$i] == $currentValue) {
$selected = ' selected="true"';
}
echo '<option value="' . $values[$i] . '"' . $selected . '>'
. $labels[$i] . '</option>';
}
echo "</select>";
}
function form_send() {
echo '<button class="btn-send" type="submit">' . \i18n('Send') . '</button>';
}
......
......@@ -118,5 +118,7 @@
"Currency.format": "Format",
"Currency.active": "Active",
"Resource.label": "Label"
"Resource.label": "Label",
"Location": "Warehouse"
}
......@@ -118,5 +118,7 @@
"Currency.format": "Format",
"Currency.active": "Active",
"Resource.label": "Désignation"
"Resource.label": "Désignation",
"Location": "Entrepôt"
}
......@@ -20,12 +20,36 @@
namespace BaseStocks;
$locSrv = new \Pasteque\LocationsService();
$locations = $locSrv->getAll();
$locNames = array();
$locIds = array();
foreach ($locations as $location) {
$locNames[] = $location->label;
$locIds[] = $location->id;
}
$currLocation = null;
if (isset($_POST['location'])) {
$currLocation = $_POST['location'];
}
$products = \Pasteque\ProductsService::getAll();
$stocks = \Pasteque\StocksService::getQties();
$levels = \Pasteque\StocksService::getLevels();
$stocks = \Pasteque\StocksService::getQties($currLocation);
$levels = \Pasteque\StocksService::getLevels($currLocation);
?>
<h1><?php \pi18n("Inventory", PLUGIN_NAME); ?></h1>
<?php if (count($locations) > 1) { ?>
<form class="edit" action="<?php echo \Pasteque\get_current_url(); ?>" method="post">
<div class="row">
<?php \Pasteque\form_select("location", \i18n("Location"), $locIds, $locNames, $currLocation); ?>
</div>
<div class="row actions">
<?php \Pasteque\form_send(); ?>
</div>
</form>
<?php } ?>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
......
Supports Markdown
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