File "soa.php"
Full Path: /home/leadltht/fastlinkinternet.com/wp-comment-form/reports/soa.php
File size: 10.84 KB
MIME-type: text/x-php
Charset: utf-8
<?php
require_once('/home/leadltht/fastlinkinternet.com/administrator/data-provider/config.php'); // Ensure the correct path to config.php
$clientName = '';
$clientDetails = [];
$billingCutOff = null;
$fiveDaysBillDueDate = null; // Disconnection date
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
function getBillingCutOffAndDisconnection($clientDetails, $billingYear, $billingMonth) {
// Billing cutoff logic (same as report3.php)
$cutOffDay = $clientDetails['cut_off_day'];
$billingCutOff = new DateTime("$billingYear-$billingMonth-$cutOffDay");
$fiveDaysBillDueDate = clone $billingCutOff;
$fiveDaysBillDueDate->add(new DateInterval('P5D'));
return [$billingCutOff, $fiveDaysBillDueDate];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$clientName = trim(strtolower($_POST['clientName']));
$billingMonth = $_POST['billingMonth'];
$billingYear = $_POST['billingYear'];
$billingCutOff = $_POST['billingCutOff']; // Date input for Billing Cut Off
$fiveDaysBillDueDate = $_POST['fiveDaysBillDueDate']; // Date input for Disconnection Date
$accountBalance = floatval($_POST['accountBalance']);
$billAdjustment = floatval($_POST['billAdjustment']);
$adjustmentReason = $_POST['adjustmentReason'];
// Fetch client details from report3.php logic
$sql = "SELECT CONCAT(firstname, ' ', lastname) AS client_name, plan_name, plan_price, cut_off_day, installation_date
FROM member_list
WHERE LOWER(CONCAT(firstname, ' ', lastname)) = '$clientName'";
$result = $conn->query($sql);
$clientDetails = $result->fetch_assoc();
// Calculate Amount Due
$amountDue = $accountBalance - $billAdjustment;
}
// Fetch all client names for the dropdown
$clientResult = $conn->query("SELECT CONCAT(firstname, ' ', lastname) AS client_name FROM member_list ORDER BY client_name ASC");
$clients = $clientResult->fetch_all(MYSQLI_ASSOC);
?>
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Statement of Account</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<style>
body {
font-size: 12px;
}
.heavy-line {
border-top: 5px solid #000;
margin: 20px 0;
}
.form-section {
margin-bottom: 20px;
}
.total-account-balance {
background-color: red;
color: white;
padding: 10px;
border-radius: 5px;
font-size: 25px;
text-align: center;
}
.amount-due-section {
background-color: #f8f9fa;
padding: 15px;
font-size: 20px;
font-weight: bold;
text-align: center;
}
.print-logo {
text-align: center;
}
.print-logo img {
width: 150px; /* Adjust to your logo size */
}
/* Print Specific Styling */
@media print {
.no-print {
display: none !important;
}
body {
font-size: 14px;
}
.container {
width: 100%;
padding: 0;
}
.print-logo {
text-align: center;
}
.heavy-line {
margin: 10px 0;
}
}
</style>
</head>
<body>
<div class="container mt-1 no-print">
<h4 class="mb-2">Select a Client to Show Statement of Account</h4>
<form method="POST" id="soa-form" action="">
<div class="row form-section">
<!-- Client Name -->
<div class="col-md-4">
<label for="clientName">Client Name:</label>
<select name="clientName" id="clientName" class="form-control">
<option value="">Select a client</option>
<?php foreach ($clients as $client): ?>
<option value="<?= htmlspecialchars(strtolower($client['client_name'])) ?>" <?= (strtolower($clientName) == strtolower($client['client_name'])) ? 'selected' : '' ?>>
<?= htmlspecialchars($client['client_name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<!-- Billing Month -->
<div class="col-md-4">
<label for="billingMonth">Billing Month:</label>
<select name="billingMonth" id="billingMonth" class="form-control">
<option value="">Choose Month</option>
<?php for ($m=1; $m<=12; $m++): ?>
<option value="<?= $m ?>" <?= (isset($billingMonth) && $billingMonth == $m) ? 'selected' : '' ?>>
<?= date('F', mktime(0, 0, 0, $m, 10)) ?>
</option>
<?php endfor; ?>
</select>
</div>
<!-- Billing Year -->
<div class="col-md-4">
<label for="billingYear">Billing Year:</label>
<input type="number" name="billingYear" id="billingYear" class="form-control" placeholder="Enter Year" value="<?= isset($billingYear) ? $billingYear : '' ?>">
</div>
</div>
<div class="row form-section">
<!-- Billing Cut Off -->
<div class="col-md-4">
<label for="billingCutOff">Billing Cut Off:</label>
<input type="date" name="billingCutOff" id="billingCutOff" class="form-control" value="<?= isset($billingCutOff) ? $billingCutOff : '' ?>">
</div>
<!-- Disconnection Date -->
<div class="col-md-4">
<label for="fiveDaysBillDueDate">Disconnection Date:</label>
<input type="date" name="fiveDaysBillDueDate" id="fiveDaysBillDueDate" class="form-control" value="<?= isset($fiveDaysBillDueDate) ? $fiveDaysBillDueDate : '' ?>">
</div>
<!-- Buttons -->
<div class="col-md-4 d-flex align-items-end">
<button type="submit" class="btn btn-primary mr-2">Show Details</button>
<button type="button" class="btn btn-secondary" id="printBtn">Print</button>
</div>
</div>
</form>
</div>
<!-- Printable Section -->
<div class="container mt-3" id="printable-section">
<div class="print-logo">
<img src="https://fastlinkinternet.com/administrator/data-provider/uploads/fastlink.png" alt="Logo" class="logo">
</div>
<h2 class="text-center">FASTLINK INTERNET | STATEMENT OF ACCOUNT</h2>
<h4 class="text-center">As of: <?= isset($billingMonth) ? date('F', mktime(0, 0, 0, $billingMonth, 10)) : 'Choose Month'; ?> <?= isset($billingYear) ? $billingYear : 'Enter Year'; ?></h4>
<div class="row">
<div class="col-md-4">
<h6>Client Name:</h6>
<h2><p><?= isset($clientDetails['client_name']) ? htmlspecialchars($clientDetails['client_name']) : '' ?></p></h2>
</div>
<div class="col-md-4">
<h6>Plan Name:</h6>
<h6><p><?= isset($clientDetails['plan_name']) ? htmlspecialchars($clientDetails['plan_name']) : '' ?></p></h6>
</div>
<div class="col-md-4">
<h6>Plan Price:</h6>
<h6><p>₱<?= isset($clientDetails['plan_price']) ? number_format($clientDetails['plan_price']) : '' ?></p></h6>
</div>
<div class="col-md-4">
<h6>Billing Cut Off:</h6>
<h6><p><?= isset($billingCutOff) ? htmlspecialchars($billingCutOff) : '' ?></p></h6>
</div>
<div class="col-md-4">
<h6>Disconnection Date:</h6>
<h6><p><?= isset($fiveDaysBillDueDate) ? htmlspecialchars($fiveDaysBillDueDate) : '' ?></p></h6>
</div>
</div>
<div class="heavy-line"></div>
<div class="row form-section">
<!-- Account Balance -->
<div class="col-md-4">
<h6><label for="accountBalance">Account Balance:</label></h6>
<input type="number" id="accountBalance" name="accountBalance" class="form-control" placeholder="Enter Amount" value="<?= isset($accountBalance) ? $accountBalance : '' ?>">
</div>
<!-- Bill Adjustment (Optional) -->
<div class="col-md-4">
<h6><label for="billAdjustment">Bill Adjustment (Optional):</label></h6>
<input type="number" id="billAdjustment" name="billAdjustment" class="form-control" placeholder="Enter Amount" value="<?= isset($billAdjustment) ? $billAdjustment : '' ?>">
</div>
<!-- Bill Adjustment Reason -->
<div class="col-md-4">
<h6><label for="adjustmentReason">Bill Adjustment Reason (Optional):</label></h6>
<input type="text" id="adjustmentReason" name="adjustmentReason" class="form-control" placeholder="Enter Reason" value="<?= isset($adjustmentReason) ? $adjustmentReason : '' ?>">
</div>
</div>
<div class="heavy-line"></div>
<div class="amount-due-section">
<h2>Amount Due: ₱<span id="amountDue">0.00</span></h2>
</div>
<h5><p class="text-center">To Avoid disconnection of the service, pay your account balance to:</p></h5>
<h4><p class="text-center">Felix I. Albotra Jr.</p></h4>
<h4><p class="text-center">GCASH# 09453306374</p></h4>
<div class="heavy-line"></div>
</div>
<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
function calculateAmountDue() {
var accountBalance = parseFloat($('#accountBalance').val()) || 0;
var billAdjustment = parseFloat($('#billAdjustment').val()) || 0;
var amountDue = accountBalance - billAdjustment;
$('#amountDue').text(amountDue.toFixed(2));
}
$('#accountBalance, #billAdjustment').on('input', function() {
calculateAmountDue();
});
// Print functionality
$('#printBtn').on('click', function () {
// Hide the form
$('.no-print').hide();
// Trigger print
window.print();
// Show the form again after printing
$('.no-print').show();
});
$('#clientName').select2({
placeholder: 'Select a client',
allowClear: true
});
});
</script>
</body>
</html>