visa_app/application/controllers/Dashboard_Controller.php
venbatechnologies@gmail.com 9d83dc3ccb follow changes
2018-08-17 12:19:12 +05:30

357 lines
12 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';
$data['usercount']= $this->Dashboard_Model->usercount();
$this->loadViews('Dashboard', $this->global,$data,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($Cc='');
$this->loadViews('country_master', $this->global,$data , NULL);
}
/**
* To Store/Insert Country Master Values
*/
function Add_country_master(){
$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);
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>";
}
/**
* To Update Country Master Values
*/
function Update_country_master(){
$CountryCode = $this->input->post('HideCountryCode'); // value getting from hidden field
$CountryMasterDatas =
array( 'CountryName'=>$this->input->post('EditCountryName'),
'CapitalCity'=>$this->input->post('EditCapitalCity'),
'CountryDescription'=>$this->input->post('EditEditor'),
'IsActive'=>$this->input->post('EditIsActive') != '' ? 1 : 0);
$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 Get_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 Add_city_master(){
$CityMasterDatas =
array( 'CityName'=>$this->input->post('CityName'),
'CityDescription'=>$this->input->post('CityDescription'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
$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>";
}
/**
* To Update City Master Values
*/
function Update_city_master(){
$CityCode = $this->input->post('HideCityCode'); // value getting from hidden field
$CityMasterDatas =
array( 'CityName'=>$this->input->post('EditCityName'),
'CityDescription'=>$this->input->post('EditCityDescription'),
'IsActive'=>$this->input->post('EditIsActive') != '' ? 1 : 0);
$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 Add_visa_type_master(){
$VisaTypeMasterDatas =
array( 'VisaName'=>$this->input->post('VisaName'),
'VisaDescription'=>$this->input->post('VisaDescription'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
$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>";
}
/**
* To Update Visa Type Master Values
*/
function Update_visa_type_master(){
$VisaCode = $this->input->post('HideVisaCode'); // value getting from hidden field
$VisaTypeMasterDatas =
array( 'VisaName'=>$this->input->post('EditVisaName'),
'VisaDescription'=>$this->input->post('EditVisaDescription'),
'IsActive'=>$this->input->post('EditIsActive') != '' ? 1 : 0);
$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 Add_document_master(){
$DocumentMasterDatas =
array( 'DocumentName'=>$this->input->post('DocumentName'),
'Document'=> $this->uploadFile(),
'DocumentDescription'=>$this->input->post('Description'),
'IsActive'=>$this->input->post('IsActive') != '' ? 1 : 0);
$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>";
}
/**
* To Store Visa's File & Documents Datas
*/
function Update_document_master(){
$DocNo = $this->input->post('HideDocumentCode'); // value getting from hidden field
$Doc = $this->input->post('HideDocument'); // value getting from hidden field
if(!empty($_FILES['DocumentFile']['name'])){
//echo 'I Have File., So Upload me';
$Docname = $this->uploadFile();
}
else{
//echo 'I Have Empty File and Replace me as old file ';
$Docname = $Doc;
}
//die();
$DocumentMasterDatas =
array( 'DocumentName'=>$this->input->post('EditDocumentName'),
'Document'=>$Docname,
'DocumentDescription'=>$this->input->post('EditDescription'),
'IsActive'=>$this->input->post('EditIsActive') != '' ? 1 : 0);
$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 files
*/
function uploadFile()
{
$picture = '';
if(!empty($_FILES['DocumentFile']['name']))
{
$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();
$picture = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$picture = '';
}
}
else
{
$picture = '';
}
return $picture ;
}
/**
* 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);
}
}
?>