public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_performanceappraisal', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $userid = $this->getRequest()->getParam('userid');
             $employeeModal = new Default_Model_Employee();
             $isrowexist = $employeeModal->getsingleEmployeeData($userid);
             if ($isrowexist == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 $this->view->rowexist = "rows";
             }
             $empdata = $employeeModal->getActiveEmployeeData($userid);
             if (!empty($empdata)) {
                 $empperformanceApprModel = new Default_Model_Empperformanceappraisal();
                 if ($userid) {
                     //To display Employee Profile information......
                     $usersModel = new Default_Model_Users();
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($userid);
                 }
                 $this->view->id = $userid;
                 $this->view->employeedata = $employeeData[0];
                 if ($this->getRequest()->getPost()) {
                 }
             }
             $this->view->empdata = $empdata;
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_leaves', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $conText = "";
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
                 $conText = $this->_getParam('context') != '' ? $this->_getParam('context') : $this->getRequest()->getParam('context');
             }
             $usersModel = new Default_Model_Users();
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             if ($Uid != "") {
                 $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid);
             }
             $employeeleavesModel = new Default_Model_Employeeleaves();
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $isrowexist = $employeeModal->getsingleEmployeeData($id);
                     if ($isrowexist == 'norows') {
                         $this->view->rowexist = "norows";
                     } else {
                         $this->view->rowexist = "rows";
                     }
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     if (!empty($empdata)) {
                         $usersModel = new Default_Model_Users();
                         if ($id) {
                             $empleavesform = new Default_Form_empleaves();
                             $employeeleavesModal = new Default_Model_Employeeleaves();
                             $data = $employeeleavesModal->getsingleEmployeeleaveData($id);
                             $used_leaves = 0;
                             $date = date('Y');
                             if (!empty($data)) {
                                 $empleavesform->populate($data[0]);
                                 $used_leaves = $data[0]['used_leaves'];
                             }
                             $empleavesform->alloted_year->setValue($date);
                             $empleavesform->setAttrib('action', BASE_URL . 'empleaves/edit/userid/' . $id);
                             $this->view->form = $empleavesform;
                             $this->view->data = $data;
                             $this->view->id = $id;
                         }
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $dashboardcall = $this->_getParam('dashboardcall', null);
                         $data = array();
                         $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 = $employeeleavesModel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $Uid, $conText);
                         array_push($data, $dataTmp);
                         $this->view->dataArray = $data;
                         $this->view->call = $call;
                         $this->view->id = $id;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         if (!empty($employeeData)) {
                             $this->view->employeedata = $employeeData[0];
                         }
                     }
                     $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 viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_salary', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             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 = 'empsalarydetails';
             $empsalarydetailsform = new Default_Form_empsalarydetails();
             $empsalarydetailsform->removeElement("submit");
             $elements = $empsalarydetailsform->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) {
                     $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)) {
                             $empsalarydetailsModal = new Default_Model_Empsalarydetails();
                             $usersModel = new Default_Model_Users();
                             $currencymodel = new Default_Model_Currency();
                             $accountclasstypemodel = new Default_Model_Accountclasstype();
                             $bankaccounttypemodel = new Default_Model_Bankaccounttype();
                             $data = $empsalarydetailsModal->getsingleEmpSalaryDetailsData($id);
                             if (!empty($data)) {
                                 if (isset($data[0]['currencyid']) && $data[0]['currencyid'] != '') {
                                     $currencyArr = $currencymodel->getCurrencyDataByID($data[0]['currencyid']);
                                     if (sizeof($currencyArr) > 0) {
                                         $empsalarydetailsform->currencyid->addMultiOption($currencyArr[0]['id'], $currencyArr[0]['currencyname'] . ' ' . $currencyArr[0]['currencycode']);
                                     }
                                 }
                                 if (isset($data[0]['accountclasstypeid']) && $data[0]['accountclasstypeid'] != '') {
                                     $accountclasstypeArr = $accountclasstypemodel->getsingleAccountClassTypeData($data[0]['accountclasstypeid']);
                                     if (sizeof($accountclasstypeArr) > 0) {
                                         $empsalarydetailsform->accountclasstypeid->addMultiOption($accountclasstypeArr[0]['id'], $accountclasstypeArr[0]['accountclasstype']);
                                     }
                                 }
                                 if (isset($data[0]['bankaccountid']) && $data[0]['bankaccountid'] != '') {
                                     $bankaccounttypeArr = $bankaccounttypemodel->getsingleBankAccountData($data[0]['bankaccountid']);
                                     if ($bankaccounttypeArr != 'norows') {
                                         $empsalarydetailsform->bankaccountid->addMultiOption($bankaccounttypeArr[0]['id'], $bankaccounttypeArr[0]['bankaccounttype']);
                                     }
                                 }
                                 $empsalarydetailsform->populate($data[0]);
                                 if ($data[0]['accountholding'] != '') {
                                     $accountholding = sapp_Global::change_date($data[0]["accountholding"], 'view');
                                     $empsalarydetailsform->accountholding->setValue($accountholding);
                                 }
                             }
                             $this->view->controllername = $objName;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->form = $empsalarydetailsform;
                             $this->view->employeedata = $empdata[0];
                         }
                         $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 viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('creditcarddetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'creditcarddetails';
             $creditcardDetailsform = new Default_Form_Creditcarddetails();
             $creditcardDetailsModel = new Default_Model_Creditcarddetails();
             $creditcardDetailsform->removeElement("submit");
             $elements = $creditcardDetailsform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             $data = $creditcardDetailsModel->getcreditcarddetailsRecord($id);
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             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"]);
                             }
                             $this->view->controllername = $objName;
                             $this->view->id = $id;
                             if (!empty($empdata)) {
                                 $this->view->employeedata = $empdata[0];
                             } else {
                                 $this->view->employeedata = $empdata;
                             }
                             $this->view->form = $creditcardDetailsform;
                             $this->view->data = $data;
                         }
                         $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 changeOrgHead($oldhead, $newhead, $oldheadRM = '')
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $db = Zend_Db_Table::getDefaultAdapter();
     $empmodel = new Default_Model_Employee();
     $oldRMData = $empmodel->getsingleEmployeeData($oldhead);
     try {
         $empQuery1 = "UPDATE main_employees SET reporting_manager = " . $newhead . ", modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE reporting_manager=" . $oldhead . " and isactive = 1 AND user_id <> " . $newhead . ";";
         if ($oldheadRM != '') {
             $orgQuery1 = "UPDATE main_employees SET is_orghead = 0, reporting_manager= " . $oldheadRM . ", modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE user_id=" . $oldhead . " ;";
             $db->query($orgQuery1);
         }
         $orgQuery2 = "UPDATE main_employees SET is_orghead = 1,reporting_manager= 0, modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE user_id=" . $newhead . " ;";
         $db->query($orgQuery2);
         $db->query($empQuery1);
         return 'success';
     } catch (Exception $e) {
         return 'failed';
     }
 }
 public function jobhistoryAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_jobhistory', $empOrganizationTabs)) {
             $userID = "";
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
             }
             $id = $loginUserId;
             $conText = 'mydetails';
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
                 $conText = $this->_getParam('context') != '' ? $this->_getParam('context') : $this->getRequest()->getParam('context');
             }
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             $employeeModal = new Default_Model_Employee();
             try {
                 $empdata = $employeeModal->getsingleEmployeeData($Uid);
                 if ($empdata == 'norows') {
                     $this->view->rowexist = "norows";
                     $this->view->empdata = "";
                 } else {
                     $this->view->rowexist = "rows";
                     if (!empty($empdata)) {
                         $empjobhistoryModel = new Default_Model_Empjobhistory();
                         $view = Zend_Layout::getMvcInstance()->getView();
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $dashboardcall = $this->_getParam('dashboardcall', null);
                         $data = array();
                         $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 = $empjobhistoryModel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $Uid, $conText);
                         array_push($data, $dataTmp);
                         $this->view->dataArray = $data;
                         $this->view->call = $call;
                         $this->view->employeedata = $empdata[0];
                         $this->view->id = $id;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     }
                     $this->view->empdata = $empdata;
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('dependency_details', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
             }
             $userid = $this->getRequest()->getParam('userid');
             $employeeData = array();
             $empdata = array();
             $userID = '';
             $conText = "";
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
                 $conText = $this->_getParam('context') != '' ? $this->_getParam('context') : $this->getRequest()->getParam('context');
             }
             if ($userid == '') {
                 $userid = $userID;
             }
             $dependencydetailsModel = new Default_Model_Dependencydetails();
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($userid && is_numeric($userid) && $userid > 0 && $userid != $loginUserId) {
                     $isrowexist = $employeeModal->getsingleEmployeeData($userid);
                     if ($isrowexist == 'norows') {
                         $this->view->rowexist = "norows";
                     } else {
                         $this->view->rowexist = "rows";
                     }
                     $empdata = $employeeModal->getActiveEmployeeData($userid);
                     if (!empty($empdata)) {
                         $view = Zend_Layout::getMvcInstance()->getView();
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $data = array();
                         $searchQuery = '';
                         $searchArray = array();
                         $tablecontent = '';
                         if ($refresh == 'refresh') {
                             $sort = 'DESC';
                             $by = 'modifieddate';
                             $perPage = 10;
                             $pageNo = 1;
                             $searchData = '';
                         } else {
                             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'modifieddate';
                             $perPage = $this->_getParam('per_page', 10);
                             $pageNo = $this->_getParam('page', 1);
                             $searchData = $this->_getParam('searchData');
                             $searchData = rtrim($searchData, ',');
                             /** search from grid - START **/
                             $searchData = $this->_getParam('searchData');
                             if ($searchData != '' && $searchData != 'undefined') {
                                 $searchValues = json_decode($searchData);
                                 foreach ($searchValues as $key => $val) {
                                     $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                                     $searchArray[$key] = $val;
                                 }
                                 $searchQuery = rtrim($searchQuery, " AND");
                             }
                             /** search from grid - END **/
                         }
                         $objName = 'dependencydetails';
                         $Uid = $userid ? $userid : $userID;
                         $tableFields = array('action' => 'Action', 'dependent_name' => 'Dependent Name', 'dependent_relation' => 'Dependent Relation', 'dependent_dob' => 'Dependent DOB');
                         $tablecontent = $dependencydetailsModel->getdependencydetailsData($sort, $by, $pageNo, $perPage, $searchQuery, $Uid);
                         if ($Uid != "") {
                             $usersModel = new Default_Model_Users();
                             $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid);
                         }
                         $dataTmp = array('userid' => $Uid, 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getEmployeeAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'add' => 'add', 'menuName' => 'Dependency', 'formgrid' => 'true', 'unitId' => $Uid, 'call' => $call, 'context' => $conText);
                         array_push($data, $dataTmp);
                         $this->view->id = $userid;
                         $this->view->controllername = $objName;
                         $this->view->dataArray = $data;
                         $this->view->call = $call;
                         $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";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 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) {
                     $empdata = $employeeModal->getsingleEmployeeData($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();
                                 $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                                 $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;
                                 if (!empty($employeeData)) {
                                     $this->view->employeedata = $employeeData[0];
                                 } else {
                                     $this->view->employeedata = $employeeData;
                                 }
                                 $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 viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('disabilitydetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             $emptyFlag = 0;
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
             }
             $id = $this->getRequest()->getParam('userid');
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $isrowexist = $employeeModal->getsingleEmployeeData($id);
                     if ($isrowexist == 'norows') {
                         $this->view->rowexist = "norows";
                     } else {
                         $this->view->rowexist = "rows";
                     }
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     if (!empty($empdata)) {
                         $callval = $this->getRequest()->getParam('call');
                         if ($callval == 'ajaxcall') {
                             $this->_helper->layout->disableLayout();
                         }
                         $objName = 'disabilitydetails';
                         $employeeData = array();
                         $empDisabilitydetailsform = new Default_Form_Disabilitydetails();
                         $empDisabilitydetailsModel = new Default_Model_Disabilitydetails();
                         $empDisabilitydetailsform->removeElement("submit");
                         $elements = $empDisabilitydetailsform->getElements();
                         if (count($elements) > 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                     $element->setAttrib("disabled", "disabled");
                                 }
                             }
                         }
                         $data = $empDisabilitydetailsModel->getempDisabilitydetails($id);
                         $usersModel = new Default_Model_Users();
                         $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                         if (!empty($data)) {
                             $empDisabilitydetailsform->setDefault('user_id', $data[0]['user_id']);
                             $empDisabilitydetailsform->setDefault('disability_name', $data[0]['disability_name']);
                             $empDisabilitydetailsform->setDefault('disability_type', $data[0]['disability_type']);
                             $empDisabilitydetailsform->setDefault('other_disability_type', $data[0]['other_disability_type']);
                             $empDisabilitydetailsform->setDefault('disability_description', $data[0]['disability_description']);
                         }
                         $this->view->controllername = $objName;
                         $this->view->id = $id;
                         $this->view->data = $data;
                         $this->view->employeedata = $employeeData[0];
                         $this->view->form = $empDisabilitydetailsform;
                     }
                     $this->view->empdata = $empdata;
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     }
 }
 public function editAction()
 {
     $genderaddpermission = '';
     $msaddpermission = '';
     $ethnicaddpermission = '';
     $racecodepermission = '';
     $languagepermission = '';
     $nationalityaddpermission = '';
     $identityDocumentArr = array();
     $documentsArr = array();
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emppersonaldetails', $empOrganizationTabs)) {
             $loginUserId = '';
             $loginUserGroup = '';
             $loginUserRole = '';
             $auth = Zend_Auth::getInstance();
             $emptyFlag = 0;
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
             }
             $genderaddpermission = sapp_Global::_checkprivileges(GENDER, $loginUserGroup, $loginUserRole, 'add');
             $msaddpermission = sapp_Global::_checkprivileges(MARITALSTATUS, $loginUserGroup, $loginUserRole, 'add');
             $ethnicaddpermission = sapp_Global::_checkprivileges(ETHNICCODE, $loginUserGroup, $loginUserRole, 'add');
             $racecodepermission = sapp_Global::_checkprivileges(RACECODE, $loginUserGroup, $loginUserRole, 'add');
             $languagepermission = sapp_Global::_checkprivileges(LANGUAGE, $loginUserGroup, $loginUserRole, 'add');
             $nationalityaddpermission = sapp_Global::_checkprivileges(NATIONALITY, $loginUserGroup, $loginUserRole, 'add');
             $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)) {
                             $empperdetailsModal = new Default_Model_Emppersonaldetails();
                             $usersModel = new Default_Model_Users();
                             $empprobationreviewform = new Default_Form_empprobationreview();
                             $emppersonaldetailsform = new Default_Form_emppersonaldetails();
                             if ($loginUserGroup == MANAGEMENT_GROUP || $loginUserGroup == HR_GROUP || $loginUserRole == SUPERADMINROLE) {
                                 $identitydocumentsModel = new Default_Model_Identitydocuments();
                                 $identityDocumentArr = $identitydocumentsModel->getIdentitydocumnetsrecord();
                             }
                             $genderModel = new Default_Model_Gender();
                             $maritalstatusmodel = new Default_Model_Maritalstatus();
                             $nationalitymodel = new Default_Model_Nationality();
                             $ethniccodemodel = new Default_Model_Ethniccode();
                             $racecodemodel = new Default_Model_Racecode();
                             $languagemodel = new Default_Model_Language();
                             $msgarray = array();
                             $genderlistArr = $genderModel->getGenderList();
                             if (!empty($genderlistArr)) {
                                 foreach ($genderlistArr as $genderlistres) {
                                     $emppersonaldetailsform->genderid->addMultiOption($genderlistres['id'], $genderlistres['gendername']);
                                 }
                             } else {
                                 $msgarray['genderid'] = 'Gender is not configured yet.';
                                 $emptyFlag++;
                             }
                             $maritalstatuslistArr = $maritalstatusmodel->getMaritalStatusList();
                             if (!empty($maritalstatuslistArr)) {
                                 foreach ($maritalstatuslistArr as $maritalstatuslistres) {
                                     $emppersonaldetailsform->maritalstatusid->addMultiOption($maritalstatuslistres['id'], $maritalstatuslistres['maritalstatusname']);
                                 }
                             } else {
                                 $msgarray['maritalstatusid'] = 'Marital status is not configured yet.';
                                 $emptyFlag++;
                             }
                             $nationalitylistArr = $nationalitymodel->getNationalityList();
                             if (!empty($nationalitylistArr)) {
                                 foreach ($nationalitylistArr as $nationalitylistres) {
                                     $emppersonaldetailsform->nationalityid->addMultiOption($nationalitylistres['id'], $nationalitylistres['nationalitycode']);
                                 }
                             } else {
                                 $msgarray['nationalityid'] = 'Nationality is not configured yet.';
                                 $emptyFlag++;
                             }
                             $ethniccodeArr = $ethniccodemodel->gettotalEthnicCodeData();
                             if (!empty($ethniccodeArr)) {
                                 foreach ($ethniccodeArr as $ethniccoderes) {
                                     $emppersonaldetailsform->ethniccodeid->addMultiOption($ethniccoderes['id'], $ethniccoderes['ethnicname']);
                                 }
                             } else {
                                 $msgarray['ethniccodeid'] = 'Ethnic codes are not configured yet.';
                                 $emptyFlag++;
                             }
                             $racecodeArr = $racecodemodel->gettotalRaceCodeData();
                             if (!empty($racecodeArr)) {
                                 foreach ($racecodeArr as $racecoderes) {
                                     $emppersonaldetailsform->racecodeid->addMultiOption($racecoderes['id'], $racecoderes['racename']);
                                 }
                             } else {
                                 $msgarray['racecodeid'] = 'Race codes are not configured yet.';
                                 $emptyFlag++;
                             }
                             $languageArr = $languagemodel->gettotalLanguageData();
                             if (!empty($languageArr)) {
                                 foreach ($languageArr as $languageres) {
                                     $emppersonaldetailsform->languageid->addMultiOption($languageres['id'], $languageres['languagename']);
                                 }
                             } else {
                                 $msgarray['languageid'] = 'Languages are not configured yet.';
                                 $emptyFlag++;
                             }
                             if (!empty($identityDocumentArr)) {
                                 $this->view->identitydocument = $identityDocumentArr;
                             }
                             $data = $empperdetailsModal->getsingleEmpPerDetailsData($id);
                             if (!empty($data)) {
                                 $emppersonaldetailsform->populate($data[0]);
                                 $dob = sapp_Global::change_date($data[0]["dob"], 'view');
                                 $emppersonaldetailsform->dob->setValue($dob);
                                 if ($data[0]['celebrated_dob'] != '') {
                                     $celebrated_dob = sapp_Global::change_date($data[0]["celebrated_dob"], 'view');
                                     $emppersonaldetailsform->celebrated_dob->setValue($celebrated_dob);
                                 }
                                 if ($data[0]['identity_documents'] != '') {
                                     $documentsArr = get_object_vars(json_decode($data[0]['identity_documents']));
                                 }
                                 $emppersonaldetailsform->setDefault('genderid', $data[0]['genderid']);
                                 $emppersonaldetailsform->setDefault('maritalstatusid', $data[0]['maritalstatusid']);
                                 $emppersonaldetailsform->setDefault('nationalityid', $data[0]['nationalityid']);
                                 $emppersonaldetailsform->setDefault('ethniccodeid', $data[0]['ethniccodeid']);
                                 $emppersonaldetailsform->setDefault('racecodeid', $data[0]['racecodeid']);
                                 $emppersonaldetailsform->setDefault('languageid', $data[0]['languageid']);
                             }
                             $emppersonaldetailsform->user_id->setValue($id);
                             $emppersonaldetailsform->setAttrib('action', DOMAIN . 'emppersonaldetails/edit/userid/' . $id);
                             $this->view->form = $empprobationreviewform;
                             $this->view->data = $data;
                             $this->view->documentsArr = $documentsArr;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->employeedata = $empdata[0];
                             $this->view->emptyFlag = $emptyFlag;
                             $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($empprobationreviewform, $id, $identityDocumentArr);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
     $empprobationreviewModal = new Default_Model_Empprobationreview();
     $this->view->probationreviewhistory = $this->ConvertArrayToGrid("Probation Review History", $empprobationreviewModal->getProbationReviewHistory($id));
     $this->view->genderaddpermission = $genderaddpermission;
     $this->view->msaddpermission = $msaddpermission;
     $this->view->ethnicaddpermission = $ethnicaddpermission;
     $this->view->racecodepermission = $racecodepermission;
     $this->view->languagepermission = $languagepermission;
     $this->view->nationalityaddpermission = $nationalityaddpermission;
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_holidays', $empOrganizationTabs)) {
             $conText = "";
             $userID = '';
             $msgarray = array();
             $empGroupId = '';
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
                 $conText = $this->_getParam('context') != '' ? $this->_getParam('context') : $this->getRequest()->getParam('context');
             }
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             if ($Uid != "") {
                 //TO dispaly EMployee Profile information.....
                 $usersModel = new Default_Model_Users();
                 $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid);
             }
             $employeesModel = new Default_Model_Employees();
             $holidaydatesmodel = new Default_Model_Holidaydates();
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $isrowexist = $employeeModal->getsingleEmployeeData($id);
                     if ($isrowexist == 'norows') {
                         $this->view->rowexist = "norows";
                     } else {
                         $this->view->rowexist = "rows";
                     }
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     if (!empty($empdata)) {
                         if ($id) {
                             $empholidaysform = new Default_Form_empholidays();
                             $holidaygroupModel = new Default_Model_Holidaygroups();
                             $holidaygroupArr = $holidaygroupModel->getAllGroupData();
                             if (sizeof($holidaygroupArr) > 0) {
                                 $empGroupId = $holidaygroupArr[0]['id'];
                                 foreach ($holidaygroupArr as $holidaygroupres) {
                                     $empholidaysform->holiday_group->addMultiOption($holidaygroupres['id'], $holidaygroupres['groupname']);
                                 }
                             } else {
                                 $msgarray['empholidaysform'] = 'Holiday groups not configured yet';
                             }
                             $data = $employeesModel->getHolidayGroupForEmployee($id);
                             if ($data[0]['holiday_group'] != '') {
                                 $singleholidaygroupArr = $holidaygroupModel->getsingleGroupData($data[0]['holiday_group']);
                                 $empholidaysform->populate($data[0]);
                                 $empholidaysform->setDefault('holiday_group', $data[0]['holiday_group']);
                                 $empGroupId = $data[0]['holiday_group'];
                                 $this->view->data = $data;
                             }
                             $empholidaysform->setAttrib('action', BASE_URL . 'empholidays/edit/userid/' . $id);
                             $this->view->form = $empholidaysform;
                         }
                         if ($this->getRequest()->getPost()) {
                             $result = $this->save($empholidaysform, $id);
                             $this->view->msgarray = $result;
                         }
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $dashboardcall = $this->_getParam('dashboardcall', null);
                         $data = array();
                         $searchQuery = '';
                         $searchArray = array();
                         $tablecontent = '';
                         if ($refresh == 'refresh') {
                             if ($dashboardcall == 'Yes') {
                                 $perPage = DASHBOARD_PERPAGE;
                             } else {
                                 $perPage = PERPAGE;
                             }
                             $sort = 'DESC';
                             $by = 'h.modifieddate';
                             $pageNo = 1;
                             $searchData = '';
                             $searchQuery = '';
                             $searchArray = array();
                         } else {
                             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'h.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, ',');
                         }
                         $objName = 'empholidays';
                         $dataTmp = $holidaydatesmodel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $objName, $empGroupId, $Uid, $conText);
                         array_push($data, $dataTmp);
                         $this->view->dataArray = $data;
                         $this->view->call = $call;
                         $this->view->id = $id;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         if (!empty($employeeData)) {
                             $this->view->employeedata = $employeeData[0];
                         }
                     }
                     $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 viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('visadetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $objName = 'visaandimmigrationdetails';
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $employeeModal = new Default_Model_Employee();
             $visaandimmigrationDetailsform = new Default_Form_Visaandimmigrationdetails();
             $visaandimmigrationdetailsModel = new Default_Model_Visaandimmigrationdetails();
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $visaandimmigrationDetailsform->removeElement("submit");
                             $elements = $visaandimmigrationDetailsform->getElements();
                             if (count($elements) > 0) {
                                 foreach ($elements as $key => $element) {
                                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                         $element->setAttrib("disabled", "disabled");
                                     }
                                 }
                             }
                             $data = $visaandimmigrationdetailsModel->getvisadetailsRecord($id);
                             if (!empty($data)) {
                                 $visaandimmigrationDetailsform->setDefault("id", $data[0]["id"]);
                                 $visaandimmigrationDetailsform->setDefault("user_id", $data[0]["user_id"]);
                                 $visaandimmigrationDetailsform->setDefault("passport_number", $data[0]["passport_number"]);
                                 $pp_issue_date = sapp_Global::change_date($data[0]["passport_issue_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault('passport_issue_date', $pp_issue_date);
                                 $pp_expiry_date = sapp_Global::change_date($data[0]["passport_expiry_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault("passport_expiry_date", $pp_expiry_date);
                                 $visaandimmigrationDetailsform->setDefault("visa_number", $data[0]["visa_number"]);
                                 $visaandimmigrationDetailsform->setDefault("visa_type", $data[0]["visa_type"]);
                                 $v_issue_date = sapp_Global::change_date($data[0]["visa_issue_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault('visa_issue_date', $v_issue_date);
                                 $v_expiry_date = sapp_Global::change_date($data[0]["visa_expiry_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault("visa_expiry_date", $v_expiry_date);
                                 $visaandimmigrationDetailsform->setDefault("inine_status", $data[0]["inine_status"]);
                                 $inine_review = sapp_Global::change_date($data[0]["inine_review_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault("inine_review_date", $inine_review);
                                 $visaandimmigrationDetailsform->setDefault("issuing_authority", $data[0]["issuing_authority"]);
                                 $visaandimmigrationDetailsform->setDefault("ininetyfour_status", $data[0]["ininetyfour_status"]);
                                 $ininetyfour_expiry = sapp_Global::change_date($data[0]["ininetyfour_expiry_date"], 'view');
                                 $visaandimmigrationDetailsform->setDefault("ininetyfour_expiry_date", $ininetyfour_expiry);
                             }
                             $this->view->controllername = $objName;
                             $this->view->id = $id;
                             $this->view->data = $data;
                             $this->view->employeedata = $empdata[0];
                             $this->view->form = $visaandimmigrationDetailsform;
                         }
                         $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 sendmailstoemployees($oldRM, $newRM)
    {
        $baseUrl = BASE_URL;
        $employeeModal = new Default_Model_Employee();
        $employessunderEmpId = $employeeModal->getEmployeesUnderRM($oldRM);
        /* Send Mails to the employees whose reporting manager is changed */
        $oldRMData = $employeeModal->getsingleEmployeeData($oldRM);
        $newRMData = $employeeModal->getsingleEmployeeData($newRM);
        if (!empty($newRMData)) {
            foreach ($employessunderEmpId as $employee) {
                $options['subject'] = APPLICATION_NAME . ' : Change of reporting manager';
                $options['header'] = 'Change of reporting manager';
                $options['toEmail'] = $employee['emailaddress'];
                $options['toName'] = $employee['userfullname'];
                $options['message'] = '<div>Hello ' . ucfirst($employee['userfullname']) . ',
											<div>' . ucfirst($newRMData[0]['userfullname']) . ' is your new reporting manager.</div>
											<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login </div>
										</div>';
                $result = sapp_Global::_sendEmail($options);
            }
        }
    }
 public function viewAction()
 {
     $orgInfoModel = new Default_Model_Organisationinfo();
     $employeeModal = new Default_Model_Employee();
     $getorgData = $orgInfoModel->getorgrecords();
     if (!empty($getorgData)) {
         $orgdata = '';
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $loginUserId = $auth->getStorage()->read()->id;
             $loginuserRole = $auth->getStorage()->read()->emprole;
             $loginuserGroup = $auth->getStorage()->read()->group_id;
         }
         $permission = 'No';
         $id = $this->getRequest()->getParam('id');
         if (is_numeric($id) && $id > 0) {
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $popup = $this->getRequest()->getParam('popup');
             $bunitid = $this->getRequest()->getParam('unitId');
             $permission = sapp_Global::_checkprivileges(DEPARTMENTS, $loginuserGroup, $loginuserRole, 'edit');
             $form = new Default_Form_departments();
             if ($popup && $bunitid) {
                 Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
                 $this->view->popup = $popup;
                 $this->view->unitid = $bunitid;
                 $this->view->id = $id;
             }
             $objName = 'departments';
             $form->removeElement("submit");
             $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");
                     }
                 }
             }
             $deptModel = new Default_Model_Departments();
             $data = $deptModel->getSingleDepartmentData($id);
             if (!empty($data)) {
                 $countryId = $data['country'];
                 $stateId = $data['state'];
                 $cityId = $data['city'];
                 if ($countryId && $stateId) {
                     $statesmodel = new Default_Model_States();
                     $citiesmodel = new Default_Model_Cities();
                     $statesData = $statesmodel->getBasicStatesList($countryId);
                     $citiesData = $citiesmodel->getBasicCitiesList($stateId);
                     foreach ($statesData as $res) {
                         $form->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                     }
                     foreach ($citiesData as $res) {
                         $form->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                     }
                     $form->setDefault('country', $countryId);
                     $form->setDefault('state', $stateId);
                     $form->setDefault('city', $cityId);
                 }
                 if ($data["startdate"] != '') {
                     $st_date = sapp_Global::change_date($data["startdate"], 'view');
                     $form->setDefault('start_date', $st_date);
                 }
                 if (!empty($data['depthead'])) {
                     $empdata = $employeeModal->getsingleEmployeeData($data['depthead']);
                 }
                 if (!empty($empdata) && $empdata != 'norows') {
                     $form->depthead->addMultiOption($empdata[0]['user_id'], utf8_encode($empdata[0]['userfullname']));
                 }
                 $form->populate($data);
                 $this->view->controllername = $objName;
                 $this->view->id = $id;
                 $this->view->form = $form;
                 $this->view->role = $loginuserRole;
                 $this->view->editpermission = $permission;
                 $this->view->ermsg = '';
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $orgdata = 'noorgdata';
         $this->view->orgdata = $orgdata;
     }
 }
    public function changereportingmanagerAction()
    {
        $oldRM = $this->_getParam('empid', null);
        $newRM = $this->_getParam('newrmanager', null);
        $status = trim($this->_getParam('status', null));
        $ishead = trim($this->_getParam('ishead', null));
        $baseUrl = BASE_URL;
        $employeeModal = new Default_Model_Employee();
        $employessunderEmpId = $employeeModal->getEmployeesUnderRM($oldRM);
        $updateTable = $employeeModal->changeRM($oldRM, $newRM, $status, $ishead);
        /* Send Mails to the employees whose reporting manager is changed */
        $oldRMData = $employeeModal->getsingleEmployeeData($oldRM);
        $newRMData = $employeeModal->getsingleEmployeeData($newRM);
        foreach ($employessunderEmpId as $employee) {
            $options['subject'] = APPLICATION_NAME . ' : Change of reporting manager';
            $options['header'] = 'Change of reporting manager';
            $options['toEmail'] = $employee['emailaddress'];
            $options['toName'] = $employee['userfullname'];
            $options['message'] = '<div>Hello ' . ucfirst($employee['userfullname']) . ',
										<div>' . ucfirst($newRMData[0]['userfullname']) . ' is your new reporting manager.</div>
										<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login </div>
									</div>';
            $result = sapp_Global::_sendEmail($options);
        }
        $this->_helper->json(array('result' => $updateTable));
    }
 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 editAction()
 {
     $auth = Zend_Auth::getInstance();
     $role_datap = array();
     $empGroup = "";
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserUnitID = $auth->getStorage()->read()->businessunit_id;
         $loginuserDeptID = $auth->getStorage()->read()->department_id;
     }
     $id = (int) $this->getRequest()->getParam('id');
     $id = abs($id);
     if ($id == '') {
         $id = $loginUserId;
     }
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $employeeform = new Default_Form_Myteamemployee();
     try {
         if ($id != '' && is_numeric($id) && $id > 0 && $id != $loginUserId) {
             $employeeModal = new Default_Model_Employee();
             $usersModel = new Default_Model_Users();
             $employmentstatusModel = new Default_Model_Employmentstatus();
             $busineesUnitModel = new Default_Model_Businessunits();
             $deptModel = new Default_Model_Departments();
             $role_model = new Default_Model_Roles();
             $user_model = new Default_Model_Usermanagement();
             $candidate_model = new Default_Model_Candidatedetails();
             $jobtitlesModel = new Default_Model_Jobtitles();
             $positionsmodel = new Default_Model_Positions();
             $prefixModel = new Default_Model_Prefix();
             $my_emp_data = array();
             $empDeptId = "";
             $empRoleId = "";
             $my_emp_data = $employeeModal->getsingleEmployeeData($id);
             $empdata = $employeeModal->getActiveEmployeeData($id);
             if ($my_emp_data == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 if (!empty($my_emp_data)) {
                     $this->view->rowexist = "rows";
                     $employeeform->submit->setLabel('Update');
                     $my_emp_data = $my_emp_data[0];
                     $roles_arr = $role_model->getRolesListByGroupID(EMPLOYEE_GROUP);
                     if (sizeof($roles_arr) > 0) {
                         $employeeform->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
                     }
                     $employmentStatusData = $employmentstatusModel->getempstatuslist();
                     if (sizeof($employmentStatusData) > 0) {
                         $employeeform->emp_status_id->addMultiOption('', 'Select Employment Status');
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $businessunitData = $busineesUnitModel->getDeparmentList();
                     if (sizeof($businessunitData) > 0) {
                         foreach ($businessunitData as $businessunitres) {
                             if ($businessunitres['id'] == $my_emp_data['businessunit_id']) {
                                 $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
                             }
                         }
                     }
                     $departmentsData = $deptModel->getDepartmentList($my_emp_data['businessunit_id']);
                     if (sizeof($departmentsData) > 0) {
                         foreach ($departmentsData as $departmentsres) {
                             if ($departmentsres['id'] == $my_emp_data['department_id']) {
                                 $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']);
                             }
                         }
                     }
                     $jobtitleData = $jobtitlesModel->getJobTitleList();
                     if (sizeof($jobtitleData) > 0) {
                         $employeeform->jobtitle_id->addMultiOption('', 'Select Job Title');
                         foreach ($jobtitleData as $jobtitleres) {
                             $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
                         }
                     }
                     $positionlistArr = $positionsmodel->getPositionList($my_emp_data['jobtitle_id']);
                     if (sizeof($positionlistArr) > 0) {
                         $employeeform->position_id->addMultiOption('', 'Select Position');
                         foreach ($positionlistArr as $positionlistres) {
                             $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                         }
                     }
                     $prefixData = $prefixModel->getPrefixList();
                     if (!empty($prefixData)) {
                         foreach ($prefixData as $prefixres) {
                             $employeeform->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
                         }
                     }
                     $userData = $usersModel->getUserDetails($loginUserId);
                     if (count($userData) > 0) {
                         $employeeform->reporting_manager->addMultiOption($userData[0]['id'], $userData[0]['userfullname']);
                     }
                     $employeeform->populate($my_emp_data);
                     $employeeform->setDefault('user_id', $my_emp_data['user_id']);
                     $employeeform->setDefault('emp_status_id', $my_emp_data['emp_status_id']);
                     $employeeform->setDefault('businessunit_id', $my_emp_data['businessunit_id']);
                     $employeeform->setDefault('jobtitle_id', $my_emp_data['jobtitle_id']);
                     $employeeform->setDefault('department_id', $my_emp_data['department_id']);
                     $employeeform->setDefault('position_id', $my_emp_data['position_id']);
                     $employeeform->setDefault('prefix_id', $my_emp_data['prefix_id']);
                     $date_of_joining = sapp_Global::change_date($my_emp_data['date_of_joining'], 'view');
                     $employeeform->date_of_joining->setValue($date_of_joining);
                     if ($my_emp_data['date_of_leaving'] != '' && $my_emp_data['date_of_leaving'] != '0000-00-00') {
                         $date_of_leaving = sapp_Global::change_date($my_emp_data['date_of_leaving'], 'view');
                         $employeeform->date_of_leaving->setValue($date_of_leaving);
                     }
                     $role_data = $role_model->getRoleDataById($my_emp_data['emprole']);
                     $employeeform->emprole->setValue($my_emp_data['emprole'] . "_" . $role_data['group_id']);
                     $employeeform->setAttrib('action', BASE_URL . 'myemployees/edit/id/' . $id);
                     $this->view->id = $id;
                     $this->view->form = $employeeform;
                     $this->view->my_emp_data = $my_emp_data;
                     $this->view->empdata = $empdata;
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                 }
             }
         } else {
             $this->view->rowexist = "norows";
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($employeeform);
             $this->view->msgarray = $result;
             $employeeform->modeofentry->setValue($data['modeofentry']);
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }