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){
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
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;
|
||||||
@@ -35,6 +35,36 @@
|
|||||||
})
|
})
|
||||||
.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);
|
endDateElement.addEventListener('changeDate', sendDailySmsUnits);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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