2024-07-10 12:43:19 +00:00
< div class = " content-wrapper " >
< div class = " content " >
< div class = " container-fluid " >
< div class = " row " >
< div class = " col " >
< div class = " card card-primary card-outline " >
2024-08-09 03:54:49 +00:00
< div class = " card-header disabled color-palette " >
< h3 class = " card-title mt-1 " >< ? php echo $pageTitle ; ?> </h3>
2024-08-08 12:39:25 +00:00
< div class = " card-tools " >
2024-08-09 03:54:49 +00:00
< 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 " >
2024-08-09 03:54:49 +00:00
</ 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 " >
2024-08-09 03:54:49 +00:00
</ 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 >
</ div > -->
2024-08-09 03:54:49 +00:00
< div class = " form-check " >
2024-08-14 15:54:12 +00:00
<!-- < input type = " hidden " name = " showOB " value = " not " > -->
2024-08-09 03:54:49 +00:00
< 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 >
2024-08-09 03:54:49 +00:00
</ 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 >
2024-08-09 03:54:49 +00:00
</ 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 >
2024-08-09 03:54:49 +00:00
</ div >
2024-08-08 12:39:25 +00:00
</ div >
2024-08-09 03:54:49 +00:00
< 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 >
</ div >
</ div >
2024-08-09 03:54:49 +00:00
< div class = " btn-group " >
2024-09-30 10:24:29 +00:00
< button type = " submit " id = " downloadCsv " class = " btn btn-warning btn-sm " >
Export csv
2024-08-09 03:54:49 +00:00
</ button >
2024-09-30 10:24:29 +00:00
<!-- < button id = " exportButton " > Export to Excel </ button > -->
<!-- < button class = " btn btn-warning btn-sm " id = " downloadBtn " > Download CSV </ button > -->
<!-- < button type = " submit " class = " btn btn-warning btn-sm " data - toggle = " dropdown " data - offset = " -52 " >
Export
</ button > -->
2024-08-09 03:54:49 +00:00
<!-- < div class = " dropdown-menu " role = " menu " >
2024-08-08 12:39:25 +00:00
< 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-08-09 03:54:49 +00:00
</ div >
2024-09-30 10:24:29 +00:00
< button class = " btn btn-secondary toggle-collapse btn-sm " id = " toggleShowAll " > Toggle Collapse </ button >
2024-08-09 03:54:49 +00:00
</ 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 >
2024-08-08 12:39:25 +00:00
</ div >
2024-07-10 12:43:19 +00:00
</ div >
< div class = " card-body " >
< div class = " row " >
< div class = " col " >
< div id = " dataTable_wrapper " >
< ? php //$this->myaccounts->getAllAccountsTable(3);
?>
< ? php
$accategory_id = 3 ;
$CI = & get_instance ();
2024-08-08 12:39:25 +00:00
2024-07-10 12:43:19 +00:00
// $CI->db->where("status", 1)->where("(accategory_id = 2 OR accategory_id = 3)");
2024-09-29 11:14:27 +00:00
$CI -> db -> where ( " status " , 1 ) -> where ( " accategory_id = 3 " ) -> where ( " created_on >= ' $fiscalStart ' " ) -> where ( " created_on >= ' $fiscalEnd ' " );
2024-07-10 12:43:19 +00:00
$CI -> db -> order_by ( " account_name ASC " );
$Accounts = $CI -> db -> get ( " tbl_accounts " ) -> result ();
2024-08-08 12:39:25 +00:00
2024-07-10 12:43:19 +00:00
foreach ( $Accounts as $Account ) {
$Account -> Group = $CI -> db -> query ( " select * from tbl_acgroups where acgroup_id=(select acgroup_id from tbl_accategories where accategory_id = $Account->accategory_id ) " ) -> row ();
$Account -> Category = $CI -> db -> query ( " select * from tbl_accategories where accategory_id = $Account->accategory_id " ) -> row ();
}
?>
< div class = " row mb-3 " >
<!-- < div id = " dataTable_commands " class = " col text-right " ></ div > -->
</ div >
< ? php
$html = " " ;
2024-09-30 10:24:29 +00:00
$html .= " <table id='myTable' class='table table-bordered table-striped longdataTable'> " ;
2024-07-10 12:43:19 +00:00
$html .= " <thead> " ;
2024-08-12 10:36:46 +00:00
$html .= " <tr><th class='text-center' width='25'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Balance</th><th class='text-center col-1'>Action</th></tr> " ;
2024-07-10 12:43:19 +00:00
$html .= " </thead><tbody> " ;
$sn = 0 ;
$BalanceTotal = 0 ;
foreach ( $Accounts as $Account ) : $sn ++ ;
$balance = getBalance ( $Account -> account_id );
$BalanceTotal += $balance ;
// pre($Account);
2024-08-12 10:36:46 +00:00
$html .= " <tr><td class='col-1 text-center'> " . $sn . " </td><td><a href='#' onClick='showLedger( " . $Account -> account_id . " )'> " . $Account -> account_name . " </a></td><td class='col-2'> " . $Account -> Category -> accategory_name . " </td><td class='col-1'> " . (( $balance >= 0 ) ? myCurrency ( $balance ) : " " ) . " </td><td class='col-1'> " . (( $balance < 0 ) ? myCurrency ( abs ( $balance )) : " " ) . " </td><td class='col-1'> " . ( myCurrency ( $balance )) . " </td><td class=' text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger( " . $Account -> account_id . " )'><i class='fa fa-eye'></i></a></td></tr> " ;
2024-07-10 12:43:19 +00:00
endforeach ;
$html .= " </tbody><tfoot> " ;
2024-08-14 15:54:12 +00:00
$html .= " <tr><th colspan=3 class='text-right'>Total</th><th class='text-right'> " . (( $BalanceTotal > 0 ) ? myCurrency ( abs ( $BalanceTotal )) : " " ) . " </th><th class='text-right'> " . (( $BalanceTotal < 0 ) ? myCurrency ( abs ( $BalanceTotal )) : " " ) . " </th><th class='text-right'> " . myCurrency ( $BalanceTotal ) . " </th><th></th></tr> " ;
2024-07-10 12:43:19 +00:00
$html .= " </tfoot></table> \n " ;
$html .= " <div class= \" modal fade \" id= \" ledgerdetails_box \" tabindex= \" -1 \" role= \" dialog \" aria-labelledby= \" ledgerdetails_box \" aria-hidden= \" true \" >
2024-08-09 03:54:49 +00:00
< div class = \ " modal-dialog modal-xl \" role= \" document \" >
< div class = \ " modal-content \" >
< div class = \ " modal-header \" >
< h5 class = \ " modal-title \" id= \" exampleModalLabel \" >Ledger Details</h5>
< button type = \ " button \" class= \" close \" data-dismiss= \" modal \" aria-label= \" Close \" >
< span aria - hidden = \ " true \" >×</span>
</ button >
</ div >
< div class = \ " modal-body \" id= \" details_container \" >
Ledger Details Goes Here
</ div >
<!--< div class = \ " modal-footer \" >
< button type = \ " button \" class= \" btn btn-secondary \" data-dismiss= \" modal \" >Close</button>
< button type = \ " button \" class= \" btn btn-success \" data-dismiss= \" modal \" >Print</button>
</ div >-->
</ div >
</ div >
</ div > " ;
2024-07-10 12:43:19 +00:00
$html .= '<script>function showLedger(id) {$.ajax({url: \'' ;
$html .= site_url ( " accounts/reports/ajax/getledgersummary/ " );
$html .= '\' + id,success: function(data) {$(\'#ledgerdetails_box #details_container\').html(data);$(\'#ledgerdetails_box\').modal(\'show\');}});}</script>' ;
echo $html ;
?>
</ div >
</ div >
</ div >
</ div >
</ div >
</ 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-09-30 10:24:29 +00:00
< script >
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
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 " );
2024-08-14 15:54:12 +00:00
}
2024-09-30 10:24:29 +00:00
}
});
2024-08-14 15:54:12 +00:00
2024-09-30 10:24:29 +00:00
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
2024-08-14 15:54:12 +00:00
}
2024-09-30 10:24:29 +00:00
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 ( " , " ));
2024-08-14 15:54:12 +00:00
}
2024-09-30 10:24:29 +00:00
// 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 >
<!-- 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 );
2024-08-14 15:54:12 +00:00
});
2024-09-30 10:24:29 +00:00
// 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 -->
2024-07-10 12:43:19 +00:00
< ? php
}
?>