/**
     * @name deletepocAction
     *
     * This action is used to delete a point of contact of an agency.
     *  @author Asma
     *  @version 1.0
     */
    public function deletepocAction()
    {
        try {
            $pocsmodel = new Default_Model_Bgpocdetails();
            $agencylistmodel = new Default_Model_Agencylist();
            $auth = Zend_Auth::getInstance();
            if ($auth->hasIdentity()) {
                $loginUserId = $auth->getStorage()->read()->id;
            }
            $poc_name = '';
            $agencyid = $this->_request->getParam('agencyid');
            $pocid = $this->_request->getParam('pocid');
            $pocdata = $pocsmodel->getSingleagencyPOCData($pocid);
            if (!empty($pocdata[0])) {
                $poc_name = $pocdata[0]['first_name'] . ' ' . $pocdata[0]['last_name'];
            }
            $messages['message'] = '';
            $messages['msgtype'] = '';
            $actionflag = 3;
            if (isset($pocdata[0]['contact_type']) && $pocdata[0]['contact_type'] == '2') {
                if ($pocid && $agencyid) {
                    $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                    $where = array('id=?' => $pocid, 'bg_agencyid=?' => $agencyid);
                    $result = $pocsmodel->SaveorUpdatePOCDetails($data, $where);
                    $result_2 = $pocsmodel->deleteBGcheckdetails($agencyid, $pocid, $loginUserId);
                    // Mail to Secondary contact
                    $options['subject'] = APPLICATION_NAME . ' :: POC is deleted';
                    $options['header'] = 'POC deleted';
                    $options['toEmail'] = trim($pocdata[0]['email']);
                    $options['toName'] = $pocdata[0]['userfullname'];
                    $salutation = 'Dear ' . $pocdata[0]['first_name'] . ',';
                    $custom_base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                    $options['message'] = '<div>
										<div>' . $salutation . ' </div>
										<div></div>	
										<div>You are deleted as a secondary point of contact from ' . $pocdata[0]['agencyname'] . ' agency.</div>
										<div>
											<table border="1" style="border-collapse:collapse;">
												<tr><td>Name : </td><td>' . $poc_name . '</td></tr>
												<tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr>
												<tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr>
											</table>
										</div>	
										<div></div>
										</div>';
                    $options['cron'] = 'Yes';
                    if ($options['toEmail'] != '') {
                        $result_email = sapp_Global::_sendEmail($options);
                    }
                    // Mail to Primary contact
                    $primary_poc = $pocsmodel->getPrimaryPOCData($agencyid);
                    $primary_poc_name = $primary_poc[0]['first_name'] . ' ' . $primary_poc[0]['last_name'];
                    $options['subject'] = APPLICATION_NAME . ' :: POC is deleted';
                    $options['header'] = 'POC deleted';
                    $options['toEmail'] = trim($primary_poc[0]['email']);
                    $options['toName'] = $primary_poc_name;
                    $salutation = 'Dear ' . $primary_poc[0]['first_name'] . ',';
                    $options['message'] = '<div>
										<div>' . $salutation . ' </div>
										<div></div>	
										<div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div>
										<div>
											<table border="1" style="border-collapse:collapse;">
												<tr><td>Name : </td><td>' . $poc_name . '</td></tr>
												<tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr>
												<tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr>
											</table>
										</div>	
										<div></div>
										<div style="padding:20px 0 10px 0;">Please <a href="' . $custom_base_url . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div>												
										</div>';
                    $options['cron'] = 'Yes';
                    if ($options['toEmail'] != '') {
                        $result_email = sapp_Global::_sendEmail($options);
                    }
                    // Mail to HR and Management
                    $emailids = $agencylistmodel->getAllHRManagementEMails();
                    foreach ($emailids as $email) {
                        $options['subject'] = APPLICATION_NAME . ' :: POC is deleted';
                        $options['header'] = 'POC deleted';
                        $options['toEmail'] = trim($email['groupEmail']);
                        $options['toName'] = $email['group_name'];
                        if ($email['group_id'] == 4) {
                            $salutation = 'Dear HR,';
                        } else {
                            $salutation = 'Dear Management,';
                        }
                        $options['message'] = '<div>
												<div>' . $salutation . '</div>
												<div></div>	
												<div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div>
												<div>
													<table cellpadding="0" cellspacing="0" border="1">
														<tr><td>Name :</td><td>' . $poc_name . '</td></tr>
														<tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr>
														<tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr>
													</table>
												</div>	
												<div></div>
												<div style="padding:20px 0 10px 0;">Please <a href="' . $custom_base_url . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div>											
											</div>';
                        $options['cron'] = 'Yes';
                        if ($options['toEmail'] != '') {
                            $result_email = sapp_Global::_sendEmail($options);
                        }
                    }
                    if ($result) {
                        $menuID = AGENCYLIST;
                        $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $agencyid, $pocid);
                        $messages['message'] = 'Point Of Contact details deleted successfully.';
                        $messages['msgtype'] = 'success';
                    } else {
                        $messages['message'] = 'POC cannot be deleted.';
                        $messages['msgtype'] = 'error';
                    }
                } else {
                    $messages['message'] = 'POC cannot be deleted.';
                    $messages['msgtype'] = 'error';
                }
            } else {
                $messages['message'] = 'Primary point of contact cannot be deleted.';
                $messages['msgtype'] = 'error';
            }
            $this->_helper->json($messages);
        } catch (Exception $e) {
            exit($e->getMessage());
        }
    }
    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;
    }
    public function sendEMails($agencyData, $flag)
    {
        $baseUrl = $this->generateBaseurl();
        $agencylistmodel = new Default_Model_Agencylist();
        if ($flag == 'activated') {
            $emailids = $agencylistmodel->getAllHRManagementEMails();
            foreach ($emailids as $email) {
                $options['subject'] = APPLICATION_NAME . ' : Agency activated';
                $options['header'] = 'Agency activated';
                $options['toEmail'] = $email['groupEmail'];
                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>	
										' . $agencyData['userfullname'] . ' agency has been activated. 
										<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  to your Sentrifugo account.</div>
										</div>';
                $options['cron'] = 'yes';
                $result = sapp_Global::_sendEmail($options);
            }
            $options['subject'] = APPLICATION_NAME . ' : Agency Activated';
            $options['header'] = 'Agency Activated';
            $options['toEmail'] = $agencyData['emailaddress'];
            $options['toName'] = $agencyData['userfullname'];
            $options['message'] = '<div>
									<div>Dear ' . $agencyData['userfullname'] . ',</div>
									<div></div>	
									Your agency has been activated. For further details, please contact our HR directly.
									<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  to your Sentrifugo account.</div>																			
									</div>';
            $options['cron'] = 'yes';
            $result = sapp_Global::_sendEmail($options);
        } else {
            if ($flag == 'inactivated') {
                $emailids = $agencylistmodel->getAllHRManagementEMails();
                foreach ($emailids as $email) {
                    $options['subject'] = APPLICATION_NAME . ' : Agency is deleted';
                    $options['header'] = 'Agency deleted';
                    $options['toEmail'] = $email['groupEmail'];
                    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>	
										' . $agencyData['userfullname'] . ' agency has been deleted. 
										<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  to your Sentrifugo account.</div>											
										</div>';
                    $options['cron'] = 'yes';
                    $result = sapp_Global::_sendEmail($options);
                }
                $options['subject'] = APPLICATION_NAME . ' :: Agency is deleted';
                $options['header'] = 'Agency Deleted';
                $options['toEmail'] = $agencyData['emailaddress'];
                $options['toName'] = $agencyData['userfullname'];
                $options['message'] = '<div>
									<div>Dear ' . $agencyData['userfullname'] . ',</div>
									<div></div>	
									We regret to inform you that your agency has been deleted.
									<div></div>											
									</div>';
                $options['cron'] = 'yes';
                $result = sapp_Global::_sendEmail($options);
            }
        }
    }
 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;
     }
 }
示例#5
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'agencylist');
     $this->setAttrib('action', BASE_URL . 'agencylist/edit/id/1');
     $id = new Zend_Form_Element_Hidden('id');
     $pocid_1 = new Zend_Form_Element_Hidden('pocid_1');
     $pocid_2 = new Zend_Form_Element_Hidden('pocid_2');
     $pocid_3 = new Zend_Form_Element_Hidden('pocid_3');
     $agencyname = new Zend_Form_Element_Text('agencyname');
     $agencyname->setAttrib('maxLength', 50);
     $agencyname->addFilter(new Zend_Filter_StringTrim());
     $agencyname->setRequired(true);
     $agencyname->addValidator('NotEmpty', false, array('messages' => 'Please enter agency name.'));
     $agencyname->addValidator("regex", true, array('pattern' => '/^(?![0-9]{4})[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid agency name.')));
     $address = new Zend_Form_Element_Textarea('address');
     $address->setAttrib('rows', 10);
     $address->setAttrib('cols', 50);
     $address->setRequired(true);
     $address->addValidator('NotEmpty', false, array('messages' => 'Please enter address.'));
     $primaryphone = new Zend_Form_Element_Text('primaryphone');
     $primaryphone->setAttrib('maxLength', 15);
     $primaryphone->addFilter(new Zend_Filter_StringTrim());
     $primaryphone->setRequired(true);
     $primaryphone->addValidator('NotEmpty', false, array('messages' => 'Please enter primary phone number.'));
     $primaryphone->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Primary phone number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Primary phone number must contain at least %min% characters.')))));
     $primaryphone->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $primaryphone->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_bgagencylist', 'field' => 'primaryphone', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $primaryphone->getValidator('Db_NoRecordExists')->setMessage('Primary phone number already exists.');
     $secondaryphone = new Zend_Form_Element_Text('secondaryphone');
     $secondaryphone->setAttrib('maxLength', 15);
     $secondaryphone->addFilter(new Zend_Filter_StringTrim());
     $secondaryphone->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Secondary phone number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Secondary phone number must contain at least %min% characters.')))));
     $secondaryphone->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $checktype = new Zend_Form_Element_Multiselect('bg_checktype');
     $checktype->setRequired(true)->addErrorMessage('Please select screening type.');
     $checktype->addValidator('NotEmpty', false, array('messages' => 'Please select screening type.'));
     $checktypeModal = new Default_Model_Bgscreeningtype();
     $typesData = $checktypeModal->fetchAll('isactive=1', 'type');
     foreach ($typesData->toArray() as $data) {
         $checktype->addMultiOption($data['id'], $data['type']);
     }
     $checktype->setRegisterInArrayValidator(false);
     $emprole = new Zend_Form_Element_Select('emprole');
     $emprole->setRequired(true)->addErrorMessage('Please select role.');
     $emprole->addValidator('NotEmpty', false, array('messages' => 'Please select role.'));
     $emprole->addMultiOption('', 'Select Role');
     $agencyModal = new Default_Model_Agencylist();
     $roleData = $agencyModal->getagencyrole();
     foreach ($roleData as $data) {
         $emprole->addMultiOption($data['id'], $data['rolename']);
     }
     $emprole->setRegisterInArrayValidator(false);
     $website = new Zend_Form_Element_Text('website_url');
     $website->setAttrib('maxLength', 50);
     $website->addFilter(new Zend_Filter_StringTrim());
     $website->setRequired(true);
     $website->addValidator('NotEmpty', false, array('messages' => 'Please enter website URL.'));
     $website->addValidator("regex", true, array('pattern' => '/^(http:\\/\\/www|https:\\/\\/www|www)+\\.([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,3})$/', 'messages' => array('regexNotMatch' => 'Please enter valid URL.')));
     $firstname_1 = new Zend_Form_Element_Text('firstname_1');
     $firstname_1->setAttrib('maxLength', 50);
     $firstname_1->addFilter(new Zend_Filter_StringTrim());
     $firstname_1->setRequired(true);
     $firstname_1->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
     $firstname_1->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_1 = new Zend_Form_Element_Text('lastname_1');
     $lastname_1->setAttrib('maxLength', 50);
     $lastname_1->addFilter(new Zend_Filter_StringTrim());
     $lastname_1->setRequired(true);
     $lastname_1->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
     $lastname_1->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_1 = new Zend_Form_Element_Text('mobile_1');
     $mobile_1->setAttrib('maxLength', 10);
     $mobile_1->addFilter(new Zend_Filter_StringTrim());
     $mobile_1->setRequired(true);
     $mobile_1->addValidator('NotEmpty', false, array('messages' => 'Please enter 10 digit mobile number.'));
     $mobile_1->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_1->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $email_1 = new Zend_Form_Element_Text('email_1');
     $email_1->setAttrib('maxLength', 50);
     $email_1->addFilter(new Zend_Filter_StringTrim());
     $email_1->setRequired(true);
     $email_1->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
     $location_1 = new Zend_Form_Element_Text('location_1');
     $location_1->setAttrib('maxLength', 50);
     $location_1->addFilter(new Zend_Filter_StringTrim());
     $location_1->setRequired(true);
     $location_1->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
     $country_1 = new Zend_Form_Element_Select('country_1');
     $country_1->setLabel('country');
     $country_1->setRequired(true);
     $country_1->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country_1->setAttrib('onchange', 'displayParticularState_normal(this,"","state_1","city_1")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_1->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_1->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $country_1->setRegisterInArrayValidator(false);
     $state_1 = new Zend_Form_Element_Select('state_1');
     $state_1->setAttrib('class', 'selectoption');
     $state_1->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_1","")');
     $state_1->setRegisterInArrayValidator(false);
     $state_1->addMultiOption('', 'Select State');
     $state_1->setRequired(true);
     $state_1->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $city_1 = new Zend_Form_Element_Select('city_1');
     $city_1->setAttrib('class', 'selectoption');
     $city_1->setAttrib('onchange', 'displayCityCode(this)');
     $city_1->setRegisterInArrayValidator(false);
     $city_1->addMultiOption('', 'Select City');
     $city_1->setRequired(true);
     $city_1->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $contact_type_1 = new Zend_Form_Element_Select('contact_type_1');
     $contact_type_1->setLabel('contact_type_1')->setMultiOptions(array('' => 'Select Contact Type', '1' => 'Primary', '2' => 'Secondary'));
     $contact_type_1->setRegisterInArrayValidator(false);
     $contact_type_1->setRequired(true);
     $contact_type_1->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
     $firstname_2 = new Zend_Form_Element_Text('firstname_2');
     $firstname_2->setAttrib('maxLength', 50);
     $firstname_2->addFilter(new Zend_Filter_StringTrim());
     $lastname_2 = new Zend_Form_Element_Text('lastname_2');
     $lastname_2->setAttrib('maxLength', 50);
     $lastname_2->addFilter(new Zend_Filter_StringTrim());
     $mobile_2 = new Zend_Form_Element_Text('mobile_2');
     $mobile_2->setAttrib('maxLength', 10);
     $mobile_2->addFilter(new Zend_Filter_StringTrim());
     $email_2 = new Zend_Form_Element_Text('email_2');
     $email_2->setAttrib('maxLength', 50);
     $email_2->addFilter(new Zend_Filter_StringTrim());
     $location_2 = new Zend_Form_Element_Text('location_2');
     $location_2->setAttrib('maxLength', 50);
     $location_2->addFilter(new Zend_Filter_StringTrim());
     $country_2 = new Zend_Form_Element_Select('country_2');
     $country_2->setLabel('country');
     $country_2->setAttrib('onchange', 'displayParticularState_normal(this,"","state_2","city_2")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_2->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_2->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $state_2 = new Zend_Form_Element_Select('state_2');
     $state_2->setAttrib('class', 'selectoption');
     $state_2->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_2","")');
     $state_2->addMultiOption('', 'Select State');
     $city_2 = new Zend_Form_Element_Select('city_2');
     $city_2->setAttrib('class', 'selectoption');
     $city_2->setAttrib('onchange', 'displayCityCode(this)');
     $city_2->addMultiOption('', 'Select City');
     $contact_type_2 = new Zend_Form_Element_Select('contact_type_2');
     $contact_type_2->setLabel('contact_type_2')->setMultiOptions(array('' => 'select contact type', '1' => 'Primary', '2' => 'Secondary'));
     $secondpocid = new Zend_Form_Element_Hidden('secondpocid');
     $valfirstname_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('firstname_2', null);
     $vallastname_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('lastname_2', null);
     $valmobile_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('mobile_2', null);
     $valemail_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('email_2', null);
     $vallocation_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('location_2', null);
     $valcountry_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('country_2', null);
     $valstate_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('state_2', null);
     $valcity_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('city_2', null);
     $valcontact_type_2 = Zend_Controller_Front::getInstance()->getRequest()->getParam('contact_type_2', null);
     if ($valfirstname_2 != '' || $vallastname_2 != '' || $valmobile_2 != '' || $valemail_2 != '' || $vallocation_2 != '' || $valcountry_2 != '' || $valstate_2 != '' || $valcity_2 != '' || $valcontact_type_2 != '') {
         $firstname_2->setRequired(true);
         $firstname_2->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
         $lastname_2->setRequired(true);
         $lastname_2->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
         $mobile_2->setRequired(true);
         $mobile_2->addValidator('NotEmpty', false, array('messages' => 'Please enter 10 digit mobile number.'));
         $email_2->setRequired(true);
         $email_2->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
         $location_2->setRequired(true);
         $location_2->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
         $country_2->setRequired(true);
         $country_2->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
         $country_2->setRegisterInArrayValidator(false);
         $state_2->setRequired(true);
         $state_2->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
         $state_2->setRegisterInArrayValidator(false);
         $city_2->setRequired(true);
         $city_2->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
         $city_2->setRegisterInArrayValidator(false);
         $contact_type_2->setRequired(true);
         $contact_type_2->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
         $contact_type_2->setRegisterInArrayValidator(false);
     }
     $firstname_2->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_2->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_2->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_2->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $firstname_3 = new Zend_Form_Element_Text('firstname_3');
     $firstname_3->setAttrib('maxLength', 50);
     $firstname_3->addFilter(new Zend_Filter_StringTrim());
     $lastname_3 = new Zend_Form_Element_Text('lastname_3');
     $lastname_3->setAttrib('maxLength', 50);
     $lastname_3->addFilter(new Zend_Filter_StringTrim());
     $mobile_3 = new Zend_Form_Element_Text('mobile_3');
     $mobile_3->setAttrib('maxLength', 10);
     $mobile_3->addFilter(new Zend_Filter_StringTrim());
     $email_3 = new Zend_Form_Element_Text('email_3');
     $email_3->setAttrib('maxLength', 50);
     $email_3->addFilter(new Zend_Filter_StringTrim());
     $location_3 = new Zend_Form_Element_Text('location_3');
     $location_3->setAttrib('maxLength', 50);
     $location_3->addFilter(new Zend_Filter_StringTrim());
     $country_3 = new Zend_Form_Element_Select('country_3');
     $country_3->setLabel('country');
     $country_3->setAttrib('onchange', 'displayParticularState_normal(this,"","state_3","city_3")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->getTotalCountriesList('isactive=1', 'country_name');
     $country_3->addMultiOption('', 'Select country');
     foreach ($countriesData as $data) {
         $country_3->addMultiOption($data['id'], utf8_encode($data['country_name']));
     }
     $state_3 = new Zend_Form_Element_Select('state_3');
     $state_3->setAttrib('class', 'selectoption');
     $state_3->setAttrib('onchange', 'displayParticularCity_normal(this,"","city_3","")');
     $state_3->addMultiOption('', 'Select State');
     $city_3 = new Zend_Form_Element_Select('city_3');
     $city_3->setAttrib('class', 'selectoption');
     $city_3->setAttrib('onchange', 'displayCityCode(this)');
     $city_3->addMultiOption('', 'Select City');
     $contact_type_3 = new Zend_Form_Element_Select('contact_type_3');
     $contact_type_3->setLabel('contact_type_3')->setMultiOptions(array('' => 'select contact type', '1' => 'Primary', '2' => 'Secondary'));
     $thirdpocid = new Zend_Form_Element_Hidden('thirdpocid');
     $thirdData = Zend_Controller_Front::getInstance()->getRequest()->getParam('thirdpocid', null);
     $valfirstname_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('firstname_3', null);
     $vallastname_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('lastname_3', null);
     $valmobile_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('mobile_3', null);
     $valemail_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('email_3', null);
     $vallocation_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('location_3', null);
     $valcountry_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('country_3', null);
     $valstate_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('state_3', null);
     $valcity_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('city_3', null);
     $valcontact_type_3 = Zend_Controller_Front::getInstance()->getRequest()->getParam('contact_type_3', null);
     if ($valfirstname_3 != '' || $vallastname_3 != '' || $valmobile_3 != '' || $valemail_3 != '' || $vallocation_3 != '' || $valcountry_3 != '' || $valstate_3 != '' || $valcity_3 != '' || $valcontact_type_3 != '') {
         $firstname_3->setRequired(true);
         $firstname_3->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.'));
         $lastname_3->setRequired(true);
         $lastname_3->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));
         $mobile_3->setRequired(true);
         $mobile_3->addValidator('NotEmpty', false, array('messages' => 'Please enter  10 digit mobile number.'));
         $email_3->setRequired(true);
         $email_3->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
         $location_3->setRequired(true);
         $location_3->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
         $country_3->setRequired(true);
         $country_3->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
         $country_3->setRegisterInArrayValidator(false);
         $state_3->setRequired(true);
         $state_3->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
         $state_3->setRegisterInArrayValidator(false);
         $city_3->setRequired(true);
         $city_3->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
         $city_3->setRegisterInArrayValidator(false);
         $contact_type_3->setRequired(true);
         $contact_type_3->addValidator('NotEmpty', false, array('messages' => 'Please select contact type.'));
         $contact_type_3->setRegisterInArrayValidator(false);
     }
     $firstname_3->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $lastname_3->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $mobile_3->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Mobile number must contain at most %max% characters', Zend_Validate_StringLength::TOO_SHORT => 'Mobile number must contain at least %min% characters.')))));
     $mobile_3->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $pocid_1, $pocid_2, $pocid_3, $agencyname, $address, $primaryphone, $secondaryphone, $checktype, $website, $firstname_1, $lastname_1, $mobile_1, $email_1, $location_1, $country_1, $state_1, $city_1, $contact_type_1, $firstname_2, $lastname_2, $mobile_2, $email_2, $location_2, $country_2, $state_2, $city_2, $contact_type_2, $secondpocid, $firstname_3, $lastname_3, $mobile_3, $email_3, $location_3, $country_3, $state_3, $city_3, $contact_type_3, $thirdpocid, $emprole, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }