Example #1
0
 public function editPasswordAction()
 {
     $account = new Default_Model_Users();
     $account->find(Zend_Registry::get('user')->getId());
     $form = new Default_Form_EditPassword();
     $form->editPassword();
     $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/users/edit-password.phtml'))));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $post = $this->getRequest()->getPost();
             if (md5($post['oldPassword']) == $account->getPassword()) {
                 $account->setPassword(md5($post['password']));
                 if ($account->save()) {
                     $this->_flashMessenger->addMessage("<div class='success  canhide'><p>" . Zend_Registry::get('translate')->_('password_change_success_message') . "</p><a href='javascript:;'></a></div>");
                 } else {
                     $this->_flashMessenger->addMessage("<div class='failure canhide'><p>" . Zend_Registry::get('translate')->_('administrators_edit_password_error_message') . "</p><a href='javascript:;'></a></div>");
                 }
             } else {
                 $this->_flashMessenger->addMessage("<div class='failure canhide'><p>" . Zend_Registry::get('translate')->_('administrators_invalid_old_password') . "</p><a href='javascript:;'></a></div>");
             }
             $this->_redirect(WEBROOT . 'settings/edit-password');
         }
     }
 }
Example #2
0
 /**
  * 
  * @param type $sort
  * @param type $by
  * @param type $pageNo
  * @param type $perPage
  * @param type $searchQuery
  * @return type
  */
 public function getCreateProjectsData($sort, $by, $pageNo, $perPage, $searchQuery)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     /*
      * 1. only for - Login User is part of Project creator, Primary Admin or Secondary Admin
      * 2. only for - Login User's Business Unit Projects
      */
     $usersModel = new Default_Model_Users();
     $loginUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId);
     $where = " (b.isactive = 1) AND (b.businessunit=" . $loginUserSummary['businessunit_id'] . ") ";
     if ($loginuserGroup != MANAGEMENT_GROUP && $loginuserGroup != MANAGER_GROUP) {
         $where .= " AND (b.primarylead = " . $loginUserId . " OR b.secondarylead = " . $loginUserId . " or createdby = " . $loginUserId . ") ";
     }
     if ($searchQuery) {
         $where .= " AND (" . $searchQuery . ")";
     } else {
         $where .= " AND (b.status = 5)";
     }
     $db = Zend_Db_Table::getDefaultAdapter();
     $businessunitsdata = $this->select()->setIntegrityCheck(false)->from(array('b' => 'main_timemanagement_projects'), array('id' => 'b.id', 'projectname' => 'b.projectname', 'description' => 'b.description', 'startdate' => 'date_format(b.startdate,"' . DATEFORMAT_MYSQL . '")', 'enddate' => 'date_format(b.enddate,"' . DATEFORMAT_MYSQL . '")', 'effort' => 'b.effort'))->where($where)->order("{$by} {$sort}")->limitPage($pageNo, $perPage);
     return $businessunitsdata;
 }
Example #3
0
 /**
  * 
  * @param type $sort
  * @param type $by
  * @param type $pageNo
  * @param type $perPage
  * @param type $searchQuery
  * @return type
  */
 public function getProjectTasksData($sort, $by, $pageNo, $perPage, $searchQuery)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     /*
      * 1. only for - Login User is part of Project/Task  creator, Primary Admin or Secondary Admin
      * 2. only for - Login User's Business Unit Projects
      */
     $usersModel = new Default_Model_Users();
     $loginUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId);
     $where = " (b.isactive = 1 and a.isactive = 1) AND (a.businessunit=" . $loginUserSummary['businessunit_id'] . ") ";
     if ($loginuserGroup != MANAGEMENT_GROUP && $loginuserGroup != MANAGER_GROUP) {
         $where .= " AND (b.primarylead = " . $loginUserId . " OR b.secondarylead = " . $loginUserId . " or b.createdby = " . $loginUserId . " or a.primarylead = " . $loginUserId . " OR a.secondarylead = " . $loginUserId . " or a.createdby = " . $loginUserId . ") ";
     }
     //        if ($searchData != '' && $searchData != 'undefined') {
     //            $searchValues = json_decode($searchData);
     //            foreach ($searchValues as $searchQuery =>$key)
     //            if ($searchQuery=='startdate') {
     //                $where .= " AND (" . $searchQuery . ")";
     //            }
     //        }
     $where = " b.isactive = 1 ";
     if ($searchQuery) {
         $where .= " AND " . $searchQuery;
     }
     $db = Zend_Db_Table::getDefaultAdapter();
     $businessunitsdata = $this->select()->setIntegrityCheck(false)->from(array('b' => 'main_timemanagement_project_tasks'), array('id' => 'b.id', 'taskname' => 'b.taskname', 'description' => 'b.description', 'effort' => 'b.effort', 'startdate' => 'date_format(b.startdate,"' . DATEFORMAT_MYSQL . '")', 'enddate' => 'date_format(b.enddate,"' . DATEFORMAT_MYSQL . '")'))->joinLeft(array('a' => 'main_timemanagement_projects'), "a.id=b.projectid ", array('projectname' => 'a.projectname'))->where($where)->order("{$by} {$sort}")->limitPage($pageNo, $perPage);
     return $businessunitsdata;
 }
Example #4
0
 function init()
 {
     $this->setMethod('post');
     $this->addAttribs(array('id' => 'share-file', 'class' => ''));
     $action = new Zend_Form_Element_Hidden('action');
     $action->setValue('sharefile');
     $this->addElement($action);
     $idFile = new Zend_Form_Element_Hidden('idFile');
     $idFile->setValue(Zend_Controller_Front::getInstance()->getRequest()->getParam('id'));
     $this->addElement($idFile);
     //BEGIN:Users
     $idUserTo = new Zend_Form_Element_Select('idUserTo');
     $idUserTo->setLabel('To: ');
     $options = array('' => 'Select user');
     $shops = new Default_Model_Users();
     $select = $shops->getMapper()->getDbTable()->select()->where('id != ?', Zend_Registry::get('user')->getId())->where('NOT deleted')->order('name DESC');
     $result = $shops->fetchAll($select);
     if (NULL != $result) {
         foreach ($result as $value) {
             $options[$value->getId()] = $value->getName();
         }
     }
     $idUserTo->addMultiOptions($options);
     $idUserTo->addValidator(new Zend_Validate_InArray(array_keys($options)));
     $idUserTo->setAttribs(array('class' => 'validate[required] form_selector_fm', 'id' => 'idUserTo'));
     $idUserTo->setRequired(true);
     $this->addElement($idUserTo);
     //END:Users
     $subject = new Zend_Form_Element_Text('subject');
     $subject->setLabel('Subject');
     $subject->setAttribs(array('class' => 'form_subject w_424 validate[required]', 'placeholder' => 'Subject'));
     $subject->setRequired(true);
     $this->addElement($subject);
     $message = new Zend_Form_Element_Textarea('message');
     $message->setLabel('Observations');
     $message->setAttribs(array('class' => 'form_textarea w_424 h_97 validate[required]', 'placeholder' => 'Observations', 'style' => 'width:290px'));
     $message->setRequired(true);
     $this->addElement($message);
     $button = new Zend_Form_Element_Submit('rightSubmit');
     $button->setValue('SEND');
     $button->setAttribs(array('class' => 'comments_submit'));
     $button->setIgnore(true);
     $this->addElement($button);
 }
 public function addAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('visadetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             $data = array();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $employeeModal = new Default_Model_Employee();
             $isrowexist = $employeeModal->getsingleEmployeeData($id);
             if ($isrowexist == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 $this->view->rowexist = "rows";
             }
             $empdata = $employeeModal->getActiveEmployeeData($id);
             if (!empty($empdata)) {
                 $visaandimmigrationDetailsform = new Default_Form_Visaandimmigrationdetails();
                 $visaandimmigrationdetailsModel = new Default_Model_Visaandimmigrationdetails();
                 if ($id) {
                     $usersModel = new Default_Model_Users();
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                     $this->view->id = $id;
                     $visaandimmigrationDetailsform->setAttrib('action', BASE_URL . 'visaandimmigrationdetails/add/userid/' . $id);
                 }
                 $this->view->form = $visaandimmigrationDetailsform;
                 $this->view->employeedata = $employeeData[0];
                 $this->view->data = $data;
                 if ($this->getRequest()->getPost()) {
                     $result = $this->save($visaandimmigrationDetailsform);
                     $this->view->msgarray = $result;
                 }
             }
             $this->view->empdata = $empdata;
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Example #6
0
 public static function _checkstatus()
 {
     $auth = Zend_Auth::getInstance();
     $usersmodel = new Default_Model_Users();
     $flag = 'all';
     $isactivestatus = 1;
     $temporarylock = 0;
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         if ($loginUserId) {
             $loggedinEmpId = $usersmodel->getUserDetailsByID($loginUserId, $flag);
         }
     }
     if (!empty($loggedinEmpId)) {
         $isactivestatus = $loggedinEmpId[0]['isactive'];
         $temporarylock = $loggedinEmpId[0]['emptemplock'];
     }
     if ($isactivestatus == 1 && $temporarylock == 0) {
         return 'true';
     } else {
         return 'false';
     }
 }
