added SMS balance and Sent SMS
This commit is contained in:
@@ -9,7 +9,10 @@
|
|||||||
### client
|
### client
|
||||||
- hixu@mailinator.com/frantic@300
|
- hixu@mailinator.com/frantic@300
|
||||||
|
|
||||||
|
## Sunking
|
||||||
|
- https://smsportal.clickmlapps.com/
|
||||||
|
- info@sunking.com
|
||||||
|
- 847SIcgO9sUX
|
||||||
### add
|
### add
|
||||||
- change pagination to 1000 from 20
|
- change pagination to 1000 from 20
|
||||||
- remove delivery receipt
|
- remove delivery receipt
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class ClientsLoginController extends Controller
|
|||||||
if ($elapsedMinutes > 30) {
|
if ($elapsedMinutes > 30) {
|
||||||
// code...
|
// code...
|
||||||
// $elapsedDays = Carbon::parse($stringDate)->diffInDays();
|
// $elapsedDays = Carbon::parse($stringDate)->diffInDays();
|
||||||
// OR using the now() helper
|
// OR using the now() helper
|
||||||
|
|
||||||
// $isExpired = $check_activation->activation_start_time->diffInMinutes() > 30;
|
// $isExpired = $check_activation->activation_start_time->diffInMinutes() > 30;
|
||||||
$data = [
|
$data = [
|
||||||
@@ -83,15 +83,17 @@ class ClientsLoginController extends Controller
|
|||||||
$logged_in = '';
|
$logged_in = '';
|
||||||
|
|
||||||
$client = Models\ClientSession::where('email', $request->email)->first();
|
$client = Models\ClientSession::where('email', $request->email)->first();
|
||||||
|
// dd($client);
|
||||||
if ($client == false) {
|
if ($client == false) {
|
||||||
return redirect()->back()->withErrors(['Invalid credentials']);
|
return redirect()->back()->withErrors(['Invalid credentials']);
|
||||||
}
|
}
|
||||||
$client_url = "clients/" . $client->client_id;
|
$client_url = "clients/" . $client->client_id;
|
||||||
$result = ApiCalls::CurlGet($client_url);
|
$result = ApiCalls::CurlGet($client_url);
|
||||||
|
|
||||||
$result_arr = json_decode($result, true);
|
$result_arr = json_decode($result, true);
|
||||||
$logged_in = $result_arr;
|
$logged_in = $result_arr;
|
||||||
|
|
||||||
|
|
||||||
$request->session()->regenerate(true);
|
$request->session()->regenerate(true);
|
||||||
$request->session()->put('current_user.user_id', $logged_in['id']);
|
$request->session()->put('current_user.user_id', $logged_in['id']);
|
||||||
$request->session()->put('current_user.org_id', $logged_in['id']);
|
$request->session()->put('current_user.org_id', $logged_in['id']);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Utilities\ApiCalls;
|
|||||||
use Session;
|
use Session;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
class ClientsTrafficController extends Controller
|
class ClientsTrafficController extends Controller
|
||||||
{
|
{
|
||||||
@@ -38,15 +39,34 @@ class ClientsTrafficController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
public function index(){
|
public function index(){
|
||||||
//dump(session('current_user'));
|
|
||||||
$client_id = session('current_user.org_id');
|
$client_id = session('current_user.org_id');
|
||||||
$clients_url = "messages/client/$client_id?page=0&size=1000&sort=createdAt,desc";
|
$clients_url = "messages/client/$client_id?page=0&size=1000&sort=createdAt,desc";
|
||||||
$result = ApiCalls::CurlGet($clients_url);
|
$result = ApiCalls::CurlGet($clients_url);
|
||||||
$result_arr = json_decode($result);
|
$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 = [
|
$data = [
|
||||||
'page_title' => 'SMS Traffic',
|
'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);
|
return view('client-traffic.index-test', $data);
|
||||||
}
|
}
|
||||||
@@ -155,6 +175,22 @@ class ClientsTrafficController extends Controller
|
|||||||
}
|
}
|
||||||
Session::flash('success_message', 'Message successfully submitted for delivery!');
|
Session::flash('success_message', 'Message successfully submitted for delivery!');
|
||||||
return redirect("send-sms");
|
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){
|
public function newAppStore(Request $request){
|
||||||
|
|
||||||
|
|||||||
11
info.md
Normal file
11
info.md
Normal file
@@ -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
|
||||||
|
|
||||||
@@ -5,9 +5,11 @@
|
|||||||
@section('page-css')
|
@section('page-css')
|
||||||
<!-- <link href="https://unpkg.com/tabulator-tables@6.4.0/dist/css/tabulator.min.css" rel="stylesheet"> -->
|
<!-- <link href="https://unpkg.com/tabulator-tables@6.4.0/dist/css/tabulator.min.css" rel="stylesheet"> -->
|
||||||
<link href="{{ url('public/libs/tabulator-master/dist/css/tabulator_bootstrap5.css') }}" rel="stylesheet">
|
<link href="{{ url('public/libs/tabulator-master/dist/css/tabulator_bootstrap5.css') }}" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/css/datepicker.min.css">
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<section class="traffic-hero mb-4">
|
<section class="traffic-hero mb-4">
|
||||||
<div class="row g-4 align-items-end">
|
<div class="row g-4 align-items-end">
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
@@ -17,9 +19,66 @@
|
|||||||
Search sent SMS, review delivery outcomes, inspect failed attempts, and give clients a fast audit trail for every campaign.
|
Search sent SMS, review delivery outcomes, inspect failed attempts, and give clients a fast audit trail for every campaign.
|
||||||
</p> -->
|
</p> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4"></div>
|
<div class="col-lg-4">
|
||||||
|
<div class="row g-3">
|
||||||
|
<!-- <div class="col-6">
|
||||||
|
<div class="rounded-4 p-3 bg-white bg-opacity-10">
|
||||||
|
<div class="small opacity-75">Campaigns</div>
|
||||||
|
<div class="h3 mb-0">18</div>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="rounded-4 p-3 bg-white bg-opacity-10">
|
||||||
|
<div class="small opacity-75">SMS Account Balance</div>
|
||||||
|
<div class="h3 mb-0" id="mainSmsBalance">{{ number_format($balance_arr['balance']) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="row g-4 mb-4">
|
||||||
|
<div class="col-md-6 col-xl-6">
|
||||||
|
<article class="traffic-card">
|
||||||
|
<div class="d-flex align-items-start justify-content-between mb-3">
|
||||||
|
<!-- <div class="icon-wrap"><i class="bi bi-send-check"></i></div> -->
|
||||||
|
<!-- <span class="small text-success fw-semibold">+12.6%</span> -->
|
||||||
|
</div>
|
||||||
|
<div class="muted-label mb-2">
|
||||||
|
<!-- Messages sent from -->
|
||||||
|
<span id="reportRange">{{ $sms_units_arr['reportDate'] }}</span> </div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<input id="startDate" name="start_date" type="text" class="form-control" placeholder="Select Start Date">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<input id="endDate" name="end_date" type="text" class="form-control" placeholder="Select End Date">
|
||||||
|
</div>
|
||||||
|
<div id="loadingSpinner" class="spinner-border text-primary" role="status" style="display:none;">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="h3 mb-2 pt-1" id="smsUnitsValue">SMS Units : {{ $sms_units_arr['smsUnits'] }}</div> -->
|
||||||
|
<!-- <div class="mini-chart"><span style="width: 52%;"></span></div> -->
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-xl-6">
|
||||||
|
<article class="traffic-card">
|
||||||
|
<div class="d-flex align-items-start justify-content-between mb-3">
|
||||||
|
<div class="icon-wrap"><i class="bi bi-check2-circle"></i></div>
|
||||||
|
<!-- <span class="small text-success fw-semibold">98.4%</span> -->
|
||||||
|
</div>
|
||||||
|
<div class="muted-label mb-2">Sent Messages</div>
|
||||||
|
<!-- <div class="h3 mb-2">183,372</div> -->
|
||||||
|
<div class="h3 mb-2 pt-1" id="smsUnitsValue">SMS Units : {{ $sms_units_arr['smsUnits'] }}</div>
|
||||||
|
|
||||||
|
<div class="mini-chart"><span style="width: 98%;"></span></div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
<section class="row g-4">
|
<section class="row g-4">
|
||||||
<div class="col-xl-12">
|
<div class="col-xl-12">
|
||||||
<div class="filter-card mb-4">
|
<div class="filter-card mb-4">
|
||||||
@@ -36,8 +95,7 @@
|
|||||||
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="float-end">
|
<div class="float-end">
|
||||||
|
|
||||||
|
|
||||||
<!-- <label for="search" class="form-label fw-semibold">Search</label> -->
|
<!-- <label for="search" class="form-label fw-semibold">Search</label> -->
|
||||||
<!-- <input id="search" type="text" class="form-control" placeholder="Phone, sender ID, text"> -->
|
<!-- <input id="search" type="text" class="form-control" placeholder="Phone, sender ID, text"> -->
|
||||||
@@ -47,6 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="traffic-table-card">
|
<div class="traffic-table-card">
|
||||||
|
<h2 class="h4 mb-1">Sent SMS list</h2>
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
<button id="download-pdf" class="btn btn-danger"><i class="bi bi-file-pdf-fill me-2"></i> Export PDF</button>
|
<button id="download-pdf" class="btn btn-danger"><i class="bi bi-file-pdf-fill me-2"></i> Export PDF</button>
|
||||||
<button id="download-xlsx" class="btn btn-success"><i class="bi bi-file-excel-fill me-2"></i> Export Excel</button>
|
<button id="download-xlsx" class="btn btn-success"><i class="bi bi-file-excel-fill me-2"></i> Export Excel</button>
|
||||||
@@ -77,6 +136,8 @@
|
|||||||
@endsection
|
@endsection
|
||||||
@section('page-js')
|
@section('page-js')
|
||||||
<!-- <script src="https://unpkg.com/tabulator-tables@6.4.0/dist/js/tabulator.min.js"></script> -->
|
<!-- <script src="https://unpkg.com/tabulator-tables@6.4.0/dist/js/tabulator.min.js"></script> -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/datepicker.min.js"></script>
|
||||||
|
|
||||||
<script src="{{ url('public/libs/tabulator-master/dist/js/tabulator.min.js') }}"></script>
|
<script src="{{ url('public/libs/tabulator-master/dist/js/tabulator.min.js') }}"></script>
|
||||||
|
|
||||||
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
|
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
|
||||||
@@ -85,6 +146,51 @@
|
|||||||
<script src="{{ url('public/libs/tabulator-master/dist/js/autotable.min.js') }}"></script>
|
<script src="{{ url('public/libs/tabulator-master/dist/js/autotable.min.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
console.log(base_url);
|
console.log(base_url);
|
||||||
|
const token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||||
|
const startDateElement = document.getElementById('startDate');
|
||||||
|
const endDateElement = document.getElementById('endDate');
|
||||||
|
|
||||||
|
|
||||||
|
const startDatepicker = new Datepicker(startDateElement, {
|
||||||
|
autohide: true,
|
||||||
|
format: 'yyyy-mm-dd'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const endDatepicker = new Datepicker(endDateElement, {
|
||||||
|
autohide: true,
|
||||||
|
format: 'yyyy-mm-dd'
|
||||||
|
});
|
||||||
|
|
||||||
|
function sendDailySmsUnits() {
|
||||||
|
document.getElementById('loadingSpinner').style.display = 'inline-block';
|
||||||
|
const endpoint = "{{ route('client.dailysmsunits') }}";
|
||||||
|
const startDate = startDateElement.value;
|
||||||
|
const endDate = endDateElement.value;
|
||||||
|
fetch(endpoint, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRF-TOKEN': token },
|
||||||
|
body: 'start_date=' + encodeURIComponent(startDate) + '&end_date=' + encodeURIComponent(endDate)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('Server response:', data);
|
||||||
|
console.log(data.smsUnits);
|
||||||
|
document.getElementById('loadingSpinner').style.display = 'none';
|
||||||
|
const theReportRange = document.getElementById('reportRange');
|
||||||
|
const theSmsUnitsValue = document.getElementById('smsUnitsValue');
|
||||||
|
theReportRange.innerHTML = data.reportDate;
|
||||||
|
theSmsUnitsValue.innerHTML = "SMS Units : " + data.smsUnits;
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//startDateElement.addEventListener('changeDate', sendDailySmsUnits);
|
||||||
|
endDateElement.addEventListener('changeDate', sendDailySmsUnits);
|
||||||
|
|
||||||
|
|
||||||
function statusDesign (cell, formatterParams){
|
function statusDesign (cell, formatterParams){
|
||||||
var value = cell.getValue();
|
var value = cell.getValue();
|
||||||
// if(value === 'Approved'){
|
// if(value === 'Approved'){
|
||||||
@@ -101,8 +207,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var table = new Tabulator("#message-table", {
|
var table = new Tabulator("#message-table", {
|
||||||
ajaxURL: "https://smsportal.clickmlapps.com/client-traffic-tabulator/",
|
ajaxURL: base_url = "client-traffic-tabulator", // "https://smsportal.clickmlapps.com/client-traffic-tabulator/",
|
||||||
ajaxConfig: {
|
ajaxConfig: {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -140,7 +246,7 @@
|
|||||||
invalidPlaceholder: "(invalid date)"
|
invalidPlaceholder: "(invalid date)"
|
||||||
}}
|
}}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("download-pdf").addEventListener("click", function(){
|
document.getElementById("download-pdf").addEventListener("click", function(){
|
||||||
table.download("pdf", "messages.pdf", {
|
table.download("pdf", "messages.pdf", {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<!-- <title>Click Client Portal | SMS Traffic</title> -->
|
<!-- <title>Click Client Portal | SMS Traffic</title> -->
|
||||||
<title>@yield('page-title') | Client Portal </title>
|
<title>@yield('page-title') | Client Portal </title>
|
||||||
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
|
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
<link rel="icon" type="image/png" href="{{ url('public/assets/images/click-logo.png') }}">
|
<link rel="icon" type="image/png" href="{{ url('public/assets/images/click-logo.png') }}">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ Route::post('/client-activation', [App\Http\Controllers\ClientsLoginController::
|
|||||||
Route::post('send-sms', [App\Http\Controllers\ClientsTrafficController::class, 'store'])->name('client.sendsms');
|
Route::post('send-sms', [App\Http\Controllers\ClientsTrafficController::class, 'store'])->name('client.sendsms');
|
||||||
Route::post('client-newapp', [App\Http\Controllers\ClientsTrafficController::class, 'newAppStore'])->name('client.sendsms');
|
Route::post('client-newapp', [App\Http\Controllers\ClientsTrafficController::class, 'newAppStore'])->name('client.sendsms');
|
||||||
|
|
||||||
|
Route::post('client-dailysmsunits', [App\Http\Controllers\ClientsTrafficController::class, 'dailySmsUnits'])->name('client.dailysmsunits');
|
||||||
|
|
||||||
// Route::post('send-sms', [App\Http\Controllers\ClientsTrafficController::class, 'store'])->name('client.sendsms');
|
// Route::post('send-sms', [App\Http\Controllers\ClientsTrafficController::class, 'store'])->name('client.sendsms');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user