public function indexAction()
 {
     $searchform = new AlbumSearchForm();
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['artist'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('artist', '%' . $formdata['artist'] . '%'));
         }
         if (!empty($formdata['title'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('title', '%' . $formdata['title'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $album = $this->getAlbumTable()->fetchAll($select);
     $totalRecord = $album->count();
     $itemsPerPage = 2;
     $album->current();
     $paginator = new Paginator(new paginatorIterator($album));
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($itemsPerPage)->setPageRange(7);
     $searchform->setData($formdata);
     return new ViewModel(array('search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator, 'pageAction' => 'album', 'form' => $searchform, 'totalRecord' => $totalRecord));
 }
 /**
  * index Action
  * Receive the search params
  * Build the search query
  * Generate the search result as a list
  * @return type
  * Author: Tahmina Khatoon
  */
 public function indexAction()
 {
     $searchform = new UserRolesSearchForm();
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_DESCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $item_per_page = $this->params()->fromRoute('item_per_page') ? (int) $this->params()->fromRoute('item_per_page') : 10;
     $page_range = $this->params()->fromRoute('page_range') ? (int) $this->params()->fromRoute('page_range') : 7;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['user_id'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('user_id', '%' . $formdata['user_id'] . '%'));
         }
         if (!empty($formdata['role_id'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('role_id', '%' . $formdata['role_id'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $paginator = $this->getUserRolesTable()->fetchAll($select, true);
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($item_per_page)->setPageRange($page_range);
     $totalRecord = $paginator->getTotalItemCount();
     $currentPage = $paginator->getCurrentPageNumber();
     $totalPage = $paginator->count();
     $searchform->setData($formdata);
     $this->vm->setVariables(array('flashMessages' => $this->flashMessenger()->getMessages(), 'search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'item_per_page' => $item_per_page, 'paginator' => $paginator, 'pageAction' => 'user_roles/index', 'form' => $searchform, 'totalRecord' => $totalRecord, 'currentPage' => $currentPage, 'totalPage' => $totalPage));
     return $this->vm;
 }
 public function masterindexAction()
 {
     $this->layout('layout/apotravinyadmin');
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     $this->layout()->getuser = $getuser;
     // notlogin
     if (!$getuser) {
         $this->redirect()->toUrl(WEBPATH);
     }
     // 		//search
     // 		$searchform = new SearchFromSlider();
     // 		$searchform->get ( 'submit' )->setValue ( 'Search' );
     // 		$this->layout()->formSearch = $searchform;
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_DESCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $select->order($order_by . ' ' . $order);
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['descriptionkey'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('descriptionkey', '%' . $formdata['descriptionkey'] . '%'));
         }
         if (!empty($formdata['title'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('title', '%' . $formdata['title'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $ContactpTable = $this->getSliderTable();
     $allRecord = $ContactpTable->countAll();
     $pageNull = new PageNull($allRecord);
     $itemsPerPage = 20;
     $pageRange = 5;
     $page = $this->params()->fromRoute('page', 1);
     $offset = ($page - 1) * $itemsPerPage;
     $paginator = new Paginator($pageNull);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemsPerPage);
     $paginator->setPageRange($pageRange);
     $listpr = $ContactpTable->getList($offset, $itemsPerPage);
     $this->layout()->listNews = $listpr;
     $this->layout()->paginator = $paginator;
     $this->layout()->allRecord = $allRecord;
     $this->layout()->offset = $offset;
     $this->layout()->itemsPerPage = $itemsPerPage;
     $all_catalogue = $this->getSliderTable()->fetchAll();
     $this->layout()->catalogue = $all_catalogue;
 }
Esempio n. 4
0
 public function fetchAllByIdentity($identity, $identitykey = 'email')
 {
     $adapter = $this->adapter;
     $select = new Select();
     $select->from($this->table);
     $select->join('user_roles', 'user_roles.user_id = users.id', array('role_id' => 'role_id'), 'inner');
     $select->join('roles', 'user_roles.role_id = roles.id', array('role_name' => 'name', 'role_label' => 'label', 'role_weight' => 'weight'), 'inner');
     $where = new \Zend\Db\Sql\Where();
     $where->addPredicate(new \Zend\Db\Sql\Predicate\Expression("(users." . $identitykey . " = '" . $identity . "')"));
     if (!empty($where)) {
         $select->where($where);
     }
     //        echo "<pre>";
     //        echo $select->getSqlString();
     //        die();
     $sql = new Sql($adapter);
     $statement = $sql->getSqlStringForSqlObject($select);
     $resultSet = $adapter->query($statement, $adapter::QUERY_MODE_EXECUTE);
     $resultSet->buffer();
     return $resultSet;
 }
 /**
  * Retourne le predicate pour la gestiond es palliers
  * @param mixed $mRoster id ou nom du pallier
  * @return \Zend\Db\Sql\Where
  * @throws \Commun\Exception\LogException
  */
 public function getPredicate($mRoster)
 {
     try {
         if (is_string($mRoster)) {
             $aPalliers = $this->getPallierPourNomRoster($mRoster);
         } else {
             $aPalliers = $this->getPallierPourIdRoster($mRoster);
         }
         if (!$aPalliers) {
             $msg = sprintf($this->_getServTranslator()->translate("Aucun palier définit pour le roster [ %s ]."), $mRoster);
             throw new \Commun\Exception\LogException($msg, 499, $this->_getServiceLocator(), null, $mRoster);
         }
         $predicateGlobal = new \Zend\Db\Sql\Where();
         $predicatePallierGlobal = new \Zend\Db\Sql\Where();
         foreach ($aPalliers as $key => $aPallier) {
             $predicatePallier = new \Zend\Db\Sql\Where();
             $predicatePallier->NEST->equalTo("r.idMode", $aPallier['idModeDifficulte'])->AND->equalTo("r.idZoneTmp", $aPallier['idZone'])->AND->equalTo("r.idRosterTmp", $aPallier['idRoster'])->UNNEST;
             if ($key == 1) {
                 $predicatePallierGlobal->addPredicate($predicatePallier, 'OR');
             } else {
                 $predicatePallierGlobal->addPredicate($predicatePallier);
             }
         }
         $predicateGlobal->NEST->addPredicate($predicatePallierGlobal)->UNNEST;
         return $predicatePallierGlobal;
     } catch (\Exception $exc) {
         throw new DatabaseException(10000, 4, $this->_getServiceLocator(), $mRoster, $exc);
     }
 }
 /**
  * Update package assignments
  *
  * Sets a new package on existing assignments. Updated assignments have
  * their status reset to "not notified" and their options (force, schedule,
  * post cmd) removed.
  *
  * @param integer $oldPackageId package to be replaced
  * @param integer $newPackageId new package
  * @param bool $deployNonnotified Update assignments with status 'not notified'
  * @param bool $deploySuccess Update assignments with status 'success'
  * @param bool $deployNotified Update assignments with status 'notified'
  * @param bool $deployError Update assignments with status 'error'
  * @param bool $deployGroups Update assignments for groups
  * @throws RuntimeException if an error occurs
  */
 public function updateAssignments($oldPackageId, $newPackageId, $deployNonnotified, $deploySuccess, $deployNotified, $deployError, $deployGroups)
 {
     if (!($deployNonnotified or $deploySuccess or $deployNotified or $deployError or $deployGroups)) {
         return;
         // nothing to do
     }
     $clientConfig = $this->_serviceManager->get('Database\\Table\\ClientConfig');
     $groupInfo = $this->_serviceManager->get('Database\\Table\\GroupInfo');
     $where = new \Zend\Db\Sql\Where();
     $where->equalTo('ivalue', $oldPackageId);
     // Additional filters are only necessary if not all conditions are set
     if (!($deployNonnotified and $deploySuccess and $deployNotified and $deployError and $deployGroups)) {
         $groups = $groupInfo->getSql()->select()->columns(array('hardware_id'));
         $filters = new \Zend\Db\Sql\Where(null, \Zend\Db\Sql\Where::COMBINED_BY_OR);
         if ($deployNonnotified) {
             $filters->isNull('tvalue')->and->notIn('hardware_id', $groups);
         }
         if ($deploySuccess) {
             $filters->equalTo('tvalue', \Model\Package\Assignment::SUCCESS);
         }
         if ($deployNotified) {
             $filters->equalTo('tvalue', \Model\Package\Assignment::NOTIFIED);
         }
         if ($deployError) {
             $filters->like('tvalue', \Model\Package\Assignment::ERROR_PREFIX . '%');
         }
         if ($deployGroups) {
             $filters->in('hardware_id', $groups);
         }
         $where->addPredicate($filters);
     }
     $now = $this->_serviceManager->get('Library\\Now')->format(\Model\Package\Assignment::DATEFORMAT);
     try {
         // Remove DOWNLOAD_* options from updated assignments
         $subquery = $clientConfig->getSql()->select()->columns(array('hardware_id'))->where(array('name' => 'DOWNLOAD', $where));
         $delete = new \Zend\Db\Sql\Where();
         $delete->equalTo('ivalue', $oldPackageId)->in('hardware_id', $subquery)->notEqualTo('name', 'DOWNLOAD_SWITCH')->like('name', 'DOWNLOAD_%');
         $clientConfig->delete($delete);
         // Update package ID and reset status
         $clientConfig->update(array('ivalue' => $newPackageId, 'tvalue' => \Model\Package\Assignment::NOT_NOTIFIED, 'comments' => $now), array('name' => 'DOWNLOAD', $where));
     } catch (\Exception $e) {
         throw new RuntimeException($e->getMessage(), (int) $e->getCode(), $e);
     }
 }
Esempio n. 7
0
 public function getUserTreeMenus($role_id, $parent_id = 0)
 {
     $adapter = $this->adapter;
     $result = array();
     $select = new Select();
     $select->from($this->table);
     //        $select->columns(array(new Expression('DISTINCT(menus.id) as id'), 'name', 'type', 'url', 'target'));
     $select->join('resources', 'resources.id = menus.resource_id', array('resource_name' => 'name'), 'left');
     $select->join('role_resources', 'menus.resource_id = role_resources.resource_id', array('role_id' => 'role_id'), 'left');
     $where = new \Zend\Db\Sql\Where();
     if ($role_id != 1) {
         $where->addPredicate(new \Zend\Db\Sql\Predicate\Expression("(role_resources.role_id = {$role_id} OR menus.type = 1)"));
     }
     $where->equalTo('parent_id', $parent_id);
     $where->equalTo('status', 1);
     if (!empty($where)) {
         $select->where($where);
     }
     $select->order('order' . ' ' . 'ASC');
     $sql = new Sql($adapter);
     $statement = $sql->getSqlStringForSqlObject($select);
     //echo $statement;
     //        die();
     $resultSet = $adapter->query($statement, $adapter::QUERY_MODE_EXECUTE);
     $resultSet->buffer();
     if (!empty($resultSet)) {
         $exist_ids = array();
         foreach ($resultSet as $key => $data) {
             if (!in_array($data->id, $exist_ids)) {
                 $exist_ids[] = $data->id;
                 $result[$key]['data'] = $data;
                 $result[$key]['child'] = $this->getUserTreeMenus($role_id, $data->id);
             }
         }
     }
     return $result;
 }
 /**
  * Retourne le nombre total de loot du roster.(hors pallier)
  * @param int $iIdRoster
  */
 function getNbTotalLootRoster($iIdRoster, $iSpe)
 {
     try {
         $sql = new \Zend\Db\Sql\Sql($this->getAdapter());
         $oQuery = $sql->select();
         $oQuery->columns(array('totalItem' => new Expression('COUNT(ipr.idItem)')))->from(array('ipr' => 'item_personnage_raid'))->join(array('r' => 'raids'), 'r.idRaid=ipr.idRaid', array(), \Zend\Db\Sql\Select::JOIN_INNER);
         // spé
         /* @var $predicateSpe \Zend\Db\Sql\Where() */
         $predicateSpe = $this->getPredicateSpe($iSpe);
         // palllier
         /* @var $predicateGlobal \Zend\Db\Sql\Where() */
         $predicateGlobal = new \Zend\Db\Sql\Where();
         $predicateGlobal->equalTo("idRosterTmp", $iIdRoster);
         $predicateGlobal->addPredicate($predicateSpe, 'AND');
         $oQuery->where($predicateGlobal);
         return $this->fetchAllArray($oQuery)[0]['totalItem'];
     } catch (\Exception $exc) {
         throw new DatabaseException(4000, 4, $this->_getServiceLocator(), $iIdRoster, $exc);
     }
 }
Esempio n. 9
0
 /**
  * index Action
  * Receive the search params
  * Build the search query
  * Generate the search result as a list
  * @return type
  * Author: Tahmina Khatoon
  */
 public function indexAction()
 {
     $searchform = new MenusSearchForm();
     /**
      * Set Resource List
      */
     $options = $this->getResourcesTable()->dropdownResources();
     $searchform->get('resource_id')->setOptions(array('value_options' => $options));
     /**
      * Set Parent Menu List
      */
     $menuoptions = $this->dropdownMenus();
     $searchform->get('parent_id')->setOptions(array('value_options' => $menuoptions));
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'order';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_DESCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $item_per_page = $this->params()->fromRoute('item_per_page') ? (int) $this->params()->fromRoute('item_per_page') : 10;
     $page_range = $this->params()->fromRoute('page_range') ? (int) $this->params()->fromRoute('page_range') : 7;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $select->join('resources', 'resources.id = menus.resource_id', array('resource_name' => 'name'), 'left');
     $select->join(array('parents' => 'menus'), 'parents.id = menus.parent_id', array('parent_name' => 'name'), 'left');
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['name'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('menus.name', '%' . $formdata['name'] . '%'));
         }
         if (!empty($formdata['type'])) {
             $where->equalTo('menus.type', $formdata['type']);
         }
         if (!empty($formdata['resource_id'])) {
             $where->equalTo('menus.resource_id', $formdata['resource_id']);
         }
         if (!empty($formdata['url'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('menus.url', '%' . $formdata['url'] . '%'));
         }
         if (!empty($formdata['target'])) {
             $where->equalTo('menus.target', $formdata['target']);
         }
         if (!empty($formdata['parent_id'])) {
             $where->equalTo('menus.parent_id', $formdata['parent_id']);
         }
         if (!empty($formdata['status'])) {
             $where->equalTo('menus.status', $formdata['status']);
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $paginator = $this->getMenusTable()->fetchAll($select, true);
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($item_per_page)->setPageRange($page_range);
     $totalRecord = $paginator->getTotalItemCount();
     $currentPage = $paginator->getCurrentPageNumber();
     $totalPage = $paginator->count();
     $searchform->setData($formdata);
     $this->vm->setVariables(array('flashMessages' => $this->flashMessenger()->getMessages(), 'search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'item_per_page' => $item_per_page, 'paginator' => $paginator, 'pageAction' => 'menus/index', 'form' => $searchform, 'totalRecord' => $totalRecord, 'currentPage' => $currentPage, 'totalPage' => $totalPage));
     return $this->vm;
 }
Esempio n. 10
0
 /**
  * Update package assignments
  *
  * Sets a new package on existing assignments. Updated assignments have
  * their status reset to "pending" and their options (force, schedule,
  * post cmd) removed.
  *
  * @param integer $oldPackageId package to be replaced
  * @param integer $newPackageId new package
  * @param bool $deployPending Update assignments with status 'pending'
  * @param bool $deployRunning Update assignments with status 'running'
  * @param bool $deploySuccess Update assignments with status 'success'
  * @param bool $deployError Update assignments with status 'error'
  * @param bool $deployGroups Update assignments for groups
  * @throws RuntimeException if an error occurs
  */
 public function updateAssignments($oldPackageId, $newPackageId, $deployPending, $deployRunning, $deploySuccess, $deployError, $deployGroups)
 {
     if (!($deployPending or $deployRunning or $deploySuccess or $deployError or $deployGroups)) {
         return;
         // nothing to do
     }
     $clientConfig = $this->_serviceManager->get('Database\\Table\\ClientConfig');
     $groupInfo = $this->_serviceManager->get('Database\\Table\\GroupInfo');
     $where = new \Zend\Db\Sql\Where();
     $where->equalTo('ivalue', $oldPackageId);
     $where->equalTo('name', 'DOWNLOAD');
     // Additional filters are only necessary if not all conditions are set
     if (!($deployPending and $deployRunning and $deploySuccess and $deployError and $deployGroups)) {
         $groups = $groupInfo->getSql()->select()->columns(array('hardware_id'));
         $filters = new \Zend\Db\Sql\Where(null, \Zend\Db\Sql\Where::COMBINED_BY_OR);
         if ($deployPending) {
             $filters->isNull('tvalue')->and->notIn('hardware_id', $groups);
         }
         if ($deployRunning) {
             $filters->equalTo('tvalue', \Model\Package\Assignment::RUNNING);
         }
         if ($deploySuccess) {
             $filters->equalTo('tvalue', \Model\Package\Assignment::SUCCESS);
         }
         if ($deployError) {
             $filters->like('tvalue', \Model\Package\Assignment::ERROR_PREFIX . '%');
         }
         if ($deployGroups) {
             $filters->in('hardware_id', $groups);
         }
         $where->addPredicate($filters);
     }
     $now = $this->_serviceManager->get('Library\\Now')->format(\Model\Package\Assignment::DATEFORMAT);
     try {
         // Remove DOWNLOAD_* options from updated assignments
         $subquery = $clientConfig->getSql()->select()->columns(array('hardware_id'))->where($where);
         // @codeCoverageIgnoreStart
         if ($clientConfig->getAdapter()->getPlatform()->getName() == 'MySQL') {
             // MySQL does not allow subquery on the same table for DELETE
             // statements. Fetch result as a list instead.
             $subquery = array_column($clientConfig->selectWith($subquery)->toArray(), 'hardware_id');
         }
         // @codeCoverageIgnoreEnd
         if ($subquery) {
             // $subquery is either an SQL statement or a non-empty array.
             $delete = new \Zend\Db\Sql\Where();
             $delete->equalTo('ivalue', $oldPackageId)->notEqualTo('name', 'DOWNLOAD_SWITCH')->in('hardware_id', $subquery)->like('name', 'DOWNLOAD_%');
             $clientConfig->delete($delete);
         }
         // Update package ID and reset status
         $clientConfig->update(array('ivalue' => $newPackageId, 'tvalue' => \Model\Package\Assignment::PENDING, 'comments' => $now), $where);
     } catch (\Exception $e) {
         throw new RuntimeException($e->getMessage(), (int) $e->getCode(), $e);
     }
 }