Commit 90162d54 authored by philippepary's avatar philippepary
Browse files

stocks actions pages, tariff areas action page, discount profiles action...

stocks actions pages, tariff areas action page, discount profiles action pages, providers action page
parent 0125fe96
......@@ -135,31 +135,10 @@ echo \Pasteque\row(\Pasteque\buttonGroup($buttons));
//Information
\Pasteque\tpl_msg_box($message, $error);
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_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);
if ($countedStock !== null) {
foreach ($categories as $category) {
$printed = false;
$i = 1;
if (isset($prdCat[$category->id])) {
foreach ($prdCat[$category->id] as $product) {
$counted = 0;
......@@ -178,44 +157,51 @@ if ($countedStock !== null) {
}
if (!$printed) {
$printed = true;
?>
<h3><?php echo \Pasteque\esc_html($category->label); ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th></th>
<th><?php \pi18n("Product.reference"); ?></th>
<th><?php \pi18n("Product.label"); ?></th>
<th><?php \pi18n("Counted stock", PLUGIN_NAME); ?></th>
<th><?php \pi18n("Actual stock", PLUGIN_NAME); ?></th>
<th><?php \pi18n("Difference", PLUGIN_NAME); ?></th>
</tr>
</thead>
<tbody>
<?php
}
?>
<tr>
<td><img class="thumbnail" src="?<?php echo $imgSrc ?>" />
<td><?php echo $product->reference; ?></td>
<td><?php echo $product->label; ?></td>
<td><?php echo $counted ?></td>
<td><?php echo $actual; ?></td>
<td><?php echo $counted - $actual; ?></td>
</tr>
<?php
echo \Pasteque\row(\Pasteque\secondaryTitle($category->label));
$content[0][0] = "";
$content[0][1] = \i18n("Product.reference");
$content[0][2] = \i18n("Product.label");
$content[0][3] = \i18n("Counted stock", PLUGIN_NAME);
$content[0][4] = \i18n("Actual stock", PLUGIN_NAME);
$content[0][5] = \i18n("Difference", PLUGIN_NAME);
}
$content[$i][0] = "<img class=\"thumbnail\" src=\"?" . $imgSrc . "\">";
$content[$i][1] = $product->reference;
$content[$i][2] = $product->label;
$content[$i][3] = $counted;
$content[$i][4] = $actual;
$content[$i][5] = $counted - $actual;
$i++;
}
}
?>
</tbody>
</table>
<?php
echo \Pasteque\row(\Pasteque\standardTable($content));
}
}
} // end of stock comparison
else {
// FORM
$content .= \Pasteque\form_value_hidden("","send","true");
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_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_send());
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) {
......
......@@ -2,7 +2,7 @@
// Pastèque Web back office, Stocks module
//
// Copyright (C) 2013-2016 Scil (http://scil.coop)
// Philippe Pary philippe@scil.coop
// Cédric Houbart, Philippe Pary philippe@scil.coop
//
// This file is part of Pastèque.
//
......@@ -72,6 +72,7 @@ if ($multilocations) {
echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(), "post", $content));
}
unset($content);
foreach ($categories as $category) {
if (isset($prdCat[$category->id])) {
// Category header
......
<?php
// Pastèque Web back office
//
// Copyright (C) 2015 Scil (http://scil.coop)
// Copyright (C) 2015-2016 Scil (http://scil.coop)
// Cédric Houbart, Philippe Pary
//
// This file is part of Pastèque.
//
......@@ -21,27 +22,27 @@
namespace BaseStocks;
$sql = "SELECT "
. "LOCATIONS.NAME AS NAME, PRODUCTS.NAME AS PRODUCTNAME, STOCKCURRENT.UNITS, STOCKLEVEL.STOCKSECURITY, STOCKLEVEL.STOCKMAXIMUM "
. "FROM STOCKCURRENT "
. "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) "
. "OR STOCKCURRENT.UNITS < 0 "
. "ORDER BY STOCKLEVEL.LOCATION";
. "LOCATIONS.NAME AS NAME, PRODUCTS.NAME AS PRODUCTNAME, STOCKCURRENT.UNITS, STOCKLEVEL.STOCKSECURITY, STOCKLEVEL.STOCKMAXIMUM "
. "FROM STOCKCURRENT "
. "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) "
. "OR STOCKCURRENT.UNITS < 0 "
. "ORDER BY STOCKLEVEL.LOCATION";
$fields = array("NAME","PRODUCTNAME","UNITS","STOCKSECURITY","STOCKMAXIMUM");
$headers = array(
\i18n("Location.label"),
\i18n("Product.label"),
\i18n("Quantity"),
\i18n("QuantityMin"),
\i18n("QuantityMax")
\i18n("Location.label"),
\i18n("Product.label"),
\i18n("Quantity"),
\i18n("QuantityMin"),
\i18n("QuantityMax")
);
$report = new \Pasteque\Report(PLUGIN_NAME, "alert",
\i18n("Stock.AlertReport"),
$sql, $headers, $fields);
\i18n("Stock.AlertReport"),
$sql, $headers, $fields);
\Pasteque\register_report($report);
<?php
// Pastèque Web back office, Products module
//
// Copyright (C) 2013 Scil (http://scil.coop)
// Copyright (C) 2013-2016 Scil (http://scil.coop)
// Cédric Houbart, Philippe Pary philippe@scil.coop
//
// This file is part of Pastèque.
//
......@@ -18,53 +19,44 @@
// You should have received a copy of the GNU General Public License
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
// category_edit action
namespace CustomerDiscountProfiles;
$message = null;
$error = null;
$srv = new \Pasteque\DiscountProfilesService();
if (isset($_POST['id']) && isset($_POST['label'])) {
// Update profile
$profile = \Pasteque\DiscountProfile::__build($_POST['id'], $_POST['label'],
$_POST['rate']);
if ($srv->update($profile)) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
}
// Update profile
$profile = \Pasteque\DiscountProfile::__build($_POST['id'], $_POST['label'],
$_POST['rate']);
if ($srv->update($profile)) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
}
} else if (isset($_POST['label'])) {
// New profile
$profile = new \Pasteque\DiscountProfile($_POST['label'], $_POST['rate']);
$id = $srv->create($profile);
if ($id !== false) {
$message = \i18n("Discount profile saved. <a href=\"%s\">Go to the profile page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'discountprofile_edit', array('id' => $id)));
} else {
$error = \i18n("Unable to save changes");
}
// New profile
$profile = new \Pasteque\DiscountProfile($_POST['label'], $_POST['rate']);
$id = $srv->create($profile);
if ($id !== false) {
$message = \i18n("Discount profile saved. <a href=\"%s\">Go to the profile page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'discountprofile_edit', array('id' => $id)));
} else {
$error = \i18n("Unable to save changes");
}
}
$profile = null;
if (isset($_GET['id'])) {
$profile = $srv->get($_GET['id']);
$profile = $srv->get($_GET['id']);
}
?>
<h1><?php \pi18n("Edit a profile", PLUGIN_NAME); ?></h1>
<?php \Pasteque\tpl_msg_box($message, $error); ?>
//Title
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Edit a profile", PLUGIN_NAME)));
//Informations
\Pasteque\tpl_msg_box($message,$error);
<form class="edit" action="<?php echo \Pasteque\get_current_url(); ?>" method="post" enctype="multipart/form-data">
<?php \Pasteque\form_hidden("edit", $profile, "id"); ?>
<?php \Pasteque\form_input("edit", "DiscountProfile", $profile, "label", "string", array("required" => true)); ?>
<?php \Pasteque\form_input("edit", "DiscountProfile", $profile, "rate", "float", array("required" => true)); ?>
<div class="row actions">
<?php \Pasteque\form_save(); ?>
</div>
</form>
<?php if ($profile !== NULL) { ?>
<form action="<?php echo \Pasteque\get_module_url_action(PLUGIN_NAME, 'discountprofiles'); ?>" method="post">
<?php \Pasteque\form_delete("profile", $profile->id); ?>
</form>
<?php } ?>
$content .= \Pasteque\form_hidden("edit", $profile, "id");
$content .= \Pasteque\form_input("edit", "DiscountProfile", $profile, "label", "string", array("required" => true));
$content .= \Pasteque\form_input("edit", "DiscountProfile", $profile, "rate", "float", array("required" => true));
$content .= \Pasteque\form_save();
echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(), "post", $content));
?>
......@@ -2,7 +2,7 @@
// Pastèque Web back office, Users module
//
// Copyright (C) 2013-2016 Scil (http://scil.coop)
// Philippe Pary philippe@scil.coop
// Cédric Houbart, Philippe Pary philippe@scil.coop
//
// This file is part of Pastèque.
//
......@@ -25,8 +25,8 @@ $message = null;
$error = null;
$srv = new \Pasteque\DiscountProfilesService();
if (isset($_POST['delete-profile'])) {
if ($srv->delete($_POST['delete-profile'])) {
if (isset($_GET['delete-profile'])) {
if ($srv->delete($_GET['delete-profile'])) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
......@@ -39,6 +39,7 @@ $profiles = $srv->getAll();
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Discount profiles", PLUGIN_NAME)));
//Buttons
$buttons = \Pasteque\addButton(\i18n("New discount profile", PLUGIN_NAME), \Pasteque\get_module_url_action(PLUGIN_NAME, "discountprofile_edit"));
echo \Pasteque\buttonGroup($buttons);
//Informations
\Pasteque\tpl_msg_box($message,$error);
//Counter
......@@ -54,7 +55,8 @@ else {
foreach ($profiles as $profile) {
$content[$i][0] = $profile->label;
$content[$i][1] = $profile->rate;
$btn_group = \Pasteque\editButton(\i18n('Edit', PLUGIN_NAME), \Pasteque\get_module_url_action(PLUGIN_NAME, 'discountprofile_edit', array("id" => $profile->id)));
$btn_group = \Pasteque\editButton(\i18n('Edit'), \Pasteque\get_module_url_action(PLUGIN_NAME, 'discountprofile_edit', array("id" => $profile->id)));
$btn_group .= \Pasteque\deleteButton(\i18n("Delete", PLUGIN_NAME), \Pasteque\get_current_url() . "&delete-profile=" . $profile->id);
$content[$i][1] .= \Pasteque\buttonGroup($btn_group, "pull-right");
$i++;
}
......
<?php
// Pastèque Web back office, Products module
//
// Copyright (C) 2013 Scil (http://scil.coop)
// Copyright (C) 2013-2016 Scil (http://scil.coop)
// Philippe Pary
//
// This file is part of Pastèque.
//
......@@ -18,114 +19,102 @@
// You should have received a copy of the GNU General Public License
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
// provider_edit action
namespace ProductProviders;
$message = NULL;
$error = NULL;
if (isset($_POST['id']) && isset($_POST['label'])) {
if ($_FILES['image']['tmp_name'] !== "") {
$output = $_FILES['image']['tmp_name'] . "thumb";
\Pasteque\img_thumbnail($_FILES['image']['tmp_name'], $output);
$img = file_get_contents($output);
} else if ($_POST['clearImage']) {
$img = NULL;
} else {
$img = "";
}
$dispOrder = 0;
if ($_POST['dispOrder'] !== "") {
$dispOrder = intval($_POST['dispOrder']);
}
$prov = \Pasteque\provider::__build($_POST['id'], $_POST['label'], $img !== null,
$_POST['firstName'], $_POST['lastName'], $_POST['email'],
$_POST['phone1'], $_POST['phone2'], $_POST['website'], $_POST['fax'],
$_POST['addr1'], $_POST['addr2'], $_POST['zipCode'], $_POST['city'],
$_POST['region'], $_POST['country'], $_POST['notes'], $_POST['visible'],
$dispOrder);
if (\Pasteque\providersService::updateprov($prov, $img)) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
}
if ($_FILES['image']['tmp_name'] !== "") {
$output = $_FILES['image']['tmp_name'] . "thumb";
\Pasteque\img_thumbnail($_FILES['image']['tmp_name'], $output);
$img = file_get_contents($output);
} else if ($_POST['clearImage']) {
$img = NULL;
} else {
$img = "";
}
$dispOrder = 0;
if ($_POST['dispOrder'] !== "") {
$dispOrder = intval($_POST['dispOrder']);
}
$prov = \Pasteque\provider::__build($_POST['id'], $_POST['label'], $img !== null,
$_POST['firstName'], $_POST['lastName'], $_POST['email'],
$_POST['phone1'], $_POST['phone2'], $_POST['website'], $_POST['fax'],
$_POST['addr1'], $_POST['addr2'], $_POST['zipCode'], $_POST['city'],
$_POST['region'], $_POST['country'], $_POST['notes'], $_POST['visible'],
$dispOrder);
if (\Pasteque\providersService::updateprov($prov, $img)) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
}
} else if (isset($_POST['label'])) {
if ($_FILES['image']['tmp_name'] !== "") {
$img = file_get_contents($_FILES['image']['tmp_name']);
} else {
$img = NULL;
}
$dispOrder = 0;
if ($_POST['dispOrder'] !== "") {
$dispOrder = intval($_POST['dispOrder']);
}
if ($_FILES['image']['tmp_name'] !== "") {
$img = file_get_contents($_FILES['image']['tmp_name']);
} else {
$img = NULL;
}
$dispOrder = 0;
if ($_POST['dispOrder'] !== "") {
$dispOrder = intval($_POST['dispOrder']);
}
$prov = new \Pasteque\Provider($_POST['label'], $img !== null,
$_POST['firstName'], $_POST['lastName'], $_POST['email'],
$_POST['phone1'], $_POST['phone2'], $_POST['website'], $_POST['fax'],
$_POST['addr1'], $_POST['addr2'], $_POST['zipCode'], $_POST['city'],
$_POST['region'], $_POST['country'], $_POST['notes'], $_POST['visible'],
$dispOrder);
$id = \Pasteque\providersService::createprov($prov, $img);
if ($id !== FALSE) {
$message = \i18n("provider saved. <a href=\"%s\">Go to the provider page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'provider_edit', array('id' => $id)));
} else {
$error = \i18n("Unable to save changes");
}
$prov = new \Pasteque\Provider($_POST['label'], $img !== null,
$_POST['firstName'], $_POST['lastName'], $_POST['email'],
$_POST['phone1'], $_POST['phone2'], $_POST['website'], $_POST['fax'],
$_POST['addr1'], $_POST['addr2'], $_POST['zipCode'], $_POST['city'],
$_POST['region'], $_POST['country'], $_POST['notes'], $_POST['visible'],
$dispOrder);
$id = \Pasteque\providersService::createprov($prov, $img);
if ($id !== FALSE) {
$message = \i18n("provider saved. <a href=\"%s\">Go to the provider page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'provider_edit', array('id' => $id)));
} else {
$error = \i18n("Unable to save changes");
}
}
$provider = NULL;
if (isset($_GET['id'])) {
$provider = \Pasteque\providersService::get($_GET['id']);
$provider = \Pasteque\providersService::get($_GET['id']);
}
?>
<h1><?php \pi18n("Edit a provider", PLUGIN_NAME); ?></h1>
<?php \Pasteque\tpl_msg_box($message, $error); ?>
//Title
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Edit a provider", PLUGIN_NAME)));
//Informations
\Pasteque\tpl_msg_box($message, $error);
<form class="edit" action="<?php echo \Pasteque\get_current_url(); ?>" method="post" enctype="multipart/form-data">
<?php \Pasteque\form_hidden("edit", $provider, "id"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "label", "string", array("required" => true)); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "dispOrder", "numeric"); ?>
<div class="row">
<label for="image"><?php \pi18n("Image", PLUGIN_NAME); ?></label>
<div style="display:inline-block">
<input type="hidden" id="clearImage" name="clearImage" value="0" />
<?php if ($provider !== null && $provider->hasImage) { ?>
<img id="img" class="image-preview" src="?<?php echo \Pasteque\PT::URL_ACTION_PARAM; ?>=img&w=provider&id=<?php echo $provider->id; ?>" />
<a class="btn" id="clear" href="" onClick="javascript:clearImage(); return false;"><?php \pi18n("Delete"); ?></a>
<a class="btn" style="display:none" id="restore" href="" onClick="javascript:restoreImage(); return false;"><?php \pi18n("Restore"); ?></a><br />
<?php } ?>
<input type="file" name="image" />
</div>
</div>
<legend><?php \pi18n("Contact data", PLUGIN_NAME); ?></legend>
<?php \Pasteque\form_input("edit", "Provider", $provider, "firstName", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "lastName", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "email", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "phone1", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "phone2", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "website", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "fax", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "addr1", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "addr2", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "zipCode", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "city", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "region", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "country", "string"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "notes", "text"); ?>
<?php \Pasteque\form_input("edit", "Provider", $provider, "visible", "boolean"); ?>
</fieldset>
$content = \Pasteque\form_hidden("edit", $provider, "id");
$content .= \Pasteque\form_input("edit", "Provider", $provider, "label", "string", array("required" => true));
$content .= \Pasteque\form_input("edit", "Provider", $provider, "dispOrder", "numeric");
<div class="row actions">
<?php \Pasteque\form_save(); ?>
</div>
</form>
<?php if ($provider !== NULL) { ?>
<form action="<?php echo \Pasteque\get_module_url_action(PLUGIN_NAME, 'providers'); ?>" method="post">
<?php \Pasteque\form_delete("prov", $provider->id); ?>
</form>
<?php } ?>
$content .= \Pasteque\row(\Pasteque\form_file("image","image",\i18n("Image", PLUGIN_NAME)));
$content .= \Pasteque\form_value_hidden("clearImage", "clearImage", "0");
if ($provider !== null && $provider->hasImage) {
$content .= \Pasteque\row("<img id=\"img\" class=\"image-preview\" src=\"?" . \Pasteque\PT::URL_ACTION_PARAM . "=img&w=provider&id=" . $provider->id . "\">");
$buttons .= \Pasteque\jsDeleteButton(\i18n("Delete"), "javascript:clearImage();");
$buttons .= \Pasteque\jsAddButton(\i18n("Restore"), "javascript:restoreImage();");
$content .= \Pasteque\buttonGroup($buttons);
}
$fieldset_legend = \i18n("Contact data", PLUGIN_NAME);
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "firstName", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "lastName", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "email", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "phone1", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "phone2", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "website", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "fax", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "addr1", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "addr2", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "zipCode", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "city", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "region", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "country", "string");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "notes", "text");
$fieldset_fields .= \Pasteque\form_input("edit", "Provider", $provider, "visible", "boolean");
$content .= \Pasteque\form_fieldset($fieldset_legend,$fieldset_fields);
$content .= \Pasteque\form_save();
echo \Pasteque\row(\Pasteque\form_generate(\Pasteque\get_current_url(), "post", $content));
?>
<script type="text/javascript">
clearImage = function() {
......
<?php
// Pastèque Web back office, Stocks module
//
// Copyright (C) 2013 Scil (http://scil.coop)
// Copyright (C) 2013-2016 Scil (http://scil.coop)
// Cédric Houbart, Philippe Pary philippe@scil.coop
//
// This file is part of Pastèque.
//
......@@ -25,87 +26,77 @@ $error = null;
$srv = new \Pasteque\TariffAreasService();
if (isset($_POST['id'])) {
// Edit the area
$area = \Pasteque\TariffArea::__build($_POST['id'], $_POST['label'],
$_POST['dispOrder']);
foreach ($_POST as $key => $value) {
if (strpos($key, "price-") === 0) {
$productId = substr($key, 6);
$product = \Pasteque\ProductsService::get($productId);
$taxCat = \Pasteque\TaxesService::get($product->taxCatId);
$tax = $taxCat->getCurrentTax();
$price = $value / (1 + $tax->rate);
$area->addPrice($productId, $price);
}
}
if ($srv->update($area)) {
$message = \i18n("Changes saved");
} else {
$error = \i18n("Unable to save changes");
}
// Edit the area
$area = \Pasteque\TariffArea::__build($_POST['id'], $_POST['label'],
$_POST['dispOrder']);
foreach ($_POST as $key => $value) {
if (strpos($key, "price-") === 0) {
$productId = substr($key, 6);
$product = \Pasteque\ProductsService::get($productId);
$taxCat = \Pasteque\TaxesService::get($product->taxCatId);
$tax = $taxCat->getCurrentTax();
$price = $value / (1 + $tax->rate);
$area->addPrice($productId, $price);
}
}