public function addAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $msgarray = array(); $errorflag = 'true'; $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $checktypeModal = new Default_Model_Bgscreeningtype(); $agencymodel = new Default_Model_Agencylist(); $emp_check = 'yes'; $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray(); $agencyData = $agencymodel->fetchAll('isactive=1', 'agencyname')->toArray(); $empscreeningModel = new Default_Model_Empscreening(); $empscreeningform = new Default_Form_empscreening(); $empscreeningform->setAttrib('action', BASE_URL . 'empscreening/add'); /* Add multi-options to the employee dropdown */ $employeeData = $empscreeningModel->getEmployeesForScreening(); $candidateData = $empscreeningModel->getCandidatesForScreening(); $specimenArr = array(); $empArr = array(); $candArr = array(); foreach ($employeeData as $eData) { $empArr[] = array('id' => $eData['id'], 'name' => $eData['name'] . ', ' . $eData['jobtitle'], 'profileimg' => $eData['profileimg']); } foreach ($candidateData as $cData) { $candArr[] = array('id' => $cData['id'], 'name' => $cData['name'], 'profileimg' => ''); } if (sapp_Global::_isactivemodule(RESOURCEREQUISITION)) { $specimenArr = array_merge($empArr, $candArr); } else { $specimenArr = $empArr; } $specimenArr = sapp_Global::aasort($specimenArr, 'name'); $this->view->specimenArr = $specimenArr; /* */ $candid = $this->getRequest()->getParam('candid'); $empid = $this->getRequest()->getParam('empid'); $personalData = ''; $addressData = ''; $companyData = ''; if (isset($candid) && $candid != '') { $empscreeningform->setAttrib('action', BASE_URL . 'empscreening/add/candid/' . $candid); $empscreeningform->setDefault('employee', 'cand-' . $candid); $personalData = $empscreeningModel->getEmpPersonalData($candid, 2); $addressData = $empscreeningModel->getEmpAddressData($candid, 2); $companyData = $empscreeningModel->getEmpCompanyData($candid, 2); $empscreeningform->removeElement('employee'); $emp_check = 'no'; } elseif (isset($empid) && $empid != '') { $empscreeningform->setAttrib('action', BASE_URL . 'empscreening/add/empid/' . $empid); $empscreeningform->setDefault('employee', 'emp-' . $empid); $personalData = $empscreeningModel->getEmpPersonalData($empid, 1); $addressData = $empscreeningModel->getEmpAddressData($empid, 1); $companyData = $empscreeningModel->getEmpCompanyData($empid, 1); $empscreeningform->removeElement('employee'); $emp_check = 'no'; } if (sapp_Global::_isactivemodule(RESOURCEREQUISITION)) { if (!empty($personalData)) { if ($personalData[0]['backgroundchk_status'] != 'Yet to start' && $personalData[0]['backgroundchk_status'] != 'Not Applicable') { $this->view->bgstatus = 'notapplicable'; } else { $this->view->bgstatus = ''; } } else { if (isset($empid) && $empid != '' || isset($candid) && $candid != '') { $this->view->bgstatus = 'no data'; } else { $this->view->bgstatus = ''; } } } else { $this->view->bgstatus = 'no data'; } $hrEmail = 'false'; $mngmntEmail = 'false'; if (!empty($personalData)) { if (isset($personalData[0]['businessid'])) { if (defined('BG_CHECKS_HR_' . $personalData[0]['businessid'])) { $hrEmail = constant('BG_CHECKS_HR_' . $personalData[0]['businessid']); } if (defined('BG_CHECKS_MNGMNT_' . $personalData[0]['businessid'])) { $mngmntEmail = constant('BG_CHECKS_MNGMNT_' . $personalData[0]['businessid']); } } } $this->view->hrEmail = $hrEmail; $this->view->mngmntEmail = $mngmntEmail; /* Check for HR and Management emails END */ $this->view->personalData = $personalData; $this->view->addressData = $addressData; $this->view->companyData = $companyData; $this->view->candid = $candid; $this->view->empid = $empid; $empscreeningform->removeElement("bgcheck_status"); $this->view->form = $empscreeningform; if (!empty($typesData) && !empty($agencyData)) { $this->view->configure = ''; } else { $this->view->configure = 'notconfigured'; } if (empty($typesData)) { $msgarray['checktype'] = 'Screening types are not configured yet.'; $errorflag = 'false'; } if (empty($candidateData) && empty($employeeData)) { $msgarray['employee'] = 'Employees/candidates are not added yet.'; $errorflag = 'false'; } if ($emp_check == 'yes') { if (count($empscreeningform->employee->getMultiOptions()) == 1 && $emp_check == 'yes') { $msgarray['employee'] = 'Employees/candidates are not added yet.'; $errorflag = 'false'; } } if (empty($agencyData)) { $msgarray['agencyids'] = 'Agencies are not added yet.'; $errorflag = 'false'; } $this->view->msgarray = $msgarray; $agencyids = ''; if ($this->getRequest()->getPost()) { $result = $this->save($empscreeningform); $agencyids = $this->_request->getParam('agencyids'); $this->view->msgarray = $result; $this->view->messages = $result; $this->view->agencyids = $agencyids; $this->view->contactRadio = $this->_request->getParam('contactRadio'); } }