Example #7
0
File: Users.php Project: valizr/MMA
 function edit(Default_Model_Users $model)
 {
     $this->name->setValue($model->getName());
     $this->name->setLabel(Zend_Registry::get('translate')->_('admin_name'));
     $this->accountName->setValue($model->getAccountName());
     $this->accountName->setLabel(Zend_Registry::get('translate')->_('admin_account_name'));
     $this->email->setValue($model->getEmail());
     $this->email->setLabel(Zend_Registry::get('translate')->_('admin_email'));
     $emailValidateDbNotExists = $this->email->getValidator('Zend_Validate_Db_NoRecordExists');
     $emailValidateDbNotExists->setExclude(array('field' => 'email', 'value' => $model->getEmail()));
     $this->idRole->setValue($model->getIdRole());
     $this->idRole->setLabel(Zend_Registry::get('translate')->_('admin_level'));
     $this->add->setValue(Zend_Registry::get('translate')->_('admin_edit_user'));
 }
 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();
             $data = array();
             $empDeptId = "";
             $empRoleId = "";
             $data = $employeeModal->getsingleEmployeeData($id);
             if ($data == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 if (!empty($data)) {
                     $this->view->rowexist = "rows";
                     $employeeform->submit->setLabel('Update');
                     $data = $data[0];
                     /* Earlier code to fetch employee details */
                     $employeeData = $employeeModal->getsingleEmployeeData($id);
                     $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'] == $loginuserUnitID) {
                                 $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
                             }
                         }
                     }
                     $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']);
                     if (sizeof($departmentsData) > 0) {
                         foreach ($departmentsData as $departmentsres) {
                             if ($departmentsres['id'] == $loginuserDeptID) {
                                 $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($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($data);
                     $employeeform->setDefault('user_id', $data['user_id']);
                     $employeeform->setDefault('emp_status_id', $data['emp_status_id']);
                     $employeeform->setDefault('businessunit_id', $data['businessunit_id']);
                     $employeeform->setDefault('jobtitle_id', $data['jobtitle_id']);
                     $employeeform->setDefault('department_id', $data['department_id']);
                     $employeeform->setDefault('position_id', $data['position_id']);
                     $employeeform->setDefault('prefix_id', $data['prefix_id']);
                     $date_of_joining = sapp_Global::change_date($data['date_of_joining'], 'view');
                     $employeeform->date_of_joining->setValue($date_of_joining);
                     if ($data['date_of_leaving'] != '' && $data['date_of_leaving'] != '0000-00-00') {
                         $date_of_leaving = sapp_Global::change_date($data['date_of_leaving'], 'view');
                         $employeeform->date_of_leaving->setValue($date_of_leaving);
                     }
                     $role_data = $role_model->getRoleDataById($data['emprole']);
                     $employeeform->emprole->setValue($data['emprole'] . "_" . $role_data['group_id']);
                     $employeeform->setAttrib('action', DOMAIN . 'myemployees/edit/id/' . $id);
                     $this->view->id = $id;
                     $this->view->form = $employeeform;
                     $this->view->employeedata = !empty($employeeData) ? $employeeData[0] : "";
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     $this->view->data = $data;
                 }
             }
         } 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";
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $employeeData = array();
             $id = $this->getRequest()->getParam('userid');
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'workeligibilitydetails';
             $issuingauthority = '';
             $employeeModal = new Default_Model_Employee();
             $workeligibilityform = new Default_Form_Workeligibilitydetails();
             $workeligibilityform->removeElement("submit");
             $elements = $workeligibilityform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $usersModel = new Default_Model_Users();
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $workeligibilityModel = new Default_Model_Workeligibilitydetails();
                             if ($id) {
                                 $usersModel = new Default_Model_Users();
                                 $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                                 $countriesModel = new Default_Model_Countries();
                                 $statesmodel = new Default_Model_States();
                                 $citiesmodel = new Default_Model_Cities();
                                 $countrieslistArr = $countriesModel->getTotalCountriesList();
                                 if (sizeof($countrieslistArr) > 0) {
                                     $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country');
                                     foreach ($countrieslistArr as $countrieslistres) {
                                         $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     }
                                 } else {
                                     $msgarray['issuingauth_country'] = 'Countries are not configured yet.';
                                 }
                                 $data = $workeligibilityModel->getWorkEligibilityRecord($id);
                                 if (!empty($data) && isset($data)) {
                                     $countryId = $data[0]['issuingauth_country'];
                                     $stateId = $data[0]['issuingauth_state'];
                                     $cityId = $data[0]['issuingauth_city'];
                                     $documenttype_id = $data[0]['documenttype_id'];
                                     if ($countryId != '') {
                                         $statelistArr = $statesmodel->getStatesList($countryId);
                                         if (sizeof($statelistArr) > 0) {
                                             $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State');
                                             foreach ($statelistArr as $statelistres) {
                                                 $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                                             }
                                         }
                                     }
                                     if ($stateId != '') {
                                         $citylistArr = $citiesmodel->getCitiesList($stateId);
                                         if (sizeof($citylistArr) > 0) {
                                             $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City');
                                             foreach ($citylistArr as $cityPermlistres) {
                                                 $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                                             }
                                         }
                                         $stateNameArr = $statesmodel->getStateName($stateId);
                                     }
                                     if ($cityId != '') {
                                         $cityNameArr = $citiesmodel->getCityName($cityId);
                                     }
                                     if ($documenttype_id != '') {
                                         $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                                     }
                                     if (!empty($issuingauthorityArr)) {
                                         $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                                         $workeligibilityform->issuingauthflag->setValue($issuingauthority);
                                         $workeligibilityform->documenttype_id->addMultiOption($issuingauthorityArr[0]['id'], $issuingauthorityArr[0]['documenttype']);
                                     }
                                     $workeligibilityform->setDefault("id", $data[0]["id"]);
                                     $workeligibilityform->setDefault("user_id", $data[0]["user_id"]);
                                     $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']);
                                     if (!empty($stateNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']);
                                     }
                                     if (!empty($cityNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']);
                                     }
                                     $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]);
                                     $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]);
                                     $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]);
                                     $issue_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_issue_date"]));
                                     $workeligibilityform->setDefault('doc_issue_date', $issue_date);
                                     $expiry_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_expiry_date"]));
                                     $workeligibilityform->setDefault('doc_expiry_date', $expiry_date);
                                 }
                                 $this->view->controllername = $objName;
                                 $this->view->id = $id;
                                 $this->view->data = $data;
                                 $this->view->employeedata = $employeeData[0];
                                 $this->view->form = $workeligibilityform;
                                 $this->view->issuingauthority = $issuingauthority;
                             }
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_additional', $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 = $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');
             }
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             $employeeModal = new Default_Model_Employee();
             try {
                 if ($Uid && is_numeric($Uid) && $Uid > 0) {
                     $usersModel = new Default_Model_Users();
                     $empdata = $employeeModal->getActiveEmployeeData($Uid);
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $empadditionaldetailsModal = new Default_Model_Empadditionaldetails();
                             $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 = '';
                             } 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 = $empadditionaldetailsModal->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 = $employeeData[0];
                             $this->view->id = $id;
                             $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()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $leaverequestmodel = new Default_Model_Leaverequest();
     $id = $this->getRequest()->getParam('id');
     try {
         $useridArr = $leaverequestmodel->getUserID($id);
         if (!empty($useridArr)) {
             $user_id = $useridArr[0]['user_id'];
             if ($user_id == $loginUserId) {
                 $callval = $this->getRequest()->getParam('call');
                 if ($callval == 'ajaxcall') {
                     $this->_helper->layout->disableLayout();
                 }
                 $objName = 'pendingleaves';
                 $leaverequestform = new Default_Form_leaverequest();
                 $leaverequestform->removeElement("submit");
                 $elements = $leaverequestform->getElements();
                 if (count($elements) > 0) {
                     foreach ($elements as $key => $element) {
                         if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                             $element->setAttrib("disabled", "disabled");
                         }
                     }
                 }
                 $data = $leaverequestmodel->getsinglePendingLeavesData($id);
                 $data = $data[0];
                 $getavailbaleleaves = $leaverequestmodel->getAvailableLeaves($loginUserId);
                 if (!empty($data) && $data['leavestatus'] == 'Approved') {
                     $employeeleavetypemodel = new Default_Model_Employeeleavetypes();
                     $usersmodel = new Default_Model_Users();
                     $employeeleavetypeArr = $employeeleavetypemodel->getsingleEmployeeLeavetypeData($data['leavetypeid']);
                     if ($employeeleavetypeArr != 'norows') {
                         $leaverequestform->leavetypeid->addMultiOption($employeeleavetypeArr[0]['id'], utf8_encode($employeeleavetypeArr[0]['leavetype']));
                     }
                     if ($data['leaveday'] == 1) {
                         $leaverequestform->leaveday->addMultiOption($data['leaveday'], 'Full Day');
                     } else {
                         $leaverequestform->leaveday->addMultiOption($data['leaveday'], 'Half Day');
                     }
                     $repmngrnameArr = $usersmodel->getUserDetailsByID($data['rep_mang_id'], 'all');
                     $leaverequestform->populate($data);
                     $from_date = sapp_Global::change_date($data["from_date"], 'view');
                     $to_date = sapp_Global::change_date($data["to_date"], 'view');
                     $appliedon = sapp_Global::change_date($data["createddate"], 'view');
                     $leaverequestform->from_date->setValue($from_date);
                     $leaverequestform->to_date->setValue($to_date);
                     $leaverequestform->createddate->setValue($appliedon);
                     $leaverequestform->appliedleavesdaycount->setValue($data['appliedleavescount']);
                     $leaverequestform->comments->setValue($data['approver_comments']);
                     if (!empty($repmngrnameArr)) {
                         $leaverequestform->rep_mang_id->setValue($repmngrnameArr[0]['userfullname']);
                     } else {
                         $leaverequestform->rep_mang_id->setValue('');
                     }
                     /*	if(!empty($getavailbaleleaves))
                     		 {
                     			$leaverequestform->no_of_days->setValue($getavailbaleleaves[0]['remainingleaves']);
                     		 }  */
                     $this->view->controllername = $objName;
                     $this->view->id = $id;
                     $this->view->form = $leaverequestform;
                     $this->view->data = $data;
                     $leaverequestform->setDefault('leavetypeid', $data['leavetypeid']);
                     $leaverequestform->setDefault('leaveday', $data['leaveday']);
                     $this->view->reportingmanagerStatus = !empty($repmngrnameArr) ? $repmngrnameArr[0]['isactive'] : '';
                 } else {
                     $this->view->rowexist = "rows";
                 }
             } else {
                 $this->view->rowexist = "rows";
             }
         } else {
             $this->view->rowexist = "norows";
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }
 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');
     }
 }
Example #13
0
 public function setIdUserTo($value)
 {
     $model = new Default_Model_Users();
     $model->find($value);
     if ($model->getId() != NULL) {
         $this->setUserTo($model);
     }
     $this->_idUserTo = !empty($value) ? (int) $value : '0';
     return $this;
 }
