603 lines
26 KiB
PHP
603 lines
26 KiB
PHP
<?
|
||
// Level 9 이하만 사용 가능
|
||
$func->checkLevelModal(9);
|
||
|
||
// 기능 제한 (Admin : 1, Staff : 5, Accounting : 6, Driver : 9 만 가능)
|
||
$permit = array("1", "3", "5", "6", "7", "9");
|
||
if (in_array($_SESSION['ss_LEVEL'], $permit)) {
|
||
$setTag = "ENABLED";
|
||
}
|
||
else {
|
||
$setTag = "DISABLED";
|
||
$msg = "Sorry, You don't have permission. Please contact Administrator.";
|
||
$func -> modalMsg ($msg, "/index_intranet.php");
|
||
exit();
|
||
}
|
||
|
||
|
||
|
||
$APPLYDATE = "20260316000000";
|
||
$applyDay = substr($APPLYDATE, 0, 8);
|
||
|
||
$fromRaw = isset($_REQUEST['fromDate']) ? preg_replace('/[^0-9]/', '', $_REQUEST['fromDate']) : '';
|
||
$toRaw = isset($_REQUEST['toDate']) ? preg_replace('/[^0-9]/', '', $_REQUEST['toDate']) : '';
|
||
|
||
if ($fromRaw === '' && isset($_REQUEST['fromYear'])) {
|
||
$fromRaw = preg_replace('/[^0-9]/','',$_REQUEST['fromYear'])
|
||
. sprintf("%02d",(int)preg_replace('/[^0-9]/','',$_REQUEST['fromMonth']))
|
||
. sprintf("%02d",(int)preg_replace('/[^0-9]/','',$_REQUEST['fromDay']));
|
||
}
|
||
if ($toRaw === '' && isset($_REQUEST['toYear'])) {
|
||
$toRaw = preg_replace('/[^0-9]/','',$_REQUEST['toYear'])
|
||
. sprintf("%02d",(int)preg_replace('/[^0-9]/','',$_REQUEST['toMonth']))
|
||
. sprintf("%02d",(int)preg_replace('/[^0-9]/','',$_REQUEST['toDay']));
|
||
}
|
||
|
||
if (strlen($fromRaw) !== 8) $fromRaw = date('Ym') . '01';
|
||
if (strlen($toRaw) !== 8) $toRaw = date('Ymd');
|
||
|
||
$periodStart = $fromRaw;
|
||
$periodEnd = $toRaw;
|
||
|
||
$fromDateVal = substr($fromRaw,0,4) . '-' . substr($fromRaw,4,2) . '-' . substr($fromRaw,6,2);
|
||
$toDateVal = substr($toRaw,0,4) . '-' . substr($toRaw,4,2) . '-' . substr($toRaw,6,2);
|
||
|
||
if ($periodStart > $periodEnd) {
|
||
$tmp = $periodStart; $periodStart = $periodEnd; $periodEnd = $tmp;
|
||
}
|
||
$periodLabel = $periodStart . " ~ " . $periodEnd;
|
||
|
||
$searchDriver = isset($_REQUEST['searchDriver']) ? $_REQUEST['searchDriver'] : 'ALL';
|
||
if ($searchDriver !== 'ALL') $searchDriver = preg_replace('/[^0-9]/', '', $searchDriver);
|
||
if ($searchDriver === '') $searchDriver = 'ALL';
|
||
|
||
$drivers = array();
|
||
$qry_dr = "SELECT dr_uid, dr_initial, dr_lastname, dr_firstname
|
||
FROM tbl_driver
|
||
WHERE dr_status = 'A' AND dr_type = 'UCO'
|
||
AND dr_initial <> 'I.N'
|
||
ORDER BY dr_initial ASC ";
|
||
$rt_dr = $jdb->nQuery($qry_dr, "driver list error");
|
||
while ($lt_dr = mysqli_fetch_array($rt_dr, MYSQLI_ASSOC)) {
|
||
$drivers[] = $lt_dr;
|
||
}
|
||
|
||
$selectStr = ($searchDriver == "ALL") ? "selected" : "";
|
||
$c_driveruidSTR = "<option value='ALL' $selectStr>ALL</option>";
|
||
foreach ($drivers as $d) {
|
||
$sel = ($d['dr_uid'] == $searchDriver) ? "selected" : "";
|
||
$c_driveruidSTR .= "<option value='" . $d['dr_uid'] . "' $sel>" . htmlspecialchars($d['dr_lastname'] . $d['dr_firstname'] . " (" . $d['dr_initial'] . ")") . "</option>";
|
||
}
|
||
$getDriverInitial = ($searchDriver == "ALL") ? "ALL" : "";
|
||
|
||
$drFilter_d = ($searchDriver == "ALL") ? "" : " AND d_druid = '" . (int)$searchDriver . "' ";
|
||
$drFilter_h = ($searchDriver == "ALL") ? "" : " AND h_druid = '" . (int)$searchDriver . "' ";
|
||
|
||
function calcDriverBalance($jdb, $APPLYDATE, $druid, $asOf)
|
||
{
|
||
static $cache = array();
|
||
|
||
$druid = (int)$druid;
|
||
$asOf = preg_replace('/[^0-9]/', '', $asOf);
|
||
$applyDay = substr($APPLYDATE, 0, 8);
|
||
|
||
if (!isset($cache[$druid])) {
|
||
$c = array(
|
||
'out' => array(),
|
||
'in' => array(),
|
||
'r' => array(),
|
||
'g' => array(),
|
||
'days_out' => array(),
|
||
);
|
||
|
||
$q1 = "SELECT SUBSTRING(d_visitdate,1,8) AS dd, SUM(d_payamount) AS amt
|
||
FROM tbl_daily
|
||
WHERE d_druid = '$druid'
|
||
AND d_visitdate >= '$APPLYDATE'
|
||
AND d_paystatus = 'P' AND d_status = 'F'
|
||
GROUP BY SUBSTRING(d_visitdate,1,8) ";
|
||
$r1 = $jdb->nQuery($q1, "calc out err");
|
||
while ($row = mysqli_fetch_array($r1, MYSQLI_ASSOC)) {
|
||
$c['out'][$row['dd']] = (float)$row['amt'];
|
||
}
|
||
|
||
$q2 = "SELECT h_date, h_balance_in, h_balance_r, h_balance_g
|
||
FROM tbl_memberhis
|
||
WHERE h_druid = '$druid' AND h_date >= '$applyDay'
|
||
ORDER BY h_uid ASC ";
|
||
$r2 = $jdb->nQuery($q2, "calc his err");
|
||
while ($row = mysqli_fetch_array($r2, MYSQLI_ASSOC)) {
|
||
$d = $row['h_date'];
|
||
|
||
$c['in'][$d] = (float)$row['h_balance_in'];
|
||
$c['r'][$d] = (float)$row['h_balance_r'];
|
||
$c['g'][$d] = (float)$row['h_balance_g'];
|
||
}
|
||
|
||
$cache[$druid] = $c;
|
||
}
|
||
|
||
$c = $cache[$druid];
|
||
|
||
$cashoutTODAY = isset($c['out'][$asOf]) ? $c['out'][$asOf] : 0;
|
||
$cashinTODAY = isset($c['in'][$asOf]) ? $c['in'][$asOf] : 0;
|
||
$cashrtTODAY = isset($c['r'][$asOf]) ? $c['r'][$asOf] : 0;
|
||
$gasTODAY = isset($c['g'][$asOf]) ? $c['g'][$asOf] : 0;
|
||
|
||
$cashoutSUM = 0;
|
||
foreach ($c['out'] as $d => $v) { if ($d < $asOf) $cashoutSUM += $v; }
|
||
$cashinSUM = 0;
|
||
foreach ($c['in'] as $d => $v) { if ($d < $asOf) $cashinSUM += $v; }
|
||
$cashrtSUM = 0;
|
||
foreach ($c['r'] as $d => $v) { if ($d < $asOf) $cashrtSUM += $v; }
|
||
|
||
$balance = $cashinSUM + $cashinTODAY - $cashrtTODAY - $cashoutTODAY - $cashrtSUM - $cashoutSUM;
|
||
$openingbalance = $cashinSUM - $cashrtSUM - $cashoutSUM;
|
||
|
||
if ($asOf < $applyDay) {
|
||
$balance = 0;
|
||
$openingbalance = 0;
|
||
}
|
||
|
||
return array(
|
||
'opening' => $openingbalance,
|
||
'cashin' => $cashinTODAY,
|
||
'cashout' => $cashoutTODAY,
|
||
'cashrt' => $cashrtTODAY,
|
||
'balance' => $balance,
|
||
'gas' => $gasTODAY,
|
||
);
|
||
}
|
||
|
||
if (!isset($page) || !$page) $page = isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 1;
|
||
if ($page < 1) $page = 1;
|
||
$list_count = 20;
|
||
if (!isset($page_count) || !$page_count) $page_count = isset($INIT_PAGEVIEWCNT) ? $INIT_PAGEVIEWCNT : 10;
|
||
$rowStart = ($page - 1) * $list_count;
|
||
|
||
$drFilter_u = ($searchDriver == "ALL") ? "" : " AND druid = '" . (int)$searchDriver . "' ";
|
||
|
||
$qry_union = "SELECT orderdate, druid FROM (
|
||
SELECT d_orderdate AS orderdate, d_druid AS druid
|
||
FROM tbl_daily
|
||
WHERE d_orderdate >= '$periodStart' AND d_orderdate <= '$periodEnd'
|
||
UNION
|
||
SELECT h_date AS orderdate, h_druid AS druid
|
||
FROM tbl_memberhis
|
||
WHERE h_date >= '$periodStart' AND h_date <= '$periodEnd'
|
||
) AS U
|
||
INNER JOIN tbl_driver ON (U.druid = dr_uid AND dr_type = 'UCO')
|
||
WHERE 1=1 AND dr_initial <> 'I.N' $drFilter_u
|
||
GROUP BY orderdate, druid ";
|
||
|
||
$qry_count = "SELECT COUNT(*) FROM ( $qry_union ) AS CNT ";
|
||
$total_count = (int)$jdb->rQuery($qry_count, "count error");
|
||
|
||
$qry_rows = "SELECT U2.orderdate AS d_orderdate, U2.druid AS d_druid,
|
||
dr_initial AS m_initial, dr_lastname AS m_lastname, dr_firstname AS m_firstname
|
||
FROM ( $qry_union ) AS U2
|
||
INNER JOIN tbl_driver ON (U2.druid = dr_uid AND dr_type = 'UCO')
|
||
ORDER BY U2.orderdate DESC, dr_initial ASC
|
||
LIMIT $rowStart, $list_count ";
|
||
$rt_rows = $jdb->nQuery($qry_rows, "rows error");
|
||
|
||
$pageRows = array();
|
||
while ($r = mysqli_fetch_array($rt_rows, MYSQLI_ASSOC)) {
|
||
$pageRows[] = $r;
|
||
}
|
||
|
||
$strList = "";
|
||
$list_number = $total_count - $rowStart;
|
||
foreach ($pageRows as $row) {
|
||
$asOf = $row['d_orderdate'];
|
||
$dateLabel = $func->convertFormat($asOf, 3);
|
||
$b = calcDriverBalance($jdb, $APPLYDATE, $row['d_druid'], $asOf);
|
||
|
||
$driverShow = htmlspecialchars($row['m_lastname'] . $row['m_firstname'] . " (" . $row['m_initial'] . ")");
|
||
|
||
$strList .= "
|
||
<tr>
|
||
<td>$list_number</td>
|
||
<td>$dateLabel</td>
|
||
<td>$driverShow</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['opening'], 2) . "</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['cashin'], 2) . "</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['cashout'], 2) . "</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['cashrt'], 2) . "</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['balance'], 2) . "</td>
|
||
<td style=\"text-align:right; padding-right:20px;\">" . number_format($b['gas'], 2) . "</td>
|
||
</tr>";
|
||
$list_number--;
|
||
}
|
||
|
||
if ($total_count == 0) {
|
||
$strList = "<tr><td colspan='9' align='center' height='30'><b>No Data</b></td></tr>";
|
||
}
|
||
|
||
$sumKey = $periodStart . '_' . $periodEnd . '_' . $searchDriver;
|
||
$needCalc = true;
|
||
if (isset($_SESSION['exp_sumkey']) && $_SESSION['exp_sumkey'] === $sumKey
|
||
&& isset($_SESSION['exp_sum'])) {
|
||
|
||
$s = $_SESSION['exp_sum'];
|
||
$sumIn = $s['in']; $sumRt = $s['rt']; $sumGas = $s['gas']; $sumOut = $s['out'];
|
||
$sumBal = $sumIn - $sumRt - $sumOut;
|
||
$sumEndBal = isset($s['endbal']) ? $s['endbal'] : 0;
|
||
$sumOpenBal = isset($s['openbal']) ? $s['openbal'] : 0;
|
||
$needCalc = false;
|
||
}
|
||
|
||
if ($needCalc) {
|
||
|
||
$qry_sum = "SELECT
|
||
SUM(h_balance_in) AS CASHINSUM,
|
||
SUM(h_balance_r) AS CASHRETURNSUM,
|
||
SUM(h_balance_g) AS GASSUM
|
||
FROM tbl_memberhis
|
||
WHERE h_date >= '$periodStart' AND h_date <= '$periodEnd'
|
||
$drFilter_h ";
|
||
$rt_sum = $jdb->fQuery($qry_sum, "sum error");
|
||
|
||
$sumIn = (float)$rt_sum['CASHINSUM'];
|
||
$sumRt = (float)$rt_sum['CASHRETURNSUM'];
|
||
$sumGas = (float)$rt_sum['GASSUM'];
|
||
|
||
$qry_cashout = "SELECT SUM(d_payamount) FROM tbl_daily
|
||
WHERE (d_visitdate >= '" . $periodStart . "000000'
|
||
AND d_visitdate <= '" . $periodEnd . "235959')
|
||
$drFilter_d
|
||
AND d_paystatus = 'P' AND d_status = 'F' ";
|
||
$sumOut = (float)$jdb->rQuery($qry_cashout, "cashout sum error");
|
||
|
||
$sumBal = $sumIn - $sumRt - $sumOut;
|
||
|
||
$sumEndBal = 0;
|
||
$sumOpenBal = 0;
|
||
$qry_enddr = "SELECT DISTINCT druid FROM (
|
||
SELECT d_druid AS druid FROM tbl_daily
|
||
WHERE d_orderdate >= '$periodStart' AND d_orderdate <= '$periodEnd'
|
||
UNION
|
||
SELECT h_druid AS druid FROM tbl_memberhis
|
||
WHERE h_date >= '$periodStart' AND h_date <= '$periodEnd'
|
||
) AS UD
|
||
INNER JOIN tbl_driver ON (UD.druid = dr_uid AND dr_type = 'UCO')
|
||
WHERE 1=1 AND dr_initial <> 'I.N' $drFilter_u ";
|
||
$rt_enddr = $jdb->nQuery($qry_enddr, "end-balance drivers error");
|
||
while ($ed = mysqli_fetch_array($rt_enddr, MYSQLI_ASSOC)) {
|
||
$eb = calcDriverBalance($jdb, $APPLYDATE, $ed['druid'], $periodEnd);
|
||
$sumEndBal += $eb['balance'];
|
||
|
||
// 기간초(periodStart) 시점 잔액 = 그날의 opening
|
||
$ob = calcDriverBalance($jdb, $APPLYDATE, $ed['druid'], $periodStart);
|
||
$sumOpenBal += $ob['opening'];
|
||
}
|
||
|
||
$_SESSION['exp_sumkey'] = $sumKey;
|
||
$_SESSION['exp_sum'] = array('in'=>$sumIn,'rt'=>$sumRt,'gas'=>$sumGas,'out'=>$sumOut,'endbal'=>$sumEndBal,'openbal'=>$sumOpenBal);
|
||
}
|
||
|
||
$getCASHINSUM = number_format($sumIn, 2);
|
||
$getCASHRETURNSUM = number_format($sumRt, 2);
|
||
$getGASSUM = number_format($sumGas, 2);
|
||
$getCASHOUTSUM = number_format($sumOut, 2);
|
||
$getBALANCESUM = number_format($sumBal, 2);
|
||
$getENDBALANCESUM = number_format($sumEndBal, 2);
|
||
$getOPENINGSUM = number_format($sumOpenBal, 2);
|
||
$getINOUTDIFF = number_format($sumIn - $sumOut, 2);
|
||
|
||
addLog("add", "EXPENSE LIST", "VIEW", $lguserid, "report_expense", $lgno);
|
||
?>
|
||
|
||
<main id="main" class="main">
|
||
|
||
<!-- ======= Breadcrumbs ======= -->
|
||
<div class="breadcrumbs">
|
||
<div class="container">
|
||
|
||
<div class="d-flex justify-content-between align-items-center">
|
||
<h2>EXPENSE</h2>
|
||
<ol>
|
||
<li><a href="index.html">HOME</a></li>
|
||
<li>EXPENSE</li>
|
||
</ol>
|
||
</div>
|
||
|
||
</div>
|
||
</div><!-- End Breadcrumbs -->
|
||
|
||
<section class="page">
|
||
|
||
|
||
<div class="expense-wrap" data-aos="fade-up">
|
||
|
||
|
||
|
||
<div class="wrap-border">
|
||
|
||
<style>
|
||
|
||
.qbtn{
|
||
display:inline-block;
|
||
padding:5px 10px;
|
||
margin:0;
|
||
border:1px solid #f5821f;
|
||
background:#fff;
|
||
color:#f5821f;
|
||
border-radius:4px;
|
||
font-size:14px;
|
||
cursor:pointer;
|
||
vertical-align:middle;
|
||
white-space:nowrap;
|
||
box-sizing:border-box;
|
||
}
|
||
.qbtn:hover{ background:#fde6d2; }
|
||
.qbtn.active{ background:#f5821f; color:#fff; }
|
||
|
||
.sumcard{ transition:background 0.15s, box-shadow 0.15s; cursor:default; }
|
||
.sumcard:hover{ background:#f3f7f4 !important; box-shadow:0 2px 10px rgba(16,24,40,0.10); }
|
||
.sumcard-strong:hover{ background:#e4efe7 !important; box-shadow:0 2px 10px rgba(46,83,64,0.16); }
|
||
.sumcard-gas:hover{ background:#fdecd9 !important; box-shadow:0 2px 10px rgba(245,130,31,0.20); }
|
||
</style>
|
||
|
||
<?php /* 검색 폼은 아래 요약 영역 오른쪽으로 이동됨 */ ?>
|
||
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', function(){
|
||
(function(){
|
||
var fromEl = document.getElementById('fromDate');
|
||
var toEl = document.getElementById('toDate');
|
||
|
||
var ref = document.getElementById('searchBtn');
|
||
var qbtns = document.querySelectorAll('.qbtn');
|
||
if (ref) {
|
||
var h = ref.offsetHeight;
|
||
if (h > 0) {
|
||
for (var x=0; x<qbtns.length; x++){ qbtns[x].style.height = h + 'px'; qbtns[x].style.boxSizing = 'border-box'; }
|
||
|
||
var drv = document.getElementById('searchDriver');
|
||
if (drv) { drv.style.height = h + 'px'; drv.style.boxSizing = 'border-box'; }
|
||
if (fromEl) { fromEl.style.height = h + 'px'; fromEl.style.boxSizing = 'border-box'; }
|
||
if (toEl) { toEl.style.height = h + 'px'; toEl.style.boxSizing = 'border-box'; }
|
||
}
|
||
}
|
||
function fmt(d){
|
||
var y=d.getFullYear(), m=('0'+(d.getMonth()+1)).slice(-2), dd=('0'+d.getDate()).slice(-2);
|
||
return y+'-'+m+'-'+dd;
|
||
}
|
||
var btns = document.querySelectorAll('.qbtn');
|
||
for (var i=0;i<btns.length;i++){
|
||
btns[i].addEventListener('click', function(){
|
||
var n=new Date(), s, e, r=this.getAttribute('data-range');
|
||
if(r==='today'){ s=new Date(n); e=new Date(n); }
|
||
else if(r==='yesterday'){ s=new Date(n); s.setDate(n.getDate()-1); e=new Date(s); }
|
||
else if(r==='thismonth'){ s=new Date(n.getFullYear(),n.getMonth(),1); e=new Date(n); }
|
||
else if(r==='lastmonth'){ s=new Date(n.getFullYear(),n.getMonth()-1,1); e=new Date(n.getFullYear(),n.getMonth(),0); }
|
||
else if(r==='twomonths'){ s=new Date(n.getFullYear(),n.getMonth()-2,1); e=new Date(n.getFullYear(),n.getMonth()-1,0); }
|
||
else if(r==='last7'){ s=new Date(n); s.setDate(n.getDate()-6); e=new Date(n); }
|
||
else if(r==='thisyear'){ s=new Date(n.getFullYear(),0,1); e=new Date(n); }
|
||
if(fromEl) fromEl.value=fmt(s);
|
||
if(toEl) toEl.value=fmt(e);
|
||
for(var k=0;k<btns.length;k++){ btns[k].classList.remove('active'); }
|
||
this.classList.add('active');
|
||
document.getElementById('form2').submit();
|
||
});
|
||
}
|
||
|
||
(function(){
|
||
if(!fromEl || !toEl) return;
|
||
var n=new Date();
|
||
function fmt2(d){ var y=d.getFullYear(),m=('0'+(d.getMonth()+1)).slice(-2),dd=('0'+d.getDate()).slice(-2); return y+'-'+m+'-'+dd; }
|
||
|
||
var y1=new Date(); y1.setDate(n.getDate()-1);
|
||
var l7=new Date(); l7.setDate(n.getDate()-6);
|
||
var ranges = {
|
||
today: [fmt2(n), fmt2(n)],
|
||
yesterday: [fmt2(y1), fmt2(y1)],
|
||
last7: [fmt2(l7), fmt2(n)],
|
||
thismonth: [fmt2(new Date(n.getFullYear(),n.getMonth(),1)), fmt2(n)],
|
||
lastmonth: [fmt2(new Date(n.getFullYear(),n.getMonth()-1,1)), fmt2(new Date(n.getFullYear(),n.getMonth(),0))],
|
||
twomonths: [fmt2(new Date(n.getFullYear(),n.getMonth()-2,1)), fmt2(new Date(n.getFullYear(),n.getMonth()-1,0))],
|
||
thisyear: [fmt2(new Date(n.getFullYear(),0,1)), fmt2(n)]
|
||
};
|
||
var cur = fromEl.value + '|' + toEl.value;
|
||
for(var key in ranges){
|
||
if(ranges[key][0] + '|' + ranges[key][1] === cur){
|
||
for(var k=0;k<btns.length;k++){
|
||
if(btns[k].getAttribute('data-range') === key){ btns[k].classList.add('active'); }
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
})();
|
||
})();
|
||
});
|
||
</script>
|
||
|
||
</div>
|
||
|
||
<div class="container section-oil-history-details" data-aos="fade-up" style="margin-top:-32px;">
|
||
|
||
<?php $diffNum = (float)str_replace(',', '', $getINOUTDIFF); $diffNeg = ($diffNum < 0); ?>
|
||
|
||
<?php
|
||
function sumCard($label, $value, $variant='') {
|
||
$strong = ($variant === 'strong');
|
||
$gas = ($variant === 'gas');
|
||
if ($gas) {
|
||
$border = '#fbd9b6'; $bg = '#fff7ef'; $valColor = '#f5821f';
|
||
$cls = 'sumcard sumcard-gas';
|
||
} elseif ($strong) {
|
||
$border = '#cfe0d4'; $bg = '#f7faf8'; $valColor = '#2e5340';
|
||
$cls = 'sumcard sumcard-strong';
|
||
} else {
|
||
$border = '#ebeeec'; $bg = '#fff'; $valColor = '#2f3a33';
|
||
$cls = 'sumcard';
|
||
}
|
||
$labelColor = $gas ? '#f5821f' : '#9aa4a0';
|
||
$valWeight = '500';
|
||
echo '<div class="'.$cls.'" style="flex:0 0 auto; width:172px; height:132px; box-sizing:border-box; display:flex; flex-direction:column; align-items:center; background:'.$bg.'; border:1px solid '.$border.'; border-radius:14px; padding:24px 12px; text-align:center; box-shadow:0 1px 3px rgba(16,24,40,0.04);">';
|
||
echo '<div style="height:32px; display:flex; align-items:center; justify-content:center; font-size:10.5px; font-weight:500; letter-spacing:0.09em; text-transform:uppercase; line-height:1.4; color:'.$labelColor.';">'.$label.'</div>';
|
||
echo '<div style="flex:1 1 auto; display:flex; align-items:center; color:'.$valColor.'; font-size:21px; font-weight:'.$valWeight.'; letter-spacing:0.01em; font-variant-numeric:tabular-nums;">'.$value.'</div>';
|
||
echo '</div>';
|
||
}
|
||
function opSign($s) {
|
||
$color = '#b4bbb6';
|
||
if ($s === '+') $color = '#7fae8c';
|
||
if ($s === '−') $color = '#d4a5ad';
|
||
$size = ($s === ',') ? '40px' : '26px';
|
||
$w = ($s === ',') ? '44px' : '36px';
|
||
if ($s === ',') {
|
||
$inner = '<span style="display:inline-block; transform:translateY(-0.35em);">,</span>';
|
||
} else {
|
||
$inner = $s;
|
||
}
|
||
echo '<div style="flex:0 0 auto; width:'.$w.'; align-self:center; display:flex; align-items:center; justify-content:center; height:132px; font-size:'.$size.'; color:'.$color.'; font-weight:600;">'.$inner.'</div>';
|
||
}
|
||
?>
|
||
|
||
<!-- 검색 (원본 형태) -->
|
||
<form method="post" name="form2" id="form2" action="<?=$_SERVER["PHP_SELF"]?>">
|
||
<input type="hidden" name="view" value="report_expense">
|
||
|
||
<table class="table-search-customer-2" style="width:100%; margin-left:0;">
|
||
<tr>
|
||
<td class="td-title" style="width:1%; white-space:nowrap;">
|
||
<button type="button" class="qbtn" data-range="today">Today</button>
|
||
<button type="button" class="qbtn" data-range="yesterday">Yesterday</button>
|
||
<button type="button" class="qbtn" data-range="last7">Last 7 Days</button>
|
||
<button type="button" class="qbtn" data-range="thismonth">This Month</button>
|
||
<button type="button" class="qbtn" data-range="lastmonth">Last Month</button>
|
||
<button type="button" class="qbtn" data-range="twomonths">2 Months Ago</button>
|
||
<button type="button" class="qbtn" data-range="thisyear">This Year</button>
|
||
</td>
|
||
|
||
<td class="td-title" style="width:1%; white-space:nowrap; padding-left:14px;">
|
||
<select name="searchDriver" id="searchDriver" class="custom-select" style="width:200px; font-size:15px;">
|
||
<?=$c_driveruidSTR?>
|
||
</select>
|
||
</td>
|
||
|
||
<td class="td-title" style="width:1%; white-space:nowrap; padding-left:14px;">
|
||
<input type="date" name="fromDate" id="fromDate" class="custom-select"
|
||
value="<?=$fromDateVal?>" style="width:150px; font-size:15px;">
|
||
<span style="margin:0 4px;">~</span>
|
||
<input type="date" name="toDate" id="toDate" class="custom-select"
|
||
value="<?=$toDateVal?>" style="width:150px; font-size:15px;">
|
||
</td>
|
||
|
||
<td align="right">
|
||
<button type="submit" class="btn-add" id="searchBtn">SEARCH</button>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</form>
|
||
|
||
<div style="height:28px;"></div>
|
||
|
||
<!-- 요약 패널 -->
|
||
<div style="background:#fafbfa; border:1px solid #eef0ee; border-radius:16px; padding:22px 24px 26px;">
|
||
|
||
<!-- 패널 헤더: SUMMARY (좌) + PERIOD (우) -->
|
||
<div style="display:flex; align-items:baseline; justify-content:space-between; margin-bottom:20px; padding:0 2px;">
|
||
<span style="display:inline-flex; align-items:baseline; gap:10px;">
|
||
<span style="font-size:12px; font-weight:400; letter-spacing:0.12em; text-transform:uppercase; color:#6b7770;">Summary</span>
|
||
<span style="font-size:11px; font-weight:400; letter-spacing:0.03em; color:#adb4af;">/ From the driver's perspective</span>
|
||
</span>
|
||
<span style="font-size:12px; letter-spacing:0.04em; color:#9aa0a6;">PERIOD · <?=$periodLabel?></span>
|
||
</div>
|
||
|
||
<!-- 카드 섹션 전체를 가운데 정렬: 안쪽은 고정폭 기준으로 정렬 일치 -->
|
||
<div style="display:flex; justify-content:center;">
|
||
<div style="display:inline-block;">
|
||
|
||
<!-- 가로 카드 줄 (연산자 포함) -->
|
||
<div style="display:flex; gap:14px; align-items:center; justify-content:flex-start; flex-wrap:nowrap;">
|
||
<?php sumCard('OPENING BALANCE', $getOPENINGSUM); ?>
|
||
<?php opSign('+'); ?>
|
||
<?php sumCard('CASH IN', $getCASHINSUM); ?>
|
||
<?php opSign('−'); ?>
|
||
<?php sumCard('CASH OUT', $getCASHOUTSUM); ?>
|
||
<?php opSign('−'); ?>
|
||
<?php sumCard('CASH RETURN', $getCASHRETURNSUM); ?>
|
||
<?php opSign('='); ?>
|
||
<?php sumCard('CASH ON HAND', $getENDBALANCESUM, 'strong'); ?>
|
||
<div style="flex:0 0 auto; width:16px;"></div>
|
||
<?php opSign(','); ?>
|
||
<div style="flex:0 0 auto; width:4px;"></div>
|
||
<?php sumCard('GAS', $getGASSUM, 'gas'); ?>
|
||
</div>
|
||
|
||
<!-- CASH IN − CASH OUT: 왼쪽 기준 정렬이라 위 카드줄과 x좌표 일치 -->
|
||
<div style="display:flex; align-items:flex-start;">
|
||
<!-- OPENING(172) + gap(14) + '+'(36) + gap(14) = 236 → CASH IN 시작 -->
|
||
<div style="flex:0 0 auto; width:236px;"></div>
|
||
<div style="flex:0 0 auto; width:408px; position:relative;">
|
||
<svg width="408" height="46" viewBox="0 0 408 46" style="display:block;">
|
||
<path d="M86 2 L86 20 Q86 32 98 32 L306 32 Q318 32 318 20 L318 2"
|
||
fill="none" stroke="#c4c9c5" stroke-width="2" stroke-dasharray="0.1 7" stroke-linecap="round"/>
|
||
</svg>
|
||
<div style="position:absolute; left:50%; top:24px; transform:translateX(-50%); background:#fafbfa; padding:0 12px; white-space:nowrap;">
|
||
<span style="font-size:11px; letter-spacing:0.05em; color:#8a9095;">CASH IN − CASH OUT</span>
|
||
</div>
|
||
<div style="text-align:center; margin-top:2px;">
|
||
<span style="font-size:18px; font-weight:500; font-variant-numeric:tabular-nums; color:<?=($diffNeg?'#c0392b':'#2e5340')?>;"><?=$getINOUTDIFF?></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div style="height:8px;"></div>
|
||
|
||
</div>
|
||
<!-- /요약 패널 -->
|
||
|
||
</div>
|
||
|
||
|
||
<div class="wrap-overflow forecast-info">
|
||
<table class="tb-list">
|
||
<tr>
|
||
<th>No</th>
|
||
<th>Date</th>
|
||
<th>Driver</th>
|
||
<th style="text-align:right; padding-right:20px;">Opening Balance</th>
|
||
<th style="text-align:right; padding-right:20px;">Cash In</th>
|
||
<th style="text-align:right; padding-right:20px;">Cash Out</th>
|
||
<th style="text-align:right; padding-right:20px;">Cash Return</th>
|
||
<th style="text-align:right; padding-right:20px;">Balance</th>
|
||
<th style="text-align:right; padding-right:20px;">Gas</th>
|
||
</tr>
|
||
|
||
<?=$strList?>
|
||
|
||
</table>
|
||
</div>
|
||
|
||
<div class="container-inner">
|
||
<div class="pagination">
|
||
<?php
|
||
$page_string = "view=report_expense"
|
||
. "&searchDriver=" . $searchDriver
|
||
. "&fromDate=" . $fromDateVal
|
||
. "&toDate=" . $toDateVal
|
||
. "&s_in=" . $sumIn . "&s_rt=" . $sumRt
|
||
. "&s_gas=" . $sumGas . "&s_out=" . $sumOut;
|
||
|
||
if ($total_count > $list_count && class_exists('PAGE')) {
|
||
$paging = new PAGE('page', $total_count, $list_count, $page_count, $page, $page_string, '#c71930', '', '', '#c71930', '');
|
||
}
|
||
?>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
</div><!--container Ends-->
|
||
|
||
|
||
</section>
|
||
|
||
</main><!-- End #main -->
|