Example #1
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', DOMAIN . 'countries/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'countries');
     $id = new Zend_Form_Element_Hidden('id');
     $country = new Zend_Form_Element_Select('country');
     $country->setAttrib('class', 'selectoption');
     $country->setAttrib('onchange', 'displayCountryCode(this)');
     $country->setRegisterInArrayValidator(false);
     $country->addMultiOption('', 'Select Country');
     $countrymodel = new Default_Model_Countries();
     $id_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null);
     $actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     if ($id_val == '' || $actionName == 'view') {
         $countrymodeldata = $countrymodel->getTotalCountriesList('addcountry');
         foreach ($countrymodeldata as $countryres) {
             $country->addMultiOption($countryres['id'], utf8_encode($countryres['country_name']));
         }
         $country->addMultiOption('other', 'Other');
     }
     $country->setRequired(true);
     $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_countries', 'field' => 'country_id_org', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $country->getValidator('Db_NoRecordExists')->setMessage('Country already exists.');
     $countrycode = new Zend_Form_Element_Text('countrycode');
     $countrycode->setAttrib('maxLength', 20);
     $countrycode->setAttrib('readonly', true);
     $countrycode->setAttrib('onfocus', 'this.blur()');
     $countrycode->setRequired(true);
     $countrycode->addValidator('NotEmpty', false, array('messages' => 'Please enter country code.'));
     $countrycode->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid country code.')));
     $citizenship = new Zend_Form_Element_Text('citizenship');
     $citizenship->setAttrib('maxLength', 20);
     $citizenship->setRequired(true);
     $citizenship->addValidator('NotEmpty', false, array('messages' => 'Please enter citizenship.'));
     $citizenship->addValidator("regex", true, array('pattern' => '/^[a-zA-Z\\s]*$/i', 'messages' => array('regexNotMatch' => 'Please enter valid citizenship.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $country, $countrycode, $citizenship, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
Example #2
0
 public function init()
 {
     $this->setMethod('post');
     $this->setEnctype('multipart/form-data');
     $this->setName('edit_profile_form');
     $this->setAttrib('id', 'edit-profile-form');
     $this->addElementPrefixPath('Oibs_Form_Decorator', 'Oibs/Form/Decorator/', 'decorator');
     $mailvalid = new Zend_Validate_EmailAddress();
     $mailvalid->setMessage('email-invalid', Zend_Validate_EmailAddress::INVALID);
     $mailvalid->setMessage('email-invalid-hostname', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
     $mailvalid->setMessage('email-invalid-mx-record', Zend_Validate_EmailAddress::INVALID_MX_RECORD);
     $mailvalid->setMessage('email-dot-atom', Zend_Validate_EmailAddress::DOT_ATOM);
     $mailvalid->setMessage('email-quoted-string', Zend_Validate_EmailAddress::QUOTED_STRING);
     $mailvalid->setMessage('email-invalid-local-part', Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
     $mailvalid->setMessage('email-length-exceeded', Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
     $mailvalid->hostnameValidator->setMessage('hostname-invalid-hostname', Zend_Validate_Hostname::INVALID_HOSTNAME);
     $mailvalid->hostnameValidator->setMessage('hostname-local-name-not-allowed', Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
     $mailvalid->hostnameValidator->setMessage('hostname-unknown-tld', Zend_Validate_Hostname::UNKNOWN_TLD);
     $mailvalid->hostnameValidator->setMessage('hostname-invalid-local-name', Zend_Validate_Hostname::INVALID_LOCAL_NAME);
     $mailvalid->hostnameValidator->setMessage('hostname-undecipherable-tld', Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
     // Clear div
     $clear = '<div class="clear"></div>';
     // Headers
     $accountInformation = new Oibs_Form_Element_Note('accountinformation');
     $accountInformation->setValue($clear . '<h3>Account information</h3>' . $clear);
     $personalInformation = new Oibs_Form_Element_Note('personalinformation');
     $personalInformation->setValue('<h3>Personal Information</h3>' . $clear);
     $locationInformation = new Oibs_Form_Element_Note('locationinformation');
     $locationInformation->setValue('<h3>Location Information</h3>' . $clear);
     $employmentInformation = new Oibs_Form_Element_Note('employmentinformation');
     $employmentInformation->setValue('<h3>Employment Information</h3>' . $clear);
     $subscribeInformation = new Oibs_Form_Element_Note('subscribeinformation');
     $subscribeInformation->setValue('<h3>Subscribe settings</h3>' . $clear);
     // Public text
     $publictext = 'Public';
     // Username for description
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     $usernametext = $identity->username;
     $username = new Zend_Form_Element_Hidden('username');
     $username->setLabel('Username')->setDescription($usernametext);
     $usernamepublic = new Zend_Form_Element_Hidden('username_publicity');
     $usernamepublic->setLabel($publictext);
     $openid = new Zend_Form_Element_Text('openid');
     $openid->setLabel('Open-ID')->setAttrib('id', 'open-ID')->addValidators(array(new Oibs_Validators_OpenidExists()));
     $openidclear = new Oibs_Form_Element_Note('openidclear');
     $openidclear->setValue($clear);
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('New password')->setAttrib('id', 'password')->addValidators(array(new Oibs_Validators_RepeatValidator('confirm_password'), array('NotEmpty', true, array('messages' => array('isEmpty' => 'Empty'))), array('StringLength', false, array(4, 22, 'messages' => array('stringLengthTooShort' => 'Password too short (4-22 characters)', 'stringLengthTooLong' => 'Password too long (4-22 characters)')))));
     $passwordclear = new Oibs_Form_Element_Note('passwordclear');
     $passwordclear->setValue($clear);
     $confirmpassword = new Zend_Form_Element_Password('confirm_password');
     $confirmpassword->setLabel('Confirm password')->setAttrib('id', 'confirm-password')->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Empty'))), array('StringLength', false, array(4, 22, 'messages' => array('stringLengthTooShort' => 'Password too short (4-22 characters)', 'stringLengthTooLong' => 'Password too long (4-22 characters)')))));
     $confirmpasswordclear = new Oibs_Form_Element_Note('confirm_passwordclear');
     $confirmpasswordclear->setValue($clear);
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel('Email')->setAttrib('id', 'email')->setRequired(true)->addFilter('StringtoLower')->addValidators(array($mailvalid, array('NotEmpty', true, array('messages' => array('isEmpty' => 'Email empty'))), array('StringLength', false, array(6, 50, 'messages' => array('stringLengthTooShort' => 'Email too short (6-50 characters)', 'stringLengthTooLong' => 'Email too long (6-50 characters)')))));
     $emailclear = new Oibs_Form_Element_Note('emailclear');
     $emailclear->setValue($clear);
     $gravatar = new Zend_Form_Element_Hidden('gravatartext');
     $gravatar->setLabel('Gravatar')->setDescription('<div style="text-align: right;">Enable <a href="http://www.gravatar.com">gravatar</a></div>');
     $gravatarcheck = new Zend_Form_Element_Checkbox('gravatar');
     $phone = new Zend_Form_Element_Text('phone');
     $phone->setLabel('Phone')->setAttrib('id', 'phone');
     $phonepublic = new Zend_Form_Element_Checkbox('phone_publicity');
     $phonepublic->setLabel($publictext);
     $firstname = new Zend_Form_Element_Text('firstname');
     $firstname->setLabel('First name')->setAttrib('id', 'first-name');
     $firstnamepublic = new Zend_Form_Element_Checkbox('firstname_publicity');
     $firstnamepublic->setLabel($publictext);
     // DB: surname
     $lastname = new Zend_Form_Element_Text('surname');
     $lastname->setLabel('Last name')->setAttrib('id', 'last-name');
     $lastnamepublic = new Zend_Form_Element_Checkbox('surname_publicity');
     $lastnamepublic->setLabel($publictext);
     $gender = new Zend_Form_Element_Select('gender');
     $gender->setLabel('Gender')->setAttrib('id', 'gender')->addMultiOptions(array('Select', 'Male', 'Female'));
     $genderpublic = new Zend_Form_Element_Checkbox('gender_publicity');
     $genderpublic->setLabel($publictext);
     $birthday = new Zend_Form_Element_Text('birthday');
     $birthday->setLabel('Date of Birth')->setAttrib('id', 'birthday')->setValidators(array(new Zend_Validate_Date('birthday')));
     $birthdaypublic = new Zend_Form_Element_Checkbox('birthday_publicity');
     $birthdaypublic->setLabel($publictext);
     $biography = new Zend_Form_Element_Textarea('biography');
     $biography->setLabel('Biography')->setAttrib('id', 'biography')->setAttrib('rows', 30)->setAttrib('cols', 45)->addValidators(array(array('StringLength', false, array(0, 4000, 'messages' => array('stringLengthTooLong' => 'Biography too long')))));
     //->setDescription('<div id="progressbar_biography" class="progress_ok"></div>');
     $biographypublic = new Zend_Form_Element_Checkbox('biography_publicity');
     $biographypublic->setLabel($publictext);
     $intereststext = new Oibs_Form_Element_Note('intereststext');
     $intereststext->setValue('<div class="input-column1"></div>' . '<div class="input-column2 help">(Use commas to separate tags)</div><div class="clear"></div>');
     $interests = new Zend_Form_Element_Text('interests');
     $interests->setLabel('My interest (tags)')->setAttrib('id', 'interests');
     $interestsclear = new Oibs_Form_Element_Note('interestsclear');
     $interestsclear->setValue($clear);
     $weblinks_websites = new Oibs_Form_Element_Note('weblinks_websites');
     $weblinks_websites->setValue('<div class="input-column-website1"><label><strong>Links to my websites:</strong></label></div>');
     $weblinks_name = new Oibs_Form_Element_Note('weblinks_name');
     $weblinks_name->setValue('<div class="input-column-website2">Name</div>');
     $weblinks_url = new Oibs_Form_Element_Note('weblinks_url');
     $weblinks_url->setValue('<div class="input-column-website3">Url</div><div class="clear"></div>');
     $nameTooLongText = 'Name too long (max 45)';
     $urlTooLongText = 'URL too long (max 150)';
     $weblinks_name_site1 = new Zend_Form_Element_Text('weblinks_name_site1');
     $weblinks_name_site1->setLabel('Web site 1')->setAttrib('id', 'website1-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site1 = new Zend_Form_Element_Text('weblinks_url_site1');
     $weblinks_url_site1->setAttrib('id', 'website1-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site2 = new Zend_Form_Element_Text('weblinks_name_site2');
     $weblinks_name_site2->setLabel('Web site 2')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site2 = new Zend_Form_Element_Text('weblinks_url_site2');
     $weblinks_url_site2->setAttrib('id', 'website2-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site3 = new Zend_Form_Element_Text('weblinks_name_site3');
     $weblinks_name_site3->setLabel('Web site 3')->setAttrib('id', 'website3-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site3 = new Zend_Form_Element_Text('weblinks_url_site3');
     $weblinks_url_site3->setAttrib('id', 'website3-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site4 = new Zend_Form_Element_Text('weblinks_name_site4');
     $weblinks_name_site4->setLabel('Web site 4')->setAttrib('id', 'website4-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site4 = new Zend_Form_Element_Text('weblinks_url_site4');
     $weblinks_url_site4->setAttrib('id', 'website4-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $weblinks_name_site5 = new Zend_Form_Element_Text('weblinks_name_site5');
     $weblinks_name_site5->setLabel('Web site 5')->setAttrib('id', 'website5-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText)))));
     $weblinks_url_site5 = new Zend_Form_Element_Text('weblinks_url_site5');
     $weblinks_url_site5->setAttrib('id', 'website5-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText)))));
     $languages = new Default_Model_Languages();
     $allLanguages = $languages->getAllNamesAndIds();
     $userlanguage = new Zend_Form_Element_Select('userlanguage');
     $userlanguage->setLabel('User interface language')->setAttrib('id', 'user-interface-language')->addMultiOption('', 'Select');
     foreach ($allLanguages as $language) {
         $userlanguage->addMultiOption($language['id_lng'], $language['name_lng']);
     }
     $userlanguageclear = new Oibs_Form_Element_Note('userlanguageclear');
     $userlanguageclear->setValue($clear);
     /*
             $avatar = new Zend_Form_Element_File('avatar');
             $avatar->setLabel('Avatar image');
     */
     // DB: city
     $hometown = new Zend_Form_Element_Text('city');
     $hometown->setLabel('Hometown')->setAttrib('id', 'hometown')->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Hometown empty'))), array('Regex', true, array('/^[\\p{L}0-9.\\- ]*$/'))));
     $hometownpublic = new Zend_Form_Element_Checkbox('city_publicity');
     $hometownpublic->setLabel($publictext);
     $hometownpublic->helper = 'FormHidden';
     $address = new Zend_Form_Element_Text('address');
     $address->setLabel('Address')->setAttrib('id', 'address');
     $addresspublic = new Zend_Form_Element_Checkbox('address_publicity');
     $addresspublic->setLabel($publictext)->setAttrib('checked', 'checked')->setValue(1);
     $addresspublic->helper = 'FormHidden';
     $country_model = new Default_Model_Countries();
     $allCountries = $country_model->getAllCountries();
     $usercountry = new Zend_Form_Element_Select('country');
     $usercountry->setLabel('Country of Residence')->setAttrib('id', 'country')->addMultiOption('', 'Select');
     foreach ($allCountries as $country) {
         $usercountry->addMultiOption($country['iso_ctr'], $country['printable_name_ctr']);
     }
     $usercountrypublic = new Zend_Form_Element_Checkbox('country_publicity');
     $usercountrypublic->setLabel($publictext);
     $timezone_model = new Default_Model_Timezones();
     $allTimezones = $timezone_model->getAllTimezones();
     $usertimezone = new Zend_Form_Element_Select('usertimezone');
     $usertimezone->setLabel('Time Zone')->setAttrib('id', 'time-zone')->addMultiOption('', 'Select');
     foreach ($allTimezones as $timezone) {
         $usertimezone->addMultiOption($timezone['id_tmz'], $timezone['gmt_tmz'] . ' ' . $timezone['timezone_location_tmz']);
     }
     $usertimezonepublic = new Zend_Form_Element_Checkbox('usertimezone_publicity');
     $usertimezonepublic->setLabel($publictext);
     $userProfilesModel = new Default_Model_UserProfiles();
     $employments = $userProfilesModel->getEmployments();
     $employments = array_merge(array('' => 'Select'), $employments);
     $employment = new Zend_Form_Element_Select('employment');
     $employment->setLabel('I am currently')->setAttrib('id', 'status')->setRequired(true)->addMultiOptions($employments)->setErrorMessages(array('Select status'));
     $employmentpublic = new Zend_Form_Element_Checkbox('employment_publicity');
     $employmentpublic->setLabel($publictext);
     // DB: company
     $employer_organization = new Zend_Form_Element_Text('company');
     $employer_organization->setLabel('Employer / Organization')->setAttrib('id', 'employer-organization');
     $employer_organizationpublic = new Zend_Form_Element_Checkbox('company_publicity');
     $employer_organizationpublic->setLabel($publictext);
     //Subscribe things
     $favouritesModel = new Default_Model_UserHasFavourites();
     $subscribeOptions = $favouritesModel->getFollows();
     unset($subscribeOptions['8']);
     //Unsetting the translation box till its in use.
     //print_r($subscribeOptions);die;
     $test = new Zend_Form_Element_MultiCheckbox('lol');
     //$test->setV
     $subscribeClasses = array("own_follows" => "Own contents", "fvr_follows" => "Favourite contents");
     foreach ($subscribeClasses as $key => $value) {
         $subscribe[$key] = new Zend_Form_Element_MultiCheckbox($key);
         $subscribe[$key]->setLabel('Activities you want to follow in your ' . $value);
         $subscribe[$key]->addMultiOptions($subscribeOptions);
     }
     $subscribeclear = new Oibs_Form_Element_Note('subscribeclear');
     $subscribeclear->setValue($clear);
     $save = new Zend_Form_Element_Submit('save');
     $save->setLabel('Save profile')->setAttrib('id', 'save-profile')->setAttrib('class', 'submit-button');
     $cancel = new Zend_Form_Element_Submit('cancel');
     $cancel->setLabel('Cancel')->setAttrib('id', 'cancel')->setAttrib('class', 'submit-button');
     $this->addElements(array($accountInformation, $username, $usernamepublic, $openid, $openidclear, $password, $passwordclear, $confirmpassword, $confirmpasswordclear, $personalInformation, $email, $emailclear, $gravatar, $gravatarcheck, $phone, $phonepublic, $firstname, $firstnamepublic, $lastname, $lastnamepublic, $gender, $genderpublic, $birthday, $birthdaypublic, $biography, $biographypublic, $weblinks_websites, $weblinks_name, $weblinks_url, $weblinks_name_site1, $weblinks_url_site1, $weblinks_name_site2, $weblinks_url_site2, $weblinks_name_site3, $weblinks_url_site3, $weblinks_name_site4, $weblinks_url_site4, $weblinks_name_site5, $weblinks_url_site5, $userlanguage, $userlanguageclear, $locationInformation, $hometown, $hometownpublic, $address, $addresspublic, $usercountry, $usercountrypublic, $usertimezone, $usertimezonepublic, $employmentInformation, $employment, $employmentpublic, $employer_organization, $employer_organizationpublic, $save, $cancel));
     $accountInformation->setDecorators(array('ViewHelper'));
     $personalInformation->setDecorators(array('ViewHelper'));
     $locationInformation->setDecorators(array('ViewHelper'));
     $employmentInformation->setDecorators(array('ViewHelper'));
     $subscribeInformation->setDecorators(array('ViewHelper'));
     $username->setDecorators(array('InputDecorator'));
     $usernamepublic->setDecorators(array('PublicDecorator'));
     $openid->setDecorators(array('InputDecorator'));
     $openidclear->setDecorators(array('ViewHelper'));
     $password->setDecorators(array('InputDecorator'));
     $passwordclear->setDecorators(array('ViewHelper'));
     $confirmpassword->setDecorators(array('InputDecorator'));
     $confirmpasswordclear->setDecorators(array('ViewHelper'));
     $email->setDecorators(array('InputDecorator'));
     $emailclear->setDecorators(array('ViewHelper'));
     $gravatar->setDecorators(array('InputDecorator'));
     $gravatarcheck->setDecorators(array('PublicDecorator'));
     $phone->setDecorators(array('InputDecorator'));
     $phonepublic->setDecorators(array('PublicDecorator'));
     $firstname->setDecorators(array('InputDecorator'));
     $firstnamepublic->setDecorators(array('PublicDecorator'));
     $lastname->setDecorators(array('InputDecorator'));
     $lastnamepublic->setDecorators(array('PublicDecorator'));
     $gender->setDecorators(array('InputDecorator'));
     $genderpublic->setDecorators(array('PublicDecorator'));
     $birthday->setDecorators(array('InputDecorator'));
     $birthdaypublic->setDecorators(array('PublicDecorator'));
     $biography->setDecorators(array('InputDecorator'));
     $biographypublic->setDecorators(array('PublicDecorator'));
     $intereststext->setDecorators(array('ViewHelper'));
     $interests->setDecorators(array('InputDecorator'));
     $interestsclear->setDecorators(array('ViewHelper'));
     $weblinks_websites->setDecorators(array('ViewHelper'));
     $weblinks_name->setDecorators(array('ViewHelper'));
     $weblinks_url->setDecorators(array('ViewHelper'));
     $weblinks_name_site1->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site1->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site2->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site2->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site3->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site3->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site4->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site4->setDecorators(array('InputWebsiteUrlDecorator'));
     $weblinks_name_site5->setDecorators(array('InputWebsiteNameDecorator'));
     $weblinks_url_site5->setDecorators(array('InputWebsiteUrlDecorator'));
     $userlanguage->setDecorators(array('InputDecorator'));
     $userlanguageclear->setDecorators(array('ViewHelper'));
     $hometown->setDecorators(array('InputDecorator'));
     $hometownpublic->setDecorators(array('PublicDecorator'));
     $address->setDecorators(array('InputDecorator'));
     $addresspublic->setDecorators(array('PublicDecorator'));
     $usercountry->setDecorators(array('InputDecorator'));
     $usercountrypublic->setDecorators(array('PublicDecorator'));
     $usertimezone->setDecorators(array('InputDecorator'));
     $usertimezonepublic->setDecorators(array('PublicDecorator'));
     $employment->setDecorators(array('InputDecorator'));
     $employmentpublic->setDecorators(array('PublicDecorator'));
     $employer_organization->setDecorators(array('InputDecorator'));
     $employer_organizationpublic->setDecorators(array('PublicDecorator'));
     $subscribe['own_follows']->setDecorators(array('InputDecorator'));
     $subscribe['fvr_follows']->setDecorators(array('InputDecorator'));
     $subscribeclear->setDecorators(array('ViewHelper'));
     $save->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'openOnly' => true, 'id' => 'save_changes'))));
     $cancel->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'closeOnly' => true))));
     $this->setDecorators(array('FormElements', 'Form'));
 }
 public function viewpopupAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $intrvwModel = new Default_Model_Interviewdetails();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $user_model = new Default_Model_Usermanagement();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $jobtitle = '';
     $deptid = $this->getRequest()->getParam('deptid');
     if ($deptid == '') {
         $deptid = $this->getRequest()->getParam('deptidform');
     }
     $intId = $this->getRequest()->getParam('unitId');
     $roundId = $this->getRequest()->getParam('id');
     $ir_form = new Default_Form_Interviewrounds();
     $elements = $ir_form->getElements();
     //giving only for hr,management and super admin
     if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
         $ir_form->round_status->addMultiOptions(array('Decision pending' => 'Decision pending', 'On hold' => 'On hold'));
     }
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     $intData = $intrvwModel->getReqByintrvwID($intId);
     $roundData = $interview_round_model->getSingleRoundData($roundId);
     $this->view->ermsg = '';
     $edit_flag = 'no';
     if ($roundData['interviewer_id'] == $loginUserId) {
         $edit_flag = 'yes';
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '' || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP) {
         $countryId = $roundData['int_country'];
         $stateId = $roundData['int_state'];
         $cityId = $roundData['int_city'];
         $country_name = '';
         $state_name = '';
         $city_name = '';
         if ($countryId && $stateId) {
             $statesmodel = new Default_Model_States();
             $citiesmodel = new Default_Model_Cities();
             $countryModal = new Default_Model_Countries();
             $countriesData = $countryModal->fetchAll('isactive=1', 'country');
             foreach ($countriesData as $cdata) {
                 if ($roundData['int_country'] == $cdata['country_id_org']) {
                     $country_name = $cdata['country'];
                     break;
                 }
             }
             $statesData = $statesmodel->getBasicStatesList($countryId);
             $citiesData = $citiesmodel->getBasicCitiesList($stateId);
             foreach ($statesData as $res) {
                 $ir_form->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                 if ($roundData['int_state'] == $res['state_id_org']) {
                     $state_name = $res['state'];
                 }
             }
             foreach ($citiesData as $res) {
                 $ir_form->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                 if ($roundData['int_city'] == $res['city_org_id']) {
                     $city_name = $res['city'];
                 }
             }
         }
         $interviewer_data = $user_model->getUserDataById($roundData['interviewer_id']);
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($interviewer_data['jobtitle_id']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = ', ' . $jobttlArr[0]['jobtitlename'];
             $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $ir_form->interviewer_id->addMultiOptions(array('' => $interviewer_data['userfullname'] . $jobtitle));
         $roundData['interview_date'] = sapp_Global::change_date($roundData['interview_date'], 'view');
         $roundData['interview_time'] = sapp_Global::change_time($roundData['interview_time'], 'view');
         $ir_form->populate($roundData);
         $this->view->form = $ir_form;
         $this->view->intId = $intId;
         $this->view->deptid = $deptid;
         $this->view->roundId = $roundId;
         $this->view->ermsg = '';
         $this->view->country_name = $country_name;
         $this->view->state_name = $state_name;
         $this->view->city_name = $city_name;
         $this->view->edit_flag = $edit_flag;
     } else {
         $this->view->ermsg = 'nodata';
     }
 }
 public function comeditAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('empcommunicationdetails', $empOrganizationTabs)) {
             $empDeptdata = array();
             $employeeData = array();
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginuserRole = $auth->getStorage()->read()->emprole;
                 $loginuserGroup = $auth->getStorage()->read()->group_id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $employeeModal = new Default_Model_Employee();
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $empDept = $empdata[0]['department_id'];
                             $empcommdetailsform = new Default_Form_empcommunicationdetails();
                             $empcommdetailsModal = new Default_Model_Empcommunicationdetails();
                             $usersModel = new Default_Model_Users();
                             $countriesModel = new Default_Model_Countries();
                             $statesmodel = new Default_Model_States();
                             $citiesmodel = new Default_Model_Cities();
                             $orgInfoModel = new Default_Model_Organisationinfo();
                             $msgarray = array();
                             $orgid = 1;
                             $countryId = '';
                             $stateId = '';
                             $cityId = '';
                             $deptModel = new Default_Model_Departments();
                             if ($empDept != '' && $empDept != 'NULL') {
                                 $empDeptdata = $deptModel->getEmpdepartmentdetails($empDept);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             } else {
                                 $empDeptdata = $orgInfoModel->getOrganisationDetails($orgid);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             }
                             if ($countryId != '') {
                                 $countryData = $countriesModel->getActiveCountryName($countryId);
                             }
                             if (!empty($countryData)) {
                                 $empDeptdata[0]['country'] = $countryData[0]['country'];
                             } else {
                                 $empDeptdata[0]['country'] = '';
                             }
                             if ($stateId != '') {
                                 $stateData = $statesmodel->getStateNameData($stateId);
                             }
                             if (!empty($stateData)) {
                                 $empDeptdata[0]['state'] = $stateData[0]['state'];
                             } else {
                                 $empDeptdata[0]['state'] = '';
                             }
                             if ($cityId != '') {
                                 $citiesData = $citiesmodel->getCitiesNameData($cityId);
                             }
                             if (!empty($citiesData)) {
                                 $empDeptdata[0]['city'] = $citiesData[0]['city'];
                             } else {
                                 $empDeptdata[0]['city'] = '';
                             }
                             $countrieslistArr = $countriesModel->getTotalCountriesList();
                             if (sizeof($countrieslistArr) > 0) {
                                 $empcommdetailsform->perm_country->addMultiOption('', 'Select Country');
                                 $empcommdetailsform->current_country->addMultiOption('', 'Select Country');
                                 foreach ($countrieslistArr as $countrieslistres) {
                                     $empcommdetailsform->perm_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     $empcommdetailsform->current_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                 }
                             } else {
                                 $msgarray['perm_country'] = 'Countries are not configured yet.';
                                 $msgarray['current_country'] = 'Countries are not configured yet.';
                             }
                             $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id);
                             if (!empty($data)) {
                                 $perm_country = $data[0]['perm_country'];
                                 if (isset($_POST['perm_country'])) {
                                     $perm_country = $_POST['perm_country'];
                                 }
                                 $perm_state = $data[0]['perm_state'];
                                 if (isset($_POST['perm_state'])) {
                                     $perm_state = $_POST['perm_state'];
                                 }
                                 $perm_city = $data[0]['perm_city'];
                                 if (isset($_POST['perm_city'])) {
                                     $perm_city = $_POST['perm_city'];
                                 }
                                 if ($perm_country != '') {
                                     $statePermlistArr = $statesmodel->getStatesList($perm_country);
                                     if (sizeof($statePermlistArr) > 0) {
                                         $empcommdetailsform->perm_state->addMultiOption('', 'Select State');
                                         foreach ($statePermlistArr as $statelistres) {
                                             $empcommdetailsform->perm_state->addMultiOption($statelistres['id'], $statelistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($perm_state != '') {
                                     $cityPermlistArr = $citiesmodel->getCitiesList($perm_state);
                                     if (sizeof($cityPermlistArr) > 0) {
                                         $empcommdetailsform->perm_city->addMultiOption('', 'Select City');
                                         foreach ($cityPermlistArr as $cityPermlistres) {
                                             $empcommdetailsform->perm_city->addMultiOption($cityPermlistres['id'], $cityPermlistres['city_name']);
                                         }
                                     }
                                 }
                                 $current_country = $data[0]['current_country'];
                                 if (isset($_POST['current_country'])) {
                                     $current_country = $_POST['current_country'];
                                 }
                                 $current_state = $data[0]['current_state'];
                                 if (isset($_POST['current_state'])) {
                                     $current_state = $_POST['current_state'];
                                 }
                                 $current_city = $data[0]['current_city'];
                                 if (isset($_POST['current_city'])) {
                                     $current_city = $_POST['current_city'];
                                 }
                                 if ($current_country != '') {
                                     $statecurrlistArr = $statesmodel->getStatesList($current_country);
                                     if (sizeof($statecurrlistArr) > 0) {
                                         $empcommdetailsform->current_state->addMultiOption('', 'Select State');
                                         foreach ($statecurrlistArr as $statecurrlistres) {
                                             $empcommdetailsform->current_state->addMultiOption($statecurrlistres['id'], $statecurrlistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($current_state != '') {
                                     $cityCurrlistArr = $citiesmodel->getCitiesList($current_state);
                                     if (sizeof($cityCurrlistArr) > 0) {
                                         $empcommdetailsform->current_city->addMultiOption('', 'Select City');
                                         foreach ($cityCurrlistArr as $cityCurrlistres) {
                                             $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'], $cityCurrlistres['city_name']);
                                         }
                                     }
                                 }
                                 $empcommdetailsform->populate($data[0]);
                                 $empcommdetailsform->setDefault('perm_country', $perm_country);
                                 $empcommdetailsform->setDefault('perm_state', $perm_state);
                                 $empcommdetailsform->setDefault('perm_city', $perm_city);
                                 if ($data[0]['current_country'] != '') {
                                     $empcommdetailsform->setDefault('current_country', $current_country);
                                 }
                                 if ($data[0]['current_state'] != '') {
                                     $empcommdetailsform->setDefault('current_state', $current_state);
                                 }
                                 if ($data[0]['current_city'] != '') {
                                     $empcommdetailsform->setDefault('current_city', $current_city);
                                 }
                             }
                             $empcommdetailsform->setAttrib('action', DOMAIN . 'myemployees/comedit/userid/' . $id);
                             $empcommdetailsform->user_id->setValue($id);
                             if (!empty($empdata)) {
                                 $this->view->employeedata = $empdata[0];
                             } else {
                                 $this->view->employeedata = $empdata;
                             }
                             if (!empty($empDeptdata)) {
                                 $this->view->dataArray = $empDeptdata[0];
                             } else {
                                 $this->view->dataArray = $empDeptdata;
                             }
                             $this->view->form = $empcommdetailsform;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             if ($this->getRequest()->getPost()) {
                 $result = $this->comsave($empcommdetailsform, $id);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function editpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $orgInfoModel = new Default_Model_Organisationinfo();
     $getorgData = $orgInfoModel->getorgrecords();
     $deptModel = new Default_Model_Departments();
     if (!empty($getorgData)) {
         $orgdata = '';
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $loginUserId = $auth->getStorage()->read()->id;
         }
         $msgarray = array();
         $flag = 'true';
         $bunitid = $this->getRequest()->getParam('unitId');
         $id = intVal($this->getRequest()->getParam('id'));
         $countriesModel = new Default_Model_Countries();
         $statesmodel = new Default_Model_States();
         $citiesmodel = new Default_Model_Cities();
         $timezonemodel = new Default_Model_Timezone();
         $businessunitsmodel = new Default_Model_Businessunits();
         $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray();
         $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray();
         $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray();
         $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray();
         $allBusinessunitsData = $businessunitsmodel->fetchAll('isactive=1', 'unitname')->toArray();
         $deptModel = new Default_Model_Departments();
         $deptform = new Default_Form_departments();
         $deptform->setAction(BASE_URL . 'departments/editpopup/id/' . $id . '/unitId/' . $bunitid);
         $country = $getorgData[0]['country'];
         if (isset($_POST['country'])) {
             $country = $_POST['country'];
         }
         $state = $getorgData[0]['state'];
         if (isset($_POST['state'])) {
             $state = $_POST['state'];
         }
         $city = $getorgData[0]['city'];
         if (isset($_POST['city'])) {
             $city = $_POST['city'];
         }
         $address = $getorgData[0]['address1'];
         //department head data
         $managementUsersData = $deptModel->getDepartmenttHead('');
         foreach ($managementUsersData as $mgmtdata) {
             $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']);
         }
         if (isset($country) && $country != 0 && $country != '') {
             $deptform->setDefault('country', $country);
             $statesData = $statesmodel->getBasicStatesList($country);
             foreach ($statesData as $res) {
                 $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
             }
             if (isset($state) && $state != 0 && $state != '') {
                 $deptform->setDefault('state', $state);
             }
         }
         if (isset($state) && $state != 0 && $state != '') {
             $citiesData = $citiesmodel->getBasicCitiesList($state);
             foreach ($citiesData as $res) {
                 $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
             }
             if (isset($city) && $city != 0 && $city != '') {
                 $deptform->setDefault('city', $city);
             }
         }
         if (isset($address) && $address != '') {
             $deptform->address1->setValue($address);
         }
         $close = '';
         $controllername = 'departments';
         $deptData = array();
         if ($id) {
             $data = $deptModel->getSingleDepartmentData($id);
             if (!empty($data)) {
                 $deptform->populate($data);
                 $deptform->submit->setLabel('Update');
                 $st_date = sapp_Global::change_date($data['startdate'], 'view');
                 $deptform->setDefault('start_date', $st_date);
                 $deptform->setDefault('start_date', $st_date);
                 $deptform->state->clearMultiOptions();
                 $deptform->city->clearMultiOptions();
                 $countryId = $data['country'];
                 if (isset($_POST['country'])) {
                     $countryId = $_POST['country'];
                 }
                 $stateId = $data['state'];
                 if (isset($_POST['state'])) {
                     $stateId = $_POST['state'];
                 }
                 $cityId = $data['city'];
                 if (isset($_POST['city'])) {
                     $cityId = $_POST['city'];
                 }
                 if ($countryId != '') {
                     $statesmodel = new Default_Model_States();
                     $statesData = $statesmodel->getBasicStatesList($countryId);
                     foreach ($statesData as $res) {
                         $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                     }
                 }
                 if ($stateId != '') {
                     $citiesmodel = new Default_Model_Cities();
                     $citiesData = $citiesmodel->getBasicCitiesList($stateId);
                     foreach ($citiesData as $res) {
                         $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                     }
                 }
                 $deptform->setDefault('country', $countryId);
                 $deptform->setDefault('state', $stateId);
                 $deptform->setDefault('city', $cityId);
                 $this->view->ermsg = '';
                 $this->view->datarr = $data;
             } else {
                 $this->view->ermsg = 'nodata';
             }
         }
         $bname = $deptModel->getbusinessunitname($bunitid);
         $this->view->bunitname = $bname;
         $this->view->deptData = sizeof($deptData);
         $this->view->form = $deptform;
         $this->view->unitid = $bunitid;
         $this->view->controllername = $controllername;
         if (!empty($allBusinessunitsData) && !empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData) && !empty($allTimezoneData)) {
             $this->view->configuremsg = '';
         } else {
             $this->view->configuremsg = 'notconfigurable';
         }
         if (empty($allCountriesData)) {
             $msgarray['country'] = 'Countries are not configured yet.';
             $flag = 'false';
         }
         if (empty($allStatesData)) {
             $msgarray['state'] = 'States are not configured yet.';
             $flag = 'false';
         }
         if (empty($allCitiesData)) {
             $msgarray['city'] = 'Cities are not configured yet.';
             $flag = 'false';
         }
         if (empty($allTimezoneData)) {
             $msgarray['timezone'] = 'Time zones are not configured yet.';
             $flag = 'false';
         }
         $this->view->msgarray = $msgarray;
         if ($this->getRequest()->getPost()) {
             if ($deptform->isValid($this->_request->getPost()) && $flag == 'true') {
                 $deptname = $this->_request->getParam('deptname');
                 $deptcode = $this->_request->getParam('deptcode');
                 $description = $this->_request->getParam('description');
                 $start_date = $this->_request->getParam('start_date', null);
                 $start_date = sapp_Global::change_date($start_date, 'database');
                 $country = $this->_request->getParam('country');
                 $state = intval($this->_request->getParam('state'));
                 $city = intval($this->_request->getParam('city'));
                 $address1 = $this->_request->getParam('address1');
                 $address2 = $this->_request->getParam('address2');
                 $address3 = $this->_request->getParam('address3');
                 $unitid = $this->_request->getParam('unitid');
                 $timezone = $this->_request->getParam('timezone');
                 $depthead = $this->_request->getParam('depthead');
                 if (!isset($unitid) || $unitid == '') {
                     $unitid = $bunitid;
                 }
                 $deptcodeExistance = $deptModel->checkCodeDuplicates($deptcode, $id);
                 if (!$deptcodeExistance) {
                     $date = new Zend_Date();
                     $actionflag = '';
                     $tableid = '';
                     $data = array('deptname' => trim($deptname), 'deptcode' => trim($deptcode), 'description' => trim($description), 'startdate' => $start_date != '' ? $start_date : NULL, 'country' => trim($country), 'state' => trim($state), 'city' => trim($city), 'address1' => trim($address1), 'address2' => trim($address2), 'address3' => trim($address3), 'timezone' => trim($timezone), 'unitid' => $unitid, 'depthead' => trim($depthead), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'));
                     if ($id != '') {
                         $where = array('id=?' => $id);
                         $actionflag = 2;
                     } else {
                         $data['createdby'] = $loginUserId;
                         $data['createddate'] = $date->get('yyyy-MM-dd HH:mm:ss');
                         $data['isactive'] = 1;
                         $where = '';
                         $actionflag = 1;
                     }
                     $Id = $deptModel->SaveorUpdateDepartmentsUnits($data, $where);
                     if ($Id == 'update') {
                         $this->view->eventact = 'updated';
                         $tableid = $id;
                     } else {
                         $this->view->eventact = 'added';
                         $tableid = $Id;
                     }
                     $menuID = DEPARTMENTS;
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
                     $close = 'close';
                     $this->view->popup = $close;
                     $this->view->controllername = $controllername;
                 } else {
                     $msgarray['message'] = 'A Department, with the given code, already exists.';
                     $msgarray['msgtype'] = 'error';
                     $this->view->messages = $msgarray;
                 }
             } else {
                 $messages = $deptform->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                     if (empty($allCountriesData)) {
                         $msgarray['country'] = 'Countries are not configured yet.';
                     }
                     if (empty($allStatesData)) {
                         $msgarray['state'] = 'States are not configured yet.';
                     }
                     if (empty($allCitiesData)) {
                         $msgarray['city'] = 'Cities are not configured yet.';
                     }
                     if (empty($allTimezoneData)) {
                         $msgarray['timezone'] = 'Time zones are not configured yet.';
                     }
                 }
                 $this->view->msgarray = $msgarray;
             }
         }
     } else {
         $orgdata = 'noorgdata';
         $this->view->orgdata = $orgdata;
     }
 }
 public function editpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $userid = $this->getRequest()->getParam('unitId');
     if ($id == '') {
         $id = $loginUserId;
     }
     // For open the form in popup...
     $empadditionaldetailsform = new Default_Form_empadditionaldetails();
     $empadditionaldetailsModal = new Default_Model_Empadditionaldetails();
     $countriesModel = new Default_Model_Countries();
     $veteranstatusmodel = new Default_Model_Veteranstatus();
     $militaryservicemodel = new Default_Model_Militaryservice();
     $countrieslistArr = $countriesModel->getTotalCountriesList();
     $empadditionaldetailsform->countries_served->addMultiOption('', 'Select Country');
     if (!empty($countrieslistArr)) {
         foreach ($countrieslistArr as $countrieslistres) {
             $empadditionaldetailsform->countries_served->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     }
     $militaryserviceArr = $militaryservicemodel->getTotalMilitaryServiceData();
     $empadditionaldetailsform->military_servicetype->addMultiOption('', 'Select Service Type');
     if (!empty($militaryserviceArr)) {
         foreach ($militaryserviceArr as $militaryserviceres) {
             $empadditionaldetailsform->military_servicetype->addMultiOption($militaryserviceres['id'], $militaryserviceres['militaryservicetype']);
         }
     }
     $veteranstatusArr = $veteranstatusmodel->getTotalVeteranStatusData();
     $empadditionaldetailsform->veteran_status->addMultiOption('', 'Select Veteran Status');
     if (!empty($veteranstatusArr)) {
         foreach ($veteranstatusArr as $veteranstatusres) {
             $empadditionaldetailsform->veteran_status->addMultiOption($veteranstatusres['id'], $veteranstatusres['veteranstatus']);
         }
     }
     if ($id) {
         $data = $empadditionaldetailsModal->getEmpAdditionalDetailsData($id);
         if (!empty($data)) {
             $empadditionaldetailsform->populate($data[0]);
             $empadditionaldetailsform->setDefault('countries_served', $data[0]['countries_served']);
             $empadditionaldetailsform->setDefault('military_servicetype', $data[0]['military_servicetype']);
             $empadditionaldetailsform->setDefault('veteran_status', $data[0]['veteran_status']);
             $from_date = sapp_Global::change_date($data[0]['from_date'], 'view');
             $to_date = sapp_Global::change_date($data[0]['to_date'], 'view');
             $empadditionaldetailsform->from_date->setValue($from_date);
             $empadditionaldetailsform->to_date->setValue($to_date);
             $this->view->data = $data;
         }
     }
     $empadditionaldetailsform->setAttrib('action', BASE_URL . 'empadditionaldetails/editpopup/unitId/' . $userid);
     $this->view->form = $empadditionaldetailsform;
     $this->view->controllername = 'empadditionaldetails';
     if ($this->getRequest()->getPost()) {
         $result = $this->save($empadditionaldetailsform, $userid);
         $this->view->msgarray = $result;
     }
 }
 public function workeligibilityAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $tabName = "workeligibility";
             $employeeData = array();
             $msgarray = array();
             $emptyFlag = 0;
             $issuingauthority = '';
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $userid = $loginUserId;
             $employeeModal = new Default_Model_Employee();
             $empdata = $employeeModal->getsingleEmployeeData($userid);
             if ($empdata == 'norows') {
                 $this->view->rowexist = "norows";
                 $this->view->empdata = "";
             } else {
                 $this->view->rowexist = "rows";
                 if (!empty($empdata)) {
                     $workeligibilityform = new Default_Form_Workeligibilitydetails();
                     $workeligibilityModel = new Default_Model_Workeligibilitydetails();
                     $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                     //fetchAll($where = null, $order = null, $count = null, $offset = null) function syntax...
                     $workeligibilityDoctypesData = $workeligibilityDoctypesModal->fetchAll('isactive=1', 'documenttype');
                     $workeligibilityDoctypesDataArr = $workeligibilityDoctypesData->toArray();
                     if (!empty($workeligibilityDoctypesDataArr)) {
                         foreach ($workeligibilityDoctypesDataArr as $data) {
                             $workeligibilityform->documenttype_id->addMultiOption($data['id'], $data['documenttype']);
                         }
                     } else {
                         $msgarray['documenttype_id'] = 'Work eligibility document types are not configured yet.';
                         $emptyFlag++;
                     }
                     if ($userid) {
                         $countriesModel = new Default_Model_Countries();
                         $statesmodel = new Default_Model_States();
                         $citiesmodel = new Default_Model_Cities();
                         $countrieslistArr = $countriesModel->getTotalCountriesList();
                         if (sizeof($countrieslistArr) > 0) {
                             $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country');
                             foreach ($countrieslistArr as $countrieslistres) {
                                 $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                             }
                         } else {
                             $msgarray['issuingauth_country'] = 'Countries are not configured yet.';
                             $emptyFlag++;
                         }
                         $data = $workeligibilityModel->getWorkEligibilityRecord($userid);
                         if (!empty($data) && isset($data)) {
                             $countryId = $data[0]['issuingauth_country'];
                             $stateId = $data[0]['issuingauth_state'];
                             $cityId = $data[0]['issuingauth_city'];
                             $documenttype_id = $data[0]['documenttype_id'];
                             //Populating states & cities Drop down......... from tbl_states & tbl_cities
                             if ($countryId != '') {
                                 $statelistArr = $statesmodel->getStatesList($countryId);
                                 if (sizeof($statelistArr) > 0) {
                                     $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State');
                                     foreach ($statelistArr as $statelistres) {
                                         $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                                     }
                                 }
                             }
                             if ($stateId != '') {
                                 $citylistArr = $citiesmodel->getCitiesList($stateId);
                                 if (sizeof($citylistArr) > 0) {
                                     $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City');
                                     foreach ($citylistArr as $cityPermlistres) {
                                         $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                                     }
                                 }
                                 $stateNameArr = $statesmodel->getStateName($stateId);
                             }
                             if ($cityId != '') {
                                 $cityNameArr = $citiesmodel->getCityName($cityId);
                             }
                             if ($documenttype_id != '') {
                                 $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                             }
                             if (!empty($issuingauthorityArr)) {
                                 $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                                 $workeligibilityform->issuingauthflag->setValue($issuingauthority);
                             }
                             $workeligibilityform->setDefault("id", $data[0]["id"]);
                             $workeligibilityform->setDefault("user_id", $data[0]["user_id"]);
                             $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']);
                             if (!empty($stateNameArr)) {
                                 $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']);
                             }
                             if (!empty($cityNameArr)) {
                                 $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']);
                             }
                             $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]);
                             $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]);
                             $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]);
                             $issue_date = sapp_Global::change_date($data[0]["doc_issue_date"], 'view');
                             $workeligibilityform->setDefault('doc_issue_date', $issue_date);
                             $expiry_date = sapp_Global::change_date($data[0]["doc_expiry_date"], 'view');
                             $workeligibilityform->setDefault('doc_expiry_date', $expiry_date);
                         }
                         $workeligibilityform->setAttrib('action', DOMAIN . 'mydetails/workeligibility');
                         $this->view->id = $userid;
                         $this->view->data = $data;
                         $this->view->form = $workeligibilityform;
                         $this->view->issuingauthority = $issuingauthority;
                         $this->view->msgarray = $msgarray;
                     }
                     if ($this->getRequest()->getPost()) {
                         $documenttype_id = $this->_request->getParam('documenttype_id');
                         if ($documenttype_id != '') {
                             $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                         }
                         if (!empty($issuingauthorityArr)) {
                             $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                             if ($issuingauthority == 2) {
                                 $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.');
                                 $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.'));
                             } else {
                                 if ($issuingauthority == 3) {
                                     $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.');
                                     $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.'));
                                     $workeligibilityform->issuingauth_city->setRequired(true)->addErrorMessage('Please select a city.');
                                     $workeligibilityform->issuingauth_city->addValidator('NotEmpty', false, array('messages' => 'Please select a city.'));
                                 }
                             }
                         }
                         $result = $this->save($workeligibilityform, $tabName);
                         $result['issuingauthorityflag'] = $_POST['issuingauthflag'];
                         $this->view->msgarray = $result;
                     }
                 }
                 $this->view->empdata = $empdata;
                 $this->view->emptyFlag = $emptyFlag;
                 $this->view->messages = $this->_helper->flashMessenger->getMessages();
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Example #8
0
 public function addnewstateAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $msgarray = array();
     $controllername = 'states';
     $statestring = '';
     $id = $this->getRequest()->getParam('id');
     $selectedcountryid = $this->_request->getParam('selectcountryid', null);
     $statesform = new Default_Form_states();
     $statesmodel = new Default_Model_States();
     $countriesModel = new Default_Model_Countries();
     /* Changing the form */
     $statesform->setAction(BASE_URL . 'states/addnewstate/selectcountryid/' . $selectedcountryid);
     $statesform->removeElement('state');
     $statesform->addElement('text', 'state', array('label' => 'State', 'maxlength' => '20', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter state name.')))));
     /* END */
     $countrieslistArr = $countriesModel->getTotalCountriesList('');
     if (sizeof($countrieslistArr) > 0) {
         $statesform->countryid->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             if (isset($selectedcountryid)) {
                 if ($countrieslistres['id'] == $selectedcountryid) {
                     $statesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                     $statesform->setDefault('countryid', $selectedcountryid);
                 }
             } else {
                 $statesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
             }
         }
     } else {
         $msgarray['countryid'] = 'Countries are not configured yet';
     }
     if ($this->getRequest()->getPost()) {
         $errorflag = "true";
         $msgarray = array();
         $id = $this->_request->getParam('id');
         $dbstate = '';
         $dbcountryid = '';
         $state = trim($this->_request->getParam('state'));
         $countryid = $this->_request->getParam('countryid');
         if (isset($countryid) && $countryid != '') {
             $isDuplicateStateNameArr = $statesmodel->getDuplicateStateName($state, $countryid);
             if ($isDuplicateStateNameArr[0]['count'] > 0) {
                 $errorflag = "false";
                 $msgarray['state'] = "State already exists.";
             }
         } else {
             $errorflag = "false";
             $msgarray['countryid'] = "Please select country.";
         }
         if ($statesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $NewStateId = $statesmodel->SaveMainStateData($countryid, $state);
             $tableid = $NewStateId;
             $actionflag = 1;
             $menuidArr = $menumodel->getMenuObjID('/states');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             if (isset($selectedcountryid)) {
                 $stateData = $statesmodel->getStatesList($selectedcountryid, '');
             } else {
                 $stateData = array();
             }
             $opt = '';
             foreach ($stateData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['state_name']);
             }
             $this->view->stateData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $statesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
         }
     }
     $this->view->ermsg = '';
     $this->view->form = $statesform;
     $this->view->msgarray = $msgarray;
     $this->view->controllername = $controllername;
 }
Example #9
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setAttrib('name', 'organisationinfo');
     $this->setAttrib('action', DOMAIN . 'organisationinfo/edit');
     $id = new Zend_Form_Element_Hidden('id');
     $orgname = new Zend_Form_Element_Text('organisationname');
     $orgname->setAttrib('maxLength', 50);
     $orgname->addFilter(new Zend_Filter_StringTrim());
     $orgname->setRequired(true);
     $orgname->addValidator('NotEmpty', false, array('messages' => 'Please enter organization name.'));
     $orgname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid organization name.')));
     $domain = new Zend_Form_Element_Multiselect('domain');
     $domain->setRequired(true);
     $domain->addValidator('NotEmpty', false, array('messages' => 'Please select domain.'));
     $domain->setLabel('domain')->setMultiOptions(array('1' => 'Admin/Secretarial', '2' => 'Customer Service/ Call Centre/ BPO', '3' => 'Finance & Accounts', '4' => 'Human Resources', '5' => 'IT', '6' => 'Legal', '7' => 'Marketing & Communications', '8' => 'Purchase/ Logistics/ Supply Chain', '9' => 'Sales/ Business Development', '10' => 'Sales & Marketing & Advertisement'));
     $org_image_value = new Zend_Form_Element_Hidden('org_image_value');
     $imgerr = new Zend_Form_Element_Hidden('imgerr');
     $imgerrmsg = new Zend_Form_Element_Hidden('imgerrmsg');
     $orgdescription = new Zend_Form_Element_Textarea('orgdescription');
     $orgdescription->setAttrib('rows', 10);
     $orgdescription->setAttrib('cols', 50);
     $orgdescription->setRequired(true);
     $orgdescription->addValidator('NotEmpty', false, array('messages' => 'Please enter organization description.'));
     $website = new Zend_Form_Element_Text('website');
     $website->setAttrib('maxLength', 50);
     $website->addFilter(new Zend_Filter_StringTrim());
     $website->setRequired(true);
     $website->addValidator('NotEmpty', false, array('messages' => 'Please enter website.'));
     $website->addValidator(new Zend_Validate_Uri());
     $totalemployees = new Zend_Form_Element_Select('totalemployees');
     $totalemployees->setRegisterInArrayValidator(false);
     $totalemployees->setMultiOptions(array('1' => '20-50', '2' => '51-100', '3' => '101-500', '4' => '501 -1000', '5' => '> 1000'));
     $totalemployees->setRequired(true);
     $totalemployees->addValidator('NotEmpty', false, array('messages' => 'Please enter total employees.'));
     $org_startdate = new ZendX_JQuery_Form_Element_DatePicker('org_startdate');
     $org_startdate->setAttrib('readonly', 'true');
     $org_startdate->setAttrib('onfocus', 'this.blur()');
     $org_startdate->setOptions(array('class' => 'brdr_none'));
     $phonenumber = new Zend_Form_Element_Text('phonenumber');
     $phonenumber->addFilter(new Zend_Filter_StringTrim());
     $phonenumber->setRequired(true);
     $phonenumber->setAttrib('maxLength', 15);
     $phonenumber->addValidator('NotEmpty', false, array('messages' => 'Please enter phone number.'));
     $phonenumber->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Phone number must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Phone number must contain at least %min% characters.')))));
     $phonenumber->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')))));
     $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->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')))));
     $faxnumber = new Zend_Form_Element_Text('faxnumber');
     $faxnumber->setAttrib('maxLength', 15);
     $faxnumber->addFilter(new Zend_Filter_StringTrim());
     $faxnumber->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Fax number must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Fax number must contain at least %min% characters.')))));
     $faxnumber->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid fax number.')))));
     $country = new Zend_Form_Element_Select('country');
     $country->setLabel('country');
     $country->setRequired(true);
     $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country->setAttrib('onchange', 'displayParticularState(this,"state","state","")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->fetchAll('isactive=1', 'country');
     $country->addMultiOption('', 'Select country');
     foreach ($countriesData->toArray() as $data) {
         $country->addMultiOption($data['country_id_org'], $data['country']);
     }
     $country->setRegisterInArrayValidator(false);
     $state = new Zend_Form_Element_Select('state');
     $state->setAttrib('class', 'selectoption');
     $state->setAttrib('onchange', 'displayParticularCity(this,"city","city","")');
     $state->setRegisterInArrayValidator(false);
     $state->addMultiOption('', 'Select State');
     $state->setRequired(true);
     $state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $city = new Zend_Form_Element_Select('city');
     $city->setAttrib('class', 'selectoption');
     $city->setAttrib('onchange', 'displayCityCode(this)');
     $city->setRegisterInArrayValidator(false);
     $city->addMultiOption('', 'Select City');
     $city->setRequired(true);
     $city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $address1 = new Zend_Form_Element_Textarea('address1');
     $address1->setAttrib('rows', 10);
     $address1->setAttrib('cols', 50);
     $address1->setRequired(true);
     $address1->addValidator('NotEmpty', false, array('messages' => 'Please enter main branch address.'));
     $address2 = new Zend_Form_Element_Textarea('address2');
     $address2->setAttrib('rows', 10);
     $address2->setAttrib('cols', 50);
     $address3 = new Zend_Form_Element_Textarea('address3');
     $address3->setAttrib('rows', 10);
     $address3->setAttrib('cols', 50);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setAttrib('rows', 10);
     $description->setAttrib('cols', 50);
     $orghead = new Zend_Form_Element_Select('orghead');
     $orghead->setLabel('orghead');
     $orghead->setRequired(true);
     $orghead->addValidator('NotEmpty', false, array('messages' => 'Please select organization head.'));
     $orghead->setAttrib('onchange', 'getdetailsoforghead(this)');
     $orghead->setRegisterInArrayValidator(false);
     $prevorgheadrm = new Zend_Form_Element_Select('prevorgheadrm');
     $prevorgheadrm->setLabel('orghead');
     $prevorgheadrm->setRegisterInArrayValidator(false);
     $rmflag = Zend_Controller_Front::getInstance()->getRequest()->getParam('rmflag', null);
     if ($rmflag == '1') {
         $prevorgheadrm->setRequired(true);
         $prevorgheadrm->addValidator('NotEmpty', false, array('messages' => 'Please select reporting manager for current organization head.'));
     }
     $designation = new Zend_Form_Element_Text('designation');
     $designation->setAttrib('maxLength', 50);
     $designation->addFilter(new Zend_Filter_StringTrim());
     $designation->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid designation.')));
     $employeeId = new Zend_Form_Element_Text("employeeId");
     $employeeId->setRequired("true");
     $employeeId->setLabel("Employee ID");
     $employeeId->setAttrib("class", "formDataElement");
     $employeeId->setAttrib("readonly", "readonly");
     $employeeId->setAttrib('onfocus', 'this.blur()');
     $employeeId->addValidator('NotEmpty', false, array('messages' => 'Identity codes are not configured yet.'));
     $prefix_id = new Zend_Form_Element_Select('prefix_id');
     $prefix_id->setLabel("Prefix");
     $prefix_id->setRegisterInArrayValidator(false);
     $emprole = new Zend_Form_Element_Select("emprole");
     $emprole->setRegisterInArrayValidator(false);
     $emprole->setRequired(true);
     $emprole->setLabel("Role");
     $emprole->setAttrib("class", "formDataElement");
     $emprole->addValidator('NotEmpty', false, array('messages' => 'Please select role.'));
     $emailaddress = new Zend_Form_Element_Text("emailaddress");
     $emailaddress->setRequired(true);
     $emailaddress->addValidator('NotEmpty', false, array('messages' => 'Please enter email.'));
     $emailaddress->addValidator("regex", true, array('pattern' => '/^(?!.*\\.{2})[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid email.')));
     $emailaddress->setLabel("Email");
     $emailaddress->setAttrib("class", "formDataElement");
     $emailaddress->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_users', 'field' => 'emailaddress', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('orghead', 0) . '" and isactive!=0')));
     $emailaddress->getValidator('Db_NoRecordExists')->setMessage('Email already exists.');
     $jobtitle = new Zend_Form_Element_Select('jobtitle_id');
     $jobtitle->setLabel("Job Title");
     $jobtitle->addMultiOption('', 'Select Job Title');
     $jobtitle->setAttrib('onchange', 'displayPositions(this,"position_id","")');
     $jobtitle->setRegisterInArrayValidator(false);
     $position = new Zend_Form_Element_Select('position_id');
     $position->setLabel("Position");
     $position->addMultiOption('', 'Select Position');
     $position->setRegisterInArrayValidator(false);
     $date_of_joining = new ZendX_JQuery_Form_Element_DatePicker('date_of_joining');
     $date_of_joining->setLabel("Date Of Joining");
     $date_of_joining->setOptions(array('class' => 'brdr_none'));
     $date_of_joining->setRequired(true);
     $date_of_joining->setAttrib('readonly', 'true');
     $date_of_joining->setAttrib('onfocus', 'this.blur()');
     $date_of_joining->addValidator('NotEmpty', false, array('messages' => 'Please select date of joining.'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $prevorgheadrm, $orgname, $imgerrmsg, $imgerr, $org_image_value, $domain, $orgdescription, $website, $totalemployees, $org_startdate, $phonenumber, $secondaryphone, $faxnumber, $country, $state, $city, $address1, $address2, $address3, $description, $orghead, $designation, $employeeId, $prefix_id, $emprole, $emailaddress, $jobtitle, $position, $date_of_joining, $submit));
     //$email,$secondaryemail,
     $this->setElementDecorators(array('ViewHelper'));
     $this->setElementDecorators(array('File'), array('org_image'));
     $this->setElementDecorators(array('UiWidgetElement'), array('org_startdate', 'date_of_joining'));
 }
Example #10
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setAttrib('name', 'organisationinfo');
     $this->setAttrib('action', DOMAIN . 'organisationinfo/edit');
     $id = new Zend_Form_Element_Hidden('id');
     $orgname = new Zend_Form_Element_Text('organisationname');
     $orgname->setAttrib('maxLength', 50);
     $orgname->addFilter(new Zend_Filter_StringTrim());
     $orgname->setRequired(true);
     $orgname->addValidator('NotEmpty', false, array('messages' => 'Please enter organization name.'));
     $orgname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid organization name.')));
     $domain = new Zend_Form_Element_Multiselect('domain');
     $domain->setLabel('domain')->setMultiOptions(array('1' => 'Admin/Secretarial', '2' => 'Customer Service/ Call Centre/ BPO', '3' => 'Finance & Accounts', '4' => 'Human Resources', '5' => 'IT', '6' => 'Legal', '7' => 'Marketing & Communications', '8' => 'Purchase/ Logistics/ Supply Chain', '9' => 'Sales/ Business Development', '10' => 'Sales & Marketing & Advertisement'));
     $org_image_value = new Zend_Form_Element_Hidden('org_image_value');
     $imgerr = new Zend_Form_Element_Hidden('imgerr');
     $imgerrmsg = new Zend_Form_Element_Hidden('imgerrmsg');
     $orgdescription = new Zend_Form_Element_Textarea('orgdescription');
     $orgdescription->setAttrib('rows', 10);
     $orgdescription->setAttrib('cols', 50);
     $website = new Zend_Form_Element_Text('website');
     $website->setAttrib('maxLength', 50);
     $website->addFilter(new Zend_Filter_StringTrim());
     $website->setRequired(true);
     $website->addValidator('NotEmpty', false, array('messages' => 'Please enter website.'));
     $website->addValidator(new Zend_Validate_Uri());
     $totalemployees = new Zend_Form_Element_Select('totalemployees');
     $totalemployees->setRegisterInArrayValidator(false);
     $totalemployees->setMultiOptions(array('1' => '20-50', '2' => '51-100', '3' => '101-500', '4' => '501 -1000', '5' => '> 1000'));
     $totalemployees->setRequired(true);
     $totalemployees->addValidator('NotEmpty', false, array('messages' => 'Please enter total employees.'));
     $org_startdate = new ZendX_JQuery_Form_Element_DatePicker('org_startdate');
     $org_startdate->setAttrib('readonly', 'true');
     $org_startdate->setAttrib('onfocus', 'this.blur()');
     $org_startdate->setOptions(array('class' => 'brdr_none'));
     $phonenumber = new Zend_Form_Element_Text('phonenumber');
     $phonenumber->addFilter(new Zend_Filter_StringTrim());
     $phonenumber->setAttrib('maxLength', 15);
     $phonenumber->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Phone number must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Phone number must contain at least %min% characters.')))));
     $phonenumber->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')))));
     $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->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.')))));
     $faxnumber = new Zend_Form_Element_Text('faxnumber');
     $faxnumber->setAttrib('maxLength', 15);
     $faxnumber->addFilter(new Zend_Filter_StringTrim());
     $faxnumber->addValidators(array(array('StringLength', false, array('min' => 10, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Fax number must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Fax number must contain at least %min% characters.')))));
     $faxnumber->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[0-9-]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid fax number.')))));
     $country = new Zend_Form_Element_Select('country');
     $country->setLabel('country');
     $country->setRequired(true);
     $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country->setAttrib('onchange', 'displayParticularState(this,"state","state","")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->fetchAll('isactive=1', 'country');
     $country->addMultiOption('', 'Select country');
     foreach ($countriesData->toArray() as $data) {
         $country->addMultiOption($data['country_id_org'], $data['country']);
     }
     $country->setRegisterInArrayValidator(false);
     $state = new Zend_Form_Element_Select('state');
     $state->setAttrib('class', 'selectoption');
     $state->setAttrib('onchange', 'displayParticularCity(this,"city","city","")');
     $state->setRegisterInArrayValidator(false);
     $state->addMultiOption('', 'Select State');
     $state->setRequired(true);
     $state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $city = new Zend_Form_Element_Select('city');
     $city->setAttrib('class', 'selectoption');
     $city->setAttrib('onchange', 'displayCityCode(this)');
     $city->setRegisterInArrayValidator(false);
     $city->addMultiOption('', 'Select City');
     $city->setRequired(true);
     $city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $address1 = new Zend_Form_Element_Textarea('address1');
     $address1->setAttrib('rows', 10);
     $address1->setAttrib('cols', 50);
     $address2 = new Zend_Form_Element_Textarea('address2');
     $address2->setAttrib('rows', 10);
     $address2->setAttrib('cols', 50);
     $address3 = new Zend_Form_Element_Textarea('address3');
     $address3->setAttrib('rows', 10);
     $address3->setAttrib('cols', 50);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setAttrib('rows', 10);
     $description->setAttrib('cols', 50);
     $designation = new Zend_Form_Element_Text('designation');
     $designation->setAttrib('maxLength', 50);
     $designation->addFilter(new Zend_Filter_StringTrim());
     $designation->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid designation.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $orgname, $imgerrmsg, $imgerr, $org_image_value, $domain, $orgdescription, $website, $totalemployees, $org_startdate, $phonenumber, $secondaryphone, $faxnumber, $country, $state, $city, $address1, $address2, $address3, $description, $designation, $submit));
     //$email,$secondaryemail,
     $this->setElementDecorators(array('ViewHelper'));
     $this->setElementDecorators(array('File'), array('org_image'));
     $this->setElementDecorators(array('UiWidgetElement'), array('org_startdate', 'date_of_joining'));
 }
Example #11
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'frm_sinterview_rounds');
     $id = new Zend_Form_Element_Hidden('id');
     $req_id = new Zend_Form_Element_Select("req_id");
     $req_id->setRegisterInArrayValidator(false);
     $req_id->setRequired(true);
     $req_id->setAttrib("class", "formDataElement");
     $req_id->addValidator('NotEmpty', false, array('messages' => 'Please select requisition id.'));
     $req_id->setAttrib('title', 'Interviewer');
     $req_id->setAttrib('onchange', 'displayParticularCandidates(this,"")');
     $candidate_name = new Zend_Form_Element_Select('candidate_name');
     $candidate_name->setAttrib('title', 'Candidate Name');
     $candidate_name->addFilter(new Zend_Filter_StringTrim());
     $candidate_name->setRequired(true);
     $candidate_name->addValidator('NotEmpty', false, array('messages' => 'Please select candidate.'));
     $candidate_name->addMultiOption('', 'Select candidate');
     $candidate_name->setRegisterInArrayValidator(false);
     $interviewer_id = new Zend_Form_Element_Select("interviewer_id");
     $interviewer_id->setRegisterInArrayValidator(false);
     $interviewer_id->setAttrib("class", "formDataElement");
     $interviewer_id->setAttrib('title', 'Interviewer');
     $interview_mode = new Zend_Form_Element_Select("interview_mode");
     $interview_mode->setRegisterInArrayValidator(true);
     $interview_mode->setAttrib("class", "formDataElement");
     $interview_mode->addMultiOptions(array('' => 'Select Interview Type', 'In person' => 'In person', 'Phone' => 'Phone', 'Video conference' => 'Video conference'));
     $interview_mode->setAttrib('title', 'Interview Type');
     $int_location = new Zend_Form_Element_Text('int_location');
     $int_location->setAttrib('maxLength', 100);
     $int_location->setAttrib('title', 'Location');
     $int_location->addFilter(new Zend_Filter_StringTrim());
     $job_title = new Zend_Form_Element_Text('job_title');
     $job_title->setAttrib('readonly', 'readonly');
     $country = new Zend_Form_Element_Select('country');
     $country->setLabel('country');
     $country->setAttrib('onchange', 'displayParticularState_normal(this,"state","state","city")');
     $country->setRegisterInArrayValidator(false);
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->fetchAll('isactive=1', 'country');
     $country->addMultiOption('', 'Select country');
     foreach ($countriesData->toArray() as $data) {
         $country->addMultiOption(trim($data['country_id_org']), $data['country']);
     }
     $state = new Zend_Form_Element_Select('state');
     $state->setAttrib('onchange', 'displayParticularCity_normal(this,"city","city","")');
     $state->setRegisterInArrayValidator(false);
     $state->addMultiOption('', 'Select State');
     $city = new Zend_Form_Element_Select('city');
     $city->setAttrib('class', 'selectoption');
     $city->setAttrib('onchange', 'displayCityCode(this)');
     $city->setRegisterInArrayValidator(false);
     $city->addMultiOption('', 'Select City');
     $interview_time = new Zend_Form_Element_Text('interview_time');
     $interview_time->setAttrib('title', 'Interview Time');
     $interview_time->setAttrib('readonly', 'readonly');
     $interview_time->setAttrib('onfocus', 'this.blur()');
     $interview_time->setAttrib('class', 'time');
     $interview_time->addFilter(new Zend_Filter_StringTrim());
     $interview_date = new Zend_Form_Element_Text('interview_date');
     $interview_date->setAttrib('readonly', 'readonly');
     $interview_date->setAttrib('onfocus', 'this.blur()');
     $interview_date->setAttrib('title', 'Interview Date');
     $interview_date->addFilter(new Zend_Filter_StringTrim());
     $interview_round = new Zend_Form_Element_Text('interview_round');
     $interview_round->setAttrib('title', 'Interview Round');
     $interview_round->addFilter(new Zend_Filter_StringTrim());
     $interview_round->setAttrib('maxlength', 45);
     $interview_feedback = new Zend_Form_Element_Textarea('interview_feedback');
     $interview_feedback->setAttrib('rows', 10);
     $interview_feedback->setAttrib('cols', 50);
     $interview_feedback->setAttrib('maxlength', 300);
     $interview_feedback->setAttrib('title', 'Feedback.');
     $interview_comments = new Zend_Form_Element_Textarea('interview_comments');
     $interview_comments->setAttrib('rows', 10);
     $interview_comments->setAttrib('cols', 50);
     $interview_comments->setAttrib('maxlength', 300);
     $interview_comments->setAttrib('title', 'Comments.');
     $round_status = new Zend_Form_Element_Select('round_status');
     $round_status->setRegisterInArrayValidator(false);
     $round_status->setLabel('Round status');
     $round_status->addMultiOptions(array('' => 'Select status', 'Schedule for next round' => 'Schedule for next round', 'Qualified' => 'Qualified', 'Selected' => 'Selected', 'Disqualified' => 'Disqualified', 'Incompetent' => 'Incompetent', 'Ineligible' => 'Ineligible', 'Candidate no show' => 'Candidate no show'));
     $hid_round_status_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('hid_round_status', null);
     $interview_status = new Zend_Form_Element_Select('interview_status');
     $interview_status->setLabel('Interview status')->setMultiOptions(array('' => 'Select status', 'In process' => 'In process', 'Completed' => 'Complete', 'On hold' => 'On hold'));
     $interview_status->setRegisterInArrayValidator(false);
     $cand_status = new Zend_Form_Element_Select('cand_status');
     $cand_status->setLabel('Candidate status')->setMultiOptions(array('' => 'Select status'));
     $cand_status->setRegisterInArrayValidator(false);
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $intrvid_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('intrvid', null);
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $intrvid_val == $loginUserId) {
         $round_status->setRequired(true);
         $round_status->addValidator('NotEmpty', false, array('messages' => 'Please select status.'));
         $interview_comments->setRequired(true);
         $interview_comments->addValidator('NotEmpty', false, array('messages' => 'Please select comments.'));
         $interview_feedback->setRequired(true);
         $interview_feedback->addValidator('NotEmpty', false, array('messages' => 'Please select feedback.'));
     }
     if (($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '') && $intrvid_val != $loginUserId) {
         if ($hid_round_status_val != '' && ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '')) {
             $round_status->setRequired(true);
             $round_status->addValidator('NotEmpty', false, array('messages' => 'Please select status.'));
         } else {
             $interview_status->setRequired(true);
             $interview_status->addValidator('NotEmpty', false, array('messages' => 'Please select interview status.'));
             $cand_status->setRequired(true);
             $cand_status->addValidator('NotEmpty', false, array('messages' => 'Please select candidate status.'));
             $interviewer_id->setRequired(true);
             $interviewer_id->addValidator('NotEmpty', false, array('messages' => 'Please select interviewer.'));
             $interview_mode->setRequired(true);
             $interview_mode->addValidator('NotEmpty', false, array('messages' => 'Please select interview type.'));
             $int_location->setRequired(true);
             $int_location->addValidator('NotEmpty', false, array('messages' => 'Please enter location.'));
             $country->setRequired(true);
             $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
             $state->setRequired(true);
             $state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
             $city->setRequired(true);
             $city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
             $interview_time->setRequired(true);
             $interview_time->addValidator('NotEmpty', false, array('messages' => 'Please select interview time.'));
             $interview_date->setRequired(true);
             $interview_date->addValidator('NotEmpty', false, array('messages' => 'Please select interview date.'));
             $interview_round->setRequired(true);
             $interview_round->addValidator('NotEmpty', false, array('messages' => 'Please select interview name.'));
         }
     }
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Update');
     $int_location->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid location.')));
     $interview_round->addValidator("regex", true, array('pattern' => '/^[0-9a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please select valid interview name.')));
     $this->addElements(array($req_id, $id, $candidate_name, $job_title, $interviewer_id, $interview_mode, $int_location, $country, $state, $city, $interview_time, $interview_date, $round_status, $interview_feedback, $interview_comments, $interview_round, $interview_status, $cand_status, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
 public function edit_oldAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     $empid = '';
     $orgheadsData = array();
     $oldOrgHead = '';
     $new_stateId = '';
     $actionpage = '';
     if (sapp_Global::_checkprivileges(PREFIX, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'prefix');
     }
     if (sapp_Global::_checkprivileges(IDENTITYCODES, $loginuserGroup, $loginuserRole, 'edit') == 'Yes') {
         array_push($popConfigPermission, 'identitycodes');
     }
     if (sapp_Global::_checkprivileges(JOBTITLES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'jobtitles');
     }
     if (sapp_Global::_checkprivileges(POSITIONS, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'position');
     }
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     if (sapp_Global::_checkprivileges(EMPLOYEE, $loginuserGroup, $loginuserRole, 'edit') == 'Yes') {
         array_push($popConfigPermission, 'employee');
     }
     $msgarray = array();
     $new_stateId = '';
     $new_cityId = '';
     $id = $this->getRequest()->getParam('id');
     $form = new Default_Form_Organisationinfo();
     $user_model = new Default_Model_Usermanagement();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $countriesModel = new Default_Model_Countries();
     $statesmodel = new Default_Model_States();
     $citiesmodel = new Default_Model_Cities();
     $role_model = new Default_Model_Roles();
     $prefixModel = new Default_Model_Prefix();
     $identity_code_model = new Default_Model_Identitycodes();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $employeeModal = new Default_Model_Employee();
     $positionsmodel = new Default_Model_Positions();
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $role_data = $role_model->getRolesList_orginfo();
     $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray();
     $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray();
     $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray();
     $flag = 'true';
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
         $flag = 'false';
     }
     $form->employeeId->setValue($emp_id);
     $form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
     if (empty($allCountriesData)) {
         $msgarray['country'] = 'Countries are not configured yet.';
         $flag = 'false';
     }
     if (empty($role_data)) {
         $msgarray['emprole'] = 'Roles are not added yet.';
         $flag = 'false';
     }
     if (empty($allStatesData)) {
         $msgarray['state'] = 'States are not configured yet.';
         $flag = 'false';
     }
     if (empty($allCitiesData)) {
         $msgarray['city'] = 'Cities are not configured yet.';
         $flag = 'false';
     }
     $prefixData = $prefixModel->getPrefixList();
     $form->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
     }
     $orgheadsData = $employeeModal->getEmployeesForOrgHead();
     $currentOrgHead = $employeeModal->getCurrentOrgHead();
     if (!empty($currentOrgHead)) {
         $oldOrgHead = $currentOrgHead[0]['user_id'];
     }
     if ($id) {
         $form->submit->setLabel('Update');
         try {
             $data = $orgInfoModel->getOrganisationData($id);
             $form->setAttrib('action', BASE_URL . 'organisationinfo/edit/id/' . $id);
             $data['org_startdate'] = sapp_Global::change_date($data['org_startdate'], 'view');
             $form->populate($data);
             $countryId = $data['country'];
             $stateId = $data['state'];
             $cityId = $data['city'];
             $actionpage = 'edit';
             if (count($_POST) > 0) {
                 $countryId = isset($_POST['country']) ? $_POST['country'] : "";
                 $stateId = isset($_POST['state']) ? $_POST['state'] : "";
                 $cityId = isset($_POST['city']) ? $_POST['city'] : "";
             }
             if ($countryId != '') {
                 $statesData = $statesmodel->getBasicStatesList((int) $countryId);
                 foreach ($statesData as $res) {
                     if ($stateId == $res['state_id_org']) {
                         $new_stateId = $res['state_id_org'] . '!@#' . utf8_encode($res['state']);
                     }
                     $form->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state']));
                 }
                 if (count($_POST) == 0) {
                     $stateId = $new_stateId;
                 }
             }
             if ($stateId != '') {
                 $citiesData = $citiesmodel->getBasicCitiesList((int) $stateId);
                 foreach ($citiesData as $res) {
                     if ($cityId == $res['city_org_id']) {
                         $new_cityId = $res['city_org_id'] . '!@#' . utf8_encode($res['city']);
                     }
                     $form->city->addMultiOption($res['city_org_id'] . '!@#' . utf8_encode($res['city']), utf8_encode($res['city']));
                 }
                 if (count($_POST) == 0) {
                     $cityId = $new_cityId;
                 }
             }
             $emp_data = $employeeModal->fetchRow("is_orghead = 1");
             if (!empty($emp_data)) {
                 $user_data = $user_model->fetchRow("id = " . $emp_data->user_id);
                 if (!empty($user_data)) {
                     $form->setDefault('firstname_orghead', $user_data->firstname);
                     $form->setDefault('lastname_orghead', $user_data->lastname);
                     $form->setDefault('employeeId', $user_data->employeeId);
                     $form->setDefault('emprole', $user_data->emprole);
                     $form->setDefault('emailaddress', $user_data->emailaddress);
                     $form->setDefault('jobtitle_id', $user_data->jobtitle_id);
                     $form->setDefault('prefix_id', $emp_data->prefix_id);
                     $form->setDefault('date_of_joining', sapp_Global::change_date($emp_data->date_of_joining, 'view'));
                     $jobtitle_id = $emp_data->jobtitle_id;
                     if (isset($_POST['jobtitle_id'])) {
                         $jobtitle_id = $_POST['jobtitle_id'];
                     }
                     $form->position_id->addMultiOption('', 'Select a Position');
                     if ($jobtitle_id != '') {
                         $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
                         if (sizeof($positionlistArr) > 0) {
                             foreach ($positionlistArr as $positionlistres) {
                                 $form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                             }
                         }
                     }
                     $form->setDefault('position_id', $emp_data->position_id);
                     $form->setDefault('orghead', $user_data->id);
                 }
                 $empid = $emp_data->user_id;
             } else {
                 $form->setDefault('orghead', '');
             }
             if (empty($orgheadsData)) {
                 $msgarray['orghead'] = 'Management employees are not added yet.';
             }
             $form->setDefault('country', $countryId);
             $form->setDefault('state', $stateId);
             $form->setDefault('city', $cityId);
             $this->view->domainValue = $data['domain'];
             $this->view->org_image = $data['org_image'];
             $this->view->ermsg = '';
             $this->view->datarr = $data;
             $this->view->user_id = $empid;
             $this->view->orgheadsData = $orgheadsData;
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $actionpage = 'add';
         $activeOrgs = $orgInfoModel->getorgrecords();
         if (empty($activeOrgs)) {
             $form->setAttrib('action', BASE_URL . 'organisationinfo/edit');
             $country = $this->_request->getParam('country');
             $state = intVal($this->_request->getParam('state'));
             $city = intVal($this->_request->getParam('city'));
             if (isset($country) && $country != 0 && $country != '') {
                 $statesData = $statesmodel->getBasicStatesList($country);
                 foreach ($statesData as $res) {
                     $form->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state']));
                 }
                 if (isset($state) && $state != 0 && $state != '') {
                     $form->setDefault('state', $state);
                 }
             }
             if (isset($state) && $state != 0 && $state != '') {
                 $citiesData = $citiesmodel->getBasicCitiesList($state);
                 foreach ($citiesData as $res) {
                     $form->city->addMultiOption($res['city_org_id'] . '!@#' . utf8_encode($res['city']), utf8_encode($res['city']));
                 }
                 if (isset($city) && $city != 0 && $city != '') {
                     $form->setDefault('city', $city);
                 }
             }
             $this->view->ermsg = '';
         } else {
             $this->view->ermsg = 'cannotadd';
         }
         $form->position_id->addMultiOption('', 'Select a Position');
         if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
             $jobtitle_id = $_POST['jobtitle_id'];
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             if (sizeof($positionlistArr) > 0) {
                 foreach ($positionlistArr as $positionlistres) {
                     $form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                 }
             }
         }
         $emp_data = $employeeModal->fetchRow("is_orghead = 1");
         if (!empty($emp_data)) {
             $user_data = $user_model->fetchRow("id = " . $emp_data->user_id);
             if (!empty($user_data)) {
                 $form->setDefault('employeeId', $user_data->employeeId);
                 $form->setDefault('emprole', $user_data->emprole);
                 $form->setDefault('emailaddress', $user_data->emailaddress);
                 $form->setDefault('jobtitle_id', $user_data->jobtitle_id);
                 $form->setDefault('prefix_id', $emp_data->prefix_id);
                 $form->setDefault('date_of_joining', sapp_Global::change_date($emp_data->date_of_joining, 'view'));
                 $jobtitle_id = $emp_data->jobtitle_id;
                 if (isset($_POST['jobtitle_id'])) {
                     $jobtitle_id = $_POST['jobtitle_id'];
                 }
                 $form->position_id->addMultiOption('', 'Select a Position');
                 if ($jobtitle_id != '') {
                     $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
                     if (sizeof($positionlistArr) > 0) {
                         foreach ($positionlistArr as $positionlistres) {
                             $form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                         }
                     }
                 }
                 $form->setDefault('position_id', $emp_data->position_id);
                 $form->setDefault('orghead', $user_data->id);
             }
             $empid = $emp_data->user_id;
         } else {
             $form->setDefault('orghead', '');
         }
         if (empty($orgheadsData)) {
             $msgarray['orghead'] = 'Management employees are not added yet.';
         }
         $this->view->user_id = $empid;
         $this->view->orgheadsData = $orgheadsData;
     }
     $this->view->form = $form;
     $this->view->currentOrgHead = $currentOrgHead;
     $this->view->actionpage = $actionpage;
     if (!empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData)) {
         $this->view->configuremsg = '';
     } else {
         $this->view->configuremsg = 'notconfigurable';
     }
     if (isset($_POST['prevorgheadrm'])) {
         $prevorgheadrm = $this->_request->getParam('prevorgheadrm');
     } else {
         $prevorgheadrm = '';
     }
     $this->view->prevorgheadrmval = $prevorgheadrm;
     if (isset($_POST['rmflag'])) {
         $rmflag = $this->_request->getParam('rmflag');
     } else {
         $rmflag = '0';
     }
     $this->view->rmflag = $rmflag;
     if ($this->getRequest()->getPost()) {
         $imagerror = $this->_request->getParam('imgerr');
         $imagepath = $this->_request->getParam('org_image_value');
         $imgerrmsg = $this->_request->getParam('imgerrmsg');
         $pphnumber = $this->_request->getParam('phonenumber');
         $sphnumber = $this->_request->getParam('secondaryphone');
         $org_startdate = sapp_Global::change_date($this->_request->getParam('org_startdate'), 'database');
         $flag = 'true';
         if (isset($imagepath) && $imagepath != '') {
             $imageArr = explode('.', $imagepath);
             if (sizeof($imageArr) > 1) {
                 $imagename = $imageArr[0];
                 $imageext = $imageArr[1];
                 $extArr = array('gif', 'jpg', 'jpeg', 'png');
                 if (!in_array($imageext, $extArr)) {
                     $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
                     $flag = 'false';
                 }
             } else {
                 $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
                 $flag = 'false';
             }
         }
         if ($imagerror == 'error') {
             if ($imgerrmsg != '' && $imgerrmsg != 'undefined') {
                 $msgarray['org_image_value'] = $imgerrmsg;
             } else {
                 $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
             }
             $flag = 'false';
         }
         if ($pphnumber == $sphnumber && $sphnumber != '' && $pphnumber != '') {
             $msgarray['secondaryphone'] = 'Please enter different phone number.';
             $flag = 'false';
         }
         if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
             $domain = $this->_request->getParam('domain');
             $domain = implode(',', $domain);
             $prevorgheadrm = $this->_request->getParam('prevorgheadrm');
             $actionflag = '';
             $date = new Zend_Date();
             $newOrgHead = $this->_request->getParam('orghead');
             if ($newOrgHead != '') {
                 $neworgHeadData = $employeeModal->getsingleEmployeeData($newOrgHead);
             }
             if (!empty($neworgHeadData)) {
                 $headfullname = $neworgHeadData[0]['userfullname'];
             } else {
                 $headfullname = '';
             }
             $data = array('organisationname' => trim($this->_request->getParam('organisationname')), 'domain' => trim($domain), 'website' => trim($this->_request->getParam('website')), 'org_image' => $imagepath, 'orgdescription' => trim($this->_request->getParam('orgdescription')), 'totalemployees' => trim($this->_request->getParam('totalemployees')), 'org_startdate' => $org_startdate != '' ? $org_startdate : NULL, 'phonenumber' => trim($this->_request->getParam('phonenumber')), 'secondaryphone' => trim($this->_request->getParam('secondaryphone')), 'faxnumber' => trim($this->_request->getParam('faxnumber')), 'country' => trim((int) $this->_request->getParam('country')), 'state' => trim(intval($this->_request->getParam('state'))), 'city' => trim(intval($this->_request->getParam('city'))), 'address1' => trim($this->_request->getParam('address1')), 'address2' => trim($this->_request->getParam('address2')), 'address3' => trim($this->_request->getParam('address3')), 'description' => trim($this->_request->getParam('description')), 'orghead' => trim($this->_request->getParam('orghead')), 'designation' => trim($this->_request->getParam('jobtitle_id', null)), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $db = Zend_Db_Table::getDefaultAdapter();
             $db->beginTransaction();
             try {
                 if ($oldOrgHead != $newOrgHead && $oldOrgHead != '' && $newOrgHead != '' && $prevorgheadrm) {
                     $orgInfoModel->changeOrgHead($oldOrgHead, $newOrgHead, $prevorgheadrm);
                 }
                 $path = IMAGE_UPLOAD_PATH;
                 $imagepath = $this->_request->getParam('org_image_value');
                 $filecopy = 'success';
                 if ($imagepath != '') {
                     $filecopy = 'error';
                     if (file_exists(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath)) {
                         try {
                             if (copy(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath, $path . '//' . $imagepath)) {
                                 $filecopy = 'success';
                             }
                             unlink(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath);
                         } catch (Exception $e) {
                             echo $msgarray['org_image_value'] = $e->getMessage();
                             exit;
                         }
                     }
                 }
                 $where = array('id=?' => $id);
                 if ($imagepath == '') {
                     unset($data['org_image']);
                 } else {
                     if ($filecopy == 'error') {
                         unset($data['org_image']);
                     }
                 }
                 if ($id != '') {
                     $where = array('id=?' => $id);
                     $actionflag = 2;
                 } else {
                     $data['createdby'] = $loginUserId;
                     $data['createddate'] = gmdate("Y-m-d H:i:s");
                     $data['isactive'] = 1;
                     $where = '';
                     $actionflag = 1;
                 }
                 $Id = $orgInfoModel->SaveorUpdateData($data, $where);
                 $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
                 $position_id = $this->_request->getParam('position_id', null);
                 $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database');
                 $employeeId = $this->_getParam('employeeId', null);
                 $emprole = $this->_getParam('emprole', null);
                 $emailaddress = $this->_getParam('emailaddress', null);
                 $emppassword = sapp_Global::generatePassword();
                 $first_name = trim($this->_request->getParam('firstname_orghead', null));
                 $last_name = trim($this->_request->getParam('lastname_orghead', null));
                 $userfullname = $first_name . ' ' . $last_name;
                 //$userfullname = $headfullname;
                 $prefix_id = $this->_getParam('prefix_id', null);
                 $user_id = $this->_getParam('user_id', null);
                 $user_data = array('emprole' => $emprole, 'firstname' => $first_name, 'lastname' => $last_name, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'selecteddate' => $date_of_joining, 'userstatus' => 'old', 'modeofentry' => 'Direct');
                 $emp_data = array('user_id' => $newOrgHead, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'reporting_manager' => 0, 'date_of_joining' => $date_of_joining, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 if ($Id == 'update') {
                     $tableid = $id;
                     unset($user_data['emppassword']);
                     unset($user_data['modeofentry']);
                     unset($user_data['userstatus']);
                     if ($newOrgHead != '') {
                         $user_st = $user_model->SaveorUpdateUserData($user_data, " id = " . $newOrgHead);
                         $employeeModal->SaveorUpdateEmployeeData($emp_data, " user_id = " . $newOrgHead);
                     } else {
                         $user_data['userstatus'] = 'old';
                         $user_data['emppassword'] = md5($emppassword);
                         $user_data['createdby'] = $loginUserId;
                         $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                         $user_data['isactive'] = 1;
                         if ($emp_identity_code != '') {
                             $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                         } else {
                             $emp_id = '';
                         }
                         $user_data['employeeId'] = $emp_id;
                         $user_id = $user_model->SaveorUpdateUserData($user_data, '');
                         $emp_data['user_id'] = $newOrgHead;
                         $emp_data['createdby'] = $loginUserId;
                         $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
                         $emp_data['isactive'] = 1;
                         $emp_data['is_orghead'] = 1;
                         $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
                     }
                     if ($filecopy == 'success') {
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information updated successfully.");
                     } else {
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information updated successfully but failed to upload the logo.");
                     }
                 } else {
                     //start of saving into employee table
                     $user_data['createdby'] = $loginUserId;
                     $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                     $user_data['isactive'] = 1;
                     if ($emp_identity_code != '') {
                         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                     } else {
                         $emp_id = '';
                     }
                     $user_data['employeeId'] = $emp_id;
                     $user_id = $user_model->SaveorUpdateUserData($user_data, '');
                     $emp_data['user_id'] = $user_id;
                     $emp_data['createdby'] = $loginUserId;
                     $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
                     $emp_data['isactive'] = 1;
                     $emp_data['is_orghead'] = 1;
                     $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
                     $tableid = $Id;
                     if ($filecopy == 'success') {
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully.");
                     } else {
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully but failed to upload the logo.");
                     }
                 }
                 $menuID = ORGANISATIONINFO;
                 try {
                     if ($Id != '' && $Id != 'update') {
                         $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id);
                     } else {
                         $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                     }
                 } catch (Exception $e) {
                     echo $e->getMessage();
                 }
                 /* Send Mail to the user */
                 if ($Id != 'update') {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $userfullname;
                     $this->view->password = $emppassword;
                     $this->view->emp_id = $employeeId;
                     $this->view->base_url = $base_url;
                     $text = $view->render('mailtemplates/newpassword.phtml');
                     $options['subject'] = APPLICATION_NAME . ': login credentials';
                     $options['header'] = 'Greetings from Sentrifugo';
                     $options['toEmail'] = $emailaddress;
                     $options['toName'] = $this->view->emp_name;
                     $options['message'] = $text;
                     $result = sapp_Global::_sendEmail($options);
                 }
                 /* END */
                 $db->commit();
                 $this->_redirect('organisationinfo');
             } catch (Exception $e) {
                 $db->rollBack();
                 return 'failed';
             }
         } else {
             $messages = $form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
                 if (empty($allCountriesData)) {
                     $msgarray['country'] = 'Countries are not configured yet.';
                 }
                 if (empty($allStatesData)) {
                     $msgarray['state'] = 'States are not configured yet.';
                 }
                 if (empty($allCitiesData)) {
                     $msgarray['city'] = 'Cities are not configured yet.';
                 }
             }
             if (isset($this->msgarray['domain'])) {
                 $this->view->msMsg = 'multiselecterror';
             }
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->popConfigPermission = $popConfigPermission;
 }
Example #13
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'));
 }
Example #14
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'systempreference');
     $id = new Zend_Form_Element_Hidden('id');
     $currencyid = new Zend_Form_Element_Hidden('currencyid');
     $organisationid = new Zend_Form_Element_Hidden('organisationid');
     $empcodeid = new Zend_Form_Element_Hidden('empcodeid');
     $dateformatid = new Zend_Form_Element_Select('dateformatid');
     $dateformatid->setAttrib('class', 'selectoption');
     $dateformatid->setRegisterInArrayValidator(false);
     $dateformatid->setRequired(true);
     $dateformatid->addValidator('NotEmpty', false, array('messages' => 'Please select date format.'));
     $timeformatid = new Zend_Form_Element_Select('timeformatid');
     $timeformatid->setAttrib('class', 'selectoption');
     $timeformatid->setRegisterInArrayValidator(false);
     $timeformatid->setRequired(true);
     $timeformatid->addValidator('NotEmpty', false, array('messages' => 'Please select time format.'));
     $timezoneid = new Zend_Form_Element_Select('timezoneid');
     $timezoneid->setAttrib('class', 'selectoption');
     $timezoneid->setRegisterInArrayValidator(false);
     $timezoneid->setRequired(true);
     $timezoneid->addValidator('NotEmpty', false, array('messages' => 'Please select time zone preference.'));
     $timezoneid->addMultiOption('', 'Select Time zone');
     $timezoneModal = new Default_Model_Timezone();
     $timezoneData = $timezoneModal->fetchAll('isactive=1', 'timezone')->toArray();
     foreach ($timezoneData as $data) {
         $timezoneid->addMultiOption($data['id'], $data['timezone'] . ' [' . $data['timezone_abbr'] . ']');
     }
     $currencyname = new Zend_Form_Element_Text('currencyname');
     $currencyname->setAttrib('maxLength', 50);
     $currencyname->addFilter(new Zend_Filter_StringTrim());
     $currencyname->setRequired(true);
     $currencyname->addValidator('NotEmpty', false, array('messages' => 'Please enter currency.'));
     $currencyname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency.')));
     $currencyname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencyname', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('currencyid') . '" and isactive=1')));
     $currencyname->getValidator('Db_NoRecordExists')->setMessage('Currency already exists.');
     $currencycode = new Zend_Form_Element_Text('currencycode');
     $currencycode->setAttrib('maxLength', 20);
     $currencycode->addFilter(new Zend_Filter_StringTrim());
     $currencycode->setRequired(true);
     $currencycode->addValidator('NotEmpty', false, array('messages' => 'Please enter currency code.'));
     $currencycode->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency code.')));
     $currencycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencycode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('currencyid') . '" and isactive=1')));
     $currencycode->getValidator('Db_NoRecordExists')->setMessage('Currency code already exists.');
     $passwordid = new Zend_Form_Element_Select('passwordid');
     $passwordid->setAttrib('class', 'selectoption');
     $passwordid->setAttrib('onchange', 'displayPasswordDesc(this)');
     $passwordid->setRegisterInArrayValidator(false);
     $passwordid->setRequired(true);
     $passwordid->addValidator('NotEmpty', false, array('messages' => 'Please select default password.'));
     $perm_country = new Zend_Form_Element_Select('perm_country');
     $perm_country->setAttrib('onchange', 'displayParticularState(this,"","perm_state","")');
     $perm_country->setRegisterInArrayValidator(false);
     $countriesModel = new Default_Model_Countries();
     $countrieslistArr = $countriesModel->getTotalCountriesList('addcountry');
     if (sizeof($countrieslistArr) > 0) {
         $perm_country->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             $perm_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     }
     $perm_country->setRequired(true);
     $perm_country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $perm_state = new Zend_Form_Element_Select('perm_state');
     $perm_state->setAttrib('onchange', 'displayParticularCity(this,"","perm_city","")');
     $perm_state->setRegisterInArrayValidator(false);
     $perm_state->addMultiOption('', 'Select State');
     $perm_state->setRequired(true);
     $perm_state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $perm_city = new Zend_Form_Element_Select('perm_city');
     $perm_city->setRegisterInArrayValidator(false);
     $perm_city->addMultiOption('', 'Select City');
     $perm_city->setRequired(true);
     $perm_city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $workcodename = new Zend_Form_Element_Multiselect('workcodename');
     $workcodename->setRegisterInArrayValidator(false);
     $workcodename->setRequired(true);
     $workcodename->addValidator('NotEmpty', false, array('messages' => 'Please select employment status.'));
     $empCode = new Zend_Form_Element_Text('employee_code');
     $empCode->addFilter(new Zend_Filter_StringTrim());
     $empCode->setAttrib('maxLength', 5);
     $empCode->setRequired(true);
     $empCode->addValidator('NotEmpty', false, array('messages' => 'Please enter employee code.'));
     $empCode->addValidators(array(array('StringLength', false, array('min' => 1, 'max' => 5, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Employee code must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Employee code must contain at least %min% characters.')))));
     $empCode->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[A-Za-z][a-zA-Z@\\-]*$/', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => 'Please enter valid employee code.')))));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($timezoneid, $id, $currencyid, $organisationid, $empcodeid, $dateformatid, $timeformatid, $currencycode, $currencyname, $passwordid, $perm_country, $perm_state, $perm_city, $workcodename, $empCode, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
Example #15
0
 public function addnewcountryAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     $controllername = 'countries';
     $countriesform = new Default_Form_countries();
     $countriesmodel = new Default_Model_Countries();
     $countriesform->setAction(BASE_URL . 'countries/addnewcountry');
     /* Changing the form */
     $countriesform->removeElement('country');
     $countriesform->removeElement('countrycode');
     $countriesform->addElement('text', 'country', array('label' => 'Country', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter country name.')))));
     $countriesform->country->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tbl_countries', 'field' => 'country_name')));
     $countriesform->country->getValidator('Db_NoRecordExists')->setMessage('Country name already exists.');
     $countriesform->addElement('text', 'countrycode', array('label' => 'Country code', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter country code.')))));
     $countriesform->countrycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tbl_countries', 'field' => 'country_code')));
     $countriesform->countrycode->getValidator('Db_NoRecordExists')->setMessage('Country code already exists.');
     /* END */
     if ($this->getRequest()->getPost()) {
         $id = $this->_request->getParam('id');
         $errorflag = "true";
         $msgarray = array();
         $dbcountry = '';
         $dbcountryid = '';
         $country = $this->_request->getParam('country');
         $countrycode = $this->_request->getParam('countrycode');
         $citizenship = $this->_request->getParam('citizenship');
         $dbcountry = $country;
         if ($countriesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $date = new Zend_Date();
             $actionflag = 1;
             $tableid = '';
             $countryID = $countriesmodel->SaveMainCountryData($country, $countrycode);
             $tableid = $countryID;
             $menuID = COUNTRIES;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $countryData = $countriesmodel->getTotalCountriesList('isactive=1', 'country_name');
             $opt = '';
             foreach ($countryData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['country_name']);
             }
             $this->view->countryData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $countriesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->ermsg = '';
     $this->view->form = $countriesform;
     $this->view->controllername = $controllername;
 }
Example #16
0
 public function addnewcityAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $selectedcountryid = $this->_request->getParam('selectcountryid');
     $selectedstateid = $this->_request->getParam('selectstateid');
     $msgarray = array();
     $setDefaultString = '';
     $citystring = '';
     $controllername = 'cities';
     $citiesform = new Default_Form_cities();
     $citiesmodel = new Default_Model_Cities();
     $countriesModel = new Default_Model_Countries();
     $statesmodel = new Default_Model_States();
     /* Changing the form */
     $citiesform->setAction(BASE_URL . 'cities/addnewcity/selectcountryid/' . $selectedcountryid . '/selectstateid/' . $selectedstateid);
     $citiesform->removeElement('city');
     $citiesform->addElement('text', 'city', array('label' => 'City', 'maxlength' => '20', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => 'Please enter city name.')))));
     /* END */
     $countrieslistArr = $countriesModel->getTotalCountriesList('');
     if (sizeof($countrieslistArr) > 0) {
         $citiesform->countryid->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             if ($selectedcountryid != '') {
                 if ($countrieslistres['id'] == $selectedcountryid) {
                     $citiesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                     $citiesform->setDefault('countryid', $selectedcountryid);
                 }
             } else {
                 $citiesform->countryid->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
             }
             $citiesform->countryid->setAttrib('onchange', 'displayParticularState_normal(this,"","state","city")');
         }
     } else {
         $msgarray['countryid'] = 'Countries are not configured yet.';
     }
     $countryid = $this->_request->getParam('countryid');
     if (isset($selectedcountryid) && $selectedcountryid != '' || isset($countryid) && $countryid != '') {
         if ($countryid) {
             $statesmodeldata = $statesmodel->getStatesList($countryid, '');
         } else {
             $statesmodeldata = $statesmodel->getStatesList($selectedcountryid, '');
         }
         $citiesform->state->addMultiOption('', 'Select State');
         foreach ($statesmodeldata as $res) {
             $citiesform->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
             if ($selectedstateid != '') {
                 if ($res['id'] == $selectedstateid) {
                     $setDefaultString = $res['id'];
                 }
             } else {
                 if ($countryid != '') {
                     if ($res['id'] == $countryid) {
                         $setDefaultString = $res['id'];
                     }
                 }
             }
         }
         $citiesform->setDefault('state', $setDefaultString);
     } else {
         $citiesform->state->addMultiOption('', 'Select State');
     }
     if ($this->getRequest()->getPost()) {
         $id = $this->_request->getParam('id');
         $errorflag = "true";
         $msgarray = array();
         $dbstate = '';
         $dbcountryid = '';
         $stateidstr = $this->_request->getParam('state');
         $stateid = intval($stateidstr);
         $city = $this->_request->getParam('city');
         if (isset($stateid)) {
             $isDuplicateCityNameArr = $citiesmodel->getDuplicateCityName($city, $stateid);
             if ($isDuplicateCityNameArr[0]['count'] > 0) {
                 $errorflag = "false";
                 $msgarray['city'] = "City already exists.";
             }
         } else {
             $errorflag = "false";
             $msgarray['state'] = "Please select state.";
         }
         if ($citiesform->isValid($this->_request->getPost()) && $errorflag == "true") {
             $menumodel = new Default_Model_Menu();
             $city = $this->_request->getParam('city');
             $actionflag = '';
             $tableid = '';
             $NewCityId = $citiesmodel->SaveMainCityData($stateid, $city);
             $actionflag = 1;
             $tableid = $NewCityId;
             $menuidArr = $menumodel->getMenuObjID('/cities');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             if (isset($selectedstateid) && isset($selectedcountryid)) {
                 $cityData = $citiesmodel->getCitiesList($selectedstateid, 'city');
             } else {
                 $cityData = array();
             }
             $opt = '';
             foreach ($cityData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['city_name']);
             }
             $this->view->cityData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $citiesform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             if (isset($countryid) && $countryid != 0 && $countryid != '') {
                 $statesmodel = new Default_Model_States();
                 $statesmodeldata = $statesmodel->getBasicStatesList($countryid);
                 foreach ($statesmodeldata as $res) {
                     $citiesform->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state']));
                 }
                 if (isset($stateidstr) && $stateidstr != 0 && $stateidstr != '') {
                     $citiesform->setDefault('state', $stateidstr);
                 }
             }
         }
     }
     $this->view->controllername = $controllername;
     $this->view->ermsg = '';
     $this->view->form = $citiesform;
     $this->view->msgarray = $msgarray;
 }
Example #17
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', BASE_URL . 'businessunits/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'businessunits');
     $id = new Zend_Form_Element_Hidden('id');
     $unitname = new Zend_Form_Element_Text('unitname');
     $unitname->setAttrib('maxLength', 50);
     $unitname->addFilter(new Zend_Filter_StringTrim());
     $unitname->setRequired(true);
     $unitname->addValidator('NotEmpty', false, array('messages' => 'Please enter name.'));
     $unitname->addValidator("regex", true, array('pattern' => '/^(?![0-9]{4})[a-zA-Z0-9.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $unitname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_businessunits', 'field' => 'unitname', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $unitname->getValidator('Db_NoRecordExists')->setMessage('Name already exists.');
     $unitcode = new Zend_Form_Element_Text('unitcode');
     $unitcode->addFilter(new Zend_Filter_StringTrim());
     $unitcode->setRequired(true);
     $unitcode->setAttrib("maxlength", 4);
     $unitcode->addValidator('NotEmpty', false, array('messages' => 'Please enter code.'));
     $unitcode->addValidators(array(array('StringLength', false, array('min' => 2, 'max' => 4, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Code must contain at most %max% characters.', Zend_Validate_StringLength::TOO_SHORT => 'Code must contain at least %min% characters.')))));
     $unitcode->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z0-9\\&\'\\.\\s]+$/', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => 'Please enter valid code.')))));
     $unitcode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_businessunits', 'field' => 'unitcode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $unitcode->getValidator('Db_NoRecordExists')->setMessage('Code already exists.');
     $description = new Zend_Form_Element_Textarea('description');
     $description->setAttrib('rows', 10);
     $description->setAttrib('cols', 50);
     $start_date = new ZendX_JQuery_Form_Element_DatePicker('start_date');
     $start_date->setAttrib('readonly', 'true');
     $start_date->setAttrib('onfocus', 'this.blur()');
     $start_date->setOptions(array('class' => 'brdr_none'));
     $country = new Zend_Form_Element_Select('country');
     $country->setLabel('country');
     $country->setRequired(true);
     $country->addValidator('NotEmpty', false, array('messages' => 'Please select country.'));
     $country->setAttrib('onchange', 'displayParticularState_normal(this,"state","state","city")');
     $countryModal = new Default_Model_Countries();
     $countriesData = $countryModal->fetchAll('isactive=1', 'country');
     $country->addMultiOption('', 'Select country');
     foreach ($countriesData->toArray() as $data) {
         $country->addMultiOption($data['country_id_org'], $data['country']);
     }
     $country->setRegisterInArrayValidator(false);
     $state = new Zend_Form_Element_Select('state');
     $state->setAttrib('onchange', 'displayParticularCity_normal(this,"city","city","")');
     $state->setRegisterInArrayValidator(false);
     $state->addMultiOption('', 'Select State');
     $state->setRequired(true);
     $state->addValidator('NotEmpty', false, array('messages' => 'Please select state.'));
     $city = new Zend_Form_Element_Select('city');
     $city->setAttrib('class', 'selectoption');
     $city->setAttrib('onchange', 'displayCityCode(this)');
     $city->setRegisterInArrayValidator(false);
     $city->addMultiOption('', 'Select City');
     $city->setRequired(true);
     $city->addValidator('NotEmpty', false, array('messages' => 'Please select city.'));
     $address1 = new Zend_Form_Element_Textarea('address1');
     $address1->setAttrib('rows', 10);
     $address1->setAttrib('cols', 50);
     $address1->setRequired(true);
     $address1->addValidator('NotEmpty', false, array('messages' => 'Please enter street address.'));
     $address2 = new Zend_Form_Element_Textarea('address2');
     $address2->setAttrib('rows', 10);
     $address2->setAttrib('cols', 50);
     $address3 = new Zend_Form_Element_Textarea('address3');
     $address3->setAttrib('rows', 10);
     $address3->setAttrib('cols', 50);
     $timezone = new Zend_Form_Element_Select('timezone');
     $timezone->setLabel('timezone');
     $timezone->setRequired(true);
     $timezone->addValidator('NotEmpty', false, array('messages' => 'Please select time zone.'));
     $timezoneModel = new Default_Model_Timezone();
     $timezonedata = $timezoneModel->fetchAll('isactive=1', 'timezone');
     $timezone->addMultiOption('', 'Select Time zone');
     foreach ($timezonedata->toArray() as $data) {
         $timezone->addMultiOption($data['id'], $data['timezone'] . ' [' . $data['timezone_abbr'] . ']');
     }
     $timezone->setRegisterInArrayValidator(false);
     $unithead = new Zend_Form_Element_Text('unithead');
     $unithead->setLabel('timezone');
     $unithead->setAttrib('maxlength', '50');
     $unithead->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid name.')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $unitname, $unitcode, $description, $start_date, $country, $state, $city, $address1, $address2, $address3, $timezone, $unithead, $submit));
     $this->setElementDecorators(array('ViewHelper'));
     $this->setElementDecorators(array('UiWidgetElement'), array('start_date'));
 }
 /**
  * 
  */
 public function candidatepopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $req_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $cand_model = new Default_Model_Candidatedetails();
     $candwork_model = new Default_Model_Candidateworkdetails();
     $country_model = new Default_Model_Countries();
     $role_model = new Default_Model_Roles();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $login_group_id = $auth->getStorage()->read()->group_id;
         $login_role_id = $auth->getStorage()->read()->emprole;
     }
     $id = $this->getRequest()->getParam('cand_id');
     $form = new Default_Form_Candidatedetails();
     $req_data = array();
     $jobtitle = '';
     $req_data['jobtitlename'] = '';
     try {
         $candidateData = $cand_model->getcandidateData($id);
         $req_data = $req_model->getRequisitionDataById($candidateData['requisition_id']);
         $req_data['cand_resume'] = !empty($candidateData['cand_resume']) ? $candidateData['cand_resume'] : '';
         $req_data['rec_id'] = $id;
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($req_data['jobtitle']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = $jobttlArr[0]['jobtitlename'];
             $req_data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $req_options = array();
         $req_options[$req_data['id']] = $req_data['requisition_code'];
         try {
             $candidateworkData = $candwork_model->getcandidateworkData($id);
             $countryId = $candidateData['country'];
             $stateId = $candidateData['state'];
             $cityId = $candidateData['city'];
             if ($countryId && $stateId) {
                 $statesmodel = new Default_Model_States();
                 $citiesmodel = new Default_Model_Cities();
                 $statesData = $statesmodel->getStatesList($countryId);
                 $citiesData = $citiesmodel->getCitiesList($stateId);
                 foreach ($statesData as $res) {
                     $form->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
                 }
                 foreach ($citiesData as $res) {
                     $form->city->addMultiOption($res['id'], utf8_encode($res['city_name']));
                 }
                 $form->setDefault('country', $countryId);
                 $form->setDefault('state', $stateId);
                 $form->setDefault('city', $cityId);
                 $form->setDefault('job_title', $jobtitle);
             }
             $countrieslistArr = $country_model->getTotalCountriesList();
             if (sizeof($countrieslistArr) > 0) {
                 $form->country->addMultiOption('0', 'Select Country');
                 foreach ($countrieslistArr as $countrieslistres) {
                     $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                 }
             } else {
                 $msgarray['country'] = 'Countries not configured yet';
             }
             $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
             if ($id) {
                 $form->submit->setLabel('Update');
                 $form->populate($candidateworkData);
                 $form->populate($candidateData);
             }
             $elements = $form->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             $previ_data = sapp_Global::_checkprivileges(CANDIDATEDETAILS, $login_group_id, $login_role_id, 'edit');
             $this->view->form = $form;
             $this->view->previ_data = $previ_data;
             $this->view->workdata = $candidateworkData;
             $this->view->ermsg = '';
             $this->view->req_data = $req_data;
             $objName = 'candidatedetails';
             $this->view->id = $id;
             $this->view->controllername = $objName;
         } catch (Exception $e) {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
Example #19
0
 public function loginAction()
 {
     /* Check whether the user is already logged in */
     if ($this->session->userid !== null) {
         if (!$this->handle_actions()) {
             $this->_helper->layout->disableLayout();
             $this->_helper->viewRenderer->setNoRender();
             header('Location: https://' . $_SERVER['HTTP_HOST'] . '/');
         }
         return;
     }
     $this->view->session = $this->session;
     $ldap = ApplicationConfiguration::service('egi.ldap.host');
     if (array_key_exists('username', $_POST)) {
         $this->view->username = $_POST['username'];
         $username = "******" . $_POST['username'] . ",ou=People,dc=egi,dc=eu";
         $password = $_POST['password'];
         $ds = $this->initLDAP(true, $username, $password);
         if (is_resource($ds)) {
             @ldap_close($ds);
             $username = $_POST['username'];
             $this->session->username = $username;
             $users = new Default_Model_Researchers();
             $users->viewModerated = true;
             $users->filter->username->equals($username);
             if ($users->count() == 1) {
                 if (!$users->items[0]->deleted) {
                     $this->session->userid = $users->items[0]->Id;
                     $this->session->userRole = $users->items[0]->positionTypeID;
                     $this->session->userCountryID = $users->items[0]->countryID;
                     $this->session->userCountryName = $users->items[0]->country->name;
                     $this->session->user = $users->items[0];
                     $this->session->fullName = $users->items[0]->firstName . " " . $users->items[0]->lastName;
                     $this->session->cname = $users->items[0]->cname;
                     setAuthCookies($username, md5($password));
                     $user = $users->items[0];
                     $user->lastLogin = time();
                     $user->password = md5($password);
                     // TODO: remove this when SAML has been implemented
                     $user->save();
                     $this->saveUserCredentials($user->id, md5($password));
                     // TODO: replace with SAML Auth token
                     $this->handle_actions();
                 } else {
                     $this->view->accountDeleted = true;
                     error_log(var_export($users->items[0]->delInfo, true));
                     $this->view->accountDeleter = $users->items[0]->delInfo->deleter->name;
                     $this->view->accountDeleterID = $users->items[0]->delInfo->deleter->id;
                     $this->view->accountDeletedOn = $users->items[0]->delInfo->deletedOn;
                 }
             } else {
                 $this->session->claimPassword = md5($password);
                 $ds = $this->initLDAP(true);
                 // no rdn/pwd: root connection
                 if ($ds !== false) {
                     $users2 = new Default_Model_Contacts();
                     $sr = ldap_search($ds, "ou=people,dc=egi,dc=eu", "(uid=" . $_POST['username'] . ")");
                     $info = ldap_get_entries($ds, $sr);
                     ldap_close($ds);
                     if ($info["count"] > 0) {
                         $this->session->fullName = $info[0]['cn'][0];
                         $users2->filter->data->ilike($info[0]['mail'][0]);
                         if ($users2->refresh()->count() != 0) {
                             // Found existing profiles
                             $ids = array();
                             for ($i = 0; $i < $users2->count(); $i++) {
                                 $ids[] = $users2->items[$i]->researcherid;
                             }
                             $users->viewModerated = false;
                             $users->filter->id->in($ids);
                             $users->refresh();
                             $entries = array();
                             $canClaim = array();
                             for ($i = 0; $i < $users->count(); $i++) {
                                 $entries[] = $users->items[$i];
                                 $canClaim[] = $users->items[$i]->id;
                             }
                             $this->view->entries = $entries;
                             $this->session->canClaim = $canClaim;
                         } else {
                             // Create a new profile
                             $roleTypeID = 3;
                             if (array_key_exists('usercertificatesubject', $info[0])) {
                                 $sub = explode('/', $info[0]['usercertificatesubject'][0]);
                                 foreach ($sub as $s) {
                                     if (substr($s, 0, 2) == 'C=') {
                                         $country = substr($s, 2);
                                         $cs = new Default_Model_Countries();
                                         $cs->filter->isocode->equals($country);
                                         if ($cs->count() > 0) {
                                             $this->view->country = $cs->items[0]->name;
                                         }
                                         break;
                                     }
                                 }
                             }
                             if (array_key_exists('sn', $info[0])) {
                                 $this->view->lastname = $info[0]['sn'][0];
                                 $this->view->firstname = str_replace($info[0]['sn'][0], "", $info[0]['cn'][0]);
                             }
                             if (array_key_exists('destinationindicator', $info[0])) {
                                 $this->view->gender = $info[0]['destinationindicator'][0];
                             }
                             if (array_key_exists('ou', $info[0])) {
                                 $this->view->institute = $info[0]['ou']['0'];
                             }
                             if (array_key_exists('employeetype', $info[0])) {
                                 if ($info[0]['employeetype'][0] == "Experienced researcher" || $info[0]['employeetype'][0] == "Management") {
                                     $roleTypeID = 2;
                                 } else {
                                     if ($info[0]['employeetype'][0] == "Technical Support" || $info[0]['employeetype'][0] == "PhD Student") {
                                         $roleTypeID = 3;
                                     } else {
                                         $roleTypeID = 4;
                                     }
                                 }
                             }
                             if (array_key_exists('mail', $info[0])) {
                                 $this->view->SSOmail = $info[0]['mail'][0];
                             }
                             $pts = new Default_Model_PositionTypes();
                             $pts->filter->id->equals($roleTypeID);
                             $this->view->roleType = $pts->items[0]->description;
                             $contactTypes = new Default_Model_ContactTypes();
                             $this->view->contactTypes = $contactTypes->refresh();
                         }
                     }
                 } else {
                     error_log($this->view->ldapError);
                 }
             }
         } else {
             error_log($this->view->ldapError);
         }
     }
 }
 public function editAction()
 {
     $orgInfoModel = new Default_Model_Organisationinfo();
     $getorgData = $orgInfoModel->getorgrecords();
     $popConfigPermission = array();
     if (!empty($getorgData)) {
         $orgdata = '';
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $loginUserId = $auth->getStorage()->read()->id;
             $loginuserRole = $auth->getStorage()->read()->emprole;
             $loginuserGroup = $auth->getStorage()->read()->group_id;
         }
         if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'timezone');
         }
         if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'country');
         }
         if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'state');
         }
         if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'city');
         }
         $msgarray = array();
         $flag = 'true';
         $id = $this->getRequest()->getParam('id');
         $callval = $this->getRequest()->getParam('call');
         if ($callval == 'ajaxcall') {
             $this->_helper->layout->disableLayout();
         }
         $countriesModel = new Default_Model_Countries();
         $statesmodel = new Default_Model_States();
         $citiesmodel = new Default_Model_Cities();
         $timezonemodel = new Default_Model_Timezone();
         $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray();
         $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray();
         $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray();
         $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray();
         $businessunitsform = new Default_Form_businessunits();
         $businessunitsmodel = new Default_Model_Businessunits();
         $orgInfoModel = new Default_Model_Organisationinfo();
         $deptModel = new Default_Model_Departments();
         $deptform = new Default_Form_departments();
         $deptData = array();
         $msgarray = array();
         $businessunitsform->setAttrib('action', DOMAIN . 'businessunits/edit');
         $country = $getorgData[0]['country'];
         if (isset($_POST['country'])) {
             $country = $_POST['country'];
         }
         $state = $getorgData[0]['state'];
         if (isset($_POST['state'])) {
             $state = $_POST['state'];
         }
         $city = $getorgData[0]['city'];
         if (isset($_POST['city'])) {
             $city = $_POST['city'];
         }
         $address = $getorgData[0]['address1'];
         if (isset($country) && $country != 0 && $country != '') {
             $businessunitsform->setDefault('country', $country);
             $statesData = $statesmodel->getBasicStatesList($country);
             foreach ($statesData as $res) {
                 $businessunitsform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
             }
             if (isset($state) && $state != 0 && $state != '') {
                 $businessunitsform->setDefault('state', $state);
             }
         }
         if (isset($state) && $state != 0 && $state != '') {
             $citiesData = $citiesmodel->getBasicCitiesList($state);
             foreach ($citiesData as $res) {
                 $businessunitsform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
             }
             if (isset($city) && $city != 0 && $city != '') {
                 $businessunitsform->setDefault('city', $city);
             }
         }
         if (isset($address) && $address != '') {
             $businessunitsform->address1->setValue($address);
         }
         if (is_numeric($id) && $id > 0) {
             $data = $businessunitsmodel->getSingleUnitData($id);
             if (!empty($data)) {
                 $businessunitsform->setAttrib('action', DOMAIN . 'businessunits/edit/id/' . $id);
                 $businessunitsform->populate($data);
                 $businessunitsform->submit->setLabel('Update');
                 $st_date = sapp_Global::change_date($data["startdate"], 'view');
                 $businessunitsform->setDefault('start_date', $st_date);
                 $businessunitsform->state->clearMultiOptions();
                 $businessunitsform->city->clearMultiOptions();
                 $businessunitsform->state->addMultiOption('', utf8_encode("Select State"));
                 $businessunitsform->city->addMultiOption('', utf8_encode("Select City"));
                 $countryId = $data['country'];
                 if (isset($_POST['country'])) {
                     $countryId = $_POST['country'];
                 }
                 $stateId = $data['state'];
                 if (isset($_POST['state'])) {
                     $stateId = $_POST['state'];
                 }
                 $cityId = $data['city'];
                 if (isset($_POST['city'])) {
                     $cityId = $_POST['city'];
                 }
                 if ($countryId != '') {
                     $statesData = $statesmodel->getBasicStatesList($countryId);
                     foreach ($statesData as $res) {
                         $businessunitsform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                     }
                     $businessunitsform->setDefault('country', $countryId);
                     $businessunitsform->setDefault('state', $stateId);
                 }
                 if ($stateId != '') {
                     $citiesData = $citiesmodel->getBasicCitiesList($stateId);
                     foreach ($citiesData as $res) {
                         $businessunitsform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                     }
                     $businessunitsform->setDefault('city', $cityId);
                 }
                 $deptData = $deptModel->getAllDeptsForUnit($id);
                 $this->view->ermsg = '';
                 $this->view->datarr = $data;
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             if ($id != '') {
                 $this->view->ermsg = 'nodata';
             }
         }
         $deptaddpermission = sapp_Global::_checkprivileges(DEPARTMENTS, $loginuserGroup, $loginuserRole, 'add');
         $this->view->deptaddpermission = $deptaddpermission;
         $this->view->dataArray = $this->departmentGrid($id);
         $this->view->deptData = sizeof($deptData);
         $this->view->form = $businessunitsform;
         $this->view->unitid = $id;
         if (!empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData) && !empty($allTimezoneData)) {
             $this->view->configuremsg = '';
         } else {
             $this->view->configuremsg = 'notconfigurable';
         }
         if (empty($allCountriesData)) {
             $msgarray['country'] = 'Countries are not configured yet.';
             $flag = 'false';
         }
         if (empty($allStatesData)) {
             $msgarray['state'] = 'States are not configured yet.';
             $flag = 'false';
         }
         if (empty($allCitiesData)) {
             $msgarray['city'] = 'Cities are not configured yet.';
             $flag = 'false';
         }
         if (empty($allTimezoneData)) {
             $msgarray['timezone'] = 'Time zones are not configured yet.';
             $flag = 'false';
         }
         $start_date = $this->_request->getParam('start_date');
         $start_date = sapp_Global::change_date($start_date, 'database');
         $this->view->msgarray = $msgarray;
         if ($this->getRequest()->getPost()) {
             if ($businessunitsform->isValid($this->_request->getPost()) && $flag == 'true') {
                 $unitname = $this->_request->getParam('unitname');
                 $unitcode = $this->_request->getParam('unitcode');
                 $description = $this->_request->getParam('description');
                 $country = $this->_request->getParam('country');
                 $state = intval($this->_request->getParam('state'));
                 $city = $this->_request->getParam('city');
                 $address1 = $this->_request->getParam('address1');
                 $address2 = $this->_request->getParam('address2');
                 $address3 = $this->_request->getParam('address3');
                 $timezone = $this->_request->getParam('timezone');
                 $unithead = $this->_request->getParam('unithead');
                 $unitcodeExistance = $businessunitsmodel->checkUnitCodeDuplicates($unitcode, $id);
                 if (!$unitcodeExistance) {
                     $date = new Zend_Date();
                     $menumodel = new Default_Model_Menu();
                     $actionflag = '';
                     $tableid = '';
                     $data = array('unitname' => trim($unitname), 'unitcode' => trim($unitcode), 'description' => trim($description), 'startdate' => $start_date != '' ? $start_date : NULL, 'country' => trim($country), 'state' => trim($state), 'city' => trim($city), 'address1' => trim($address1), 'address2' => trim($address2), 'address3' => trim($address3), 'timezone' => trim($timezone), 'unithead' => trim($unithead), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     if ($id != '') {
                         $where = array('id=?' => $id);
                         $actionflag = 2;
                     } else {
                         $data['createdby'] = $loginUserId;
                         $data['createddate'] = gmdate("Y-m-d H:i:s");
                         $data['isactive'] = 1;
                         $where = '';
                         $actionflag = 1;
                     }
                     $Id = $businessunitsmodel->SaveorUpdateBusinessUnits($data, $where);
                     if ($Id == 'update') {
                         $tableid = $id;
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Business unit updated successfully.");
                     } else {
                         $tableid = $Id;
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Business unit added successfully.");
                     }
                     $menuidArr = $menumodel->getMenuObjID('/businessunits');
                     $menuID = $menuidArr[0]['id'];
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                     $this->_redirect('businessunits');
                 } else {
                     $msgarray['message'] = 'A Business Unit, with the given code, already exists.';
                     $msgarray['msgtype'] = 'error';
                     $this->view->messages = $msgarray;
                 }
             } else {
                 $messages = $businessunitsform->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                     if (empty($allCountriesData)) {
                         $msgarray['country'] = 'Countries are not configured yet.';
                     }
                     if (empty($allStatesData)) {
                         $msgarray['state'] = 'States are not configured yet.';
                     }
                     if (empty($allCitiesData)) {
                         $msgarray['city'] = 'Cities are not configured yet.';
                     }
                     if (empty($allTimezoneData)) {
                         $msgarray['timezone'] = 'Time zones are not configured yet.';
                     }
                 }
                 $this->view->msgarray = $msgarray;
             }
         }
     } else {
         $orgdata = 'noorgdata';
         $this->view->orgdata = $orgdata;
     }
     $this->view->popConfigPermission = $popConfigPermission;
 }
Example #21
0
 public function getCountry()
 {
     if ($this->_country === null) {
         $Countries = new Default_Model_Countries();
         $Countries->filter->id->equals($this->getCountryID());
         if ($Countries->count() > 0) {
             $this->_country = $Countries->items[0];
         }
     }
     return $this->_country;
 }
Example #22
0
 /**
  * @overrides get() from RestResource
  */
 public function get()
 {
     if (parent::get() !== false) {
         if ($this->_listMode === RestListModeEnum::RL_NORMAL) {
             $res1 = new Default_Model_Countries();
             $res2 = new Default_Model_Regions();
             $res3 = new Default_Model_NGIs();
             $res1->refresh("xml");
             $res2->refresh("xml");
             $res3->refresh("xml");
             $items = array_merge(array_merge($res1->items, $res2->items), $res3->items);
             $this->_total = count($items);
             return new XMLFragmentRestResponse($items, $this);
         } elseif ($this->_listMode === RestListModeEnum::RL_LISTING) {
             $this->_listMode = RestListModeEnum::RL_NORMAL;
             return $this->_list();
         }
     } else {
         return false;
     }
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('workeligibilitydetails', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $employeeData = array();
             $id = $this->getRequest()->getParam('userid');
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'workeligibilitydetails';
             $issuingauthority = '';
             $employeeModal = new Default_Model_Employee();
             $workeligibilityform = new Default_Form_Workeligibilitydetails();
             $workeligibilityform->removeElement("submit");
             $elements = $workeligibilityform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $usersModel = new Default_Model_Users();
                     $empdata = $employeeModal->getActiveEmployeeData($id);
                     $employeeData = $usersModel->getUserDetailsByIDandFlag($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $workeligibilityModel = new Default_Model_Workeligibilitydetails();
                             if ($id) {
                                 $usersModel = new Default_Model_Users();
                                 $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes();
                                 $countriesModel = new Default_Model_Countries();
                                 $statesmodel = new Default_Model_States();
                                 $citiesmodel = new Default_Model_Cities();
                                 $countrieslistArr = $countriesModel->getTotalCountriesList();
                                 if (sizeof($countrieslistArr) > 0) {
                                     $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country');
                                     foreach ($countrieslistArr as $countrieslistres) {
                                         $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     }
                                 } else {
                                     $msgarray['issuingauth_country'] = 'Countries are not configured yet.';
                                 }
                                 $data = $workeligibilityModel->getWorkEligibilityRecord($id);
                                 if (!empty($data) && isset($data)) {
                                     $countryId = $data[0]['issuingauth_country'];
                                     $stateId = $data[0]['issuingauth_state'];
                                     $cityId = $data[0]['issuingauth_city'];
                                     $documenttype_id = $data[0]['documenttype_id'];
                                     if ($countryId != '') {
                                         $statelistArr = $statesmodel->getStatesList($countryId);
                                         if (sizeof($statelistArr) > 0) {
                                             $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State');
                                             foreach ($statelistArr as $statelistres) {
                                                 $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']);
                                             }
                                         }
                                     }
                                     if ($stateId != '') {
                                         $citylistArr = $citiesmodel->getCitiesList($stateId);
                                         if (sizeof($citylistArr) > 0) {
                                             $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City');
                                             foreach ($citylistArr as $cityPermlistres) {
                                                 $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']);
                                             }
                                         }
                                         $stateNameArr = $statesmodel->getStateName($stateId);
                                     }
                                     if ($cityId != '') {
                                         $cityNameArr = $citiesmodel->getCityName($cityId);
                                     }
                                     if ($documenttype_id != '') {
                                         $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id);
                                     }
                                     if (!empty($issuingauthorityArr)) {
                                         $issuingauthority = $issuingauthorityArr[0]['issuingauthority'];
                                         $workeligibilityform->issuingauthflag->setValue($issuingauthority);
                                         $workeligibilityform->documenttype_id->addMultiOption($issuingauthorityArr[0]['id'], $issuingauthorityArr[0]['documenttype']);
                                     }
                                     $workeligibilityform->setDefault("id", $data[0]["id"]);
                                     $workeligibilityform->setDefault("user_id", $data[0]["user_id"]);
                                     $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']);
                                     if (!empty($stateNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']);
                                     }
                                     if (!empty($cityNameArr)) {
                                         $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']);
                                     }
                                     $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]);
                                     $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]);
                                     $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]);
                                     $issue_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_issue_date"]));
                                     $workeligibilityform->setDefault('doc_issue_date', $issue_date);
                                     $expiry_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_expiry_date"]));
                                     $workeligibilityform->setDefault('doc_expiry_date', $expiry_date);
                                 }
                                 $this->view->controllername = $objName;
                                 $this->view->id = $id;
                                 $this->view->data = $data;
                                 $this->view->employeedata = $employeeData[0];
                                 $this->view->form = $workeligibilityform;
                                 $this->view->issuingauthority = $issuingauthority;
                             }
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Example #24
0
 public function createDepartmentsReportFinalArray($dataArray, $columnArray)
 {
     $businessunitArray = array();
     $cityArray = array();
     $stateArray = array();
     $countryArray = array();
     if (!empty($dataArray)) {
         foreach ($dataArray as $key => $curr) {
             if (isset($curr['unitid'])) {
                 if (!in_array($curr['unitid'], $businessunitArray)) {
                     array_push($businessunitArray, $curr['unitid']);
                 }
             }
             if (isset($curr['city'])) {
                 if (!in_array($curr['city'], $cityArray)) {
                     array_push($cityArray, $curr['city']);
                 }
             }
             if (isset($curr['state'])) {
                 if (!in_array($curr['state'], $stateArray)) {
                     array_push($stateArray, $curr['state']);
                 }
             }
             if (isset($curr['country'])) {
                 if (!in_array($curr['country'], $countryArray)) {
                     array_push($countryArray, $curr['country']);
                 }
             }
         }
     }
     if (!empty($businessunitArray)) {
         $businessunitModel = new Default_Model_Businessunits();
         $businessNameArray = $businessunitModel->getBusinessunitNamesByIds($businessunitArray);
     }
     if (!empty($cityArray)) {
         $cityModel = new Default_Model_Cities();
         $cityNameArray = $cityModel->getCityNamesByIds($cityArray);
     }
     if (!empty($stateArray)) {
         $stateModel = new Default_Model_States();
         $stateNameArray = $stateModel->getStateNamesByIds($stateArray);
     }
     if (!empty($countryArray)) {
         $countryModel = new Default_Model_Countries();
         $countryNameArray = $countryModel->getCountryNamesByIds($countryArray);
     }
     $finalArray = array();
     if (!empty($dataArray)) {
         foreach ($dataArray as $key => $curr) {
             $finalArray[$key]['id'] = $curr['id'];
             if (in_array("deptname", $columnArray)) {
                 $finalArray[$key]['deptname'] = $curr['deptname'];
             }
             if (in_array("unitname", $columnArray)) {
                 $finalArray[$key]['unitname'] = isset($businessNameArray[$curr['unitid']]) ? $businessNameArray[$curr['unitid']] : '';
             }
             if (in_array("deptcode", $columnArray)) {
                 $finalArray[$key]['deptcode'] = $curr['deptcode'];
             }
             if (in_array("empcount", $columnArray)) {
                 $finalArray[$key]['empcount'] = $curr['empcount'];
             }
             if (in_array("startdate", $columnArray)) {
                 $finalArray[$key]['startdate'] = $curr['startdate'];
             }
             if (in_array("address", $columnArray)) {
                 $finalArray[$key]['address1'] = $curr['address1'];
                 $finalArray[$key]['address'] = $curr['address1'];
             }
             if (in_array("ccity", $columnArray)) {
                 $finalArray[$key]['ccity'] = isset($cityNameArray[$curr['city']]) ? $cityNameArray[$curr['city']] : '';
             }
             if (in_array("sstate", $columnArray)) {
                 $finalArray[$key]['sstate'] = isset($stateNameArray[$curr['state']]) ? $stateNameArray[$curr['state']] : '';
             }
             if (in_array("ccountry", $columnArray)) {
                 $finalArray[$key]['ccountry'] = isset($countryNameArray[$curr['country']]) ? $countryNameArray[$curr['country']] : '';
             }
             if (in_array("status", $columnArray)) {
                 $finalArray[$key]['status'] = $curr['status'];
             }
         }
     }
     return $finalArray;
 }
 /**
  * This action is used for adding data.    
  * @return Zend_Form.
  */
 public function addAction()
 {
     $req_model = new Default_Model_Requisition();
     $cand_model = new Default_Model_Candidatedetails();
     $cand_work_model = new Default_Model_Candidateworkdetails();
     $countriesModel = new Default_Model_Countries();
     $auth = Zend_Auth::getInstance();
     $msgarray = array();
     $popConfigPermission = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
     $req_options = array();
     foreach ($req_data as $req) {
         $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
     }
     if (count($req_options) == 0) {
         $msgarray['requisition_id'] = "No approved requisitions.";
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Candidatedetails();
     $form->setAction(DOMAIN . 'candidatedetails/add');
     $countrieslistArr = $countriesModel->getTotalCountriesList();
     if (sizeof($countrieslistArr) > 0) {
         $form->country->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     } else {
         $msgarray['country'] = 'Countries are not configured yet';
     }
     $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
     if (isset($_POST['country']) && $_POST['country'] != '') {
         $statesmodel = new Default_Model_States();
         $statesmodeldata = $statesmodel->getStatesList(intval($_POST['country']));
         $st_opt = array();
         if (count($statesmodeldata) > 0) {
             foreach ($statesmodeldata as $dstate) {
                 $st_opt[$dstate['id'] . '!@#' . $dstate['state_name']] = $dstate['state_name'];
             }
         }
         $form->state->addMultiOptions(array('' => 'Select State') + $st_opt);
     }
     if (isset($_POST['state']) && $_POST['state'] != '') {
         $citiesmodel = new Default_Model_Cities();
         $citiesmodeldata = $citiesmodel->getCitiesList(intval($_POST['state']));
         $ct_opt = array();
         if (count($citiesmodeldata) > 0) {
             foreach ($citiesmodeldata as $dcity) {
                 $ct_opt[$dcity['id'] . '!@#' . $dcity['city_name']] = $dcity['city_name'];
             }
         }
         $form->city->addMultiOptions(array('' => 'Select City') + $ct_opt);
     }
     $data = array();
     $data['cand_resume'] = $this->_getParam('cand_resume');
     $data['selected_option'] = $this->_getParam('selected_option');
     $this->view->form = $form;
     $this->view->data = $data;
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->msgarray = $msgarray;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
Example #26
0
 /**
  * Gets all public data as an array, used in public profile page
  *
  * @author joel peltonen
  * @param id int user whose data we are to get
  * @return array of user data
  */
 public function getPublicData($id = -1)
 {
     if ($id == -1) {
         return false;
         // don't allow default value
     }
     // get only key and value fields, others are not needed
     $select = $this->select()->from($this, array('profile_key_usp', 'profile_value_usp'))->where('id_usr_usp = ?', $id)->where('public_usp = ?', 1);
     // roll to array and return
     $results = $this->fetchAll($select);
     foreach ($results as $result) {
         $collection[$result->profile_key_usp] = htmlentities($result->profile_value_usp);
     }
     // Change gender to M or N
     if (isset($collection['gender']) && $collection['gender'] == 1) {
         $collection['gender'] = 'Male';
     } else {
         if (isset($collection['gender']) && $collection['gender'] == 2) {
             $collection['gender'] = 'Female';
         }
     }
     // Change employment "code" to text
     if (isset($collection['employment'])) {
         $collection['employment'] = $this->getEmploymentByEmployment($collection['employment']);
     }
     // User timezone
     if (isset($collection['usertimezone'])) {
         $timezone_model = new Default_Model_Timezones();
         $collection['usertimezone'] = $timezone_model->getTimezoneTextById($collection['usertimezone']);
     }
     // User country
     if (isset($collection['country'])) {
         $country_model = new Default_Model_Countries();
         $collection['country'] = $country_model->getCountryPrintableNameByIso($collection['country']);
     }
     return $collection;
 }
Example #27
0
 public function configureorganisationAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     $new_stateId = '';
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     $msgarray = array();
     $new_stateId = '';
     $new_cityId = '';
     $id = $this->getRequest()->getParam('id');
     $form = new Default_Form_Organisationinfo();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $countriesModel = new Default_Model_Countries();
     $statesmodel = new Default_Model_States();
     $citiesmodel = new Default_Model_Cities();
     $wizard_model = new Default_Model_Wizard();
     $wizardData = $wizard_model->getWizardData();
     $orginfodata = $orgInfoModel->getOrganisationInfo();
     $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray();
     $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray();
     $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray();
     $form->setAttrib('action', DOMAIN . 'wizard/configureorganisation');
     $flag = 'true';
     if (empty($allCountriesData)) {
         $msgarray['country'] = 'Countries are not configured yet.';
         $flag = 'false';
     }
     if (empty($allStatesData)) {
         $msgarray['state'] = 'States are not configured yet.';
         $flag = 'false';
     }
     if (empty($allCitiesData)) {
         $msgarray['city'] = 'Cities are not configured yet.';
         $flag = 'false';
     }
     if (!empty($orginfodata)) {
         try {
             $data = $orginfodata[0];
             $data['org_startdate'] = sapp_Global::change_date($data['org_startdate'], 'view');
             $form->populate($data);
             $countryId = $data['country'];
             $stateId = $data['state'];
             $cityId = $data['city'];
             $actionpage = 'edit';
             if (count($_POST) > 0) {
                 $countryId = isset($_POST['country']) ? $_POST['country'] : "";
                 $stateId = isset($_POST['state']) ? $_POST['state'] : "";
                 $cityId = isset($_POST['city']) ? $_POST['city'] : "";
             }
             if ($countryId != '') {
                 $statesData = $statesmodel->getBasicStatesList((int) $countryId);
                 foreach ($statesData as $res) {
                     if ($stateId == $res['state_id_org']) {
                         $new_stateId = $res['state_id_org'] . '!@#' . utf8_encode($res['state']);
                     }
                     $form->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state']));
                 }
                 if (count($_POST) == 0) {
                     $stateId = $new_stateId;
                 }
             }
             if ($stateId != '') {
                 $citiesData = $citiesmodel->getBasicCitiesList((int) $stateId);
                 foreach ($citiesData as $res) {
                     if ($cityId == $res['city_org_id']) {
                         $new_cityId = $res['city_org_id'] . '!@#' . utf8_encode($res['city']);
                     }
                     $form->city->addMultiOption($res['city_org_id'] . '!@#' . utf8_encode($res['city']), utf8_encode($res['city']));
                 }
                 if (count($_POST) == 0) {
                     $cityId = $new_cityId;
                 }
             }
             $form->setDefault('country', $countryId);
             $form->setDefault('state', $stateId);
             $form->setDefault('city', $cityId);
             $this->view->domainValue = $data['domain'];
             $this->view->org_image = $data['org_image'];
             $this->view->ermsg = '';
             $this->view->datarr = $data;
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } else {
         sapp_Global::buildlocations($form, $wizardData);
     }
     $this->view->form = $form;
     if (!empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData)) {
         $this->view->configuremsg = '';
     } else {
         $this->view->configuremsg = 'notconfigurable';
     }
     $this->view->wizarddata = $wizardData;
     $this->view->msgarray = $msgarray;
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     if ($this->getRequest()->getPost()) {
         $result = $this->saveorginfo($form, $loginUserId, $wizardData);
         $this->view->msgarray = $result;
         if (isset($this->msgarray['domain'])) {
             $this->view->msMsg = 'multiselecterror';
         }
     }
 }
Example #28
0
 /**
  * This function acts as a service for adding a interview.
  * @param array $params_arr  = array of parameters
  * @return array  Array of results.
  */
 public function addinterview($params_arr)
 {
     $result = array();
     $status = 0;
     $message = "No access to add interview.";
     if (isset($params_arr['role_id']) && $params_arr['role_id'] != '' && isset($params_arr['group_id']) && $params_arr['group_id'] != '' && isset($params_arr['userid']) && $params_arr['userid'] != '') {
         $role_id = $params_arr['role_id'];
         $group_id = $params_arr['group_id'];
         $userid = $params_arr['userid'];
         if ($role_id == SUPERADMINROLE || $group_id == MANAGEMENT_GROUP || $group_id == HR_GROUP) {
             $privilege_flag = sapp_Global::_checkprivileges(SCHEDULEINTERVIEWS, $group_id, $role_id, 'add');
             if ($privilege_flag == 'Yes') {
                 $status = 1;
                 $message = "success";
                 $req_model = new Default_Model_Requisition();
                 $countryModal = new Default_Model_Countries();
                 $req_data = $req_model->getReqForInterviews();
                 $req_options = $requisition_options = array();
                 $countries_options = $cntry_options = array();
                 foreach ($req_data as $req) {
                     $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
                 }
                 $requisition_options = array('' => 'Select Requisition ID') + $req_options;
                 $countriesData = $countryModal->fetchAll('isactive=1', 'country');
                 foreach ($countriesData->toArray() as $data) {
                     $cntry_options[trim($data['country_id_org'])] = $data['country'];
                 }
                 $countries_options = array('' => 'Select country') + $cntry_options;
                 $interview_type_options = array('' => 'Select Interview Type', 'In person' => 'In person', 'Phone' => 'Phone', 'Video conference' => 'Video conference');
                 if (empty($req_options) && count($req_options) == 0) {
                     $status = 0;
                     $message = "No approved requisitions.";
                 } else {
                     if (empty($cntry_options) && count($cntry_options) == 0) {
                         $status = 0;
                         $message = "Countries are not configured yet.";
                     } else {
                         $result['req_id'] = $requisition_options;
                         $result['country'] = $countries_options;
                         $result['interview_mode'] = $interview_type_options;
                     }
                 }
             }
         }
     }
     return array('status' => $status, 'message' => $message, 'result' => $result);
 }