/**
  * This action is used to delete roles and their child data.
  * @parameters
  * @param objid    =   id of role.
  * 
  * @return String    success/failure message 
  */
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $baseUrl = $this->generateBaseurl();
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $actionflag = 3;
     $agencyuser = '******';
     $Id = '';
     if ($id) {
         $user_model = new Default_Model_Usermanagement();
         $menumodel = new Default_Model_Menu();
         $agencylistmodel = new Default_Model_Agencylist();
         $agencyroles = $agencylistmodel->getagencyrole();
         $userData = $user_model->getUserDataById($id);
         $user_role = $userData['emprole'];
         foreach ($agencyroles as $agrole) {
             if ($agrole['id'] == $user_role) {
                 $agencyuser = '******';
             }
         }
         $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $Id = $user_model->SaveorUpdateUserData($data, $where);
         if ($agencyuser == 'yes') {
             $agencyData = $user_model->getAgencyData($id);
             $user_model->deleteAllagencydetails($agencyData['agencyid'], $loginUserId);
             $emailids = $agencylistmodel->getAllHRManagementEMails();
             $this->sendEMails($agencyData, 'inactivated');
         }
         if ($Id == 'update') {
             $objidArr = $menumodel->getMenuObjID('/roles');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'User deleted successfully';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'User cannot be deleted';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'User cannot be deleted';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
    /**
     * @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;
        }
    }
Beispiel #3
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'));
 }