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', 'creationdate', 'cmd' ); if ($this->filter_order=='creationdate' && !$this->filter_order_Dir) $this->filter_order_Dir = 'asc'; $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->searchfranchise = $mainframe->getUserStateFromRequest( "$option.$view.searchfranchise", 'searchfranchise', '', 'string' ); if (!$this->searchfranchise) { $userId = LegacyHelper::getUserId(); $this->_db->setQuery("SELECT uf.franchise id FROM #__vxc_userfranchise uf WHERE uf.userid = ".$userId); $this->searchfranchise = $this->_db->loadResult(); } $customerId = (int) JRequest::getVar('customerId'); if ($customerId) $this->searchcustomerid = $customerId; $limit = -1; $limitstart = JRequest::getVar('limitstart',0); $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); } function getPredesigningColors() { $returnValue = array(); $modelSettings = new vxcModelSettings(); $strUserColors = $modelSettings->getVar('predesigningUserColors',''); $userColorsArray = explode(',',$strUserColors); for ($i=0;$isearchcustomerid) $where[] = ' o.customer = '.$this->searchcustomerid; if ($this->searchreference) $where[] = ' LOWER(o.reference) LIKE '. $this->_db->Quote('%'.$this->searchreference.'%') ; if ($this->searchuser) $where[] = " o.user = ".$this->searchuser; if ($this->searchcustomer) { $cond = " ((LOWER(CONCAT_WS(' ',c.name,c.middlename,c.surname)) LIKE ".$this->_db->Quote('%'.$this->searchcustomer.'%').')'; if (LegacyHelper::getNewMode()) $cond .=" OR (LOWER(CONCAT_WS(' ',atfirst.value,atmiddle.value,atlast.value)) LIKE ".$this->_db->Quote('%'.$this->searchcustomer.'%').')'; $cond .= ')'; $where[] = $cond; } if ($this->searchfranchise) $where[] = " uf.franchise = ".$this->searchfranchise; $where[] = ' o.deleted IS NOT TRUE '; $where[] = " (os.nameid = 'PREDESIGNING' OR os.nameid='COMPLETED')"; $where[] = ' o.delegatedesign = 1 '; $where[] = ' o.checked_date IS NULL ' ; $where[] = ' o.archived IS NOT TRUE '; if (!LegacyHelper::getNewMode() && LegacyHelper::updatedDB()) $where[] = " o.`uuid` IS NULL "; $where =( count($where) ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; $orderby = ''; $orders = array('id','username','customerfullname','reference','creationdate','predesigner'); 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; } $newModeFields = ''; $newJoins = ''; $oldModeFields =''; if (LegacyHelper::getNewMode()) { $newModeFields = "o.uuid uuid, CONCAT_WS(' ',NULLIF(CONCAT_WS(' ',NULLIF(c.name,''),NULLIF(c.middlename,''),NULLIF(c.surname,'')),''),NULLIF(atfirst.value,''),NULLIF(atmiddle.value,''),NULLIF(atlast.value,'')) customerfullname,"; $newJoins = " LEFT JOIN jos_vxc_attribute atfirst ON atfirst.orderid = o.id AND atfirst.name = 'patient.firstName' LEFT JOIN jos_vxc_attribute atmiddle ON atmiddle.orderid = o.id AND atmiddle.name = 'patient.middleName' LEFT JOIN jos_vxc_attribute atlast ON atlast.orderid = o.id AND atlast.name = 'patient.lastName' "; } else { $oldModeFields = "CONCAT_WS(' ',NULLIF(c.name,''),NULLIF(c.middlename,''),NULLIF(c.surname,'')) customerfullname,"; } $this->_query = " SELECT o.id id,o.user user, $newModeFields o.customer customer, o.reference reference, o.creationdate creationdate, o.currentStep currentStep, o.completedSteps completedSteps, o.predesigned_date predesigned_date, $oldModeFields o.predesigning_user predesigning_user, u2.name predesigner, u.name username " . ' FROM #__vxc_order o LEFT JOIN #__vxc_user u ON u.id = o.user LEFT JOIN #__vxc_user u2 ON u2.id = o.predesigning_user LEFT JOIN #__vxc_userfranchise uf ON uf.userid = u.id LEFT JOIN #__vxc_orderstate os ON os.id = o.state LEFT JOIN #__vxc_customer c ON c.id = o.customer ' .$newJoins . ' ' . $where . $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 getCustomers() { $userId = $this->searchuser; if (!$userId) return array(); $db =& $this->_db; $sql = "SELECT id id, CONCAT_WS(' ',name,middlename,surname) fullname FROM #__vxc_customer WHERE user = $userId AND deleted IS NOT TRUE"; $db->setQuery($sql); $customers = $db->loadObjectList(); return $customers; } function getUsers() { $db =& $this->_db; $sql = "SELECT id id, name name FROM #__vcx_user"; $db->setQuery($sql); $users = $db->loadObjectList(); return $users; } 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; 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; } }// class