Commit 820e3d72 authored by Karamel's avatar Karamel
Browse files

Fix some notices about undefined indexes in routes

parent 1319f074
......@@ -77,7 +77,10 @@ $app->POST('/api/cashregister',
function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
$tab = $request->getParsedBody();
$cr = CashRegister::loadFromId($tab['id'], $ptApp->getDao());
$cr = null;
if (!empty($tab['id'])) {
$cr = CashRegister::loadFromId($tab['id'], $ptApp->getDao());
}
if ($cr == null) {
$cr = new CashRegister();
}
......
......@@ -137,7 +137,10 @@ $app->POST('/api/product',
function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
$tab = $request->getParsedBody();
$prd = Product::loadFromId($tab['id'], $ptApp->getDao());
$prd = null;
if (!empty($tab['id'])) {
$prd = Product::loadFromId($tab['id'], $ptApp->getDao());
}
if ($prd == null) {
$prd = new Product();
}
......
......@@ -33,6 +33,7 @@ $app->POST('/api/role',
function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
$tab = $request->getParsedBody();
$role = null;
if (!empty($tab['id'])) {
$role = Role::loadFromId($tab['id'], $ptApp->getDao());
}
......
......@@ -37,7 +37,10 @@ $app->POST('/api/tariffarea',
function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
$tab = $request->getParsedBody();
$ta = TariffArea::loadFromId($tab['id'], $ptApp->getDao());
$ta = null;
if (!empty($tab['id'])) {
$ta = TariffArea::loadFromId($tab['id'], $ptApp->getDao());
}
if ($ta == null) {
$ta = new TariffArea();
}
......
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