コード例 #1
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;
     }
 }
コード例 #2
0
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = '';
     $actionflag = 3;
     if ($id) {
         $systempreferencemodel = new Default_Model_Sitepreference();
         $menumodel = new Default_Model_Menu();
         $data = array('isactive' => 0);
         $where = array('id=?' => $id);
         $Id = $systempreferencemodel->SaveorUpdateSystemPreferanceData($data, $where);
         if ($Id == 'update') {
             $menuidArr = $menumodel->getMenuObjID('/sitepreference');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'Site preferences deleted successfully.';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'Site preferences cannot be deleted.';
         }
         $messages['msgtype'] = 'error';
     } else {
         $messages['message'] = 'Site preferences cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
コード例 #3
0
 public function editAction()
 {
     $orgInfoModel = new Default_Model_Organisationinfo();
     $getorgData = $orgInfoModel->getorgrecords();
     $sitepreferencemodel = new Default_Model_Sitepreference();
     $activerecordArr = $sitepreferencemodel->getActiveRecord();
     $timezoneid = !empty($activerecordArr[0]['timezoneid']) ? $activerecordArr[0]['timezoneid'] : '';
     $popConfigPermission = array();
     $organisationHead = array();
     if (!empty($getorgData)) {
         $orgdata = '';
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $loginUserId = $auth->getStorage()->read()->id;
             $loginUserRole = $auth->getStorage()->read()->emprole;
             $loginUserGroup = $auth->getStorage()->read()->group_id;
         }
         if (sapp_Global::_checkprivileges(TIMEZONE, $loginUserGroup, $loginUserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'timezone');
         }
         if (sapp_Global::_checkprivileges(COUNTRIES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'country');
         }
         if (sapp_Global::_checkprivileges(STATES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'state');
         }
         if (sapp_Global::_checkprivileges(CITIES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'city');
         }
         if (sapp_Global::_checkprivileges(EMPLOYEE, $loginUserGroup, $loginUserRole, 'add') == 'Yes') {
             array_push($popConfigPermission, 'employee');
         }
         $msgarray = array();
         $flag = 'true';
         $id = $this->getRequest()->getParam('id');
         $callval = $this->getRequest()->getParam('call');
         $deptModel = new Default_Model_Departments();
         $deptform = new Default_Form_departments();
         $statesmodel = new Default_Model_States();
         $citiesmodel = new Default_Model_Cities();
         $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();
         $orgInfoModel = new Default_Model_Organisationinfo();
         $employeeModal = new Default_Model_Employee();
         $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();
         $deptData = array();
         $deptform->setAttrib('action', BASE_URL . 'departments/edit');
         $country = $getorgData[0]['country'];
         if (isset($_POST['country'])) {
             $country = $_POST['country'];
         }
         $state = $getorgData[0]['state'];
         if (isset($_POST['state'])) {
             $state = $_POST['state'];
         }
         $city = $getorgData[0]['city'];
         if (isset($_POST['city'])) {
             $city = $_POST['city'];
         }
         $deptform->setDefault('timezone', $timezoneid);
         $address = $getorgData[0]['address1'];
         $organisationHead = $employeeModal->getCurrentOrgHead();
         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);
         }
         if (is_numeric($id) && $id > 0) {
             $data = $deptModel->getSingleDepartmentData($id);
             if (!empty($data)) {
                 $deptform->setAttrib('action', BASE_URL . 'departments/edit/id/' . $id);
                 $managementUsersData = $deptModel->getDepartmenttHead($data['depthead']);
                 foreach ($managementUsersData as $mgmtdata) {
                     $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']);
                 }
                 $deptform->populate($data);
                 $deptform->setDefault('depthead', $data['depthead']);
                 $deptform->submit->setLabel('Update');
                 $deptform->state->clearMultiOptions();
                 $deptform->city->clearMultiOptions();
                 $deptform->state->addMultiOption('', utf8_encode("Select State"));
                 $deptform->city->addMultiOption('', utf8_encode("Select City"));
                 $countryId = $data['country'];
                 if (isset($_POST['country'])) {
                     $countryId = $_POST['country'];
                 }
                 $stateId = $data['state'];
                 if (isset($_POST['state'])) {
                     $stateId = $_POST['state'];
                 }
                 $cityId = $data['city'];
                 if (isset($_POST['city'])) {
                     $cityId = $_POST['city'];
                 }
                 if ($countryId != '') {
                     $statesData = $statesmodel->getBasicStatesList($countryId);
                     foreach ($statesData as $res) {
                         $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                     }
                     $deptform->setDefault('country', $countryId);
                     $deptform->setDefault('state', $stateId);
                 }
                 if ($stateId != '') {
                     $citiesData = $citiesmodel->getBasicCitiesList($stateId);
                     foreach ($citiesData as $res) {
                         $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                     }
                     $deptform->setDefault('city', $cityId);
                 }
                 if ($data["startdate"] != '') {
                     $st_date = sapp_Global::change_date($data["startdate"], 'view');
                     $deptform->setDefault('start_date', $st_date);
                 }
                 $this->view->ermsg = '';
                 $this->view->datarr = $data;
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             if ($id != '') {
                 $this->view->ermsg = 'nodata';
             } else {
                 $managementUsersData = $deptModel->getDepartmenttHead('');
                 foreach ($managementUsersData as $mgmtdata) {
                     $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']);
                 }
             }
         }
         $this->view->deptData = sizeof($deptData);
         $this->view->form = $deptform;
         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($allBusinessunitsData)) {
             $msgarray['unitid'] = 'Business units are not added yet.';
             $flag = 'false';
         }
         if (empty($allTimezoneData)) {
             $msgarray['timezone'] = 'Time zones are not configured yet.';
             $flag = 'false';
         }
         $this->view->msgarray = $msgarray;
         if ($this->getRequest()->getPost()) {
             $deptname = trim($this->_request->getParam('deptname'));
             $unitid = $this->_request->getParam('unitid');
             if ($deptname != '' && $unitid != '') {
                 if (!preg_match('/^[a-zA-Z.\\- ?]+$/', $deptname)) {
                     $msgarray['deptname'] = "Please enter valid department name.";
                     $flag = 'false';
                 } else {
                     $checkExists = $deptModel->checkExistance($deptname, $unitid, $id);
                     if ($checkExists != 0) {
                         $msgarray['deptname'] = "Department name already exists.";
                         $flag = 'false';
                     }
                 }
             } else {
                 $flag = 'false';
             }
             $start_date = $this->_request->getParam('start_date', null);
             $start_date = sapp_Global::change_date($start_date, 'database');
             if ($deptform->isValid($this->_request->getPost()) && $flag == 'true') {
                 $deptname = $this->_request->getParam('deptname');
                 $deptcode = $this->_request->getParam('deptcode');
                 $description = $this->_request->getParam('description');
                 $country = $this->_request->getParam('country');
                 $state = intval($this->_request->getParam('state'));
                 $city = $this->_request->getParam('city');
                 $address1 = $this->_request->getParam('address1');
                 $address2 = $this->_request->getParam('address2');
                 $address3 = $this->_request->getParam('address3');
                 $unitid = $this->_request->getParam('unitid');
                 $timezone = $this->_request->getParam('timezone');
                 $depthead = $this->_request->getParam('depthead');
                 $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);
                     /* Updating business unit and department for org head*/
                     $emp_data = array('businessunit_id' => $unitid, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     $emp_where = array('user_id=?' => $depthead);
                     if ($Id == 'update') {
                         $tableid = $id;
                         $emp_data['department_id'] = $id;
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Department updated successfully.");
                     } else {
                         $tableid = $Id;
                         $emp_data['department_id'] = $Id;
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Department added successfully.");
                     }
                     $employeeModal->SaveorUpdateEmployeeData($emp_data, $emp_where);
                     $menuID = DEPARTMENTS;
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                     $this->_redirect('departments');
                 } 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($allBusinessunitsData)) {
                         $msgarray['unitid'] = 'Business units are not added yet.';
                     }
                     if (empty($allTimezoneData)) {
                         $msgarray['timezone'] = 'Time zones are not configured yet.';
                     }
                 }
                 $this->view->msgarray = $msgarray;
             }
         }
     } else {
         $orgdata = 'noorgdata';
         $this->view->orgdata = $orgdata;
     }
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->organisationHead = $organisationHead;
 }
