Files
ExpenseCount/app/View/Expense/print_family_report.ctp
2026-06-25 13:03:45 +06:00

543 lines
26 KiB
PHP

<?php
$showPieChart = false;
if(isset($data['FamilyExpense']) && !empty($data['FamilyExpense'])){
$showPieChart = true;
}
?>
<script>
function printPage(){
window.print();
}
</script>
<style type="text/css">
.showHideSpan{
font-size: 14px;
}
input[type="checkbox"]{
width: 20px;height: 18px;
}
.displaynone{
display: none;
}
.floatRight{
float: left;
}
#generateCSVBtn{
padding:10px 50px;
margin-right: 40px;
cursor: pointer;
}
#generatePdfBtn{
padding:10px 50px;
margin-right: 20px;
cursor: pointer;
}
#emailBtn{
margin-right: 20px;
cursor: pointer;
}
#topExportTable{
margin-bottom: 10px !important;
}
form#expenseorincomelistForm {
display: inline-flex;
}
select#expenseorincomelist {
margin-top: 4px;
}
@media print{
.showHideSpan{
display: none;
}
}
</style>
<div class="wrapper" id="printWrapper">
<div class="print" style="overflow: hidden;">
<form action="<?php echo $this->webroot . 'Expense/printReport/' . $data['Expense']['unique_url']; ?>" class="form-inline hidden-print" id="expenseorincomelistForm" method="post">
<div class="form-group">
<!-- <label for="participantId"><?php echo __("LBL_SELECT_PARTICIPANT"); ?> </label> -->
<input type="hidden" name="unique_url" value="<?php echo $data['Expense']['unique_url']; ?>">
<select name="current_perticipants" class="form-control" id="expenseorincomelist" style="width: 50%;height: 35px;min-width: 100px;">
<option value="">All</option>
<option value="Incomes" <?php echo ($current_perticipants == 'Incomes')? 'selected="selected"':''?>>Incomes</option>
<option value="Expenses" <?php echo ($current_perticipants == 'Expenses')? 'selected="selected"':''?>>Expenses</option>
</select>
</div>
</form>
<!-- <button type="submit" class="btn btn-info floatRight hidden-print" id="generateCSVBtn"><b>--><?php //echo __("LBL_CSV"); ?><!--</b> <img src="--><?php //echo HTTP_SITE_URL; ?><!--/images/download.png" style="height: 18px;width: 18px;"/></button>-->
<div class="float-right">
<button type="submit" class="btn btn-info floatRight hidden-print" id="generatePdfBtn"><b><?php echo __("LBL_PDF"); ?></b> <img src="<?php echo HTTP_SITE_URL; ?>/images/download.png" style="height: 18px;width: 18px;"/></button>
<!-- <span><?php //echo date("d/m/Y - H:i"); ?></span> -->
<!-- EMIAL BUTTON BEGIN -->
<?php if ($issetParam) { ?>
<button type="button" class="btn btn-info floatRight hidden-print generate" id="emailBtn" data-toggle="modal" data-target="#myExpenseModal"><b>Send Email</b></button>
<?php } ?>
</div>
<div class="modal fade" id="myExpenseModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-header-inner">
<h5 class="modal-title" id="exampleModalLabel">Send Email</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>
<div class="modal-body my-expenses" style="min-height: auto;">
<?php //echo $this->Form->create(null, array('id' => 'sendEmailForm'));
?>
<form action="<?php echo $this->Html->url(array('controller' => 'Expense', 'action' => 'sendEmailPdf')); ?>" class="form-inline" method="post" id="sendEmailForm">
<input type="hidden" name="whole_content_email" id="wholeContentEmail">
<div class="form-group" style="width: 100%;margin-bottom: 5px;">
<?php if($isPaid){ ?>
<label for="email"><?php echo __("LBL_INVITE_EMAIL_ADDRESS"); ?>:</label>
<?php
echo $this->Form->input('email', array('label' => false, 'email' => __('LBL_PLEASE_PROVIDE_EMAIL'), 'length' => '200px', 'required' => 'true', 'style' => 'width:240px; height:30px;', 'id' => 'email'));
}else{
echo "This function is for paid user only!";
}
?>
</div>
<?php if($isPaid){
echo $this->Form->end('Send Email', array('class' => 'myExpenseSend','style'=>'margin-top:1rem;'));
}else{
?>
<div class="submit" style="margin-top: 3rem;"></div>
<?php
echo "</form>";
}
?>
<img id="loadImg1" style="display:none;float: right" src="<?php echo CDN_URL; ?>images/loading.gif" />
<button type="button" class="btn btn-secondary modal-footer-close" data-dismiss="modal" style="height: 35px; bottom:2rem;">Close</button>
<?php //} ?>
</div>
</div>
</div>
</div>
<!-- email button End-->
</div>
<div id="exportPrintTable">
<div class="wrapper2">
<div style="width: 100%; overflow: hidden;">
<div style="width: 40%;float: left; ">
<!-- <p><a href="<?php echo $this->webroot; ?>"><img src="<?php echo CDN_URL; ?><?php echo __('LBL_LOGO_PDF');?>" width="270" height="72" alt=""/></a> </p> -->
<div class="description">
<p><strong style="font-size: 20px;"><?php echo $data['Expense']["title"];?></strong><br/><?php if(!empty($data['Expense']["description"])){ ?><?php echo $data['Expense']["description"];?><br/>
<?php }
$create_date = strtotime($data['Expense']["create_date"]); ?>
<?php echo __("LBL_CREATED_ON"); ?> <?php echo date('d-M-Y', $create_date);?><br />
<?php echo __("LBL_BALANCE"); ?>: <b><?php echo ($total_family_income - $total_family_expense)." ".$data['Expense']["currency"];?></b></p>
</div>
</div>
<?php if ($showPieChart) { ?>
<div style="width: 60%;float: left; margin-bottom: 10px;">
<!-- <span class="showHideSpan" style=""> (<label for="isChartShow">--><?php //echo __("LBL_HIDE_SHOW"); ?><!-- <input type="checkbox" value="1" id="isChartShow" checked="checked"></label>)</span>-->
<div style="border: 1px solid #bbb; margin: 5px 0; " id="chartDiv" class="hidden-print">
<script src="<?php echo CDN_URL;?>js/highcharts/highcharts.js"></script>
<!-- <script src="https://code.highcharts.com/modules/exporting.js"></script> -->
<!-- <script src="https://code.highcharts.com/modules/export-data.js"></script> -->
<div id="containerLine" ></div>
<script type="text/javascript">
Highcharts.chart('containerLine', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'line'
},
title: {
text: '<?php echo __("LBL_INCOME_EXPENSE_BALANCE_COMPARISON"); ?>'
},
subtitle: {
text: ''
},
yAxis: {
title: {
text: 'Amount'
}
},
legend: {
backgroundColor: '',
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
floating: false,
symbolHeight:10,
symbolWidth:10,
squareSymbol:true
},
colors: ['#1FA809', '#7E0202', '#0E9FD5', '#910000', '#1aadce', '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a'],
credits: {
enabled:false
},
exporting: {
type: 'image/jpeg',
enabled:true
},
series: [
<?php if($current_perticipants != 'Expenses' ) : ?>
{
name: '<?php echo __("LBL_INCOMES"); ?>',
data: [<?php echo $total_income_str; ?>/*43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175*/]
},
<?php endif; ?>
<?php if($current_perticipants != 'Incomes' ) : ?>
{
name: '<?php echo __("LBL_EXPENSE"); ?>',
data: [<?php echo $total_expense_str; ?>/*24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434*/]
},
<?php endif; ?>
{
name: '<?php echo __("LBL_BALANCE"); ?>',
data: [<?php echo $total_balance_str; ?>/*11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387*/]
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
</div>
</div>
<?php } ?>
</div>
<!-- <div class="print">
<?php echo __("LBL_INCOMES"); ?> <span><?php echo __("LBL_PRINTED_ON"); ?> <?php echo date("d/m/Y - H:i");?></span>
</div> -->
<?php if($current_perticipants != 'Expenses' ) : ?>
<h5 id="summaryHeader" style="text-align: left;"><?php echo __("LBL_INCOMES"); ?>
<!--<span class="showHideSpan" style="width: 100%; "> (<?php /*echo __("LBL_HIDE_SHOW"); */?>:
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isWhatReasonShowIncome"><?php /*echo __("LBL_FOR_WHAT_REASONS"); */?>
<input type="checkbox" value="1" id="isWhatReasonShowIncome" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isCategoryShowIncome"><?php /*echo __("LBL_CATEGORY"); */?>
<input type="checkbox" value="1" id="isCategoryShowIncome" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isWhenShowIncome"><?php /*echo __("LBL_WHEN"); */?>
<input type="checkbox" value="1" id="isWhenShowIncome" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isHowMuchShowIncome"><?php /*echo __("LBL_HOW_MUCH"); */?>
<input type="checkbox" value="1" id="isHowMuchShowIncome" checked="checked"></label>
)
</span>--></h5>
<table class="printTable table" id="topExportTable">
<thead>
<tr>
<th><?php echo __("LBL_FOR_WHAT_REASONS"); ?>?</th>
<th><?php echo __("LBL_CATEGORY"); ?></th>
<th><?php echo __("LBL_WHEN"); ?></th>
<th><?php echo __("LBL_HOW_MUCH"); ?>?</th>
</tr>
</thead>
<tbody>
<?php
$finalIncomeList = array();
$finalIncomeHeadingList = array();
$finalIncomeHeadingList['nameHeading'] = __("LBL_FOR_WHAT_REASONS");
$finalIncomeHeadingList['categoryHeading'] = __("LBL_CATEGORY");
$finalIncomeHeadingList['dateHeading'] = __("LBL_WHEN");
$finalIncomeHeadingList['amountHeading'] = __("LBL_HOW_MUCH");
foreach($data['FamilyExpense'] as $key=>$value){
if($value['record_type'] == 2) {
$finalIncomeList[$key]['expenseName'] = $value['what'];
$finalIncomeList[$key]['expenseCategory'] = $value['category'];
$finalIncomeList[$key]['expenseDate'] = $value['expense_date_new'];
$finalIncomeList[$key]['amount'] = $value['amount'];
$finalIncomeList[$key]['currency'] = $data['Expense']["currency"];
?>
<tr>
<td><?php echo $value["what"];?></td>
<td><?php echo $value["category"];?></td>
<td><?php echo $value["expense_date_new"];?></td>
<td><?php echo $value["amount"];?><?php echo " ".$data['Expense']["currency"];?></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
<tr style="background: transparent;">
<td style="border:0px"> </td>
<td style="border:0px"> </td>
<td style="border:0px;text-align:right"><?php echo __("LBL_TOTAL"); ?>:</td>
<td style="border:0px"><b><?php echo $total_family_income." ".$data['Expense']["currency"];?></b></td>
</tr>
</tfoot>
</table>
<?php endif; ?>
<!-- <br/>
<div class="print">
<?php echo __("LBL_EXPENSE"); ?>
</div> -->
<?php if($current_perticipants != 'Incomes' ) : ?>
<h5 id="summaryHeader" style="text-align: left;"><?php echo __("LBL_EXPENSES"); ?>
<!--<span class="showHideSpan" style="width: 100%; "> (<?php /*echo __("LBL_HIDE_SHOW"); */?>:
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isWhatReasonShowExpense"><?php /*echo __("LBL_FOR_WHAT_REASONS"); */?>
<input type="checkbox" value="1" id="isWhatReasonShowExpense" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isCategoryShowExpense"><?php /*echo __("LBL_CATEGORY"); */?>
<input type="checkbox" value="1" id="isCategoryShowExpense" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isWhenShowExpense"><?php /*echo __("LBL_WHEN"); */?>
<input type="checkbox" value="1" id="isWhenShowExpense" checked="checked"></label>
&nbsp;&nbsp;&nbsp;&nbsp;
<label for="isHowMuchShowExpense"><?php /*echo __("LBL_HOW_MUCH"); */?>
<input type="checkbox" value="1" id="isHowMuchShowExpense" checked="checked"></label>
)
</span>--></h5>
<table class="printTable table" id="exportTable">
<thead>
<tr>
<th><?php echo __("LBL_FOR_WHAT_REASONS"); ?></th>
<th><?php echo __("LBL_CATEGORY"); ?></th>
<th><?php echo __("LBL_WHEN"); ?></th>
<th><?php echo __("LBL_HOW_MUCH"); ?>?</th>
</tr>
</thead>
<tbody>
<?php
$finalExpenseList = array();
$finalExpenseHeadingList = array();
$finalExpenseHeadingList['nameHeading'] = __("LBL_FOR_WHAT_REASONS");
$finalExpenseHeadingList['categoryHeading'] = __("LBL_CATEGORY");
$finalExpenseHeadingList['dateHeading'] = __("LBL_WHEN");
$finalExpenseHeadingList['amountHeading'] = __("LBL_HOW_MUCH");
foreach($data['FamilyExpense'] as $key=>$value){
if($value['record_type'] == 1) {
$finalExpenseList[$key]['expenseName'] = $value['what'];
$finalExpenseList[$key]['expenseCategory'] = $value['category'];
$finalExpenseList[$key]['expenseDate'] = $value['expense_date_new'];
$finalExpenseList[$key]['amount'] = $value['amount'];
$finalExpenseList[$key]['currency'] = $data['Expense']["currency"];
?>
<tr>
<td><?php echo $value["what"];?></td>
<td><?php echo $value["category"];?></td>
<td><?php echo $value["expense_date_new"];?></td>
<td><?php echo $value["amount"];?><?php echo " ".$data['Expense']["currency"];?></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
<tr style="background: #fff;">
<td style="border:0px"> </td>
<td style="border:0px"> </td>
<td style="border:0px;text-align:right"><?php echo __("LBL_TOTAL"); ?>:</td>
<td style="border:0px"><b><?php echo $total_family_expense." ".$data['Expense']["currency"];?></b></td>
</tr>
</tfoot>
</table>
<?php endif; ?>
<div style="width: 100%; overflow: hidden;margin-top: 50px;">
<div class="hidden-print" style="width: 30%;float:left;">
<a href="#" id="previewBtn" class="btn btn-info"><?php echo __('LBL_PREVIEW_BTN'); ?></a>
</div>
<div style="width: 40%;float: right; text-align: right;margin-right: 20px;">
<p><a href="<?php echo $this->webroot; ?>"><img src="<?php echo $this->webroot; ?><?php echo __('LBL_FAMILY_EXPENSE_LOGO'); ?>" width="270" height="72" alt=""/></a> </p>
</div>
</div>
<!-- <div class="footerText">
<?php echo __("LBL_CLICK"); ?> <a href="#" style="cursor:pointer" onclick="printPage()"> <?php echo __("LBL_HERE"); ?></a> <?php echo __("LBL_TO_PRINT_THE_PAGE"); ?>.</div> -->
<div class="footer-pdf-print-link hidden-print displaynone">
<a href="#" onclick="printPage()" class="btn btn-info"><?php echo __("LBL_PRINT"); ?></a>
<form action="<?php echo $this->Html->url(array('controller'=>'Expense','action'=>'generatePdf'));?>" class="form-inline" method="post" id="generatePdf">
<input type="hidden" name="whole_content" id="wholeContent">
<div class="form-group">
<button type="submit" class="btn btn-info" id="generatePdfBtn2"><?php echo __("LBL_DOWNLOAD"); ?></button>
</div>
</form>
<form action="<?php echo $this->Html->url(array('controller'=>'Expense','action'=>'generateFamilyCSV'));?>" class="form-inline" method="post" id="generateCSV" style="display: inline-flex;">
<input type="hidden" name="csv_income_content" value='<?php echo serialize($finalIncomeList); ?>'>
<input type="hidden" name="csv_income_heading" value='<?php echo serialize($finalIncomeHeadingList); ?>'>
<input type="hidden" name="csv_expense_content" value='<?php echo serialize($finalExpenseList); ?>'>
<input type="hidden" name="csv_expense_heading" value='<?php echo serialize($finalExpenseHeadingList); ?>'>
<div class="form-group">
<button type="submit" class="btn btn-info" id="generateCSVBtn2"><?php echo __("LBL_CSV"); ?></button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#topExportTable').DataTable({
"paging": false,
"searching": false,
"info": false
});
$('#exportTable').DataTable({
"paging": false,
"searching": false,
"info": false
});
$("#generateCSVBtn").on('click', function () {
$("form#generateCSV").submit();
});
$("#generatePdfBtn").on('click', function () {
$('.showHideSpan').hide();
$('input[type="checkbox"]').remove();
var Content = $('#exportPrintTable').html();
var ContentWrap = "<!doctype html><html><body>"+Content+"</body></html>";
var currentHtml = $("#wholeContent").val(ContentWrap);
// alert($("#wholeContent").val());
$("form#generatePdf").submit();
});
$("#emailBtn").on('click', function () {
$('.showHideSpan').hide();
$('input[type="checkbox"]').remove();
var Content = $('#exportPrintTable').html();
var ContentWrap = '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>'+Content+'</body></html>';
var currentHtml = $("#wholeContentEmail").val(ContentWrap);
// alert($("#wholeContent").val());
//$("form#sendEmail").submit();
});
$("#previewBtn").on('click', function () {
$('.showHideSpan').hide();
$('#expenseorincomelist').hide();
$('#chartDiv').hide();
// $('.hidden-print').hide();
// $('.hidden-print.generate').show();
$(this).hide();
});
$("#isWhatReasonShowIncome").on('click', function () {
if(this.checked) {
$('table#topExportTable th:nth-child(1)').show();
$('table#topExportTable td:nth-child(1)').show();
} else {
$('table#topExportTable th:nth-child(1)').hide();
$('table#topExportTable td:nth-child(1)').hide();
}
});
$("#isCategoryShowIncome").on('click', function () {
if(this.checked) {
$('table#topExportTable th:nth-child(2)').show();
$('table#topExportTable td:nth-child(2)').show();
} else {
$('table#topExportTable th:nth-child(2)').hide();
$('table#topExportTable td:nth-child(2)').hide();
}
});
$("#isWhenShowIncome").on('click', function () {
if(this.checked) {
$('table#topExportTable th:nth-child(3)').show();
$('table#topExportTable td:nth-child(3)').show();
} else {
$('table#topExportTable th:nth-child(3)').hide();
$('table#topExportTable td:nth-child(3)').hide();
}
});
$("#isHowMuchShowIncome").on('click', function () {
if(this.checked) {
$('table#topExportTable th:nth-child(4)').show();
$('table#topExportTable td:nth-child(4)').show();
} else {
$('table#topExportTable th:nth-child(4)').hide();
$('table#topExportTable td:nth-child(4)').hide();
}
});
$("#isWhatReasonShowExpense").on('click', function () {
if(this.checked) {
$('table#exportTable th:nth-child(1)').show();
$('table#exportTable td:nth-child(1)').show();
} else {
$('table#exportTable th:nth-child(1)').hide();
$('table#exportTable td:nth-child(1)').hide();
}
});
$("#isCategoryShowExpense").on('click', function () {
if(this.checked) {
$('table#exportTable th:nth-child(2)').show();
$('table#exportTable td:nth-child(2)').show();
} else {
$('table#exportTable th:nth-child(2)').hide();
$('table#exportTable td:nth-child(2)').hide();
}
});
$("#isWhenShowExpense").on('click', function () {
if(this.checked) {
$('table#exportTable th:nth-child(3)').show();
$('table#exportTable td:nth-child(3)').show();
} else {
$('table#exportTable th:nth-child(3)').hide();
$('table#exportTable td:nth-child(3)').hide();
}
});
$("#isHowMuchShowExpense").on('click', function () {
if(this.checked) {
$('table#exportTable th:nth-child(4)').show();
$('table#exportTable td:nth-child(4)').show();
} else {
$('table#exportTable th:nth-child(4)').hide();
$('table#exportTable td:nth-child(4)').hide();
}
});
$("#isChartShow").on('click', function () {
if(this.checked) {
$('#chartDiv').show();
} else {
$('#chartDiv').hide();
}
});
$("#expenseorincomelist").on('change', function () {
// var Content = $('#exportPrintTable').html();
// var ContentWrap = "<!doctype html><html><body>"+Content+"</body></html>";
// var currentHtml = $("#wholeContent").val(ContentWrap);
// alert($("#wholeContent").val());
$("form#expenseorincomelistForm").submit();
// dashBoard.printExpense();
});
});
</script>