public function revertsupportleadAction()
 {
     $page = $this->getRequest()->getQuery('page', 1);
     $currentItem = $this->getRequest()->getQuery('currentItem', 0);
     $dbSql = $this->getServiceLocator()->get('dbSql');
     $dbAdapter = $this->getServiceLocator()->get('dbAdapter');
     $select = $dbSql->select(array('a' => \Crm\Model\ActivityMapper::TABLE_NAME));
     $select->join(['ca' => \Calendar\Model\Calendar\AttendanceMapper::TABLE_NAME], 'ca.calendarId=a.calendarId', ['userId' => 'userId']);
     $select->columns(['leadId' => 'leadId']);
     $select->where(['(a.type = ? OR a.result = ?)' => [\Crm\Model\Activity::TYPE_REQUEST_PHONECALL, \Crm\Model\Activity::RESULT_PHONECALL]]);
     $select->where(['leadId IS NOT NULL']);
     $select->order(['a.id ASC', 'ca.userId ASC']);
     $paginatorAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $dbAdapter);
     $paginator = new \Zend\Paginator\Paginator($paginatorAdapter);
     $paginator->setItemCountPerPage(100);
     $paginator->setCurrentPageNumber($page);
     $leadUserMapper = $this->getServiceLocator()->get('\\Crm\\Model\\Lead\\UserMapper');
     foreach ($paginator as $row) {
         $row = (array) $row;
         $leadUser = new \Crm\Model\Lead\User();
         $leadUser->setLeadId($row['leadId']);
         $leadUser->setUserId($row['userId']);
         $leadUser->setType(\Crm\Model\Lead\User::TYPE_TELESALE);
         if (!$leadUserMapper->isExisted($leadUser)) {
             $leadUser->setCreatedById($this->user()->getIdentity());
             $leadUser->setCreatedDateTime(DateBase::getCurrentDateTime());
             $leadUserMapper->save($leadUser);
             $currentItem++;
         }
     }
     if ($paginator->getCurrentPageNumber() >= $paginator->getTotalItemCount() / $paginator->getItemCountPerPage()) {
         $this->getViewModel()->setVariable('defaultRedirectUri', '/system/tool/revertsupportlead');
         $this->getViewModel()->setVariable('page', $currentItem);
         $this->getViewModel()->setVariable('totalPages', $paginator->getTotalItemCount());
         return $this->getViewModel();
     }
     $this->getViewModel()->setVariable('redirectUri', '/system/tool/revertsupportlead?page=' . ($page + 1) . '&currentItem=' . $currentItem);
     $this->getViewModel()->setVariable('defaultRedirectUri', '/system/tool/revertsupportlead');
     $this->getViewModel()->setVariable('page', $currentItem);
     $this->getViewModel()->setVariable('totalPages', $paginator->getTotalItemCount());
     return $this->getViewModel();
 }