visa_app/application/controllers/Dashboard_Controller.php
venbatechnologies@gmail.com 769edb667b profile
2018-08-09 10:27:59 +05:30

304 lines
11 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : Dashboard_Controller
* Dashboard_Controller class to control the Dashboard Contents and Master Data.
* @author : Surendiran.M
* @version : 1.1
* @since : 27 July 2018
*/
class Dashboard_Controller extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct(){
parent::__construct();
$this->load->model('Dashboard_Model');
$this->isLoggedIn();
}
/**
* Index Page for this controller.
*/
public function index()
{
$this->Dashboard();
}
/**
* This function used to load the Dashboard page
*/
function Dashboard()
{
$this->global['pageTitle'] = 'Visa : Dashboard';
$this->loadViews('Dashboard', $this->global);
}
/**
* 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($Cc='');
$this->loadViews('country_master', $this->global,$data , NULL);
}
/**
* To Store Country Master Values
*/
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);
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{
$Edited = $this->Dashboard_Model->Update_CountryMaster($CountryMasterDatas, $CountryCode);
echo $Edited == True ? "<script>alert('Successfully Updated $CountryCode Details! ');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
*/
function city_master(){
$this->global['pageTitle'] = 'Visa : Country Master';
$data['getcity']= $this->Dashboard_Model->Get_CityMaster($citycode='');
$this->loadViews('city_master', $this->global,$data , NULL);
}
/**
* To Store City Master Values
*/
function SaveAll_city_master(){
$CityCode = $this->input->post('HideCityCode'); // value getting from hidden field
$CityMasterDatas =
array( 'CityName'=>$this->input->post('CityName'),
'CityDescription'=>$this->input->post('CityDescription'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
if($CityCode == ''){
$Added = $this->Dashboard_Model->Add_CityMaster($CityMasterDatas);
echo $Added != "" ? "<script>alert('Created Successfully ! City Code:$Added');window.location.href='city_master';</script>"
: "<script>alert('Sorry Not Created ! Try Again '); window.location.href='city_master';</script>";
}
else
{
$Edited = $this->Dashboard_Model->Update_CityMaster($CityMasterDatas, $CityCode);
echo $Edited == True ? "<script>alert('Successfully Updated!');window.location.href='city_master';</script>"
: "<script>alert('Sorry Not Updated ! Try Again'); window.location.href='city_master';</script>";
}
}
/**
* View - city_master
* Get an argument From Ajax Call - 'citycode' is CITYCODE
* Return Datas to View Through JSON_encode
*/
function GetAll_city_master() {
$CityCode = $this->input->post('citycode');
$EditIt = $this->Dashboard_Model->Get_CityMaster($CityCode);
echo json_encode($EditIt);
}
/**
* This function used to load the Visa Type Master page
*/
function visa_type_master(){
$this->global['pageTitle'] = 'Visa : Visa Type Master';
$data['getvisatype']= $this->Dashboard_Model->Get_VisaTypeMaster($VisaNo='');
$this->loadViews('visa_type_master', $this->global,$data , NULL);
}
/**
* To Store Visa Type Master Values
*/
function SaveAll_visa_type_master(){
$VisaCode = $this->input->post('HideVisaCode'); // value getting from hidden field
$VisaTypeMasterDatas =
array( 'VisaName'=>$this->input->post('VisaName'),
'VisaDescription'=>$this->input->post('VisaDescription'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
if($VisaCode == ''){
$Added = $this->Dashboard_Model->Add_VisaType($VisaTypeMasterDatas);
echo $Added != "" ? "<script>alert('Created Successfully ! Visa NO :$Added'); window.location.href='visa_type_master';</script>"
: "<script>alert('Sorry Not Created ! Try Again'); window.location.href='visa_type_master';</script>";
}
else{
$Edited = $this->Dashboard_Model->Update_VisaType($VisaTypeMasterDatas,$VisaCode);
echo $Edited == True ? "<script>alert('Successfully Updated ! ');window.location.href='visa_type_master';</script>"
: "<script>alert('Sorry Not Updated ! Try Again'); window.location.href='visa_type_master';</script>";
}
}
/**
* View - visa_type_master
* Get an argument From Ajax Call - 'arg' is VisaNo
* Return Datas to View Through JSON_encode
*/
function GetAll_visa_type_master() {
$VisaNo = $this->input->post('arg');
$EditIt = $this->Dashboard_Model->Get_VisaTypeMaster($VisaNo);
echo json_encode($EditIt);
}
/**
* This function used to load the Document page
*/
function document_master(){
$this->global['pageTitle'] = 'Visa : Upload Document';
$data['getdocument'] =$this->Dashboard_Model->Get_DocumentMaster($DocNo='');
$this->loadViews('document_upload', $this->global,$data , NULL);
}
/**
* To Store Visa's File & Documents Datas
*/
function SaveAll_document_master(){
$DocNo = $this->input->post('HideDocumentCode'); // value getting from hidden field
$Doc = $this->input->post('HideDocument'); // value getting from hidden field
$DocumentMasterDatas =
array( 'DocumentName'=>$this->input->post('DocumentName'),
'Document'=>$Doc == '' ? $this->uploadFile() : $Doc ,
'DocumentDescription'=>$this->input->post('Description'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
if($DocNo == ''){
$Added = $this->Dashboard_Model->Add_Document($DocumentMasterDatas);
echo $Added != "" ? "<script>alert('Created Successfully ! Document NO :$Added'); window.location.href='document_master';</script>"
: "<script>alert('Sorry Not Created ! Try Again '); window.location.href='document_master';</script>";
}
else{
$Edited = $this->Dashboard_Model->Update_Document($DocumentMasterDatas,$DocNo);
echo $Edited == True ? "<script>alert('Successfully Updated ! ');window.location.href='document_master';</script>"
: "<script>alert('Sorry Not Updated ! Try Again'); window.location.href='document_master';</script>";
}
}
/**
* View - document_upload
* Get an argument From Ajax Call - 'arg' is DocumentNo
* Return Datas to View Through JSON_encode
*/
function GetAll_document_master() {
$DocNo = $this->input->post('arg');
$EditIt = $this->Dashboard_Model->Get_DocumentMaster($DocNo);
echo json_encode($EditIt);
}
/**
* To upload IGR files
*/
function uploadFile()
{
$config['upload_path'] = 'assets/dist/img/Uploads';
$config['allowed_types'] = 'png|jpg|jpeg|pdf|docx';
$config['file_name'] = $_FILES['DocumentFile']['name'];
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('DocumentFile'))
{
$uploadData = $this->upload->data();
$uploadfilename = $uploadData['file_name'];
return $uploadfilename;
}
else
{
$error = array('error' => $this->upload->display_errors());
$uploadfilename = '';
return 0;
}
}
/**
* This function used to load the Dashboard page
*/
function country_visa_details(){
$this->global['pageTitle'] = 'Visa : CountryWise Visa Details';
$data['records'] = $this->Dashboard_Model->Get_CountryMaster($Cc='');
$this->loadViews('country_visa_details',$this->global,$data, NULL);
}
}
?>