public function init() { $this->setMethod('post'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'currencyconverter'); $id = new Zend_Form_Element_Hidden('id'); $id_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('id'); $basecurrency = new Zend_Form_Element_Select('basecurrency'); $basecurrency->setAttrib('class', 'selectoption'); $basecurrency->addMultiOption('', 'Select base currency'); $basecurrency->setAttrib('onchange', 'displayTargetCurrency(this)'); $basecurrency->setRegisterInArrayValidator(false); $basecurrency->setRequired(true); $basecurrency->addValidator('NotEmpty', false, array('messages' => 'Please select base currency.')); $targetcurrency = new Zend_Form_Element_Select('targetcurrency'); $targetcurrency->setAttrib('class', 'selectoption'); $targetcurrency->addMultiOption('', 'Select target currency'); $targetcurrency->setRegisterInArrayValidator(false); $targetcurrency->setRequired(true); $targetcurrency->addValidator('NotEmpty', false, array('messages' => 'Please select target currency.')); if ($id_val == '') { $targetcurrency->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currencyconverter', 'field' => 'targetcurrency', 'exclude' => 'basecurrency="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('basecurrency') . '" AND targetcurrency="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('targetcurrency') . '" and isactive=1'))); $targetcurrency->getValidator('Db_NoRecordExists')->setMessage('Currency combination already exists.'); } $exchangerate = new Zend_Form_Element_Text("exchangerate"); $exchangerate->setAttrib('maxLength', 15); $exchangerate->addFilter(new Zend_Filter_StringTrim()); $exchangerate->setRequired(true); $exchangerate->addValidator('NotEmpty', false, array('messages' => 'Please enter exchange rate.')); $exchangerate->addValidator("regex", false, array("/^[0-9]+(\\.[0-9]{1,6})?\$/", "messages" => "Please enter valid exchange rate.")); $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')); $start_date->setRequired(true); $start_date->addValidator('NotEmpty', false, array('messages' => 'Please select start date.')); $end_date = new ZendX_JQuery_Form_Element_DatePicker('end_date'); $end_date->setAttrib('readonly', 'true'); $end_date->setAttrib('onfocus', 'this.blur()'); $end_date->setOptions(array('class' => 'brdr_none')); $end_date->setRequired(true); $end_date->addValidator('NotEmpty', false, array('messages' => 'Please select end date.')); $description = new Zend_Form_Element_Textarea('description'); $description->setAttrib('rows', 10); $description->setAttrib('cols', 50); $description->setAttrib('maxlength', '200'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $this->addElements(array($id, $basecurrency, $targetcurrency, $exchangerate, $start_date, $end_date, $description, $submit)); $this->setElementDecorators(array('ViewHelper')); $this->setElementDecorators(array('UiWidgetElement'), array('start_date', 'end_date')); }
public function init() { $this->setMethod('post'); //$this->setAttrib('action',BASE_URL.'timemanagement/projects/edit'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'projects'); $id = new Zend_Form_Element_Hidden('id'); $invoice_method = new Zend_Form_Element_Hidden('invoice_method'); $project_name = new Zend_Form_Element_Text('project_name'); $project_name->setAttrib('maxLength', 100); $project_name->setRequired(true); $project_name->addValidator('NotEmpty', false, array('messages' => 'Please enter project name.')); $project_name->addValidator("regex", true, array('pattern' => '/^(?![0-9]*$)[a-zA-Z0-9.,&\\(\\)\\/\\-_\' ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter a valid project name.'))); $project_name->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'tm_projects', 'field' => 'project_name', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and is_active=1'))); $project_name->getValidator('Db_NoRecordExists')->setMessage('Project name already exists.'); $projstatus = new Zend_Form_Element_Select('project_status'); $projstatus->addMultiOption('', 'Select Status'); $projstatus->addMultiOption('initiated', 'Initiated'); $projstatus->addMultiOption('draft', 'Draft'); $projstatus->addMultiOption('in-progress', 'In Progress'); $projstatus->addMultiOption('hold', 'Hold'); $projstatus->addMultiOption('completed', 'Completed'); $projstatus->setRequired(true); $projstatus->setRegisterInArrayValidator(false); $projstatus->addValidator('NotEmpty', false, array('messages' => 'Please select status.')); $base_project = new Zend_Form_Element_Select('base_project'); $base_project->addMultiOption('', 'Select Project'); $base_project->setRegisterInArrayValidator(false); $client = new Zend_Form_Element_Select('client_id'); $client->addMultiOption('', 'Select Client'); $client->setRegisterInArrayValidator(false); $client->setRequired(true); $client->addValidator('NotEmpty', false, array('messages' => 'Please select client.')); $client->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_clients', 'field' => 'id', 'exclude' => 'is_active = 1'))); $client->getValidator('Db_RecordExists')->setMessage('Selected client is inactivated.'); $description = new Zend_Form_Element_Textarea('description'); $description->setAttrib('rows', 10); $description->setAttrib('cols', 50); $description->setAttrib('maxlength', '500'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $this->addElements(array($id, $invoice_method, $project_name, $projstatus, $base_project, $description, $client, $submit)); $this->setElementDecorators(array('ViewHelper')); $this->setElementDecorators(array('UiWidgetElement'), array('start_date', 'end_date')); }
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')); }
public function init() { $this->setMethod('post'); $this->setAttrib('action', DOMAIN . 'employee/add'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'employee'); $controller_name = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $id = new Zend_Form_Element_Hidden('id'); $id_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null); $userid = new Zend_Form_Element_Hidden('user_id'); $reportingmanager = new Zend_Form_Element_Select('reporting_manager'); $reportingmanager->addMultiOption('', 'Select Reporting Manager'); $reportingmanager->setRegisterInArrayValidator(false); if ($controller_name != 'organisationinfo') { $reportingmanager->setRequired(true); $reportingmanager->addValidator('NotEmpty', false, array('messages' => 'Please select reporting manager.')); } $reportingmanager->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_users', 'field' => 'id', 'exclude' => 'isactive = 1'))); $reportingmanager->getValidator('Db_RecordExists')->setMessage('Selected reporting manager is inactivated.'); $emproleStr = Zend_Controller_Front::getInstance()->getRequest()->getParam('emprole', null); $empstatus = new Zend_Form_Element_Select('emp_status_id'); $empstatus->setAttrib('onchange', 'displayempstatusmessage()'); $empstatus->setRegisterInArrayValidator(false); if ($controller_name != 'organisationinfo') { $empstatus->setRequired(true); $empstatus->addValidator('NotEmpty', false, array('messages' => 'Please select employment status.')); } $empstatus->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_employmentstatus', 'field' => 'workcodename', 'exclude' => 'isactive = 1'))); $empstatus->getValidator('Db_RecordExists')->setMessage('Selected employment status is deleted.'); $businessunit = new Zend_Form_Element_Select('businessunit_id'); $businessunit->setAttrib('onchange', 'displayEmployeeDepartments(this,"department_id","")'); $businessunit->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_businessunits', 'field' => 'id', 'exclude' => 'isactive = 1'))); $businessunit->getValidator('Db_RecordExists')->setMessage('Selected business unit is deleted.'); $department = new Zend_Form_Element_Select('department_id'); $department->addMultiOption('', 'Select Department'); $department->setRegisterInArrayValidator(false); $roleArr = array(); if ($controller_name != 'organisationinfo') { //For management 'department is not manditory'...... if ($emproleStr != "") { $roleArr = explode('_', $emproleStr); if (!empty($roleArr)) { if (isset($roleArr[1]) && $roleArr[1] != MANAGEMENT_GROUP) { $department->setRequired(true); $department->addValidator('NotEmpty', false, array('messages' => 'Please select department.')); } } } else { $department->setRequired(true); $department->addValidator('NotEmpty', false, array('messages' => 'Please select department.')); } } $department->setAttrib("onchange", "displayReportingmanagers_emp('department_id','reporting_manager','emprole','id')"); $department->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_departments', 'field' => 'id', 'exclude' => 'isactive = 1'))); $department->getValidator('Db_RecordExists')->setMessage('Selected department is deleted.'); $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); $jobtitle->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_jobtitles', 'field' => 'id', 'exclude' => 'isactive = 1'))); $jobtitle->getValidator('Db_RecordExists')->setMessage('Selected job title is deleted.'); $position = new Zend_Form_Element_Select('position_id'); $position->setLabel("Position"); $position->addMultiOption('', 'Select Position'); $position->setRegisterInArrayValidator(false); $position->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_positions', 'field' => 'id', 'exclude' => 'isactive = 1'))); $position->getValidator('Db_RecordExists')->setMessage('Selected position is deleted.'); $prefix_id = new Zend_Form_Element_Select('prefix_id'); $prefix_id->addMultiOption('', 'Select Prefix'); $prefix_id->setLabel("Prefix"); $prefix_id->setRegisterInArrayValidator(false); $prefix_id->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_prefix', 'field' => 'id', 'exclude' => 'isactive = 1'))); $prefix_id->getValidator('Db_RecordExists')->setMessage('Selected prefix is deleted.'); $extension_number = new Zend_Form_Element_Text('extension_number'); $extension_number->setAttrib('maxLength', 4); $extension_number->setLabel("Extension"); $extension_number->addFilter(new Zend_Filter_StringTrim()); $extension_number->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers.'))); $office_number = new Zend_Form_Element_Text('office_number'); $office_number->setAttrib('maxLength', 10); $office_number->setLabel("Work Telephone Number"); $office_number->addFilter(new Zend_Filter_StringTrim()); $office_number->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9\\+\\-\\)\\(]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.'))); $office_faxnumber = new Zend_Form_Element_Text('office_faxnumber'); $office_faxnumber->setAttrib('maxLength', 15); $office_faxnumber->setLabel("Fax"); $office_faxnumber->addFilter(new Zend_Filter_StringTrim()); $office_faxnumber->addValidator("regex", true, array('pattern' => '/^[0-9\\+\\-\\)\\(]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid fax number.'))); $yearsofexp = new Zend_Form_Element_Text('years_exp'); $yearsofexp->setAttrib('maxLength', 2); $yearsofexp->addFilter(new Zend_Filter_StringTrim()); $yearsofexp->addValidator("regex", true, array('pattern' => '/^[0-9]\\d{0,1}(\\.\\d*)?$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers.'))); $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.')); $date_of_leaving = new ZendX_JQuery_Form_Element_DatePicker('date_of_leaving'); $date_of_leaving->setOptions(array('class' => 'brdr_none')); $date_of_leaving->setAttrib('onchange', 'validatejoiningdate(this)'); $date_of_leaving->setAttrib('readonly', 'true'); $date_of_leaving->setAttrib('onfocus', 'this.blur()'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); //fields from user management $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.')); $employeeId->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_users', 'field' => 'employeeId', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('user_id', 0) . '" '))); $employeeId->getValidator('Db_NoRecordExists')->setMessage('Employee ID already exists. Please try again.'); /*$userfullname = new Zend_Form_Element_Text("userfullname"); $userfullname->setLabel("Full Name"); $userfullname->setAttrib("class", "formDataElement"); $userfullname->setAttrib('maxlength', 50);*/ $first_name = new Zend_Form_Element_Text("firstname"); $first_name->setLabel("First Name"); $first_name->setAttrib("class", "formDataElement"); $first_name->setAttrib('maxlength', 50); $last_name = new Zend_Form_Element_Text("lastname"); $last_name->setLabel("Last Name"); $last_name->setAttrib("class", "formDataElement"); $last_name->setAttrib('maxlength', 50); $other_modeofentry = new Zend_Form_Element_Text("other_modeofentry"); $other_modeofentry->setLabel("Mode of Employment(Other)"); $other_modeofentry->setAttrib("class", "formDataElement"); $other_modeofentry->setAttrib('maxlength', 50); $modeofentry = new Zend_Form_Element_Select("modeofentry"); $modeofentry->setLabel("Mode of Employment")->addMultiOptions(array('' => 'Select mode of entry', 'Direct' => 'Direct', 'Interview' => 'Interview', 'Other' => 'Other', 'Reference' => 'Reference')); $modeofentry->setAttrib("class", "formDataElement"); if ($controller_name != 'organisationinfo') { if ($id_val == '') { $modeofentry->setRequired(true); $modeofentry->addValidator('NotEmpty', false, array('messages' => 'Please select mode of employment.')); } } $candidatereferredby = new Zend_Form_Element_Select("candidatereferredby"); $candidatereferredby->setRegisterInArrayValidator(false); $candidatereferredby->setLabel("Referred By"); $candidatereferredby->setAttrib("class", "formDataElement"); $rccandidatename = new Zend_Form_Element_Select("rccandidatename"); $rccandidatename->setRegisterInArrayValidator(false); $rccandidatename->setLabel("Candidate Name"); $rccandidatename->setAttrib("class", "formDataElement"); $rccandidatename->setAttrib("onchange", "disp_requisition(this.value,'disp_requi')"); $emailaddress = new Zend_Form_Element_Text("emailaddress"); $modeofentry_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('modeofentry', null); $hid_modeofentry_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('hid_modeofentry', null); if ($modeofentry_val != '' || $hid_modeofentry_val != '') { if ($modeofentry_val == 'Direct' || $hid_modeofentry_val == 'Direct') { /*$userfullname->setRequired(true); $userfullname->addValidator('NotEmpty', false, array('messages' => 'Please enter full name.'));*/ $first_name->setRequired(true); $first_name->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.')); $last_name->setRequired(true); $last_name->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.')); } else { if ($modeofentry_val == 'Other' || $hid_modeofentry_val == 'Direct') { $other_modeofentry->setRequired(true); $other_modeofentry->addValidator('NotEmpty', false, array('messages' => 'Please enter mode of employment(Other).')); $rccandidatename->setRequired(true); $rccandidatename->addValidator('NotEmpty', false, array('messages' => 'Please select candidate name.')); } else { if ($modeofentry_val == 'Reference' || $hid_modeofentry_val == 'Direct') { $candidatereferredby->setRequired(true); $candidatereferredby->addValidator('NotEmpty', false, array('messages' => 'Please select referred by.')); $rccandidatename->setRequired(true); $rccandidatename->addValidator('NotEmpty', false, array('messages' => 'Please select candidate name.')); } else { $empid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null); if ($empid == '') { $rccandidatename->setRequired(true); $rccandidatename->addValidator('NotEmpty', false, array('messages' => 'Please select candidate name.')); } } } } } /*$userfullname->addValidator("regex",true,array( 'pattern'=>'/^([a-zA-Z.]+ ?)+$/', 'messages'=>array( 'regexNotMatch'=>'Please enter only alphabets.' ) ));*/ $first_name->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.'))); $last_name->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.'))); $other_modeofentry->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.'))); $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('user_id', 0) . '" '))); $emailaddress->getValidator('Db_NoRecordExists')->setMessage('Email already exists.'); $role_id = ''; if ($emproleStr) { $rolArr = explode('_', $emproleStr); if (!empty($rolArr)) { if (isset($rolArr[0])) { $role_id = $rolArr[0]; } } } $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.')); $emprole->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_roles', 'field' => 'id', 'exclude' => 'isactive = 1 and id="' . $role_id . '" '))); $emprole->getValidator('Db_RecordExists')->setMessage('Selected role is deleted.'); $hid_modeofentry = new Zend_Form_Element_Hidden('hid_modeofentry'); $hid_rccandidatename = new Zend_Form_Element_Hidden('hid_rccandidatename'); $act_inact = new Zend_Form_Element_Checkbox("act_inact"); $disp_requi = new Zend_Form_Element_Text('disp_requi'); $disp_requi->setAttrib('readonly', 'readonly'); $disp_requi->setAttrib('onfocus', 'this.blur()'); //end of fields from user management $this->addElements(array($id, $userid, $reportingmanager, $empstatus, $businessunit, $department, $jobtitle, $position, $prefix_id, $extension_number, $office_number, $office_faxnumber, $yearsofexp, $date_of_joining, $date_of_leaving, $submit, $employeeId, $modeofentry, $candidatereferredby, $rccandidatename, $emailaddress, $emprole, $hid_modeofentry, $hid_rccandidatename, $other_modeofentry, $act_inact, $disp_requi, $first_name, $last_name)); $this->setElementDecorators(array('ViewHelper')); $this->setElementDecorators(array('UiWidgetElement'), array('date_of_joining', 'date_of_leaving')); }
public function init() { $this->setMethod('post'); $this->setAttrib('action', BASE_URL . 'timemanagement/expenses/edit'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'expensecategory'); $id = new Zend_Form_Element_Hidden('id'); $client = new Zend_Form_Element_Select('client_id'); $client->addMultiOption('', 'Select Client'); $client->setRegisterInArrayValidator(false); $client->setAttrib('onchange', 'loadProjects(this)'); $client->setRequired(true); $client->addValidator('NotEmpty', false, array('messages' => 'Please select Client.')); $client->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_clients', 'field' => 'id', 'exclude' => 'is_active = 1'))); $client->getValidator('Db_RecordExists')->setMessage('Selected Client is inactivated.'); $project = new Zend_Form_Element_Select('project_id'); $project->addMultiOption('', 'Select Project'); $project->setRegisterInArrayValidator(false); $project->setRequired(true); $project->addValidator('NotEmpty', false, array('messages' => 'Please select Project.')); $project->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_projects', 'field' => 'id', 'exclude' => 'is_active = 1'))); $project->getValidator('Db_RecordExists')->setMessage('Selected Project is inactivated.'); $category = new Zend_Form_Element_Select('expense_cat_id'); $category->addMultiOption('', 'Select Category'); $category->setRegisterInArrayValidator(false); $category->setRequired(true); $category->addValidator('NotEmpty', false, array('messages' => 'Please select Category.')); $category->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_expense_categories', 'field' => 'id', 'exclude' => 'is_active = 1'))); $category->getValidator('Db_RecordExists')->setMessage('Selected Category is inactivated.'); $expenseDate = new ZendX_JQuery_Form_Element_DatePicker('expense_date'); $expenseDate->setOptions(array('class' => 'brdr_none')); //$date_of_leaving->setAttrib('onchange', 'validatejoiningdate(this)'); $expenseDate->setAttrib('readonly', 'true'); $expenseDate->setAttrib('onfocus', 'this.blur()'); $expenseAmount = new Zend_Form_Element_Text('expense_amount'); $expenseAmount->setAttrib('maxLength', 8); $expenseAmount->setLabel("Unit Price"); $expenseAmount->addValidator("regex", true, array('pattern' => '/^[1-9]\\d{1,4}(\\.\\d{1,2})?$/', 'messages' => array('regexNotMatch' => 'Please enter valid Amount.'))); $note = new Zend_Form_Element_Text('note'); $note->setAttrib('maxLength', 200); $note->setLabel("Note"); $billable = new Zend_Form_Element_Radio('is_billable'); $billable->setLabel("Type"); $billable->addMultiOptions(array('1' => 'Yes', '0' => 'No')); $billable->setSeparator(''); $billable->setValue('billable'); $billable->setRegisterInArrayValidator(false); $billable->setRequired(true); $billable->addValidator('NotEmpty', false, array('messages' => 'Please select Type.')); /* client_idbigint(20) unsigned NOT NULL project_idbigint(20) unsigned NOT NULL expense_cat_idint(10) unsigned NOT NULL expense_datetimestamp NOT NULL expense_amountdecimal(8,2) unsigned NOT NULL notevarchar(200) NULL is_billabletinyint(1) unsigned NOT NULL receipt_filevarchar(200) NULL expense_statusenum('saved','submitted','approved','rejected') NULL status_update_datetimestamp NOT NULL status_update_byint(11) NULL reject_notevarchar(200) NULL */ $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $this->addElements(array($id, $client, $project, $category, $expenseDate, $expenseAmount, $note, $billable, $submit)); $this->setElementDecorators(array('ViewHelper')); $this->setElementDecorators(array('UiWidgetElement'), array('expense_date')); }
public function init() { $this->setMethod('post'); $this->setAttrib('action', DOMAIN . 'myemployees/add'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'myteamemployee'); $controller_name = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $id = new Zend_Form_Element_Hidden('id'); $id_val = Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null); $userid = new Zend_Form_Element_Hidden('user_id'); $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.')); $employeeId->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_users', 'field' => 'employeeId', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('user_id', 0) . '" '))); $employeeId->getValidator('Db_NoRecordExists')->setMessage('Employee ID already exists. Please try again.'); $prefix_id = new Zend_Form_Element_Select('prefix_id'); $prefix_id->addMultiOption('', 'Select Prefix'); $prefix_id->setLabel("Prefix"); $prefix_id->setRegisterInArrayValidator(false); $prefix_id->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_prefix', 'field' => 'id', 'exclude' => 'isactive = 1'))); $prefix_id->getValidator('Db_RecordExists')->setMessage('Selected prefix is deleted.'); $first_name = new Zend_Form_Element_Text("firstname"); $first_name->setLabel("First Name"); $first_name->setRequired(true); $first_name->addValidator('NotEmpty', false, array('messages' => 'Please enter first name.')); $first_name->setAttrib("class", "formDataElement"); $first_name->setAttrib('maxlength', 50); $first_name->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.'))); $last_name = new Zend_Form_Element_Text("lastname"); $last_name->setLabel("Last Name"); $last_name->setRequired(true); $last_name->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.')); $last_name->setAttrib("class", "formDataElement"); $last_name->setAttrib('maxlength', 50); $last_name->addValidator("regex", true, array('pattern' => '/^([a-zA-Z.]+ ?)+$/', 'messages' => array('regexNotMatch' => 'Please enter only alphabets.'))); $modeofentry = new Zend_Form_Element_Select("modeofentry"); $modeofentry->setLabel("Mode of Employment")->addMultiOptions(array('Direct' => 'Direct')); $modeofentry->setAttrib("class", "formDataElement"); if ($id_val == '') { $modeofentry->setRequired(true); $modeofentry->addValidator('NotEmpty', false, array('messages' => 'Please select mode of employment.')); } $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.')); $emprole->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_roles', 'field' => 'id', 'exclude' => 'isactive = 1'))); $emprole->getValidator('Db_RecordExists')->setMessage('Selected role is deleted.'); $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('user_id', 0) . '" '))); $emailaddress->getValidator('Db_NoRecordExists')->setMessage('Email already exists.'); $businessunit = new Zend_Form_Element_Select('businessunit_id'); $businessunit->setRegisterInArrayValidator(false); $businessunit->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_businessunits', 'field' => 'id', 'exclude' => 'isactive = 1'))); $businessunit->getValidator('Db_RecordExists')->setMessage('Selected business unit is deleted.'); $department = new Zend_Form_Element_Select('department_id'); $department->setRegisterInArrayValidator(false); $department->setRequired(true); $department->addValidator('NotEmpty', false, array('messages' => 'Please select department.')); $department->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_departments', 'field' => 'id', 'exclude' => 'isactive = 1'))); $department->getValidator('Db_RecordExists')->setMessage('Selected department is deleted.'); $reportingmanager = new Zend_Form_Element_Select('reporting_manager'); $reportingmanager->setRegisterInArrayValidator(false); $reportingmanager->setRequired(true); $reportingmanager->addValidator('NotEmpty', false, array('messages' => 'Please select reporting manager.')); $reportingmanager->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_users', 'field' => 'id', 'exclude' => 'isactive = 1'))); $reportingmanager->getValidator('Db_RecordExists')->setMessage('Selected reporting manager is inactivated.'); $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); $jobtitle->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_jobtitles', 'field' => 'id', 'exclude' => 'isactive = 1'))); $jobtitle->getValidator('Db_RecordExists')->setMessage('Selected job title is deleted.'); $position = new Zend_Form_Element_Select('position_id'); $position->setLabel("Position"); $position->addMultiOption('', 'Select Position'); $position->setRegisterInArrayValidator(false); $position->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_positions', 'field' => 'id', 'exclude' => 'isactive = 1'))); $position->getValidator('Db_RecordExists')->setMessage('Selected position is deleted.'); $empstatus = new Zend_Form_Element_Select('emp_status_id'); $empstatus->setAttrib('onchange', 'displayempstatusmessage()'); $empstatus->setRegisterInArrayValidator(false); $empstatus->setRequired(true); $empstatus->addValidator('NotEmpty', false, array('messages' => 'Please select employment status.')); $empstatus->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'main_employmentstatus', 'field' => 'workcodename', 'exclude' => 'isactive = 1'))); $empstatus->getValidator('Db_RecordExists')->setMessage('Selected employment status is deleted.'); $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.')); $date_of_leaving = new ZendX_JQuery_Form_Element_DatePicker('date_of_leaving'); $date_of_leaving->setOptions(array('class' => 'brdr_none')); $date_of_leaving->setAttrib('onchange', 'validatejoiningdate(this)'); $date_of_leaving->setAttrib('readonly', 'true'); $date_of_leaving->setAttrib('onfocus', 'this.blur()'); $yearsofexp = new Zend_Form_Element_Text('years_exp'); $yearsofexp->setAttrib('maxLength', 2); $yearsofexp->addFilter(new Zend_Filter_StringTrim()); $yearsofexp->addValidator("regex", true, array('pattern' => '/^[0-9]\\d{0,1}(\\.\\d*)?$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers.'))); $extension_number = new Zend_Form_Element_Text('extension_number'); $extension_number->setAttrib('maxLength', 4); $extension_number->setLabel("Extension"); $extension_number->addFilter(new Zend_Filter_StringTrim()); $extension_number->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers.'))); $office_number = new Zend_Form_Element_Text('office_number'); $office_number->setAttrib('maxLength', 10); $office_number->setLabel("Work Telephone Number"); $office_number->addFilter(new Zend_Filter_StringTrim()); $office_number->addValidator("regex", true, array('pattern' => '/^(?!0{10})[0-9\\+\\-\\)\\(]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid phone number.'))); $office_faxnumber = new Zend_Form_Element_Text('office_faxnumber'); $office_faxnumber->setAttrib('maxLength', 15); $office_faxnumber->setLabel("Fax"); $office_faxnumber->addFilter(new Zend_Filter_StringTrim()); $office_faxnumber->addValidator("regex", true, array('pattern' => '/^[0-9\\+\\-\\)\\(]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid fax number.'))); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $this->addElements(array($id, $userid, $reportingmanager, $empstatus, $businessunit, $department, $jobtitle, $position, $prefix_id, $extension_number, $office_number, $office_faxnumber, $yearsofexp, $date_of_joining, $date_of_leaving, $submit, $employeeId, $modeofentry, $emailaddress, $emprole, $first_name, $last_name)); $this->setElementDecorators(array('ViewHelper')); $this->setElementDecorators(array('UiWidgetElement'), array('date_of_joining', 'date_of_leaving')); }
/** * Utility function to create a select form element of countries * * @param string $name The element name (default `country`) * @param string $label The element label and title (default `Country`) * @return Zend_Form_Element_Select */ public static function createFormSelectElement($name = 'country', $label = 'Country') { $country = new Zend_Form_Element_Select($name); $country->setLabel($label)->setAttrib('title', $label)->setMultiOptions(['' => ' '] + self::getCountriesArray())->setAttrib('data-placeholder', 'Select your country...')->addValidator('InArray', true, [self::getCountriesKeys()]); $country->getValidator('InArray')->setMessage('You must choose a country', Zend_Validate_InArray::NOT_IN_ARRAY); return $country; }