示例#1
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', DOMAIN . 'countries/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'countries');
     $id = new Zend_Form_Element_Hidden('id');
     $country = new Zend_Form_Element_Select('country');
     $country->setAttrib('class', 'selectoption');
     $country->setAttrib('onchange', 'displayCountryCode(this)');
     $country->setRegisterInArrayValidator(false);
     $country->addMultiOption('', 'Select Country');
     $countrymodel = new Default_Model_Countries();
     $id_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null);
     $actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     if ($id_val == '' || $actionName == 'view') {
         $countrymodeldata = $countrymodel->getTotalCountriesList('addcountry');
         foreach ($countrymodeldata as $countryres) {
             $country->addMultiOption($countryres['id'], utf8_encode($countryres['country_name']));
         }
         $country->addMultiOption('other', 'Other');
     }
     $country->setRequired(true);
     $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_countries', 'field' => 'country_id_org', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $country->getValidator('Db_NoRecordExists')->setMessage('Country already exists.');
     $countrycode = new Zend_Form_Element_Text('countrycode');
     $countrycode->setAttrib('maxLength', 20);
     $countrycode->setAttrib('readonly', true);
     $countrycode->setAttrib('onfocus', 'this.blur()');
     $countrycode->setRequired(true);
     $countrycode->addValidator('NotEmpty', false, array('messages' => 'Please enter country code.'));
     $countrycode->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid country code.')));
     $citizenship = new Zend_Form_Element_Text('citizenship');
     $citizenship->setAttrib('maxLength', 20);
     $citizenship->setRequired(true);
     $citizenship->addValidator('NotEmpty', false, array('messages' => 'Please enter citizenship.'));
     $citizenship->addValidator("regex", true, array('pattern' => '/^[a-zA-Z\\s]*$/i', 'messages' => array('regexNotMatch' => 'Please enter valid citizenship.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $country, $countrycode, $citizenship, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
 public function comeditAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('empcommunicationdetails', $empOrganizationTabs)) {
             $empDeptdata = array();
             $employeeData = array();
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginuserRole = $auth->getStorage()->read()->emprole;
                 $loginuserGroup = $auth->getStorage()->read()->group_id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $employeeModal = new Default_Model_Employee();
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $empDept = $empdata[0]['department_id'];
                             $empcommdetailsform = new Default_Form_empcommunicationdetails();
                             $empcommdetailsModal = new Default_Model_Empcommunicationdetails();
                             $usersModel = new Default_Model_Users();
                             $countriesModel = new Default_Model_Countries();
                             $statesmodel = new Default_Model_States();
                             $citiesmodel = new Default_Model_Cities();
                             $orgInfoModel = new Default_Model_Organisationinfo();
                             $msgarray = array();
                             $orgid = 1;
                             $countryId = '';
                             $stateId = '';
                             $cityId = '';
                             $deptModel = new Default_Model_Departments();
                             if ($empDept != '' && $empDept != 'NULL') {
                                 $empDeptdata = $deptModel->getEmpdepartmentdetails($empDept);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             } else {
                                 $empDeptdata = $orgInfoModel->getOrganisationDetails($orgid);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             }
                             if ($countryId != '') {
                                 $countryData = $countriesModel->getActiveCountryName($countryId);
                             }
                             if (!empty($countryData)) {
                                 $empDeptdata[0]['country'] = $countryData[0]['country'];
                             } else {
                                 $empDeptdata[0]['country'] = '';
                             }
                             if ($stateId != '') {
                                 $stateData = $statesmodel->getStateNameData($stateId);
                             }
                             if (!empty($stateData)) {
                                 $empDeptdata[0]['state'] = $stateData[0]['state'];
                             } else {
                                 $empDeptdata[0]['state'] = '';
                             }
                             if ($cityId != '') {
                                 $citiesData = $citiesmodel->getCitiesNameData($cityId);
                             }
                             if (!empty($citiesData)) {
                                 $empDeptdata[0]['city'] = $citiesData[0]['city'];
                             } else {
                                 $empDeptdata[0]['city'] = '';
                             }
                             $countrieslistArr = $countriesModel->getTotalCountriesList();
                             if (sizeof($countrieslistArr) > 0) {
                                 $empcommdetailsform->perm_country->addMultiOption('', 'Select Country');
                                 $empcommdetailsform->current_country->addMultiOption('', 'Select Country');
                                 foreach ($countrieslistArr as $countrieslistres) {
                                     $empcommdetailsform->perm_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     $empcommdetailsform->current_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                 }
                             } else {
                                 $msgarray['perm_country'] = 'Countries are not configured yet.';
                                 $msgarray['current_country'] = 'Countries are not configured yet.';
                             }
                             $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id);
                             if (!empty($data)) {
                                 $perm_country = $data[0]['perm_country'];
                                 if (isset($_POST['perm_country'])) {
                                     $perm_country = $_POST['perm_country'];
                                 }
                                 $perm_state = $data[0]['perm_state'];
                                 if (isset($_POST['perm_state'])) {
                                     $perm_state = $_POST['perm_state'];
                                 }
                                 $perm_city = $data[0]['perm_city'];
                                 if (isset($_POST['perm_city'])) {
                                     $perm_city = $_POST['perm_city'];
                                 }
                                 if ($perm_country != '') {
                                     $statePermlistArr = $statesmodel->getStatesList($perm_country);
                                     if (sizeof($statePermlistArr) > 0) {
                                         $empcommdetailsform->perm_state->addMultiOption('', 'Select State');
                                         foreach ($statePermlistArr as $statelistres) {
                                             $empcommdetailsform->perm_state->addMultiOption($statelistres['id'], $statelistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($perm_state != '') {
                                     $cityPermlistArr = $citiesmodel->getCitiesList($perm_state);
                                     if (sizeof($cityPermlistArr) > 0) {
                                         $empcommdetailsform->perm_city->addMultiOption('', 'Select City');
                                         foreach ($cityPermlistArr as $cityPermlistres) {
                                             $empcommdetailsform->perm_city->addMultiOption($cityPermlistres['id'], $cityPermlistres['city_name']);
                                         }
                                     }
                                 }
                                 $current_country = $data[0]['current_country'];
                                 if (isset($_POST['current_country'])) {
                                     $current_country = $_POST['current_country'];
                                 }
                                 $current_state = $data[0]['current_state'];
                                 if (isset($_POST['current_state'])) {
                                     $current_state = $_POST['current_state'];
                                 }
                                 $current_city = $data[0]['current_city'];
                                 if (isset($_POST['current_city'])) {
                                     $current_city = $_POST['current_city'];
                                 }
                                 if ($current_country != '') {
                                     $statecurrlistArr = $statesmodel->getStatesList($current_country);
                                     if (sizeof($statecurrlistArr) > 0) {
                                         $empcommdetailsform->current_state->addMultiOption('', 'Select State');
                                         foreach ($statecurrlistArr as $statecurrlistres) {
                                             $empcommdetailsform->current_state->addMultiOption($statecurrlistres['id'], $statecurrlistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($current_state != '') {
                                     $cityCurrlistArr = $citiesmodel->getCitiesList($current_state);
                                     if (sizeof($cityCurrlistArr) > 0) {
                                         $empcommdetailsform->current_city->addMultiOption('', 'Select City');
                                         foreach ($cityCurrlistArr as $cityCurrlistres) {
                                             $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'], $cityCurrlistres['city_name']);
                                         }
                                     }
                                 }
                                 $empcommdetailsform->populate($data[0]);
                                 $empcommdetailsform->setDefault('perm_country', $perm_country);
                                 $empcommdetailsform->setDefault('perm_state', $perm_state);
                                 $empcommdetailsform->setDefault('perm_city', $perm_city);
                                 if ($data[0]['current_country'] != '') {
                                     $empcommdetailsform->setDefault('current_country', $current_country);
                                 }
                                 if ($data[0]['current_state'] != '') {
                                     $empcommdetailsform->setDefault('current_state', $current_state);
                                 }
                                 if ($data[0]['current_city'] != '') {
                                     $empcommdetailsform->setDefault('current_city', $current_city);
                                 }
                             }
                             $empcommdetailsform->setAttrib('action', DOMAIN . 'myemployees/comedit/userid/' . $id);
                             $empcommdetailsform->user_id->setValue($id);
                             if (!empty($empdata)) {
                                 $this->view->employeedata = $empdata[0];
                             } else {
                                 $this->view->employeedata = $empdata;
                             }
                             if (!empty($empDeptdata)) {
                                 $this->view->dataArray = $empDeptdata[0];
                             } else {
                                 $this->view->dataArray = $empDeptdata;
                             }
                             $this->view->form = $empcommdetailsform;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             if ($this->getRequest()->getPost()) {
                 $result = $this->comsave($empcommdetailsform, $id);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 /**
  * This action is used for adding data.    
  * @return Zend_Form.
  */
 public function addAction()
 {
     $req_model = new Default_Model_Requisition();
     $cand_model = new Default_Model_Candidatedetails();
     $cand_work_model = new Default_Model_Candidateworkdetails();
     $countriesModel = new Default_Model_Countries();
     $auth = Zend_Auth::getInstance();
     $msgarray = array();
     $popConfigPermission = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
     $req_options = array();
     foreach ($req_data as $req) {
         $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
     }
     if (count($req_options) == 0) {
         $msgarray['requisition_id'] = "No approved requisitions.";
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Candidatedetails();
     $form->setAction(DOMAIN . 'candidatedetails/add');
     $countrieslistArr = $countriesModel->getTotalCountriesList();
     if (sizeof($countrieslistArr) > 0) {
         $form->country->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     } else {
         $msgarray['country'] = 'Countries are not configured yet';
     }
     $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
     if (isset($_POST['country']) && $_POST['country'] != '') {
         $statesmodel = new Default_Model_States();
         $statesmodeldata = $statesmodel->getStatesList(intval($_POST['country']));
         $st_opt = array();
         if (count($statesmodeldata) > 0) {
             foreach ($statesmodeldata as $dstate) {
                 $st_opt[$dstate['id'] . '!@#' . $dstate['state_name']] = $dstate['state_name'];
             }
         }
         $form->state->addMultiOptions(array('' => 'Select State') + $st_opt);
     }
     if (isset($_POST['state']) && $_POST['state'] != '') {
         $citiesmodel = new Default_Model_Cities();
         $citiesmodeldata = $citiesmodel->getCitiesList(intval($_POST['state']));
         $ct_opt = array();
         if (count($citiesmodeldata) > 0) {
             foreach ($citiesmodeldata as $dcity) {
                 $ct_opt[$dcity['id'] . '!@#' . $dcity['city_name']] = $dcity['city_name'];
             }
         }
         $form->city->addMultiOptions(array('' => 'Select City') + $ct_opt);
     }
     $data = array();
     $data['cand_resume'] = $this->_getParam('cand_resume');
     $data['selected_option'] = $this->_getParam('selected_option');
     $this->view->form = $form;
     $this->view->data = $data;
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->msgarray = $msgarray;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $employeeData = array();
             $id = $this->getRequest()->getParam('userid');
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'workeligibilitydetails';
             $issuingauthority = '';
             $employeeModal = new Default_Model_Employee();
             $workeligibilityform = new Default_Form_Workeligibilitydetails();
             $workeligibilityform->removeElement("submit");
             $elements = $workeligibilityform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $usersModel = new Default_Model_Users();
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $workeligibilityModel = new Default_Model_Workeligibilitydetails();
                             if ($id) {
                                 $usersModel = new Default_Model_Users();
                                 $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                                 $countriesModel = new Default_Model_Countries();
                                 $statesmodel = new Default_Model_States();
                                 $citiesmodel = new Default_Model_Cities();
                                 $countrieslistArr = $countriesModel->getTotalCountriesList();
                                 if (sizeof($countrieslistArr) > 0) {
                                     $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country');
                                     foreach ($countrieslistArr as $countrieslistres) {
                                         $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     }
                                 } else {
                                     $msgarray['issuingauth_country'] = 'Countries are not configured yet.';
                                 }
                                 $data = $workeligibilityModel->getWorkEligibilityRecord($id);
                                 if (!empty($data) && isset($data)) {
                                     $countryId = $data[0]['issuingauth_country'];
                                     $stateId = $data[0]['issuingauth_state'];
                                     $cityId = $data[0]['issuingauth_city'];
                                     $documenttype_id = $data[0]['documenttype_id'];
                                     if ($countryId != '') {
                                         $statelistArr = $statesmodel->getStatesList($countryId);
                                         if (sizeof($statelistArr) > 0) {
                                             $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State');
                                             foreach ($statelistArr as $statelistres) {
                                                 $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                                             }
                                         }
                                     }
                                     if ($stateId != '') {
                                         $citylistArr = $citiesmodel->getCitiesList($stateId);
                                         if (sizeof($citylistArr) > 0) {
                                             $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City');
                                             foreach ($citylistArr as $cityPermlistres) {
                                                 $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                                             }
                                         }
                                         $stateNameArr = $statesmodel->getStateName($stateId);
                                     }
                                     if ($cityId != '') {
                                         $cityNameArr = $citiesmodel->getCityName($cityId);
                                     }
                                     if ($documenttype_id != '') {
                                         $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                                     }
                                     if (!empty($issuingauthorityArr)) {
                                         $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                                         $workeligibilityform->issuingauthflag->setValue($issuingauthority);
                                         $workeligibilityform->documenttype_id->addMultiOption($issuingauthorityArr[0]['id'], $issuingauthorityArr[0]['documenttype']);
                                     }
                                     $workeligibilityform->setDefault("id", $data[0]["id"]);
                                     $workeligibilityform->setDefault("user_id", $data[0]["user_id"]);
                                     $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']);
                                     if (!empty($stateNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']);
                                     }
                                     if (!empty($cityNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']);
                                     }
                                     $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]);
                                     $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]);
                                     $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]);
                                     $issue_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_issue_date"]));
                                     $workeligibilityform->setDefault('doc_issue_date', $issue_date);
                                     $expiry_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_expiry_date"]));
                                     $workeligibilityform->setDefault('doc_expiry_date', $expiry_date);
                                 }
                                 $this->view->controllername = $objName;
                                 $this->view->id = $id;
                                 $this->view->data = $data;
                                 $this->view->employeedata = $employeeData[0];
                                 $this->view->form = $workeligibilityform;
                                 $this->view->issuingauthority = $issuingauthority;
                             }
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function editpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $userid = $this->getRequest()->getParam('unitId');
     if ($id == '') {
         $id = $loginUserId;
     }
     // For open the form in popup...
     $empadditionaldetailsform = new Default_Form_empadditionaldetails();
     $empadditionaldetailsModal = new Default_Model_Empadditionaldetails();
     $countriesModel = new Default_Model_Countries();
     $veteranstatusmodel = new Default_Model_Veteranstatus();
     $militaryservicemodel = new Default_Model_Militaryservice();
     $countrieslistArr = $countriesModel->getTotalCountriesList();
     $empadditionaldetailsform->countries_served->addMultiOption('', 'Select Country');
     if (!empty($countrieslistArr)) {
         foreach ($countrieslistArr as $countrieslistres) {
             $empadditionaldetailsform->countries_served->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     }
     $militaryserviceArr = $militaryservicemodel->getTotalMilitaryServiceData();
     $empadditionaldetailsform->military_servicetype->addMultiOption('', 'Select Service Type');
     if (!empty($militaryserviceArr)) {
         foreach ($militaryserviceArr as $militaryserviceres) {
             $empadditionaldetailsform->military_servicetype->addMultiOption($militaryserviceres['id'], $militaryserviceres['militaryservicetype']);
         }
     }
     $veteranstatusArr = $veteranstatusmodel->getTotalVeteranStatusData();
     $empadditionaldetailsform->veteran_status->addMultiOption('', 'Select Veteran Status');
     if (!empty($veteranstatusArr)) {
         foreach ($veteranstatusArr as $veteranstatusres) {
             $empadditionaldetailsform->veteran_status->addMultiOption($veteranstatusres['id'], $veteranstatusres['veteranstatus']);
         }
     }
     if ($id) {
         $data = $empadditionaldetailsModal->getEmpAdditionalDetailsData($id);
         if (!empty($data)) {
             $empadditionaldetailsform->populate($data[0]);
             $empadditionaldetailsform->setDefault('countries_served', $data[0]['countries_served']);
             $empadditionaldetailsform->setDefault('military_servicetype', $data[0]['military_servicetype']);
             $empadditionaldetailsform->setDefault('veteran_status', $data[0]['veteran_status']);
             $from_date = sapp_Global::change_date($data[0]['from_date'], 'view');
             $to_date = sapp_Global::change_date($data[0]['to_date'], 'view');
             $empadditionaldetailsform->from_date->setValue($from_date);
             $empadditionaldetailsform->to_date->setValue($to_date);
             $this->view->data = $data;
         }
     }
     $empadditionaldetailsform->setAttrib('action', BASE_URL . 'empadditionaldetails/editpopup/unitId/' . $userid);
     $this->view->form = $empadditionaldetailsform;
     $this->view->controllername = 'empadditionaldetails';
     if ($this->getRequest()->getPost()) {
         $result = $this->save($empadditionaldetailsform, $userid);
         $this->view->msgarray = $result;
     }
 }
 public function workeligibilityAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $tabName = "workeligibility";
             $employeeData = array();
             $msgarray = array();
             $emptyFlag = 0;
             $issuingauthority = '';
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $userid = $loginUserId;
             $employeeModal = new Default_Model_Employee();
             $empdata = $employeeModal->getsingleEmployeeData($userid);
             if ($empdata == 'norows') {
                 $this->view->rowexist = "norows";
                 $this->view->empdata = "";
             } else {
                 $this->view->rowexist = "rows";
                 if (!empty($empdata)) {
                     $workeligibilityform = new Default_Form_Workeligibilitydetails();
                     $workeligibilityModel = new Default_Model_Workeligibilitydetails();
                     $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                     //fetchAll($where = null, $order = null, $count = null, $offset = null) function syntax...
                     $workeligibilityDoctypesData = $workeligibilityDoctypesModal->fetchAll('isactive=1', 'documenttype');
                     $workeligibilityDoctypesDataArr = $workeligibilityDoctypesData->toArray();
                     if (!empty($workeligibilityDoctypesDataArr)) {
                         foreach ($workeligibilityDoctypesDataArr as $data) {
                             $workeligibilityform->documenttype_id->addMultiOption($data['id'], $data['documenttype']);
                         }
                     } else {
                         $msgarray['documenttype_id'] = 'Work eligibility document types are not configured yet.';
                         $emptyFlag++;
                     }
                     if ($userid) {
                         $countriesModel = new Default_Model_Countries();
                         $statesmodel = new Default_Model_States();
                         $citiesmodel = new Default_Model_Cities();
                         $countrieslistArr = $countriesModel->getTotalCountriesList();
                         if (sizeof($countrieslistArr) > 0) {
                             $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country');
                             foreach ($countrieslistArr as $countrieslistres) {
                                 $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                             }
                         } else {
                             $msgarray['issuingauth_country'] = 'Countries are not configured yet.';
                             $emptyFlag++;
                         }
                         $data = $workeligibilityModel->getWorkEligibilityRecord($userid);
                         if (!empty($data) && isset($data)) {
                             $countryId = $data[0]['issuingauth_country'];
                             $stateId = $data[0]['issuingauth_state'];
                             $cityId = $data[0]['issuingauth_city'];
                             $documenttype_id = $data[0]['documenttype_id'];
                             //Populating states & cities Drop down......... from tbl_states & tbl_cities
                             if ($countryId != '') {
                                 $statelistArr = $statesmodel->getStatesList($countryId);
                                 if (sizeof($statelistArr) > 0) {
                                     $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State');
                                     foreach ($statelistArr as $statelistres) {
                                         $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                                     }
                                 }
                             }
                             if ($stateId != '') {
                                 $citylistArr = $citiesmodel->getCitiesList($stateId);
                                 if (sizeof($citylistArr) > 0) {
                                     $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City');
                                     foreach ($citylistArr as $cityPermlistres) {
                                         $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                                     }
                                 }
                                 $stateNameArr = $statesmodel->getStateName($stateId);
                             }
                             if ($cityId != '') {
                                 $cityNameArr = $citiesmodel->getCityName($cityId);
                             }
                             if ($documenttype_id != '') {
                                 $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                             }
                             if (!empty($issuingauthorityArr)) {
                                 $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                                 $workeligibilityform->issuingauthflag->setValue($issuingauthority);
                             }
                             $workeligibilityform->setDefault("id", $data[0]["id"]);
                             $workeligibilityform->setDefault("user_id", $data[0]["user_id"]);
                             $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']);
                             if (!empty($stateNameArr)) {
                                 $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']);
                             }
                             if (!empty($cityNameArr)) {
                                 $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']);
                             }
                             $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]);
                             $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]);
                             $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]);
                             $issue_date = sapp_Global::change_date($data[0]["doc_issue_date"], 'view');
                             $workeligibilityform->setDefault('doc_issue_date', $issue_date);
                             $expiry_date = sapp_Global::change_date($data[0]["doc_expiry_date"], 'view');
                             $workeligibilityform->setDefault('doc_expiry_date', $expiry_date);
                         }
                         $workeligibilityform->setAttrib('action', DOMAIN . 'mydetails/workeligibility');
                         $this->view->id = $userid;
                         $this->view->data = $data;
                         $this->view->form = $workeligibilityform;
                         $this->view->issuingauthority = $issuingauthority;
                         $this->view->msgarray = $msgarray;
                     }
                     if ($this->getRequest()->getPost()) {
                         $documenttype_id = $this->_request->getParam('documenttype_id');
                         if ($documenttype_id != '') {
                             $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                         }
                         if (!empty($issuingauthorityArr)) {
                             $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                             if ($issuingauthority == 2) {
                                 $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.');
                                 $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.'));
                             } else {
                                 if ($issuingauthority == 3) {
                                     $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.');
                                     $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.'));
                                     $workeligibilityform->issuingauth_city->setRequired(true)->addErrorMessage('Please select a city.');
                                     $workeligibilityform->issuingauth_city->addValidator('NotEmpty', false, array('messages' => 'Please select a city.'));
                                 }
                             }
                         }
                         $result = $this->save($workeligibilityform, $tabName);
                         $result['issuingauthorityflag'] = $_POST['issuingauthflag'];
                         $this->view->msgarray = $result;
                     }
                 }
                 $this->view->empdata = $empdata;
                 $this->view->emptyFlag = $emptyFlag;
                 $this->view->messages = $this->_helper->flashMessenger->getMessages();
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
示例#7
0
 public function addnewstateAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $msgarray = array();
     $controllername = 'states';
     $statestring = '';
     $id = $this->getRequest()->getParam('id');
     $selectedcountryid = $this->_request->getParam('selectcountryid', null);
     $statesform = new Default_Form_states();
     $statesmodel = new Default_Model_States();
     $countriesModel = new Default_Model_Countries();
     /* Changing the form */
     $statesform->setAction(BASE_URL . 'states/addnewstate/selectcountryid/' . $selectedcountryid);
     $statesform->removeElement('state');
     $statesform->addElement('text', 'state', array('label' => 'State', 'maxlength' => '20', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter state name.')))));
     /* END */
     $countrieslistArr = $countriesModel->getTotalCountriesList('');
     if (sizeof($countrieslistArr) > 0) {
         $statesform->countryid->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             if (isset($selectedcountryid)) {
                 if ($countrieslistres['id'] == $selectedcountryid) {
                     $statesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                     $statesform->setDefault('countryid', $selectedcountryid);
                 }
             } else {
                 $statesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
             }
         }
     } else {
         $msgarray['countryid'] = 'Countries are not configured yet';
     }
     if ($this->getRequest()->getPost()) {
         $errorflag = "true";
         $msgarray = array();
         $id = $this->_request->getParam('id');
         $dbstate = '';
         $dbcountryid = '';
         $state = trim($this->_request->getParam('state'));
         $countryid = $this->_request->getParam('countryid');
         if (isset($countryid) && $countryid != '') {
             $isDuplicateStateNameArr = $statesmodel->getDuplicateStateName($state, $countryid);
             if ($isDuplicateStateNameArr[0]['count'] > 0) {
                 $errorflag = "false";
                 $msgarray['state'] = "State already exists.";
             }
         } else {
             $errorflag = "false";
             $msgarray['countryid'] = "Please select country.";
         }
         if ($statesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $NewStateId = $statesmodel->SaveMainStateData($countryid, $state);
             $tableid = $NewStateId;
             $actionflag = 1;
             $menuidArr = $menumodel->getMenuObjID('/states');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             if (isset($selectedcountryid)) {
                 $stateData = $statesmodel->getStatesList($selectedcountryid, '');
             } else {
                 $stateData = array();
             }
             $opt = '';
             foreach ($stateData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['state_name']);
             }
             $this->view->stateData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $statesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
         }
     }
     $this->view->ermsg = '';
     $this->view->form = $statesform;
     $this->view->msgarray = $msgarray;
     $this->view->controllername = $controllername;
 }
示例#8
0
 public function addnewcityAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $selectedcountryid = $this->_request->getParam('selectcountryid');
     $selectedstateid = $this->_request->getParam('selectstateid');
     $msgarray = array();
     $setDefaultString = '';
     $citystring = '';
     $controllername = 'cities';
     $citiesform = new Default_Form_cities();
     $citiesmodel = new Default_Model_Cities();
     $countriesModel = new Default_Model_Countries();
     $statesmodel = new Default_Model_States();
     /* Changing the form */
     $citiesform->setAction(BASE_URL . 'cities/addnewcity/selectcountryid/' . $selectedcountryid . '/selectstateid/' . $selectedstateid);
     $citiesform->removeElement('city');
     $citiesform->addElement('text', 'city', array('label' => 'City', 'maxlength' => '20', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter city name.')))));
     /* END */
     $countrieslistArr = $countriesModel->getTotalCountriesList('');
     if (sizeof($countrieslistArr) > 0) {
         $citiesform->countryid->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             if ($selectedcountryid != '') {
                 if ($countrieslistres['id'] == $selectedcountryid) {
                     $citiesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                     $citiesform->setDefault('countryid', $selectedcountryid);
                 }
             } else {
                 $citiesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
             }
             $citiesform->countryid->setAttrib('onchange', 'displayParticularState_normal(this,"","state","city")');
         }
     } else {
         $msgarray['countryid'] = 'Countries are not configured yet.';
     }
     $countryid = $this->_request->getParam('countryid');
     if (isset($selectedcountryid) && $selectedcountryid != '' || isset($countryid) && $countryid != '') {
         if ($countryid) {
             $statesmodeldata = $statesmodel->getStatesList($countryid, '');
         } else {
             $statesmodeldata = $statesmodel->getStatesList($selectedcountryid, '');
         }
         $citiesform->state->addMultiOption('', 'Select State');
         foreach ($statesmodeldata as $res) {
             $citiesform->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
             if ($selectedstateid != '') {
                 if ($res['id'] == $selectedstateid) {
                     $setDefaultString = $res['id'];
                 }
             } else {
                 if ($countryid != '') {
                     if ($res['id'] == $countryid) {
                         $setDefaultString = $res['id'];
                     }
                 }
             }
         }
         $citiesform->setDefault('state', $setDefaultString);
     } else {
         $citiesform->state->addMultiOption('', 'Select State');
     }
     if ($this->getRequest()->getPost()) {
         $id = $this->_request->getParam('id');
         $errorflag = "true";
         $msgarray = array();
         $dbstate = '';
         $dbcountryid = '';
         $stateidstr = $this->_request->getParam('state');
         $stateid = intval($stateidstr);
         $city = $this->_request->getParam('city');
         if (isset($stateid)) {
             $isDuplicateCityNameArr = $citiesmodel->getDuplicateCityName($city, $stateid);
             if ($isDuplicateCityNameArr[0]['count'] > 0) {
                 $errorflag = "false";
                 $msgarray['city'] = "City already exists.";
             }
         } else {
             $errorflag = "false";
             $msgarray['state'] = "Please select state.";
         }
         if ($citiesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $menumodel = new Default_Model_Menu();
             $city = $this->_request->getParam('city');
             $actionflag = '';
             $tableid = '';
             $NewCityId = $citiesmodel->SaveMainCityData($stateid, $city);
             $actionflag = 1;
             $tableid = $NewCityId;
             $menuidArr = $menumodel->getMenuObjID('/cities');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             if (isset($selectedstateid) && isset($selectedcountryid)) {
                 $cityData = $citiesmodel->getCitiesList($selectedstateid, 'city');
             } else {
                 $cityData = array();
             }
             $opt = '';
             foreach ($cityData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['city_name']);
             }
             $this->view->cityData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $citiesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             if (isset($countryid) && $countryid != 0 && $countryid != '') {
                 $statesmodel = new Default_Model_States();
                 $statesmodeldata = $statesmodel->getBasicStatesList($countryid);
                 foreach ($statesmodeldata as $res) {
                     $citiesform->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state']));
                 }
                 if (isset($stateidstr) && $stateidstr != 0 && $stateidstr != '') {
                     $citiesform->setDefault('state', $stateidstr);
                 }
             }
         }
     }
     $this->view->controllername = $controllername;
     $this->view->ermsg = '';
     $this->view->form = $citiesform;
     $this->view->msgarray = $msgarray;
 }
 /**
  * 
  */
 public function candidatepopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $req_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $cand_model = new Default_Model_Candidatedetails();
     $candwork_model = new Default_Model_Candidateworkdetails();
     $country_model = new Default_Model_Countries();
     $role_model = new Default_Model_Roles();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $login_group_id = $auth->getStorage()->read()->group_id;
         $login_role_id = $auth->getStorage()->read()->emprole;
     }
     $id = $this->getRequest()->getParam('cand_id');
     $form = new Default_Form_Candidatedetails();
     $req_data = array();
     $jobtitle = '';
     $req_data['jobtitlename'] = '';
     try {
         $candidateData = $cand_model->getcandidateData($id);
         $req_data = $req_model->getRequisitionDataById($candidateData['requisition_id']);
         $req_data['cand_resume'] = !empty($candidateData['cand_resume']) ? $candidateData['cand_resume'] : '';
         $req_data['rec_id'] = $id;
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($req_data['jobtitle']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = $jobttlArr[0]['jobtitlename'];
             $req_data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $req_options = array();
         $req_options[$req_data['id']] = $req_data['requisition_code'];
         try {
             $candidateworkData = $candwork_model->getcandidateworkData($id);
             $countryId = $candidateData['country'];
             $stateId = $candidateData['state'];
             $cityId = $candidateData['city'];
             if ($countryId && $stateId) {
                 $statesmodel = new Default_Model_States();
                 $citiesmodel = new Default_Model_Cities();
                 $statesData = $statesmodel->getStatesList($countryId);
                 $citiesData = $citiesmodel->getCitiesList($stateId);
                 foreach ($statesData as $res) {
                     $form->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
                 }
                 foreach ($citiesData as $res) {
                     $form->city->addMultiOption($res['id'], utf8_encode($res['city_name']));
                 }
                 $form->setDefault('country', $countryId);
                 $form->setDefault('state', $stateId);
                 $form->setDefault('city', $cityId);
                 $form->setDefault('job_title', $jobtitle);
             }
             $countrieslistArr = $country_model->getTotalCountriesList();
             if (sizeof($countrieslistArr) > 0) {
                 $form->country->addMultiOption('0', 'Select Country');
                 foreach ($countrieslistArr as $countrieslistres) {
                     $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                 }
             } else {
                 $msgarray['country'] = 'Countries not configured yet';
             }
             $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
             if ($id) {
                 $form->submit->setLabel('Update');
                 $form->populate($candidateworkData);
                 $form->populate($candidateData);
             }
             $elements = $form->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             $previ_data = sapp_Global::_checkprivileges(CANDIDATEDETAILS, $login_group_id, $login_role_id, 'edit');
             $this->view->form = $form;
             $this->view->previ_data = $previ_data;
             $this->view->workdata = $candidateworkData;
             $this->view->ermsg = '';
             $this->view->req_data = $req_data;
             $objName = 'candidatedetails';
             $this->view->id = $id;
             $this->view->controllername = $objName;
         } catch (Exception $e) {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
示例#10
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'agencylist');
     $this->setAttrib('action', BASE_URL . 'agencylist/edit/id/1');
     $id = new Zend_Form_Element_Hidden('id');
     $pocid_1 = new Zend_Form_Element_Hidden('pocid_1');
     $pocid_2 = new Zend_Form_Element_Hidden('pocid_2');
     $pocid_3 = new Zend_Form_Element_Hidden('pocid_3');
     $agencyname = new Zend_Form_Element_Text('agencyname');
     $agencyname->setAttrib('maxLength', 50);
     $agencyname->addFilter(new Zend_Filter_StringTrim());
     $agencyname->setRequired(true);
     $agencyname->addValidator('NotEmpty', false, array('messages' => 'Please enter agency name.'));
     $agencyname->addValidator("regex", true, array('pattern' => '/^(?![0-9]{4})[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid agency name.')));
     $address = new Zend_Form_Element_Textarea('address');
     $address->setAttrib('rows', 10);
     $address->setAttrib('cols', 50);
     $address->setRequired(true);
     $address->addValidator('NotEmpty', false, array('messages' => 'Please enter address.'));
     $primaryphone = new Zend_Form_Element_Text('primaryphone');
     $primaryphone->setAttrib('maxLength', 15);
     $primaryphone->addFilter(new Zend_Filter_StringTrim());
     $primaryphone->setRequired(true);
     $primaryphone->addValidator('NotEmpty', false, array('messages' => 'Please enter primary phone number.'));
     $primaryphone->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Primary phone number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Primary phone number must contain at least %min% characters.')))));
     $primaryphone->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $primaryphone->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_bgagencylist', 'field' => 'primaryphone', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $primaryphone->getValidator('Db_NoRecordExists')->setMessage('Primary phone number already exists.');
     $secondaryphone = new Zend_Form_Element_Text('secondaryphone');
     $secondaryphone->setAttrib('maxLength', 15);
     $secondaryphone->addFilter(new Zend_Filter_StringTrim());
     $secondaryphone->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Secondary phone number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Secondary phone number must contain at least %min% characters.')))));
     $secondaryphone->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $checktype = new Zend_Form_Element_Multiselect('bg_checktype');
     $checktype->setRequired(true)->addErrorMessage('Please select screening type.');
     $checktype->addValidator('NotEmpty', false, array('messages' => 'Please select screening type.'));
     $checktypeModal = new Default_Model_Bgscreeningtype();
     $typesData = $checktypeModal->fetchAll('isactive=1', 'type');
     foreach ($typesData->toArray() as $data) {
         $checktype->addMultiOption($data['id'], $data['type']);
     }
     $checktype->setRegisterInArrayValidator(false);
     $emprole = new Zend_Form_Element_Select('emprole');
     $emprole->setRequired(true)->addErrorMessage('Please select role.');
     $emprole->addValidator('NotEmpty', false, array('messages' => 'Please select role.'));
     $emprole->addMultiOption('', 'Select Role');
     $agencyModal = new Default_Model_Agencylist();
     $roleData = $agencyModal->getagencyrole();
     foreach ($roleData as $data) {
         $emprole->addMultiOption($data['id'], $data['rolename']);
     }
     $emprole->setRegisterInArrayValidator(false);
     $website = new Zend_Form_Element_Text('website_url');
     $website->setAttrib('maxLength', 50);
     $website->addFilter(new Zend_Filter_StringTrim());
     $website->setRequired(true);
     $website->addValidator('NotEmpty', false, array('messages' => 'Please enter website URL.'));
     $website->addValidator("regex", true, array('pattern' => '/^(http:\\/\\/www|https:\\/\\/www|www)+\\.([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,3})$/', 'messages' => array('regexNotMatch' => 'Please enter valid URL.')));
     $firstname_1 = new Zend_Form_Element_Text('firstname_1');
     $firstname_1->setAttrib('maxLength', 50);
     $firstname_1->addFilter(new Zend_Filter_StringTrim());
     $firstname_1->setRequired(true);
     $firstname_1->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
     $firstname_1->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_1 = new Zend_Form_Element_Text('lastname_1');
     $lastname_1->setAttrib('maxLength', 50);
     $lastname_1->addFilter(new Zend_Filter_StringTrim());
     $lastname_1->setRequired(true);
     $lastname_1->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
     $lastname_1->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_1 = new Zend_Form_Element_Text('mobile_1');
     $mobile_1->setAttrib('maxLength', 10);
     $mobile_1->addFilter(new Zend_Filter_StringTrim());
     $mobile_1->setRequired(true);
     $mobile_1->addValidator('NotEmpty', false, array('messages' => 'Please enter 10 digit mobile number.'));
     $mobile_1->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_1->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $email_1 = new Zend_Form_Element_Text('email_1');
     $email_1->setAttrib('maxLength', 50);
     $email_1->addFilter(new Zend_Filter_StringTrim());
     $email_1->setRequired(true);
     $email_1->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
     $location_1 = new Zend_Form_Element_Text('location_1');
     $location_1->setAttrib('maxLength', 50);
     $location_1->addFilter(new Zend_Filter_StringTrim());
     $location_1->setRequired(true);
     $location_1->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
     $country_1 = new Zend_Form_Element_Select('country_1');
     $country_1->setLabel('country');
     $country_1->setRequired(true);
     $country_1->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country_1->setAttrib('onchange', 'displayParticularState_normal(this,"","state_1","city_1")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_1->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_1->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $country_1->setRegisterInArrayValidator(false);
     $state_1 = new Zend_Form_Element_Select('state_1');
     $state_1->setAttrib('class', 'selectoption');
     $state_1->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_1","")');
     $state_1->setRegisterInArrayValidator(false);
     $state_1->addMultiOption('', 'Select State');
     $state_1->setRequired(true);
     $state_1->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $city_1 = new Zend_Form_Element_Select('city_1');
     $city_1->setAttrib('class', 'selectoption');
     $city_1->setAttrib('onchange', 'displayCityCode(this)');
     $city_1->setRegisterInArrayValidator(false);
     $city_1->addMultiOption('', 'Select City');
     $city_1->setRequired(true);
     $city_1->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $contact_type_1 = new Zend_Form_Element_Select('contact_type_1');
     $contact_type_1->setLabel('contact_type_1')->setMultiOptions(array('' => 'Select Contact Type', '1' => 'Primary', '2' => 'Secondary'));
     $contact_type_1->setRegisterInArrayValidator(false);
     $contact_type_1->setRequired(true);
     $contact_type_1->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
     $firstname_2 = new Zend_Form_Element_Text('firstname_2');
     $firstname_2->setAttrib('maxLength', 50);
     $firstname_2->addFilter(new Zend_Filter_StringTrim());
     $lastname_2 = new Zend_Form_Element_Text('lastname_2');
     $lastname_2->setAttrib('maxLength', 50);
     $lastname_2->addFilter(new Zend_Filter_StringTrim());
     $mobile_2 = new Zend_Form_Element_Text('mobile_2');
     $mobile_2->setAttrib('maxLength', 10);
     $mobile_2->addFilter(new Zend_Filter_StringTrim());
     $email_2 = new Zend_Form_Element_Text('email_2');
     $email_2->setAttrib('maxLength', 50);
     $email_2->addFilter(new Zend_Filter_StringTrim());
     $location_2 = new Zend_Form_Element_Text('location_2');
     $location_2->setAttrib('maxLength', 50);
     $location_2->addFilter(new Zend_Filter_StringTrim());
     $country_2 = new Zend_Form_Element_Select('country_2');
     $country_2->setLabel('country');
     $country_2->setAttrib('onchange', 'displayParticularState_normal(this,"","state_2","city_2")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_2->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_2->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $state_2 = new Zend_Form_Element_Select('state_2');
     $state_2->setAttrib('class', 'selectoption');
     $state_2->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_2","")');
     $state_2->addMultiOption('', 'Select State');
     $city_2 = new Zend_Form_Element_Select('city_2');
     $city_2->setAttrib('class', 'selectoption');
     $city_2->setAttrib('onchange', 'displayCityCode(this)');
     $city_2->addMultiOption('', 'Select City');
     $contact_type_2 = new Zend_Form_Element_Select('contact_type_2');
     $contact_type_2->setLabel('contact_type_2')->setMultiOptions(array('' => 'select contact type', '1' => 'Primary', '2' => 'Secondary'));
     $secondpocid = new Zend_Form_Element_Hidden('secondpocid');
     $valfirstname_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('firstname_2', null);
     $vallastname_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('lastname_2', null);
     $valmobile_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('mobile_2', null);
     $valemail_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('email_2', null);
     $vallocation_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('location_2', null);
     $valcountry_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('country_2', null);
     $valstate_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('state_2', null);
     $valcity_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('city_2', null);
     $valcontact_type_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('contact_type_2', null);
     if ($valfirstname_2 != '' || $vallastname_2 != '' || $valmobile_2 != '' || $valemail_2 != '' || $vallocation_2 != '' || $valcountry_2 != '' || $valstate_2 != '' || $valcity_2 != '' || $valcontact_type_2 != '') {
         $firstname_2->setRequired(true);
         $firstname_2->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
         $lastname_2->setRequired(true);
         $lastname_2->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
         $mobile_2->setRequired(true);
         $mobile_2->addValidator('NotEmpty', false, array('messages' => 'Please enter 10 digit mobile number.'));
         $email_2->setRequired(true);
         $email_2->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
         $location_2->setRequired(true);
         $location_2->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
         $country_2->setRequired(true);
         $country_2->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
         $country_2->setRegisterInArrayValidator(false);
         $state_2->setRequired(true);
         $state_2->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
         $state_2->setRegisterInArrayValidator(false);
         $city_2->setRequired(true);
         $city_2->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
         $city_2->setRegisterInArrayValidator(false);
         $contact_type_2->setRequired(true);
         $contact_type_2->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
         $contact_type_2->setRegisterInArrayValidator(false);
     }
     $firstname_2->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_2->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_2->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_2->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $firstname_3 = new Zend_Form_Element_Text('firstname_3');
     $firstname_3->setAttrib('maxLength', 50);
     $firstname_3->addFilter(new Zend_Filter_StringTrim());
     $lastname_3 = new Zend_Form_Element_Text('lastname_3');
     $lastname_3->setAttrib('maxLength', 50);
     $lastname_3->addFilter(new Zend_Filter_StringTrim());
     $mobile_3 = new Zend_Form_Element_Text('mobile_3');
     $mobile_3->setAttrib('maxLength', 10);
     $mobile_3->addFilter(new Zend_Filter_StringTrim());
     $email_3 = new Zend_Form_Element_Text('email_3');
     $email_3->setAttrib('maxLength', 50);
     $email_3->addFilter(new Zend_Filter_StringTrim());
     $location_3 = new Zend_Form_Element_Text('location_3');
     $location_3->setAttrib('maxLength', 50);
     $location_3->addFilter(new Zend_Filter_StringTrim());
     $country_3 = new Zend_Form_Element_Select('country_3');
     $country_3->setLabel('country');
     $country_3->setAttrib('onchange', 'displayParticularState_normal(this,"","state_3","city_3")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_3->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_3->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $state_3 = new Zend_Form_Element_Select('state_3');
     $state_3->setAttrib('class', 'selectoption');
     $state_3->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_3","")');
     $state_3->addMultiOption('', 'Select State');
     $city_3 = new Zend_Form_Element_Select('city_3');
     $city_3->setAttrib('class', 'selectoption');
     $city_3->setAttrib('onchange', 'displayCityCode(this)');
     $city_3->addMultiOption('', 'Select City');
     $contact_type_3 = new Zend_Form_Element_Select('contact_type_3');
     $contact_type_3->setLabel('contact_type_3')->setMultiOptions(array('' => 'select contact type', '1' => 'Primary', '2' => 'Secondary'));
     $thirdpocid = new Zend_Form_Element_Hidden('thirdpocid');
     $thirdData = Zend_Controller_Front::getInstance()->getRequest()->getParam('thirdpocid', null);
     $valfirstname_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('firstname_3', null);
     $vallastname_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('lastname_3', null);
     $valmobile_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('mobile_3', null);
     $valemail_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('email_3', null);
     $vallocation_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('location_3', null);
     $valcountry_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('country_3', null);
     $valstate_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('state_3', null);
     $valcity_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('city_3', null);
     $valcontact_type_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('contact_type_3', null);
     if ($valfirstname_3 != '' || $vallastname_3 != '' || $valmobile_3 != '' || $valemail_3 != '' || $vallocation_3 != '' || $valcountry_3 != '' || $valstate_3 != '' || $valcity_3 != '' || $valcontact_type_3 != '') {
         $firstname_3->setRequired(true);
         $firstname_3->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
         $lastname_3->setRequired(true);
         $lastname_3->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
         $mobile_3->setRequired(true);
         $mobile_3->addValidator('NotEmpty', false, array('messages' => 'Please enter  10 digit mobile number.'));
         $email_3->setRequired(true);
         $email_3->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
         $location_3->setRequired(true);
         $location_3->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
         $country_3->setRequired(true);
         $country_3->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
         $country_3->setRegisterInArrayValidator(false);
         $state_3->setRequired(true);
         $state_3->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
         $state_3->setRegisterInArrayValidator(false);
         $city_3->setRequired(true);
         $city_3->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
         $city_3->setRegisterInArrayValidator(false);
         $contact_type_3->setRequired(true);
         $contact_type_3->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
         $contact_type_3->setRegisterInArrayValidator(false);
     }
     $firstname_3->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_3->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_3->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_3->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $pocid_1, $pocid_2, $pocid_3, $agencyname, $address, $primaryphone, $secondaryphone, $checktype, $website, $firstname_1, $lastname_1, $mobile_1, $email_1, $location_1, $country_1, $state_1, $city_1, $contact_type_1, $firstname_2, $lastname_2, $mobile_2, $email_2, $location_2, $country_2, $state_2, $city_2, $contact_type_2, $secondpocid, $firstname_3, $lastname_3, $mobile_3, $email_3, $location_3, $country_3, $state_3, $city_3, $contact_type_3, $thirdpocid, $emprole, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
示例#11
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'systempreference');
     $id = new Zend_Form_Element_Hidden('id');
     $currencyid = new Zend_Form_Element_Hidden('currencyid');
     $organisationid = new Zend_Form_Element_Hidden('organisationid');
     $empcodeid = new Zend_Form_Element_Hidden('empcodeid');
     $dateformatid = new Zend_Form_Element_Select('dateformatid');
     $dateformatid->setAttrib('class', 'selectoption');
     $dateformatid->setRegisterInArrayValidator(false);
     $dateformatid->setRequired(true);
     $dateformatid->addValidator('NotEmpty', false, array('messages' => 'Please select date format.'));
     $timeformatid = new Zend_Form_Element_Select('timeformatid');
     $timeformatid->setAttrib('class', 'selectoption');
     $timeformatid->setRegisterInArrayValidator(false);
     $timeformatid->setRequired(true);
     $timeformatid->addValidator('NotEmpty', false, array('messages' => 'Please select time format.'));
     $timezoneid = new Zend_Form_Element_Select('timezoneid');
     $timezoneid->setAttrib('class', 'selectoption');
     $timezoneid->setRegisterInArrayValidator(false);
     $timezoneid->setRequired(true);
     $timezoneid->addValidator('NotEmpty', false, array('messages' => 'Please select time zone preference.'));
     $timezoneid->addMultiOption('', 'Select Time zone');
     $timezoneModal = new Default_Model_Timezone();
     $timezoneData = $timezoneModal->fetchAll('isactive=1', 'timezone')->toArray();
     foreach ($timezoneData as $data) {
         $timezoneid->addMultiOption($data['id'], $data['timezone'] . ' [' . $data['timezone_abbr'] . ']');
     }
     $currencyname = new Zend_Form_Element_Text('currencyname');
     $currencyname->setAttrib('maxLength', 50);
     $currencyname->addFilter(new Zend_Filter_StringTrim());
     $currencyname->setRequired(true);
     $currencyname->addValidator('NotEmpty', false, array('messages' => 'Please enter currency.'));
     $currencyname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency.')));
     $currencyname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencyname', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('currencyid') . '" and isactive=1')));
     $currencyname->getValidator('Db_NoRecordExists')->setMessage('Currency already exists.');
     $currencycode = new Zend_Form_Element_Text('currencycode');
     $currencycode->setAttrib('maxLength', 20);
     $currencycode->addFilter(new Zend_Filter_StringTrim());
     $currencycode->setRequired(true);
     $currencycode->addValidator('NotEmpty', false, array('messages' => 'Please enter currency code.'));
     $currencycode->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency code.')));
     $currencycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencycode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('currencyid') . '" and isactive=1')));
     $currencycode->getValidator('Db_NoRecordExists')->setMessage('Currency code already exists.');
     $passwordid = new Zend_Form_Element_Select('passwordid');
     $passwordid->setAttrib('class', 'selectoption');
     $passwordid->setAttrib('onchange', 'displayPasswordDesc(this)');
     $passwordid->setRegisterInArrayValidator(false);
     $passwordid->setRequired(true);
     $passwordid->addValidator('NotEmpty', false, array('messages' => 'Please select default password.'));
     $perm_country = new Zend_Form_Element_Select('perm_country');
     $perm_country->setAttrib('onchange', 'displayParticularState(this,"","perm_state","")');
     $perm_country->setRegisterInArrayValidator(false);
     $countriesModel = new Default_Model_Countries();
     $countrieslistArr = $countriesModel->getTotalCountriesList('addcountry');
     if (sizeof($countrieslistArr) > 0) {
         $perm_country->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             $perm_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     }
     $perm_country->setRequired(true);
     $perm_country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $perm_state = new Zend_Form_Element_Select('perm_state');
     $perm_state->setAttrib('onchange', 'displayParticularCity(this,"","perm_city","")');
     $perm_state->setRegisterInArrayValidator(false);
     $perm_state->addMultiOption('', 'Select State');
     $perm_state->setRequired(true);
     $perm_state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $perm_city = new Zend_Form_Element_Select('perm_city');
     $perm_city->setRegisterInArrayValidator(false);
     $perm_city->addMultiOption('', 'Select City');
     $perm_city->setRequired(true);
     $perm_city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $workcodename = new Zend_Form_Element_Multiselect('workcodename');
     $workcodename->setRegisterInArrayValidator(false);
     $workcodename->setRequired(true);
     $workcodename->addValidator('NotEmpty', false, array('messages' => 'Please select employment status.'));
     $empCode = new Zend_Form_Element_Text('employee_code');
     $empCode->addFilter(new Zend_Filter_StringTrim());
     $empCode->setAttrib('maxLength', 5);
     $empCode->setRequired(true);
     $empCode->addValidator('NotEmpty', false, array('messages' => 'Please enter employee code.'));
     $empCode->addValidators(array(array('StringLength', false, array('min' => 1, 'max' => 5, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Employee code must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Employee code must contain at least %min% characters.')))));
     $empCode->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[A-Za-z][a-zA-Z@\\-]*$/', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => 'Please enter valid employee code.')))));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($timezoneid, $id, $currencyid, $organisationid, $empcodeid, $dateformatid, $timeformatid, $currencycode, $currencyname, $passwordid, $perm_country, $perm_state, $perm_city, $workcodename, $empCode, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
示例#12
0
 public function addnewcountryAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     $controllername = 'countries';
     $countriesform = new Default_Form_countries();
     $countriesmodel = new Default_Model_Countries();
     $countriesform->setAction(BASE_URL . 'countries/addnewcountry');
     /* Changing the form */
     $countriesform->removeElement('country');
     $countriesform->removeElement('countrycode');
     $countriesform->addElement('text', 'country', array('label' => 'Country', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter country name.')))));
     $countriesform->country->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tbl_countries', 'field' => 'country_name')));
     $countriesform->country->getValidator('Db_NoRecordExists')->setMessage('Country name already exists.');
     $countriesform->addElement('text', 'countrycode', array('label' => 'Country code', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter country code.')))));
     $countriesform->countrycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tbl_countries', 'field' => 'country_code')));
     $countriesform->countrycode->getValidator('Db_NoRecordExists')->setMessage('Country code already exists.');
     /* END */
     if ($this->getRequest()->getPost()) {
         $id = $this->_request->getParam('id');
         $errorflag = "true";
         $msgarray = array();
         $dbcountry = '';
         $dbcountryid = '';
         $country = $this->_request->getParam('country');
         $countrycode = $this->_request->getParam('countrycode');
         $citizenship = $this->_request->getParam('citizenship');
         $dbcountry = $country;
         if ($countriesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $date = new Zend_Date();
             $actionflag = 1;
             $tableid = '';
             $countryID = $countriesmodel->SaveMainCountryData($country, $countrycode);
             $tableid = $countryID;
             $menuID = COUNTRIES;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $countryData = $countriesmodel->getTotalCountriesList('isactive=1', 'country_name');
             $opt = '';
             foreach ($countryData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['country_name']);
             }
             $this->view->countryData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $countriesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->ermsg = '';
     $this->view->form = $countriesform;
     $this->view->controllername = $controllername;
 }