public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Categories", $_POST);
         $this->session->conditions = $query->getConditions();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->session->conditions) {
         $parameters["conditions"] = $this->session->conditions;
     }
     $parameters["order"] = "id";
     $categories = Categories::find($parameters);
     if (count($categories) == 0) {
         $this->flash->notice("The search did not find any categories");
         return $this->dispatcher->forward(array("controller" => "categories", "action" => "index"));
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $categories, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
 public function loanAction()
 {
     /* 		$id = $this->filter->sanitize($id, array("int"));
     		
     		if($id){
     			$searchParams = array("id = '".$id."'");
     			
     			$loan = Loan::findFirst($searchParams);
     			$this->view->setVar("loan", $loan);
     			
     			$pawn = Pawn::find("bid = ".$id);
     			$this->view->pawn = $pawn;
     		}else{
     			$this->flash->error("没有找到对应的借款");
     			return $this->forward("loan/index");
     		}	 */
     $auth = $this->session->get("auth");
     $id = $auth['cid'];
     $searchParams = array();
     $searchParams = array("id = '" . $id . "'");
     $debts = Debts::find(array("cid = " . $id, "order" => "pay_time desc"));
     if (count($customer) == 0) {
         $this->flash->notice("没有找到对应的债权信息");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $debts, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->page = $page;
     $this->view->setVar("uid", $id);
     /* 		$account = Account::findFirst("cid = ".$id);
     		if(isset($account->id)){
     			$this->view->hasAccount = 1;
     		}else{
     			$this->view->hasAccount = 0;
     		}	 */
 }
예제 #3
0
 public function indexAction()
 {
     $numberPage = 1;
     if (isset($_GET['tags'])) {
         $tags = $this->request->getQuery("tags", "string");
         $criteria = new \Phalcon\Mvc\Model\Criteria();
         $criteria->setModelName("\\Models\\Posts");
         //$criteria->setDI($this->di);
         $criteria->where("tags LIKE :tags:");
         $criteria->andWhere("status = :1:");
         $criteria->bind(array('tags' => "%{$tags}%", '1' => '0'));
         $this->persistent->searchParams = $criteria->getParams();
         $models = \Models\Posts::find($criteria);
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if (!$numberPage or $numberPage <= 0) {
             $numberPage = 1;
         }
         if ($numberPage > 1 and !\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
             $models = \Models\Posts::find($this->persistent->searchParams);
         } else {
             $models = \Models\Posts::find("status = '0'");
             $this->persistent->searchParams = null;
         }
     }
     if (!$models->count()) {
         $this->flashSession->notice("Ничего не найдено");
         $this->persistent->searchParams = null;
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $models, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     //$this->view->setVar('searchparams', $this->persistent->searchParams);
     //$this->view->setVar('numpage', $numberPage);
 }
 public function indexAction()
 {
     $request = new Request();
     $this->view->setVar("title", "Інспектори");
     $search = trim($request->get("search"));
     $pageCount = $request->get("page-count") ? $request->get("page-count") : $this->session->get("page-count");
     if ($pageCount) {
         $this->session->set("page-count", $pageCount);
     }
     $orderColumn = trim($request->get("order-column")) . " " . trim($request->get("order-type"));
     $offset = $request->get("page") * $pageCount - $pageCount;
     $inspectorsQuery = \Users::query()->rightJoin("UserGroups")->where("UserGroups.group_id = 3");
     $pageCount = $pageCount ? $pageCount : self::$ITEMS_ON_PAGE;
     $inspectorsQuery->limit($pageCount, $offset >= 0 ? $offset : null);
     if ($orderColumn and !empty($orderColumn)) {
         $inspectorsQuery->orderBy(trim($orderColumn) ? $orderColumn : "last_name ASC");
     }
     if ($search and !empty($search)) {
         $searchBind = "'%" . $search . "%'";
         $inspectorsQuery->andWhere("name LIKE {$searchBind} OR last_name LIKE {$searchBind} OR second_name LIKE {$searchBind} OR email LIKE {$searchBind} OR pmobile LIKE {$searchBind}");
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $inspectorsQuery->execute(), "limit" => $pageCount ? $pageCount : self::$ITEMS_ON_PAGE, "page" => $request->get("page")));
     $page = $paginator->getPaginate();
     $this->view->page = $page;
     $this->view->countItems = count($page->items);
     $this->view->search = $search;
     $this->view->orderColumn = $request->get("order-column");
     $this->view->orderType = $request->get("order-type");
     $this->view->pageCount = $pageCount;
 }
예제 #5
0
 public function indexAction($page = 1)
 {
     // $parameters["order"] = "id desc";
     $users = Rights::find($parameters);
     $paginator = new \Phalcon\Paginator\Adapter\Model(array('data' => $users, 'limit' => 20, 'page' => $page));
     $this->view->page = $paginator->getPaginate();
 }
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Companies", $_POST);
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $companies = Department::find($parameters);
     if (count($companies) == 0) {
         $this->flash->notice("没有找到对应的部门");
         return $this->forward("companies/index");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $companies, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("companies", $companies);
 }
예제 #7
0
 public function indexAction()
 {
     $type = $this->dispatcher->getParam('type', 'string');
     $typeModel = Type::getCachedBySlug($type);
     if (!$typeModel) {
         throw new Exception("Publication hasn't type = '{$type}''");
     }
     $typeLimit = $typeModel->getLimit() ? $typeModel->getLimit() : 10;
     $limit = $this->request->getQuery('limit', 'string', $typeLimit);
     if ($limit != 'all') {
         $paginatorLimit = (int) $limit;
     } else {
         $paginatorLimit = 9999;
     }
     $page = $this->request->getQuery('page', 'int', 1);
     $publications = Publication::find(array("type_id = {$typeModel->getId()}", "order" => "date DESC"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $publications, "limit" => $paginatorLimit, "page" => $page));
     $this->view->paginate = $paginator->getPaginate();
     $this->helper->title()->append($typeModel->getHead_title());
     if ($page > 1) {
         $this->helper->title()->append($this->helper->translate('Страница №') . ' ' . $page);
     }
     $this->view->title = $typeModel->getTitle();
     $this->view->format = $typeModel->getFormat();
     $this->view->type = $type;
     $this->helper->menu->setActive($type);
 }
예제 #8
0
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Products", $_POST);
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $products = Products::find($parameters);
     if (count($products) == 0) {
         $this->flash->notice("The search did not find any products");
         return $this->forward("products/index");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 5, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
예제 #9
0
 public function indexAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = \Phalcon\Mvc\Model\Criteria::fromInput($this->di, "Models\\News", $_POST);
         $query->order("id ASC, title ASC");
         $this->persistent->searchParams = $query->getParams();
         if (!\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
             $news = \Models\News::find($this->persistent->searchParams);
         }
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if (!$numberPage or $numberPage <= 0) {
             $numberPage = 1;
         }
         if ($numberPage > 1 and !\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
             $news = \Models\News::find($this->persistent->searchParams);
         } else {
             $news = \Models\News::find();
             $this->persistent->searchParams = null;
         }
     }
     if (count($news) == 0) {
         $this->flashSession->notice("Не найдено ни одной новости");
         $this->persistent->searchParams = null;
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $news, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar('searchparams', $this->persistent->searchParams);
     $this->view->setVar('numpage', $numberPage);
 }
예제 #10
0
 public function chatAction()
 {
     $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     if ($this->request->hasPost('chat_id')) {
         $chat = Chat::findFirst($this->request->getPost('chat_id'));
         ///////////////// Пагинация
         if (!empty($_POST['page'])) {
             $currentPage = $_POST["page"];
         } else {
             $currentPage = 1;
         }
         $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $chat->getchatmicrodialog(), "limit" => 10, "page" => $currentPage));
         $page = $paginator->getPaginate();
         if ($chatmicrodialog = $page->items) {
             foreach ($chatmicrodialog as $micro) {
                 foreach ($micro->messagechat as $mess) {
                     if ($mess->id == $micro->base_mess_id) {
                         $microd[$micro->id]['base'] = $mess->toArray();
                     } else {
                         $microd[$micro->id]['mess'][] = $mess->toArray();
                     }
                 }
             }
             //  echo '<pre>';  print_r($microd); echo '<pre>';
         }
         $this->view->setVars(array('chat' => $microd = isset($microd) ? $microd : false, 'chat_id' => $this->request->getPost('chat_id'), 'page_num' => $page->current, 'page_total' => $page->total_pages));
     }
 }
