public function manageRestaurantOwners(User_Model_RestOwnSearch $obj, $offset) { try { $limit = 20; $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $stateTableMapper = new Application_Model_StatebdMapper(); $stateTable = $stateTableMapper->getDbTable(); $stateTableSelect = $stateTable->select(); $stateTableSelect->from($stateTable, array('id', 'code', 'description'))->where('status = ?', true); $cityTableMapper = new Application_Model_CitybdMapper(); $cityTable = $cityTableMapper->getDbTable(); $cityTableSelect = $cityTable->select(); $cityTableSelect->from($cityTable, array('id', 'code', 'description'))->where('status = ?', true); $storage = new Zend_Auth_Storage_Session(); $userdata = $storage->read(); $select->from(array('usr' => 'rd.user'), array('usrid', 'usremail', 'usrregistered_date', 'usruser_status_id', 'usrusertype_id', 'usripaddress'))->joinLeft(array('res' => 'rd.restaurant_details'), 'usr.usrid = res.resfk_user', array(''))->distinct()->join(array('own' => 'rd.restaurant_owner'), 'own.rsofk_user = usr.usrid', array('rsofirst_name', 'rsolast_name', 'rsorestaurant_name', 'rsophone', 'rsostateid', 'rsocityid', 'rsodescription', 'rsoregionid', 'rsocantfind', 'rsoyourstate', 'rsoyourregion', 'rsoyourcity', 'rso_companyid'))->join(array('usrsts' => 'rd.userstatus_bd'), 'usrsts.id = usr.usruser_status_id', array('code as statuscode', 'description as statusdesc'))->where('usr.usrusertype_id = ?', 3); if ($obj->getCompany()) { $select->where('own.rso_companyid = ?', $obj->getCompany()); } else { if ($userdata['Usertype'] == "ADU" && $userdata['companyid'] != 1) { $select->where('own.rso_companyid = ?', $userdata['companyid']); } } if ($obj->getResName()) { $select->where('res.resname Ilike ?', '%' . trim($obj->getResName()) . '%'); } if ($obj->getEmail()) { $select->where('usr.usremail Ilike ?', '%' . trim($obj->getEmail()) . '%'); } if ($obj->getId()) { $select->where('usr.usrid = ?', $obj->getId()); } if ($obj->getStatusId()) { $select->where('usr.usruser_status_id = ?', $obj->getStatusId()); } if ($obj->getFirstname()) { $select->where('own.rsofirst_name Ilike ?', '%' . trim($obj->getFirstname()) . '%'); } if ($obj->getLastname()) { $select->where('own.rsolast_name Ilike ?', '%' . trim($obj->getLastname()) . '%'); } if ($obj->getStateid()) { $select->where('own.rsostateid = ?', $obj->getStateid()); } if ($obj->getRegionid()) { $select->where('own.rsoregionid = ?', $obj->getRegionid()); } if ($obj->getCityid()) { $select->where('own.rsocityid = ?', $obj->getCityid()); } $select->order('usr.usrregistered_date DESC'); $result = $table->fetchAll($select); //print_r($result);die(); $rowset = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($select)); $rowset->setItemCountPerPage($limit); $rowset->setCurrentPageNumber($offset); return $rowset; } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
public function manageRestaurantOwners($data, $page) { try { $obj = new User_Model_RestOwnSearch(); $adminService = new Application_Service_Administrator(); $form = $adminService->getRestOwnerSearchForm(); if ($form->isValid($data)) { if ($data) { $formData = $form->getValues(); if ($formData['userId']) { $obj->setId($formData['userId']); } if ($formData['email']) { $obj->setEmail($formData['email']); } if ($formData['status']) { $obj->setStatusId($formData['status']); } if ($formData['firstname']) { $obj->setFirstname($formData['firstname']); } if ($formData['lastname']) { $obj->setLastname($formData['lastname']); } if ($formData['state']) { $obj->setStateid($formData['state']); } if ($formData['region']) { $obj->setRegionid($formData['region']); } if ($formData['city']) { $obj->setCityid($formData['city']); } if ($formData['resname']) { $obj->setResName($formData['resname']); } if ($formData['company']) { $obj->setCompany($formData['company']); } } $userMapper = new User_Model_ClientDataMapper(); $result = $userMapper->manageRestaurantOwners($obj, $page); return $result; } } catch (Exception $ex) { Rdine_Logger_FileLogger::info($ex->getMessage()); throw new Exception($ex->getMessage()); } }