diff --git a/Layout/default/Admin/ivtimport_product_match.php b/Layout/default/Admin/ivtimport_product_match.php index eef62b011..c447e819e 100644 --- a/Layout/default/Admin/ivtimport_product_match.php +++ b/Layout/default/Admin/ivtimport_product_match.php @@ -1,3 +1,8 @@ +getUrl($Mod,"ivtImportMatchProducts"); + $pagination_baseurl_params = ["filter" => $filter]; + $pagination_entity_name = "IVT Products"; +?> @@ -19,33 +24,50 @@
+ + + + + - - - - - - - + + + + + + + + + +
IVT Produkt Preis Interval Typ thetool Produktivt_id hinterlegt
name?>price?>interval?>typ?> - -
name?>price?>interval?>typ?>id?> + + " : ""?>
+ + + +
diff --git a/Layout/default/tpl/pagination.php b/Layout/default/tpl/pagination.php index c15392242..8e83e2382 100644 --- a/Layout/default/tpl/pagination.php +++ b/Layout/default/tpl/pagination.php @@ -66,15 +66,24 @@ if($mfPagination_pagecount < 12) { } +if(count($pagination_baseurl_params)) { + $baseurl_with_params = $pagination_baseurl."?".http_build_query($pagination_baseurl_params); + if(substr($baseurl_with_params, -1, 1) != "&" && substr($baseurl_with_params, -1, 1) != "?") { + $baseurl_with_params .= "&"; + } +} else { + $baseurl_with_params = $pagination_baseurl."?"; +} + ?> diff --git a/application/Admin/AdminController.php b/application/Admin/AdminController.php index 59ad538a4..4f59656c8 100644 --- a/application/Admin/AdminController.php +++ b/application/Admin/AdminController.php @@ -41,8 +41,40 @@ class AdminController extends mfBaseController { protected function ivtImportMatchProductsAction() { $this->layout()->setTemplate("Admin/ivtimport_product_match"); - $ivtproducts = IvtProductModel::getAll(); + $filter_name = MFAPPNAME.'-Admin-ivtimport_product-filter'; + if($this->request->resetFilter) { + unset($_SESSION[$filter_name]); + } + + $filter = []; + if(is_array($this->request->filter)) { + $filter = $this->request->filter; + $_SESSION[$filter_name] = $filter; + } else { + if(array_key_exists($filter_name, $_SESSION) && count($_SESSION[$filter_name])) { + $filter = $_SESSION[$filter_name]; + } + } + + $this->layout->set("filter", $filter); + //$filter = $this->getPreparedFilter($filter); + + // pagination defaults + $pagination = []; + $pagination['start'] = 0; + $pagination['count'] = 20; + $pagination['maxItems'] = 0; + + if(is_numeric($this->request->s)) { + $pagination['start'] = intval($this->request->s); + } + //var_dump($filter);exit; + $pagination['maxItems'] = IvtProductModel::count($filter); + $ivtproducts = IvtProductModel::search($filter, $pagination); + + $this->layout()->set("pagination", $pagination); $this->layout()->set("ivtproducts", $ivtproducts); + $this->layout()->set("products", ProductModel::getActive()); } } \ No newline at end of file diff --git a/application/IvtProduct/IvtProductModel.php b/application/IvtProduct/IvtProductModel.php index 4d5d23a4b..79ee5b07f 100644 --- a/application/IvtProduct/IvtProductModel.php +++ b/application/IvtProduct/IvtProductModel.php @@ -37,12 +37,26 @@ class IvtProductModel { return null; } + public static function count($filter) { + $db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) cnt FROM products WHERE $where ORDER by id"; + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + public static function search($filter, $limit = false) { $items = []; $db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME); $where = self::getSqlFilter($filter); - $sql = "SELECT * FROM products $where ORDER by id"; + $sql = "SELECT * FROM products WHERE $where ORDER by id"; mfLoghandler::singleton()->debug($sql); if(is_array($limit) && count($limit)) {