Exemplo n.º 1
0
 /**
  * 
  */
 public function communicationdetailsviewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('empcommunicationdetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             $empdata = array();
             $empDeptdata = array();
             $empDept = '';
             $editPrivilege = "";
             $departmentAddress = array();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'mydetails';
             $empcommdetailsform = new Default_Form_empcommunicationdetails();
             $empcommdetailsform->removeElement("submit");
             $elements = $empcommdetailsform->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) {
                     $employeeModal = new Default_Model_Employee();
                     $employeeDetails = $employeeModal->getsingleEmployeeCommunicationsDetailsData($id);
                     $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'];
                             $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();
                             $deptModel = new Default_Model_Departments();
                             if ($empDept != '' && $empDept != 'NULL') {
                                 $departmentAddress = $usersModel->getDepartmentAddress($empDept);
                             } else {
                                 $departmentAddress = $usersModel->getOrganizationAddress();
                             }
                             $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id);
                             if (!empty($data)) {
                                 if ($data[0]['perm_country'] != '') {
                                     $countrieslistArr = $countriesModel->getCountryCode($data[0]['perm_country']);
                                     if (sizeof($countrieslistArr) > 0) {
                                         $empcommdetailsform->perm_country->addMultiOption('', 'Select Country');
                                         foreach ($countrieslistArr as $countrieslistres) {
                                             $empcommdetailsform->perm_country->addMultiOption($countrieslistres['id'], $countrieslistres['country_name']);
                                         }
                                     }
                                 }
                                 if ($data[0]['perm_country'] != '') {
                                     $statePermlistArr = $statesmodel->getStatesList($data[0]['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'], $statelistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($data[0]['perm_state'] != '') {
                                     $cityPermlistArr = $citiesmodel->getCitiesList($data[0]['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'], $cityPermlistres['city_name']);
                                         }
                                     }
                                 }
                                 if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '') {
                                     $countriesArr = $countriesModel->getCountryCode($data[0]['current_country']);
                                     if (sizeof($countriesArr) > 0) {
                                         $empcommdetailsform->current_country->addMultiOption('', 'Select Country');
                                         foreach ($countriesArr as $countrieslistres) {
                                             $empcommdetailsform->current_country->addMultiOption($countrieslistres['id'], $countrieslistres['country_name']);
                                         }
                                     }
                                     $statecurrlistArr = $statesmodel->getStatesList($data[0]['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'], $statecurrlistres['state_name']);
                                         }
                                     }
                                     $currstateNameArr = $statesmodel->getStateName($data[0]['current_state']);
                                 }
                                 if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '' && $data[0]['current_city'] != '') {
                                     $cityCurrlistArr = $citiesmodel->getCitiesList($data[0]['current_state']);
                                     if (sizeof($cityCurrlistArr) > 0) {
                                         $empcommdetailsform->current_city->addMultiOption('', 'Select State');
                                         foreach ($cityCurrlistArr as $cityCurrlistres) {
                                             $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'] . '!@#' . $cityCurrlistres['city_name'], $cityCurrlistres['city_name']);
                                         }
                                     }
                                     $currcityNameArr = $citiesmodel->getCityName($data[0]['current_city']);
                                 }
                                 $empcommdetailsform->populate($data[0]);
                                 if ($data[0]['perm_country'] != '') {
                                     $empcommdetailsform->setDefault('perm_country', $data[0]['perm_country']);
                                 }
                                 if ($data[0]['perm_state'] != '') {
                                     $permstateNameArr = $statesmodel->getStateName($data[0]['perm_state']);
                                     $empcommdetailsform->setDefault('perm_state', $permstateNameArr[0]['id'] . '!@#' . $permstateNameArr[0]['statename']);
                                 }
                                 if ($data[0]['perm_city'] != '') {
                                     $permcityNameArr = $citiesmodel->getCityName($data[0]['perm_city']);
                                     $empcommdetailsform->setDefault('perm_city', $permcityNameArr[0]['id'] . '!@#' . $permcityNameArr[0]['cityname']);
                                 }
                                 if ($data[0]['current_country'] != '') {
                                     $empcommdetailsform->setDefault('current_country', $data[0]['current_country']);
                                 }
                                 if ($data[0]['current_state'] != '') {
                                     $empcommdetailsform->setDefault('current_state', $currstateNameArr[0]['id'] . '!@#' . $currstateNameArr[0]['statename']);
                                 }
                                 if ($data[0]['current_city'] != '') {
                                     $empcommdetailsform->setDefault('current_city', $currcityNameArr[0]['id'] . '!@#' . $currcityNameArr[0]['cityname']);
                                 }
                             }
                             $this->view->controllername = $objName;
                             $this->view->actionname = 'communication';
                             //Edit action name
                             $this->view->data = $data;
                             $this->view->dataArray = !empty($departmentAddress) ? $departmentAddress : array();
                             $this->view->id = $id;
                             $this->view->employeedata = $empdata[0];
                             $this->view->employeeDetails = $employeeDetails;
                             $this->view->form = $empcommdetailsform;
                         }
                         $this->view->empdata = $empdata;
                         $this->view->editPrivilege = $this->mydetailsobjPrivileges;
                     }
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }