306 lines
14 KiB
PHP
306 lines
14 KiB
PHP
@extends('layouts.master')
|
|
@section('page-title')
|
|
{{ $page_title }}
|
|
@endsection
|
|
@section('page-css')
|
|
<!-- <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 rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/css/datepicker.min.css">
|
|
|
|
@endsection
|
|
@section('content')
|
|
<div id="loadingOverlay"
|
|
style="display:none; position:fixed; top:0; left:0; width:100%; height:100%;
|
|
background:rgba(255,255,255,0.8); z-index:9999;
|
|
align-items:center; justify-content:center;">
|
|
<div class="spinner-border text-primary" role="status">
|
|
<span class="visually-hidden">Loading...</span>
|
|
</div>
|
|
</div>
|
|
<section class="traffic-hero mb-4">
|
|
<div class="row g-4 align-items-end">
|
|
<div class="col-lg-8">
|
|
<div class="text-uppercase small fw-semibold opacity-75 mb-2">SMS Traffic Monitoring</div>
|
|
<!-- <h1 class="display-6 fw-semibold mb-3">Track every message your team sends.</h1>
|
|
<p class="fs-5 opacity-75 mb-0">
|
|
Search sent SMS, review delivery outcomes, inspect failed attempts, and give clients a fast audit trail for every campaign.
|
|
</p> -->
|
|
</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>
|
|
</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">
|
|
<div class="col-xl-12">
|
|
<div class="filter-card mb-4">
|
|
<div class="d-flex flex-column flex-lg-row align-items-lg-center justify-content-between gap-3 mb-3">
|
|
<div>
|
|
<h2 class="h4 mb-1">Sent SMS list</h2>
|
|
<!-- <p class="text-secondary mb-0">Filter messages by date, sender, recipient, or delivery state.</p> -->
|
|
</div>
|
|
<!-- <div class="d-flex flex-wrap gap-2">
|
|
<button class="btn btn-ghost px-4"><i class="bi bi-download me-2"></i>Export CSV</button>
|
|
<button class="btn btn-click px-4"><i class="bi bi-funnel me-2"></i>Apply filters</button>
|
|
</div> -->
|
|
</div>
|
|
|
|
<div class="row g-3">
|
|
<div class="col-md-12">
|
|
<div class="float-end">
|
|
|
|
<!-- <label for="search" class="form-label fw-semibold">Search</label> -->
|
|
<!-- <input id="search" type="text" class="form-control" placeholder="Phone, sender ID, text"> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="traffic-table-card">
|
|
<h2 class="h4 mb-1">Sent SMS list</h2>
|
|
<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-xlsx" class="btn btn-success"><i class="bi bi-file-excel-fill me-2"></i> Export Excel</button>
|
|
</div>
|
|
<div id="message-table"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <div class="col-xl-2"> -->
|
|
|
|
|
|
<!-- <aside class="detail-card"> -->
|
|
<!-- <h2 class="h5 mb-3">Recent activity</h2> -->
|
|
|
|
<!-- <div class="timeline-item pt-0 mt-0 border-0">
|
|
<div class="fw-semibold">Sender ID approved</div>
|
|
<div class="muted-label">CLICKINFO added </div>
|
|
<div class="small text-secondary mt-1">09:04</div>
|
|
</div> -->
|
|
<!-- <div class="timeline-item">
|
|
<div class="fw-semibold">Campaign completed</div>
|
|
<div class="muted-label">[campaign name] batch finished</div>
|
|
<div class="small text-secondary mt-1">08:41</div>
|
|
</div> -->
|
|
<!-- </aside> -->
|
|
<!-- </div> -->
|
|
</section>
|
|
@endsection
|
|
@section('page-js')
|
|
<!-- <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="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
|
|
<script type="text/javascript" src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js"></script>
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@2.3.1/build/global/luxon.min.js"></script>
|
|
<script src="{{ url('public/libs/tabulator-master/dist/js/autotable.min.js') }}"></script>
|
|
<script src=" https://cdn.jsdelivr.net/npm/luxon@3.7.2/build/global/luxon.min.js "></script>
|
|
<script>
|
|
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';
|
|
document.getElementById('loadingOverlay').style.display = 'flex';
|
|
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 => {
|
|
// document.getElementById('loadingSpinner').style.display = 'none';
|
|
document.getElementById('loadingOverlay').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){
|
|
var value = cell.getValue();
|
|
// if(value === 'Approved'){
|
|
// console.log(value !== null);
|
|
if (value !== null) {
|
|
if(value.includes('SENT')){
|
|
return "<span style='color:#3FB449; font-weight:bold;'>" + value + "</span>";
|
|
}
|
|
// else if(value.includes('Active')){
|
|
// return "<span style='color:#3FB449; font-weight:bold;'>" + value + "</span>";
|
|
// }
|
|
else{
|
|
return "<span style='color:#E4A11B;'>" + value + "</span>";
|
|
}
|
|
}
|
|
}
|
|
var table = new Tabulator("#message-table", {
|
|
ajaxURL: base_url = "client-traffic-tabulator", // "https://smsportal.clickmlapps.com/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", headerFilter:"input", formatterParams:{
|
|
// inputFormat: "iso",
|
|
// outputFormat: "dd-MM-yyyy HH:mm:ss",
|
|
// invalidPlaceholder: "(invalid date)"
|
|
// }}
|
|
// ],
|
|
|
|
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){
|
|
// Create native date input
|
|
var input = document.createElement("input");
|
|
input.type = "date";
|
|
|
|
input.addEventListener("change", function(){
|
|
console.log(input.value);
|
|
success(input.value); // pass value to Tabulator filter
|
|
});
|
|
|
|
return input;
|
|
},
|
|
headerFilterFunc:function(headerValue, rowValue){
|
|
if(!headerValue){ return true; } // no filter
|
|
if(!rowValue){ return false; }
|
|
|
|
// Extract just the date portion from ISO timestamp
|
|
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(){
|
|
table.download("pdf", "messages.pdf", {
|
|
orientation:"portrait", // portrait or landscape
|
|
title:"Messages Export", // document title
|
|
});
|
|
});
|
|
|
|
document.getElementById("download-xlsx").addEventListener("click", function(){
|
|
table.download("xlsx", "messages.xlsx", {sheetName:"Messages"});
|
|
});
|
|
</script>
|
|
|
|
@endsection |