BBnepal-Accounts/account/application/views/accounts/pl_new.php

427 lines
22 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
$this->load->library("BIBAccounts");
$BIBAccounts = new BIBAccounts();
?>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Include jQuery UI -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
table,
2024-07-10 12:43:19 +00:00
td,
tr {
padding: 0px;
margin: 0px;
}
2024-07-10 12:43:19 +00:00
.group-name {
width: 40%;
2024-07-10 12:43:19 +00:00
}
2024-07-10 12:43:19 +00:00
.group-total {
width: 10%;
}
2024-07-10 12:43:19 +00:00
.table-gray {
background-color: #eee;
}
2024-07-10 12:43:19 +00:00
.table td,
.table th {
padding: 0px;
margin: 0px;
}
2024-07-10 12:43:19 +00:00
.bg-darker {
background-color: #ddd;
}
2024-07-10 12:43:19 +00:00
td .table {
border: 0px !important;
margin-bottom: 0rem;
}
2024-07-10 12:43:19 +00:00
table td:first-child {
padding-left: 5px;
}
2024-07-10 12:43:19 +00:00
.table-bordered.vertical-borders td,
.table-bordered.vertical-borders th {
border-left: 1px solid #dee2e6;
border-right: 1px solid #dee2e6;
}
2024-07-10 12:43:19 +00:00
.table-bordered.vertical-borders thead th {
padding: 0.25rem;
border-top: none;
border-bottom: 2px solid #dee2e6;
}
2024-07-10 12:43:19 +00:00
.table-bordered.vertical-borders tfoot th {
padding: 0.25rem;
border-top: 2px solid #dee2e6;
border-bottom: none;
}
.currency {
font-weight: normal !important;
}
.underline {
text-decoration: underline;
}
2024-07-10 12:43:19 +00:00
.form-control {
display: block;
width: 100%;
height: calc(1.5rem + 1px);
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
2024-08-26 06:44:38 +00:00
.table1 {
border: 0px !important;
padding: 0;
margin: 10 !important;
width: 100%;
vertical-align: middle;
}
.table-responsive {
overflow-x: auto;
}
.card-body {
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
min-height: 1px;
padding: 0;
}
table {
border: 1px solid #ddd;
border-collapse: collapse;
}
2024-07-10 12:43:19 +00:00
</style>
<div class="content-wrapper">
<div class="content">
2024-07-10 12:43:19 +00:00
<div class="container-fluid">
<div class="card card-primary card-outline ">
<div class="card-header">
2024-08-08 12:39:25 +00:00
<h2 class="card-title mt-1"><?php echo $pageTitle; ?> <?php //myLang("Report");
2024-08-14 15:54:12 +00:00
?></h2>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
2024-08-14 15:54:12 +00:00
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
2024-08-14 15:54:12 +00:00
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
2024-08-14 15:54:12 +00:00
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
2024-08-14 15:54:12 +00:00
</div> -->
<div class="form-check">
2024-08-14 15:54:12 +00:00
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
2024-08-14 15:54:12 +00:00
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
2024-08-14 15:54:12 +00:00
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
2024-08-14 15:54:12 +00:00
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
2024-08-14 15:54:12 +00:00
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
2024-08-08 12:39:25 +00:00
</div>
2024-07-10 12:43:19 +00:00
</div>
</div>
<div class="btn-group">
2024-08-08 12:39:25 +00:00
<button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
2024-07-10 12:43:19 +00:00
</div>
2024-08-14 15:54:12 +00:00
2024-08-14 08:11:37 +00:00
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
2024-07-10 12:43:19 +00:00
</div>
</div>
</div>
</div>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
2024-08-14 08:11:37 +00:00
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
2024-08-26 06:44:38 +00:00
<div class="card card-primary card-outline">
<div class="card-body pl-2 pr-2">
<div class="row">
<?php
// echo $_POST['showClosing'];
$ReportOptions = array(
'showZeroBalances' => false,
'showOB' => false,
'showClosing' => true,
'showPeriod' => false,
);
// die;
?>
<div class="col-6 p-0">
<div class="table-responsive">
<table class="table ">
<thead>
<tr>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
2024-07-10 12:43:19 +00:00
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(3); ?>
2024-08-26 06:44:38 +00:00
<?php
2024-07-10 12:43:19 +00:00
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
$incomes_totalOpeningCr = 0;
$incomes_totalThisYearDr = 0;
$incomes_totalThisYearCr = 0;
$incomes_totalClosingDr = 0;
$incomes_totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
2024-08-26 06:44:38 +00:00
<tr>
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
2024-07-10 12:43:19 +00:00
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
2024-07-10 12:43:19 +00:00
</div>
2024-08-26 06:44:38 +00:00
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
2024-08-26 06:50:45 +00:00
<?php $PL = $incomes_totalClosingCr - $totalClosingDr; ?>
2024-08-26 06:44:38 +00:00
<tr>
<th class="p-1">Total Incomes</th>
<th class="cr closing-cr">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($incomes_totalClosingCr); ?>
<?php else : ?>
<?php echo myCurrency($incomes_totalClosingCr + abs($PL)); ?>
<?php endif; ?>
</th>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="col-6 p-0">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
2024-07-10 12:43:19 +00:00
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(4); ?>
2024-08-26 06:44:38 +00:00
<?php
2024-07-10 12:43:19 +00:00
// Initialize variables for column totals
$totalOpeningDr = 0;
$totalOpeningCr = 0;
$totalThisYearDr = 0;
$totalThisYearCr = 0;
$totalClosingDr = 0;
$totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
2024-08-26 06:44:38 +00:00
<tr>
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<i> <?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
2024-07-10 12:43:19 +00:00
</i>
</div>
2024-08-26 06:44:38 +00:00
</td>
</tr>
<?php
2024-07-10 12:43:19 +00:00
// Update column totals
$totalOpeningDr += ($group->posting_side == "DR") ? $group->opening_balance : 0;
$totalOpeningCr += ($group->posting_side == "CR") ? $group->opening_balance : 0;
$totalThisYearDr += ($group->posting_side == "DR") ? $group->regular_balance : 0;
$totalThisYearCr += ($group->posting_side == "CR") ? $group->regular_balance : 0;
$totalClosingDr += ($group->posting_side == "DR") ? $group->closing_balance : 0;
$totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
2024-08-26 06:44:38 +00:00
<?php $PL = $incomes_totalClosingCr - $totalClosingDr; ?>
2024-07-10 12:43:19 +00:00
<?php if ($incomes_totalClosingCr > $totalClosingDr) : ?>
<tr>
2024-08-26 06:44:38 +00:00
<th></th>
<th></th>
<th class="pl-1">Total Profit</th>
<th class="cr closing-cr text-right"><?php echo myCurrency($PL); ?></th>
2024-07-10 12:43:19 +00:00
</tr>
2024-08-26 06:44:38 +00:00
2024-07-10 12:43:19 +00:00
<?php endif; ?>
2024-08-26 06:44:38 +00:00
</tbody>
<tfoot>
<th class="pl-1">Total Expenses</th>
2024-07-10 12:43:19 +00:00
<th class="dr closing-dr">
<?php if ($PL > 0) : ?>
2024-08-26 06:44:38 +00:00
<?php echo myCurrency($totalClosingDr + abs($PL)); ?>
2024-07-10 12:43:19 +00:00
<?php else : ?>
<?php echo myCurrency($totalClosingDr); ?>
2024-08-26 06:44:38 +00:00
2024-07-10 12:43:19 +00:00
<?php endif; ?>
</th>
2024-08-26 06:44:38 +00:00
</tfoot>
</table>
</div>
</div>
</div>
2024-07-10 12:43:19 +00:00
</div>
</div>
2024-08-26 06:44:38 +00:00
2024-07-10 12:43:19 +00:00
</div>
</div>
</div>
</div>
</div>
<?php
function footerfunctions()
{
?>
2024-08-14 15:54:12 +00:00
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
2024-07-10 12:43:19 +00:00
<script>
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
var exportButton = document.getElementById("exportButton");
exportButton.addEventListener("click", function() {
exportTableToCSV("table.csv");
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
2024-07-10 12:43:19 +00:00
<?php
}
?>