当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::getPages方法代码示例

本文整理汇总了PHP中Zend\Paginator\Paginator::getPages方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getPages方法的具体用法?PHP Paginator::getPages怎么用?PHP Paginator::getPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Paginator\Paginator的用法示例。


在下文中一共展示了Paginator::getPages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __toString

 /**
  * @return string
  */
 public function __toString()
 {
     $pages = $this->paginator->getPages($this->type);
     $routeMatch = $this->getApp()->getMvcEvent()->getRouteMatch();
     $routeName = $routeMatch->getMatchedRouteName();
     $params = $routeMatch->getParams();
     $paramName = $this->paramName;
     $paramType = $this->paramType;
     $url = function ($page) use($routeName, $params, $paramName, $paramType) {
         if (method_exists($this->view, 'plugin')) {
             /** @var Url $url */
             $url = $this->view->plugin('url');
             $query = $_GET;
             if ($paramType == 'query') {
                 $query[$paramName] = $page;
             } else {
                 if ($paramName == 'route') {
                     $params[$paramName] = $page;
                 } else {
                     throw new \RuntimeException('Currently only `query` and `route` param type supported by pagination helper.');
                 }
             }
             // filter controller name:
             // transforms e.g. '\Some\Module\IndexController' into just 'index'
             if (isset($params['controller']) && isset($params['__CONTROLLER__'])) {
                 $params['controller'] = $params['__CONTROLLER__'];
             } else {
                 if (isset($params['controller']) && strpos($params['controller'], '\\') !== false) {
                     $parts = array_reverse(explode('\\', $params['controller']));
                     $filteredParts = [];
                     foreach ($parts as $part) {
                         if (strtolower($part) == 'controller' || strtolower($part) == 'controllers') {
                             break;
                         }
                         $tmp = $part;
                         if (substr($part, -10) == 'Controller') {
                             $tmp = substr($part, 0, -10);
                         }
                         array_unshift($filteredParts, strtolower($this->getCamelCaseToDashFilter()->filter($tmp)));
                     }
                     $params['controller'] = join('/', $filteredParts);
                 }
             }
             return $url($routeName, $params, compact('query'));
         }
         throw new \Exception('Could not resolve URL helper.');
     };
     $viewModel = new ViewModel(compact('pages', 'url'));
     $viewModel->setTemplate($this->template);
     return $this->getView()->render($viewModel);
 }
开发者ID:hanif,项目名称:stokq,代码行数:54,代码来源:Pagination.php

