public function addpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $hrem = 'true';
     $mngmntem = 'true';
     $idData = $this->getRequest()->getParam('unitId');
     $idArr = array();
     $idArr = explode('-', $idData);
     $specimen_id = $idArr[0];
     $userflag = $idArr[1];
     $bgstatus = '';
     $agencyids = '';
     $empmodel = new Default_Model_Empscreening();
     $emparraydata = $empmodel->checkbgstatus($specimen_id, $userflag, 'status');
     if (!empty($emparraydata)) {
         $bgstatus = $emparraydata[0]['bgcheck_status'];
     }
     $empscreeningform = new Default_Form_empscreening();
     $empscreeningform->setAttrib('id', 'processform');
     $submitButon = $empscreeningform->getElement("submit");
     $submitButon->setAttrib('style', 'display:none;');
     $empscreeningform->setAttrib('action', DOMAIN . 'processes/addpopup/unitId/' . $idData);
     $empscreeningform->removeElement("employee");
     $processdata = array();
     $empscreeningform->removeElement("bgcheck_status");
     if ($loginuserGroup != HR_GROUP && $loginuserGroup != '' && $loginuserGroup != MANAGEMENT_GROUP) {
         $elements = $empscreeningform->getElements();
         if (count($elements) > 0) {
             foreach ($elements as $key => $element) {
                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                     $element->setAttrib("disabled", "disabled");
                 }
             }
         }
     }
     /* */
     /* Checking for configurations - screening type and agencies */
     $msgarray = array();
     $errorflag = 'true';
     $checktypeModal = new Default_Model_Bgscreeningtype();
     $agencymodel = new Default_Model_Agencylist();
     $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray();
     $agencyData = $agencymodel->fetchAll('isactive=1', 'agencyname')->toArray();
     $personalData = $empmodel->getEmpPersonalData($specimen_id, $userflag);
     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';
     }
     if (!empty($typesData) && !empty($agencyData)) {
         $this->view->configure = '';
     } else {
         $this->view->configure = 'notconfigured';
     }
     $bid = '';
     if (isset($personalData[0]['businessid'])) {
         $bid = $personalData[0]['businessid'];
     }
     if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') {
         $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid));
     } else {
         $hrem = 'false';
         $hremailId = array();
     }
     if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') {
         $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid));
     } else {
         $mngmntem = 'false';
         $mngmntemailId = array();
     }
     if ($specimen_id == $loginUserId) {
         $displaymsg = 'nodata';
     } else {
         $displaymsg = '';
     }
     $this->view->msgarray = $msgarray;
     $this->view->hrEmail = $hrem;
     $this->view->mngmntEmail = $mngmntem;
     $this->view->displaymsg = $displaymsg;
     /* */
     $this->view->form = $empscreeningform;
     $this->view->bgstatus = $bgstatus;
     if ($this->getRequest()->getPost()) {
         $agencyids = $this->_request->getParam('agencyids');
         $result = $this->save($empscreeningform, $processdata);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
         $this->view->agencyids = $agencyids;
         $this->view->contactRadio = $this->_request->getParam('contactRadio');
     }
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $idData = $this->getRequest()->getParam('id');
     /* Checking for configurations - screening type and agencies*/
     $msgarray = array();
     $errorflag = 'true';
     $checktypeModal = new Default_Model_Bgscreeningtype();
     $agencymodel = new Default_Model_Agencylist();
     $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray();
     $agencyData = $agencymodel->fetchAll('isactive=1', 'agencyname')->toArray();
     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;
     /* */
     $empscreeningform = new Default_Form_empscreening();
     $empscreeningModel = new Default_Model_Empscreening();
     $submitButon = $empscreeningform->getElement("submit");
     $submitButon->setAttrib('style', 'display:none;');
     $idArr = array();
     $idArr = explode('-', $idData);
     if (sizeof($idArr) > 1) {
         $id = intVal($idArr[0]);
         $userflag = intVal($idArr[1]);
         $idData = $id . '-' . $userflag;
     } else {
         $id = '';
         $userflag = '';
         $idData = '';
     }
     $errorpagedata = '';
     if ($userflag == 2) {
         $flag = 'cand';
     } else {
         $flag = 'emp';
     }
     if ($userflag == 1 || $userflag == 2 && sapp_Global::_isactivemodule(RESOURCEREQUISITION)) {
         if ($id && $id != $loginUserId) {
             $data = $empscreeningModel->getsingleEmpscreeningData($id, $userflag);
             if (!empty($data) && $data != 'norows') {
                 $empscreeningform->setAttrib('action', BASE_URL . 'empscreening/edit/id/' . $idData);
                 $empscreeningform->removeElement("employee");
                 $empscreeningform->removeElement("checktype");
                 $empscreeningform->removeElement("checkagency");
                 $empscreeningform->populate($data);
                 $specimenId = $data['specimen_id'];
                 $hrEmail = 'false';
                 $mngmntEmail = 'false';
                 $empData = array();
                 $personalData = array();
                 $addressData = array();
                 $companyData = array();
                 if (isset($specimenId) && isset($flag)) {
                     $personalData = $empscreeningModel->getEmpPersonalData($specimenId, $flag);
                     $addressData = $empscreeningModel->getEmpAddressData($specimenId, $flag);
                     $companyData = $empscreeningModel->getEmpCompanyData($specimenId, $flag);
                     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']);
                         }
                     }
                 }
                 $checkstatuses = $empscreeningModel->checkbgstatus($specimenId, $userflag, 'status');
                 $inprocess = 'no';
                 for ($i = 0; $i < sizeof($checkstatuses); $i++) {
                     if (($checkstatuses[$i]['process_status'] == 'In process' || $checkstatuses[$i]['process_status'] == 'On hold') && $checkstatuses[$i]['explanation'] == '' && $checkstatuses[$i]['bgcheck_status'] != 'Complete') {
                         $inprocess = 'yes';
                     }
                 }
                 $this->view->inprocessStatus = $inprocess;
                 $this->view->personalData = $personalData;
                 $this->view->addressData = $addressData;
                 $this->view->companyData = $companyData;
                 $this->view->hrEmail = $hrEmail;
                 $this->view->mngmntEmail = $mngmntEmail;
                 $this->view->errorpagedata = '';
             } else {
                 $this->view->ermsg = 'nodata';
             }
         }
         if ($loginuserGroup != '' && $loginuserGroup != HR_GROUP && $loginuserGroup != MANAGEMENT_GROUP) {
             $elements = $empscreeningform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
         }
         if (!empty($personalData)) {
             if ($personalData[0]['backgroundchk_status'] == 'Completed') {
                 $empscreeningform->setDefault('bgcheck_status', 'Complete');
             }
             if ($personalData[0]['backgroundchk_status'] == 'In process') {
                 $empscreeningform->setDefault('bgcheck_status', 'In process');
             }
             if ($personalData[0]['backgroundchk_status'] == 'On hold') {
                 $empscreeningform->setDefault('bgcheck_status', 'On hold');
             }
             $processData = $this->processesGrid($idData, $personalData[0]['ustatus']);
             $this->view->dataArray = $processData;
             $this->view->form = $empscreeningform;
             $this->view->ermsg = '';
         } else {
             $this->view->ermsg = 'nodata';
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($empscreeningform);
             $this->view->msgarray = $result;
             $this->view->messages = $result;
         }
     } else {
         $errorpagedata = 'nodata';
         $this->view->ermsg = $errorpagedata;
     }
 }