예제 #11
0
 public function indexAction()
 {
     $currentPage = 1;
     $currentPage = $this->request->get("page");
     $products = Products::find();
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 4, "page" => $currentPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
예제 #12
0
 public function indexAction()
 {
     $searchWords = '';
     $categories = EventsCategories::find();
     $countries = Countries::find();
     if (isset($_GET['page'])) {
         $currentPage = (int) $_GET['page'];
     } else {
         $currentPage = 1;
     }
     if ($this->request->isPost()) {
         //$this->view->disable();
         $name = $this->request->getPost('name');
         $street = $this->request->getPost('street');
         $city = $this->request->getPost('city');
         $country = $this->request->getPost('country');
         $category = $this->request->getPost('category');
         $conditions = '';
         if (!empty($name)) {
             $conditions = ' OR name LIKE :name:';
             $bind['name'] = $name;
             $searchWords .= ", " . $name;
         }
         if (!empty($street)) {
             $conditions .= ' OR street LIKE :street:';
             $bind['street'] = $street;
             $searchWords .= ", " . $street;
         }
         if (!empty($city)) {
             $conditions .= ' OR city LIKE :city:';
             $bind['city'] = $city;
             $searchWords .= ", " . $city;
         }
         if (!empty($country)) {
             $conditions .= ' OR country_id LIKE :country:';
             $bind['country'] = $country;
             $searchWords .= ", country id:" . $country;
         }
         if (!empty($category)) {
             $conditions .= ' OR event_category_id LIKE :category:';
             $bind['category'] = $category;
             $searchWords .= ", category id: " . $category;
         }
         $events = Events::find(['columns' => '*', 'conditions' => substr($conditions, 3), 'bind' => $bind]);
         $this->view->setVars(['events' => $events, 'categories' => $categories, 'countries' => $countries]);
     } else {
         //$this->view->disable();
         $events = Events::find(['order' => 'id DESC']);
         $this->view->setVars(['events' => $events, 'categories' => $categories, 'countries' => $countries]);
     }
     //$this->view->disable();
     $paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $events, "limit" => 12, "page" => $currentPage]);
     $page = $paginator->getPaginate();
     $this->view->setVar('thing_p', $page);
 }
예제 #13
0
 public function indexAction()
 {
     $searchWords = '';
     $business = array();
     if (isset($_GET["page"])) {
         $currentPage = (int) $_GET["page"];
     } else {
         $currentPage = 1;
     }
     if ($this->request->isPost()) {
         $businessName = $this->request->getPost('name');
         $businessAddress = $this->request->getPost('address');
         $businessCategoryId = $this->request->getPost('business_category_id');
         $businessCategory = BusinessCategories::findFirst($businessCategoryId);
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'country LIKE :country:', 'bind' => array('country' => $businessAddress)));
         $countryId = '';
         if ($country) {
             $countryId = $country->id;
         }
         $conditions = '';
         $bind = array();
         if (!empty($businessName)) {
             $conditions .= ' OR name LIKE :name:';
             $bind['name'] = '%' . $businessName . '%';
             $searchWords .= ', ' . $businessName;
         }
         if (!empty($businessAddress)) {
             $conditions .= ' OR street LIKE :street:';
             $bind['street'] = '%' . $businessAddress . '%';
             $conditions .= ' OR city LIKE :city:';
             $bind['city'] = '%' . $businessAddress . '%';
             $searchWords .= ', ' . $businessAddress;
         }
         if (!empty($countryId)) {
             $conditions .= ' OR country_id LIKE :country_id:';
             $bind['country_id'] = $countryId;
             $searchWords .= ', ' . $country->country;
         }
         if (!empty($businessCategoryId)) {
             $conditions .= ' OR business_category_id = :business_category_id:';
             $bind['business_category_id'] = $businessCategoryId;
             $searchWords .= ', ' . $businessCategory->name;
         }
         $business = Business::find(array('columns' => '*', 'conditions' => substr($conditions, 3), 'bind' => $bind));
     } else {
         $realties = Realties::find();
     }
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $realties, "limit" => 10, "page" => $currentPage));
     $page = $paginator->getPaginate();
     $this->view->setVar('searchWords', $searchWords);
     $this->view->setVar('realties', $page);
     $realtyCategories = RealtyCategories::find();
     $this->view->setVar('realtyCategories', $realtyCategories);
 }
