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');
     }
 }
 public function communicationAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('empcommunicationdetails', $empOrganizationTabs)) {
             $empdata = array();
             $departmentAddress = array();
             $tabName = "communication";
             $emptyFlag = 0;
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $id = $loginUserId;
                 $employeeModal = new Default_Model_Employee();
                 $empdata = $employeeModal->getsingleEmployeeData($id);
                 if ($empdata == 'norows') {
                     $this->view->rowexist = "norows";
                     $this->view->empdata = "";
                 } else {
                     if (!empty($empdata)) {
                         $this->view->rowexist = "rows";
                         $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();
                         $countrieslistArr = $countriesModel->getTotalCountriesList();
                         $msgarray = array();
                         //Department address
                         $deptId = $empdata[0]['department_id'];
                         if ($deptId != '' && $deptId != '') {
                             $departmentAddress = $usersModel->getDepartmentAddress($deptId);
                         } else {
                             $departmentAddress = $usersModel->getOrganizationAddress();
                         }
                         if (!empty($countrieslistArr)) {
                             $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';
                             $emptyFlag++;
                         }
                         //login Employee communication details.....
                         $data = $empcommdetailsModal->getsingleEmpCommDetailsData($loginUserId);
                         if (!empty($data)) {
                             $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']);
                                 }
                             }
                             $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'] != '') {
                                 $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']);
                             }
                             $permstateNameArr = $statesmodel->getStateName($data[0]['perm_state']);
                             $permcityNameArr = $citiesmodel->getCityName($data[0]['perm_city']);
                             $empcommdetailsform->populate($data[0]);
                             $empcommdetailsform->setDefault('perm_country', $data[0]['perm_country']);
                             $empcommdetailsform->setDefault('perm_state', $permstateNameArr[0]['id'] . '!@#' . $permstateNameArr[0]['statename']);
                             $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']);
                             }
                             $empcommdetailsform->setAttrib('action', DOMAIN . 'mydetails/communication');
                             $empcommdetailsform->user_id->setValue($loginUserId);
                             $this->view->data = $data;
                             $this->view->emptyFlag = $emptyFlag;
                             $this->view->msgarray = $msgarray;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->dataArray = $departmentAddress;
                         if ($this->getRequest()->getPost()) {
                             $result = $this->save($empcommdetailsform, $tabName);
                             $this->view->msgarray = $result;
                         }
                         $this->view->id = $loginUserId;
                         $this->view->empdata = $empdata;
                         $this->view->form = $empcommdetailsform;
                     }
                 }
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }