158 lines
11 KiB
PHP
158 lines
11 KiB
PHP
<div class="content-wrapper">
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card card-primary card-outline">
|
|
<div class="card-header">
|
|
<!-- <h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?></h5> -->
|
|
</div>
|
|
<form class="ml-4" method="post" action="<?php echo base_url('accounts/reports/pl'); ?>" 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>
|
|
<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>
|
|
<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>
|
|
<!-- <div class="form-check">
|
|
<input class="form-check-input" type="checkbox">
|
|
<label class="form-check-label">Select
|
|
All</label>
|
|
</div> -->
|
|
<div class="form-check">
|
|
<!-- <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"> -->
|
|
<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" : ""; ?>>
|
|
<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"; ?>>
|
|
<label class="form-check-label" for="showPeriod">Period</label>
|
|
</div>
|
|
</div>
|
|
<div class="dropdown-divider"></div>
|
|
<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>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="btn-group">
|
|
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
|
|
Export
|
|
</button> -->
|
|
<!-- <button type="submit" onclick="exportTableToCSV('accounts_data.csv')" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
|
|
Export
|
|
</button> -->
|
|
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
|
|
Export csv
|
|
</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> -->
|
|
</div>
|
|
|
|
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
|
|
</form>
|
|
<div class="card-body">
|
|
<?php $TableData = $this->db->query("select * from tbl_purchases where status=1")->result(); ?>
|
|
<table class="table table-bordered table-striped dataTable" id="myTable">
|
|
<thead>
|
|
<tr>
|
|
<th width="3%" class="text-center"><?php myLang('S.N'); ?></th>
|
|
<th width="10%" class="col-1"><?php myLang('Date'); ?></th>
|
|
<th class="table-col col-9"><?php myLang('Purchase Transaction'); ?></th>
|
|
<th width="8%" class="col-2"><?php myLang('Amount'); ?></th>
|
|
|
|
<td class="col-1 text-center"><b>Action</b></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php $a = 0;
|
|
$n = 0;
|
|
foreach ($PurchaseRecords as $TableRow) : $a++;
|
|
$id = $TableRow->purchase_id; ?>
|
|
<tr>
|
|
<td><?php echo ++$n; ?></td>
|
|
<td><?php echo $TableRow->purchase_date; ?></td>
|
|
<td><?php echo ($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name) ?? ""; ?></td>
|
|
<td><?php echo myCurrency($TableRow->TotalPurchase); ?></td>
|
|
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$id"); ?>
|
|
<?php showDeleteButton($id); ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<tbody>
|
|
</table>
|
|
<script>
|
|
function doDelete(id) {
|
|
if (confirm('Are you sure to delete?')) {
|
|
window.location = '<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/delete/"); ?>' + id;
|
|
}
|
|
}
|
|
</script>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- pdf document -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
|
|
|
|
<script>
|
|
document.getElementById('downloadCsv').addEventListener('click', function() {
|
|
const table = document.getElementById('myTable');
|
|
const rows = Array.from(table.rows);
|
|
const data = [];
|
|
|
|
rows.forEach((row) => {
|
|
const cells = Array.from(row.cells);
|
|
const rowData = [];
|
|
cells.forEach((cell) => {
|
|
// Handle colspan
|
|
const colspan = cell.colSpan || 1;
|
|
for (let i = 0; i < (colspan - 1); i++) {
|
|
rowData.push(''); // Fill empty cells for merged columns
|
|
}
|
|
for (let i = 0; i < 1; i++) {
|
|
rowData.push(cell.innerText.trim());
|
|
}
|
|
// Fill empty cells for colspan
|
|
});
|
|
data.push(rowData);
|
|
});
|
|
|
|
// Create a worksheet
|
|
const worksheet = XLSX.utils.aoa_to_sheet(data);
|
|
const workbook = XLSX.utils.book_new();
|
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
|
|
|
|
// Export to Excel
|
|
XLSX.writeFile(workbook, 'table.xlsx');
|
|
});
|
|
</script>
|
|
<!-- pdf document ends-->
|