Example #14
0
 public function updatethemeAction()
 {
     $this->_helper->layout->disableLayout();
     if ($this->getRequest()->isPost()) {
         $theme_name = $this->getRequest()->getParam('theme_name');
         $usersModel = new Default_Model_Users();
         $user_id = sapp_Global::_readSession('id');
         $where = array('id = ?' => $user_id);
         $data = array('themes' => $theme_name, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $usersModel->addOrUpdateUserModel($data, $where);
         sapp_Global::_writeSession('themes', $theme_name);
         $this->_helper->json(array('result' => 'success'));
     }
 }
Example #15
0
    public function employeedetails($emparr, $conText, $userId)
    {
        $session = new Zend_Auth_Storage_Session();
        $data = $session->read();
        $loggedinuser = $data['id'];
        $group_id = $data['group_id'];
        $empdata = '';
        $employeetabsStr = '';
        $empdata = '<div class="ml-alert-1-success" id="empdetailsmsgdiv" style="display:none;">';
        $empdata .= '<div class="style-1-icon success" style="display:block;"></div>';
        $empdata .= '<div id="successtext"></div>';
        $empdata .= '</div>';
        $empdata .= '<div class="all-bg-ctrl">';
        $employeeModal = new Default_Model_Employee();
        $employessunderEmpId = $employeeModal->getEmployeesUnderRM($userId);
        if (!empty($employessunderEmpId)) {
            $empdata .= '<input type="hidden" value="true" id="hasteam" name="hasteam" />';
        } else {
            $empdata .= '<input type="hidden" value="false" id="hasteam" name="hasteam" />';
        }
        if ($conText == 'edit' || $conText == 'view') {
            //If the user has BG status as "Yet to start" then we should enable the link....
            $usersModel = new Default_Model_Users();
            $bgstatusArr = $usersModel->getBGstatus($userId);
            if (!empty($bgstatusArr) && isset($bgstatusArr) && $bgstatusArr[0]['group_id'] != MANAGEMENT_GROUP) {
                if ($bgstatusArr[0]['isactive'] == 1) {
                    $empdata .= '<div id="hrbgchecklink" style="display:none;" class="action-to-page"><a href="' . BASE_URL . '/empscreening/checkscreeningstatus/empid/' . $userId . '">Send for background checks</a></div>';
                }
            }
        }
        if ($conText != 'mydetails') {
            $empdata .= '<div class="back-to-page"><input type="button" value="Back" name="Back" onclick="gobacktocontroller(\'' . $conText . '\');"></div>';
        }
        $empdata .= '<div class="emp-screen-view">';
        $empdata .= '<div class="display-img-div" id="displayimg" >';
        $empdata .= '<div class="employee-pic-emp">';
        if ($emparr['profileimg'] != '') {
            $empdata .= '<img id="userImage" src="' . BASE_URL . "/public/uploads/profile/" . $emparr['profileimg'] . '" onerror="this.src=\'' . BASE_URL . '/public/media/images/default-profile-pic.jpg\'"/>';
        } else {
            $empdata .= '<img id="userImage" src="' . BASE_URL . '/public/media/images/employee-deafult-pic.jpg" />';
        }
        if ($conText != 'mydetails') {
            if ($group_id == HR_GROUP || $loggedinuser == SUPERADMIN || $group_id == MANAGEMENT_GROUP) {
                $sel_act = $sel_dact = "";
                if ($emparr['isactive'] < 2 && $emparr['emptemplock'] == 0) {
                    if ($emparr['isactive'] == 1) {
                        $sel_act = "selected";
                    } else {
                        if ($emparr['isactive'] == 0) {
                            $sel_dact = "selected";
                        }
                    }
                    $empdata .= '<p class="field switch"><label class="cb-enable  ' . $sel_act . '"><span>Active</span></label><label class="cb-disable ' . $sel_dact . '"><span>Inactive</span></label> </p>';
                    if ($sel_act == "selected") {
                        $empdata .= "\n\t\t\t\t\t\t\t\t\t<script type='text/javascript' language='javascript'>\n\t\t\t\t\t\t\t\t\t\t\$('.cb-disable').click(function(){              \n\t\t\t\t\t\t\t\t\t\t\tmakeActiveInactive('inactive','" . $emparr['id'] . "');\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script> ";
                    } else {
                        if ($sel_dact == "selected") {
                            $empdata .= "\n\t\t\t\t\t\t\t\t\t<script type='text/javascript' language='javascript'>\n\t\t\t\t\t\t\t\t\t\t\$('.cb-enable').click(function(){                \n\t\t\t\t\t\t\t\t\t\t\tmakeActiveInactive('active','" . $emparr['id'] . "');\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script> ";
                        }
                    }
                } else {
                    if ($emparr['isactive'] < 2 && $emparr['emptemplock'] == 1) {
                        $sel_dact = "selected";
                        $sel_act = "";
                        $empdata .= '<p class="field switch"><label class="cb-enable  ' . $sel_act . '"><span>Active</span></label><label class="cb-disable ' . $sel_dact . '"><span>Inactive</span></label> </p>';
                        $empdata .= "\n\t\t\t\t\t\t\t\t<script type='text/javascript' language='javascript'>\n\t\t\t\t\t\t\t\t\t\$('.cb-enable').click(function(){                \n\t\t\t\t\t\t\t\t\t\tmakeActiveInactive('active','" . $emparr['id'] . "');\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</script>   \n\t\t\t\t\t\t\t\t";
                    } else {
                        $sel_dact = "selected";
                        $sel_act = "";
                        $empdata .= '<p class="field switch"><label class="cb-enable  ' . $sel_act . '"><span>Active</span></label><label class="cb-disable ' . $sel_dact . '"><span>Inactive</span></label> </p>';
                        $empdata .= "\n\t\t\t\t\t\t\t\t<script type='text/javascript' language='javascript'>\n\t\t\t\t\t\t\t\t\t\$('.cb-enable,.cb-disable').click(function(){                \n\t\t\t\t\t\t\t\t\t\tmakeActiveInactive('other','" . $emparr['isactive'] . "');\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</script>   \n\t\t\t\t\t\t\t\t";
                    }
                }
            }
        }
        $empdata .= '</div>';
        $empdata .= '<div id="loaderimg" style="display:none; clear:both; margin:0 auto; text-align: center; width:100%;"><img src="' . BASE_URL . "/public/media/images/loaderwhite_21X21.gif" . '" style="width:21px; height: 21px; float: none; "/>';
        $empdata .= '</div>';
        $empdata .= '</div>';
        $empdata .= '<div id="personalDetailsDiv">';
        if ($emparr['is_orghead'] == '1') {
            $headicon = '<img src="' . BASE_URL . "/public/media/images/org-head.png" . '" class="org-head-icon" />';
        } else {
            $headicon = '';
        }
        if (isset($emparr['active_prefix']) && isset($emparr['prefix']) && $emparr['active_prefix'] == 1 && $emparr['prefix'] != '') {
            $empdata .= '<p><b>Employee Name <i>:</i></b><span class="emp-name-span bold-text">' . $emparr['prefix'] . '.&nbsp;' . $emparr['userfullname'] . '</span>' . $headicon . '</p>';
        } else {
            $empdata .= '<p><b>Employee Name <i>:</i></b><span class="emp-name-span bold-text">' . $emparr['userfullname'] . '</span>' . $headicon . '</p>';
        }
        $empdata .= '<p><b>Employee Id <i>:</i></b><span class="emp-name-span" id ="spanempid">' . $emparr['employeeId'] . '</span></p>';
        $empdata .= '<p><b>Email Id <i>:</i></b><span><a href="javascript:void(0)">' . $emparr['emailaddress'] . '</a></span></p>';
        if ($emparr['contactnumber'] != '') {
            $empdata .= '<p><b>Contact Number <i>:</i></b>';
            $empdata .= '<span id="contactnospan" >' . $emparr['contactnumber'] . '</span>';
            if ($group_id == HR_GROUP || $loggedinuser == SUPERADMIN || $loggedinuser == $userId || $group_id == MANAGER_GROUP) {
                $empdata .= '<span class="number-edit"><input type="button" value="Update" id="editcontactnumber" name="Edit Number" onclick="opencontactnumberpopup(\'' . $emparr['id'] . '\',\'edit\',\'' . $emparr['contactnumber'] . '\');">';
                $empdata .= '</span>';
            }
            $empdata .= '</p>';
        } else {
            $empdata .= '<p><b>Contact Number <i>:</i></b>';
            $empdata .= '<span id="contactnospan" ></span>';
            if ($group_id == HR_GROUP || $loggedinuser == SUPERADMIN || $loggedinuser == $userId || $group_id == MANAGER_GROUP) {
                $empdata .= '<span class="number-add"><input type="button" value="Add" id="addcontactnumber" name="Add Number" onclick="opencontactnumberpopup(\'' . $emparr['id'] . '\',\'add\',\'\');">';
                $empdata .= '</span>';
            }
            $empdata .= '</p>';
        }
        $empdata .= '</div>';
        $empdata .= '</div>';
        $empdata .= '<div id="employeeContainer"  style="display: none; overflow: auto;">
						<div class="heading">
							<a href="javascript:void(0)">
								<img src="' . BASE_URL . '/public/media/images/close.png" name="" align="right" border="0" hspace="3" vspace="5" class="closeAttachPopup" style="margin: -24px 8px 0 0;"> 
							</a>
						</div>
						<iframe id="employeeCont" name="employeeCont" class="business_units_iframe" frameborder="0"></iframe>
					</div>';
        $empdata .= '</div>';
        echo $empdata;
        $employeetabsStr = $this->employeetabs($conText, $userId);
        echo $employeetabsStr;
    }
    /**
     * @name save
     *
     * This function is used to save the data that comes from add and edit actions.
     *  @author Asma
     *  @version 1.0
     */
    public function save($agencylistform)
    {
        $baseUrl = BASE_URL;
        $baseUrl = rtrim($baseUrl, '/');
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $loginUserId = $auth->getStorage()->read()->id;
        }
        $id = $this->_request->getParam('id');
        $agencyEmail = '';
        $agencyContactNum = '';
        $agencyuserid = '';
        $agencylistmodel = new Default_Model_Agencylist();
        $pocModel = new Default_Model_Bgpocdetails();
        $usersModel = new Default_Model_Users();
        $statesmodel = new Default_Model_States();
        $citiesmodel = new Default_Model_Cities();
        $pocData_1 = array();
        $pocData_2 = array();
        $pocData_3 = array();
        $contact_type_1 = $this->_request->getParam('contact_type_1');
        $contact_type_2 = $this->_request->getParam('contact_type_2');
        $contact_type_3 = $this->_request->getParam('contact_type_3');
        $checktypeModal = new Default_Model_Bgscreeningtype();
        $errorflag = "true";
        $primaryphone = $this->_request->getParam('primaryphone');
        $secondaryphone = $this->_request->getParam('secondaryphone');
        if ($primaryphone == $secondaryphone && $secondaryphone != '' && $primaryphone != '') {
            $msgarray['secondaryphone'] = 'Primary and secondary phone numbers must not be same.';
            $errorflag = 'false';
        }
        if ($agencylistform->isValid($this->_request->getPost())) {
            if ($contact_type_1 == 1 || $contact_type_2 == 1 || $contact_type_3 == 1) {
                if ($contact_type_1 == 1 && $contact_type_2 == 1 || $contact_type_1 == 1 && $contact_type_3 == 1 || $contact_type_2 == 1 && $contact_type_3 == 1 || $contact_type_1 == 1 && $contact_type_2 == 1 && $contact_type_3 == 1) {
                    $msgarray['contacttype'] = "Please set one contact type as primary.";
                    $errorflag = "false";
                }
            } else {
                $msgarray['contacttype'] = "Please set one contact type as primary.";
                $errorflag = "false";
            }
        }
        /* Check for duplicate entry of mobile and email*/
        $pocid_1 = $this->_request->getParam('pocid_1');
        $mobile_1 = $this->_request->getParam('mobile_1');
        $email_1 = $this->_request->getParam('email_1');
        if ($mobile_1 != '' && $email_1 != '') {
            $exists_M1 = $pocModel->checkMobileDuplicates($pocid_1, $mobile_1);
            if ($exists_M1) {
                $msgarray['mobile_1'] = "Mobile number already exists.";
                $errorflag = "false";
            }
            $exists_E1 = $pocModel->checkEmailDuplicates($pocid_1, $email_1);
            if ($exists_E1) {
                $msgarray['email_1'] = "Email already exists.";
                $errorflag = "false";
            }
        }
        $pocid_2 = $this->_request->getParam('pocid_2');
        $mobile_2 = $this->_request->getParam('mobile_2');
        $email_2 = $this->_request->getParam('email_2');
        if ($mobile_2 != '' && $email_2 != '') {
            $exists_M2 = $pocModel->checkMobileDuplicates($pocid_2, $mobile_2);
            if ($exists_M2) {
                $msgarray['mobile_2'] = "Mobile number already exists.";
                $errorflag = "false";
            }
            $exists_E2 = $pocModel->checkEmailDuplicates($pocid_2, $email_2);
            if ($exists_E2) {
                $msgarray['email_2'] = "Email already exists.";
                $errorflag = "false";
            }
        }
        $pocid_3 = $this->_request->getParam('pocid_3');
        $mobile_3 = $this->_request->getParam('mobile_3');
        $email_3 = $this->_request->getParam('email_3');
        if ($mobile_3 != '' && $email_3 != '') {
            $exists_M3 = $pocModel->checkMobileDuplicates($pocid_3, $mobile_3);
            if ($exists_M3) {
                $msgarray['mobile_3'] = "Mobile number already exists.";
                $errorflag = "false";
            }
            $exists_E3 = $pocModel->checkEmailDuplicates($pocid_3, $email_3);
            if ($exists_E3) {
                $msgarray['email_3'] = "Email already exists.";
                $errorflag = "false";
            }
        }
        $contact_type_1 = $this->_request->getParam('contact_type_1');
        $contact_type_2 = $this->_request->getParam('contact_type_2');
        $contact_type_3 = $this->_request->getParam('contact_type_3');
        if ($contact_type_1 == 1) {
            $agid = $id;
            $agencyEmail = $email_1;
            $agencyContactNum = $mobile_1;
            $pocuseremail = $pocModel->checkEmailInUsers($email_1, $agid);
            if (!empty($pocuseremail)) {
                $msgarray['email_1'] = "Email already exists.";
                $errorflag = "false";
            }
        } else {
            if ($contact_type_2 == 1) {
                $agencyEmail = $email_2;
                $agencyContactNum = $mobile_2;
                $pocuseremail = $pocModel->checkEmailInUsers($email_2, $agid);
                if (!empty($pocuseremail)) {
                    $msgarray['email_2'] = "Email already exists.";
                    $errorflag = "false";
                }
            } else {
                if ($contact_type_3 == 1) {
                    $agencyEmail = $email_3;
                    $agencyContactNum = $mobile_3;
                    $pocuseremail = $pocModel->checkEmailInUsers($email_3, $agid);
                    if (!empty($pocuseremail)) {
                        $msgarray['email_3'] = "Email already exists.";
                        $errorflag = "false";
                    }
                }
            }
        }
        if ($mobile_1 != '' && ($mobile_2 != '' || $mobile_3 != '')) {
            if ($mobile_2 != '' && $mobile_1 == $mobile_2) {
                $msgarray['mobile_2'] = "Contact 1 and contact 2 mobile numbers cannot be same.";
                $errorflag = "false";
            }
            if ($mobile_3 != '' && $mobile_1 == $mobile_3) {
                $msgarray['mobile_3'] = "Contact 1 and contact 3 mobile numbers cannot be same.";
                $errorflag = "false";
            }
            if ($mobile_3 != '' && $mobile_2 != '' && $mobile_2 == $mobile_3) {
                $msgarray['mobile_3'] = "Contact 2 and contact 3 mobile numbers cannot be same.";
                $errorflag = "false";
            }
        }
        if ($email_1 != '' && ($email_2 != '' || $email_3 != '')) {
            if ($email_2 != '' && $email_1 == $email_2) {
                $msgarray['email_2'] = "Contact 1 and contact 2 emails cannot be same.";
                $errorflag = "false";
            }
            if ($email_3 != '' && $email_1 == $email_3) {
                $msgarray['email_3'] = "Contact 1 and contact 3 emails cannot be same.";
                $errorflag = "false";
            }
            if ($email_3 != '' && $email_2 != '' && $email_2 == $email_3) {
                $msgarray['email_3'] = "Contact 2 and contact 3 emails cannot be same.";
                $errorflag = "false";
            }
        }
        /* Duplicate check END */
        $country_1 = $this->_request->getParam('country_1');
        $state_1 = intVal($this->_request->getParam('state_1'));
        $city_1 = intVal($this->_request->getParam('city_1'));
        if (isset($country_1) && $country_1 != 0 && $country_1 != '') {
            $statesData = $statesmodel->getStatesList($country_1);
            foreach ($statesData as $res) {
                $agencylistform->state_1->addMultiOption($res['id'], utf8_encode($res['state_name']));
            }
            if (isset($state_1) && $state_1 != 0 && $state_1 != '') {
                $agencylistform->setDefault('state_1', $state_1);
            }
        }
        if (isset($state_1) && $state_1 != 0 && $state_1 != '') {
            $citiesData = $citiesmodel->getCitiesList($state_1);
            foreach ($citiesData as $res) {
                $agencylistform->city_1->addMultiOption($res['id'], utf8_encode($res['city_name']));
            }
            if (isset($city_1) && $city_1 != 0 && $city_1 != '') {
                $agencylistform->setDefault('city_1', $city_1);
            }
        }
        $country_2 = $this->_request->getParam('country_2');
        $state_2 = intVal($this->_request->getParam('state_2'));
        $city_2 = intVal($this->_request->getParam('city_2'));
        if (isset($country_2) && $country_2 != 0 && $country_2 != '') {
            $statesData = $statesmodel->getStatesList($country_2);
            foreach ($statesData as $res) {
                $agencylistform->state_2->addMultiOption($res['id'], utf8_encode($res['state_name']));
            }
            if (isset($state_2) && $state_2 != 0 && $state_2 != '') {
                $agencylistform->setDefault('state_2', $state_2);
            }
        }
        if (isset($state_2) && $state_2 != 0 && $state_2 != '') {
            $citiesData = $citiesmodel->getCitiesList($state_2);
            foreach ($citiesData as $res) {
                $agencylistform->city_2->addMultiOption($res['id'], utf8_encode($res['city_name']));
            }
            if (isset($city_2) && $city_2 != 0 && $city_2 != '') {
                $agencylistform->setDefault('city_2', $city_2);
            }
        }
        $country_3 = $this->_request->getParam('country_3');
        $state_3 = intVal($this->_request->getParam('state_3'));
        $city_3 = intVal($this->_request->getParam('city_3'));
        if (isset($country_3) && $country_3 != 0 && $country_3 != '') {
            $statesData = $statesmodel->getStatesList($country_3);
            foreach ($statesData as $res) {
                $agencylistform->state_3->addMultiOption($res['id'], utf8_encode($res['state_name']));
            }
            if (isset($state_3) && $state_3 != 0 && $state_3 != '') {
                $agencylistform->setDefault('state_3', $state_3);
            }
        }
        if (isset($state_3) && $state_3 != 0 && $state_3 != '') {
            $citiesData = $citiesmodel->getCitiesList($state_3);
            foreach ($citiesData as $res) {
                $agencylistform->city_3->addMultiOption($res['id'], utf8_encode($res['city_name']));
            }
            if (isset($city_3) && $city_3 != 0 && $city_3 != '') {
                $agencylistform->setDefault('city_3', $city_3);
            }
        }
        $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray();
        if (!empty($typesData)) {
            $this->view->configure = '';
        } else {
            $msgarray['bg_checktype'] = 'Screening types are not configured yet.';
            $errorflag = 'false';
            $this->view->configure = 'notconfigured';
        }
        $rolesData = $agencylistmodel->getagencyrole();
        if (!empty($rolesData)) {
            $this->view->rolesconfigure = '';
        } else {
            $msgarray['emprole'] = 'Roles are not configured yet.';
            $errorflag = 'false';
            $this->view->rolesconfigure = 'notconfigured';
        }
        /* Email address validation */
        $email_1 = $this->_request->getParam('email_1');
        $isvalidemail = filter_var($email_1, FILTER_VALIDATE_EMAIL);
        if ($email_1 == $isvalidemail) {
        } else {
            $msgarray['email_1'] = "Please enter valid email.";
            $errorflag = "false";
        }
        $email_2 = $this->_request->getParam('email_2');
        if ($email_2 != '') {
            $isvalidemail = filter_var($email_2, FILTER_VALIDATE_EMAIL);
            if ($email_2 == $isvalidemail) {
            } else {
                $msgarray['email_2'] = "Please enter valid email.";
                $errorflag = "false";
            }
        }
        $email_3 = $this->_request->getParam('email_3');
        if ($email_3 != '') {
            $isvalidemail = filter_var($email_3, FILTER_VALIDATE_EMAIL);
            if ($email_3 == $isvalidemail) {
            } else {
                $msgarray['email_3'] = "Please enter valid email.";
                $errorflag = "false";
            }
        }
        /* Email address validation END	 */
        /* Website validation */
        $id = $this->_request->getParam('id');
        $website_url = $this->_request->getParam('website_url');
        $websiteExistance = $agencylistmodel->checkSiteDuplicates($website_url, $id);
        if (!empty($websiteExistance)) {
            $eid = isset($websiteExistance['employeeId']) ? $websiteExistance['employeeId'] : 'An agency';
            if ($websiteExistance['isactive'] == '1') {
                $msgarray['website_url'] = $eid . " with the given website URL already exists.";
            } else {
                $msgarray['website_url'] = $eid . " with the given website URL already exists but it might be inactive. Please activate it from manage external users.";
            }
            $errorflag = "false";
        }
        /* Website validation END */
        if ($agencylistform->isValid($this->_request->getPost()) && $errorflag != 'false') {
            $agencyname = $this->_request->getParam('agencyname');
            $address = $this->_request->getParam('address');
            $primaryphone = $this->_request->getParam('primaryphone');
            $secondaryphone = $this->_request->getParam('secondaryphone');
            $bg_checktype = $this->_request->getParam('bg_checktype');
            $bg_checktype = implode(',', $bg_checktype);
            $website_url = $this->_request->getParam('website_url');
            $pocid_1 = $this->_request->getParam('pocid_1');
            $firstname_1 = $this->_request->getParam('firstname_1');
            $lastname_1 = $this->_request->getParam('lastname_1');
            $mobile_1 = $this->_request->getParam('mobile_1');
            $email_1 = $this->_request->getParam('email_1');
            $location_1 = $this->_request->getParam('location_1');
            $country_1 = $this->_request->getParam('country_1');
            $state_1 = $this->_request->getParam('state_1');
            $city_1 = $this->_request->getParam('city_1');
            $contact_type_1 = $this->_request->getParam('contact_type_1');
            $pocid_2 = $this->_request->getParam('pocid_2');
            $firstname_2 = $this->_request->getParam('firstname_2');
            $lastname_2 = $this->_request->getParam('lastname_2');
            $mobile_2 = $this->_request->getParam('mobile_2');
            $email_2 = $this->_request->getParam('email_2');
            $location_2 = $this->_request->getParam('location_2');
            $country_2 = $this->_request->getParam('country_2');
            $state_2 = $this->_request->getParam('state_2');
            $city_2 = $this->_request->getParam('city_2');
            $contact_type_2 = $this->_request->getParam('contact_type_2');
            $pocid_3 = $this->_request->getParam('pocid_3');
            $firstname_3 = $this->_request->getParam('firstname_3');
            $lastname_3 = $this->_request->getParam('lastname_3');
            $mobile_3 = $this->_request->getParam('mobile_3');
            $email_3 = $this->_request->getParam('email_3');
            $location_3 = $this->_request->getParam('location_3');
            $country_3 = $this->_request->getParam('country_3');
            $state_3 = $this->_request->getParam('state_3');
            $city_3 = $this->_request->getParam('city_3');
            $contact_type_3 = $this->_request->getParam('contact_type_3');
            $emprole = $this->_request->getParam('emprole');
            if (empty($websiteExistance)) {
                $date = new Zend_Date();
                if ($contact_type_1 == 1) {
                    $agencyEmail = $email_1;
                    $agencyContactNum = $mobile_1;
                    $pocfn = $firstname_1;
                    $pocln = $lastname_1;
                } else {
                    if ($contact_type_2 == 1) {
                        $agencyEmail = $email_2;
                        $agencyContactNum = $mobile_2;
                        $pocfn = $firstname_2;
                        $pocln = $lastname_2;
                    } else {
                        if ($contact_type_3 == 1) {
                            $agencyEmail = $email_3;
                            $agencyContactNum = $mobile_3;
                            $pocfn = $firstname_3;
                            $pocln = $lastname_3;
                        }
                    }
                }
                $primary_poc_name = ucfirst($pocfn);
                /* Create user for the agency */
                if ($id == '') {
                    $pswd = uniqid();
                    $userdata = array('emprole' => $emprole, 'userstatus' => 'old', 'firstname' => $firstname_1, 'lastname' => $lastname_1, 'userfullname' => $firstname_1 . ' ' . $lastname_1, 'emailaddress' => $agencyEmail, 'contactnumber' => $agencyContactNum, 'emppassword' => md5($pswd), 'isactive' => 1, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $userWhere = '';
                    $usersModel = new Default_Model_Users();
                    $usersTableId = $usersModel->addOrUpdateUserModel($userdata, $userWhere);
                    $agencyuserid = $usersTableId;
                    $idcodeModel = new Default_Model_Identitycodes();
                    $idcode = $idcodeModel->getallcodes('bgcheck');
                    $userdata = array('employeeId' => $idcode . $usersTableId, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $userWhere = array('id=?' => $usersTableId);
                    $usersTableId = $usersModel->addOrUpdateUserModel($userdata, $userWhere);
                    $options['subject'] = APPLICATION_NAME . ' :: Agency is created';
                    $options['header'] = 'Greetings from ' . APPLICATION_NAME;
                    $options['toEmail'] = $agencyEmail;
                    $options['toName'] = $pocfn . ' ' . $pocln;
                    $options['message'] = '<div>Dear ' . $pocfn . ',</div>
											<div>' . ucfirst($agencyname) . ' agency has been created. The credentials to login to your ' . APPLICATION_NAME . ' account are:
												<div>Login ID : ' . $idcode . $agencyuserid . ' </div>
												<div>Password : '******'</div>
												<div></div>											
												<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div>
											</div>';
                    $result = sapp_Global::_sendEmail($options);
                    $emailids = $agencylistmodel->getAllHRManagementEMails();
                    foreach ($emailids as $email) {
                        $options['subject'] = APPLICATION_NAME . ' :: Agency is created';
                        $options['header'] = 'Agency created';
                        $options['toEmail'] = $email['groupEmail'];
                        $options['toName'] = $email['group_name'];
                        if ($email['group_id'] == 4) {
                            $salutation = 'Dear HR,';
                            $options['toName'] = 'HR';
                        } else {
                            $salutation = 'Dear Management,';
                            $options['toName'] = 'Management';
                        }
                        $options['message'] = '<div>
													<div>' . $salutation . ' </div>
													<div></div>	
													' . ucfirst($agencyname) . ' agency has been created with ' . $pocfn . ' ' . $pocln . ' as primary point of contact.
													<div></div>											
													<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div>
												</div>';
                        $options['cron'] = 'yes';
                        $result = sapp_Global::_sendEmail($options);
                    }
                } else {
                    $agencyInfo = $agencylistmodel->getSingleagencyPOCData($id);
                    $userid = $agencyInfo[0]['user_id'];
                    $agencyoldname = $agencyInfo[0]['agencyname'];
                    $userdata = array('emprole' => $emprole, 'userfullname' => $agencyname, 'emailaddress' => $agencyEmail, 'contactnumber' => $agencyContactNum, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $userWhere = array('id=?' => $userid);
                    $usersModel->addOrUpdateUserModel($userdata, $userWhere);
                    if ($agencyoldname != $agencyname) {
                        $agencynamemsg = '<div>Hello ' . ucfirst($primary_poc_name) . ',</div><div>Your agency name is changed to ' . ucfirst($agencyname) . '.</div>';
                    } else {
                        $agencynamemsg = '<div>Hello ' . ucfirst($primary_poc_name) . ',</div><div>Your agency information has been modified. Please find the details below:</div>';
                    }
                    $options['subject'] = APPLICATION_NAME . ' :: Agency details are updated';
                    $options['header'] = 'Agency information';
                    $options['toEmail'] = $agencyEmail;
                    $options['toName'] = $pocfn . ' ' . $pocln;
                    $options['message'] = '<div>' . $agencynamemsg . '
											<div><table border="1" style="border-collapse:collapse;"><tr><td>Primary email</td><td>' . $agencyEmail . '</td></tr><tr><td>Primary Contact Number</td><td>' . $agencyContactNum . '</td></tr></table></div>
											<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.
											</div>
											</div>';
                    $options['cron'] = 'yes';
                    $result = sapp_Global::_sendEmail($options);
                }
                $actionflag = '';
                $tableid = '';
                $data = array('user_id' => $agencyuserid, 'agencyname' => $agencyname, 'address' => $address, 'primaryphone' => $primaryphone, 'secondaryphone' => $secondaryphone, 'bg_checktype' => $bg_checktype, 'website_url' => $website_url, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                if ($id != '') {
                    unset($data['user_id']);
                    $where = array('id=?' => $id);
                    $actionflag = 2;
                } else {
                    $data['createdby'] = $loginUserId;
                    $data['createddate'] = gmdate("Y-m-d H:i:s");
                    $data['isactive'] = 1;
                    $where = '';
                    $actionflag = 1;
                }
                $agencyId = $agencylistmodel->SaveorUpdateAgency($data, $where);
                if ($agencyId == 'update') {
                    $tableid = $id;
                } else {
                    $tableid = $agencyId;
                }
                $menuID = AGENCYLIST;
                $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                if ($firstname_1 != '' && $mobile_1 != '') {
                    $pocData_1 = array('bg_agencyid' => $tableid, 'first_name' => $firstname_1, 'last_name' => $lastname_1, 'contact_no' => $mobile_1, 'email' => $email_1, 'location' => $location_1, 'country' => $country_1, 'state' => $state_1, 'city' => $city_1, 'contact_type' => $contact_type_1, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    if ($pocid_1 != '') {
                        $pocWhere_1 = array('id=?' => $pocid_1);
                        $actionflag = 2;
                    } else {
                        $pocData_1['createdby'] = $loginUserId;
                        $pocData_1['createddate'] = gmdate("Y-m-d H:i:s");
                        $pocData_1['isactive'] = 1;
                        $pocWhere_1 = '';
                        $actionflag = 1;
                    }
                    $savedpocId_1 = $pocModel->SaveorUpdatePOCDetails($pocData_1, $pocWhere_1);
                    if ($savedpocId_1 == 'update') {
                        $newpocid_1 = $pocid_1;
                    } else {
                        $newpocid_1 = $savedpocId_1;
                    }
                }
                if ($firstname_2 != '' && $mobile_2 != '') {
                    $pocData_2 = array('bg_agencyid' => $tableid, 'first_name' => $firstname_2, 'last_name' => $lastname_2, 'contact_no' => $mobile_2, 'email' => $email_2, 'location' => $location_2, 'country' => $country_2, 'state' => $state_2, 'city' => $city_2, 'contact_type' => $contact_type_2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    if ($pocid_2 != '') {
                        $pocWhere_2 = array('id=?' => $pocid_2);
                        $actionflag = 2;
                    } else {
                        $pocData_2['createdby'] = $loginUserId;
                        $pocData_2['createddate'] = gmdate("Y-m-d H:i:s");
                        $pocData_2['isactive'] = 1;
                        $pocWhere_2 = '';
                        $actionflag = 1;
                    }
                    $savedpocId_2 = $pocModel->SaveorUpdatePOCDetails($pocData_2, $pocWhere_2);
                    if ($savedpocId_2 == 'update') {
                        $newpocid_2 = $pocid_2;
                    } else {
                        $newpocid_2 = $savedpocId_2;
                    }
                }
                if ($firstname_3 != '' && $mobile_3 != '') {
                    $pocData_3 = array('bg_agencyid' => $tableid, 'first_name' => $firstname_3, 'last_name' => $lastname_3, 'contact_no' => $mobile_3, 'email' => $email_3, 'location' => $location_3, 'country' => $country_3, 'state' => $state_3, 'city' => $city_3, 'contact_type' => $contact_type_3, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    if ($pocid_3 != '') {
                        $pocWhere_3 = array('id=?' => $pocid_3);
                        $actionflag = 2;
                    } else {
                        $pocData_3['createdby'] = $loginUserId;
                        $pocData_3['createddate'] = gmdate("Y-m-d H:i:s");
                        $pocData_3['isactive'] = 1;
                        $pocWhere_3 = '';
                        $actionflag = 1;
                    }
                    $savedpocId_3 = $pocModel->SaveorUpdatePOCDetails($pocData_3, $pocWhere_3);
                    if ($savedpocId_3 == 'update') {
                        $newpocid_3 = $pocid_3;
                    } else {
                        $newpocid_3 = $savedpocId_3;
                    }
                }
                if ($agencyId == 'update') {
                    $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Agency data updated successfully."));
                } else {
                    $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Agency data added successfully."));
                }
                $this->_redirect('agencylist');
            } else {
                $msgarray['message'] = 'An Agency, with the given website address, already exists.';
                $msgarray['msgtype'] = 'error';
                return $msgarray;
            }
        } else {
            $messages = $agencylistform->getMessages();
            if (isset($msgarray['mobile_1']) && !isset($messages['mobile_1'])) {
                $messages['mobile_1'] = $msgarray['mobile_1'];
            }
            if (isset($msgarray['email_1']) && !isset($messages['email_1'])) {
                $messages['email_1'] = $msgarray['email_1'];
            }
            if (isset($msgarray['mobile_2']) && !isset($messages['mobile_2'])) {
                $messages['mobile_2'] = $msgarray['mobile_2'];
            }
            if (isset($msgarray['email_2']) && !isset($messages['email_2'])) {
                $messages['email_2'] = $msgarray['email_2'];
            }
            if (isset($msgarray['mobile_3']) && !isset($messages['mobile_3'])) {
                $messages['mobile_3'] = $msgarray['mobile_3'];
            }
            if (isset($msgarray['email_3']) && !isset($messages['email_3'])) {
                $messages['email_3'] = $msgarray['email_3'];
            }
            $i = 0;
            $msgarray['error1dv'] = '';
            $msgarray['error2dv'] = '';
            $msgarray['error3dv'] = '';
            foreach ($messages as $key => $val) {
                if (strpos($key, '_1') !== false) {
                    $msgarray['error1dv'] = 'first';
                }
                if (strpos($key, '_2') !== false) {
                    $msgarray['error2dv'] = 'second';
                }
                if (strpos($key, '_3') !== false) {
                    $msgarray['error3dv'] = 'third';
                }
                if (!isset($msgarray[$key])) {
                    foreach ($val as $key2 => $val2) {
                        $msgarray[$key] = $val2;
                        break;
                    }
                }
                $i = $i + 1;
                if (empty($typesData)) {
                    $msgarray['bg_checktype'] = 'Screening types are not configured yet.';
                }
                if (empty($rolesData)) {
                    $msgarray['emprole'] = 'Roles are not configured yet.';
                }
            }
            return $msgarray;
        }
    }
    public function deleteAction()
    {
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $loginUserId = $auth->getStorage()->read()->id;
            $loginUserEmail = $auth->getStorage()->read()->emailaddress;
            $loginUserName = $auth->getStorage()->read()->userfullname;
        }
        $id = $this->_request->getParam('objid');
        $messages['message'] = '';
        $actionflag = 5;
        $businessunitid = '';
        $leavetypetext = '';
        if ($id) {
            $leaverequestmodel = new Default_Model_Leaverequest();
            $usersmodel = new Default_Model_Users();
            $employeesmodel = new Default_Model_Employees();
            $employeeleavetypesmodel = new Default_Model_Employeeleavetypes();
            $loggedInEmployeeDetails = $employeesmodel->getLoggedInEmployeeDetails($loginUserId);
            if ($loggedInEmployeeDetails[0]['businessunit_id'] != '') {
                $businessunitid = $loggedInEmployeeDetails[0]['businessunit_id'];
            }
            $dataarr = array('leavestatus' => 4, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId);
            $where = array('id=?' => $id);
            $Id = $leaverequestmodel->SaveorUpdateLeaveRequest($dataarr, $where);
            $data = $leaverequestmodel->getsinglePendingLeavesData($id);
            $data = $data[0];
            $appliedleavesdaycount = $data['appliedleavescount'];
            $to_date = $data['to_date'];
            $from_date = $data['from_date'];
            $reason = $data['reason'];
            $leavetypeid = $data['leavetypeid'];
            $repmngrnameArr = $usersmodel->getUserDetailsByID($data['rep_mang_id']);
            $reportingmanageremail = $repmngrnameArr[0]['emailaddress'];
            $reportingmanagername = $repmngrnameArr[0]['userfullname'];
            if ($Id == 'update') {
                $menuID = PENDINGLEAVES;
                $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                /** MAILING CODE **/
                if ($to_date == '' || $to_date == NULL) {
                    $to_date = $from_date;
                }
                /* Mail to Employee */
                $options['subject'] = 'Leave request cancelled';
                $options['header'] = 'Leave Request';
                $options['toEmail'] = $loginUserEmail;
                $options['toName'] = $loginUserName;
                $options['message'] = '<div>Hi,</div>
								<div>The below leave(s) has been cancelled.</div>
								<div>
                <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff">
                      <tbody><tr>
                        <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td>
                        <td width="72%">' . $loginUserName . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td>
                        <td>' . $appliedleavesdaycount . '</td>
                      </tr>
                      <tr>
                        <td style="border-right:2px solid #BBBBBB;">From</td>
                        <td>' . $from_date . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">To</td>
                        <td>' . $to_date . '</td>
            	     </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td>
                        <td>' . $reason . '</td>
                  </tr>
                </tbody></table>

            </div>
            <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>';
                $result = sapp_Global::_sendEmail($options);
                /* End */
                /* Mail to Reporting Manager */
                $options['subject'] = 'Leave request cancelled';
                $options['header'] = 'Leave Request';
                $options['toEmail'] = $reportingmanageremail;
                $options['toName'] = $reportingmanagername;
                $options['message'] = '<div>Hi,</div>
								<div>The below leave(s) has been cancelled.</div>
								<div>
                <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff">
                      <tbody><tr>
                        <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td>
                        <td width="72%">' . $loginUserName . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td>
                        <td>' . $appliedleavesdaycount . '</td>
                      </tr>
                      <tr>
                        <td style="border-right:2px solid #BBBBBB;">From</td>
                        <td>' . $from_date . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">To</td>
                        <td>' . $to_date . '</td>
            	     </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td>
                        <td>' . $reason . '</td>
                  </tr>
                </tbody></table>

            </div>
            <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>';
                $result = sapp_Global::_sendEmail($options);
                /* End */
                /* Mail to HR */
                if (defined('LV_HR_' . $businessunitid) && $businessunitid != '') {
                    $options['subject'] = 'Leave request cancelled';
                    $options['header'] = 'Leave Request';
                    $options['toEmail'] = constant('LV_HR_' . $businessunitid);
                    $options['toName'] = 'Leave management';
                    $options['message'] = '<div>Hi,</div>
								<div>The below leave(s) has been cancelled by the Employee.</div>
								<div>
                <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff">
                      <tbody><tr>
                        <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td>
                        <td width="72%">' . $loginUserName . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td>
                        <td>' . $appliedleavesdaycount . '</td>
                      </tr>
                      <tr>
                        <td style="border-right:2px solid #BBBBBB;">From</td>
                        <td>' . $from_date . '</td>
                      </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">To</td>
                        <td>' . $to_date . '</td>
            	     </tr>
                      <tr bgcolor="#e9f6fc">
                        <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td>
                        <td>' . $reason . '</td>
                  </tr>
                </tbody></table>

            </div>
            <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>';
                    $options['cron'] = 'yes';
                    $result = sapp_Global::_sendEmail($options);
                }
                $messages['message'] = 'Leave request cancelled';
                $messages['msgtype'] = 'success';
            } else {
                $messages['message'] = 'Leave request cannot be cancelled';
                $messages['msgtype'] = 'error';
            }
        } else {
            $messages['message'] = 'Leave request cannot be cancelled';
            $messages['msgtype'] = 'error';
        }
        $this->_helper->json($messages);
    }
Example #18
0
 public function saveProfileDetails($viewprofileform)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     if ($viewprofileform->isValid($this->_request->getPost())) {
         $id = $this->_request->getParam('id');
         $userfullname = $this->_request->getParam('userfullname');
         $emailaddress = $this->_request->getParam('emailaddress');
         $usersModel = new Default_Model_Users();
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $actionflag = '';
         $tableid = '';
         $data = array('userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         if ($id != '') {
             $where = array('id=?' => $id);
             $actionflag = 2;
         } else {
             $data['createdby'] = $loginUserId;
             $data['createddate'] = gmdate("Y-m-d H:i:s");
             $data['isactive'] = 1;
             $where = '';
             $actionflag = 1;
         }
         $Id = $usersModel->addOrUpdateUserModel($data, $where);
         sapp_Global::writeApplicationConstants($emailaddress, APPLICATION_NAME);
         if ($Id == 'update') {
             $tableid = $id;
             $this->_helper->getHelper("FlashMessenger")->addMessage("Profile details updated successfully.");
         } else {
             $tableid = $Id;
             $this->_helper->getHelper("FlashMessenger")->addMessage("Profile details saved successfully.");
         }
         $this->_redirect('dashboard/viewprofile');
     } else {
         $messages = $viewprofileform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
Example #19
0
 public function addemppopupAction()
 {
     $flag = 'true';
     $controllername = 'employee';
     $msgarray = array();
     $emptyFlag = 0;
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $deptidforhead = $this->_getParam('deptidforhead', null);
     $report_opt = array();
     $emp_form = new Default_Form_employee();
     $user_model = new Default_Model_Usermanagement();
     $role_model = new Default_Model_Roles();
     $prefixModel = new Default_Model_Prefix();
     $identity_code_model = new Default_Model_Identitycodes();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $deptModel = new Default_Model_Departments();
     $positionsmodel = new Default_Model_Positions();
     $employeeModal = new Default_Model_Employee();
     $usersModel2 = new Default_Model_Users();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead);
     $emp_form->removeElement('department_id');
     $emp_form->removeElement('modeofentry');
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
         $flag = 'false';
     }
     $emp_form->employeeId->setValue($emp_id);
     $role_data = $role_model->getRolesList_Dept();
     $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
     if (empty($role_data)) {
         $msgarray['emprole'] = 'Roles are not configured yet.';
         $flag = 'false';
     }
     $prefixData = $prefixModel->getPrefixList();
     $emp_form->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         //$flag = 'false';
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
         //$flag = 'false';
     }
     if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
         $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']);
         if (sizeof($positionlistArr) > 0) {
             $emp_form->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistres) {
                 $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
             }
         }
     }
     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
     $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status');
     if (!empty($employmentStatusData)) {
         foreach ($employmentStatusData as $employmentStatusres) {
             $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     } else {
         $msgarray['emp_status_id'] = 'Employment status is not configured yet.';
         $emptyFlag++;
     }
     $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP);
     if (!empty($reportingManagerData)) {
         $report_opt = $reportingManagerData;
         if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') {
             $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']);
         }
     } else {
         $msgarray['reporting_manager'] = 'Reporting managers are not added yet.';
         $flag = 'false';
     }
     if ($this->getRequest()->getPost()) {
         if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') {
             $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
             $position_id = $this->_request->getParam('position_id', null);
             $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database');
             $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
             $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
             $employeeId = $this->_getParam('employeeId', null);
             $emprole = $this->_getParam('emprole', null);
             $reporting_manager = $this->_getParam('reporting_manager', null);
             $emailaddress = $this->_getParam('emailaddress', null);
             $emppassword = sapp_Global::generatePassword();
             $firstname = trim($this->_getParam('firstname', null));
             $lastname = trim($this->_getParam('lastname', null));
             $userfullname = $firstname . ' ' . $lastname;
             //$userfullname = trim($this->_request->getParam('userfullname',null));
             $prefix_id = $this->_getParam('prefix_id', null);
             $user_id = $this->_getParam('user_id', null);
             $emp_status_id = $this->_getParam('emp_status_id', null);
             $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old');
             $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $user_data['createdby'] = $loginUserId;
             $user_data['createddate'] = gmdate("Y-m-d H:i:s");
             $user_data['isactive'] = 1;
             if ($emp_identity_code != '') {
                 $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
             } else {
                 $emp_id = '';
             }
             $user_data['employeeId'] = $emp_id;
             $user_id = $user_model->SaveorUpdateUserData($user_data, '');
             $emp_data['user_id'] = $user_id;
             $emp_data['createdby'] = $loginUserId;
             $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
             $emp_data['isactive'] = 1;
             $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
             //end of saving into employee table.
             $tableid = $user_id;
             $actionflag = 1;
             $menuID = ORGANISATIONINFO;
             try {
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             } catch (Exception $e) {
             }
             $managementUsersData = $deptModel->getDeptHeads();
             $opt = '';
             foreach ($managementUsersData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']);
             }
             $this->view->managementUsersData = $opt;
             /* Send Mail to the user */
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $userfullname;
             $this->view->password = $emppassword;
             $this->view->emp_id = $employeeId;
             $this->view->base_url = $base_url;
             $text = $view->render('mailtemplates/newpassword.phtml');
             $options['subject'] = APPLICATION_NAME . ' login Credentials';
             $options['header'] = 'Greetings from Sentrifugo';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $this->view->emp_name;
             $options['message'] = $text;
             $result = sapp_Global::_sendEmail($options);
             /* END */
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $emp_form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->report_opt = $report_opt;
     $this->view->controllername = $controllername;
     $this->view->emp_form = $emp_form;
 }
 public function viewAction()
 {
     $id = intval($this->getRequest()->getParam('id'));
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'pendingleaves';
     $reportingmanagerStatus = '';
     $leaverequestform = new Default_Form_leaverequest();
     $leaverequestform->removeElement("submit");
     $elements = $leaverequestform->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     $leaverequestmodel = new Default_Model_Leaverequest();
     if (is_int($id) && $id != 0) {
         try {
             if ($id) {
                 $data = $leaverequestmodel->getLeaveRequestDetails($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     $employeeleavetypemodel = new Default_Model_Employeeleavetypes();
                     $usersmodel = new Default_Model_Users();
                     $employeeleavetypeArr = $employeeleavetypemodel->getsingleEmployeeLeavetypeData($data['leavetypeid']);
                     if ($employeeleavetypeArr != 'norows') {
                         $leaverequestform->leavetypeid->addMultiOption($employeeleavetypeArr[0]['id'], utf8_encode($employeeleavetypeArr[0]['leavetype']));
                     }
                     if ($data['leaveday'] == 1) {
                         $leaverequestform->leaveday->addMultiOption($data['leaveday'], 'Full Day');
                     } else {
                         $leaverequestform->leaveday->addMultiOption($data['leaveday'], 'Half Day');
                     }
                     $repmngrnameArr = $usersmodel->getUserDetailsByID($data['rep_mang_id'], 'all');
                     $leaverequestform->populate($data);
                     $from_date = sapp_Global::change_date($data["from_date"], 'view');
                     $to_date = sapp_Global::change_date($data["to_date"], 'view');
                     $appliedon = sapp_Global::change_date($data["createddate"], 'view');
                     $leaverequestform->from_date->setValue($from_date);
                     $leaverequestform->to_date->setValue($to_date);
                     $leaverequestform->createddate->setValue($appliedon);
                     $leaverequestform->appliedleavesdaycount->setValue($data['appliedleavescount']);
                     if (!empty($repmngrnameArr)) {
                         $reportingmanagerStatus = $repmngrnameArr[0]['isactive'];
                         $leaverequestform->rep_mang_id->setValue($repmngrnameArr[0]['userfullname']);
                     }
                     $leaverequestform->setDefault('leavetypeid', $data['leavetypeid']);
                     $leaverequestform->setDefault('leaveday', $data['leaveday']);
                     $this->view->controllername = $objName;
                     $this->view->id = $id;
                     $this->view->form = $leaverequestform;
                     $this->view->reportingmanagerStatus = $reportingmanagerStatus;
                 } else {
                     $this->view->rowexist = "rows";
                 }
             } else {
                 $this->view->rowexist = "rows";
             }
         } catch (Exception $e) {
             $this->view->rowexist = "norows";
         }
     } else {
         $this->view->rowexist = "norows";
     }
 }
Example #21
0
 public function editPasswordAction()
 {
     $accountId = new Default_Model_Users();
     $accountId->find(Zend_Registry::get('user')->getId());
     $form = new Default_Form_EditPassword();
     $form->editUserPassword();
     $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/users/edit-password.phtml'))));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $post = $this->getRequest()->getPost();
             if ($accountId->getPassword()) {
                 $accountId->setPassword(md5($post['password']));
                 if ($accountId->save()) {
                     $this->_flashMessenger->addMessage("<div class='success  canhide'><p>Password successfully changed!<a href='javascript:;'>Close</a></p></div>");
                 } else {
                     $this->_flashMessenger->addMessage("<div class='failure  canhide'><p>Password was not changed!<a href='javascript:;'>Close</a></p></div>");
                 }
             } else {
                 $this->_flashMessenger->addMessage("<div class='failure  canhide'><p>Invalid old password!<a href='javascript:;'>Close</a></p></div>");
             }
             $this->_redirect('users');
         }
     }
 }
    public function save($processesform, $processdata)
    {
        $baseUrl = DOMAIN;
        $baseUrl = rtrim($baseUrl, '/');
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $loginUserId = $auth->getStorage()->read()->id;
            $loginuserRole = $auth->getStorage()->read()->emprole;
        }
        $usermodel = new Default_Model_Users();
        $hrem = 'true';
        $mngmntem = 'true';
        $agencyEmail = '';
        $lmanager1Email = '';
        $lmanager1Name = 'Manager';
        $agencysalutationName = 'Agency';
        $id = $this->getRequest()->getParam('id');
        $idData = $this->getRequest()->getParam('unitId');
        $idArr = array();
        $idArr = explode('-', $idData);
        $specimen_id = $idArr[0];
        $userflag = $idArr[1];
        $msgarray = array();
        if ($idArr[1] == 2) {
            $flag = 'cand';
            $person = 'candidate';
        } else {
            $flag = 'emp';
            $person = 'employee';
        }
        $processesmodel = new Default_Model_Processes();
        $empscreeningModel = new Default_Model_Empscreening();
        $statusFlag = '';
        $close = '';
        $controllername = 'processes';
        $errorflag = 'true';
        $BGStatus = '';
        $oldbgstatus = '';
        $mailsentflag = 0;
        if (!empty($processdata)) {
            $newStatus = $this->getRequest()->getParam('process_status');
            $previousstatus = $processdata[0]['process_status'];
            $agencyid = $processdata[0]['agencyid'];
            $checktype = $processdata[0]['checktypeid'];
            $processStatus = $processesmodel->getProcessStatus($specimen_id, $userflag, $agencyid, $checktype);
            if (!empty($processStatus) && sizeof($processStatus) > 0) {
                $oldstatus = $processStatus[0]['process_status'];
                $BGStatus = $processStatus[0]['bgcheck_status'];
                /* Check - Adding a record with same userid, agencyid and check type */
                $exists = 'false';
                for ($i = 0; $i < sizeof($processStatus); $i++) {
                    if (($processStatus[$i]['process_status'] == 'On hold' || $processStatus[$i]['process_status'] == 'In process') && $processStatus[$i]['process_status'] == $newStatus) {
                        $exists = 'true';
                    }
                }
                if ($newStatus == $previousstatus) {
                    $msgarray['StatusError'] = "Please change the status.";
                    $errorflag = "false";
                } else {
                    if ($BGStatus != 'Complete' && $exists == 'true') {
                        $msgarray['StatusError'] = "The " . $person . " is already assigned to the selected agency. Please re-assign the " . $person . " to another agency.";
                        $errorflag = "false";
                    }
                }
                /* END */
            }
        } else {
            $checktype = $this->_request->getParam('checktype');
            $radio_pocId = $this->_request->getParam('contactRadio');
            $agencyid = $this->_request->getParam('agencyids');
            $newStatus = 'In process';
            $agencyData = array();
            $agencyPOCData = array();
            if (empty($checktype) && $checktype == '') {
                $msgarray['checktype'] = "Please check atleast one screening type";
                $errorflag = "false";
            } else {
                if (empty($radio_pocId) || $radio_pocId == '') {
                    $msgarray['contactRadio'] = "Please select point of contact";
                    $errorflag = "false";
                }
            }
            if ($checktype) {
                $agencyArr = array();
                $agencyArr = $checktype;
                $agencyData = $empscreeningModel->getAgencyData($agencyArr, '', '');
            }
            if (!isset($agencyid) || $agencyid == '') {
                $agencyid = $this->getRequest()->getParam('defaultagencyid');
            }
            if (!isset($agencyid) || $agencyid == '') {
                $msgarray['agencyids'] = "Please select agency.";
                $errorflag = "false";
            }
            if ($agencyid) {
                $agencyPOCData = $empscreeningModel->getAgencyPOCData($agencyid);
            }
            $this->view->agencyData = $agencyData;
            $this->view->agencyPOCData = $agencyPOCData;
            /* Checking for configurations - screening type and agencies */
            $checktypeModal = new Default_Model_Bgscreeningtype();
            $agencymodel = new Default_Model_Agencylist();
            $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray();
            $agencyData = $agencymodel->fetchAll('isactive=1', 'agencyname')->toArray();
            for ($i = 0; $i < sizeof($agencyPOCData); $i++) {
                if ($agencyPOCData[$i]['id'] == $radio_pocId) {
                    $agencyEmail = $agencyPOCData[$i]['email'];
                    $agencyfname = $agencyPOCData[$i]['first_name'];
                    $agencylname = $agencyPOCData[$i]['last_name'];
                    $agencysalutationName = $agencyfname . ' ' . $agencylname;
                }
            }
            if (empty($typesData)) {
                $msgarray['checktype'] = 'Screening types are not configured yet.';
                $errorflag = 'false';
            }
            if (empty($agencyData)) {
                $msgarray['agencyids'] = 'Agencies are not added yet.';
                $errorflag = 'false';
            }
            $this->view->msgarray = $msgarray;
            /* */
            /* Check - Adding a record with same userid, agencyid and check type (for each check type ) */
            if (is_array($checktype) && $errorflag != "false") {
                for ($i = 0; $i < sizeof($checktype); $i++) {
                    $processStatus = array();
                    $processStatus = $processesmodel->getProcessStatus($specimen_id, $userflag, $agencyid, $checktype[$i]);
                    if (!empty($processStatus) && sizeof($processStatus > 0)) {
                        $exists = 'false';
                        for ($i = 0; $i < sizeof($processStatus); $i++) {
                            if ($processStatus[$i]['process_status'] == 'On hold' || $processStatus[$i]['process_status'] == 'In process') {
                                $exists = 'true';
                            }
                        }
                        $oldstatus = $processStatus[0]['process_status'];
                        $BGStatus = $processStatus[0]['bgcheck_status'];
                        if ($exists == 'true' && $BGStatus != 'Complete') {
                            $msgarray['StatusError'] = "The " . $person . " is already assigned to the selected agency. Please re-assign the " . $person . " to another agency.";
                            $errorflag = "false";
                        }
                    }
                    $oldbgstatusData = $processesmodel->getProcessStatus($specimen_id, $userflag, '', '');
                    if (!empty($oldbgstatusData)) {
                        $oldbgstatus = $oldbgstatusData[0]['bgcheck_status'];
                    } else {
                        $oldbgstatus = '';
                    }
                }
            }
            /* END */
        }
        if ($processesform->isValid($this->_request->getPost()) && $errorflag != 'false') {
            $date = new Zend_Date();
            $menumodel = new Default_Model_Menu();
            $actionflag = '';
            $tableid = '';
            /* 	A New process is created for a user whose background check status is in 'Complete' status. Then updating the bg status to 'In process' */
            if (($BGStatus == 'Complete' || $oldbgstatus == 'Complete' || $BGStatus == 'On hold' || $oldbgstatus == 'On hold') && $newStatus == 'In process') {
                $totalstatusData = array('bgcheck_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag);
                $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere);
                /* Updating back ground check status to In process in employees/candidates status */
                if ($userflag == 1) {
                    $empData = array('backgroundchk_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $empWhere = array('id=?' => $specimen_id);
                    $usermodel->addOrUpdateUserModel($empData, $empWhere);
                } else {
                    $candModel = new Default_Model_Candidatedetails();
                    $candData = array('backgroundchk_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $candWhere = array('id=?' => $specimen_id);
                    $candModel->SaveorUpdateUserData($candData, $candWhere);
                }
                /* END */
                /* Mail to HRD, Line 1 and Line 2 managers that the background checks has been re-opened */
                if ($BGStatus != 'On hold' && $oldbgstatus != 'On hold') {
                    $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag);
                    if ($userflag == 1) {
                        $username = $empData[0]['name'];
                        $lmanager1Email = $empData[0]['rmanager_email'];
                        $lmanager1Name = $empData[0]['reporting_manager'];
                    } else {
                        $username = $empData[0]['candidate_name'];
                        $lmanager1Email = '';
                    }
                    $bid = '';
                    if (isset($empData[0]['businessid'])) {
                        $bid = $empData[0]['businessid'];
                    }
                    if (isset($lmanager1Email) && $lmanager1Email != '') {
                        $manager1 = array($lmanager1Email);
                    } else {
                        $manager1 = array();
                    }
                    if (isset($agencyEmail) && $agencyEmail != '') {
                        $agencyemail1 = array($agencyEmail);
                    } else {
                        $agencyemail1 = array();
                    }
                    if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') {
                        $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid));
                    } else {
                        $mngmntem = 'false';
                        $mngmntemailId = array();
                    }
                    if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') {
                        $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid));
                    } else {
                        $hrem = 'false';
                        $hremailId = array();
                    }
                    $emailArr = array_merge($agencyemail1, $manager1, $mngmntemailId, $hremailId);
                    for ($i = 0; $i < sizeof($emailArr); $i++) {
                        $salutation = 'Dear Sir/Madam,';
                        if ($i == 0) {
                            $salutation = 'Dear ' . ucfirst($agencysalutationName) . ',';
                            $options['toName'] = ucfirst($agencysalutationName);
                        }
                        if ($i == 1) {
                            $salutation = 'Dear ' . ucfirst($lmanager1Name) . ',';
                            $options['toName'] = ucfirst($lmanager1Name);
                        }
                        if ($i == 2) {
                            $salutation = 'Dear Management,';
                            $options['toName'] = 'Management';
                        }
                        if ($i == 3) {
                            $salutation = 'Dear HR,';
                            $options['toName'] = 'HR';
                        }
                        $options['subject'] = APPLICATION_NAME . ' : Background checks re-opened';
                        $options['header'] = 'Background checks re-opened';
                        $options['toEmail'] = $emailArr[$i];
                        $createdbyName = $usermodel->getUserDetails($loginUserId);
                        if ($i == 0) {
                            $mailsentflag = 1;
                            $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . '
													has been re-opened by ' . $createdbyName[0]['userfullname'] . '. </div>
													<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div>
												</div>';
                        } else {
                            $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . '
													has been re-opened by ' . $createdbyName[0]['userfullname'] . '. </div>
													<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div>
												</div>';
                        }
                        $options['cron'] = 'yes';
                        sapp_Global::_sendEmail($options);
                    }
                }
                /* END */
            }
            /* END */
            $data = array('specimen_id' => $specimen_id, 'flag' => $userflag, 'bgagency_id' => $agencyid, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
            if ($id != '') {
                $data['process_status'] = $newStatus;
                $data['explanation'] = NULL;
                $where = array('id=?' => $id);
                $actionflag = 2;
            } else {
                $data['process_status'] = $newStatus;
                $data['bgagency_pocid'] = $radio_pocId;
                $data['createdby'] = $loginUserId;
                $data['createddate'] = gmdate("Y-m-d H:i:s");
                $data['isactive'] = 1;
                $where = '';
                $actionflag = 1;
                if ($newStatus == 'In process' && ($BGStatus != 'Complete' || $oldbgstatus != 'Complete' || $BGStatus != 'On hold' || $oldbgstatus != 'On hold') && $mailsentflag == 0) {
                    $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag);
                    $table = '';
                    if ($userflag == 1) {
                        $username = $empData[0]['name'];
                        $lmanager1Email = $empData[0]['rmanager_email'];
                        $lmanager1Name = $empData[0]['reporting_manager'];
                        $table = '<div>
											<table border="1" style="border-collapse:collapse;">
												<tr><td>Employee ID</td><td>' . $empData[0]['employee_id'] . '</td></tr>
												<tr><td>Employee Email</td><td>' . $empData[0]['email_id'] . '</td></tr>
												<tr><td>Employee Designation</td><td>' . $empData[0]['designation'] . '</td></tr>
											</table>
										</div>';
                    } else {
                        $username = $empData[0]['candidate_name'];
                        $lmanager1Email = '';
                        $table = '<div>Candidate Email : ' . $empData[0]['email'] . '</div>';
                    }
                    if ($agencysalutationName != '') {
                        $salutation = 'Dear ' . ucfirst($agencysalutationName) . ',';
                        $options['toName'] = ucfirst($agencysalutationName);
                    } else {
                        $salutation = 'Dear Sir/Madam,';
                        $options['toName'] = 'Agency';
                    }
                    $createdbyName = $usermodel->getUserDetails($loginUserId);
                    $options['subject'] = APPLICATION_NAME . ' : Background checks initiated';
                    $options['header'] = 'Background checks initiated';
                    $options['toEmail'] = $agencyEmail;
                    $options['message'] = '<div>' . $salutation . '<div>' . ucfirst($username) . ' has been sent for background checks by ' . ucfirst($createdbyName[0]['userfullname']) . '. Please find the details below.</div>' . $table . '
					                    
												<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div>
											</div>';
                    $options['cron'] = 'yes';
                    sapp_Global::_sendEmail($options);
                }
            }
            if (is_array($checktype)) {
                for ($i = 0; $i < sizeof($checktype); $i++) {
                    $data['bgcheck_type'] = $checktype[$i];
                    $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where);
                }
            } else {
                $data['bgcheck_type'] = $checktype;
                $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where);
            }
            /* If all the processes are in 'Complete' status, then updating the background check status to 'Complete' and sending mail to HR, reporting manager  */
            $checkAllprocesses = $processesmodel->getProcessStatus($specimen_id, $userflag);
            $completecount = 0;
            $onholdcount = 0;
            for ($i = 0; $i < sizeof($checkAllprocesses); $i++) {
                if ($checkAllprocesses[$i]['process_status'] == 'Complete') {
                    $completecount = $completecount + 1;
                }
            }
            if ($completecount == sizeof($checkAllprocesses)) {
                $totalstatusData = array('bgcheck_status' => 'Complete', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag);
                $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere);
                /* Updating back ground check status to Completed in employees/candidates status */
                if ($userflag == 1) {
                    $usermodel = new Default_Model_Users();
                    $empData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $empWhere = array('id=?' => $specimen_id);
                    $usermodel->addOrUpdateUserModel($empData, $empWhere);
                } else {
                    $candModel = new Default_Model_Candidatedetails();
                    $candData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $candWhere = array('id=?' => $specimen_id);
                    $candModel->SaveorUpdateUserData($candData, $candWhere);
                }
                /* END */
                /* Mail to HRD, Line 1 and Line 2 managers */
                if ($newStatus == 'Complete') {
                    $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag);
                    if ($userflag == 1) {
                        $username = $empData[0]['name'];
                        $lmanager1Email = $empData[0]['rmanager_email'];
                        $lmanager1Name = $empData[0]['reporting_manager'];
                    } else {
                        $username = $empData[0]['name'];
                        $lmanager1Email = '';
                    }
                    $bid = '';
                    if (isset($empData[0]['businessid'])) {
                        $bid = $empData[0]['businessid'];
                    }
                    if (isset($lmanager1Email) && $lmanager1Email != '') {
                        $manager1 = array($lmanager1Email);
                    } else {
                        $manager1 = array();
                    }
                    if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') {
                        $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid));
                    } else {
                        $mngmntemailId = array();
                    }
                    if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') {
                        $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid));
                    } else {
                        $hremailId = array();
                    }
                    $emailArr = array_merge($manager1, $mngmntemailId, $hremailId);
                    for ($i = 0; $i < sizeof($emailArr); $i++) {
                        $salutation = 'Dear Sir/Madam,';
                        if ($i == 0) {
                            $salutation = 'Dear ' . ucfirst($lmanager1Name) . ',';
                            $options['toName'] = ucfirst($lmanager1Name);
                        } else {
                            if ($i == 1) {
                                $salutation = 'Dear Management,';
                                $options['toName'] = 'Management';
                            } else {
                                $salutation = 'Dear HR,';
                                $options['toName'] = 'HR';
                            }
                        }
                        $options['subject'] = APPLICATION_NAME . ' : Background checks completed';
                        $options['header'] = 'Background checks completed';
                        $options['toEmail'] = $emailArr[$i];
                        $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . '
													has been completed.</div>
													<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div>
												</div>';
                        $options['cron'] = 'yes';
                        sapp_Global::_sendEmail($options);
                    }
                }
                /* END */
            }
            /* End */
            /* If all the processes are in 'On hold' status, then updating the background check status to 'On hold' */
            for ($i = 0; $i < sizeof($checkAllprocesses); $i++) {
                if ($checkAllprocesses[$i]['process_status'] == 'On hold') {
                    $onholdcount = $onholdcount + 1;
                }
            }
            if ($onholdcount == sizeof($checkAllprocesses)) {
                $totalstatusData = array('bgcheck_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag);
                $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere);
                /* Updating back ground check status to Completed in employees/candidates status */
                if ($userflag == 1) {
                    $usermodel = new Default_Model_Users();
                    $empData = array('backgroundchk_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $empWhere = array('id=?' => $specimen_id);
                    $usermodel->addOrUpdateUserModel($empData, $empWhere);
                } else {
                    $candModel = new Default_Model_Candidatedetails();
                    $candData = array('backgroundchk_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $candWhere = array('id=?' => $specimen_id);
                    $candModel->SaveorUpdateUserData($candData, $candWhere);
                }
                /* END */
            }
            /* END */
            if ($detailId == 'update') {
                $tableid = $id;
                $this->view->eventact = 'updated';
            } else {
                $tableid = $detailId;
                $this->view->eventact = 'added';
            }
            $actionflag = 2;
            //Edit of the candidate or employee
            $menuidArr = $menumodel->getMenuObjID('/empscreening');
            $menuID = $menuidArr[0]['id'];
            $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $specimen_id . '-' . $userflag);
            $close = 'close';
            $this->view->popup = $close;
        } else {
            $messages = $processesform->getMessages();
            foreach ($messages as $key => $val) {
                foreach ($val as $key2 => $val2) {
                    $msgarray[$key] = $val2;
                    break;
                }
                if (empty($checktypesData)) {
                    $msgarray['checktype'] = 'Screening types are not configured yet.';
                }
                if (empty($checkagencyData)) {
                    $msgarray['agencyids'] = 'Agencies are not added yet.';
                }
            }
            return $msgarray;
        }
        $this->view->statusFlag = $statusFlag;
    }