예제 #14
0
 public function indexAction()
 {
     // set page title
     $this->view->pageTitle = 'Countries';
     // process get
     if ($this->request->isGet()) {
         // Current page to show
         $currentPage = $this->request->getQuery('page', 'int');
         $currentPage = empty($currentPage) ? 1 : $currentPage;
         // items per page
         $itemsPerPage = $this->request->getQuery('limit', 'int');
         $itemsPerPage = empty($itemsPerPage) ? $this->config->application['pagination']['itemsPerPage'] : $itemsPerPage;
         // filter
         $filter = $this->request->getQuery('filter', 'trim');
         // sort
         $sortBy = $this->request->getQuery('sort', 'string');
         $sortBy = empty($sortBy) ? 'name' : $sortBy;
         // direction
         $sortDirection = $this->request->getQuery('direction', 'string');
         $sortDirection = empty($sortDirection) ? 'asc' : $sortDirection;
     } else {
         // set defaults
         $currentPage = 1;
         $itemsPerPage = $this->config->application['pagination']['itemsPerPage'];
         $filter = null;
         $sortBy = 'name';
         $sortDirection = 'desc';
     }
     // order by
     if ($sortBy == 'date') {
         $orderBy = 'created ' . strtoupper($sortDirection);
     } elseif ($sortBy == 'name') {
         $orderBy = 'name ' . strtoupper($sortDirection);
     }
     // get all user activity logs
     if (!empty($filter)) {
         // find countries using filter
         $country = Countries::find(array('name LIKE :filter:', 'order' => $orderBy, 'bind' => array('filter' => '%' . $filter . '%')));
     } else {
         $country = Countries::find(array('order' => $orderBy));
     }
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $country, "limit" => $itemsPerPage, "page" => $currentPage));
     // Get the paginated results
     $this->view->page = $paginator->getPaginate();
     $this->view->itemsPerPage = $itemsPerPage;
     $this->view->filter = $filter;
     $this->view->sort = $sortBy;
     $this->view->direction = $sortDirection;
     $this->view->dropdownLinks = array('edit' => '/country/edit', 'delete' => '/country/delete');
 }
예제 #15
0
 public function indexAction()
 {
     $numberPage = 1;
     $numberPage = $this->request->getQuery("page", "int");
     if (!$numberPage or $numberPage <= 0) {
         $numberPage = 1;
     }
     $models = \Models\Articles::find("status = '0'");
     if (!$models->count()) {
         return $this->flashSession->notice("Не найдено ни одной новости");
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $models, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
예제 #16
0
 public function indexAction()
 {
     $limit = $this->request->getQuery('limit', 'string', 6);
     if ($limit != 'all') {
         $paginatorLimit = (int) $limit;
     } else {
         $paginatorLimit = 9999;
     }
     $page = $this->request->getQuery('page', 'int', 1);
     $projects = Project::find(array("visible = 1", array("order" => "sortorder DESC")));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $projects, "limit" => $paginatorLimit, "page" => $page));
     $this->view->paginate = $paginator->getPaginate();
     $this->helper->title()->append('Галерея проектов');
     $this->view->navigationActive = 'projects';
     $this->view->limit = $limit;
 }
예제 #17
0
 /**
  * @param int $currentPage
  * @param int $limit
  */
 public function modelAction($currentPage = 10, $limit = 10)
 {
     $startMemoryUsage = memory_get_peak_usage();
     $startTime = microtime(true);
     $currentPage = max(1, (int) $currentPage);
     $limit = max(1, (int) $limit);
     $users = \Models\User::find();
     $paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $users, "limit" => $limit, "page" => $currentPage]);
     $paginator->getPaginate();
     $finishTime = microtime(true);
     $finishMemoryUsage = memory_get_peak_usage();
     echo "Memory peak usage: ";
     echo $finishMemoryUsage - $startMemoryUsage . "\n";
     echo "Time: ";
     echo $finishTime - $startTime . "\n";
 }
 public function indexAction()
 {
     $request = new Request();
     $this->view->setVar("title", "Дилери");
     $search = trim($request->get("search"));
     $pageCount = $request->get("page-count") ? $request->get("page-count") : $this->session->get("page-count");
     if ($pageCount) {
         $this->session->set("page-count", $pageCount);
     }
     $orderColumn = trim($request->get("order-column")) . " " . trim($request->get("order-type"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => \Dealers::find(array("order" => trim($orderColumn) ? $orderColumn : "title ASC", "conditions" => "title LIKE ?1 OR address LIKE ?1 ", "bind" => array(1 => "%" . $search . "%"))), "limit" => $pageCount ? $pageCount : 30, "page" => $request->get("page")));
     $page = $paginator->getPaginate();
     $this->view->page = $page;
     $this->view->countItems = count($page->items);
     $this->view->search = $search;
     $this->view->orderColumn = $request->get("order-column");
     $this->view->orderType = $request->get("order-type");
     $this->view->pageCount = $pageCount;
 }
 public function indexAction()
 {
     $this->view->title = $this->trans->_("students");
     $request = new Request();
     $students = \Students::find();
     $search = trim($request->get("search"));
     $pageCount = $request->get("page-count") ? $request->get("page-count") : $this->session->get("page-count");
     if ($pageCount) {
         $this->session->set("page-count", $pageCount);
     }
     $orderColumn = trim($request->get("order-column")) . " " . trim($request->get("order-type"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => \Students::find(array("order" => trim($orderColumn) ? $orderColumn : "id ASC", "conditions" => "id LIKE ?1 ", "bind" => array(1 => "%" . $search . "%"))), "limit" => $pageCount ? $pageCount : 30, "page" => $request->get("page")));
     $page = $paginator->getPaginate();
     $this->view->page = $page;
     //$this->view->users=$students->;
     $this->view->countItems = count($page->items);
     $this->view->search = $search;
     $this->view->orderColumn = $request->get("order-column");
     $this->view->orderType = $request->get("order-type");
     $this->view->pageCount = $pageCount;
 }
예제 #20
0
 public function indexAction()
 {
     $page = $this->request->getQuery('page', 'int', 1);
     $type = $this->dispatcher->getParam('type');
     $type_id = null;
     $types = Type::find();
     $cond_array = [];
     if ($type) {
         $typeEntity = Type::getCachedBySlug($type);
         $type_id = $typeEntity->getId();
         $cond_array[] = "type_id = {$type_id}";
     }
     $conditions = implode(' AND ', $cond_array);
     $publications = Publication::find(["conditions" => $conditions, "order" => "date DESC, id DESC"]);
     $paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $publications, "limit" => 20, "page" => $page]);
     $this->view->paginate = $paginator->getPaginate();
     $this->view->types = $types;
     $this->view->type = $type;
     $this->view->type_id = $type_id;
     $this->helper->title($this->helper->at('Manage Publications'), true);
 }
예제 #21
0
 public function indexAction()
 {
     $searchWords = '';
     //$things = [];
     if (isset($_GET['page'])) {
         $currentPage = (int) $_GET["page"];
     } else {
         $currentPage = 1;
     }
     if ($this->request->isPost()) {
         $name = $this->request->getPost('name');
         $category_id = $this->request->getPost('thing_category_id');
         $price_from = $this->request->getPost('price_from');
         $price_to = $this->request->getPost('price_to');
         $conditions = '';
         if (!empty($name)) {
             $conditions = ' OR name LIKE :name:';
             $bind['name'] = $name;
         }
         if (!empty($category_id)) {
             $conditions = ' OR thing_category_id LIKE :category:';
             $bind['category'] = $category_id;
         }
         // if (!empty($price_from) && !empty($price_to)) {
         //     $conditions = ' price BETWEEN ?1 AND ?2';
         //     $bind[1] = $price_from;
         //     $bind[2] = $price_to;
         // }
         //$this->view->disable();
         $things = Things::find(['columns' => '*', 'conditions' => substr($conditions, 3), 'bind' => $bind]);
         $this->view->setVars(['things' => $things, 'thing_categories' => ThingCategories::find()]);
         // $this->session->set("filter", [$name, $category_id, $price_from, $price_to]);
     } else {
         $things = Things::find(['order' => 'id DESC']);
         $this->view->setVars(['things' => $things, 'thing_categories' => ThingCategories::find()]);
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $things, "limit" => 12, "page" => $currentPage]);
     $page = $paginator->getPaginate();
     $this->view->setVar('thing_p', $page);
 }
예제 #22
0
 public function indexAction()
 {
     $type = $this->dispatcher->getParam('type', 'string');
     if (!$type || !in_array($type, array_keys(Publication::$types))) {
         throw new Exception("Publication hasn't type = '{$type}''");
     }
     $limit = $this->request->getQuery('limit', 'string', 10);
     if ($limit != 'all') {
         $paginatorLimit = (int) $limit;
     } else {
         $paginatorLimit = 9999;
     }
     $page = $this->request->getQuery('page', 'int', 1);
     $publications = Publication::find(array("type = '{$type}'", "order" => "date DESC"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $publications, "limit" => $paginatorLimit, "page" => $page));
     $this->view->paginate = $paginator->getPaginate();
     $title = Publication::$types[$type];
     $this->helper->title()->append($title);
     $this->view->title = $title;
     //$this->view->limit = $limit;
     $this->view->type = $type;
 }
 public function childAction($id)
 {
     $numberPage = 1;
     $numberPage = $this->request->getQuery("page", "int");
     if ($numberPage <= 0) {
         $numberPage = 1;
     }
     $parameters = array();
     if ($id) {
         $parameters = array("fid =" . $id);
     }
     $productTypes = Types::find($parameters);
     if (count($productTypes) == 0) {
         $this->flash->notice("没有找到对应下级类型");
         return $this->forward("producttypes/newtypes/" . $id);
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $productTypes, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("id", $id);
     $this->view->setVar("page", $page);
     $this->view->setVar("productTypes", $productTypes);
 }
 public function indexAction()
 {
     $numberPage = 1;
     $searchParams = array();
     if ($this->request->isPost()) {
         //$query = Criteria::fromInput($this->di, "Customer", $_POST);
         $keyword = trim($this->request->getPost("keyword", "striptags"));
         if (isset($keyword) && $keyword != '') {
             if (strlen($keyword) == 18) {
                 $searchParams = array("number = '" . $keyword . "'");
             } else {
                 $searchParams = array("name = '" . $keyword . "'");
             }
             //$this->persistent->searchParams = $query->getParams();
         } else {
             $this->flash->notice("请重新输入搜索条件");
         }
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($searchParams) {
         $parameters = $searchParams;
     }
     $customer = Customer::find($parameters);
     if (count($customer) == 0) {
         $this->flash->notice("没有找到对应的合同");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $customer, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("customer", $customer);
 }
예제 #25
0
 public function estIssue826()
 {
     $this->_loadDI();
     $personnes = Personnes::find();
     $paginator = new Phalcon\Paginator\Adapter\Model(array('data' => $personnes, 'limit' => 1, 'page' => 1));
     $paginator->setCurrentPage(2179);
     $page = $paginator->getPaginate();
     $this->assertEquals(count($page->items), 1);
     $this->assertEquals($page->before, 2178);
     $this->assertEquals($page->next, 2180);
     $this->assertEquals($page->last, 2180);
     $this->assertEquals($page->current, 2179);
     $this->assertEquals($page->total_pages, 2180);
 }
예제 #26
0
 public function business_searchAction()
 {
     $searchWords = '';
     $business = array();
     if (isset($_GET["page"])) {
         $currentPage = (int) $_GET["page"];
     } else {
         $currentPage = 1;
     }
     if ($this->request->isPost()) {
         $businessName = $this->request->getPost('name');
         $businessAddress = $this->request->getPost('address');
         $businessCategoryId = $this->request->getPost('business_category_id');
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'country LIKE :country:', 'bind' => array('country' => $businessAddress)));
         $countryId = '';
         if ($country) {
             $countryId = $country->id;
         }
         $businessCategoryLists = BusinessCategoryLists::find(array('columns' => '*', 'conditions' => 'business_category_id = :business_category_id:', 'bind' => array('business_category_id' => $businessCategoryId)));
         $conditions = '';
         if (!empty($businessCategoryLists)) {
             foreach ($businessCategoryLists as $key => $businessCategoryList) {
                 $conditions .= ' OR id = :' . $key . ':';
                 $bind[$key] = $businessCategoryList->business_id;
             }
             //$searchWords .= ', '.$businessName;
         }
         if (!empty($businessName)) {
             $conditions .= ' OR name LIKE :name:';
             $bind['name'] = '%' . $businessName . '%';
             $searchWords .= ', ' . $businessName;
         }
         if (!empty($businessAddress)) {
             $conditions .= ' OR street LIKE :street: OR city LIKE :city:';
             $bind['street'] = '%' . $businessAddress . '%';
             $bind['city'] = '%' . $businessAddress . '%';
             $searchWords .= ', ' . $businessAddress;
         }
         if (!empty($countryId)) {
             $conditions .= ' OR country_id = :country_id:';
             $bind['country_id'] = $countryId;
             $searchWords .= ', ' . $country->country;
         }
         $searchWords = substr($searchWords, 2);
         $business = Business::find(array('columns' => '*', 'conditions' => substr($conditions, 3), 'bind' => $bind));
         $this->view->setVar('business', $business);
     } else {
         $business = Business::find(array('order' => 'id DESC'));
     }
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $business, "limit" => 12, "page" => $currentPage));
     $page = $paginator->getPaginate();
     $this->view->setVar('business', $page);
     //$this->view->setVar('business', $business);
     $businessCategories = BusinessCategories::find();
     $this->view->setVar('businessCategories', $businessCategories);
 }
예제 #27
0
 public function suggested_changesAction($id = null)
 {
     $business = Business::findFirstById($id);
     if (!$business) {
         return $this->response->redirect('review/search_business');
     }
     $businessUpdates = BusinessUpdates::find(array('business_id = "' . $id . '"', "order" => "id DESC"));
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $businessUpdates, "limit" => 10, "page" => $currentPage));
     $page = $paginator->getPaginate();
     $this->view->setVar('searchWords', $searchWords);
     $this->view->setVar('business', $page);
     $businessCategories = BusinessCategories::find();
     $this->view->setVar('businessCategories', $businessCategories);
 }
예제 #28
0
파일: Tags.php 프로젝트: huoybb/standard
 public function getShowItemPage($file)
 {
     $paginator = new Phalcon\Paginator\Adapter\Model(['data' => $this->getTaggedFiles(), 'limit' => 1, 'page' => $this->getItemID($file)]);
     $page = $paginator->getPaginate();
     //修正循环的问题
     if ($page->next == $page->current) {
         $page->next = 1;
     }
     if ($page->before == $page->current) {
         $page->before = $page->last;
     }
     $page->next = $this->getTaggedFiles()[$page->next - 1]->files->id;
     $page->before = $this->getTaggedFiles()[$page->before - 1]->files->id;
     return $page;
 }
예제 #29
0
 public function testModelPaginatorBind()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped('Test skipped');
         return;
     }
     $this->_loadDI();
     $personnes = Personnes::find(array("conditions" => "cedula >=:d1: AND cedula>=:d2: ", "bind" => array("d1" => '1', "d2" => "5"), "order" => "cedula, nombres", "limit" => "33"));
     $paginator = new Phalcon\Paginator\Adapter\Model(array('data' => $personnes, 'limit' => 10, 'page' => 1));
     //First Page
     $page = $paginator->getPaginate();
     $this->assertEquals(get_class($page), 'stdClass');
     $this->assertEquals(count($page->items), 10);
     $this->assertEquals($page->before, 1);
     $this->assertEquals($page->next, 2);
     $this->assertEquals($page->last, 4);
     $this->assertEquals($page->limit, 10);
     $this->assertEquals($page->current, 1);
     $this->assertEquals($page->total_pages, 4);
 }
예제 #30
0
 public function indexAction()
 {
     // set page title
     $this->view->pageTitle = 'Users';
     // process get
     if ($this->request->isGet()) {
         // Current page to show
         $currentPage = $this->request->getQuery('page', 'int');
         $currentPage = empty($currentPage) ? 1 : $currentPage;
         // items per page
         $itemsPerPage = $this->request->getQuery('limit', 'int');
         $itemsPerPage = empty($itemsPerPage) ? $this->config->application['pagination']['itemsPerPage'] : $itemsPerPage;
         // filter
         $filter = $this->request->getQuery('filter', 'trim');
         // sort
         $sortBy = $this->request->getQuery('sort', 'string');
         $sortBy = empty($sortBy) ? 'name' : $sortBy;
         // direction
         $sortDirection = $this->request->getQuery('direction', 'string');
         $sortDirection = empty($sortDirection) ? 'asc' : $sortDirection;
     } else {
         // set defaults
         $currentPage = 1;
         $itemsPerPage = $this->config->application['pagination']['itemsPerPage'];
         $filter = null;
         $sortBy = 'date';
         $sortDirection = 'desc';
     }
     // order by
     if ($sortBy == 'date') {
         $orderBy = 'created ' . strtoupper($sortDirection);
     } elseif ($sortBy == 'name') {
         $orderBy = 'first_name ' . strtoupper($sortDirection);
     } elseif ($sortBy == 'type') {
         $orderBy = 'group_id ' . strtoupper($sortDirection);
     } elseif ($sortBy == 'email') {
         $orderBy = 'username ' . strtoupper($sortDirection);
     }
     // get all user activity logs
     if (!empty($filter)) {
         // find users
         $user = Users::find(array('( CONCAT(first_name, " ", last_name) LIKE :filter: OR username LIKE :filter: ) AND id <> :id:', 'order' => $orderBy, 'bind' => array('filter' => '%' . $filter . '%', 'filter' => '%' . $filter . '%', 'id' => $this->userSession['id'])));
     } else {
         // find users for current customer except yourself
         $user = Users::find(array('id <> :id:', 'order' => $orderBy, 'bind' => array('id' => $this->userSession['id'])));
     }
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $user, "limit" => $itemsPerPage, "page" => $currentPage));
     // get groups
     $this->view->groups = Groups::find(array('order' => 'name'));
     // create group list
     $groupList = array();
     foreach ($this->view->groups as $group) {
         $groupList[$group->id] = $group->label;
     }
     // Get the paginated results
     $this->view->page = $paginator->getPaginate();
     $this->view->itemsPerPage = $itemsPerPage;
     $this->view->filter = $filter;
     $this->view->sort = $sortBy;
     $this->view->direction = $sortDirection;
     $this->view->groups = $groupList;
     $this->view->dropdownLinks = array('edit' => '/user/edit', 'password' => '/user/resetPassword', 'delete' => '/user/delete');
 }