462 lines
12 KiB
PHP
462 lines
12 KiB
PHP
<?php namespace App\Controllers;
|
|
|
|
use App\Models\Dashboard_model;
|
|
use App\Models\Receipt_model;
|
|
use App\Models\Transaction_model;
|
|
use App\Models\Donation_data_model;
|
|
use App\Models\My_model;
|
|
use App\Models\Donation_cause;
|
|
use App\Models\Donor_model;
|
|
|
|
class Dashboard extends BaseController
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
$this->dModel = new Dashboard_model();
|
|
$this->rModel = new Receipt_model();
|
|
$this->tModel = new Transaction_model();
|
|
$this->ddModel = new Donation_data_model();
|
|
$this->MyModel = new My_model();
|
|
$this->dcModel = new Donation_cause();
|
|
}
|
|
public function index()
|
|
{
|
|
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
$id= session()->get('logged_user');
|
|
$data['userdata']=$this->dModel->getLoggedInUserData($id);
|
|
// echo view('templates/header',$data);
|
|
// echo view('dashboard');
|
|
// echo view('templates/footer');
|
|
return view('dashboard');
|
|
}
|
|
public function logout()
|
|
{
|
|
session()->remove('logged_user');
|
|
session()->destroy();
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
function fetch_donor_id()
|
|
{
|
|
echo $this->MyModel->fetch_donor_id();
|
|
}
|
|
function edit_donor_id($receipt_id)
|
|
{
|
|
echo $receipt_id; die();
|
|
echo $this->MyModel->edit_donor_id();
|
|
}
|
|
function fetch_cause_name()
|
|
{
|
|
echo $this->dcModel->fetch_cause_name();
|
|
}
|
|
|
|
public function receipts()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
$name= session()->get('logged_user');
|
|
return view('receipts');
|
|
// echo view('templates/header');
|
|
// echo view('receipts');
|
|
// echo view('templates/footer');
|
|
}
|
|
|
|
|
|
public function generate_receipts()
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
$donor_id=$this->request->getVar('donor_id');
|
|
$mymodel = new My_model();
|
|
$donor = $mymodel->find($donor_id);
|
|
$donor_name = $donor['name'];
|
|
|
|
$cause_id=$this->request->getVar('cause_id');
|
|
$causemodel = new Donation_cause();
|
|
$cause = $causemodel->find($cause_id);
|
|
$cause_name = $cause['cause_name'];
|
|
|
|
$receiptData=[
|
|
|
|
'date' =>$this->request->getVar('date'),
|
|
'donor_id' =>$this->request->getVar('donor_id'),
|
|
'donor_name' =>$donor_name,
|
|
'amount' =>$this->request->getVar('amount'),
|
|
'mode_of_receipt' =>$this->request->getVar('mode_of_receipt'),
|
|
'receipt_details' =>$this->request->getVar('receipt_details'),
|
|
'cause_id' =>$this->request->getVar('cause_id'),
|
|
'cause_name' =>$cause_name,
|
|
'remarks' =>$this->request->getVar('remarks'),
|
|
];
|
|
//print_r($receiptData);die();
|
|
$model = new Receipt_model();
|
|
$model->save($receiptData);
|
|
return redirect()->to(base_url().'/Dashboard/last_receipt');
|
|
}
|
|
|
|
function update_receipt()
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
$receipt_id=$this->request->getVar('receipt_id');
|
|
|
|
$donor_id=$this->request->getVar('donor_id');
|
|
$mymodel = new My_model();
|
|
$donor = $mymodel->find($donor_id);
|
|
$donor_name = $donor['name'];
|
|
|
|
$cause_id=$this->request->getVar('cause_id');
|
|
$causemodel = new Donation_cause();
|
|
$cause = $causemodel->find($cause_id);
|
|
$cause_name = $cause['cause_name'];
|
|
|
|
$receiptData=[
|
|
|
|
'date' =>$this->request->getVar('date'),
|
|
'donor_id' =>$this->request->getVar('donor_id'),
|
|
'donor_name' =>$donor_name,
|
|
'amount' =>$this->request->getVar('amount'),
|
|
'mode_of_receipt' =>$this->request->getVar('mode_of_receipt'),
|
|
'receipt_details' =>$this->request->getVar('receipt_details'),
|
|
'cause_id' =>$this->request->getVar('cause_id'),
|
|
'cause_name' =>$cause_name,
|
|
'remarks' =>$this->request->getVar('remarks'),
|
|
];
|
|
$model = new Receipt_model();
|
|
$model->update($receipt_id , $receiptData);
|
|
return redirect()->to(base_url().'/all_receipt');
|
|
|
|
}
|
|
|
|
public function all_receipt()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$data['receiptdata']=$this->rModel->all_receipt();
|
|
|
|
return view('receipts_table',$data);
|
|
|
|
}
|
|
|
|
function edit_receipt($receipt_id)
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$receipt_model = new Receipt_model();
|
|
$receipt_data=$receipt_model->find($receipt_id);
|
|
|
|
$donor_model = new My_model();
|
|
$donor_data=$donor_model->findAll();
|
|
|
|
$cause_model = new Donation_cause();
|
|
$cause_data=$cause_model->findAll();
|
|
|
|
$data= [ 'post'=>$receipt_data , 'donor'=>$donor_data , 'cause'=>$cause_data ];
|
|
// if($this->request->getMethod() == 'post')
|
|
// {
|
|
// $model = new Receipt_model();
|
|
// $_POST['receipt_id'] = $receipt_id;
|
|
// $model->save($_POST);
|
|
// return redirect()->to(base_url()."/Dashboard/all_receipt");
|
|
// }
|
|
|
|
return view('receipt_edit',$data);
|
|
|
|
|
|
}
|
|
function last_receipt()
|
|
{
|
|
// admin data
|
|
$dmodel = new Donor_model();
|
|
$id= session()->get('logged_user');
|
|
$admin_data=$dmodel->find($id);
|
|
// last receipt data
|
|
$receipt_data=$this->rModel->last_receipt();
|
|
//print_r($receipt_data);
|
|
foreach($receipt_data as $key){ $key['receipt_id']; $key['donor_id'];}
|
|
//donation cause
|
|
$causemodel = new Donation_cause();
|
|
$cause_id=$key['receipt_id'];
|
|
$cause_data=$causemodel->find($cause_id);
|
|
// donor data
|
|
$model = new My_model();
|
|
$donor_id=$key['donor_id'];
|
|
$Donor_data=$model->find($donor_id);
|
|
// array for receipt
|
|
$data= [ 'donordata'=>$Donor_data , 'admindata' =>$admin_data , 'receipt'=>$receipt_data ,'causedata'=>$cause_data ];
|
|
|
|
echo view('templates/header');
|
|
echo view('pdf_view',$data);
|
|
echo view('templates/footer');
|
|
}
|
|
|
|
function view_receipt($receiptid)
|
|
{
|
|
// admin data
|
|
$dmodel = new Donor_model();
|
|
$id= session()->get('logged_user');
|
|
$admin_data=$dmodel->find($id);
|
|
// receipt data
|
|
$rmodel = new Receipt_model();
|
|
$receipt_id=$receiptid;
|
|
$receipt_data=$rmodel->find($receipt_id);
|
|
$donorid = $receipt_data['donor_id'];
|
|
$causeid = $receipt_data['cause_id'];
|
|
// donation cause
|
|
$causemodel = new Donation_cause();
|
|
$cause_id=$causeid;
|
|
$cause_data=$causemodel->find($cause_id);
|
|
// donor data
|
|
$model = new My_model();
|
|
$donor_id=$donorid;
|
|
$Donor_data=$model->find($donor_id);
|
|
// array for receipt
|
|
$data= [ 'donordata'=>$Donor_data , 'admindata' =>$admin_data , 'receipt'=>$receipt_data , 'causedata'=>$cause_data];
|
|
|
|
|
|
return view('receipt_view',$data);
|
|
|
|
}
|
|
|
|
public function transaction()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
$name= session()->get('logged_user');
|
|
//$data['userdata']=$this->dModel->getLoggedInUserData($name);
|
|
|
|
return view('transaction_upload');
|
|
|
|
}
|
|
// public function transaction_upload()
|
|
// {
|
|
// if(!session()->has('logged_user'))
|
|
// {
|
|
// return redirect()->to(base_url());
|
|
// }
|
|
// $model = new Transaction_model();
|
|
// $transactionData=[
|
|
// 'date' =>$this->request->getVar('date'),
|
|
// 'ref_1' =>$this->request->getVar('ref_1'),
|
|
// 'remarks' =>$this->request->getVar('remarks'),
|
|
// 'amount' =>$this->request->getVar('amount'),
|
|
// 'donation_ref' =>$this->request->getVar('donation_ref'),
|
|
|
|
// ];
|
|
// $model->save($transactionData);
|
|
// return redirect()->to(base_url().'/Dashboard/all_transaction');
|
|
// }
|
|
public function all_transaction()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
|
|
$data['receiptdata']=$this->tModel->all_transaction();
|
|
|
|
return view('transaction_table',$data);
|
|
|
|
}
|
|
function edit_transaction($id)
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$model = new Transaction_model();
|
|
$transaction_data=$model->find($id);
|
|
$data= [ 'post'=>$transaction_data ];
|
|
|
|
if($this->request->getMethod() == 'post')
|
|
{
|
|
$model = new Transaction_model();
|
|
$_POST['id'] = $id;
|
|
$model->save($_POST);
|
|
return redirect()->to(base_url()."/all_transaction");
|
|
}
|
|
|
|
return view('transaction_edit',$data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function donation_data()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
return view('donation_data');
|
|
|
|
}
|
|
// public function donation_data_upload()
|
|
// {
|
|
// if(!session()->has('logged_user'))
|
|
// {
|
|
// return redirect()->to(base_url());
|
|
// }
|
|
// $model = new Donation_data_model();
|
|
// $donationData=[
|
|
// 'date' =>$this->request->getVar('date'),
|
|
// 'cause_name' =>$this->request->getVar('cause_name'),
|
|
// 'amount' =>$this->request->getVar('amount'),
|
|
// 'mode_of_payment' =>$this->request->getVar('mode_of_payment'),
|
|
// 'ref_1' =>$this->request->getVar('ref_1'),
|
|
// 'donation_ref' =>$this->request->getVar('donation_ref'),
|
|
// ];
|
|
// $model->save($donationData);
|
|
// return redirect()->to(base_url().'/Dashboard');
|
|
// }
|
|
public function all_donation_data()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
|
|
|
|
$data['donationdata']=$this->ddModel->all_donation_data();
|
|
|
|
return view('donation_data_table',$data);
|
|
|
|
}
|
|
function edit_donation_data($id)
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$model = new Donation_data_model();
|
|
$donation_data=$model->find($id);
|
|
$data= [ 'post'=>$donation_data ];
|
|
|
|
if($this->request->getMethod() == 'post')
|
|
{
|
|
$model = new Donation_data_model();
|
|
$_POST['id'] = $id;
|
|
$model->save($_POST);
|
|
return redirect()->to(base_url()."/all_donation_data");
|
|
}
|
|
|
|
return view('donation_data_edit',$data);
|
|
|
|
|
|
}
|
|
public function donation_cause()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$data['donationcause']=$this->dcModel->all_donation_cause();
|
|
|
|
return view('add_donation_cause');
|
|
|
|
}
|
|
public function all_donation_cause()
|
|
{
|
|
$data = [];
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$data['donationcause']=$this->dcModel->all_donation_cause();
|
|
|
|
return view('all_donation_cause',$data);
|
|
|
|
}
|
|
public function add_donation_cause()
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$model = new Donation_cause();
|
|
$active="Active";
|
|
$donationCause=[
|
|
'cause_name' =>$this->request->getVar('cause_name'),
|
|
'from_date' =>$this->request->getVar('from_date'),
|
|
'to_date' =>$this->request->getVar('to_date'),
|
|
'status' =>$active,
|
|
];
|
|
$model->save($donationCause);
|
|
return redirect()->to(base_url()."/Dashboard/donation_cause");
|
|
}
|
|
function edit_donation_cause($id)
|
|
{
|
|
if(!session()->has('logged_user'))
|
|
{
|
|
return redirect()->to(base_url());
|
|
}
|
|
$model = new Donation_cause();
|
|
$donation_cause=$model->find($id);
|
|
$data= [ 'post'=>$donation_cause ];
|
|
|
|
if($this->request->getMethod() == 'post')
|
|
{
|
|
$model = new Donation_cause();
|
|
$_POST['id'] = $id;
|
|
$model->save($_POST);
|
|
return redirect()->to(base_url()."/all_donation_cause");
|
|
}
|
|
|
|
return view('donation_cause_edit',$data);
|
|
|
|
|
|
}
|
|
function inactive_cause($cause_id)
|
|
{ $id = $cause_id;
|
|
$inactive="Inactive";
|
|
$donationCause=['status' =>$inactive,];
|
|
$model = new Donation_cause();
|
|
$model->update($id , $donationCause);
|
|
return redirect()->to(base_url()."/all_donation_cause");
|
|
|
|
}
|
|
function active_cause($cause_id)
|
|
{ $id = $cause_id;
|
|
$active="Active";
|
|
$donationCause=['status' =>$active,];
|
|
$model = new Donation_cause();
|
|
$model->update($id , $donationCause);
|
|
return redirect()->to(base_url()."/all_donation_cause");
|
|
|
|
}
|
|
|
|
|
|
} |