-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation_costs_form.php
179 lines (156 loc) · 4.69 KB
/
location_costs_form.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
//$flagNoAuth = true;
require ('common/auth.php');
include ('classes/location_costs.class.php');
$arrJS[] = 'js/input_form.js';
$arrJS[]="https://code.highcharts.com/highcharts.js";
$arrJS[]="https://code.highcharts.com/highcharts-more.js";
$arrJS[]="https://code.highcharts.com/modules/exporting.js";
$lcoID=$_GET['lcoID']?$_GET['lcoID']:$_POST['lcoID'];
$oBudget = new Budget($budget_scenario);
$oDocument = new Location_costs ($lcoID);
$oDocument->defineEF();
$oDocument->defineGrid();
if ($_POST['DataAction']){
// echo '<pre>'; print_r($_POST); echo '</pre>';
if ($oDocument->save($_POST['DataAction'])){
$oDocument->refresh($oDocument->ID);
$arrActions = Array();
include('includes/inc_document_menu.php');
$oDocument->arrActions = $arrActions;
$oDocument->status = 'success';
header("Content-type: application/json");
$oDocument->getJSON();
}
die();
}
if ($_GET['tab']){
switch($_GET['tab']){
case 'kpi':
require_once ('classes/reports.class.php');
$sql = "SELECT pccTitle, wc, SUM(".$oDocument->budget->getThisYTDSQL('roy').")/".($oDocument->budget->offset+12-$oDocument->budget->cm)." as FTE
FROM `reg_headcount`
LEFT JOIN common_db.tbl_profit ON pccID=pc
WHERE scenario='{$oDocument->budget->id}' AND location='{$oDocument->location}'
AND salary>10000 AND posted=1
GROUP BY pc, wc
ORDER BY FTE DESC";
// echo '<pre>',$sql,'</pre>';
$rs = $oSQL->q($sql);
while ($rw = $oSQL->f($rs)){
$arrReport[$rw['pccTitle']][$rw['wc']] = $rw['FTE'];
$arrTotal[$rw['wc']] +=$rw['FTE'];
}
if (is_array($arrReport)){
?>
<table><tr><td>
<div id='distribution_table'>
<table class="budget">
<thead>
<tr>
<th>Business unit</th>
<th>White</th>
<th>Blue</th>
<th class="budget-ytd">Total</th>
</thead>
<tbody>
<?php
foreach($arrReport as $pc=>$data){
$arrPie[] = Array('name'=>$pc,'y'=>array_sum($data));
?>
<tr>
<td><?php echo $pc;?></td>
<td class='budget-decimal'><?php Reports::render($data[1],1);?></td>
<td class='budget-decimal'><?php Reports::render($data[0],1);?></td>
<td class="budget-decimal budget-ytd"><?php Reports::render(array_sum($data),1);?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr class="budget-subtotal">
<td>Total</td>
<td class='budget-decimal'><?php Reports::render($arrTotal[1],1);?></td>
<td class='budget-decimal'><?php Reports::render($arrTotalata[0],1);?></td>
<td class="budget-decimal budget-ytd"><?php Reports::render(array_sum($arrTotal),1);?></td>
</tr>
</tfoot>
</table>
</div>
</td>
<td>
<div id='distribution_chart'>
</div>
</td></tr></table>
<script type="text/javascript">
Highcharts.chart('distribution_chart', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Location headcount'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
name: 'Business unit',
colorByPoint: true,
data: <?php echo json_encode($arrPie);?>
}]
});
</script>
<?php
}
die();
break;
case 'financials':
require_once ('classes/reports.class.php');
$sqlWhere= "WHERE source='".$oDocument->GUID."'";
$oReport = new Reports(Array('budget_scenario'=>$oDocument->budget->id));
$oReport->masterByProfit($sqlWhere);
$oReport->masterByYACT($sqlWhere);
die();
break;
default:
break;
}
}
include ('includes/inc_document_menu.php');
//============================== Main form definition ==============================
$oDocument->fillGrid($oDocument->grid);
require ('includes/inc-frame_top.php');
require ('includes/inc_document_header.php');
?>
<script>
$(document).ready(function(){
// var grid=eiseGrid_find(doc.gridName);
// if (grid!=null){
// grid.change ("jan[]", function(oTr, input){
// for (m=1;m<months.length;m++){
// oTr.find("input[name='"+months[m]+"[]']").val(input.val());
// }
// })
// }
});
</script>
<?php
require ('includes/inc-frame_bottom.php');
?>