示例2: testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo

 public function testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo()
 {
     $this->paginator->setPageRange(3);
     $this->paginator->setCurrentPageNumber(19);
     $pages = $this->paginator->getPages('Elastic');
     $this->assertEquals(5, count($pages->pagesInRange));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:ElasticTest.php

示例3: render

 /**
  * Return the HTML string of this HTML element
  *
  * @return string
  */
 public function render()
 {
     $paginationData = $this->paginator->getPages($this->scrollingStyle);
     $unorderedList = $this->getElement()->spawnChild('ul');
     $previous = $unorderedList->spawnChild('li');
     $previousAnchor = $previous->spawnChild('a')->setContent('«');
     $unorderedList->setAttributes($this->getListAttributes());
     $previous->setAttributes($this->getListItemAttributes());
     $previous->addAttributes($this->getPreviousAttributes());
     $previousAnchor->setAttributes($this->getAnchorAttributes());
     if (empty($paginationData->previous)) {
         $previous->addClass('disabled');
     } else {
         $previousAnchor->addAttribute('href', $this->getUrl($this->getRoute(), array_merge(array('page' => $paginationData->previous), $this->getRouteParams())));
     }
     foreach ($paginationData->pagesInRange as $page) {
         $pageNumberElement = $unorderedList->spawnChild('li');
         $pageHref = $this->getUrl($this->getRoute(), array_merge(array('page' => $page), $this->getRouteParams()));
         $pageNumberElement->setAttributes($this->getListItemAttributes());
         if ($page === $paginationData->current) {
             $pageNumberElement->addClass('active');
         }
         $anchorElement = $pageNumberElement->spawnChild('a')->addAttribute('href', $pageHref)->setContent($page);
         $anchorElement->addAttribute('data-page', $page);
     }
     $next = $unorderedList->spawnChild('li');
     $nextAnchor = $next->spawnChild('a')->setContent('»');
     $next->setAttributes($this->getNextAttributes());
     if (empty($paginationData->next)) {
         $next->addClass('disabled');
     } else {
         $nextAnchor->addAttribute('href', $this->getUrl($this->getRoute(), array_merge(array('page' => $paginationData->next), $this->getRouteParams())));
     }
     return $this->getElement()->render();
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:40,代码来源:Pagination.php

示例4: render

 /**
  * Return the HTML string of this HTML element
  *
  * @return string
  */
 public function render()
 {
     $paginationData = $this->paginator->getPages();
     $previous = $this->getElement()->spawnChild('li');
     $next = $this->getElement()->spawnChild('li');
     $previousAnchor = $previous->spawnChild('a')->setContent($this->getPrevLabel());
     $nextAnchor = $next->spawnChild('a')->setContent($this->getNextLabel());
     $this->getElement()->addAttributes($this->getListAttributes());
     $previousAnchor->setAttributes($this->getPreviousAttributes());
     $nextAnchor->setAttributes($this->getNextAttributes());
     if (empty($paginationData->previous)) {
         $previous->addClass('disabled');
     } else {
         $previousAnchor->addAttribute('data-page', $paginationData->previous);
         $previousAnchor->addAttribute('href', $this->getUrl($this->getRoute(), array_merge(array('page' => $paginationData->previous), $this->getRouteParams())));
     }
     if (empty($paginationData->next)) {
         $next->addClass('disabled');
     } else {
         $nextAnchor->addAttribute('data-page', $paginationData->next);
         $nextAnchor->addAttribute('href', $this->getUrl($this->getRoute(), array_merge(array('page' => $paginationData->next), $this->getRouteParams())));
     }
     if ($this->align) {
         $previous->addClass('previous');
         $next->addClass('next');
     }
     return $this->getElement()->render();
 }
开发者ID:rwoverdijk,项目名称:sxbootstrap,代码行数:33,代码来源:Pager.php

示例5: testAdapterReturnsCorrectValues

 /**
  * @group ZF-3873
  */
 public function testAdapterReturnsCorrectValues()
 {
     $paginator = new Paginator\Paginator(new Adapter\Null(2));
     $paginator->setCurrentPageNumber(1);
     $paginator->setItemCountPerPage(5);
     $pages = $paginator->getPages();
     $this->assertEquals(2, $pages->currentItemCount);
     $this->assertEquals(2, $pages->lastItemNumber);
     $paginator = new Paginator\Paginator(new Adapter\Null(19));
     $paginator->setCurrentPageNumber(4);
     $paginator->setItemCountPerPage(5);
     $pages = $paginator->getPages();
     $this->assertEquals(4, $pages->currentItemCount);
     $this->assertEquals(19, $pages->lastItemNumber);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:18,代码来源:NullTest.php

示例6: search

 public function search($value, $page = 1, $count = null, $sort = null)
 {
     if (!empty($value)) {
         $qb = $this->createQueryBuilder('u');
         $qb->where($qb->expr()->like('u.username', '?1'))->orWhere($qb->expr()->like('u.email', '?2'))->setParameter(1, $value . '%')->setParameter(2, $value . '%');
         if ($sort) {
             $qb->orderBy("p." . $sort["column"], $sort["type"]);
         }
         $paginator = new Paginator(new DoctrineAdapter(new ORMPaginator($qb)));
         if ($count) {
             $paginator->setDefaultItemCountPerPage($count);
         }
         $paginator->setCurrentPageNumber($page);
         $paginator->getPages()->pageCount;
         return $paginator;
     } else {
         throw new \InvalidArgumentException("The search value can't be empty.");
     }
 }
开发者ID:JoshBour,项目名称:karolina,代码行数:19,代码来源:UserRepository.php

示例7: testGetsPagesForPageTwo

 public function testGetsPagesForPageTwo()
 {
     $expected = new stdClass();
     $expected->pageCount = 11;
     $expected->itemCountPerPage = 10;
     $expected->first = 1;
     $expected->current = 2;
     $expected->last = 11;
     $expected->previous = 1;
     $expected->next = 3;
     $expected->pagesInRange = array_combine(range(1, 10), range(1, 10));
     $expected->firstPageInRange = 1;
     $expected->lastPageInRange = 10;
     $expected->currentItemCount = 10;
     $expected->totalItemCount = 101;
     $expected->firstItemNumber = 11;
     $expected->lastItemNumber = 20;
     $this->paginator->setCurrentPageNumber(2);
     $actual = $this->paginator->getPages();
     $this->assertEquals($expected, $actual);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:21,代码来源:PaginatorTest.php

示例8: testAcceptsPageRangeLargerThanPageCount

 public function testAcceptsPageRangeLargerThanPageCount()
 {
     $this->paginator->setPageRange(100);
     $pages = $this->paginator->getPages();
     $this->assertEquals(11, $pages->last);
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:6,代码来源:SlidingTest.php

示例9: getClientProjectListAction

 function getClientProjectListAction()
 {
     $currentUserId = User::currentLoginId();
     $currentUser = $this->find('User\\Entity\\User', $currentUserId);
     $employer = $currentUser->getEmployer();
     if ($employer) {
         $user_id = $currentUser->getId();
     } else {
         $user_id = null;
     }
     $params = $this->getRequest()->getQuery();
     foreach ($params as $key => $value) {
         if (strpos($value, '{') !== false) {
             $params->{$key} = json_decode($value);
         }
     }
     //var_dump($params); exit;
     $entityManager = $this->getEntityManager();
     $projectList = $entityManager->getRepository('User\\Entity\\Project');
     $queryBuilder = $projectList->createQueryBuilder('project');
     // Sửa lại chổ này, tạm để đó
     $queryBuilder->where("project.client=?1")->setParameter(1, $user_id);
     $queryBuilder->andWhere('project.is_deleted = 0');
     // Unpaid Task
     if ($params->payStatus != null && $params->payStatus != '') {
         $queryBuilder->andWhere('project.payStatus = :payStatus');
         $queryBuilder->setParameter('payStatus', $params->payStatus);
     }
     if ($params->bsearch != null && $params->bsearch != '') {
         $queryBuilder->andWhere('project.reference LIKE :reference');
         $queryBuilder->setParameter('reference', "%" . $params->bsearch . "%");
     } else {
         // Advance Search
         if ($params->reference != null && $params->reference != '') {
             $queryBuilder->andWhere('project.reference LIKE :reference');
             $queryBuilder->setParameter('reference', "%" . $params->reference . "%");
         }
         if ($params->projectId != null && $params->projectId != '') {
             $queryBuilder->andWhere('project.id LIKE :projectId');
             $queryBuilder->setParameter('projectId', "%" . $params->projectId . "%");
         }
         if ($params->startDate != null && $params->startDate != '') {
             $time = strtotime($params->startDate);
             $time = date("Y-m-d", $time);
             $begin = $time . " 00:00:00";
             $end = $time . " 23:59:59";
             $queryBuilder->andWhere('project.startDate BETWEEN ?6 AND ?7')->setParameter(6, $begin)->setParameter(7, $end);
         }
         if ($params->dueDate != null && $params->dueDate != '') {
             $time = strtotime($params->dueDate);
             $time = date("Y-m-d", $time);
             $begin = $time . " 00:00:00";
             $end = $time . " 23:59:59";
             $queryBuilder->andWhere('project.dueDate BETWEEN ?8 AND ?9')->setParameter(8, $begin)->setParameter(9, $end);
         }
         if ($params->dueMonth != null && $params->dueMonth != '') {
             $time = strtotime($params->dueMonth);
             //$time = date("Y-m-d", $time);
             $begin = date("Y-m-d", $time) . " 00:00:00";
             $end = date("Y-m-t", $time) . " 23:59:59";
             //var_dump($begin); var_dump($end); exit;
             $queryBuilder->andWhere('project.dueDate BETWEEN :begin AND :end')->setParameter('begin', $begin)->setParameter('end', $end);
         }
     }
     $query = $queryBuilder->getQuery();
     //$result = $query->getArrayResult();
     //var_dump($result); exit;
     $adapter = new DoctrineAdapter(new ORMPaginator($query));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->getRequest()->getQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $data = array();
     foreach ($paginator as $project) {
         $data[] = $project->getData();
     }
     return new JsonModel(array('projects' => $data, 'pages' => $paginator->getPages()));
 }
开发者ID:papertask,项目名称:papertask,代码行数:80,代码来源:ProjectController.php

示例10: getList

 public function getList()
 {
     $entityManager = $this->getEntityManager();
     $employerGroup = $entityManager->find('User\\Entity\\UserGroup', UserGroup::EMPLOYER_GROUP_ID);
     $employerList = $entityManager->getRepository('User\\Entity\\User');
     $queryBuilder = $employerList->createQueryBuilder('user');
     $request = $this->getRequest();
     if ($request->getQuery('search') && $request->getQuery('company')) {
         $company = $entityManager->getRepository('User\\Entity\\Company')->findBy(array('id' => $request->getQuery('company')));
         $queryBuilder->leftJoin('user.employer', 'employer')->where('employer.company=?1')->setParameter(1, $company);
         $queryBuilder->andWhere("user.group=?2")->setParameter(2, $employerGroup);
     } else {
         $queryBuilder->where("user.group=?1")->setParameter(1, $employerGroup);
     }
     if ($request->getQuery('search')) {
         if ($arrayNames = $this->params()->fromQuery('name')) {
             $arrayName = explode(' ', $arrayNames);
             if (count($arrayName) != 2) {
                 $queryBuilder->andWhere($queryBuilder->expr()->like('user.firstName', "'%" . $arrayName[0] . "%'"));
             } else {
                 $queryBuilder->andWhere($queryBuilder->expr()->like('user.firstName', "'%" . $arrayName[0] . "%'"));
                 $queryBuilder->andWhere($queryBuilder->expr()->like('user.lastName', "'%" . $arrayName[1] . "%'"));
             }
         }
         if ($request->getQuery('idEmployer')) {
             $queryBuilder->andWhere($queryBuilder->expr()->eq("user.id", (int) $request->getQuery('idEmployer')));
         }
         if ($request->getQuery('email')) {
             $queryBuilder->andWhere($queryBuilder->expr()->like('user.email', "'%" . $request->getQuery('email') . "%'"));
         }
         if ($request->getQuery('currency')) {
             $queryBuilder->andWhere($queryBuilder->expr()->eq("user.currency", $queryBuilder->expr()->literal($request->getQuery('currency'))));
         }
         if ($request->getQuery('country')) {
             $queryBuilder->andWhere($queryBuilder->expr()->eq("user.country", (int) $request->getQuery('country')));
         }
         if (!$request->getQuery('includeInactive') || $request->getQuery('includeInactive') && $request->getQuery('includeInactive') == 'false') {
             $queryBuilder->andWhere($queryBuilder->expr()->eq("user.isActive", 1));
         }
     }
     $queryBuilder->orderBy('user.createdTime', 'ASC');
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new ZendPaginator($adapter);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->getRequest()->getQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $data = array();
     $helper = new Helper();
     foreach ($paginator as $user) {
         $userData = $user->getData();
         $userData['employer'] = $user->getEmployer()->getData();
         $userData['createdTime'] = $helper->formatDate($userData['createdTime']);
         // Count TaskDone
         $taskCount = $entityManager->getRepository('User\\Entity\\Task');
         $taskQueryBuilder = $taskCount->createQueryBuilder('task');
         $taskQueryBuilder->select('COUNT(task.id)');
         $taskQueryBuilder->innerJoin('User\\Entity\\Project', 'p', 'WITH', 'task.project = p.id');
         $taskQueryBuilder->andWhere('p.client = ?1')->setParameter(1, $userData['id']);
         // user.id
         $taskQueryBuilder->andWhere('task.status = ?2')->setParameter(2, 1);
         $taskquery = $taskQueryBuilder->getQuery();
         $task_result = $taskquery->getArrayResult();
         $userData['taskDone'] = $task_result[0][1];
         // End Count TaskDone
         $data[] = $userData;
     }
     return new JsonModel(array('employers' => $data, 'pages' => $paginator->getPages()));
 }
开发者ID:papertask,项目名称:papertask,代码行数:70,代码来源:EmployerController.php

示例11: getList


//.........这里部分代码省略.........
     $projectId = $this->params()->fromQuery('project_id');
     $params = $this->getRequest()->getQuery();
     foreach ($params as $key => $value) {
         if (strpos($value, '{') !== false) {
             $params->{$key} = json_decode($value);
         }
     }
     if ($projectId) {
         $tasks = $this->getAllDataBy('\\User\\Entity\\Task', ['is_deleted' => false, 'project' => $projectId], ['id' => 'ASC']);
         $data = array();
         $entityManager = $this->getEntityManager();
         foreach ($tasks as $task) {
             $freelancerId = $task['assignee']['id'];
             $userData = $task;
             if ($freelancerId != null) {
                 $user = $entityManager->getRepository('User\\Entity\\User')->findOneBy(array('freelancer' => $freelancerId));
                 $userData['assignee'] = $user->getData();
             }
             $data[] = $userData;
         }
         return new JsonModel(['tasks' => $data]);
     } else {
         $entityManager = $this->getEntityManager();
         $projectList = $entityManager->getRepository('User\\Entity\\Task');
         //->findBy(array('group' => $freelancerGroup));
         $queryBuilder = $projectList->createQueryBuilder('task');
         $queryBuilder->andWhere('task.is_deleted = 0');
         if ($params->search == 1) {
             // Unpaid Task
             if ($params->payStatus != null && $params->payStatus != '') {
                 $queryBuilder->andWhere('task.payStatus = :paystatus');
                 $queryBuilder->setParameter('paystatus', $params->payStatus->id);
             }
             //get task base on status
             if ($params->status != null && $params->statustask != '') {
                 $queryBuilder->andWhere('task.status = :status');
                 $queryBuilder->setParameter('status', $params->status);
             }
             if ($params->task_id != null && $params->task_id != '') {
                 $queryBuilder->andWhere('task.id = :task_id');
                 $queryBuilder->setParameter('task_id', $params->task_id);
                 //$queryBuilder_tmp->distinct();
             }
             if ($params->startDate != null && $params->startDate != '') {
                 $time = strtotime($params->startDate);
                 $time = date("Y-m-d", $time);
                 $begin = $time . " 00:00:00";
                 $end = $time . " 23:59:59";
                 $queryBuilder->andWhere('task.startDate BETWEEN ?6 AND ?7')->setParameter(6, $begin)->setParameter(7, $end);
             }
             if ($params->dueDate != null && $params->dueDate != '') {
                 $time = strtotime($params->dueDate);
                 $time = date("Y-m-d", $time);
                 $begin = $time . " 00:00:00";
                 $end = $time . " 23:59:59";
                 $queryBuilder->andWhere('task.dueDate BETWEEN ?8 AND ?9')->setParameter(8, $begin)->setParameter(9, $end);
             }
             if ($params->reference != null && $params->reference != '') {
                 $entityManagerP = $this->getEntityManager();
                 $ProjectList = $entityManagerP->getRepository('User\\Entity\\Project');
                 $queryBuilderProject = $ProjectList->createQueryBuilder('project');
                 $queryBuilderProject->where("project.reference LIKE :reference")->setParameter('reference', '%' . $params->reference . '%');
                 $queryProject = $queryBuilderProject->getQuery();
                 $resultProject = $queryProject->getArrayResult();
                 $statement = "";
                 foreach ($resultProject as $project) {
                     //echo $project['id'];
                     $statement = $statement . "task.project = " . $project['id'] . " OR ";
                 }
                 $statement = substr($statement, 0, -3);
                 $queryBuilder->andWhere($statement);
                 //var_dump($statement); exit;
             }
         }
         $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
         $paginator = new Paginator($adapter);
         $paginator->setDefaultItemCountPerPage(10);
         $page = (int) $this->getRequest()->getQuery('page');
         if ($page) {
             $paginator->setCurrentPageNumber($page);
         }
         $data = array();
         //$helper = new Helper();
         foreach ($paginator as $task) {
             $userData = $task->getData();
             // Get Employer
             $freelancerId = $userData['assignee']['id'];
             if ($freelancerId != null) {
                 $user = $entityManager->getRepository('User\\Entity\\User')->findOneBy(array('freelancer' => $freelancerId));
                 $userData['assignee'] = $user->getData();
                 $project = $this->find('User\\Entity\\Project', $userData['project']);
                 $userData['project'] = $project->getData();
                 // Get Project
                 //var_dump($user);
             }
             $data[] = $userData;
         }
         return new JsonModel(array('tasks' => $data, 'pages' => $paginator->getPages()));
     }
 }
开发者ID:papertask,项目名称:papertask,代码行数:101,代码来源:TaskController.php

示例12: getPrevPage

 /**
  * @return int
  */
 public function getPrevPage()
 {
     return $this->zendPaginator->getPages()->current - 1;
 }
开发者ID:t4web,项目名称:admin,代码行数:7,代码来源:PaginatorViewModel.php

示例13: getList


//.........这里部分代码省略.........
     // Get freelancer group
     $projectList = $entityManager->getRepository('User\\Entity\\Project');
     //->findBy(array('group' => $freelancerGroup));
     $queryBuilder = $projectList->createQueryBuilder('project');
     $queryBuilder->andWhere('project.is_deleted = 0');
     if ($q = $this->params()->fromQuery('q')) {
         $queryBuilder->andWhere($queryBuilder->expr()->orX($queryBuilder->expr()->like('project.reference', $queryBuilder->expr()->literal("%{$q}%")), $queryBuilder->expr()->like('project.id', $queryBuilder->expr()->literal("%{$q}%"))));
     }
     /** start filter */
     if ($project_id = $this->params()->fromQuery('project_id')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.id', $project_id));
     }
     if ($project_no = $this->params()->fromQuery('project_no')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.project_no', $project_no));
         //$queryBuilder->expr()->like('project.project_no', $project_no);
     }
     if ($reference = $this->params()->fromQuery('reference')) {
         $queryBuilder->andWhere($queryBuilder->expr()->like('project.reference', $queryBuilder->expr()->literal("%{$reference}%")));
     }
     if ($field = $this->params()->fromQuery('field')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.field', $field['id']));
     }
     if ($status = $this->params()->fromQuery('status')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.status', $status['id']));
     }
     if ($payStatus = $this->params()->fromQuery('payStatus')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.payStatus', $payStatus['id']));
     }
     if ($unpay = $this->params()->fromQuery('unpay')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.payStatus', $unpay));
     }
     if ($sale = $this->params()->fromQuery('sale')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.sale', $sale['id']));
     }
     if ($pm = $this->params()->fromQuery('pm')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.pm', $pm['id']));
     }
     $currentUserId = User::currentLoginId();
     $currentUser = $this->find('User\\Entity\\User', $currentUserId);
     if ($currentUser->isEmployer()) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.client', $currentUserId));
     }
     if ($clientId = $this->params()->fromQuery('clientId')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.client', $clientId));
     }
     if ($statusproject = $this->params()->fromQuery('statusproject')) {
         if ($statusproject == '7and8') {
             $queryBuilder->andWhere("project.status = 7 or project.status = 8");
         } else {
             if ($statusproject == 'client') {
                 $queryBuilder->andWhere("project.status = 0 or project.status = 1 or project.status = 2 or project.status = 3 or project.status = 4");
             } else {
                 $queryBuilder->andWhere($queryBuilder->expr()->eq('project.status', $statusproject));
             }
         }
     }
     if ($getQuote = $this->params()->fromQuery('quote')) {
         //echo 'hi'; exit;
         if ($getQuote == 1) {
             $queryBuilder->andWhere("project.status = 1 or project.status = 0");
         } else {
             $queryBuilder->andWhere($queryBuilder->expr()->like('project.status', $getQuote));
         }
         //$queryBuilder->andWhere("project.status = 2");
     }
     if ($startDate = $this->params()->fromQuery('startDate')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.startDate', $startDate));
     }
     if ($dueDate = $this->params()->fromQuery('dueDate')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.dueDate', $dueDate));
     }
     if ($source = $this->params()->fromQuery('source')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.sourceLanguage', $source['id']));
     }
     if ($target = $this->params()->fromQuery('target')) {
         // TODO: Many to many problem
     }
     /** end filter */
     $queryBuilder->orderBy('project.id', 'DESC');
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $number = $this->params()->fromQuery('number');
     if (!$number) {
         $number = 10;
     }
     $paginator->setDefaultItemCountPerPage($number);
     $page = (int) $this->getRequest()->getQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $data = array();
     $helper = new Helper();
     foreach ($paginator as $user) {
         $userData = $user->getData();
         // var_dump($userData); exit;
         $data[] = $userData;
     }
     //var_dump($paginator);die;
     return new JsonModel(array('projects' => $data, 'pages' => $paginator->getPages()));
 }
开发者ID:papertask,项目名称:papertask,代码行数:101,代码来源:ProjectController.php

示例14: getFreelancerOutTransactionListAction

 public function getFreelancerOutTransactionListAction()
 {
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     $params = $this->getRequest()->getQuery();
     foreach ($params as $key => $value) {
         if (strpos($value, '{') !== false) {
             $params->{$key} = json_decode($value);
         }
     }
     //var_dump($params);exit;
     $currentUserId = User::currentLoginId();
     $currentUser = $this->find('User\\Entity\\User', $currentUserId);
     $freelancer = $currentUser->getFreelancer();
     $freelancer_id = $freelancer->getId();
     $entityManager = $this->getEntityManager();
     $freelancerList = $entityManager->getRepository('User\\Entity\\Transaction');
     $queryBuilder = $freelancerList->createQueryBuilder('outtr');
     $queryBuilder->where('outtr.freelancer = ?1')->setParameter(1, $currentUser);
     //$queryBuilder->where("outtr.client=?1")->setParameter(1,$freelancer_id); // 4 = Pooling
     $queryBuilder->andWhere('outtr.is_deleted = 0');
     if ($params->bsearch != null && $params->bsearch != '') {
         $queryBuilder->andWhere('outtr.intrans_no LIKE :outtrId');
         $queryBuilder->setParameter('outtrId', '%' . $params->bsearch . '%');
     } else {
         // Advance Search
         if ($params->outtrId != null && $params->outtrId != '') {
             $queryBuilder->andWhere('outtr.intrans_no LIKE :outtrId');
             $queryBuilder->setParameter('outtrId', '%' . $params->outtrId . '%');
             //echo 'hi';exit;
             //$queryBuilder_tmp->distinct();
         }
         if ($params->payMonth != null && $params->payMonth != '') {
             $time = strtotime($params->payMonth);
             //$time = date("Y-m-d", $time);
             $begin = date("Y-m-d", $time) . " 00:00:00";
             $end = date("Y-m-t", $time) . " 23:59:59";
             $queryBuilder->andWhere('outtr.payDate BETWEEN :begin AND :end')->setParameter('begin', $begin)->setParameter('end', $end);
         }
     }
     $query = $queryBuilder->getQuery();
     //$result = $query->getArrayResult();
     //var_dump($result); exit;
     $adapter = new DoctrineAdapter(new ORMPaginator($query));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->getRequest()->getQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $data = array();
     foreach ($paginator as $outtransaction) {
         //var_dump($outtransaction); exit;
         //$data[]  = $outtransaction->getData();
         $outtr = array();
         $outtr = $outtransaction->getData();
         // Get Currency
         //$taskIDs = $outtransaction->getTasks();
         //$taskID  =  $taskIDs[0];
         //$task = $this->find('User\Entity\Task',$taskID);
         //$project = $task->getProject();
         //$currency = $project->getCurrency();
         //if($currency==null) $currency='CNY';
         //$outtr['currency'] =$currency;
         $data[] = $outtr;
         //var_dump($currency); exit;
     }
     return new JsonModel(array('outtrs' => $data, 'pages' => $paginator->getPages()));
 }
开发者ID:papertask,项目名称:papertask,代码行数:69,代码来源:FinanceController.php

示例15: getList

 public function getList()
 {
     //error_reporting(E_ALL);
     //ini_set('display_errors', 1);
     $entityManager = $this->getEntityManager();
     // Get freelancer group
     $projectList = $entityManager->getRepository('User\\Entity\\Project');
     //->findBy(array('group' => $freelancerGroup));
     $queryBuilder = $projectList->createQueryBuilder('project');
     $queryBuilder->andWhere('project.is_deleted = 0');
     /** start filter */
     if ($project_id = $this->params()->fromQuery('project_id')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.id', $project_id));
     }
     if ($reference = $this->params()->fromQuery('reference')) {
         $queryBuilder->andWhere($queryBuilder->expr()->like('project.reference', $queryBuilder->expr()->literal("%{$reference}%")));
     }
     if ($field = $this->params()->fromQuery('field')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.field', $field['id']));
     }
     if ($status = $this->params()->fromQuery('status')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.status', $status['id']));
     }
     if ($payStatus = $this->params()->fromQuery('payStatus')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.payStatus', $payStatus['id']));
     }
     if ($sale = $this->params()->fromQuery('sale')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.sale', $sale['id']));
     }
     if ($pm = $this->params()->fromQuery('pm')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.pm', $pm['id']));
     }
     if ($clientId = $this->params()->fromQuery('clientId')) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('project.client', $clientId));
     }
     if ($startDate = $this->params()->fromQuery('startDate')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.startDate', $startDate));
     }
     if ($dueDate = $this->params()->fromQuery('dueDate')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.dueDate', $dueDate));
     }
     if ($source = $this->params()->fromQuery('source')) {
         $queryBuilder->andWhere($queryBuilder->expr()->gte('project.sourceLanguage', $source['id']));
     }
     if ($target = $this->params()->fromQuery('target')) {
         // TODO: Many to many problem
     }
     /** end filter */
     $queryBuilder->orderBy('project.id', 'DESC');
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->getRequest()->getQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $data = array();
     $helper = new Helper();
     foreach ($paginator as $user) {
         $userData = $user->getData();
         $data[] = $userData;
     }
     //var_dump($paginator);die;
     return new JsonModel(array('projects' => $data, 'pages' => $paginator->getPages()));
 }
开发者ID:papertask,项目名称:papertask,代码行数:65,代码来源:OutcometransactionController.php


注:本文中的Zend\Paginator\Paginator::getPages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。