setDBO(VoxelCareDB::getDatabase()); $view =JRequest::getVar('view'); //global $option; $this->filter_order_Dir = $mainframe->getUserStateFromRequest( $option.$view.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); $this->filter_order = $mainframe->getUserStateFromRequest( $option.$view.'.filter_order', 'filter_order', 'payment_date', 'cmd' ); $this->searchreference = $mainframe->getUserStateFromRequest( "$option.$view.searchreference", 'searchreference', '', 'string' ); $this->searchreference = JString::strtolower( $this->searchreference ); $this->searchcustomer = $mainframe->getUserStateFromRequest( "$option.$view.searchcustomer", 'searchcustomer', '', 'string' ); $this->searchcustomer = JString::strtolower( $this->searchcustomer ); $this->searchuser = $mainframe->getUserStateFromRequest( "$option.$view.searchuser", 'searchuser', '', 'string' ); $this->searchuser = JString::strtolower( $this->searchuser ); $this->searchstate = $mainframe->getUserStateFromRequest( "$option.$view.searchstate", 'searchstate', 'CHECKED', 'string' ); $customerId = (int) JRequest::getVar('customerId'); if ($customerId) $this->searchcustomerid = $customerId; $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', 10, 'int' ); $limitstart = JRequest::getVar('limitstart',0); $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); } function _buildQuery() { $where = array(); $groupby= array(); $groupby[] ='id'; $where =( count($where) ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; $having =( count($having) ) ? ' HAVING ' . implode( ' AND ', $having ) : ''; $groupby =( count($groupby) ) ? ' GROUP BY ' . implode( ' , ', $groupby ) : ''; $orderby = ''; $orders = array('id'); if (!in_array($this->filter_order,$orders)) $this->filter_order = 'id'; if (($this->filter_order) && ($this->filter_order_Dir)) { $orderby = ' ORDER BY '. $this->filter_order .' '. $this->filter_order_Dir; } $this->_query = " SELECT g.id id " . ' FROM #__vxc_giro g ' . $where . $groupby . $having . $orderby ; return $this->_query; } function getData() { if (empty($this->_data)) { $query = $this->_buildQuery(); $this->_db->setQuery( $query,$this->getState('limitstart'), $this->getState('limit') ); $this->_data = $this->_db->loadObjectList('id'); } return $this->_data; } function getList() { // table ordering $lists['order_Dir'] = $this->filter_order_Dir; $lists['order'] = $this->filter_order; // search filter $lists['searchreference']= $this->searchreference; $lists['searchcustomer']= $this->searchcustomer; $lists['searchstate']= $this->searchstate; return $lists; } function getTotal() { // Load the content if it doesn't already exist if (empty($this->_total)) { $query = $this->_buildQuery(); $this->_total = $this->_getListCount($query); } return $this->_total; } function getPagination() { // Load the content if it doesn't already exist if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') ); } return $this->_pagination; } function getPendingInvoices() { $userId = LegacyHelper::getUserId(); $this->_db->setQuery("SELECT uf.franchise id FROM #__vxc_userfranchise uf WHERE uf.userid = ".$userId); $franchiseId = $this->_db->loadResult(); if (!$franchiseId) return array(); $sql = "SELECT i.id id, i.total total, i.reference reference, u.name username, u.acctnumber acctnumber FROM #__vxc_invoice i LEFT JOIN #__vxc_batch b ON b.id = i.batch LEFT JOIN #__vxc_user u ON u.id = b.payment_user LEFT JOIN #__vxc_paymentmethod pm ON pm.id = b.payment_method LEFT JOIN #__vxc_userfranchise uf ON uf.userid = u.id LEFT JOIN #__vxc_franchise f ON uf.franchise = f.id WHERE pm.nameid='GIROBANCARIO' AND i.paid = FALSE AND i.returned = FALSE AND f.id = $franchiseId "; $this->_db->setQuery($sql); return $this->_db->loadObjectList(); } }// class