From c996d14041244d082f2d98eab3678dcdae4a0f0f Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Wed, 1 Aug 2018 18:38:55 +0530 Subject: [PATCH] country master changes --- application/config/database.php | 2 +- application/config/routes.php | 4 +- .../controllers/Dashboard_Controller.php | 55 ++++++++++----- application/models/Dashboard_Model.php | 22 +++++- application/views/country_master.php | 69 ++++++++++++++----- 5 files changed, 114 insertions(+), 38 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index 0e3cab1..346da4f 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -77,7 +77,7 @@ $query_builder = TRUE; $hostname ="localhost"; $username ="root"; $password =""; -$database ="VISA"; +$database ="Visa_DB"; $db['default'] = array( 'dsn' => '', diff --git a/application/config/routes.php b/application/config/routes.php index f004fd3..aba2167 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -58,11 +58,13 @@ $route['translate_uri_dashes'] = FALSE; $route['Routes'] = 'Dashboard_Controller/index'; $route['Dashboard'] = 'Dashboard_Controller/Dashboard'; $route['country_master'] = 'Dashboard_Controller/country_master'; -$route['Add_country_master'] = 'Dashboard_Controller/Add_country_master'; +$route['SaveAll_country_master'] = 'Dashboard_Controller/SaveAll_country_master'; +$route['GetAll_country_master'] = 'Dashboard_Controller/GetAll_country_master'; $route['city_master'] = 'Dashboard_Controller/city_master'; $route['Add_city_master'] = 'Dashboard_Controller/Add_city_master'; + $route['visa_type_master'] = 'Dashboard_Controller/visa_type_master'; $route['Add_visa_type_master'] = 'Dashboard_Controller/Add_visa_type_master'; diff --git a/application/controllers/Dashboard_Controller.php b/application/controllers/Dashboard_Controller.php index d98f373..dc997c9 100755 --- a/application/controllers/Dashboard_Controller.php +++ b/application/controllers/Dashboard_Controller.php @@ -2,10 +2,10 @@ require APPPATH . '/libraries/BaseController.php'; /** * Class : Dashboard_Controller - * Dashboard_Controller class to control the Master Data. + * Dashboard_Controller class to control the Dashboard Contents and Master Data. * @author : Surendiran.M * @version : 1.1 - * @since : 27/07/2018 + * @since : 27 July 2018 */ class Dashboard_Controller extends BaseController { @@ -34,41 +34,62 @@ class Dashboard_Controller extends BaseController $this->loadViews('Dashboard', $this->global,NULL , NULL); } - /** + /** * This function used to load the Country Master page */ function country_master(){ $this->global['pageTitle'] = 'Visa : Country Master'; - $data['getcountry']= $this->Dashboard_Model->Get_CountryMaster(); + $data['getcountry']= $this->Dashboard_Model->Get_CountryMaster($Cc=''); $this->loadViews('country_master', $this->global,$data , NULL); } /** * To Store Country Master Values */ - function Add_country_master(){ + function SaveAll_country_master(){ + + $CountryCode = $this->input->post('HideCountryCode'); // value getting from hidden field - $CountryMasterDatas = array( 'CountryName'=>$this->input->post('CountryName'), 'CapitalCity'=>$this->input->post('CapitalCity'), 'CountryDescription'=>$this->input->post('Editor'), 'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0); - - - $Added = $this->Dashboard_Model->Add_CountryMaster($CountryMasterDatas); - - if( $Added != "" ){ - echo ""; + + if($CountryCode == ''){ + + $Added = $this->Dashboard_Model->Add_CountryMaster($CountryMasterDatas); + + echo $Added != "" ? "" + : ""; + + } - else - { - echo ""; + else{ + $Edited = $this->Dashboard_Model->Update_CountryMaster($CountryMasterDatas, $CountryCode); + + echo $Edited == True ? "" + : ""; + } - + } + /** + * View - country_master + * Get an argument From Ajax Call - 'arg' is COUNTRYCODE + * Return Datas to View Through JSON_encode + */ + function GetAll_country_master() { + + $CountryCode = $this->input->post('arg'); + + $EditIt = $this->Dashboard_Model->Get_CountryMaster($CountryCode); + + echo json_encode($EditIt); + + } /** * This function used to load the City Master page @@ -205,7 +226,7 @@ class Dashboard_Controller extends BaseController */ function country_visa_details(){ $this->global['pageTitle'] = 'Visa : CountryWise Visa Details'; - $data['records'] = $this->Dashboard_Model->Get_CountryMaster(); + $data['records'] = $this->Dashboard_Model->Get_CountryMaster($Cc=''); $this->loadViews('country_visa_details',$this->global,$data, NULL); } diff --git a/application/models/Dashboard_Model.php b/application/models/Dashboard_Model.php index f9cb21d..bf1511e 100755 --- a/application/models/Dashboard_Model.php +++ b/application/models/Dashboard_Model.php @@ -16,10 +16,30 @@ class Dashboard_Model extends CI_Model{ return $id; } - function Get_CountryMaster() + /** + * To Update the values of Country detail on respective CounterCode into 'Tab_CountryMaster' table + * @param arry $CountryMasterDatas : This will have all the edited Country Details + * @param number $Cc : This is Country code + */ + function Update_CountryMaster($CountryMasterDatas, $Cc) + { + $this->db->where('CountryCode',$Cc); + $this->db->update('Tab_CountryMaster',$CountryMasterDatas); + return TRUE; + } + + /** + * To Update the values of Country detail on respective CounterCode into 'Tab_CountryMaster' table + * @param arry $CountryMasterDatas : This will have all the edited Country Details + * @param number $Cc : This is Country code + */ + function Get_CountryMaster($Cc) { $this->db->select('*'); $this->db->from('Tab_CountryMaster'); + if($Cc != ''){ + $this->db->where('CountryCode',$Cc); + } $query = $this->db->get(); $CountryMasterDatas = $query->result(); return $CountryMasterDatas; diff --git a/application/views/country_master.php b/application/views/country_master.php index 18bdef4..6a0ab01 100755 --- a/application/views/country_master.php +++ b/application/views/country_master.php @@ -205,14 +205,13 @@ span:nth-child(3) .slide-up:active {