コード例 #4
0
ファイル: Global.php プロジェクト: rajbrt/sentrifugo
 /**
  * This function is used to write site constants to a php file.
  */
 public static function generateSiteConstants()
 {
     $filename = Zend_Registry::get('siteconstant_file_path');
     $site_model = new Default_Model_Sitepreference();
     $site_data = $site_model->getActiveRecord();
     if (!empty($site_data)) {
         $site_data = $site_data[0];
         $utc = new DateTimeZone('UTC');
         $dt = new DateTime('now', $utc);
         $current_tz = new DateTimeZone($site_data['tz_value']);
         $tzoffset = $current_tz->getOffset($dt);
         $offset = self::formatOffset($tzoffset);
         $site_content = "<?php\n           defined('DATEFORMAT_PHP') || define('DATEFORMAT_PHP','" . $site_data['date_format'] . "');\n           defined('DATEFORMAT_MYSQL') || define('DATEFORMAT_MYSQL','" . $site_data['mysql_dateformat'] . "');\n           defined('DATEFORMAT_JS') || define('DATEFORMAT_JS','" . $site_data['js_dateformat'] . "');\n           defined('DATE_DESCRIPTION') || define('DATE_DESCRIPTION','" . $site_data['date_description'] . "');\n           defined('TIME_FORMAT') || define('TIME_FORMAT','" . $site_data['time_format'] . "');   \n           defined('TIMEZONE_OFFSET') || define('TIMEZONE_OFFSET','" . $offset . "');   \n           defined('CURRENCY_FORMAT') || define('CURRENCY_FORMAT','" . $site_data['currency'] . "');\n           defined('PASSWORD_FORMAT') || define('PASSWORD_FORMAT','" . $site_data['passwordtype'] . "');\n        ?>";
         try {
             $handle = fopen($filename, "w+");
             fwrite($handle, trim($site_content));
             fclose($handle);
         } catch (Exception $e) {
         }
     }
 }
