From bba077d08ff7072b506eae9ce54bc68bcb1a156d Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 7 May 2024 12:55:27 -0400 Subject: [PATCH] Back office Dash --- app/Config/Routes.php | 2 + app/Controllers/BaseController.php | 10 +++++ app/Controllers/BkoDash.php | 65 ++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 app/Controllers/BkoDash.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0308de4..9d6b7c3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -13,6 +13,8 @@ $routes->post('/digibko/v1/identity/token', 'DigiFiAuth::startBkoToken'); $routes->get('/digibko/v1/identity/verify_token', 'DigiFiAuth::verifyGetBkoToken'); $routes->post('/digibko/v1/identity/verify_token', 'DigiFiAuth::verifyPostBkoToken'); +$routes->get('/digibko/v1/dash', 'BkoDash::bkoDashHome'); + $routes->get('/digibko/v1/loan/started', 'BkoReports::startedApplication'); $routes->get('/digibko/v1/loan/pending', 'BkoReports::pendingApplication'); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 4582dea..17d16ff 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -76,6 +76,16 @@ abstract class BaseController extends Controller return $row; } + protected function update_db($table_name, $update_data, $where_data) : array{ + $row = []; + $this->db->table($table_name)->insert($insert_data); + + $query = $this->db->query("SELECT * FROM $table_name ORDER BY id DESC LIMIT 1"); + $row = $query->getRowArray(); + // echo $row->name; + return $row; + } + public function APIcall($method, $url, $data) { // $curl = curl_init(); $curl = curl_init($url); diff --git a/app/Controllers/BkoDash.php b/app/Controllers/BkoDash.php new file mode 100644 index 0000000..458c7d0 --- /dev/null +++ b/app/Controllers/BkoDash.php @@ -0,0 +1,65 @@ +request = \Config\Services::request(); + } + + public function bkoDashHome() :ResponseInterface + { + //SELECT uid,loan_amount,payment_month,sales_agent,gender,marital_status,email,address,state,country,status,added,updated FROM applications; + $query = $this->db->query("SELECT c.firstname, c.lastname, a.uid,a.loan_amount, + a.payment_month,a.sales_agent,a.gender, + a.marital_status,a.email,a.address, + a.state,a.country,a.status,a.added, + a.updated + FROM applications a + LEFT JOIN customers c ON c.uid = a.customer_uid LIMIT 10"); + $row = $query->getResult('array'); + + $q2 = "SELECT * FROM bvn_checks ORDER BY id DESC LIMIT 10"; + $query2 = $this->db->query($q2); + $row2 = $query2->getResult('array'); + + $data = [ + 'call_return' => '100', + 'recent_applications' => $row, + 'recent_bvn' => $row2 + ]; + return $this->respond($data, 200); + // return $this->respond([], 200); + } + + public function pendingApplication() :ResponseInterface + { + //SELECT uid,loan_amount,payment_month,sales_agent,gender,marital_status,email,address,state,country,status,added,updated FROM applications; + $query = $this->db->query("SELECT c.firstname, c.lastname, a.uid,a.loan_amount, + a.payment_month,a.sales_agent,a.gender, + a.marital_status,a.email,a.address, + a.state,a.country,a.status,a.added, + a.updated + FROM applications a + LEFT JOIN customers c ON c.uid = a.customer_uid "); + $row = $query->getResult('array'); + $data = [ + 'call_return' => '100', + 'records' => $row + ]; + return $this->respond($data, 200); + // return $this->respond([], 200); + } + + +} \ No newline at end of file