Added product active flag, saving filter in Product/Index
This commit is contained in:
@@ -19,16 +19,23 @@ class ProductController extends mfBaseController {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
if($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME.'-Product-filter']);
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[MFAPPNAME.'-Product-filter'] = $filter;
|
||||
} else {
|
||||
if(array_key_exists(MFAPPNAME.'-Product-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Product-filter'])) {
|
||||
$filter = $_SESSION[MFAPPNAME.'-Product-filter'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
if($filter) {
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
}
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
@@ -55,6 +62,15 @@ class ProductController extends mfBaseController {
|
||||
unset($filter['name']);
|
||||
}
|
||||
|
||||
if(array_key_exists("active", $filter)) {
|
||||
if($filter['active'] != "all") {
|
||||
$new_filter['active'] = $filter['active'];
|
||||
}
|
||||
unset($filter['active']);
|
||||
} else {
|
||||
$new_filter['active'] = 1;
|
||||
}
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
@@ -128,7 +144,11 @@ class ProductController extends mfBaseController {
|
||||
}
|
||||
$data['external_id'] = $r->external_id;
|
||||
}
|
||||
//var_dump($data);exit;
|
||||
|
||||
$data['active'] = 1;
|
||||
if(!$r->active) {
|
||||
$data['active'] = 0;
|
||||
}
|
||||
|
||||
$data['price_nne'] = ($r->price_nne) ? Layout::commaToDot($r->price_nne) : 0;
|
||||
$data['price_nbe'] = ($r->price_nbe) ? Layout::commaToDot($r->price_nbe) : 0;
|
||||
@@ -229,7 +249,12 @@ class ProductController extends mfBaseController {
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Produkt erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Product", "Edit", ['id' => $new_id]);
|
||||
if($r->return == "index") {
|
||||
$this->redirect("Product");
|
||||
} else {
|
||||
$this->redirect("Product", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function deleteAction() {
|
||||
@@ -310,14 +335,14 @@ class ProductController extends mfBaseController {
|
||||
$products = [];
|
||||
|
||||
if(is_numeric($search)) {
|
||||
$pnumbers = ProductModel::search(["id" => $search]);
|
||||
$pnumbers = ProductModel::search(["active" => 1, "id" => $search]);
|
||||
if($pnumbers) {
|
||||
$products = array_merge($products, $pnumbers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$products = array_merge($products, ProductModel::search(["name%" => $search]));
|
||||
$products = array_merge($products, ProductModel::search(["active" => 1, "name%" => $search]));
|
||||
|
||||
if(!is_array($products) && !count($products)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user