示例#1
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', BASE_URL . 'geographygroup/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'geographygroup');
     $id = new Zend_Form_Element_Hidden('id');
     $geographygroupname = new Zend_Form_Element_Text('geographygroupname');
     $geographygroupname->setAttrib('maxLength', 50);
     $geographygroupname->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid geography group.')))));
     $geographygroupname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_geographygroup', 'field' => 'geographygroupname', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $geographygroupname->getValidator('Db_NoRecordExists')->setMessage('Geography group name already exists.');
     $geographyregion = new Zend_Form_Element_Text('geographyregion');
     $geographyregion->setAttrib('maxLength', 20);
     $geographyregion->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid geography region.')));
     $geographycityname = new Zend_Form_Element_Text('geographycityname');
     $geographycityname->setAttrib('maxLength', 20);
     $geographycityname->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid geography city.')))));
     $defaultGeographyGroup = new Zend_Form_Element_Text('defaultGeographyGroup');
     $defaultGeographyGroup->setAttrib('maxLength', 20);
     $defaultGeographyGroup->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid default geography group.')));
     $geographycode = new Zend_Form_Element_Text('geographycode');
     $geographycode->setAttrib('maxLength', 20);
     $geographycode->setRequired(true);
     $geographycode->addValidator('NotEmpty', false, array('messages' => 'Please enter geography code.'));
     $geographycode->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid geography code.')));
     $geographycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_geographygroup', 'field' => 'geographycode', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" and isactive=1')));
     $geographycode->getValidator('Db_NoRecordExists')->setMessage('Geography code already exists.');
     $currency = new Zend_Form_Element_Select('currency');
     $currency->setAttrib('class', 'selectoption');
     $currency->setRegisterInArrayValidator(false);
     $currency->addMultiOption('', 'Select Currency');
     $currencymodel = new Default_Model_Currency();
     $currencymodeldata = $currencymodel->getCurrencyList();
     foreach ($currencymodeldata as $currencyres) {
         $currency->addMultiOption($currencyres['id'], utf8_encode($currencyres['currency']));
     }
     $currency->setRequired(true);
     $currency->addValidator('NotEmpty', false, array('messages' => 'Please select currency.'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $geographygroupname, $geographyregion, $geographycityname, $defaultGeographyGroup, $geographycode, $currency, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
示例#2
0
 public function savesitepreference($wizardpreferenceform, $wizardData)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     if ($wizardpreferenceform->isValid($this->_request->getPost())) {
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $systempreferencemodel = new Default_Model_Sitepreference();
             $currencymodel = new Default_Model_Currency();
             $orgInfoModel = new Default_Model_Organisationinfo();
             $wizard_model = new Default_Model_Wizard();
             $IdentityCodesModel = new Default_Model_Identitycodes();
             $employmentstatusmodel = new Default_Model_Employmentstatus();
             $countriesmodel = new Default_Model_Countries();
             $statesmodel = new Default_Model_States();
             $citiesmodel = new Default_Model_Cities();
             $id = (int) $this->_request->getParam('id');
             $currencyid = (int) $this->_request->getParam('currencyid');
             $organisationid = (int) $this->_request->getParam('organisationid');
             $empcodeid = (int) $this->_request->getParam('empcodeid');
             $dateformatid = $this->_request->getParam('dateformatid');
             $timeformatid = $this->_request->getParam('timeformatid');
             $timezoneid = $this->_request->getParam('timezoneid');
             $currencyname = $this->_request->getParam('currencyname');
             $currencycode = $this->_request->getParam('currencycode');
             $passwordid = $this->_request->getParam('passwordid');
             $perm_country = $this->_request->getParam('perm_country');
             $perm_stateparam = $this->_request->getParam('perm_state');
             $perm_stateArr = explode("!@#", $this->_request->getParam('perm_state'));
             $perm_state = $perm_stateArr[0];
             $perm_cityparam = $this->_request->getParam('perm_city');
             $perm_cityArr = explode("!@#", $this->_request->getParam('perm_city'));
             $perm_city = $perm_cityArr[0];
             $employee_code = $this->_request->getParam('employee_code');
             $workcodename = $this->_request->getParam('workcodename');
             $date = new Zend_Date();
             $menumodel = new Default_Model_Menu();
             /*
              * Save or Update - Currency name in currency table based on currency ID
              */
             $currency_data = array('currencyname' => trim($currencyname), 'currencycode' => trim($currencycode), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($currencyid != '') {
                 $currencywhere = array('id=?' => $currencyid);
             } else {
                 $currency_data['createdby'] = $loginUserId;
                 $currency_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $currency_data['isactive'] = 1;
                 $currencywhere = '';
             }
             $CurrencyId = $currencymodel->SaveorUpdateCurrencyData($currency_data, $currencywhere);
             /*
              * End 
              */
             /*
              * Start -  Updating and Inserting Site Preference Data after fetching currency id
              */
             $siteprference_data = array('dateformatid' => $dateformatid, 'timeformatid' => $timeformatid, 'timezoneid' => $timezoneid, 'currencyid' => $currencyid != '' ? $currencyid : $CurrencyId, 'passwordid' => $passwordid, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'isactive' => 1);
             $site_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId);
             $systempreferencemodel->SaveorUpdateSystemPreferanceData($site_update_arr, 'isactive = 1');
             $Id = $systempreferencemodel->SaveorUpdateSystemPreferanceData($siteprference_data, '');
             /*
              *  End
              */
             /*
              * Updating Country,state and city based on organisation id
              */
             // Inserting into main_countries if not added
             $countryExistsArr = $countriesmodel->getActiveCountryName($perm_country);
             if (empty($countryExistsArr)) {
                 $countrynamearr = $countriesmodel->getCountryCode($perm_country);
                 if (!empty($countrynamearr)) {
                     $country_data = array('country' => trim($countrynamearr[0]['country_name']), 'countrycode' => trim($countrynamearr[0]['country_code']), 'citizenship' => NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'country_id_org' => $perm_country, 'isactive' => 1);
                     $Country_Id = $countriesmodel->SaveorUpdateCountryData($country_data, '');
                 }
             }
             // Inserting into main_state if not added
             $State_Id = $statesmodel->SaveorUpdateStatesData($perm_country, $perm_stateArr[1], $perm_state, $loginUserId);
             // Inserting into main_cities if not added
             $City_Id = $citiesmodel->SaveorUpdateCitiesData($perm_country, $perm_state, $perm_cityArr[1], $perm_city, $loginUserId);
             $location_data = array('country' => $perm_country, 'state' => $perm_state, 'city' => $perm_city, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
             if ($organisationid != '') {
                 $locwhere = array('id=?' => $organisationid);
                 $LocationId = $orgInfoModel->SaveorUpdateData($location_data, $orgwhere);
             }
             $LocationId = $wizard_model->SaveorUpdateWizardData($location_data, '');
             /*
              * End
              */
             /*
              * Start - Updating Employee Code
              */
             $empcode_data = array('employee_code' => trim($employee_code), 'modifiedBy' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($empcodeid != '') {
                 $empcodewhere = array('id=?' => $empcodeid);
             } else {
                 $empcode_data['createdby'] = $loginUserId;
                 $empcode_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $empcodewhere = '';
             }
             $EmpCodeId = $IdentityCodesModel->SaveorUpdateIdentitycodesData($empcode_data, $empcodewhere);
             /*
              * End
              */
             /*
              * Start - Update employment status data
              */
             if (!empty($workcodename)) {
                 $empstat_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId);
                 $Empstat_update_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstat_update_arr, 'isactive=1');
                 for ($j = 0; $j < sizeof($workcodename); $j++) {
                     switch ($workcodename[$j]) {
                         case 1:
                             $workcode = 'FT';
                             break;
                         case 2:
                             $workcode = 'PT';
                             break;
                         case 3:
                             $workcode = 'PERM';
                             break;
                         case 4:
                             $workcode = 'TEMP';
                             break;
                         case 5:
                             $workcode = 'PROB';
                             break;
                         case 6:
                             $workcode = 'CONT';
                             break;
                         case 7:
                             $workcode = 'DEP';
                             break;
                         case 8:
                             $workcode = 'RES';
                             break;
                         case 9:
                             $workcode = 'LEFT';
                             break;
                         case 10:
                             $workcode = 'SUSP';
                             break;
                         default:
                             $workcode = 'FT';
                     }
                     $empstatus_data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename[$j]), 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
                     $Empstat_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstatus_data, '');
                 }
             }
             /*
              * End
              */
             /*
              * Update Wizard Table
              */
             $wizardarray = array('site_config' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($wizardData['org_details'] == 2) {
                 $wizardarray['iscomplete'] = 2;
             }
             $wizard_model->SaveorUpdateWizardData($wizardarray, '');
             $trDb->commit();
             $this->_helper->getHelper("FlashMessenger")->addMessage("Site Preference updated successfully.");
             $this->_redirect('wizard/configuresite');
         } catch (Exception $e) {
             $trDb->rollBack();
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong,please try again later."));
             $this->_redirect('wizard/configuresite');
         }
     } else {
         $messages = $wizardpreferenceform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
示例#3
0
 public function gettargetcurrencyAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('gettargetcurrency', 'html')->initContext();
     $basecurr_id = $this->_request->getParam('basecurr_id');
     $currencyconverterform = new Default_Form_currencyconverter();
     $currencymodel = new Default_Model_Currency();
     $targetcurrencydata = $currencymodel->getTargetCurrencyList($basecurr_id);
     $this->view->currencyconverterform = $currencyconverterform;
     $this->view->targetcurrencydata = $targetcurrencydata;
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     $msgarray = array();
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $systempreferenceform = new Default_Form_systempreference();
     $dateformatidmodel = new Default_Model_Dateformat();
     $timeformatidmodel = new Default_Model_Timeformat();
     $currencyidmodel = new Default_Model_Currency();
     $systempreferencemodel = new Default_Model_Sitepreference();
     $date_formats_arr = array();
     $time_formats_arr = array();
     $passworddataArr = array();
     $timezonemodel = new Default_Model_Timezone();
     $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray();
     if (sapp_Global::_checkprivileges(CURRENCY, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'currency');
     }
     if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'timezone');
     }
     if ($id && $id > 0 && is_numeric($id)) {
         try {
             $data = $systempreferencemodel->getsingleSystemPreferanceData($id);
             $date_formats_arr = $dateformatidmodel->getAllDateFormats();
             $time_formats_arr = $timeformatidmodel->fetchAll()->toArray();
             $currencyidmodeldata = $currencyidmodel->getCurrencyList();
             $systempreferenceform->currencyid->addMultiOption('', 'Select Currency');
             if (sizeof($currencyidmodeldata) > 0) {
                 foreach ($currencyidmodeldata as $currencyidres) {
                     $systempreferenceform->currencyid->addMultiOption($currencyidres['id'], utf8_encode($currencyidres['currencytext']));
                 }
             }
             $systempreferenceform->passwordid->addMultiOption('', 'Select Password Preference');
             $passworddataArr = $systempreferencemodel->getPasswordData();
             foreach ($passworddataArr as $passwordres) {
                 $systempreferenceform->passwordid->addMultiOption($passwordres['id'], utf8_encode($passwordres['passwordtype']));
             }
             if (sizeof($allTimezoneData) > 0) {
                 foreach ($allTimezoneData as $timezoneidres) {
                     $systempreferenceform->timezoneid->addMultiOption($timezoneidres['id'], utf8_encode($timezoneidres['timezone'] . ' [' . $timezoneidres['timezone_abbr'] . ']'));
                 }
             } else {
                 $msgarray['timezoneid'] = 'Time Zone is not configured yet.';
             }
             $systempreferenceform->populate($data);
             $systempreferenceform->setDefault('dateformatid', $data['dateformatid']);
             $systempreferenceform->setDefault('timeformatid', $data['timeformatid']);
             $systempreferenceform->setDefault('currencyid', $data['currencyid']);
             $systempreferenceform->setDefault('passwordid', $data['passwordid']);
             $systempreferenceform->setAttrib('action', DOMAIN . 'sitepreference/edit/id/' . $id);
             $this->view->msgarray = $msgarray;
         } catch (Exception $e) {
             $this->view->nodata = "nodata";
         }
     } else {
         $this->view->nodata = "nodata";
     }
     $this->view->form = $systempreferenceform;
     $this->view->date_formats_arr = $date_formats_arr;
     $this->view->time_formats_arr = $time_formats_arr;
     $this->view->passworddata = $passworddataArr;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($systempreferenceform);
         $this->view->msgarray = $result;
     }
     $this->view->popConfigPermission = $popConfigPermission;
 }
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_salary', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'empsalarydetails';
             $empsalarydetailsform = new Default_Form_empsalarydetails();
             $empsalarydetailsform->removeElement("submit");
             $elements = $empsalarydetailsform->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) {
                     $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)) {
                             $empsalarydetailsModal = new Default_Model_Empsalarydetails();
                             $usersModel = new Default_Model_Users();
                             $currencymodel = new Default_Model_Currency();
                             $accountclasstypemodel = new Default_Model_Accountclasstype();
                             $bankaccounttypemodel = new Default_Model_Bankaccounttype();
                             $data = $empsalarydetailsModal->getsingleEmpSalaryDetailsData($id);
                             if (!empty($data)) {
                                 if (isset($data[0]['currencyid']) && $data[0]['currencyid'] != '') {
                                     $currencyArr = $currencymodel->getCurrencyDataByID($data[0]['currencyid']);
                                     if (sizeof($currencyArr) > 0) {
                                         $empsalarydetailsform->currencyid->addMultiOption($currencyArr[0]['id'], $currencyArr[0]['currencyname'] . ' ' . $currencyArr[0]['currencycode']);
                                     }
                                 }
                                 if (isset($data[0]['accountclasstypeid']) && $data[0]['accountclasstypeid'] != '') {
                                     $accountclasstypeArr = $accountclasstypemodel->getsingleAccountClassTypeData($data[0]['accountclasstypeid']);
                                     if (sizeof($accountclasstypeArr) > 0) {
                                         $empsalarydetailsform->accountclasstypeid->addMultiOption($accountclasstypeArr[0]['id'], $accountclasstypeArr[0]['accountclasstype']);
                                     }
                                 }
                                 if (isset($data[0]['bankaccountid']) && $data[0]['bankaccountid'] != '') {
                                     $bankaccounttypeArr = $bankaccounttypemodel->getsingleBankAccountData($data[0]['bankaccountid']);
                                     if ($bankaccounttypeArr != 'norows') {
                                         $empsalarydetailsform->bankaccountid->addMultiOption($bankaccounttypeArr[0]['id'], $bankaccounttypeArr[0]['bankaccounttype']);
                                     }
                                 }
                                 $empsalarydetailsform->populate($data[0]);
                                 if ($data[0]['accountholding'] != '') {
                                     $accountholding = sapp_Global::change_date($data[0]["accountholding"], 'view');
                                     $empsalarydetailsform->accountholding->setValue($accountholding);
                                 }
                             }
                             $this->view->controllername = $objName;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->form = $empsalarydetailsform;
                             $this->view->employeedata = $empdata[0];
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function salarydetailsAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_salary', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             $emptyFlag = 0;
             $tabName = 'salarydetails';
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $loginUserId;
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $empsalarydetailsform = new Default_Form_empsalarydetails();
             try {
                 if ($id) {
                     $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)) {
                             $empsalarydetailsModal = new Default_Model_Empsalarydetails();
                             $usersModel = new Default_Model_Users();
                             $currencymodel = new Default_Model_Currency();
                             $accountclasstypemodel = new Default_Model_Accountclasstype();
                             $bankaccounttypemodel = new Default_Model_Bankaccounttype();
                             $msgarray = array();
                             $basecurrencymodeldata = $currencymodel->getCurrencyList();
                             if (sizeof($basecurrencymodeldata) > 0) {
                                 $empsalarydetailsform->currencyid->addMultiOption('', 'Select Salary Currency');
                                 foreach ($basecurrencymodeldata as $basecurrencyres) {
                                     $empsalarydetailsform->currencyid->addMultiOption($basecurrencyres['id'], utf8_encode($basecurrencyres['currency']));
                                 }
                             } else {
                                 $msgarray['currencyid'] = 'Currencies are not configured yet.';
                                 $emptyFlag++;
                             }
                             $bankaccounttypeArr = $bankaccounttypemodel->getBankAccountList();
                             if (!empty($bankaccounttypeArr)) {
                                 $empsalarydetailsform->bankaccountid->addMultiOption('', 'Select Bank Account Type');
                                 foreach ($bankaccounttypeArr as $bankaccounttyperes) {
                                     $empsalarydetailsform->bankaccountid->addMultiOption($bankaccounttyperes['id'], $bankaccounttyperes['bankaccounttype']);
                                 }
                             } else {
                                 $msgarray['bankaccountid'] = 'Bank account types are not configured yet.';
                                 $emptyFlag++;
                             }
                             $accountclasstypeArr = $accountclasstypemodel->getAccountClassTypeList();
                             if (!empty($accountclasstypeArr)) {
                                 $empsalarydetailsform->accountclasstypeid->addMultiOption('', 'Select Account Type');
                                 foreach ($accountclasstypeArr as $accountclasstyperes) {
                                     $empsalarydetailsform->accountclasstypeid->addMultiOption($accountclasstyperes['id'], $accountclasstyperes['accountclasstype']);
                                 }
                             } else {
                                 $msgarray['accountclasstypeid'] = 'Account class types are not configured yet.';
                                 $emptyFlag++;
                             }
                             $data = $empsalarydetailsModal->getsingleEmpSalaryDetailsData($id);
                             if (!empty($data)) {
                                 $empsalarydetailsform->populate($data[0]);
                                 if ($data[0]['accountholding'] != '') {
                                     $accountholding = sapp_Global::change_date($data[0]["accountholding"], 'view');
                                     $empsalarydetailsform->accountholding->setValue($accountholding);
                                 }
                                 if ($data[0]['accountclasstypeid'] != '') {
                                     $empsalarydetailsform->setDefault('accountclasstypeid', $data[0]['accountclasstypeid']);
                                 }
                                 $empsalarydetailsform->setDefault('currencyid', $data[0]['currencyid']);
                                 $empsalarydetailsform->setDefault('bankaccountid', $data[0]['bankaccountid']);
                                 $this->view->data = $data[0];
                             }
                             $empsalarydetailsform->user_id->setValue($id);
                             $empsalarydetailsform->setAttrib('action', DOMAIN . 'mydetails/salarydetails');
                             $this->view->form = $empsalarydetailsform;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->employeedata = $empdata[0];
                             $this->view->emptyFlag = $emptyFlag;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->empdata = $empdata;
                     }
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             if ($this->getRequest()->getPost()) {
                 $result = $this->save($empsalarydetailsform, $tabName);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
 public function save($currencyconverterform)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $currencyconvertermodel = new Default_Model_Currencyconverter();
     $errorflag = 'true';
     $msgarray = array();
     $id = $this->_request->getParam('id');
     $basecurrparam = $this->_request->getParam('basecurrency');
     if ($basecurrparam != '') {
         $basecurrency = $this->_request->getParam('basecurrency');
     }
     $targetcurrparam = $this->_request->getParam('targetcurrency');
     if ($targetcurrparam != '') {
         $targetcurrency = $this->_request->getParam('targetcurrency');
     }
     $exchangerate = $this->_request->getParam('exchangerate');
     $start_date = $this->_request->getParam('start_date');
     $start_date = sapp_Global::change_date($start_date, 'database');
     $end_date = $this->_request->getParam('end_date');
     $end_date = sapp_Global::change_date($end_date, 'database');
     if ($basecurrparam != '' && $targetcurrparam != '' && $basecurrency == $targetcurrency) {
         $errorflag = 'false';
         $msgarray['targetcurrency'] = 'Base currency and target currency cannot be same.';
     }
     if ($currencyconverterform->isValid($this->_request->getPost()) && $errorflag == 'true') {
         try {
             $description = $this->_request->getParam('description');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $cur_names = $currencyconvertermodel->getCurrencyNames($basecurrency, $targetcurrency);
             $basecurrtext = isset($cur_names[$basecurrency]) ? $cur_names[$basecurrency] : "";
             $targetcurrtext = isset($cur_names[$targetcurrency]) ? $cur_names[$targetcurrency] : "";
             $data = array('basecurrency' => $basecurrency, 'targetcurrency' => $targetcurrency, 'basecurrtext' => $basecurrtext, 'targetcurrtext' => $targetcurrtext, 'exchangerate' => trim($exchangerate), 'start_date' => $start_date, 'end_date' => $end_date, 'description' => $description, '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 = $currencyconvertermodel->SaveorUpdateCurrencyConverterData($data, $where);
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Currency converter updated successfully."));
             } else {
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Currency converter added successfully."));
             }
             $menuID = CURRENCYCONVERTER;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->_redirect('currencyconverter');
         } catch (Exception $e) {
             $msgarray['basecurrency'] = "Something went wrong, please try again.";
             return $msgarray;
         }
     } else {
         $messages = $currencyconverterform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if (isset($basecurrparam) && $basecurrparam != 0 && $basecurrparam != '') {
             $currencymodel = new Default_Model_Currency();
             $currdatadata = $currencymodel->getTargetCurrencyList($basecurrency);
             if (sizeof($currdatadata > 0)) {
                 foreach ($currdatadata as $res) {
                     $currencyconverterform->targetcurrency->addMultiOption($res['id'], utf8_encode($res['targetcurr']));
                 }
                 if (isset($targetcurrparam) && $targetcurrparam != 0 && $targetcurrparam != '') {
                     $currencyconverterform->setDefault('targetcurrency', $targetcurrparam);
                 }
             }
         }
         return $msgarray;
     }
 }
示例#8
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_Select('currencyname');
     $currencyname->setRegisterInArrayValidator(false);
     $currencyModel = new Default_Model_Currency();
     $currencylistArr = $currencyModel->getCurrencyList();
     if (sizeof($currencylistArr) > 0) {
         $currencyname->addMultiOption('', 'Select Currency');
         foreach ($currencylistArr as $currencylistres) {
             $currencyname->addMultiOption($currencylistres['id'], $currencylistres['currencytext']);
         }
         $currencyname->addMultiOption('other', 'Other');
     }
     $currencyname->setAttrib('onchange', 'displayOtherCurrency(this)');
     $currencyname->setRequired(true);
     $currencyname->addValidator('NotEmpty', false, array('messages' => 'Please select currency.'));
     $othercurrencyname = new Zend_Form_Element_Text('othercurrencyname');
     $othercurrencyname->setAttrib('maxLength', 50);
     $othercurrencyname->addFilter(new Zend_Filter_StringTrim());
     $othercurrencyname->setRequired(true);
     $othercurrencyname->addValidator('NotEmpty', false, array('messages' => 'Please enter currency name.'));
     $othercurrencyname->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency name.')));
     $othercurrencyname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencyname')));
     $othercurrencyname->getValidator('Db_NoRecordExists')->setMessage('Currency name already exists.');
     $othercurrencycode = new Zend_Form_Element_Text('othercurrencycode');
     $othercurrencycode->setAttrib('maxLength', 50);
     $othercurrencycode->addFilter(new Zend_Filter_StringTrim());
     $othercurrencycode->setRequired(true);
     $othercurrencycode->addValidator('NotEmpty', false, array('messages' => 'Please enter currency code.'));
     $othercurrencycode->addValidator("regex", true, array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\s]*$/', 'messages' => array('regexNotMatch' => 'Please enter valid currency code.')));
     $othercurrencycode->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_currency', 'field' => 'currencycode')));
     $othercurrencycode->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, $othercurrencycode, $othercurrencyname, $currencyname, $passwordid, $perm_country, $perm_state, $perm_city, $workcodename, $empCode, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }