country master changes

This commit is contained in:
venbatechnologies@gmail.com 2018-08-01 18:38:55 +05:30
parent f34ad5968f
commit c996d14041
5 changed files with 114 additions and 38 deletions

View File

@ -77,7 +77,7 @@ $query_builder = TRUE;
$hostname ="localhost"; $hostname ="localhost";
$username ="root"; $username ="root";
$password =""; $password ="";
$database ="VISA"; $database ="Visa_DB";
$db['default'] = array( $db['default'] = array(
'dsn' => '', 'dsn' => '',

View File

@ -58,11 +58,13 @@ $route['translate_uri_dashes'] = FALSE;
$route['Routes'] = 'Dashboard_Controller/index'; $route['Routes'] = 'Dashboard_Controller/index';
$route['Dashboard'] = 'Dashboard_Controller/Dashboard'; $route['Dashboard'] = 'Dashboard_Controller/Dashboard';
$route['country_master'] = 'Dashboard_Controller/country_master'; $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['city_master'] = 'Dashboard_Controller/city_master';
$route['Add_city_master'] = 'Dashboard_Controller/Add_city_master'; $route['Add_city_master'] = 'Dashboard_Controller/Add_city_master';
$route['visa_type_master'] = 'Dashboard_Controller/visa_type_master'; $route['visa_type_master'] = 'Dashboard_Controller/visa_type_master';
$route['Add_visa_type_master'] = 'Dashboard_Controller/Add_visa_type_master'; $route['Add_visa_type_master'] = 'Dashboard_Controller/Add_visa_type_master';

View File

@ -2,10 +2,10 @@
require APPPATH . '/libraries/BaseController.php'; require APPPATH . '/libraries/BaseController.php';
/** /**
* Class : Dashboard_Controller * 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 * @author : Surendiran.M
* @version : 1.1 * @version : 1.1
* @since : 27/07/2018 * @since : 27 July 2018
*/ */
class Dashboard_Controller extends BaseController class Dashboard_Controller extends BaseController
{ {
@ -34,41 +34,62 @@ class Dashboard_Controller extends BaseController
$this->loadViews('Dashboard', $this->global,NULL , NULL); $this->loadViews('Dashboard', $this->global,NULL , NULL);
} }
/** /**
* This function used to load the Country Master page * This function used to load the Country Master page
*/ */
function country_master(){ function country_master(){
$this->global['pageTitle'] = 'Visa : 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); $this->loadViews('country_master', $this->global,$data , NULL);
} }
/** /**
* To Store Country Master Values * To Store Country Master Values
*/ */
function Add_country_master(){ function SaveAll_country_master(){
$CountryCode = $this->input->post('HideCountryCode'); // value getting from hidden field
$CountryMasterDatas = $CountryMasterDatas =
array( 'CountryName'=>$this->input->post('CountryName'), array( 'CountryName'=>$this->input->post('CountryName'),
'CapitalCity'=>$this->input->post('CapitalCity'), 'CapitalCity'=>$this->input->post('CapitalCity'),
'CountryDescription'=>$this->input->post('Editor'), 'CountryDescription'=>$this->input->post('Editor'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0); 'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
$Added = $this->Dashboard_Model->Add_CountryMaster($CountryMasterDatas);
if( $Added != "" ){
echo "<script>alert('Created Successfully ! Country Code:$Added'); window.location.href='country_master';</script>"; if($CountryCode == ''){
$Added = $this->Dashboard_Model->Add_CountryMaster($CountryMasterDatas);
echo $Added != "" ? "<script>alert('Created Successfully ! Our Country Code:$Added');window.location.href='country_master';</script>"
: "<script>alert('Sorry Not Created ! Try Again'); window.location.href='country_master';</script>";
} }
else else{
{ $Edited = $this->Dashboard_Model->Update_CountryMaster($CountryMasterDatas, $CountryCode);
echo "<script>alert('Sorry Not Created ! Try Again '); window.location.href='country_master';</script>";
echo $Edited == True ? "<script>alert('$CountryCode Details Successfully Updated!');window.location.href='country_master';</script>"
: "<script>alert('Sorry Not Updated ! Try Again'); window.location.href='country_master';</script>";
} }
} }
/**
* 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 * This function used to load the City Master page
@ -205,7 +226,7 @@ class Dashboard_Controller extends BaseController
*/ */
function country_visa_details(){ function country_visa_details(){
$this->global['pageTitle'] = 'Visa : CountryWise 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); $this->loadViews('country_visa_details',$this->global,$data, NULL);
} }

View File

@ -16,10 +16,30 @@ class Dashboard_Model extends CI_Model{
return $id; 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->select('*');
$this->db->from('Tab_CountryMaster'); $this->db->from('Tab_CountryMaster');
if($Cc != ''){
$this->db->where('CountryCode',$Cc);
}
$query = $this->db->get(); $query = $this->db->get();
$CountryMasterDatas = $query->result(); $CountryMasterDatas = $query->result();
return $CountryMasterDatas; return $CountryMasterDatas;

View File

@ -205,14 +205,13 @@ span:nth-child(3) .slide-up:active {
<!-- Custom Tabs --> <!-- Custom Tabs -->
<div class="nav-tabs-custom"> <div class="nav-tabs-custom">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#tab_1" data-toggle="tab">View Country</a></li> <li class="active" id="ViewCountryli"><a href="#ViewCountryTab" data-toggle="tab" >View Country Details</a></li>
<li><a href="#tab_2" data-toggle="tab">Add Country</a></li> <li id="AddEditCountryli"><a href="#AddEditCountryTab" data-toggle="tab" >Add/Edit Country Details</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<!-- /.tab-pane --> <!-- /.tab-pane -->
<div class="tab-pane active" id="tab_1"> <div class="tab-pane active" id="ViewCountryTab">
<!--<?php print_r($getcountry);?>--> <h3 style="text-align:center;">View Country Master</h3>
<h3 style="text-align:center;">View Country Master</h3>
<table id="example2" class="table table-bordered table-hover"> <table id="example2" class="table table-bordered table-hover">
<thead> <thead>
<tr> <tr>
@ -232,7 +231,7 @@ span:nth-child(3) .slide-up:active {
<td><?php echo $gc->CountryName;?></td> <td><?php echo $gc->CountryName;?></td>
<td><?php echo $gc->CapitalCity;?></td> <td><?php echo $gc->CapitalCity;?></td>
<td style="text-align:center;"><?php echo $gc->IsActive == 1 ? '<span class="label label-success">Active</span>' : '<span class="label label-danger">Deactive</span>' ?></td> <td style="text-align:center;"><?php echo $gc->IsActive == 1 ? '<span class="label label-success">Active</span>' : '<span class="label label-danger">Deactive</span>' ?></td>
<td style="text-align:center;"><a data-toggle="modal" data-target="#editcountry" href="#Editcenter"><i class="fa fa-edit" data-toggle="tooltip" title="" data-original-title="Click here to view/Edit" style="color: #dc2265;"></i></a> <td style="text-align:center;"><span onclick="ToEditCountryDetails(<?php echo $gc->CountryCode; ?>)"><i class="fa fa-edit" data-toggle="tooltip" data-original-title="Click here to view/Edit <?php echo $gc->CountryCode ?> Details" style="color: #dc2265;"></i></a>
</td> </td>
</tr> </tr>
<?php } <?php }
@ -252,14 +251,14 @@ span:nth-child(3) .slide-up:active {
</div> </div>
<!-- /.tab-pane --> <!-- /.tab-pane -->
<div class="tab-pane" id="tab_2"> <div class="tab-pane" id="AddEditCountryTab">
<h3 style="text-align:center;">Add Country Master</h3> <h3 style="text-align:center;">Add Country Master</h3>
<!-- form start --> <!-- form start -->
<form role="form" action="<?php echo base_url() ?>Add_country_master" method="post" style="padding:40px;"> <form role="form" action="<?php echo base_url() ?>SaveAll_country_master" method="post" style="padding:40px;">
<div class="row"> <div class="row">
<div class="col-md-5 designinput"> <div class="col-md-5 designinput">
<div class="form-group"> <div class="form-group">
<input class="slide-up" id="card" name="CountryName" type="text" placeholder="Enter country name" /><label for="CountryName">Country Name</label> <input class="slide-up" id="countryname" name="CountryName" type="text" placeholder="Enter country name" /><label for="CountryName">Country Name</label>
<!--<label for="exampleInputcountryname">Country Name</label> <!--<label for="exampleInputcountryname">Country Name</label>
<input type="text" class="form-control" id="exampleInputcountryname" placeholder="Enter country">--> <input type="text" class="form-control" id="exampleInputcountryname" placeholder="Enter country">-->
@ -267,7 +266,7 @@ span:nth-child(3) .slide-up:active {
</div> </div>
<div class="col-md-5 designinput"> <div class="col-md-5 designinput">
<div class="form-group"> <div class="form-group">
<input class="slide-up" id="expires" name="CapitalCity" type="text" placeholder="Enter country capital" /><label for="expires">Country Capital</label> <input class="slide-up" id="capitalcity" name="CapitalCity" type="text" placeholder="Enter country capital" /><label for="capitalcity">CCapital</label>
<!--<label for="exampleInputcountrycapital">Country Capital</label> <!--<label for="exampleInputcountrycapital">Country Capital</label>
<input type="text" class="form-control" id="exampleInputcountrycapital" placeholder="Enter country capital">--> <input type="text" class="form-control" id="exampleInputcountrycapital" placeholder="Enter country capital">-->
@ -277,20 +276,20 @@ span:nth-child(3) .slide-up:active {
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<label for="Description">Description</label> <label for="Description">Description</label>
<textarea id="editor1" name="Editor" rows="10" cols="120"> <textarea id="editor1" name="Editor" rows="10" cols="120">
This is my textarea to be replaced with CKEditor.
</textarea> </textarea>
</div> </div>
</div> </div>
<div class="row" style="padding-top:15px;"> <div class="row" style="padding-top:15px;">
<div class="col-md-2"> <div class="col-md-2">
<div class="form-group"> <div class="form-group">
<label>Active/Deactive <label>Active/Deactive</label>
<input type="checkbox" class="flat-red" name="IsActive" checked> <input type="checkbox" class="flat-red mycheck" id="isactive" name="IsActive" checked>
</label>
</div> </div>
</div> </div>
<input id="hidecountrycode" name="HideCountryCode" type="hidden" readonly />
<div class="col-md-offset-6 col-md-4"> <div class="col-md-offset-6 col-md-4">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
<div class="or-button">Or</div> <div class="or-button">Or</div>
@ -340,7 +339,7 @@ span:nth-child(3) .slide-up:active {
</script> </script>
<script> <script>
$(function () { $(function () {
// Replace the <textarea id="editor1"> with a CKEditor // Replace the <textarea id="editor"> with a CKEditor
// instance, using default configuration. // instance, using default configuration.
CKEDITOR.replace('editor1') CKEDITOR.replace('editor1')
//bootstrap WYSIHTML5 - text editor //bootstrap WYSIHTML5 - text editor
@ -352,6 +351,40 @@ span:nth-child(3) .slide-up:active {
checkboxClass: 'icheckbox_flat-green', checkboxClass: 'icheckbox_flat-green',
radioClass : 'iradio_flat-green' radioClass : 'iradio_flat-green'
}) })
}) });
function ToEditCountryDetails(arg){
$('#ViewCountryli,#ViewCountryTab').removeClass("active");
$('#AddEditCountryli,#AddEditCountryTab').addClass("active");
$.ajax({
data:{arg:arg},
type:"POST",
url:"<?php echo base_url();?>GetAll_country_master",
success:function(data) {
//alert(data);
$.each(JSON.parse(data), function (i, item) {
$('#hidecountrycode').val(item.CountryCode);
$('#countryname').val(item.CountryName);
$('#capitalcity').val(item.CapitalCity);
//$('#editor1').val(item.CountryDescription);
var editordata = item.CountryDescription
CKEDITOR.instances['editor1'].setData(editordata);
if(item.IsActive == 0){
$('.icheckbox_flat-green').attr("aria-checked", false);
$('.icheckbox_flat-green').removeClass('checked');
}
else{
$('.icheckbox_flat-green').attr("aria-checked", true);
}
});
}
});
}
</script> </script>