File "index.php"
Full Path: /home/leadltht/fastlinkinternet.com/administrator/data-provider/admin/members/index.php
File size: 12.23 KB
MIME-type: text/x-php
Charset: utf-8
<?php if($_settings->chk_flashdata('success')): ?>
<script>
alert_toast("<?php echo $_settings->flashdata('success') ?>",'success')
</script>
<?php endif;?>
<div class="card card-outline card-primary">
<div class="card-header">
<h3 class="card-title">List of Clients</h3>
<div class="card-tools">
<a href="javascript:void(0)" id="create_new" class="btn btn-flat btn-primary"><span class="fas fa-plus"></span> Add New</a>
</div>
</div>
<div class="card-body">
<div class="container-fluid">
<?php if($_SESSION['userdata']['type'] == 1 || $_SESSION['userdata']['type'] == 2): ?>
<div class="row mb-3">
<div class="col-md-6 text-center">
<a href="javascript:void(0)" id="prorate_calculator" class="btn btn-flat btn-secondary"><span class="fas fa-calculator"></span> Prorate Calculator</a>
</div>
<div class="col-md-6 text-center">
<div class="input-group">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary" type="button" id="decrease_account_number">-</button>
</div>
<input type="text" id="account_number" class="form-control text-center" value="1000000000" readonly>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="increase_account_number">+</button>
</div>
</div>
</div>
</div>
<table class="table table-bordered table-stripped" style="width: 100%;">
<colgroup>
<col width="5%">
<col width="15%">
<col width="10%">
<col width="10%">
<col width="5%">
<col width="6%">
<col width="10%">
<col width="6%">
<col width="8%">
<col width="7%">
<col width="5%">
<col width="5%">
<col width="8%">
<col width="5%">
<col width="15%">
</colgroup>
<thead>
<tr class="bg-gradient-secondary">
<th>#</th>
<th>Client Name</th>
<th>Acct.No.</th>
<th>Installation Date</th>
<th>Contact | Address | Etc.</th>
<th>Installation | ProRate Fee</th>
<th>Balance From Previous Bills</th>
<th>Plan Name</th>
<th>Plan Price</th>
<th>Server</th>
<th>Status</th>
<th>Cut Off</th>
<th>Inactive Date</th>
<th>For PD?</th>
<th>Notes</th>
<th>Facebook Account</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$qry = $conn->query("SELECT *, CONCAT(firstname, ' ', COALESCE(middlename,''), ' ', lastname) as fullname from `member_list` order by (CONCAT(firstname, ' ', COALESCE(middlename,''), ' ', lastname)) asc ");
$latest_account_number = 1000000000;
while($row = $qry->fetch_assoc()):
if ($row['account_number'] > $latest_account_number) {
$latest_account_number = $row['account_number'];
}
?>
<tr>
<td class="text-center"><?php echo $i++; ?></td>
<td><?php echo ucwords($row['fullname']) ?></td>
<td><?php echo ucwords($row['account_number']) ?></td>
<td><?php echo date("Y-m-d",strtotime($row['installation_date'])) ?></td>
<td><?php echo $row['contact'] ?></td>
<td class="text-right"><?php echo $row['installation_fee'] ?></td>
<td class="text-right"><?php echo $row['previous_bal'] ?></td>
<td><?php echo $row['plan_name'] ?></td>
<td><?php echo $row['plan_price'] ?></td>
<td><?php echo $row['server'] ?></td>
<td><?php echo $row['status'] ?></td>
<td class="text-right"><?php echo $row['cut_off_day'] ?></td>
<td><?php echo $row['inactive_date'] ?></td>
<td><?php echo $row['for_pd'] ?></td>
<td><?php echo $row['notes'] ?></td>
<td>
<?php if (!empty($row['fb_account'])): ?>
<a href="<?php echo htmlspecialchars($row['fb_account']); ?>" target="_blank">
<?php echo htmlspecialchars($row['fb_account']); ?>
</a>
<?php else: ?>
No FB Account
<?php endif; ?>
</td> <!-- New FB Account column -->
<td align="center">
<button type="button" class="btn btn-flat btn-default btn-sm dropdown-toggle dropdown-icon" data-toggle="dropdown">
Action
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="./?page=members/view_member&id=<?= $row['id'] ?>"><span class="fa fa-eye text-dark"></span> View</a>
<?php if($_SESSION['userdata']['type'] == 1): ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item edit_data" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>"><span class="fa fa-edit text-primary"></span> Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item delete_data" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>"><span class="fa fa-trash text-danger"></span> Delete</a>
<?php endif; ?>
</div>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#account_number').val(<?php echo $latest_account_number + 1; ?>);
$('#increase_account_number').click(function() {
let currentVal = parseInt($('#account_number').val());
$('#account_number').val(currentVal + 1);
});
$('#decrease_account_number').click(function() {
let currentVal = parseInt($('#account_number').val());
if (currentVal > 1000000000) {
$('#account_number').val(currentVal - 1);
}
});
});
</script>
<?php endif; ?>
</div>
</div>
</div>
<!-- Modal for Prorate Calculator -->
<div class="modal fade" id="prorateModal" tabindex="-1" role="dialog" aria-labelledby="prorateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="prorateModalLabel">Prorate Calculator</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="prorateForm">
<div class="form-group">
<label for="startDate">Start Date</label>
<input type="date" class="form-control" id="startDate" required>
</div>
<div class="form-group">
<label for="cutOffDate">Cut Off Date</label>
<input type="date" class="form-control" id="cutOffDate" required>
</div>
<div class="form-group">
<label for="planPrice">Plan Price</label>
<input type="number" class="form-control" id="planPrice" required>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="calculateProrate">Calculate</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="prorateAmount">Prorate Amount</label>
<input type="text" class="form-control" id="prorateAmount" readonly>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#create_new').click(function(){
uni_modal('Add New Client',"members/manage_member.php")
})
$('#prorate_calculator').click(function(){
$('#prorateModal').modal('show');
})
$('.edit_data').click(function(){
uni_modal('Update Client Details',"members/manage_member.php?id="+$(this).attr('data-id'))
})
$('.delete_data').click(function(){
_conf("Are you sure to delete this Client permanently?","delete_member",[$(this).attr('data-id')])
})
$('table th, table td').addClass('align-middle px-2 py-1')
$('.table').dataTable({
"paging": true,
"lengthChange": true,
"pageLength": 25,
"lengthMenu": [[25, 50], [25, 50]],
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
})
$('#calculateProrate').click(function(){
let startDate = new Date($('#startDate').val());
let cutOffDate = new Date($('#cutOffDate').val());
let planPrice = parseFloat($('#planPrice').val());
let prorateAmount = calculateProrate(startDate, cutOffDate, planPrice);
$('#prorateAmount').val(prorateAmount.toFixed(2));
});
})
function calculateProrate(startDate, cutOffDate, planPrice) {
let totalDays = (cutOffDate - startDate) / (1000 * 3600 * 24);
let daysInMonth = new Date(cutOffDate.getFullYear(), cutOffDate.getMonth() + 1, 0).getDate();
return (planPrice / daysInMonth) * totalDays;
}
function delete_member($id){
start_loader();
$.ajax({
url:_base_url_+"classes/Master.php?f=delete_member",
method:"POST",
data:{id: $id},
dataType:"json",
error:err=>{
console.log(err)
alert_toast("An error occured.",'error');
end_loader();
},
success:function(resp){
if(typeof resp== 'object' && resp.status == 'success'){
location.reload();
}else{
alert_toast("An error occured.",'error');
end_loader();
}
}
})
}
</script>