コード例 #5
0
 public function editpasswordAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $identity = $auth->getIdentity();
         $id = $identity->id;
         $email = $identity->emailaddress;
         $employeid = $identity->employeeId;
     }
     $password = trim($this->_request->getParam('password'));
     $newpassword = trim($this->_request->getParam('newpassword'));
     $confpassword = trim($this->_request->getParam('passwordagain'));
     $password = preg_replace('/\\s+/', ' ', $password);
     $newpassword = preg_replace('/\\s+/', ' ', $newpassword);
     $confpassword = preg_replace('/\\s+/', ' ', $confpassword);
     $pwd = md5($password);
     $newpwd = md5($newpassword);
     $confpwd = md5($confpassword);
     $loginmodel = new Default_Model_Users();
     $userpassword = $loginmodel->getLoggedInUserPwd($id, $email, $employeid);
     $sespwd = $userpassword['emppassword'];
     $changepasswordform = new Default_Form_changepassword();
     $sitepreferencemodel = new Default_Model_Sitepreference();
     $sitepreferenceArr = $sitepreferencemodel->SitePreferanceData();
     /*
         Pattern Used for alphanumeric expression 
     	   'pattern'=> '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one alphabet should be present in the expression.
     		  -> Third bracket() specifies the allowed set of characters in the expression.
     		  
     	Pattern Used for alphanumeric and special characters 
     	    'pattern'=> '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\-#$@&\_*])([a-zA-Z0-9.\-#$@&\_*]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one alphabet should be present in the expression.
     		  -> Third bracket() specifies that atleast one special character should be present in the expression.
     		  -> Fourth bracket() specifies the allowed set of characters in the expression.
     
                 Pattern Used for numbers and special characters 
     	    'pattern'=> '/^(?=.*[0-9])(?=.*[.\-#$@&\_*])([0-9.\-#$@&\_*]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one special character should be present in the expression.
     		  -> Third bracket() specifies the allowed set of characters in the expression.				  
     */
     if (!empty($sitepreferenceArr)) {
         if ($sitepreferenceArr[0]['passwordid'] == 1) {
             $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
             $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
         } else {
             if ($sitepreferenceArr[0]['passwordid'] == 2) {
                 $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\\-#$@&\\_*])([a-zA-Z0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only characters,numbers and special characters.')));
                 $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\\-#$@&\\_*])([a-zA-Z0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only characters,numbers and special characters.')));
             } else {
                 if ($sitepreferenceArr[0]['passwordid'] == 3) {
                     $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter numbers only.')));
                     $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter numbers only.')));
                 } else {
                     $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[.\\-#$@&\\_*])([0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers and special characters.')));
                     $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[.\\-#$@&\\_*])([0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers and special characters.')));
                 }
             }
         }
     } else {
         $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
         $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
     }
     /* Logic ends for site preference password validation
           END
        */
     if ($this->getRequest()->getPost()) {
         if ($changepasswordform->isValid($this->_request->getPost()) && $sespwd == $pwd && $newpwd == $confpwd && $pwd != $newpwd) {
             $loginmodel->editadminPassword($newpwd, $id, $email, $employeid);
             $this->_helper->json(array('result' => 'saved', 'message' => "Password changed successfully."));
         } else {
             $messages = $changepasswordform->getMessages();
             if ($sespwd != $pwd && $password != '') {
                 $messages['password'] = array('Wrong password. Please enter correct password.');
             }
             if ($newpwd != $confpwd && $newpassword != '' && $confpassword != '') {
                 $messages['passwordagain'] = array('New password and confirm password did not match.');
             }
             if ($pwd == $newpwd && $newpassword != '' && $password != '') {
                 $messages['passwordagain'] = array('Please choose a different password.');
             }
             $messages['result'] = 'error';
             $this->_helper->json($messages);
         }
     }
 }
コード例 #6
0
 public function savebusinessunitAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('savebusinessunit', 'json')->initContext();
     $this->_helper->layout->disableLayout();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $businessunitsmodel = new Default_Model_Businessunits();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $systempreferencemodel = new Default_Model_Sitepreference();
     $organisationData = $orgInfoModel->getOrganisationInfo();
     $sitePreferenceData = $systempreferencemodel->SitePreferanceData();
     $result['result'] = '';
     $result['id'] = '';
     $result['unitname'] = '';
     $result['address'] = '';
     $date = new Zend_Date();
     try {
         $unitname = trim($this->_request->getParam('bunit'));
         $address = $this->_request->getParam('streetAddress');
         $isUnitExist = $businessunitsmodel->checkDuplicateUnitName($unitname);
         if (!empty($isUnitExist)) {
             if ($isUnitExist[0]['count'] > 0) {
                 $result['msg'] = 'Name already exists.';
                 $result['id'] = '';
                 $result['unitname'] = '';
                 $result['address'] = '';
             } else {
                 $menumodel = new Default_Model_Menu();
                 $actionflag = '';
                 $tableid = '';
                 if (strlen(trim($unitname)) > 3) {
                     $unitCode = strtoupper(substr(trim($unitname), 0, 4));
                 } else {
                     $unitCode = strtoupper(trim($unitname));
                 }
                 $data = array('unitname' => $unitname, 'unitcode' => $unitCode, 'startdate' => NULL, 'country' => !empty($organisationData) ? $organisationData[0]['country'] : NULL, 'state' => !empty($organisationData) ? $organisationData[0]['state'] : NULL, 'city' => !empty($organisationData) ? $organisationData[0]['city'] : NULL, 'address1' => $address, 'timezone' => !empty($sitePreferenceData) ? $sitePreferenceData[0]['timezoneid'] : NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'));
                 $where = '';
                 $actionflag = 1;
                 $Id = $businessunitsmodel->SaveorUpdateBusinessUnits($data, $where);
                 if ($Id) {
                     $menuID = BUSINESSUNITS;
                     $logresult = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id);
                     $result['msg'] = 'success';
                     $result['id'] = $Id;
                     $result['unitname'] = $unitname;
                     $result['address'] = $address;
                 } else {
                     $result['msg'] = 'error';
                     $result['id'] = '';
                     $result['unitname'] = '';
                     $result['address'] = '';
                 }
             }
         }
     } catch (Exception $e) {
         $result['msg'] = $e->getMessage();
         $result['id'] = '';
         $result['unitname'] = '';
         $result['address'] = '';
     }
     $this->_helper->json($result);
 }