-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrep_investment.php
103 lines (90 loc) · 3.65 KB
/
rep_investment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
// $flagNoAuth = true;
require ('common/auth.php');
require ('classes/budget.class.php');
$oBudget = new Budget($budget_scenario);
$denominator = isset($_GET['denominator'])?(double)$_GET['denominator']:1;
include ('includes/inc-frame_top.php');
echo '<h1>',$arrUsrData["pagTitle$strLocal"],': ',$oBudget->title,'</h1>';
if ($denominator!=1) {
echo '<h2>RUB x',$denominator,'</h2>';
}
echo '<p>',$oBudget->timestamp,'</p>';
$sql = "SELECT Profit, pccFlagProd, `Budget item`, `Group`, SUM(".Budget::getYTDSQL().")/$denominator as Total, SUM(estimate)/$denominator as Estimate
FROM vw_master
WHERE scenario='$budget_scenario' AND source IN (select `invGUID` FROM `tbl_investment`)
GROUP BY Profit, `Budget item`
ORDER BY `Group`,pccFlagProd,Profit,itmOrder";
$rs = $oSQL->q($sql);
while ($rw=$oSQL->f($rs)){
$keyProfit = Budget::getProfitAlias($rw);
$arrReport[$rw['Group']][$rw['Budget item']][$keyProfit] += $rw['Total'];
$arrTotal[$rw['Group']][$keyProfit] += $rw['Total'];
$arrGrandTotal[$keyProfit] += $rw['Total'];
// $arrEstimate[$rw['Group']][$rw['Budget item']] += $rw['Estimate'];
$arrProfit[$keyProfit] = $rw['pccFlagProd'];
}
$sql = "SELECT pccFLagProd, pccTitle as Profit, pc, SUM(value_start) as Total
FROM reg_depreciation
LEFT JOIN vw_profit ON pccID=pc
WHERE source IN (select `invGUID` FROM `tbl_investment`) AND scenario='$budget_scenario' AND posted=1
GROUP BY pc";
$rs = $oSQL->q($sql);
while ($rw=$oSQL->f($rs)){
$keyProfit = Budget::getProfitAlias($rw);
$arrInvestment[$keyProfit] += $rw['Total'];
}
// echo '<pre>';print_r($arrReport);echo '</pre>';
?>
<table class='budget' id='report'>
<thead>
<tr>
<th>Account</th>
<?php foreach($arrProfit as $pc=>$flag){
echo '<th><div>',$pc,'</div><div><small>',number_format($arrInvestment[$pc],0,'.',','),'</small></div></th>';
};?>
<th class='budget-ytd'><div>Total</div><?php echo '<div><small>',number_format(array_sum($arrInvestment),0,'.',','),'</small></div>';?></th>
</tr>
</thead>
<tbody>
<?php
foreach($arrReport as $group=>$arrItem){
foreach($arrItem as $item=>$values){
echo '<tr>';
echo '<td>',$item,'</td>';
foreach($arrProfit as $pc=>$flag){
$strClass = $values[$pc]<0?"budget-negative":"";
echo "<td class='budget-decimal $strClass'>",number_format($values[$pc],0,'.',','),'</td>';
}
$strClass = array_sum($values)<0?"budget-negative":"";
echo "<td class='budget-decimal budget-ytd $strClass'>",number_format(array_sum($values),0,'.',','),'</td>';
echo '</tr>';
}
echo '<tr class="budget-subtotal">';
echo '<td>',$group,'</td>';
foreach($arrProfit as $pc=>$flag){
$strClass = $arrTotal[$group][$pc]<0?"budget-negative":"";
echo "<td class='budget-decimal $strClass'>",number_format($arrTotal[$group][$pc],0,'.',','),'</td>';
}
$strClass = array_sum($arrTotal[$group])<0?"budget-negative":"";
echo "<td class='budget-decimal budget-ytd $strClass'>",number_format(array_sum($arrTotal[$group]),0,'.',','),'</td>';
echo '</tr>';
}
echo '<tr class="budget-total">';
echo '<td>Total result</td>';
foreach($arrProfit as $pc=>$flag){
$strClass = $arrGrandTotal[$pc]<0?"budget-negative":"";
echo "<td class='budget-decimal $strClass'>",number_format($arrGrandTotal[$pc],0,'.',','),'</td>';
}
$strClass = array_sum($arrGrandTotal)<0?"budget-negative":"";
echo "<td class='budget-decimal budget-ytd $strClass'>",number_format(array_sum($arrGrandTotal),0,'.',','),'</td>';
echo '</tr>';
?>
</tbody>
</table>
<ul class='link-footer'>
<li><a href='javascript:SelectContent("report");'>Copy table</a></li>
</ul>
<?php
include ('includes/inc-frame_bottom.php');
?>