-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreview.php
More file actions
executable file
·360 lines (273 loc) · 10 KB
/
review.php
File metadata and controls
executable file
·360 lines (273 loc) · 10 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
/* Copyright Deakin University 2007,2008
* Written by Adam Zammit - adam.zammit@deakin.edu.au
* For the Deakin Computer Assisted Research Facility: http://www.deakin.edu.au/dcarf/
*
* This file is part of queXF
*
* queXF 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.
*
* queXF 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 queXF; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
include_once("config.inc.php");
include_once("db.inc.php");
include_once("functions/functions.database.php");
include_once("functions/functions.image.php");
global $db;
function bgidtocss($zoom = 1,$fid,$pid)
{
global $db;
$sql = "SELECT MIN(b.tlx) as tlx,MIN(b.tly) as tly,MAX(b.brx) as brx,MAX(b.bry) as bry, b.pid as pid, bg.btid as btid, b.bgid as bgid
FROM boxes as b, boxgroupstype as bg
WHERE b.pid = '$pid'
AND bg.bgid = b.bgid
AND bg.btid > 0
GROUP BY bg.bgid
ORDER BY bg.sortorder ASC";
$boxgroups = $db->GetAll($sql);
$sql = "SELECT offx,offy,centroidx,centroidy,costheta,sintheta,scalex,scaley,width,height
FROM formpages as f
WHERE f.pid = $pid and f.fid = $fid";
$row = $db->GetRow($sql);
$sql = "SELECT CASE WHEN done = 1 THEN assigned_vid ELSE assigned_vid2 END AS assigned_vid
FROM forms
WHERE fid = '$fid'";
$vid = $db->GetOne($sql);
$sql = "(SELECT b.bid,f.val,b.bgid,g.btid,g.sortorder,b.tly,b.tlx,b.bry,b.brx
FROM boxes as b
JOIN boxgroupstype as g ON (b.bgid = g.bgid AND g.btid > 0 AND g.btid < 5)
LEFT JOIN formboxverifychar as f ON (f.bid = b.bid AND f.vid = '{$vid}' and f.fid = '{$fid}')
WHERE b.pid = '$pid'
)
UNION
(SELECT b.bid,f.val,b.bgid,g.btid,g.sortorder,b.tly,b.tlx,b.bry,b.brx
FROM boxes as b
JOIN boxgroupstype as g on (b.bgid = g.bgid and g.btid IN (5,6))
LEFT JOIN formboxverifytext as f on (f.bid = b.bid and f.vid = '{$vid}' and f.fid = '{$fid}')
WHERE b.pid = '$pid')
ORDER BY sortorder asc,bid asc";
$boxes = $db->GetAssoc($sql);
$vis = "visible";
if (!isset($row['offx']) && !isset($row['offy']))
{
$row = array();
$row['offx'] = 0;
$row['offy'] = 0;
$row['centroidx'] = PAGE_WIDTH / 2;
$row['centroidy'] = PAGE_HEIGHT / 2;
$row['costheta'] = 1;
$row['sintheta'] = 0;
$row['scalex'] = 1;
$row['scaley'] = 1;
}
//fix for upgrades
if ($row['width'] == 0) $row['width'] = PAGE_WIDTH;
if ($row['height'] == 0) $row['height'] = PAGE_HEIGHT;
foreach($boxes as $bid => $rest)
{
$box = $rest;
$val = $rest['val'];
$bbgid = $rest['bgid'];
$btid = $rest['btid'];
$box = applytransforms($box,$row);
if ($btid == 1) //single
{
if ($val == 0) {$checked = ""; $colour = BOX_BACKGROUND_COLOUR; } else {$checked = "checked=\"checked\""; $colour = BOX_SELECT_COLOUR;}
print "<div id=\"checkImage$bid\" style=\"position:absolute; top:" . $box['tly'] / $zoom . "px; left:" . $box['tlx'] / $zoom . "px; width:" . ($box['brx'] - $box['tlx'] ) / $zoom . "px; height:" . ($box['bry'] - $box['tly'] ) / $zoom . "px; background-color: $colour;opacity:" . BOX_OPACITY . "; \"></div>";
}
else if ($btid == 2) //multiple
{
if ($val == 0) {$checked = ""; $colour = BOX_BACKGROUND_COLOUR; } else {$checked = "checked=\"checked\""; $colour = BOX_SELECT_COLOUR;}
print "<div id=\"checkImage$bid\" style=\"position:absolute; top:" . $box['tly'] / $zoom . "px; left:" . $box['tlx'] / $zoom . "px; width:" . ($box['brx'] - $box['tlx'] ) / $zoom . "px; height:" . ($box['bry'] - $box['tly'] ) / $zoom . "px; background-color: $colour;opacity:" . BOX_OPACITY . "; \"></div>";
}
else if ($btid == 3 || $btid == 4) //text or number
{
$maxlength = "maxlength=\"1\"";
if ($btid == 4)
{
if (!is_numeric($val)) $val = "";
}
$val = htmlspecialchars($val);
print "<div id=\"textImage$bid\" style=\"position:absolute; top:" . $box['tly'] / $zoom . "px; left:" . $box['tlx'] / $zoom . "px; width:" . ($box['brx'] - $box['tlx'] ) / $zoom . "px; height:" . ($box['bry'] - $box['tly'] ) / $zoom . "px; background-color: " . BOX_BACKGROUND_COLOUR . "; text-align:center; font-weight:bold;\">$val</div>";
}
else if ($btid == 6 || $btid == 5)
{
$val = htmlspecialchars($val);
print "<div id=\"textImage$bid\" style=\"position:absolute; top:" . $box['tly'] / $zoom . "px; left:" . $box['tlx'] / $zoom . "px; width:" . ($box['brx'] - $box['tlx'] ) / $zoom . "px; height:" . ($box['bry'] - $box['tly'] ) / $zoom . "px; background-color: " . BOX_BACKGROUND_COLOUR . "; text-align:center; font-weight:bold;\">$val</div>";
}
}
}
$fid = "";
$pid = "";
$var = "";
if (isset($_GET['fid']))
{
$fid = $_GET['fid'];
}
$q = get_qid_description($fid);
if (!isset($q['qid']))
$qid = "";
else
$qid = $q['qid'];
if (isset($_GET['pid']))
{
$pid = intval($_GET['pid']);
}
if (isset($_GET['var']))
{
$var = $_GET['var'];
$vars = $db->qstr($_GET['var']);
$sql = "SELECT b.pid
FROM boxgroupstype as b, pages as p
WHERE b.varname LIKE $vars
AND p.pid = b.pid
AND p.qid = '$qid'";
$v = $db->GetRow($sql);
if (isset($v['pid']))
{
$pid = $v['pid'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo T_("Review Form"); ?> - <?php print "FID:$fid"; ?></title>
<style type="text/css">
#topper {
position : fixed;
width : 100%;
height : 5%;
top : 0;
right : 0;
bottom : auto;
left : 0;
border-bottom : 2px solid #cccccc;
overflow : auto;
text-align:center;
}
#header {
position : fixed;
width : 15%;
height : 95%;
top : 5%;
right : 0;
bottom : auto;
left : 0;
border-bottom : 2px solid #cccccc;
overflow : auto;
}
#content {
position : fixed;
top : 5%;
left : 15%;
bottom : auto;
width : 85%;
height : 100%;
color : #000000;
overflow : auto;
}
</style>
</head>
<body>
<?php
//show content
//
//
print "<div id=\"content\">";
print "<div style=\"position:relative;\"><img src=\"showpage.php?pid=$pid&fid=$fid\" style=\"width:" . DISPLAY_PAGE_WIDTH . "px;\" alt=\"" . T_("Image of page") . " $pid, " . T_("form") . " $fid\" />";
print "<div id=\"overlay\">";
bgidtocss((PAGE_WIDTH/DISPLAY_PAGE_WIDTH),$fid,$pid);
print "</div>";
print "</div>";
print "</div>";
//show list of bgid for this fid
print "<div id=\"header\">";
print "<p>F:$fid</p>";
?>
<form action="" method="get">
<div><?php echo T_("Form:"); ?> <input type="text" size="5" name="fid" value="<?php echo $fid ?>"/>
<?php echo T_("Variable:"); ?> <input type="text" size="9" name="var" value="<?php echo $var ?>"/>
<?php echo T_("Page:"); ?> <input type="text" size="4" name="pid" value="<?php echo $pid ?>"/>
<input type="submit"/></div>
</form>
<p>
<script type="text/javascript">
function toggleoverlay() {
var x = document.getElementById('overlay');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
</script>
<button onclick="toggleoverlay()"><?php echo T_("Toggle overlay");?></button>
</p>
<?php
if (isset($_GET['doubleentry'])) {
$sql = "UPDATE forms
SET done = 3,
completed2 = completed,
assigned_vid2 = assigned_vid,
assigned2 = assigned,
assigned = NULL,
completed = NULL,
assigned_vid = NULL
WHERE fid = $fid
AND done = 1
AND completed2 IS NULL";
$db->Execute($sql);
}
//note here who verified and then allow for double entry if not already double entered
$sql = "SELECT f.done,v1.description,v2.description as description2,f.completed,f.completed2
FROM forms as f
LEFT JOIN verifiers as v1 on (v1.vid = f.assigned_vid)
LEFT JOIN verifiers as v2 on (v2.vid = f.assigned_vid2)
WHERE f.fid = $fid";
$ver = $db->GetRow($sql);
if ($ver['done'] == 1 && empty($ver['completed2'])) { //verified once
print "<div>" . T_("Verified by:") . $ver['description'] . "</div>";
print "<form action='?' method='get'><div><input type='hidden' name='doubleentry' value='doubleentry'><input type='hidden' name='fid' value='$fid'><input type='hidden' name='pid' value='$pid'><input type='hidden' name='var' value='$var'><input type='submit' value='". T_("Verify again by another verifier (double entry)") ."'/></div></form>";
} else if ($ver['done'] == 3) {
print "<div>" . T_("Verified by:") . $ver['description2'] . "</div>";
print "<div>". T_("Awaiting double entry") . "</div>";
} else if ($ver['done'] == 1 && !empty($ver['completed2'])) {
print "<div>" . T_("Verified first by:") . $ver['description2'] ."</div>";
print "<div>" . T_("Verified second by:") . $ver['description'] ."</div>";
} else {
print "<div>" . T_("Not yet verified") ."</div>";
}
print "</div>";
//show list of pid for this fid
print "<div id=\"topper\">";
$count = 1;
$sql = "SELECT pid
FROM pages
WHERE qid = '$qid'
ORDER BY pidentifierval ASC";
$pages = $db->GetAll($sql);
foreach($pages as $page)
{
$p = $page['pid'];
if ($pid == $p)
print "<strong>$count</strong>";
else
print " <a href=\"" . $_SERVER['PHP_SELF'] . "?pid=$p&fid=$fid\">$count</a> ";
$count++;
}
print "</div>";
?>
</body></html>