public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $employeeModel = new Default_Model_Employee();
     $myemployeesModel = new Default_Model_Myemployees();
     $call = $this->_getParam('call');
     if ($call == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $view = Zend_Layout::getMvcInstance()->getView();
     $objname = $this->_getParam('objname');
     $refresh = $this->_getParam('refresh');
     $dashboardcall = $this->_getParam('dashboardcall', null);
     $data = array();
     $id = '';
     $searchQuery = '';
     $searchArray = array();
     $tablecontent = '';
     if ($refresh == 'refresh') {
         if ($dashboardcall == 'Yes') {
             $perPage = DASHBOARD_PERPAGE;
         } else {
             $perPage = PERPAGE;
         }
         $sort = 'DESC';
         $by = 'e.modifieddate';
         $pageNo = 1;
         $searchData = '';
         $searchQuery = '';
         $searchArray = array();
     } else {
         $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
         $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'e.modifieddate';
         if ($dashboardcall == 'Yes') {
             $perPage = $this->_getParam('per_page', DASHBOARD_PERPAGE);
         } else {
             $perPage = $this->_getParam('per_page', PERPAGE);
         }
         $pageNo = $this->_getParam('page', 1);
         $searchData = $this->_getParam('searchData');
         $searchData = rtrim($searchData, ',');
     }
     $dataTmp = $myemployeesModel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $loginUserId, $loginUserId);
     array_push($data, $dataTmp);
     $this->view->dataArray = $data;
     $this->view->call = $call;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
 /**
  * Export analytics of employees reporting to manager to excel.
  */
 public function exportemployeereportAction()
 {
     $this->_helper->layout->disableLayout();
     $param_arr = $this->_getAllParams();
     $cols_param_arr = $this->_getParam('cols_arr', array());
     if (isset($param_arr['cols_arr'])) {
         unset($param_arr['cols_arr']);
     }
     $page_no = isset($param_arr['page_no']) ? $param_arr['page_no'] : 1;
     $per_page = isset($param_arr['per_page']) ? $param_arr['per_page'] : PERPAGE;
     $sort_name = $param_arr['sort_name'];
     $sort_type = $param_arr['sort_type'];
     if (isset($param_arr['page_no'])) {
         unset($param_arr['page_no']);
     }
     if (isset($param_arr['sort_name'])) {
         unset($param_arr['sort_name']);
     }
     if (isset($param_arr['sort_type'])) {
         unset($param_arr['sort_type']);
     }
     if (isset($param_arr['per_page'])) {
         unset($param_arr['per_page']);
     }
     unset($param_arr['module']);
     unset($param_arr['controller']);
     unset($param_arr['action']);
     // Get employees data reporting to manager
     $myEmployees_model = new Default_Model_Myemployees();
     $param_arr['reporting_manager'] = $myEmployees_model->getLoginUserId();
     if (count($cols_param_arr) == 0) {
         $cols_param_arr = $this->empreport_heplper1('mandatory');
     }
     $employee_model = new Default_Model_Employee();
     $emp_data_org = $employee_model->getdata_emp_report($param_arr, $per_page, $page_no, $sort_name, $sort_type);
     $emp_arr = $emp_data_org['rows'];
     require_once 'Classes/PHPExcel.php';
     require_once 'Classes/PHPExcel/IOFactory.php';
     $objPHPExcel = new PHPExcel();
     $letters = range('A', 'Z');
     $count = 0;
     $filename = "EmployeeReport.xlsx";
     $cell_name = "";
     // Show count of employees reporting to manager
     // Get employees data reporting to manager
     $myEmployees_model = new Default_Model_Myemployees();
     $employee_model = new Default_Model_Employee();
     $count_emp_reporting = $employee_model->getCountEmpReporting($myEmployees_model->getLoginUserId());
     $objPHPExcel->getActiveSheet()->SetCellValue($letters[$count] . "1", "My Team Count : " . $count_emp_reporting);
     // Make first row Headings bold and highlighted in Excel.
     foreach ($cols_param_arr as $names) {
         $i = 2;
         $cell_name = $letters[$count] . $i;
         $names = html_entity_decode($names, ENT_QUOTES, 'UTF-8');
         $objPHPExcel->getActiveSheet()->SetCellValue($cell_name, $names);
         // Make bold cells
         $objPHPExcel->getActiveSheet()->getStyle($cell_name)->getFont()->setBold(true);
         $objPHPExcel->getActiveSheet()->getStyle($cell_name)->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '82CAFF'))));
         $objPHPExcel->getActiveSheet()->getColumnDimension($letters[$count])->setAutoSize(true);
         $i++;
         $count++;
     }
     // Display field/column values in Excel.
     $i = 3;
     foreach ($emp_arr as $emp_data) {
         $count1 = 0;
         foreach ($cols_param_arr as $column_key => $column_name) {
             // display field/column values
             $cell_name = $letters[$count1] . $i;
             if ($column_key == 'userfullname') {
                 $value = isset($emp_data['prefix_name']) ? $emp_data['prefix_name'] . ". " . $emp_data['userfullname'] : $emp_data['userfullname'];
             } elseif ($column_key == 'date_of_joining') {
                 $value = isset($emp_data['date_of_joining']) ? sapp_Global::change_date($emp_data['date_of_joining'], "view") : "";
             } else {
                 $value = isset($emp_data[$column_key]) ? $emp_data[$column_key] : "";
             }
             $value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
             $objPHPExcel->getActiveSheet()->SetCellValue($cell_name, $value);
             $count1++;
         }
         $i++;
     }
     sapp_Global::clean_output_buffer();
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     header('Cache-Control: max-age=0');
     sapp_Global::clean_output_buffer();
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
     exit;
 }
 public function editAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
             }
             $this->view->WorkeligibilitydoctypesPermission = sapp_Global::_checkprivileges(WORKELIGIBILITYDOCTYPES, $loginUserGroup, $loginUserRole, 'add');
             $popConfigPermission = array();
             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');
             }
             $this->view->popConfigPermission = $popConfigPermission;
             $userid = $this->getRequest()->getParam('userid');
             $employeeModal = new Default_Model_Employee();
             $workeligibilityform = new Default_Form_Workeligibilitydetails();
             $workeligibilityModel = new Default_Model_Workeligibilitydetails();
             $msgarray = array();
             $emptyFlag = 0;
             $issuingauthority = '';
             //To check previliges for edit
             $myEmployees_model = new Default_Model_Myemployees();
             $getMyTeamIds = $myEmployees_model->getTeamIds($loginUserId);
             $teamIdArr = array();
             if (!empty($getMyTeamIds)) {
                 foreach ($getMyTeamIds as $teamId) {
                     array_push($teamIdArr, $teamId['user_id']);
                 }
             }
             if ($loginUserRole == SUPERADMINROLE || $loginUserGroup == MANAGEMENT_GROUP || $loginUserGroup == HR_GROUP || $loginUserGroup == MANAGER_GROUP && in_array($userid, $teamIdArr)) {
                 try {
                     if ($userid && is_numeric($userid) && $userid > 0 && $userid != $loginUserId) {
                         $usersModel = new Default_Model_Users();
                         $empdata = $employeeModal->getActiveEmployeeData($userid);
                         $employeeData = $usersModel->getUserDetailsByIDandFlag($userid);
                         if ($empdata == 'norows') {
                             $this->view->rowexist = "norows";
                             $this->view->empdata = "";
                         } else {
                             $this->view->rowexist = "rows";
                             if (!empty($empdata)) {
                                 $countriesModel = new Default_Model_Countries();
                                 $statesmodel = new Default_Model_States();
                                 $citiesmodel = new Default_Model_Cities();
                                 $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                                 $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++;
                                 }
                                 $countrieslistArr = $countriesModel->getTotalCountriesList();
                                 if (!empty($countrieslistArr)) {
                                     $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($userid);
                                 //echo "<pre>Work eligibility  Data ";print_r($data);echo "</pre>"; die;
                                 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 (!empty($statelistArr)) {
                                             $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 (!empty($citylistArr)) {
                                             $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 = 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);
                                 }
                                 $workeligibilityform->setAttrib('action', BASE_URL . 'workeligibilitydetails/edit/userid/' . $userid);
                                 $workeligibilityform->setDefault("user_id", $userid);
                                 $this->view->id = $userid;
                             }
                             $this->view->employeedata = $employeeData[0];
                             $this->view->form = $workeligibilityform;
                             $this->view->empdata = $empdata;
                             $this->view->msgarray = $msgarray;
                             $this->view->emptyFlag = $emptyFlag;
                             $this->view->issuingauthority = $issuingauthority;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                     } else {
                         $this->view->rowexist = "norows";
                     }
                 } catch (Exception $e) {
                     $this->view->rowexist = "norows";
                 }
                 if ($this->getRequest()->getPost()) {
                     $result = $this->save($workeligibilityform);
                     $result['issuingauthorityflag'] = $_POST['issuingauthflag'];
                     $this->view->msgarray = $result;
                 }
             } else {
                 $this->_redirect('error');
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function editAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('creditcarddetails', $empOrganizationTabs)) {
             $employeeData = array();
             $empdata = array();
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
             }
             $id = $this->getRequest()->getParam('userid');
             $auth = Zend_Auth::getInstance();
             $creditcardDetailsform = new Default_Form_Creditcarddetails();
             $creditcardDetailsModel = new Default_Model_Creditcarddetails();
             //TO get the Employee  profile information....
             $usersModel = new Default_Model_Users();
             $employeeModal = new Default_Model_Employee();
             //To check previliges for edit
             $myEmployees_model = new Default_Model_Myemployees();
             $getMyTeamIds = $myEmployees_model->getTeamIds($loginUserId);
             $teamIdArr = array();
             if (!empty($getMyTeamIds)) {
                 foreach ($getMyTeamIds as $teamId) {
                     array_push($teamIdArr, $teamId['user_id']);
                 }
             }
             if ($loginUserRole == SUPERADMINROLE || $loginUserGroup == MANAGEMENT_GROUP || $loginUserGroup == HR_GROUP || $loginUserGroup == MANAGER_GROUP && in_array($id, $teamIdArr)) {
                 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)) {
                                 $data = $creditcardDetailsModel->getcreditcarddetailsRecord($id);
                                 if (!empty($data)) {
                                     $creditcardDetailsform->setDefault("id", $data[0]["id"]);
                                     $creditcardDetailsform->setDefault("user_id", $data[0]["user_id"]);
                                     $creditcardDetailsform->setDefault("card_type", $data[0]["card_type"]);
                                     $creditcardDetailsform->setDefault("card_number", $data[0]["card_number"]);
                                     $creditcardDetailsform->setDefault("nameoncard", $data[0]["nameoncard"]);
                                     $expiry_date = sapp_Global::change_date($data[0]["card_expiration"], 'view');
                                     $creditcardDetailsform->setDefault('card_expiration', $expiry_date);
                                     $creditcardDetailsform->setDefault("card_issuedby", $data[0]["card_issued_comp"]);
                                     $creditcardDetailsform->setDefault("card_code", $data[0]["card_code"]);
                                 }
                                 $creditcardDetailsform->setAttrib('action', BASE_URL . 'creditcarddetails/edit/userid/' . $id);
                                 $this->view->id = $id;
                                 $this->view->form = $creditcardDetailsform;
                                 $this->view->employeedata = $employeeData[0];
                                 $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->save($creditcardDetailsform);
                     $this->view->msgarray = $result;
                 }
             } else {
                 $this->_redirect('error');
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function editAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $popConfigPermission = array();
         $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;
             }
             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');
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             //To check previliges for edit
             $myEmployees_model = new Default_Model_Myemployees();
             $getMyTeamIds = $myEmployees_model->getTeamIds($loginUserId);
             $teamIdArr = array();
             if (!empty($getMyTeamIds)) {
                 foreach ($getMyTeamIds as $teamId) {
                     array_push($teamIdArr, $teamId['user_id']);
                 }
             }
             if ($loginuserRole == SUPERADMINROLE || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == HR_GROUP || $loginuserGroup == MANAGER_GROUP && in_array($id, $teamIdArr)) {
                 try {
                     if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                         $employeeModal = new Default_Model_Employee();
                         $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)) {
                                 $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', BASE_URL . 'empcommunicationdetails/edit/userid/' . $id);
                                 $empcommdetailsform->user_id->setValue($id);
                                 $this->view->employeedata = $employeeData[0];
                                 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->popConfigPermission = $popConfigPermission;
                                 $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->save($empcommdetailsform, $id);
                     $this->view->msgarray = $result;
                 }
             } else {
                 $this->_redirect('error');
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }