// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // 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 StockMultilocations; $message = null; $error = null; $srv = new \Pasteque\LocationsService(); if (isset($_POST['id']) && isset($_POST['label'])) { // Update location $location = \Pasteque\Location::__build($_POST['id'], $_POST['label']); if ($srv->update($location)) { $message = \i18n("Changes saved"); } else { $error = \i18n("Unable to save changes"); } } else { if (isset($_POST['label'])) { // New location $location = new \Pasteque\Location($_POST['label']); $id = $srv->create($location); if ($id !== false) { $message = \i18n("Location saved. <a href=\"%s\">Go to the location page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'location_edit', array('id' => $id))); } else { $error = \i18n("Unable to save changes"); } }