added User management
This commit is contained in:
@@ -35,10 +35,12 @@
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="col-12">
|
||||
@if(in_array(session('current_user.role'), ['administrator', 'finance']))
|
||||
<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>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,9 +81,9 @@
|
||||
</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="h3 mb-2 pt-1" id="smsUnitsValue">SMS Units : {{ $sms_units_arr['smsUnits'] }} | Charge : {{ number_format($sms_units_arr['clientChargeTotal'], 2) }}</div>
|
||||
|
||||
<div class="mini-chart"><span style="width: 98%;"></span></div>
|
||||
<div class="mini-chart"><span style="width: 57%;"></span></div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -139,7 +141,7 @@
|
||||
</div> -->
|
||||
<!-- </aside> -->
|
||||
<!-- </div> -->
|
||||
</section>
|
||||
</section>
|
||||
@endsection
|
||||
@section('page-js')
|
||||
<!-- <script src="https://unpkg.com/tabulator-tables@6.4.0/dist/js/tabulator.min.js"></script> -->
|
||||
@@ -151,156 +153,6 @@
|
||||
<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>
|
||||
<script src="{{ url('public/assets/js/traffic-mgt.js') }}"></script>
|
||||
|
||||
@endsection
|
||||
Reference in New Issue
Block a user