modified the SMS Units and Charge
This commit is contained in:
@@ -23,5 +23,10 @@
|
|||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^ index.php [L]
|
RewriteRule ^ index.php [L]
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
<Files ~ "^.*\.([Ee][Nn][Vv])">
|
||||||
|
order allow,deny
|
||||||
|
deny from all
|
||||||
|
satisfy all
|
||||||
|
</Files>
|
||||||
php_value upload_max_filesize 512M
|
php_value upload_max_filesize 512M
|
||||||
php_value post_max_size 512M
|
php_value post_max_size 512M
|
||||||
|
|||||||
@@ -54,22 +54,45 @@ class ClientsTrafficController extends Controller
|
|||||||
$result = ApiCalls::CurlGet($daily_smsunits_url);
|
$result = ApiCalls::CurlGet($daily_smsunits_url);
|
||||||
$sms_units_arr = json_decode($result, true);
|
$sms_units_arr = json_decode($result, true);
|
||||||
|
|
||||||
|
$daily_smsunits_url_split = "ucm/reports/daily-sms-units-by-network?from=$start_date&to=$end_date";
|
||||||
|
$result = ApiCalls::CurlGet($daily_smsunits_url_split);
|
||||||
|
$split_sms_units_arr = json_decode($result, true);
|
||||||
|
|
||||||
$orgId = session('current_user.org_id');
|
$orgId = session('current_user.org_id');
|
||||||
$sms_balance_url = "clients/$orgId/balance";
|
$sms_balance_url = "clients/$orgId/balance";
|
||||||
$result = ApiCalls::CurlGet($sms_balance_url);
|
$result = ApiCalls::CurlGet($sms_balance_url);
|
||||||
|
|
||||||
$balance_arr = json_decode($result, true);
|
$balance_arr = json_decode($result, true);
|
||||||
|
/*
|
||||||
|
array:4 [▼ // app/Http/Controllers/ClientsTrafficController.php:67
|
||||||
|
"reportDate" => "2026-05-10 to 2026-05-20"
|
||||||
|
"orgId" => 629
|
||||||
|
"Airtel SMSUnits" => 401095
|
||||||
|
"TNM SMSUnits" => 18796
|
||||||
|
]
|
||||||
|
|
||||||
// dump($sms_units_arr);
|
"reportDate" => "2026-05-10 to 2026-05-20"
|
||||||
|
"orgId" => 629
|
||||||
|
"Airtel SMSUnits" => 401095
|
||||||
|
"TNM SMSUnits" => 18796
|
||||||
|
*/
|
||||||
|
// dump($split_sms_units_arr);
|
||||||
|
$airtel_rate = 14;
|
||||||
|
$tnm_rate = 18;
|
||||||
|
$charge_computation = number_format(($split_sms_units_arr['Airtel SMSUnits'] * $airtel_rate) + ($split_sms_units_arr['TNM SMSUnits'] + $tnm_rate), 2);
|
||||||
|
$split_sms_units_arr['charge_computation'] = $charge_computation;
|
||||||
$data = [
|
$data = [
|
||||||
'page_title' => 'SMS Traffic',
|
'page_title' => 'SMS Traffic',
|
||||||
'traffic_arr' => $result_arr,
|
'traffic_arr' => $result_arr,
|
||||||
'sms_units_arr' => $sms_units_arr,
|
'sms_units_arr' => $sms_units_arr,
|
||||||
|
'split_sms_units_arr' => $split_sms_units_arr,
|
||||||
|
'charge_computation' => $charge_computation,
|
||||||
'balance_arr' => $balance_arr
|
'balance_arr' => $balance_arr
|
||||||
];
|
];
|
||||||
|
// dd($data);
|
||||||
return view('client-traffic.index-main', $data);
|
return view('client-traffic.index-main', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexTabulator(Request $request){
|
public function indexTabulator(Request $request){
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
@@ -183,14 +206,29 @@ class ClientsTrafficController extends Controller
|
|||||||
]);
|
]);
|
||||||
$start_date = $request->start_date;
|
$start_date = $request->start_date;
|
||||||
$end_date = $request->end_date;
|
$end_date = $request->end_date;
|
||||||
|
/*
|
||||||
$daily_smsunits_url = "ucm/reports/daily-sms-units?from=$start_date&to=$end_date";
|
$daily_smsunits_url = "ucm/reports/daily-sms-units?from=$start_date&to=$end_date";
|
||||||
$result = ApiCalls::CurlGet($daily_smsunits_url);
|
$result = ApiCalls::CurlGet($daily_smsunits_url);
|
||||||
\Log::info('SMS Units Response ' . $result);
|
\Log::info('SMS Units Response ' . $result);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$daily_smsunits_url_split = "ucm/reports/daily-sms-units-by-network?from=$start_date&to=$end_date";
|
||||||
|
$result = ApiCalls::CurlGet($daily_smsunits_url_split);
|
||||||
|
$split_sms_units_arr = json_decode($result, true);
|
||||||
|
\Log::info('SMS Units Response ' . $result);
|
||||||
|
|
||||||
$data = json_decode($result, true);
|
$data = json_decode($result, true);
|
||||||
|
|
||||||
|
$airtel_rate = 14;
|
||||||
|
$tnm_rate = 18;
|
||||||
|
$charge_computation = ($split_sms_units_arr['Airtel SMSUnits'] * $airtel_rate) + ($split_sms_units_arr['TNM SMSUnits'] + $tnm_rate);
|
||||||
|
$data['charge_computation'] = number_format($charge_computation, 2);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
public function dailySmsUnitsSplit(){
|
||||||
|
|
||||||
|
$clients_url = "ucm/reports/daily-sms-units-by-network?from={{reportDateFrom}}&to={{reportDateTo}}";
|
||||||
}
|
}
|
||||||
public function newAppStore(Request $request){
|
public function newAppStore(Request $request){
|
||||||
|
|
||||||
|
|||||||
@@ -1,123 +1,153 @@
|
|||||||
const token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
const token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||||
const startDateElement = document.getElementById('startDate');
|
const startDateElement = document.getElementById('startDate');
|
||||||
const endDateElement = document.getElementById('endDate');
|
const endDateElement = document.getElementById('endDate');
|
||||||
|
|
||||||
const startDatepicker = new Datepicker(startDateElement, {
|
const startDatepicker = new Datepicker(startDateElement, {
|
||||||
autohide: true,
|
autohide: true,
|
||||||
format: 'yyyy-mm-dd'
|
format: 'yyyy-mm-dd'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const endDatepicker = new Datepicker(endDateElement, {
|
const endDatepicker = new Datepicker(endDateElement, {
|
||||||
autohide: true,
|
autohide: true,
|
||||||
format: 'yyyy-mm-dd'
|
format: 'yyyy-mm-dd'
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendDailySmsUnits() {
|
function sendDailySmsUnitsOld() {
|
||||||
document.getElementById('loadingOverlay').style.display = 'flex';
|
document.getElementById('loadingOverlay').style.display = 'flex';
|
||||||
const endpoint = "client-dailysmsunits";
|
const endpoint = "client-dailysmsunits";
|
||||||
const startDate = startDateElement.value;
|
const startDate = startDateElement.value;
|
||||||
const endDate = endDateElement.value;
|
const endDate = endDateElement.value;
|
||||||
fetch(endpoint, {
|
fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRF-TOKEN': token },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRF-TOKEN': token },
|
||||||
body: 'start_date=' + encodeURIComponent(startDate) + '&end_date=' + encodeURIComponent(endDate)
|
body: 'start_date=' + encodeURIComponent(startDate) + '&end_date=' + encodeURIComponent(endDate)
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
// document.getElementById('loadingSpinner').style.display = 'none';
|
// document.getElementById('loadingSpinner').style.display = 'none';
|
||||||
document.getElementById('loadingOverlay').style.display = 'none';
|
document.getElementById('loadingOverlay').style.display = 'none';
|
||||||
const theReportRange = document.getElementById('reportRange');
|
const theReportRange = document.getElementById('reportRange');
|
||||||
const theSmsUnitsValue = document.getElementById('smsUnitsValue');
|
const theSmsUnitsValue = document.getElementById('smsUnitsValue');
|
||||||
theReportRange.innerHTML = data.reportDate;
|
theReportRange.innerHTML = data.reportDate;
|
||||||
theSmsUnitsValue.innerHTML = "SMS Units : " + data.smsUnits + "| Charge : " + data.clientChargeTotal.toFixed(2);
|
theSmsUnitsValue.innerHTML = "SMS Units : " + data.smsUnits + "| Charge : " + data.clientChargeTotal.toFixed(2);
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error:', error));
|
.catch(error => console.error('Error:', error));
|
||||||
|
}
|
||||||
|
function sendDailySmsUnits() {
|
||||||
|
document.getElementById('loadingOverlay').style.display = 'flex';
|
||||||
|
const endpoint = "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 => {
|
||||||
|
document.getElementById('loadingOverlay').style.display = 'none';
|
||||||
|
const theReportRange = document.getElementById('reportRange');
|
||||||
|
const theSmsUnitsValue = document.getElementById('smsUnitsValue');
|
||||||
|
const theSmsChargeTotalValue = document.getElementById('smsUnitsCharge');
|
||||||
|
theReportRange.innerHTML = data.reportDate;
|
||||||
|
|
||||||
|
const formattedTNMUnits = Number(data['TNM SMSUnits']).toLocaleString('en-GH');
|
||||||
|
|
||||||
|
const formattedAirtelUnits = Number(data.data['Airtel SMSUnits']).toLocaleString('en-GH', {
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
theSmsChargeTotalValue.innerHTML = 'SMS Charge(MWK) : ' + data.charge_computation;
|
||||||
|
theSmsUnitsValue.innerHTML = `SMS Units: Airtel ${formattedAirtelUnits} | TNM: ${formattedTNMUnits}`;
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
}
|
||||||
|
endDateElement.addEventListener('changeDate', sendDailySmsUnits);
|
||||||
|
|
||||||
|
|
||||||
|
function statusDesign (cell, formatterParams){
|
||||||
|
var value = cell.getValue();
|
||||||
|
if (value !== null) {
|
||||||
|
if(value.includes('SENT')){
|
||||||
|
return "<span style='color:#3FB449; font-weight:bold;'>" + value + "</span>";
|
||||||
}
|
}
|
||||||
endDateElement.addEventListener('changeDate', sendDailySmsUnits);
|
else{
|
||||||
|
return "<span style='color:#E4A11B;'>" + value + "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var table = new Tabulator("#message-table", {
|
||||||
|
ajaxURL: base_url = "client-traffic-tabulator",
|
||||||
|
ajaxConfig: {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=utf-8",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ajaxParams: {size: 1000},
|
||||||
|
pagination: "remote",
|
||||||
|
paginationSize: 20,
|
||||||
|
paginationDataSent: {
|
||||||
|
"page": "page",
|
||||||
|
"size": "size"
|
||||||
|
},
|
||||||
|
paginationDataReceived: {
|
||||||
|
"last_page": "totalPages",
|
||||||
|
"data": "content",
|
||||||
|
"current_page": "number",
|
||||||
|
"total": "totalElements"
|
||||||
|
},
|
||||||
|
ajaxResponse: function(url, params, response) {
|
||||||
|
return response.content;
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{title: "Sender", field: "from", width:150, headerFilter:"input"},
|
||||||
|
{title: "Msisdn", field: "to", width:150, headerFilter:"input"},
|
||||||
|
{title:"Message", field:"message", width:650, formatter:"textarea", headerFilter:"input"},
|
||||||
|
{
|
||||||
|
title:"Date Created",
|
||||||
|
field:"createdAt",
|
||||||
|
width:200,
|
||||||
|
formatter:"datetime",
|
||||||
|
formatterParams:{
|
||||||
|
inputFormat:"iso",
|
||||||
|
outputFormat:"yyyy-MM-dd",
|
||||||
|
invalidPlaceholder:"(invalid date)"
|
||||||
|
},
|
||||||
|
headerFilter:function(cell, onRendered, success, cancel){
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.type = "date";
|
||||||
|
|
||||||
|
input.addEventListener("change", function(){
|
||||||
|
console.log(input.value);
|
||||||
|
success(input.value);
|
||||||
|
});
|
||||||
|
|
||||||
function statusDesign (cell, formatterParams){
|
return input;
|
||||||
var value = cell.getValue();
|
},
|
||||||
if (value !== null) {
|
headerFilterFunc:function(headerValue, rowValue){
|
||||||
if(value.includes('SENT')){
|
if(!headerValue){ return true; } // no filter
|
||||||
return "<span style='color:#3FB449; font-weight:bold;'>" + value + "</span>";
|
if(!rowValue){ return false; }
|
||||||
}
|
|
||||||
else{
|
const rowDate = new Date(rowValue);
|
||||||
return "<span style='color:#E4A11B;'>" + value + "</span>";
|
const formatted = rowDate.toISOString().split("T")[0]; // yyyy-MM-dd
|
||||||
|
|
||||||
|
return formatted === headerValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
var table = new Tabulator("#message-table", {
|
});
|
||||||
ajaxURL: base_url = "client-traffic-tabulator",
|
|
||||||
ajaxConfig: {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=utf-8",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ajaxParams: {size: 1000},
|
|
||||||
pagination: "remote",
|
|
||||||
paginationSize: 20,
|
|
||||||
paginationDataSent: {
|
|
||||||
"page": "page",
|
|
||||||
"size": "size"
|
|
||||||
},
|
|
||||||
paginationDataReceived: {
|
|
||||||
"last_page": "totalPages",
|
|
||||||
"data": "content",
|
|
||||||
"current_page": "number",
|
|
||||||
"total": "totalElements"
|
|
||||||
},
|
|
||||||
ajaxResponse: function(url, params, response) {
|
|
||||||
return response.content;
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{title: "Sender", field: "from", width:150, headerFilter:"input"},
|
|
||||||
{title: "Msisdn", field: "to", width:150, headerFilter:"input"},
|
|
||||||
{title:"Message", field:"message", width:650, formatter:"textarea", headerFilter:"input"},
|
|
||||||
{
|
|
||||||
title:"Date Created",
|
|
||||||
field:"createdAt",
|
|
||||||
width:200,
|
|
||||||
formatter:"datetime",
|
|
||||||
formatterParams:{
|
|
||||||
inputFormat:"iso",
|
|
||||||
outputFormat:"yyyy-MM-dd",
|
|
||||||
invalidPlaceholder:"(invalid date)"
|
|
||||||
},
|
|
||||||
headerFilter:function(cell, onRendered, success, cancel){
|
|
||||||
var input = document.createElement("input");
|
|
||||||
input.type = "date";
|
|
||||||
|
|
||||||
input.addEventListener("change", function(){
|
document.getElementById("download-pdf").addEventListener("click", function(){
|
||||||
console.log(input.value);
|
table.download("pdf", "messages.pdf", {
|
||||||
success(input.value);
|
orientation:"portrait", // portrait or landscape
|
||||||
});
|
title:"Messages Export", // document title
|
||||||
|
|
||||||
return input;
|
|
||||||
},
|
|
||||||
headerFilterFunc:function(headerValue, rowValue){
|
|
||||||
if(!headerValue){ return true; } // no filter
|
|
||||||
if(!rowValue){ return false; }
|
|
||||||
|
|
||||||
const rowDate = new Date(rowValue);
|
|
||||||
const formatted = rowDate.toISOString().split("T")[0]; // yyyy-MM-dd
|
|
||||||
|
|
||||||
return formatted === headerValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById("download-pdf").addEventListener("click", function(){
|
document.getElementById("download-xlsx").addEventListener("click", function(){
|
||||||
table.download("pdf", "messages.pdf", {
|
table.download("xlsx", "messages.xlsx", {sheetName:"Messages"});
|
||||||
orientation:"portrait", // portrait or landscape
|
});
|
||||||
title:"Messages Export", // document title
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById("download-xlsx").addEventListener("click", function(){
|
|
||||||
table.download("xlsx", "messages.xlsx", {sheetName:"Messages"});
|
|
||||||
});
|
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="muted-label mb-2">
|
<div class="muted-label mb-2">
|
||||||
<!-- Messages sent from -->
|
<!-- Messages sent from -->
|
||||||
<span id="reportRange">{{ $sms_units_arr['reportDate'] }}</span> </div>
|
<span id="reportRange">{{ $split_sms_units_arr['reportDate'] }}</span> </div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@@ -81,7 +81,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="muted-label mb-2">Sent Messages</div>
|
<div class="muted-label mb-2">Sent Messages</div>
|
||||||
<!-- <div class="h3 mb-2">183,372</div> -->
|
<!-- <div class="h3 mb-2">183,372</div> -->
|
||||||
<div class="h3 mb-2 pt-1" id="smsUnitsValue">SMS Units : {{ $sms_units_arr['smsUnits'] }} | Charge : {{ number_format($sms_units_arr['clientChargeTotal'], 2) }}</div>
|
<div class="h5 mb-2 pt-1" id="smsUnitsCharge">SMS Charge(MWK) : {{ $split_sms_units_arr['charge_computation'] }}</div>
|
||||||
|
<div class="h5 mb-2 pt-1" id="smsUnitsValue">SMS Units : Airtel : {{ number_format($split_sms_units_arr['Airtel SMSUnits']) }} | TNM : {{ number_format($split_sms_units_arr['TNM SMSUnits']) }}</div>
|
||||||
|
|
||||||
<div class="mini-chart"><span style="width: 57%;"></span></div>
|
<div class="mini-chart"><span style="width: 57%;"></span></div>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- <title>Click Client Portal | SMS Traffic</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">
|
||||||
|
<title>@yield('page-title') | Client Portal </title>
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<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">
|
||||||
|
|||||||
Reference in New Issue
Block a user