Esempio n. 1
0
 public function init()
 {
     $this->setMethod('post');
     //$this->setAttrib('action',DOMAIN.'language/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'servicedeskrequests');
     $id = new Zend_Form_Element_Hidden('id');
     $postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
     $businessunit_id = new Zend_Form_Element_Select('businessunit_id');
     $businessunit_id->setLabel("Business Unit");
     $businessunit_id->setAttrib('class', 'selectoption');
     if ($postid == '') {
         $businessunit_id->setAttrib('onchange', 'displayemployees(this)');
         $bunitModel = new Default_Model_Businessunits();
         $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
         foreach ($bunitdata->toArray() as $data) {
             $businessunit_id->addMultiOption($data['id'], $data['unitname']);
         }
     } else {
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
     }
     $businessunit_id->setRegisterInArrayValidator(false);
     $businessunit_id->setRequired(true);
     $businessunit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
     $department_id = new Zend_Form_Element_Select('department_id');
     $department_id->setLabel("Department");
     $department_id->setAttrib('class', 'selectoption');
     $department_id->addMultiOption('', 'Select Department');
     if ($postid == '') {
         $department_id->setAttrib('onchange', 'displayemployees(this)');
     }
     $department_id->setRegisterInArrayValidator(false);
     $service_desk_flag = new Zend_Form_Element_Radio('service_desk_flag');
     $service_desk_flag->setLabel("Applicability");
     $service_desk_flag->setAttrib('onclick', 'changeimplementation(this)');
     $service_desk_flag->addMultiOptions(array('1' => 'Business unit wise', '0' => 'Department wise'));
     $service_desk_flag->setSeparator('');
     $service_desk_flag->setValue(1);
     $service_desk_flag->setRegisterInArrayValidator(false);
     $service_desk_flag->setRequired(true);
     $service_desk_flag->addValidator('NotEmpty', false, array('messages' => 'Please select applicability.'));
     $service_desk_id = new Zend_Form_Element_Select('service_desk_id');
     $service_desk_id->setLabel("Category");
     $service_desk_id->setAttrib('class', 'selectoption');
     $service_desk_id->addMultiOption('', 'Select category');
     $service_desk_id->setRegisterInArrayValidator(false);
     $service_desk_id->setRequired(true);
     $service_desk_id->addValidator('NotEmpty', false, array('messages' => 'Please select category.'));
     $request_recievers = new Zend_Form_Element_Multiselect('request_recievers');
     $request_recievers->setLabel("Executors");
     $request_recievers->setAttrib('class', 'selectoption');
     $request_recievers->setRegisterInArrayValidator(false);
     $request_recievers->setRequired(true);
     $request_recievers->addValidator('NotEmpty', false, array('messages' => 'Please select executor.'));
     $approvingauthority = new Zend_Form_Element_Select('approvingauthority');
     $approvingauthority->setLabel("No. of Approvers");
     $approvingauthority->setAttrib('class', 'selectoption');
     $approvingauthority->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approvingauthority->addMultiOptions(array('' => 'Select no. of approvers', '1' => '1', '2' => '2', '3' => '3'));
     $approvingauthority->setRegisterInArrayValidator(false);
     $approvingauthority->setRequired(true);
     $approvingauthority->addValidator('NotEmpty', false, array('messages' => 'Please select no. of approvers.'));
     $approver_1 = new Zend_Form_Element_Select('approver_1');
     $approver_1->setLabel("Approver 1");
     $approver_1->setAttrib('class', 'selectoption');
     $approver_1->addMultiOption('', 'Select Approver 1');
     $approver_1->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approver_1->setRegisterInArrayValidator(false);
     $approver_2 = new Zend_Form_Element_Select('approver_2');
     $approver_2->setLabel("Approver 2");
     $approver_2->setAttrib('class', 'selectoption');
     $approver_2->addMultiOption('', 'Select Approver 2');
     $approver_2->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approver_2->setRegisterInArrayValidator(false);
     $approver_3 = new Zend_Form_Element_Select('approver_3');
     $approver_3->setLabel("Approver 3");
     $approver_3->setAttrib('class', 'selectoption');
     $approver_3->addMultiOption('', 'Select Approver 3');
     $approver_3->setRegisterInArrayValidator(false);
     $cc_mail_recievers = new Zend_Form_Element_Multiselect('cc_mail_recievers');
     $cc_mail_recievers->setLabel("Request Viewers");
     $cc_mail_recievers->setAttrib('class', 'selectoption');
     $cc_mail_recievers->setRegisterInArrayValidator(false);
     $attachment = new Zend_Form_Element_Radio('attachment');
     $attachment->setLabel("Attachment");
     $attachment->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
     $attachment->setSeparator('');
     $attachment->setValue(0);
     $attachment->setRegisterInArrayValidator(false);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setLabel("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, $businessunit_id, $department_id, $description, $service_desk_flag, $service_desk_id, $request_recievers, $approvingauthority, $approver_1, $approver_2, $approver_3, $cc_mail_recievers, $attachment, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
 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;
     }
 }
 /**
  * 
  * View function is used to populate the data for the particular ID.
  */
 public function viewAction()
 {
     $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('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'appraisalconfig';
     $appraisalconfigform = new Default_Form_Appraisalconfig();
     $appraisalconfigmodel = new Default_Model_Appraisalconfig();
     $departmentsmodel = new Default_Model_Departments();
     $appraisalconfigform->removeElement("submit");
     $elements = $appraisalconfigform->getElements();
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $appraisalconfigmodel->getAppraisalConfigbyID($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     $previ_data = sapp_Global::_checkprivileges(APPRAISAL_SETTINGS, $loginuserGroup, $loginuserRole, 'edit');
                     $this->view->previ_data = $previ_data;
                     if ($data['department_id'] != '' && $data['department_id'] != 'NULL') {
                         $deptdata = $departmentsmodel->getSingleDepartmentData($data['department_id']);
                         if (sizeof($deptdata) > 0) {
                             $appraisalconfigform->department_id->addMultiOption($deptdata['id'], utf8_encode($deptdata['deptname']));
                         }
                     }
                     $bunitModel = new Default_Model_Businessunits();
                     $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
                     $appraisalconfigform->businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
                     foreach ($bunitdata->toArray() as $bdata) {
                         $appraisalconfigform->businessunit_id->addMultiOption($bdata['id'], $bdata['unitname']);
                     }
                     $appraisalconfigform->setDefault('businessunit_id', $data['businessunit_id']);
                     $this->view->performance_app_flag = $data['performance_app_flag'];
                     $appraisalconfigform->populate($data);
                     if (count($elements) > 0) {
                         foreach ($elements as $key => $element) {
                             if ($key != "Cancel" && $key != "Edit" && $key != "Delete") {
                                 $element->setAttrib("disabled", "disabled");
                             }
                         }
                     }
                     /** to show/hide edit button **/
                     $chkFlagForEdit = $appraisalconfigmodel->checkInitializationData($id);
                     $this->view->chkFlagForEdit = $chkFlagForEdit;
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->controllername = $objName;
     $this->view->id = $id;
     $this->view->form = $appraisalconfigform;
     $this->render('form');
 }
 /**
  * 
  * View function is used to populate the data for the particular ID.
  */
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'appraisalconfig';
     $appraisalconfigform = new Default_Form_Appraisalconfig();
     $appraisalconfigmodel = new Default_Model_Appraisalconfig();
     $departmentsmodel = new Default_Model_Departments();
     $appraisalconfigform->removeElement("submit");
     $elements = $appraisalconfigform->getElements();
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $appraisalconfigmodel->getAppraisalConfigbyID($id);
                 //echo "<pre>";print_r($data);echo "</pre>";
                 if (!empty($data)) {
                     $data = $data[0];
                     if ($data['department_id'] != '' && $data['department_id'] != 'NULL') {
                         $deptdata = $departmentsmodel->getSingleDepartmentData($data['department_id']);
                         if (sizeof($deptdata) > 0) {
                             $appraisalconfigform->department_id->addMultiOption($deptdata['id'], utf8_encode($deptdata['deptname']));
                         }
                     }
                     $bunitModel = new Default_Model_Businessunits();
                     $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
                     $appraisalconfigform->businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
                     foreach ($bunitdata->toArray() as $bdata) {
                         $appraisalconfigform->businessunit_id->addMultiOption($bdata['id'], $bdata['unitname']);
                     }
                     $appraisalconfigform->setDefault('businessunit_id', $data['businessunit_id']);
                     $this->view->performance_app_flag = $data['performance_app_flag'];
                     $appraisalconfigform->populate($data);
                     if (count($elements) > 0) {
                         foreach ($elements as $key => $element) {
                             if ($key != "Cancel" && $key != "Edit" && $key != "Delete") {
                                 $element->setAttrib("disabled", "disabled");
                             }
                         }
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->controllername = $objName;
     $this->view->id = $id;
     $this->view->form = $appraisalconfigform;
     $this->render('form');
 }
 /**
  * 
  * View function is used to populate the data for the particular ID.
  */
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'servicedeskconf';
     $servicedeskconfform = new Default_Form_servicedeskconf();
     $servicedeskconfmodel = new Default_Model_Servicedeskconf();
     $servicedeskdepartmentmodel = new Default_Model_Servicedeskdepartment();
     $departmentsmodel = new Default_Model_Departments();
     $employeemodel = new Default_Model_Employee();
     $approvingauthflag = '';
     $servicedeskconfform->removeElement("submit");
     $elements = $servicedeskconfform->getElements();
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $servicedeskconfmodel->getServiceDeskConfbyID($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     if ($data['department_id'] != '' && $data['department_id'] != 'NULL') {
                         $deptdata = $departmentsmodel->getSingleDepartmentData($data['department_id']);
                         if (sizeof($deptdata) > 0) {
                             $servicedeskconfform->department_id->addMultiOption($deptdata['id'], utf8_encode($deptdata['deptname']));
                         }
                     }
                     if ($data['service_desk_id'] != '' && $data['service_desk_id'] != 'NULL') {
                         $serviceDeptData = $servicedeskdepartmentmodel->getServiceDeskDepartmentDatabyID($data['service_desk_id']);
                         if (sizeof($serviceDeptData) > 0) {
                             $servicedeskconfform->service_desk_id->addMultiOption($serviceDeptData[0]['id'], utf8_encode($serviceDeptData[0]['service_desk_name']));
                         }
                     }
                     if ($data['request_recievers'] != '' && $data['request_recievers'] != 'NULL') {
                         $reqrecieverdata = $employeemodel->getEmployeeDetails($data['request_recievers']);
                         if (sizeof($reqrecieverdata) > 0) {
                             $servicedeskconfform->request_recievers->setMultiOptions($reqrecieverdata);
                         }
                         $req_recievers_arr = explode(',', $data['request_recievers']);
                     }
                     if ($data['cc_mail_recievers'] != '' && $data['cc_mail_recievers'] != 'NULL') {
                         $ccmaildata = $employeemodel->getEmployeeDetails($data['cc_mail_recievers']);
                         if (sizeof($ccmaildata) > 0) {
                             $servicedeskconfform->cc_mail_recievers->setMultiOptions($ccmaildata);
                         }
                     }
                     if ($data['approver_1'] != '' && $data['approver_1'] != 'NULL') {
                         $approver1data = $employeemodel->getIndividualEmpDetails($data['approver_1']);
                         if (sizeof($approver1data) > 0) {
                             $servicedeskconfform->approver_1->addMultiOption($approver1data['user_id'], utf8_encode($approver1data['userfullname']));
                         }
                         $approvingauthflag = 1;
                     }
                     if ($data['approver_2'] != '' && $data['approver_2'] != 'NULL') {
                         $approver2data = $employeemodel->getIndividualEmpDetails($data['approver_2']);
                         if (sizeof($approver2data) > 0) {
                             $servicedeskconfform->approver_2->addMultiOption($approver2data['user_id'], utf8_encode($approver2data['userfullname']));
                         }
                         $approvingauthflag = 2;
                     }
                     if ($data['approver_3'] != '' && $data['approver_3'] != 'NULL') {
                         $approver3data = $employeemodel->getIndividualEmpDetails($data['approver_3']);
                         if (sizeof($approver3data) > 0) {
                             $servicedeskconfform->approver_3->addMultiOption($approver3data['user_id'], utf8_encode($approver3data['userfullname']));
                         }
                         $approvingauthflag = 3;
                     }
                     $bunitModel = new Default_Model_Businessunits();
                     $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
                     $servicedeskconfform->businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
                     foreach ($bunitdata->toArray() as $bdata) {
                         $servicedeskconfform->businessunit_id->addMultiOption($bdata['id'], $bdata['unitname']);
                     }
                     $servicedeskconfform->setDefault('businessunit_id', $data['businessunit_id']);
                     $servicedeskconfform->setDefault('approvingauthority', $approvingauthflag);
                     $this->view->approvingauthflag = $approvingauthflag;
                     $this->view->service_desk_flag = $data['service_desk_flag'];
                     $this->view->request_recievers_value = $data['request_recievers'];
                     $this->view->cc_mail_recievers_value = $data['cc_mail_recievers'] != '' ? $data['cc_mail_recievers'] : '';
                     $servicedeskconfform->populate($data);
                     if (count($elements) > 0) {
                         foreach ($elements as $key => $element) {
                             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                 $element->setAttrib("disabled", "disabled");
                             }
                         }
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->controllername = $objName;
     $this->view->id = $id;
     $this->view->form = $servicedeskconfform;
     $this->render('form');
 }
Esempio n. 6
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', BASE_URL . 'departments/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'departments');
     $id = new Zend_Form_Element_Hidden('id');
     $deptname = new Zend_Form_Element_Text('deptname');
     $deptname->setAttrib('maxLength', 50);
     $deptname->addFilter(new Zend_Filter_StringTrim());
     $deptname->setRequired(true);
     $deptname->addValidator('NotEmpty', false, array('messages' => 'Please enter department name.'));
     $deptname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z.\\- ?]+$/', 'messages' => array('regexNotMatch' => 'Please enter valid department name.')));
     $deptcode = new Zend_Form_Element_Text('deptcode');
     $deptcode->addFilter(new Zend_Filter_StringTrim());
     $deptcode->setRequired(true);
     $deptcode->setAttrib("maxlength", 4);
     $deptcode->addValidator('NotEmpty', false, array('messages' => 'Please enter department code.'));
     $deptcode->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.')))));
     $deptcode->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 department code.')))));
     $deptcode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_departments', 'field' => 'deptcode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" AND isactive=1')));
     $deptcode->getValidator('Db_NoRecordExists')->setMessage('Department 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'));
     $unitid = new Zend_Form_Element_Select('unitid');
     $unitid->setLabel('unitid');
     $unitid->setAttrib('onchange', 'validateorgandunitstartdate(this,"deptunit")');
     $bunitModel = new Default_Model_Businessunits();
     $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
     $unitid->addMultiOption('0', 'No Business Unit');
     foreach ($bunitdata->toArray() as $data) {
         $unitid->addMultiOption($data['id'], $data['unitname']);
     }
     $bUnitid = Zend_Controller_Front::getInstance()->getRequest()->getParam('unitId');
     if ($bUnitid == '') {
     }
     $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('class', 'selectoption');
     $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->setAttrib('class', 'selectoption');
     $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);
     $depthead = new Zend_Form_Element_Select('depthead');
     $depthead->setAttrib('class', 'selectoption');
     $depthead->setLabel('Department Head');
     $depthead->setRequired(true);
     $depthead->addValidator('NotEmpty', false, array('messages' => 'Please select department head.'));
     $depthead->addMultiOption('', 'Select Department Head');
     $depthead->setRegisterInArrayValidator(false);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $deptname, $deptcode, $description, $start_date, $unitid, $country, $state, $city, $address1, $address2, $address3, $timezone, $depthead, $submit));
     $this->setElementDecorators(array('ViewHelper'));
     $this->setElementDecorators(array('UiWidgetElement'), array('start_date'));
 }
Esempio n. 7
0
 public function init()
 {
     $this->setMethod('post');
     //$this->setAttrib('action',DOMAIN.'language/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'appraisalconfig');
     $id = new Zend_Form_Element_Hidden('id');
     $postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
     $businessunit_id = new Zend_Form_Element_Select('businessunit_id');
     $businessunit_id->setLabel("Business Unit");
     $businessunit_id->setAttrib('class', 'selectoption');
     if ($postid == '') {
         $businessunit_id->setAttrib('onchange', 'displayDept(this)');
         $bunitModel = new Default_Model_Businessunits();
         $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
         foreach ($bunitdata->toArray() as $data) {
             $businessunit_id->addMultiOption($data['id'], $data['unitname']);
         }
     } else {
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
     }
     $businessunit_id->setRegisterInArrayValidator(false);
     $businessunit_id->setRequired(true);
     $businessunit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
     $department_id = new Zend_Form_Element_Select('department_id');
     $department_id->setLabel("Department");
     $department_id->setAttrib('class', 'selectoption');
     $department_id->addMultiOption('', 'Select Department');
     if ($postid == '') {
         $department_id->setAttrib('onchange', 'displayDept(this)');
     }
     $department_id->setRegisterInArrayValidator(false);
     $performance_app_flag = new Zend_Form_Element_Radio('performance_app_flag');
     $performance_app_flag->setLabel("Applicability");
     $performance_app_flag->setAttrib('onclick', 'checkimplementfun(this)');
     $performance_app_flag->addMultiOptions(array('1' => 'Business unit wise', '0' => 'Department wise'));
     $performance_app_flag->setSeparator('');
     $performance_app_flag->setValue(1);
     $performance_app_flag->setRegisterInArrayValidator(false);
     $performance_app_flag->setRequired(true);
     $performance_app_flag->addValidator('NotEmpty', false, array('messages' => 'Please select applicability.'));
     $appraisal_mode = new Zend_Form_Element_Select('appraisal_mode');
     $appraisal_mode->setLabel("Appraisal Mode");
     $appraisal_mode->setAttrib('class', 'selectoption');
     $appraisal_mode->addMultiOptions(array('' => 'Select appraisal mode', 'Quarterly' => 'Quarterly', 'Half yearly' => 'Half yearly', 'Yearly' => 'Yearly'));
     $appraisal_mode->setRegisterInArrayValidator(false);
     $appraisal_mode->setRequired(true);
     $appraisal_mode->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal mode.'));
     $approval_selection = new Zend_Form_Element_Select('approval_selection');
     $approval_selection->setLabel("Appraisal Level");
     $approval_selection->setAttrib('class', 'selectoption');
     $approval_selection->addMultiOptions(array('' => 'Select appraisal level', '1' => 'HR', '2' => 'Manager'));
     $approval_selection->setRegisterInArrayValidator(false);
     $approval_selection->setRequired(true);
     $approval_selection->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal level.'));
     $appraisal_ratings = new Zend_Form_Element_Select('appraisal_ratings');
     $appraisal_ratings->setLabel("Appraisal Ratings");
     $appraisal_ratings->setAttrib('class', 'selectoption');
     $appraisal_ratings->addMultiOptions(array('' => 'Select ratings', '1' => '1-5', '2' => '1-10'));
     $appraisal_ratings->setRegisterInArrayValidator(false);
     $appraisal_ratings->setRequired(true);
     $appraisal_ratings->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal ratings.'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $businessunit_id, $performance_app_flag, $department_id, $appraisal_mode, $approval_selection, $appraisal_ratings, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }