diff --git a/app/api/apiclient.php b/app/api/apiclient.php index 2e57b59..b08f337 100644 --- a/app/api/apiclient.php +++ b/app/api/apiclient.php @@ -32,10 +32,10 @@ function api_login($login, $password){ } -function clientbuys_kuri($client_id, $page = 1, $group_id = null){ +function clientbuys_kuri($client_id, $page = 1, $category_id = 1, $group_id = null, $filter = null){ if ($group_id == 1 or $group_id == 2){ - return clients_arch($page); + return clients_arch($page, $category_id, $filter); } $sql_sub = "SELECT number_id FROM anbuy WHERE client_id = '$client_id' AND `number_id` = 486 AND `buy_status` = '1' LIMIT 1"; //есть ли активная подписка @@ -43,25 +43,46 @@ function clientbuys_kuri($client_id, $page = 1, $group_id = null){ if (isset($findsub['number_id'])) {// есть поп - return clients_arch($page); + return clients_arch($page, $category_id, $filter); } + if ($filter !== 'all'){ + $between = "AND BeginDate BETWEEN '$filter-01-11' AND '$filter-12-31'"; + } + else + $between = ''; + $limit = 25; - $countsql = "SELECT DISTINCT COUNT(buy_id) as count FROM `anbuy` WHERE `client_id` = $client_id AND `buy_status` = '1' LIMIT 1"; + $countsql = " + SELECT + DISTINCT COUNT(buy_id) as count + FROM + `anbuy` + WHERE + `client_id` = $client_id + AND `buy_status` = '1' + $between + LIMIT 1 + "; $buycount = db_get($countsql); - - - $buysql = " SELECT DISTINCT price_id, pricehash, pricename, priceimg - FROM anbuy - LEFT JOIN price ON anbuy.number_id = price.price_id - WHERE client_id = '$client_id' AND `buy_status` = '1' - ORDER BY `buy_id` DESC - LIMIT $limit"; + FROM + anbuy + LEFT JOIN + price ON anbuy.number_id = price.price_id + WHERE + client_id = '$client_id' AND `buy_status` = '1' + AND category_id = $category_id + $between + ORDER BY + `buy_id` DESC + LIMIT + $limit + "; if ($page > 1){ $offset = $limit * ($page -1); @@ -203,19 +224,43 @@ function clientmail($mail, $hash){ //весь активный архив -function clients_arch($page = 1){ +function clients_arch($page = 16, $category_id = 1, $filter = 'all'){ $limit = 25; - $countsql = "SELECT COUNT(price_id) AS count - FROM price - WHERE category_id = 1 - LIMIT 1"; + + if ($filter !== 'all'){ + $between = "AND BeginDate BETWEEN '$filter-01-11' AND '$filter-12-31'"; + } + else + $between = ''; + + $countsql = " + SELECT + COUNT(price_id) AS count + FROM + price + WHERE + category_id = $category_id + $between + LIMIT 1 + "; $count = db_get($countsql); - $pricesql = "SELECT price_id, pricehash, pricename, priceimg FROM price WHERE category_id = 1 ORDER BY price_id DESC LIMIT $limit"; + $pricesql = " + SELECT + price_id, pricehash, pricename, priceimg + FROM + price + WHERE + category_id = $category_id + $between + ORDER BY + price_id DESC + LIMIT $limit + "; if ($page > 1){ diff --git a/app/pub/css/an.css b/app/pub/css/an.css index c76cea9..4992920 100644 --- a/app/pub/css/an.css +++ b/app/pub/css/an.css @@ -237,6 +237,9 @@ input[type="email"],input[type="password"]{ font-size: 150%; } +#year_filter{ + margin-bottom: 12px; +} @media screen and (max-width: 1000px) { header .lite-logo { diff --git a/app/pub/scripts/anviewer.js b/app/pub/scripts/anviewer.js index 76a198a..78edfae 100644 --- a/app/pub/scripts/anviewer.js +++ b/app/pub/scripts/anviewer.js @@ -182,4 +182,22 @@ function changepage(){ } +function changeyear(){ + + var e = document.getElementById("year_filter"); + var curryear = e.options[e.selectedIndex].value; + + yearurl = '/mybooks/gazeta/'; + + if (curryear !== 'all') + yearurl = yearurl + curryear + '/1'; + + location.href = yearurl; + + return true; + + +} + + diff --git a/app/routes/client.php b/app/routes/client.php index 579cead..e63d841 100644 --- a/app/routes/client.php +++ b/app/routes/client.php @@ -80,7 +80,8 @@ function addcard($id, $date) { } -function mybooks_kuri($page = 1){ +function mybooks_kuri($category = 'gazeta', $filter = 'all', $page = 1){ + $login = check_login_kuri(); @@ -89,17 +90,22 @@ function mybooks_kuri($page = 1){ header('Location: '.SITE.'login'); exit; } + + if ($category == 'gazeta') + $category_id = 1; + elseif ($category == 'books') + $category_id = 3; $limit = 25; $client = api_client_kuri($login['clienthash']); - $baseurl = SITE."mybooks/"; + $baseurl = SITE.'mybooks/'.$category.'/'.$filter.'/'; if (!$client) { echo 'Пользователь не найден'; return; } - $items = clientbuys_kuri($client['client_id'], $page, $client['clientgroup_id']); + $items = clientbuys_kuri($client['client_id'], $page, $category_id, $client['clientgroup_id'], $filter); $count = $items['count']; if ($count > $limit){ diff --git a/app/views/allbooks.phtml b/app/views/allbooks.phtml index c77689e..6f9e505 100644 --- a/app/views/allbooks.phtml +++ b/app/views/allbooks.phtml @@ -4,6 +4,19 @@ +
+ фильтр: +
+ + + +
diff --git a/app/views/layout.phtml b/app/views/layout.phtml index 05ce688..d2d501c 100644 --- a/app/views/layout.phtml +++ b/app/views/layout.phtml @@ -3,8 +3,8 @@ Еженедельник Аргументы Недели - <?=$title?> "> - - + +