From d42764a89da7e547ec0170e3d4ce5af17384343d Mon Sep 17 00:00:00 2001 From: Kwesi Banson Jnr Date: Wed, 22 Apr 2026 13:46:57 +0000 Subject: [PATCH] added SMS balance and Sent SMS --- accounts.md | 5 +- .../Controllers/ClientsLoginController.php | 6 +- .../Controllers/ClientsTrafficController.php | 42 ++++++- info.md | 11 ++ .../views/client-traffic/index-test.blade.php | 118 +++++++++++++++++- resources/views/layouts/master.blade.php | 1 + routes/web.php | 1 + 7 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 info.md diff --git a/accounts.md b/accounts.md index 94ec73b..ce90077 100644 --- a/accounts.md +++ b/accounts.md @@ -9,7 +9,10 @@ ### client - hixu@mailinator.com/frantic@300 - +## Sunking +- https://smsportal.clickmlapps.com/ +- info@sunking.com +- 847SIcgO9sUX ### add - change pagination to 1000 from 20 - remove delivery receipt diff --git a/app/Http/Controllers/ClientsLoginController.php b/app/Http/Controllers/ClientsLoginController.php index baa56d3..93f70b1 100644 --- a/app/Http/Controllers/ClientsLoginController.php +++ b/app/Http/Controllers/ClientsLoginController.php @@ -27,7 +27,7 @@ class ClientsLoginController extends Controller if ($elapsedMinutes > 30) { // code... // $elapsedDays = Carbon::parse($stringDate)->diffInDays(); - // OR using the now() helper + // OR using the now() helper // $isExpired = $check_activation->activation_start_time->diffInMinutes() > 30; $data = [ @@ -83,15 +83,17 @@ class ClientsLoginController extends Controller $logged_in = ''; $client = Models\ClientSession::where('email', $request->email)->first(); - + // dd($client); if ($client == false) { return redirect()->back()->withErrors(['Invalid credentials']); } $client_url = "clients/" . $client->client_id; $result = ApiCalls::CurlGet($client_url); + $result_arr = json_decode($result, true); $logged_in = $result_arr; + $request->session()->regenerate(true); $request->session()->put('current_user.user_id', $logged_in['id']); $request->session()->put('current_user.org_id', $logged_in['id']); diff --git a/app/Http/Controllers/ClientsTrafficController.php b/app/Http/Controllers/ClientsTrafficController.php index 7871958..f0b6e61 100644 --- a/app/Http/Controllers/ClientsTrafficController.php +++ b/app/Http/Controllers/ClientsTrafficController.php @@ -8,6 +8,7 @@ use App\Utilities\ApiCalls; use Session; use Illuminate\Pagination\LengthAwarePaginator; use GuzzleHttp\Client; +use DateTime; class ClientsTrafficController extends Controller { @@ -38,15 +39,34 @@ class ClientsTrafficController extends Controller ); } public function index(){ - //dump(session('current_user')); + $client_id = session('current_user.org_id'); $clients_url = "messages/client/$client_id?page=0&size=1000&sort=createdAt,desc"; $result = ApiCalls::CurlGet($clients_url); $result_arr = json_decode($result); - // dump($result_arr); + + $current_date = new DateTime(); + + $start_date = $current_date->modify('-10 days'); + $start_date = $start_date->format('Y-m-d'); + $end_date = date('Y-m-d'); + $daily_smsunits_url = "ucm/reports/daily-sms-units?from=$start_date&to=$end_date"; + $result = ApiCalls::CurlGet($daily_smsunits_url); + $sms_units_arr = json_decode($result, true); + + $orgId = session('current_user.org_id'); + $sms_balance_url = "clients/$orgId/balance"; + $result = ApiCalls::CurlGet($sms_balance_url); + + $balance_arr = json_decode($result, true); + + // dump($sms_units_arr); + $data = [ 'page_title' => 'SMS Traffic', - 'traffic_arr' => $result_arr + 'traffic_arr' => $result_arr, + 'sms_units_arr' => $sms_units_arr, + 'balance_arr' => $balance_arr ]; return view('client-traffic.index-test', $data); } @@ -155,6 +175,22 @@ class ClientsTrafficController extends Controller } Session::flash('success_message', 'Message successfully submitted for delivery!'); return redirect("send-sms"); + } + public function dailySmsUnits(Request $request){ + $this->validate($request, [ + 'start_date' => 'required|date', + 'end_date' => 'required|date', + ]); + $start_date = $request->start_date; + $end_date = $request->end_date; + $daily_smsunits_url = "ucm/reports/daily-sms-units?from=$start_date&to=$end_date"; + $result = ApiCalls::CurlGet($daily_smsunits_url); + \Log::info('SMS Units Response ' . $result); + + $data = json_decode($result, true); + return response()->json($data); + + } public function newAppStore(Request $request){ diff --git a/info.md b/info.md new file mode 100644 index 0000000..42dcd3b --- /dev/null +++ b/info.md @@ -0,0 +1,11 @@ +Messaging Notes- meeting with Victor on messaging with focus on the dashboard + +They would like a Finance feature that shows the account balances +App to include option for report that shows balances , consumption and balances +They do not require CDRs for the report but volumes of the messages sent +Messaging report for call centre usage that enables them to extract OTP +Message access for last 3-6 hours +Sam added that we can provide functionality for the App to be useable by multiple departments +Victor will be able to share feedback on the endpoint change by 24th April. +They have Mozambique and Madagascar offices that we could potentially onboard and Victor will loop us in but mentioned they would require the dashboard functionality + diff --git a/resources/views/client-traffic/index-test.blade.php b/resources/views/client-traffic/index-test.blade.php index ad5dc48..a7fd85c 100644 --- a/resources/views/client-traffic/index-test.blade.php +++ b/resources/views/client-traffic/index-test.blade.php @@ -5,9 +5,11 @@ @section('page-css') + @endsection @section('content') +
@@ -17,9 +19,66 @@ Search sent SMS, review delivery outcomes, inspect failed attempts, and give clients a fast audit trail for every campaign.

-->
-
+
+
+ +
+
+
SMS Account Balance
+
{{ number_format($balance_arr['balance']) }}
+
+
+
+
+
+
+
+
+ + +
+
+ + {{ $sms_units_arr['reportDate'] }}
+ +
+
+ +
+
+ +
+ +
+ + + +
+
+
+
+
+
+ +
+
Sent Messages
+ +
SMS Units : {{ $sms_units_arr['smsUnits'] }}
+ +
+
+
+ +
@@ -36,8 +95,7 @@
-
- +
@@ -47,6 +105,7 @@
+

Sent SMS list

@@ -77,6 +136,8 @@ @endsection @section('page-js') + + @@ -85,6 +146,51 @@