Example #23
0
 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');
     }
 }
Example #24
0
File: Role.php Project: valizr/MMA
 public function delete(Default_Model_Role $value)
 {
     $auth = Zend_Auth::getInstance();
     $authAccount = $auth->getStorage()->read();
     if (null != $authAccount) {
         if (null != $authAccount->getId()) {
             $user = new Default_Model_Users();
             $user->find($authAccount->getId());
             $id = $value->getId();
             $data = array('deleted' => '1');
             $this->getDbTable()->update($data, array('id = ?' => $id));
             return $id;
         }
     }
 }
 public function viewAction_27092013()
 {
     $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 = 'empcommunicationdetails';
     $empcommdetailsform = new Default_Form_empcommunicationdetails();
     $empcommdetailsform->removeElement("submit");
     $elements = $empcommdetailsform->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     try {
         if ($id) {
             $employeeModal = new Default_Model_Employee();
             $isrowexist = $employeeModal->getsingleEmployeeData($id);
             if ($isrowexist == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 $this->view->rowexist = "rows";
             }
             $empdata = $employeeModal->getActiveEmployeeData($id);
             if (!empty($empdata)) {
                 //TO get the Employee  profile information....
                 $usersModel = new Default_Model_Users();
                 $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                 $empcommdetailsModal = new Default_Model_Empcommunicationdetails();
                 $usersModel = new Default_Model_Users();
                 $countriesModel = new Default_Model_Countries();
                 $statesmodel = new Default_Model_States();
                 $citiesmodel = new Default_Model_Cities();
                 $orgInfoModel = new Default_Model_Organisationinfo();
                 $msgarray = array();
                 $orgid = 1;
                 $orgdata = $orgInfoModel->getOrganisationData($orgid);
                 $countryId = $orgdata['country'];
                 $stateId = $orgdata['state'];
                 $cityId = $orgdata['city'];
                 if ($countryId != '') {
                     $countryData = $countriesModel->getActiveCountryName($countryId);
                     $orgdata['country'] = $countryData[0]['country'];
                 }
                 if ($stateId != '') {
                     $stateData = $statesmodel->getStateNameData($stateId);
                     $orgdata['state'] = $stateData[0]['state'];
                 }
                 if ($cityId != '') {
                     $citiesData = $citiesmodel->getCitiesNameData($cityId);
                     $orgdata['city'] = $citiesData[0]['city'];
                 }
                 $countrieslistArr = $countriesModel->getActiveCountriesList();
                 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['country_id_org'], $countrieslistres['country']);
                         $empcommdetailsform->current_country->addMultiOption($countrieslistres['country_id_org'], $countrieslistres['country']);
                     }
                 } else {
                     $msgarray['perm_country'] = 'Countries are not configured yet.';
                     $msgarray['current_country'] = 'Countries are not configured yet.';
                 }
                 $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id);
                 if (!empty($data)) {
                     $statePermlistArr = $statesmodel->getStatesList($data[0]['perm_country']);
                     if (sizeof($statePermlistArr) > 0) {
                         $empcommdetailsform->perm_state->addMultiOption('', 'Select State');
                         foreach ($statePermlistArr as $statelistres) {
                             $empcommdetailsform->perm_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                         }
                     }
                     $cityPermlistArr = $citiesmodel->getCitiesList($data[0]['perm_state']);
                     if (sizeof($cityPermlistArr) > 0) {
                         $empcommdetailsform->perm_city->addMultiOption('', 'Select City');
                         foreach ($cityPermlistArr as $cityPermlistres) {
                             $empcommdetailsform->perm_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                         }
                     }
                     if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '') {
                         $statecurrlistArr = $statesmodel->getStatesList($data[0]['current_country']);
                         if (sizeof($statecurrlistArr) > 0) {
                             $empcommdetailsform->current_state->addMultiOption('', 'Select State');
                             foreach ($statecurrlistArr as $statecurrlistres) {
                                 $empcommdetailsform->current_state->addMultiOption($statecurrlistres['id'] . '!@#' . $statecurrlistres['state_name'], $statecurrlistres['state_name']);
                             }
                         }
                         $currstateNameArr = $statesmodel->getStateName($data[0]['current_state']);
                     }
                     if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '' && $data[0]['current_city'] != '') {
                         $cityCurrlistArr = $citiesmodel->getCitiesList($data[0]['current_state']);
                         if (sizeof($cityCurrlistArr) > 0) {
                             $empcommdetailsform->current_city->addMultiOption('', 'Select State');
                             foreach ($cityCurrlistArr as $cityCurrlistres) {
                                 $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'] . '!@#' . $cityCurrlistres['city_name'], $cityCurrlistres['city_name']);
                             }
                         }
                         $currcityNameArr = $citiesmodel->getCityName($data[0]['current_city']);
                     }
                     $permstateNameArr = $statesmodel->getStateName($data[0]['perm_state']);
                     $permcityNameArr = $citiesmodel->getCityName($data[0]['perm_city']);
                     $empcommdetailsform->populate($data[0]);
                     $empcommdetailsform->setDefault('perm_country', $data[0]['perm_country']);
                     $empcommdetailsform->setDefault('perm_state', $permstateNameArr[0]['id'] . '!@#' . $permstateNameArr[0]['statename']);
                     $empcommdetailsform->setDefault('perm_city', $permcityNameArr[0]['id'] . '!@#' . $permcityNameArr[0]['cityname']);
                     if ($data[0]['current_country'] != '') {
                         $empcommdetailsform->setDefault('current_country', $data[0]['current_country']);
                     }
                     if ($data[0]['current_state'] != '') {
                         $empcommdetailsform->setDefault('current_state', $currstateNameArr[0]['id'] . '!@#' . $currstateNameArr[0]['statename']);
                     }
                     if ($data[0]['current_city'] != '') {
                         $empcommdetailsform->setDefault('current_city', $currcityNameArr[0]['id'] . '!@#' . $currcityNameArr[0]['cityname']);
                     }
                 }
                 $this->view->controllername = $objName;
                 $this->view->data = $data;
                 $this->view->dataArray = $orgdata;
                 $this->view->id = $id;
                 $this->view->employeedata = $employeeData[0];
                 $this->view->form = $empcommdetailsform;
             }
             $this->view->empdata = $empdata;
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }
Example #26
0
 public function updatebgstatus($con, $specimenid, $flag)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $screeningmodel = new Default_Model_Empscreening();
     $usermodel = new Default_Model_Users();
     $candmodel = new Default_Model_Candidatedetails();
     if ($con == 'onhold') {
         $userdata = array('backgroundchk_status' => 'On hold', 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $this->getLoginUserId());
         $userwhere = "id=" . $specimenid;
         if ($flag == 1) {
             $usermodel->addOrUpdateUserModel($userdata, $userwhere);
         } else {
             $candmodel->SaveorUpdateCandidateData($userdata, $userwhere);
         }
         $data = array('bgcheck_status' => 'On hold', 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $this->getLoginUserId());
         $where = "flag = " . $flag . " AND specimen_id=" . $specimenid;
         $screeningmodel->SaveorUpdateDetails($data, $where);
     }
     if ($con == 'complete') {
         $userdata = array('backgroundchk_status' => 'Completed', 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $this->getLoginUserId());
         $userwhere = "id=" . $specimenid;
         if ($flag == 1) {
             $usermodel->addOrUpdateUserModel($userdata, $userwhere);
         } else {
             $candmodel->SaveorUpdateCandidateData($userdata, $userwhere);
         }
         $data = array('bgcheck_status' => 'Complete', 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $this->getLoginUserId());
         $where = "flag = " . $flag . " AND specimen_id=" . $specimenid;
         $screeningmodel->SaveorUpdateDetails($data, $where);
     }
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $messages['message'] = '';
     $id = $this->getRequest()->getParam('id', null);
     $taskModel = new Default_Model_Createtasks();
     $currprojectsModel = new Default_Model_Createprojects();
     $activityModel = new Default_Model_Createactivities();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $currentUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId);
     $taskAllocationModel = new Default_Model_Tasksallocation();
     $where = "";
     $actionflag = 1;
     $form = new Default_Form_createprojects();
     $form->setAttrib('action', DOMAIN . 'createtasks/edit/id/' . $id);
     //$this->view->activeprojects = $taskModel->getActiveProjects();
     $this->view->activeprojects = $taskAllocationModel->getActiveProjectsForTasksForUser($currentUserSummary['businessunit_id'], $loginUserId, $loginuserGroup);
     $this->view->projectCategories = $taskModel->getProjectCategories();
     $this->view->business_units_list = $requi_model->getBusinessUnits();
     $this->view->allusers = array();
     //$this->view->allusers = $usersModel->getAllActiveUsers();
     try {
         if ($id > 0 && is_numeric($id)) {
             //update code
             $where = "";
             $actionflag = 2;
             $id = abs($id);
             $taskdata = $taskModel->getTaskDataByID($id);
             $Currprojectdata = $currprojectsModel->getProjectDataByID($taskdata['projectid']);
             $form->submit->setLabel('Update Task');
             $this->view->taskpagerefresh = '0';
             $this->view->TaskID = $id;
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->form = $form;
             $this->view->isEdit = "1";
             $this->view->data = $taskdata;
             $this->view->BUUsers = $usersModel->getAllActiveUsersByBU($Currprojectdata['businessunit']);
             $this->view->TrackingCodes = $currprojectsModel->getTrackingCodesByCategory($Currprojectdata['category']);
             if ($this->getRequest()->getPost()) {
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     //Task Details
                     $tprojectSelected = $this->_getParam('projectSelected', null);
                     $ttaskName = $this->_getParam('taskName', null);
                     $ttaskDescription = $this->_getParam('taskDescription', null);
                     $ttaskStartDate = $this->_getParam('taskStartDate', null);
                     $ttaskEndDate = $this->_getParam('taskEndDate', null);
                     $ttaskStatus = $this->_getParam('taskStatus', null);
                     $ttaskPrimaryLead = $this->_getParam('taskPrimaryLead', null);
                     $ttaskSecondaryLead = $this->_getParam('taskSecondaryLead', null);
                     $ttaskEffort = $this->_getParam('taskEffort', null);
                     //Task Activity Details
                     $tprjactivitytaskid = $this->_getParam('prjactivitytaskid', null);
                     $tprjactivityid = $this->_getParam('prjactivityid', null);
                     $tprjactivitysdate = $this->_getParam('prjactivitysdate', null);
                     $tprjactivityedate = $this->_getParam('prjactivityedate', null);
                     $tprjactivityeffort = $this->_getParam('prjactivityeffort', null);
                     $tprojectStartDate1 = sapp_Global::change_date(trim($ttaskStartDate), 'database');
                     $tprojectEndDate1 = sapp_Global::change_date(trim($ttaskEndDate), 'database');
                     $tprojectStartDate2 = sapp_Global::change_date(trim($taskdata['startdate']), 'database');
                     $tprojectEndDate2 = sapp_Global::change_date(trim($taskdata['enddate']), 'database');
                     //get tracking codes for edits
                     $ttrackingcodestartdate = $this->_getParam('trackingcodestartdate', null);
                     $ttrackingcodeenddate = $this->_getParam('trackingcodeenddate', null);
                     $ttrackingcodeeffort = $this->_getParam('trackingcodeenddate', null);
                     $mtaskactivitytrackingdata = array('startdate' => implode(',', $ttrackingcodestartdate), 'enddate' => implode(',', $ttrackingcodeenddate), 'effort' => implode(',', $ttrackingcodeeffort));
                     $this->view->taskactivitytrackingdata = $mtaskactivitytrackingdata;
                     $this->view->taskpagerefresh = '1';
                     if ($tprojectStartDate2 != $tprojectStartDate1 && ($ttrackingcodestartdate <= 0 || $ttrackingcodestartdate == '')) {
                         //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Start Date."));
                         $validationMsg['message'] = 'Tracking code due to change in Task Planned Start Date.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if ($tprojectEndDate2 != $tprojectEndDate1 && ($ttrackingcodeenddate <= 0 || $ttrackingcodeenddate == '')) {
                             //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned End Date."));
                             $validationMsg['message'] = 'Tracking code due to change in Task Planned End Date.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if ($taskdata['effort'] != $ttaskEffort && ($ttrackingcodeeffort <= 0 || $ttrackingcodeeffort == '')) {
                                 //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Effort."));
                                 $validationMsg['message'] = 'Tracking code due to change in Task Planned Effort.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if ($tprojectSelected <= 0) {
                                     $validationMsg['message'] = 'Please select project.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if (strlen(trim($ttaskName)) <= 0) {
                                         $validationMsg['message'] = 'Task name cannot be empty.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if (strlen(trim($ttaskDescription)) <= 0) {
                                             $validationMsg['message'] = 'Task description cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if (strlen(trim($ttaskStartDate)) <= 0) {
                                                 $validationMsg['message'] = 'Task startdate cannot be empty.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if (strlen(trim($ttaskEndDate)) <= 0) {
                                                     $validationMsg['message'] = 'Task enddate cannot be empty.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 } else {
                                                     if (strlen(trim($ttaskEffort)) <= 0) {
                                                         $validationMsg['message'] = 'Task effort cannot be empty.';
                                                         $validationMsg['msgtype'] = 'error';
                                                         $this->view->validationMsg = $validationMsg;
                                                         $bFlag = false;
                                                     } else {
                                                         if ($ttaskPrimaryLead <= 0) {
                                                             $validationMsg['message'] = 'Please select primary lead.';
                                                             $validationMsg['msgtype'] = 'error';
                                                             $this->view->validationMsg = $validationMsg;
                                                             $bFlag = false;
                                                         } else {
                                                             if ($ttaskSecondaryLead <= 0) {
                                                                 $validationMsg['message'] = 'Please select secondary lead.';
                                                                 $validationMsg['msgtype'] = 'error';
                                                                 $this->view->validationMsg = $validationMsg;
                                                                 $bFlag = false;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($bFlag) {
                         $mpolicydata = array('projectid' => trim($tprojectSelected), 'taskname' => trim($ttaskName), 'description' => trim($ttaskDescription), 'status' => trim($ttaskStatus), 'effort' => trim($ttaskEffort), 'startdate' => sapp_Global::change_date(trim($ttaskStartDate), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskEndDate), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $where = array('id=?' => $id);
                         $Id = $taskModel->SaveorUpdateData($mpolicydata, $where);
                         if ($tprojectStartDate2 != $tprojectStartDate1 || $tprojectEndDate2 != $tprojectEndDate1 || $taskdata['effort'] != $ttaskEffort) {
                             $taskslogModel = new Default_Model_Createtaskslog();
                             $mprojectlogdata = array('taskid' => trim($taskdata['id']), 'startdatetrackingcodeid' => trim($ttrackingcodestartdate), 'enddatetrackingcodeid' => trim($ttrackingcodeenddate), 'efforttrackingcodeid' => trim($ttrackingcodeeffort), 'effortold' => trim($taskdata['effort']), 'startdateold' => $tprojectStartDate2, 'enddateold' => $tprojectEndDate2, 'effortnew' => $ttaskEffort, 'startdatenew' => $tprojectStartDate1, 'enddatenew' => $tprojectEndDate1, 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"));
                             $where = "";
                             $Id = $taskslogModel->SaveorUpdateData($mprojectlogdata, $where);
                         }
                         //update Task Activities
                         $currRow = 0;
                         foreach ($tprjactivityid as $tprjactid) {
                             $mactivitydata = array('effort' => trim($tprjactivityeffort[$currRow]), 'startdate' => sapp_Global::change_date(trim($tprjactivitysdate[$currRow]), 'database'), 'enddate' => sapp_Global::change_date(trim($tprjactivityedate[$currRow]), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                             $where = array('id=?' => $tprjactivitytaskid[$currRow]);
                             $Id1 = $activityModel->SaveorUpdateData($mactivitydata, $where);
                             $currRow = $currRow + 1;
                         }
                         $menuID = -999;
                         sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Task details successfully modified."));
                         $trDb->commit();
                         $this->_redirect('/createtasks');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createtasks');
                 }
             }
         } else {
             //Insert code
             $actionflag = 1;
             if ($this->getRequest()->getPost()) {
                 #$result = $this->save($form, $policydata);
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     //Task Details
                     $tprojectSelected = $this->_getParam('projectSelected', null);
                     $ttaskName = $this->_getParam('taskName', null);
                     $ttaskDescription = $this->_getParam('taskDescription', null);
                     $ttaskStartDate = $this->_getParam('taskStartDate', null);
                     $ttaskEndDate = $this->_getParam('taskEndDate', null);
                     $ttaskStatus = $this->_getParam('taskStatus', null);
                     $ttaskPrimaryLead = $this->_getParam('taskPrimaryLead', null);
                     $ttaskSecondaryLead = $this->_getParam('taskSecondaryLead', null);
                     $ttaskEffort = $this->_getParam('taskEffort', null);
                     //Task Activity Details
                     $tprjactivityid = $this->_getParam('prjactivityid', null);
                     $tprjactivitysdate = $this->_getParam('prjactivitysdate', null);
                     $tprjactivityedate = $this->_getParam('prjactivityedate', null);
                     $tprjactivityeffort = $this->_getParam('prjactivityeffort', null);
                     $tprjactivitysdate1 = implode(',', $tprjactivitysdate);
                     $mtaskactivitytrackingdata = array('startdate' => implode(',', $tprjactivitysdate), 'enddate' => implode(',', $tprjactivityedate), 'effort' => implode(',', $tprjactivityeffort));
                     $this->view->taskactivitytrackingdata = $mtaskactivitytrackingdata;
                     $this->view->taskpagerefresh = '1';
                     if ($tprojectSelected <= 0) {
                         $validationMsg['message'] = 'Please select project.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if (strlen(trim($ttaskName)) <= 0) {
                             $validationMsg['message'] = 'Task name cannot be empty.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if (strlen(trim($ttaskDescription)) <= 0) {
                                 $validationMsg['message'] = 'Task description cannot be empty.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if (strlen(trim($ttaskStartDate)) <= 0) {
                                     $validationMsg['message'] = 'Task startdate cannot be empty.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if (strlen(trim($ttaskEndDate)) <= 0) {
                                         $validationMsg['message'] = 'Task enddate cannot be empty.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if (strlen(trim($ttaskEffort)) <= 0) {
                                             $validationMsg['message'] = 'Task effort cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if ($ttaskPrimaryLead <= 0) {
                                                 $validationMsg['message'] = 'Please select primary lead.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if ($ttaskSecondaryLead <= 0) {
                                                     $validationMsg['message'] = 'Please select secondary lead.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $mpolicydata = array('projectid' => trim($tprojectSelected), 'taskname' => trim($ttaskName), 'description' => trim($ttaskDescription), 'status' => trim($ttaskStatus), 'effort' => trim($ttaskEffort), 'startdate' => sapp_Global::change_date(trim($ttaskStartDate), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskEndDate), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     if ($bFlag) {
                         $Id = $taskModel->SaveorUpdateData($mpolicydata, $where);
                         if ($Id > 0 && is_numeric($Id)) {
                             //Insert Task Activities
                             $currRow = 0;
                             foreach ($tprjactivityid as $tprjactid) {
                                 $mactivitydata = array('taskid' => trim($Id), 'activityid' => trim($tprjactid), 'status' => trim($ttaskStatus), 'effort' => trim($tprjactivityeffort[$currRow]), 'startdate' => sapp_Global::change_date(trim($tprjactivitysdate[$currRow]), 'database'), 'enddate' => sapp_Global::change_date(trim($tprjactivityedate[$currRow]), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                                 $currRow = $currRow + 1;
                                 $Id1 = $activityModel->SaveorUpdateData($mactivitydata, $where);
                             }
                             $menuID = -999;
                             sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project details successfully added."));
                         } else {
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Error while adding project details."));
                         }
                         $trDb->commit();
                         $this->_redirect('/createtasks');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createtasks');
                 }
             }
             if ($tprojectSelected > 0) {
                 $Currprojectdata = $currprojectsModel->getProjectDataByID($tprojectSelected);
                 $this->view->BUUsers = $usersModel->getAllActiveUsersByBU($Currprojectdata['businessunit']);
             }
             $form->submit->setLabel('Add Task');
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->TaskID = "0";
             $this->view->form = $form;
             $this->view->isEdit = "0";
             $this->view->data = $mpolicydata;
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 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('employeedocs', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $employeeModal = new Default_Model_Employee();
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     if (!empty($empdata)) {
                         $empDocuModel = new Default_Model_Employeedocs();
                         $empDocuments = $empDocuModel->getEmpDocumentsByFieldOrAll('user_id', $id);
                         $this->view->empDocuments = $empDocuments;
                     }
                     $usersModel = new Default_Model_Users();
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                     if (!empty($employeeData)) {
                         $this->view->employeedata = $employeeData[0];
                     }
                     $this->view->id = $id;
                     $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 updateempdetails($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     if ($employeeform->isValid($this->_request->getPost())) {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_joining = $this->_request->getParam('date_of_joining', null);
         $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $hid_modeofentry = $this->_getParam('hid_modeofentry', null);
         $other_modeofentry = $this->_getParam('other_modeofentry', null);
         $userfullname = $this->_getParam('userfullname', null);
         $candidatereferredby = $this->_getParam('candidatereferredby', null);
         $rccandidatename = $this->_getParam('rccandidatename', null);
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         $tmp_name = $this->_request->getParam('tmp_emp_name', null);
         $act_inact = $this->_request->getParam("act_inact", null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') {
             $candidate_key = 'userfullname';
             $candidate_value = $userfullname;
             $emp_name = $userfullname;
             $candidate_flag = 'no';
         } else {
             $candidate_key = 'rccandidatename';
             $candidate_value = $rccandidatename;
             $emp_name = $tmp_name;
             $candidate_flag = 'yes';
         }
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate'), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry);
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
                 unset($user_data['other_modeofentry']);
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 if ($modeofentry != 'Direct') {
                     $user_data['userfullname'] = $emp_name;
                 }
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if (in_array($emp_status_id, $empstatusarray)) {
                 $isactivestatus = '';
                 if ($emp_status_id == 8) {
                     $isactivestatus = 2;
                 } else {
                     if ($emp_status_id == 9) {
                         $isactivestatus = 3;
                     } else {
                         if ($emp_status_id == 10) {
                             $isactivestatus = 4;
                         }
                     }
                 }
                 $statusdata = array('isactive' => $isactivestatus);
                 $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
             } else {
                 $statusdata = array('isactive' => 1);
                 $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $emp_name;
                 $this->view->password = $emppassword;
                 $this->view->emp_id = $employeeId;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/newpassword.phtml');
                 $options['subject'] = APPLICATION_NAME . ' login credentials';
                 $options['header'] = 'Greetings from Sentrifugo';
                 $options['toEmail'] = $emailaddress;
                 $options['toName'] = $this->view->emp_name;
                 $options['message'] = $text;
                 $result = sapp_Global::_sendEmail($options);
                 //end of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $menuidArr = $menumodel->getMenuObjID('/usermanagement');
             $menuID_user = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             if ($act_inact == 1) {
                 if ($user_data['isactive'] == 1) {
                     $act_str = array("Activated" => Zend_Registry::get('currentdate'));
                 } else {
                     $act_str = array("Inactivated" => Zend_Registry::get('currentdate'));
                 }
                 $result = sapp_Global::logManager($menuID_user, 4, $loginUserId, $user_id, '', $act_str);
             }
             $trDb->commit();
             $this->_redirect('employee/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong,please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         $usersModel = new Default_Model_Users();
         if (isset($businessunit_id) && $businessunit_id != 0 && $businessunit_id != '') {
             $departmentsmodel = new Default_Model_Departments();
             $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id);
             $employeeform->department_id->clearMultiOptions();
             $employeeform->reporting_manager->clearMultiOptions();
             $employeeform->department_id->addMultiOption('', 'Select Department');
             foreach ($departmentlistArr as $departmentlistresult) {
                 $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname']));
             }
             if (isset($department_id) && $department_id != 0 && $department_id != '') {
                 $employeeform->setDefault('department_id', $department_id);
             }
         }
         if (isset($department_id) && $department_id != 0 && $department_id != '') {
             $reportingManagerArr = $usersModel->getReportingManagerList($department_id, $user_id);
             $employeeform->reporting_manager->addMultiOption('', 'Select Reporting Manager');
             foreach ($reportingManagerArr as $reportingManagerresult) {
                 $employeeform->reporting_manager->addMultiOption($reportingManagerresult['id'], utf8_encode($reportingManagerresult['userfullname']));
             }
             if (isset($reporting_manager) && $reporting_manager != 0 && $reporting_manager != '') {
                 $employeeform->setDefault('reporting_manager', $reporting_manager);
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }