From 5e16aa99f6dcbac8cc3e58cbd5939aaed04f8740 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 25 Apr 2024 02:56:51 +0000 Subject: [PATCH] FIX_23rd disscussion : ps --- app/Controllers/Books.php | 5 +- app/Controllers/Home.php | 59 ++++++++- app/Controllers/Invoice.php | 11 +- app/Models/HomeModel.php | 85 +++++++++++- app/Views/auth_login.php | 4 +- app/Views/book_form.php | 14 ++ app/Views/business_form.php | 5 +- app/Views/dashboard.php | 46 ++++++- app/Views/dashboard_accounts.php | 124 ++++++++++++++++++ app/Views/event_form.php | 20 ++- app/Views/invoice_form.php | 104 ++++++++++----- app/Views/invoice_list.php | 10 +- app/Views/invoice_pdf_template.php | 10 +- app/Views/template/header.php | 6 +- app/Views/user_form.php | 2 +- .../js/jquery.dataTables.min.js | 4 +- 16 files changed, 444 insertions(+), 65 deletions(-) create mode 100644 app/Views/dashboard_accounts.php diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 4f72650..b3aa6cd 100644 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -99,8 +99,9 @@ class Books extends BaseController } else { // It's an update operation - $isactive = $this->request->getPost('isactive'); - $data['isactive'] = ($isactive == 'on') ? 1 : 0; + // $isactive = $this->request->getPost('isactive'); + // $data['isactive'] = ($isactive == 'on') ? 1 : 0; + $data['isactive'] = 1; $data['updated_by'] = $session_uid; $BooksModel->update($causes_id, $data); diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index ef36556..bf208bc 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -7,6 +7,32 @@ use App\Models\HomeModel; class Home extends BaseController { public function index() + { + + helper('session'); + $session_role = get_user_role(); + + if (!empty($session_role)) { + switch ($session_role) { + case 'admin': + case 'auditor': + $this->dashboard(); + break; + case 'accounts': + $this->dashboard_accounts(); + break; + case 'volunteer': + $this->dashboard_volunteers(); + break; + default: + $data['page_name'] = 'Dashboard'; + $this->render_page('dashboard', $data); + } + } + } + + //Default Dashboard.. + public function dashboard() { // echo "hwllo" helper('session'); @@ -33,7 +59,6 @@ class Home extends BaseController $where['users.branch_id'] = $branch_id; } break; - case 'donor': case 'volunteer': if ($branch_id) { $where['users.branch_id'] = $branch_id; @@ -42,7 +67,7 @@ class Home extends BaseController break; } } - + $data['donordetails'] = $model->donordetails($where); $data['donordetails']['label'] = "donors"; @@ -51,6 +76,36 @@ class Home extends BaseController } + public function dashboard_accounts() + { + + helper('session'); + $session_bid = get_business_id(); + $model = new HomeModel(); + $where = ['users.business_id' => $session_bid]; + $data = $model->dashboard_account($where); + $data['page_name'] = 'Dashboard'; + + // $this->render_page('dashboard', $data); + $this->render_page('dashboard_accounts', $data); + + } + + public function dashboard_volunteers() + { + helper('session'); + $session_bid = get_business_id(); + $session_uid = get_logged_user_id(); + + $model = new HomeModel(); + $bwhere = ['user_id'=> $session_uid,'users.business_id'=> $session_bid,'users.isactive'=> 1]; + $branch_id = $model->getbranchid($bwhere); + $data = $model->dashboard_volunteer($bwhere); + $data['page_name'] = 'Dashboard'; + $this->render_page('dashboard', $data); + + } + ## Dynamic Validation For Existing Check AJAX Call # USED in 1) User Module # 2) Recepit-DonorQuickAdd Module diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index b101f95..d494240 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -108,7 +108,7 @@ class Invoice extends BaseController $upt_data = $model->updateData('donations_accepted', $data, $where); } } - session()->setFlashdata('success', 'Data has been added successfully.'); + session()->setFlashdata('success', 'Recepit Updated Successfully.'); return redirect()->route('donations_accepted'); } catch (\Throwable $e) @@ -140,7 +140,8 @@ class Invoice extends BaseController // Get customer names for the dropdown, events details, and books details $data['currency'] = $this->BusinessModel->select('currency')->where($where)->findAll(); - + $data['currency_code'] = $this->BusinessModel->select('currency')->where($where)->first()['currency'] ?? null; + $data['causes'] = $bmodel->select('*')->where('business_id', (int)get_business_id())->where('isactive',1)->get()->getResult(); $data['campaign'] = $model->getData('campaign', $where); $data['invoice_number_formatting'] = $model->getData('business', $where); @@ -165,7 +166,7 @@ class Invoice extends BaseController $cus_where = ['business_id' => (int)get_business_id() , 'isactive' => 1, 'donor_type'=>$data['receipt_type']]; $data['typebaseddonors'] = $model->getData('donor', $cus_where); $data['alldonors'] = $model->getData('donor', ['business_id' => (int)get_business_id() , 'isactive' => 1]); - +// print_r($data);die; $this->render_page('invoice_form', $data); } @@ -201,7 +202,7 @@ class Invoice extends BaseController $this->AuditHistoryModel->save($audit_data); /************************************* */ - if($upt_data){ session()->setFlashdata('success', 'Data has been accepted successfully.');echo true; } + if($upt_data){ session()->setFlashdata('success', 'Recepit has been accepted successfully.');echo true; } else echo false; } @@ -234,7 +235,7 @@ class Invoice extends BaseController ]; $this->AuditHistoryModel->save($audit_data); /************************************* */ - session()->setFlashdata('success', 'Data has been rejected successfully.'); + session()->setFlashdata('success', 'Recepit has been rejected successfully.'); return redirect()->route('receipt_list'); } diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index 8be1431..2847fa2 100644 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -6,8 +6,7 @@ class HomeModel extends Model public function donordetails($where) { - $totalDonors = $this->db->table('donor') - ->where($where)->countAll(); + $totalDonors = $this->db->table('donor')->where($where)->countAllResults(); $activeDonors = $this->db->table('donor')->select('donor.*, users.branch_id,users.business_id as users_business_id') ->join('users', 'users.user_id = donor.created_by AND users.business_id = donor.business_id', 'left') @@ -36,5 +35,87 @@ class HomeModel extends Model $result = $query->select('branch_id')->where($bwhere)->get()->getRow(); return $result ? (int)$result->branch_id : 0; } + public function dashboard_account($where){ + $query = $this->db->table('users') + ->select('users.user_id,receipt.receipt_header,SUM(receipt.amount) AS total_amount') + ->select("CONCAT_WS(' ', users.first_name, users.last_name) AS full_name") + ->join('receipt', 'receipt.created_by = users.user_id', 'left') + ->where('users.isactive', 1) + ->where('receipt.receipt_header', 'Receipt') + ->where($where) + ->like('users.role', 'volunteer') + ->groupby('users.user_id, full_name'); + $result = $query->get()->getResult(); + // echo $this->db->getLastQuery()->getQuery();die; + $total_amount_today = $this->db->table('receipt') + ->select('SUM(amount) AS total_amount_today') + ->join('users', 'receipt.created_by = users.user_id', 'left') + ->where('receipt.receipt_header', 'Receipt') + ->where($where) + ->where('DATE(receipt.created_on) = CURDATE()') + ->get()->getRow(); + $today = ($total_amount_today) ? $total_amount_today->total_amount_today : 0; + + + + $total_amount_current_month = $this->db->table('receipt') + ->select('SUM(amount) AS total_amount_current_month') + ->join('users', 'receipt.created_by = users.user_id', 'left') + ->where('receipt.receipt_header', 'Receipt') + ->where($where) + ->where('YEAR(receipt.created_on)', date('Y')) + ->where('MONTH(receipt.created_on)', date('m')) + ->get()->getRow(); + $month = ($total_amount_current_month) ? $total_amount_current_month->total_amount_current_month : 0; + + $total_amount_current_financial_year = $this->db->table('receipt') + ->select('SUM(amount) AS total_amount_current_financial_year') + ->join('users', 'receipt.created_by = users.user_id', 'left') + ->where('receipt.receipt_header', 'Receipt') + ->where($where) + ->where('receipt.created_on >=', date('Y-04-01')) + ->where('receipt.created_on <', date('Y-04-01', strtotime('+1 year'))) + ->get()->getRow(); + $financial_year = ($total_amount_current_financial_year) ? $total_amount_current_financial_year->total_amount_current_financial_year : 0; + + + $final['volunter'] = $result; + $final['month'] = (int)$month; + $final['today'] = (int)$today; + $final['year'] = (int)$financial_year; + return $final; + } + + public function dashboard_volunteer($where){ + $common_query = $this->db->table('users') + ->select('users.user_id, SUM(receipt.amount) AS total_amount') + ->select("CONCAT_WS(' ', users.first_name, users.last_name) AS full_name") + ->join('receipt', 'receipt.created_by = users.user_id', 'left') + ->where($where) + ->like('users.role', 'volunteer') + ->groupby('users.user_id'); + + $today_collection = clone $common_query; + $today_collection = $today_collection->where('DATE(receipt.created_on)', date('Y-m-d'))->get()->getRow(); + $final['today_collection'] = ($today_collection) ? (int)$today_collection->total_amount : 0; + + $overall_collection = clone $common_query; + $overall_collection = $overall_collection->get()->getRow(); + // echo $this->db->getLastQuery()->getQuery();die; + $final['overall_collection'] = ($overall_collection) ? (int)$overall_collection->total_amount : 0; + + $settlement_today = clone $common_query; + $settlement_today = $settlement_today->where('DATE(receipt.created_on)', date('Y-m-d')) + ->where('receipt.receipt_header', 'Receipt') + ->get()->getRow(); + $final['settlement_today'] = ($settlement_today) ? (int)$settlement_today->total_amount : 0; + + $settlement_overall = clone $common_query; + $settlement_overall = $settlement_overall->where('receipt.receipt_header', 'Receipt')->get()->getRow(); + $final['settlement_overall'] = ($settlement_overall) ? (int)$settlement_overall->total_amount : 0; + + return $final; + } + } diff --git a/app/Views/auth_login.php b/app/Views/auth_login.php index 57c66ea..db6830b 100644 --- a/app/Views/auth_login.php +++ b/app/Views/auth_login.php @@ -21,7 +21,9 @@ " rel="stylesheet" type="text/css" /> - +
diff --git a/app/Views/book_form.php b/app/Views/book_form.php index 4f474a0..2df9c08 100644 --- a/app/Views/book_form.php +++ b/app/Views/book_form.php @@ -96,6 +96,14 @@ + diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 130e1ec..9959068 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -53,27 +53,51 @@
- + mobile_no; + if ($object->donor_id == $selected_donor_id) { + $selected_donor_mobile = $mobile; + } + if (!isset($mobileNumbers[$mobile])) { + $mobileNumbers[$mobile] = true; + $uniqueData[] = $object; + } + } + ?>
- + - + + + + + + +
- + + -
+
- +
+ + +
@@ -230,6 +260,7 @@ if (response.success) { $('#successModal').modal('show'); $('#downloadButton').attr('href', "" + response.invoice_id); + $('#successModal').modal('hide'); } else { // Handle errors or display a different modal for failure console.log(response.message); @@ -243,10 +274,12 @@ }); $('#closeButton').on('click', function(e) { e.preventDefault(); - var url = ""; + // var url = ""; + var baseUrl = ""; + var url = baseUrl + 'receipt_list'; + window.location.href = url; $('#successModal').modal('hide'); $('#receiptForm')[0].reset(); - window.location.href = url; }); }); @@ -265,7 +298,7 @@ $('.dm_label').find('.text-danger').remove(); } else { $('#donor_mobile').prop('disabled', false).attr('required', true); - $('.dfn_label').html('Donor Name *'); + $('.dfn_label').html('Contributor Name *'); if ($('.dm_label').find('.text-danger').length == 0) { $('.dm_label').append(' *'); } @@ -284,7 +317,7 @@ var selectedMobile = $(this).val(); var options = ''; if(role != 'accounts'){ - options += ''; + options += ''; } // Assuming `data` is an array of objects containing donor information @@ -307,7 +340,7 @@ var Rtype = $('.receipt_type:checked').val(); var options = ''; if(role != 'accounts'){ - options += ''; + options += ''; } // Assuming `data` is an array of objects containing donor information console.log(donor); @@ -337,7 +370,7 @@ var selectedID = $(this).val(); var options = ''; if(role != 'accounts'){ - options += ''; + options += ''; } // Filter the donors array based on the selectedID var filter_array = alldonors.filter(function(d) { @@ -386,10 +419,10 @@ })); if(role != 'accounts'){ $('#donor_mobile').append($('