/** * findAll * Get records the orders from the DB * @param $currentPage * @param $rowNum * @param $sort * @param $where * @return array */ public static function findAll($fields = "*", $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array(), $locale = 1) { $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); try { // Defining the url sort $uri = isset($sort[1]) ? "/sort/{$sort['1']}" : ""; $dq = Doctrine_Query::create()->select($fields)->from('OrdersItems d')->leftJoin('d.Orders o')->leftJoin('d.OrdersItemsDomains oid ON d.detail_id = oid.orderitem_id')->leftJoin('d.BillingCycle bc')->leftJoin('oid.Domains dm')->leftJoin('dm.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->leftJoin('d.Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin('p.Taxes t')->leftJoin('o.Customers c')->leftJoin('d.Statuses s')->where('p.type <> ?', 'domain'); // Show all the records but not the Expired services // Show only the services and not the domains $pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri); // Get the pager object $pager = $pagerLayout->getPager(); // Set the Order criteria if (isset($sort[0])) { $pager->getQuery()->orderBy($sort[0]); } if (isset($where) && is_array($where)) { foreach ($where as $filters) { if (isset($filters[0]) && is_array($filters[0])) { foreach ($filters as $filter) { $method = $filter['method']; $value = $filter['value']; $criteria = $filter['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } else { $method = $filters['method']; $value = $filters['value']; $criteria = $filters['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } } $pagerLayout->setTemplate('<a href="{%url}">{%page}</a> '); $pagerLayout->setSelectedTemplate('<a class="active" href="{%url}">{%page}</a> '); $records = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $pagination = $pagerLayout->display(null, true); return array('records' => $records, 'pagination' => $pagination, 'pager' => $pager, 'recordcount' => $dq->count()); } catch (Exception $e) { die($e->getMessage()); } }
/** * getRecords * Get records from the DB * @return mixed */ public function getRecords(Doctrine_Query $dq, $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array()) { $uri = ""; $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); // Defining the url sort if (!empty($sort)) { foreach ($sort as $s) { $arrSort[] = "/sort/" . str_replace(" ", ",", $s); } $arrSort = array_unique($arrSort); $uri = implode("", $arrSort); } $pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri); // Get the pager object $pager = $pagerLayout->getPager(); // Set the Order criteria if (!empty($sort)) { $pager->getQuery()->orderBy(implode(", ", $sort)); } if (isset($where) && is_array($where)) { foreach ($where as $filters) { if (isset($filters[0]) && is_array($filters[0])) { foreach ($filters as $filter) { $method = $filter['method']; $value = $filter['value']; $criteria = $filter['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } else { $method = $filters['method']; $value = $filters['value']; $criteria = $filters['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } } $pagerLayout->setTemplate('<a href="{%url}">{%page}</a> '); $pagerLayout->setSelectedTemplate('<a class="active" href="{%url}">{%page}</a> '); $this->data = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $this->paging = $pagerLayout->display(null, true); $this->recordcount = $dq->count(); #print_r ( $this->data ); return $this; }
/** * Get records the orders from the DB * * @param $currentPage * @param $rowNum * @param $sort * @param $where * @return array */ public static function findAll($fields = "*", $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array()) { $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); // Defining the url sort $uri = isset($sort[1]) ? "/sort/{$sort['1']}" : ""; $dq = self::getDQL()->select($fields)->orderBy('order_date desc'); $pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri); // Get the pager object $pager = $pagerLayout->getPager(); // Set the Order criteria if (isset($sort[0])) { $pager->getQuery()->orderBy($sort[0]); } if (isset($where) && is_array($where)) { foreach ($where as $filters) { if (isset($filters[0]) && is_array($filters[0])) { foreach ($filters as $filter) { $method = $filter['method']; $value = $filter['value']; $criteria = $filter['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } else { $method = $filters['method']; $value = $filters['value']; $criteria = $filters['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } } $pagerLayout->setTemplate('<li><a href="{%url}">{%page}</a></li>'); $pagerLayout->setSelectedTemplate('<li class="active"><a href="{%url}">{%page}</a></li>'); $orders = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $pagination = $pagerLayout->display(null, true); return array('records' => $orders, 'pagination' => $pagination, 'pager' => $pager, 'recordcount' => $dq->count()); }
/** * findAll * Get records the domains from the DB * @param $currentPage * @param $rowNum * @param $sort * @param $where * @return array */ public static function findAll($fields = "*", $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array()) { $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); // Defining the url sort $uri = isset($sort[1]) ? "/sort/{$sort['1']}" : ""; $dq = Doctrine_Query::create()->select($fields)->from('Domains d')->leftJoin('d.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->leftJoin('d.TagsConnections tc')->leftJoin('d.Customers c')->leftJoin('c.Customers r')->leftJoin('d.OrdersItems oi')->leftJoin('d.Statuses s')->orderBy('d.domain')->addWhere("c.isp_id = ?", Isp::getCurrentId()); $pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri); // Get the pager object $pager = $pagerLayout->getPager(); // Set the Order criteria if (isset($sort[0])) { $pager->getQuery()->orderBy($sort[0]); } if (isset($where) && is_array($where)) { foreach ($where as $filters) { if (isset($filters[0]) && is_array($filters[0])) { foreach ($filters as $filter) { $method = $filter['method']; $value = $filter['value']; $criteria = $filter['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } else { $method = $filters['method']; $value = $filters['value']; $criteria = $filters['criteria']; $pager->getQuery()->{$method}($criteria, $value); } } } $pagerLayout->setTemplate('<li><a href="{%url}">{%page}</a></li>'); $pagerLayout->setSelectedTemplate('<li class="active"><a href="{%url}">{%page}</a></li>'); $domains = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $pagination = $pagerLayout->display(null, true); return array('records' => $domains, 'pagination' => $pagination, 'pager' => $pager, 'recordcount' => $dq->count()); }