Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.138.105.128
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/home_expenses.php |
<?php
include("sys_connect.php");
include("sys_mainphp.php");
include("sys_session.php");
?>
<div style="margin-bottom: 5px;" class="head_blue">Expenses</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#this_month_status">Expenses Status</a></li>
<li><a data-toggle="tab" href="#prev_month_status">Prev. Month Status</a></li>
<li><a data-toggle="tab" href="#this_date_expenses">Today's Expenses</a></li>
<li><a data-toggle="tab" href="#this_month_expenses">This Month Expenses</a></li>
<li><a data-toggle="tab" href="#last_month_expenses">Prev. Month Expenses</a></li>
<li><a data-toggle="tab" href="#this_month_datewise_summary">This Month (Date wise)</a></li>
<li><a data-toggle="tab" href="#this_year_monthwise_summary">This Year (Month wise)</a></li>
<li><a data-toggle="tab" href="#total_yearwise_summary">Total (Year wise)</a></li>
</ul>
<div class="tab-content" id="home-content-note">
<!-- current status -->
<div id="this_month_status" class="tab-pane fade in active">
<?php
if ($type_id == "ADMIN") {
$myqry = " group by ex.femplcode having ftotlbaln<>0 ";
} else {
$myqry = " where ex.femplcode='$empl_id' group by ex.femplcode ";
}
$mysql = "select ex.fdeptcode as fdeptcode,fdeptname,ex.femplcode as femplcode,femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='payment' then fexpnamnt else 0 end) - sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masempl em on ex.femplcode=em.femplcode
left join masdept dp on ex.fdeptcode=dp.fdeptcode ".$myqry;
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$dept_recp = "0.00";
$dept_payt = "0.00";
$dept_baln = "0.00";
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-4'> Description</th>";
echo "<th class='text-right col-sm-2'> Total Payment</th>";
echo "<th class='text-right col-sm-2'> Total Receipt</th>";
echo "<th class='text-right col-sm-2'> Total Balance</th>";
echo "<th class='text-left col-sm-2'> Last Updated</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
$mysql1 = "select fexpndate from expenses where femplcode='$myrow[femplcode]' order by fexpndate desc limit 1";
$myres1 = mysqli_query($mycon, $mysql1);
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$last_updt = date('d/m/Y', strtotime($myrow1['fexpndate']));
}
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-right'> $myrow[ftotlpayt]</td>";
echo "<td class='text-right'> $myrow[ftotlrecp]</td>";
echo "<td class='text-right'> $myrow[ftotlbaln]</td>";
echo "<td class='text-left'> $last_updt</td>";
echo "</tr>";
$i++;
}
echo "</table>";
?>
</div>
<!-- Last Month Status -->
<div id="prev_month_status" class="tab-pane fade">
<?php
if ($type_id == "ADMIN") {
$myqry = " group by ex.femplcode having ftotlbaln<>0 ";
} else {
$myqry = " and ex.femplcode='$empl_id' group by ex.femplcode ";
}
$mysql = "select ex.fdeptcode as fdeptcode,fdeptname,ex.femplcode as femplcode,femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='payment' then fexpnamnt else 0 end) - sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masempl em on ex.femplcode=em.femplcode
left join masdept dp on ex.fdeptcode=dp.fdeptcode
where ex.fexpndate <= last_day(current_date- interval 1 month) ".$myqry ;
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$dept_recp = "0.00";
$dept_payt = "0.00";
$dept_baln = "0.00";
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-4'> Description</th>";
echo "<th class='text-right col-sm-2'> Total Payment</th>";
echo "<th class='text-right col-sm-2'> Total Receipt</th>";
echo "<th class='text-right col-sm-2'> Total Balance</th>";
echo "<th class='text-left col-sm-2'> Last Updated</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
$mysql1 = "select fexpndate from expenses where femplcode='$myrow[femplcode]'
and fdeptcode='$dept_id' and fexpndate <= last_day(current_date- interval 1 month) order by fexpndate desc limit 1";
$myres1 = mysqli_query($mycon, $mysql1);
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$last_updt = date('d/m/Y', strtotime($myrow1['fexpndate']));
}
echo "<tr>";
echo "<td class='text-right'> $i</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-right'> $myrow[ftotlpayt]</td>";
echo "<td class='text-right'> $myrow[ftotlrecp]</td>";
echo "<td class='text-right'> $myrow[ftotlbaln]</td>";
echo "<td class='text-left'> $last_updt</td>";
echo "</tr>";
$i++;
}
echo "</table>";
?>
</div>
<!-- Today's Expenses -->
<div id="this_date_expenses" class="tab-pane fade">
<?php
$mysql = "select date_format(ex.fexpndate,'%d/%m/%Y') as fexpndate,ex.fdeptcode,fdeptshrt,ex.fclntcode,fclntshrt,";
$mysql .= "ex.femplcode as femplcode, femplname, fheaddesc, facnttype, fexpnremk, ";
$mysql .= "(case when facnttype='RECEIPT' then fexpnamnt else 0 end) as frecpamnt, ";
$mysql .= "(case when facnttype='PAYMENT' then fexpnamnt else 0 end) as fpaytamnt ";
$mysql .= "from expenses ex ";
$mysql .= "left join masdept dp on ex.fdeptcode=dp.fdeptcode ";
$mysql .= "left join masclient cl on ex.fclntcode=cl.fclntcode ";
$mysql .= "left join masempl em on ex.femplcode=em.femplcode and ex.fdeptcode=em.fdeptcode ";
if ($type_id == 'ADMIN') {
$mysql .= "where ex.fexpndate=current_date ";
} else {
$mysql .= "where ex.fexpndate=current_date and ex.fdeptcode='$dept_id' and ex.femplcode='$empl_id' ";
}
$mysql .= "order by ex.fdeptcode,femplname,ex.fexpndate";
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
$totl_recp = 0;
$totl_payt = 0;
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Date</th>";
echo "<th class='text-left col-sm-3'>Name</th>";
echo "<th class='text-left col-sm-3'>Description</th>";
echo "<th class='text-right col-sm-1'>Payments</th>";
echo "<th class='text-right col-sm-1'>Receipts</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-2' >Remarks</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-left'> $myrow[fheaddesc]</td>";
echo "<td class='text-right'> $myrow[fpaytamnt]</td>";
echo "<td class='text-right'> $myrow[frecpamnt]</td>";
echo "<td class='text-left'> $myrow[fclntcode] [$myrow[fclntshrt]]</td>";
echo "<td class='text-left'> $myrow[fexpnremk]</td>";
echo "</tr>";
$totl_recp = $totl_recp + $myrow['frecpamnt'];
$totl_payt = $totl_payt + $myrow['fpaytamnt'];
$i++;
}
echo "<tr>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> TOTAL</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_payt, 2, '.', '') . "</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_recp, 2, '.', '') . "</td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "</tr>";
echo "</table>";
}
?>
</div>
<!-- This Month Expenses -->
<div id="this_month_expenses" class="tab-pane fade">
<?php
$mysql = "select date_format(ex.fexpndate,'%d/%m/%Y') as fexpndate, ex.fdeptcode,fdeptshrt,ex.fclntcode,fclntshrt,";
$mysql .= "ex.femplcode as femplcode, femplname, fheaddesc, facnttype, fexpnremk, ";
$mysql .= "(case when facnttype='RECEIPT' then fexpnamnt else 0 end) as frecpamnt, ";
$mysql .= "(case when facnttype='PAYMENT' then fexpnamnt else 0 end) as fpaytamnt, ";
$mysql .= "(case when facnttype='PAYMENT' then fexpnamnt else 0 end) - (case when facnttype='RECEIPT' then fexpnamnt else 0 end) as fbalnamnt ";
$mysql .= "from expenses ex ";
$mysql .= "left join masdept dp on ex.fdeptcode=dp.fdeptcode ";
$mysql .= "left join masclient cl on ex.fclntcode=cl.fclntcode ";
$mysql .= "left join masempl em on ex.femplcode=em.femplcode ";
if ($type_id == 'ADMIN') {
$mysql .= "where date_format(ex.fexpndate,'%m-%Y')=date_format(current_date,'%m-%Y') ";
} else {
$mysql .= "where date_format(ex.fexpndate,'%m-%Y')=date_format(current_date,'%m-%Y') and ex.femplcode='$empl_id' ";
}
$mysql .= "order by ex.fexpndate,ex.fdeptcode,femplcode,fheaddesc";
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Date</th>";
echo "<th class='text-left col-sm-3'>Name</th>";
echo "<th class='text-left col-sm-3'>Description</th>";
echo "<th class='text-right col-sm-1'>Payments</th>";
echo "<th class='text-right col-sm-1'>Receipts</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-2' >Remarks</th>";
echo "</tr>";
$totl_recp = 0;
$totl_payt = 0;
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-left'> $myrow[fheaddesc]</td>";
echo "<td class='text-right'> $myrow[fpaytamnt]</td>";
echo "<td class='text-right'> $myrow[frecpamnt]</td>";
echo "<td class='text-left'> $myrow[fclntcode] [$myrow[fclntshrt]]</td>";
echo "<td class='text-left'> $myrow[fexpnremk]</td>";
echo "</tr>";
$totl_recp = $totl_recp + $myrow['frecpamnt'];
$totl_payt = $totl_payt + $myrow['fpaytamnt'];
$i++;
}
echo "<tr>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> TOTAL</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_payt, 2, '.', '') . "</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_recp, 2, '.', '') . "</td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "</tr>";
echo "</table>";
}
?>
</div>
<!-- Last Month Expenses -->
<div id="last_month_expenses" class="tab-pane fade">
<?php
$mysql = "select date_format(ex.fexpndate,'%d/%m/%Y') as fexpndate,ex.fdeptcode,fdeptshrt,ex.fclntcode,fclntshrt,";
$mysql .= "ex.femplcode as femplcode, femplname, fheaddesc, facnttype, fexpnremk, ";
$mysql .= "(case when facnttype='RECEIPT' then fexpnamnt else 0 end) as frecpamnt, ";
$mysql .= "(case when facnttype='PAYMENT' then fexpnamnt else 0 end) as fpaytamnt, ";
$mysql .= "(case when facnttype='PAYMENT' then fexpnamnt else 0 end) - (case when facnttype='RECEIPT' then fexpnamnt else 0 end) as fbalnamnt ";
$mysql .= "from expenses ex ";
$mysql .= "left join masdept dp on ex.fdeptcode=dp.fdeptcode ";
$mysql .= "left join masclient cl on ex.fclntcode=cl.fclntcode ";
$mysql .= "left join masempl em on ex.femplcode=em.femplcode ";
if ($type_id == 'ADMIN') {
$mysql .= "where date_format(ex.fexpndate,'%m-%Y')=date_format(current_date - interval 1 month,'%m-%Y') ";
} else {
$mysql .= "where date_format(ex.fexpndate,'%m-%Y')=date_format(current_date - interval 1 month,'%m-%Y') and ex.femplcode='$empl_id' ";
}
$mysql .= "order by ex.fexpndate,ex.fdeptcode,femplcode,fheaddesc";
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Date</th>";
echo "<th class='text-left col-sm-3'>Name</th>";
echo "<th class='text-left col-sm-3'>Description</th>";
echo "<th class='text-right col-sm-1'>Payments</th>";
echo "<th class='text-right col-sm-1'>Receipts</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-2' >Remarks</th>";
echo "</tr>";
$totl_recp = 0;
$totl_payt = 0;
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-left'> $myrow[fheaddesc]</td>";
echo "<td class='text-right'> $myrow[fpaytamnt]</td>";
echo "<td class='text-right'> $myrow[frecpamnt]</td>";
echo "<td class='text-left'> $myrow[fclntcode] [$myrow[fclntshrt]]</td>";
echo "<td class='text-left'> $myrow[fexpnremk]</td>";
echo "</tr>";
$totl_recp = $totl_recp + $myrow['frecpamnt'];
$totl_payt = $totl_payt + $myrow['fpaytamnt'];
$i++;
}
echo "<tr>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> TOTAL</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_payt, 2, '.', '') . "</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_recp, 2, '.', '') . "</td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "</tr>";
echo "</table>";
}
?>
</div>
<!-- this month daywise -->
<div id="this_month_datewise_summary" class="tab-pane fade">
<?php
if ($type_id == 'ADMIN') {
$myqry = " ";
} else {
$myqry = " and ex.fdeptcode='$dept_id' and ex.femplcode='$empl_id' ";
}
$mysql = "select date_format(ex.fexpndate,'%d-%b-%Y') as fexpndate, ex.fdeptcode as fdeptcode ,fdeptshrt, ex.femplcode as femplcode, femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='PAYMENT' then fexpnamnt else 0 end) - sum(case when facnttype='RECEIPT' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masdept dp on ex.fdeptcode=dp.fdeptcode
left join masempl em on ex.femplcode=em.femplcode and ex.fdeptcode=em.fdeptcode
where date_format(ex.fexpndate,'%m-%Y')=date_format(current_date,'%m-%Y') ".$myqry."
group by ex.fexpndate,ex.fdeptcode,femplcode";
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Date</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-4'>Name</th>";
echo "<th class='text-right col-sm-2'>Payment</th>";
echo "<th class='text-right col-sm-2'>Receipt</th>";
echo "<th class='text-right col-sm-2'>Balance</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> $myrow[fdeptcode] [$myrow[fdeptshrt]]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-right'> $myrow[ftotlpayt]</td>";
echo "<td class='text-right'> $myrow[ftotlrecp]</td>";
echo "<td class='text-right'> $myrow[ftotlbaln]</td>";
echo "</tr>";
$totl_recp = $totl_recp + $myrow['ftotlrecp'];
$totl_payt = $totl_payt + $myrow['ftotlpayt'];
$i++;
}
echo "<tr>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> </td>";
echo "<td class='text-left bg-info'> TOTAL</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_payt, 2, '.', '') . "</td>";
echo "<td class='text-right bg-info'> " . number_format((float)$totl_recp, 2, '.', '') . "</td>";
echo "<td class='text-left bg-info'> </td>";
echo "</tr>";
echo "</table>";
echo "</table>";
}
?>
</div>
<!-- This Year (Monthwise) -->
<div id="this_year_monthwise_summary" class="tab-pane fade">
<?php
if ($type_id == 'ADMIN') {
$mysql = "select date_format(ex.fexpndate,'%Y-%b') as fexpndate, ex.fdeptcode as fdeptcode ,fdeptshrt, ex.femplcode as femplcode, femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) - sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masdept dp on ex.fdeptcode=dp.fdeptcode
left join masempl em on ex.femplcode=em.femplcode and ex.fdeptcode=em.fdeptcode
where date_format(ex.fexpndate,'%Y')=date_format(current_date,'%Y')
group by date_format(ex.fexpndate,'%m-%Y'),ex.fdeptcode,femplcode";
} else {
$mysql = "select date_format(ex.fexpndate,'%Y-%b') as fexpndate, ex.fdeptcode as fdeptcode ,fdeptshrt, ex.femplcode as femplcode, femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) - sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masdept dp on ex.fdeptcode=dp.fdeptcode
left join masempl em on ex.femplcode=em.femplcode and ex.fdeptcode=em.fdeptcode
where date_format(ex.fexpndate,'%Y')=date_format(current_date,'%Y') and ex.fdeptcode='$dept_id' and ex.femplcode='$empl_id'
group by date_format(ex.fexpndate,'%m-%Y'),ex.fdeptcode,femplcode";
}
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Month</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-4'>Name</th>";
echo "<th class='text-right col-sm-2'>Payment</th>";
echo "<th class='text-right col-sm-2'>Receipt</th>";
echo "<th class='text-right col-sm-2'>Balance</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> $myrow[fdeptcode] [$myrow[fdeptshrt]]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-right'> $myrow[ftotlpayt]</td>";
echo "<td class='text-right'> $myrow[ftotlrecp]</td>";
echo "<td class='text-right'> $myrow[ftotlbaln]</td>";
echo "</tr>";
$i++;
}
echo "</table>";
}
?>
</div>
<!-- Over All (Yearwise) -->
<div id="total_yearwise_summary" class="tab-pane fade">
<?php
if ($type_id == 'ADMIN') {
$mysql = "select date_format(ex.fexpndate,'%Y') as fexpndate, ex.fdeptcode as fdeptcode ,fdeptshrt, ex.femplcode as femplcode, femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) - sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masdept dp on ex.fdeptcode=dp.fdeptcode
left join masempl em on ex.femplcode=em.femplcode
group by date_format(ex.fexpndate,'%Y'),ex.fdeptcode,femplcode";
} else {
$mysql = "select date_format(ex.fexpndate,'%Y') as fexpndate, ex.fdeptcode as fdeptcode ,fdeptshrt, ex.femplcode as femplcode, femplname,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) as ftotlrecp,
sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlpayt,
sum(case when facnttype='receipt' then fexpnamnt else 0 end) - sum(case when facnttype='payment' then fexpnamnt else 0 end) as ftotlbaln
from expenses ex
left join masdept dp on ex.fdeptcode=dp.fdeptcode
left join masempl em on ex.femplcode=em.femplcode
where ex.fdeptcode='$dept_id' and ex.femplcode='$empl_id'
group by date_format(ex.fexpndate,'%Y'),ex.fdeptcode,femplcode";
}
$myres = mysqli_query($mycon, $mysql) or die(mysqli_error($mycon));
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
echo "<div class='alert alert-info'>No expense details found!</div>";
} else {
echo "<table class='table table-striped table-condensed table-hover'>";
echo "<tr>";
echo "<th class='text-right'>#</th>";
echo "<th class='text-left col-sm-1'>Year</th>";
echo "<th class='text-left col-sm-1'>Client</th>";
echo "<th class='text-left col-sm-4'>Name</th>";
echo "<th class='text-right col-sm-2'>Payment</th>";
echo "<th class='text-right col-sm-2'>Receipt</th>";
echo "<th class='text-right col-sm-2'>Balance</th>";
echo "</tr>";
$i = 1;
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<tr>";
echo "<td class='text-right'> $i.</td>";
echo "<td class='text-left'> $myrow[fexpndate]</td>";
echo "<td class='text-left'> $myrow[fdeptcode] [$myrow[fdeptshrt]]</td>";
echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
echo "<td class='text-right'> $myrow[ftotlpayt]</td>";
echo "<td class='text-right'> $myrow[ftotlrecp]</td>";
echo "<td class='text-right'> $myrow[ftotlbaln]</td>";
echo "</tr>";
$i++;
}
echo "</table>";
}
?>
</div>
</div>
|