/
indgross.php
171 lines (162 loc) · 7.48 KB
/
indgross.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
<?
/**
*
* Copyright (C) 2003-2011 Cory Powers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
require_once('includes/common.php');
checkLogin('accounting');
require_once('includes/SI_Reports.php');
$title = 'Individual Gross';
$reports = new SI_Reports();
$start_ts = 0;
$end_ts = 0;
if(isset($_REQUEST['start'])){
$start_ts = getTSFromInput($_REQUEST['start']);
}elseif(isset($_REQUEST['start_ts'])){
$start_ts = $_REQUEST['start_ts'];
}else{
$start_ts = mktime(0, 0, 0, date("n"), 1, date("Y"));
}
$next_start_ts = mktime(0, 0, 0, date("n", $start_ts) + 1, 1, date("Y", $start_ts));
$prev_start_ts = mktime(0, 0, 0, date("n", $start_ts) - 1, 1, date("Y", $start_ts));
if(isset($_REQUEST['end'])){
$end_ts = getTSFromInput($_REQUEST['end']) + 86399;
}elseif(isset($_REQUEST['end_ts'])){
$end_ts = $_REQUEST['end_ts'];
}else{
$end_ts = mktime(23, 59, 59, date("n") + 1, 1, date("Y")) - (24 * 60 * 60);
}
$next_end_ts = mktime(0, 0, 0, date("n", $next_start_ts) + 1, 1, date("Y", $next_start_ts)) - (24 * 60 * 60);
$prev_end_ts = mktime(0, 0, 0, date("n", $prev_start_ts) + 1, 1, date("Y", $prev_start_ts)) - (24 * 60 * 60);
$use_salaries = true;
if(!isset($_REQUEST['use_salaries'])){
$_REQUEST['use_salaries'] = 'Y';
}else{
if($_REQUEST['use_salaries'] == 'N'){
$use_salaries = false;
}
}
$next_month_url = $_SERVER['PHP_SELF']."?start_ts=$next_start_ts&end_ts=$next_end_ts&use_salaries=".$_REQUEST['use_salaries'].'&';
$prev_month_url = $_SERVER['PHP_SELF']."?start_ts=$prev_start_ts&end_ts=$prev_end_ts&use_salaries=".$_REQUEST['use_salaries'].'&';
$rows = $reports->individualGross($start_ts, $end_ts, $use_salaries);
if($rows === FALSE){
$error_msg .= "Error getting report data!\n";
debug_message($reports->getLastError());
}
?>
<? require('header.php'); ?>
<form action="<?= $_SERVER['PHP_SELF'] ?>" METHOD="GET">
<div class="tableContainer">
<a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" /><?= $title ?></a><div>
<table border="0" cellspacing="0" cellpadding="0" class="form_table">
<tr>
<td class="form_field_header_cell">Start:</td>
<td class="form_field_cell">
<input type="text" class="input_text" name="start" id="start" SIZE="10" value="<?= date("n/j/Y", $start_ts) ?>">
<a href="javascript:;" onclick="Uversa.SureInvoice.Calendar.show('start')"><img width="16" height="16" border="0" src="images/dynCalendar.gif"/></a>
</td>
</tr>
<tr>
<td class="form_field_header_cell">End:</td>
<td class="form_field_cell">
<input type="text" class="input_text" name="end" id="end" SIZE="10" value="<?= date("n/j/Y", $end_ts) ?>">
<a href="javascript:;" onclick="Uversa.SureInvoice.Calendar.show('end')"><img width="16" height="16" border="0" src="images/dynCalendar.gif"/></a>
</td>
</tr>
<tr>
<td class="form_field_header_cell">Use Salaries?</td>
<td class="form_field_cell">
<input name="use_salaries" type="radio" value="Y" <?= checked($_REQUEST['use_salaries'], "Y") ?>>Yes
<input name="use_salaries" type="radio" value="N" <?= checked($_REQUEST['use_salaries'], "N") ?>>No
</td>
</tr>
<tr>
<td colspan="2" class="form_field_cell">
<a href="<?= $prev_month_url ?>">Previous Month</a><br>
<a href="<?= $next_month_url ?>">Next Month</a>
</td>
</tr>
<tr>
<td colspan="2" class="form_field_cell">
<div align="right"><input type="submit" name="save" class="button" value="Report"></div>
</td>
</tr>
</table>
</div>
</div>
</form>
<?
if(count($rows) > 0){
$cost_total = 0.00;
$price_total = 0.00;
$cost_hours_total = 0;
$price_hours_total = 0;
?>
<div class="tableContainer" style="clear: both;">
<a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)">
<img src="images/arrow_down.jpg" alt="Hide table" />Employee Time</a><div>
<table border="0" cellspacing="0" cellpadding="0" class="dg_table">
<tr>
<th class="dg_header_cell" colspan="2"> </th>
<th class="dg_header_cell" colspan="2">Worked</th>
<th class="dg_header_cell" colspan="2">Billed</th>
<th class="dg_header_cell"> </th>
</tr>
<tr>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 0, 0, false)">First Name</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 1, 1, false)">Last Name</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 2, 0, false)">Hours</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 2, 0, false)">Amount</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 4, 0, false)">Hours</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 4, 0, false)">Amount</a></th>
<th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId1', 5, 0, false)">Diff</a></th>
</tr>
<tbody id="bodyId1">
<? $i = 0;
foreach($rows as $row){
$i++;
$cost_total += $row['cost'];
$price_total += $row['price'];
$cost_hours_total += $row['hours_worked'];
$price_hours_total += $row['hours_billed'];
?>
<tr onmouseover="this.style.backgroundColor ='#CCCCCC'" onmouseout="this.style.backgroundColor ='#FFFFFF'">
<td class="dg_data_cell_1"><?= $row['first_name'] ?></td>
<td class="dg_data_cell_1"><?= $row['last_name'] ?></td>
<td class="dg_data_cell_1" align="right"><?= formatLengthOfTime($row['hours_worked']) ?></td>
<td class="dg_data_cell_1" align="right"><?= SureInvoice::getCurrencySymbol().number_format($row['cost'], 2) ?></td>
<td class="dg_data_cell_1" align="right"><?= formatLengthOfTime($row['hours_billed']) ?></td>
<td class="dg_data_cell_1" align="right"><?= SureInvoice::getCurrencySymbol().number_format($row['price'], 2) ?></td>
<td class="dg_data_cell_1" align="right" <?= ($row['price'] - $row['cost']) < 0 ? 'style="color:red"' : '' ?>><?= number_format($row['price'] - $row['cost'], 2) ?></td>
</tr>
<? }?>
</tbody>
<tr>
<td colspan="2" class="form_header_cell" align="right">Totals:</td>
<td class="form_field_cell" align="right"><?= formatLengthOfTime($cost_hours_total) ?></td>
<td class="form_field_cell" align="right"><?= SureInvoice::getCurrencySymbol().number_format($cost_total,2) ?></td>
<td class="form_field_cell" align="right"><?= formatLengthOfTime($price_hours_total) ?></td>
<td class="form_field_cell" align="right"><?= SureInvoice::getCurrencySymbol().number_format($price_total,2) ?></td>
<td class="form_field_cell" align="right" <?= ($price_total - $cost_total) < 0 ? 'style="color:red"' : '' ?>><?= number_format($price_total - $cost_total, 2) ?></td>
</tr>
</table>
</div>
</div>
<? } ?>
<? require('footer.php'); ?>