public function init()
 {
     /* Populating Restaurant  Status Bd*/
     $StatusMapper = new Application_Model_UserStatusDataMapper();
     $statusres = $StatusMapper->fetchAll();
     $statusresLst = array();
     $statusresLst[] = array('key' => '', 'value' => 'Select Status');
     foreach ($statusres as $val) {
         $statusresLst[] = array('key' => $val->getId(), 'value' => $val->getDescription());
     }
     /* Populating State Base Data */
     $stateMapper = new Application_Model_StatebdMapper();
     $states = $stateMapper->fetchAll();
     $stateList = array();
     $stateList[] = array('key' => '', 'value' => 'Select Country');
     foreach ($states as $state) {
         $stateList[] = array('key' => $state->getId(), 'value' => $state->getDescription());
     }
     //         $companyList = array();
     //     	$companyMapper = new Administrator_Model_CompanyDataMapper();
     //     	$companyList = $companyMapper->getAllComapnyList();
     $firstName = $this->createElement('text', 'firstname');
     $firstName->removeDecorator('Label')->setAttrib('class', 'inp1 form input_form')->setAttrib('placeholder', 'First Name')->setAttrib('title', 'First Name')->removeDecorator('HtmlTag')->addFilters(array('StringTrim'))->setValue('');
     $resName = $this->createElement('text', 'resname');
     $resName->removeDecorator('Label')->setAttrib('class', 'inp1 form input_form')->setAttrib('placeholder', 'Restaurant Name')->setAttrib('title', 'Restaurant Name')->removeDecorator('HtmlTag')->addFilters(array('StringTrim'))->setValue('');
     $lastName = $this->createElement('text', 'lastname');
     $lastName->removeDecorator('Label')->setAttrib('class', 'inp1 form input_form')->setAttrib('placeholder', 'Last Name')->setAttrib('title', 'Last Name')->removeDecorator('HtmlTag')->addFilters(array('StringTrim'))->setValue('');
     $userId = $this->createElement('text', 'userId');
     $userId->removeDecorator('Label')->setAttrib('class', 'inp1 form input_form')->setAttrib('placeholder', 'User Id')->setAttrib('title', 'User Id')->removeDecorator('HtmlTag')->addValidator('Digits', new Zend_Validate_Digits(), array('messages' => 'Please enter Numbers only'))->setValue('');
     $email = $this->createElement('text', 'email');
     $email->removeDecorator('Label')->setAttrib('class', 'inp1 form input_form')->setAttrib('placeholder', 'Email')->setAttrib('title', 'Email')->removeDecorator('HtmlTag')->addFilters(array('StringTrim'))->setValue('');
     $Status = $this->createElement('select', 'status');
     $Status->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'drpDown form input_form')->setAttrib('title', 'Status')->addMultiOptions($statusresLst);
     $state = $this->createElement('select', 'state');
     $state->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1 form input_form')->setAttrib('title', 'Country')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select State.'))))->addMultiOptions($stateList)->setRequired(false);
     $region = $this->createElement('select', 'region');
     $region->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'drpDown form input_form')->setAttrib('title', 'State')->setRegisterInArrayValidator(false)->setRequired(false);
     $city = $this->createElement('select', 'city');
     $city->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1 form input_form')->setAttrib('title', 'City')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select City.'))))->setRegisterInArrayValidator(false)->setRequired(false);
     //          $company = $this->createElement('select','company');
     // 		 $company->removeDecorator('Label')
     //          	     ->removeDecorator('HtmlTag')
     // //         	     ->setAttrib('style','width:160px')
     //          	     ->setAttrib('class','drpDown form input_form')
     //          	     ->setAttrib('title','Company')
     //                  ->addMultiOptions($companyList);
     $Search = $this->createElement('submit', 'search');
     $Search->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setValue('Search')->setAttrib('class', 'submitBtn')->setIgnore(true);
     $this->addElements(array($userId, $email, $resName, $firstName, $lastName, $Status, $state, $region, $city, $Search));
 }
示例#2
0
 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());
     }
 }