forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HistoricalTestResults.php
159 lines (140 loc) · 5.25 KB
/
HistoricalTestResults.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
<?php
include('includes/session.php');
$Title = _('Historical Test Results');
$ViewTopic= 'QualityAssurance';// Filename in ManualContents.php's TOC.
$BookMark = 'QA_HistoricalResults';// Anchor's id in the manual's html document.
include('includes/header.php');
if (isset($_GET['KeyValue'])){
$KeyValue =mb_strtoupper($_GET['KeyValue']);
} elseif (isset($_POST['KeyValue'])){
$KeyValue =mb_strtoupper($_POST['KeyValue']);
} else {
$KeyValue='';
}
if (!isset($_POST['FromDate'])){
$_POST['FromDate']=Date(($_SESSION['DefaultDateFormat']), Mktime(0, 0, 0, Date('m'), Date('d')-180, Date('Y')));
}
if (!isset($_POST['ToDate'])){
$_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']);
}
if (!Is_Date($_POST['FromDate'])) {
$InputError = 1;
prnMsg(_('Invalid From Date'),'error');
$_POST['FromDate']=Date(($_SESSION['DefaultDateFormat']), Mktime(0, 0, 0, Date('m'), Date('d')-180, Date('Y')));
}
if (!Is_Date($_POST['ToDate'])) {
$InputError = 1;
prnMsg(_('Invalid To Date'),'error');
$_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']);
}
$FromDate = FormatDateForSQL($_POST['FromDate']);
$ToDate = FormatDateForSQL($_POST['ToDate']);
if (isset($Errors)) {
unset($Errors);
}
$Errors = array();
echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p>';
//prompt user for Key Value
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<div>
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
<table class="selection">
<tr>
<td>' . _('Show Test Results For') .':</td>';
$SQLSpecSelect="SELECT DISTINCT(prodspeckey),
description
FROM qasamples LEFT OUTER JOIN stockmaster
ON stockmaster.stockid=qasamples.prodspeckey";
$ResultSelection=DB_query($SQLSpecSelect);
echo '<td><select name="KeyValue">';
while ($MyRowSelection=DB_fetch_array($ResultSelection)){
if ($MyRowSelection['prodspeckey']==$KeyValue) {
$Selected='selected="selected" ';
} else {
$Selected='';
}
echo '<option ' . $Selected . ' value="' . $MyRowSelection['prodspeckey'] . '">' . $MyRowSelection['prodspeckey'].' - ' .htmlspecialchars($MyRowSelection['description'], ENT_QUOTES,'UTF-8', false) . '</option>';
}
echo '</select></td>';
echo '</tr>
<tr>
<td>' . _('From Sample Date') . ': </td>
<td><input name="FromDate" maxlength="10" size="11" class="date" value="' . $_POST['FromDate'] . '" /></td>
</tr>
<tr>
<td> ' . _('To Sample Date') . ':</td>
<td> <input name="ToDate" maxlength="10" size="11" class="date" value="' . $_POST['ToDate'] . '" /></td>
</tr>
</table>
</div>
<div>
<input type="submit" name="PickSpec" value="' . _('Submit') . '" />
</div>
</form>';
//show header
$SQLSpecSelect="SELECT description
FROM stockmaster
WHERE stockmaster.stockid='" . $KeyValue . "'";
$ResultSelection=DB_query($SQLSpecSelect);
$MyRowSelection=DB_fetch_array($ResultSelection);
$SQLTests="SELECT sampleresults.testid,
sampledate,
sampleresults.sampleid,
lotkey,
identifier,
cert,
isinspec,
testvalue,
name
FROM qasamples
INNER JOIN sampleresults on sampleresults.sampleid=qasamples.sampleid
INNER JOIN qatests
ON qatests.testid=sampleresults.testid
WHERE qasamples.prodspeckey='" . $KeyValue . "'
AND sampleresults.showontestplan='1'
AND sampledate>='" . $FromDate . "'
AND sampledate <='" . $ToDate . "'";
$TestResult=DB_query($SQLTests);
$TestsArray=array();
$SamplesArray=array();
$AllResultsArray=array();
$TotResults=0;
while ($MyTestRow=DB_fetch_array($TestResult)) {
$FormattedSampleID=str_pad($MyTestRow['sampleid'],10,'0',STR_PAD_LEFT);
$testkey=array_search ($MyTestRow['name'] , $TestsArray);
if ($testkey===false) {
$TestsArray[$MyTestRow['name']]=$MyTestRow['name'];
}
$testkey=array_search ($MyTestRow['sampleid'] , $SamplesArray);
if ($testkey===false) {
$SamplesArray[$FormattedSampleID]=$MyTestRow;
$TotResults++;
}
$AllResultsArray[$MyTestRow['name']][$FormattedSampleID]=$MyTestRow;
}
if ($TotResults>0) {
echo '<br/>' . _('Historical Test Results for') . ' ' . $KeyValue . '-' . $MyRowSelection['description'] . '<br/>';
echo '<div>
<div style="overflow:auto; width:98%; padding:10px; ">
<table width="90%" style="overflow: scroll;">
<tr>
<th style="white-space:nowrap;" class="number">' . _('Sample ID:') . '<br>' . _('Lot/Serial:') . '<br>' . _('Identifier:') . '<br>' . _('Sample Date:') .'</th>';
foreach ($SamplesArray as $samplekey => $samplevalue) {
echo '<th>'. $samplekey . '<br>' . $samplevalue['lotkey'] . '<br>' . $samplevalue['identifier'] . '<br>' . ConvertSQLDate($samplevalue['sampledate']).'</th>';
}
echo '</tr>';
foreach ($TestsArray as $testkey => $testvalue) {
echo '<tr class="striped_row">
<td class="select" style="white-space:nowrap;">'.$testvalue.'</td>';
foreach ($SamplesArray as $samplekey => $samplevalue) {
if ($AllResultsArray[$testkey][$samplekey]['testvalue']=='' OR !isset($AllResultsArray[$testkey][$samplekey]['testvalue'])) {
$AllResultsArray[$testkey][$samplekey]['testvalue']=' ';
}
echo '<td>'.$AllResultsArray[$testkey][$samplekey]['testvalue'].'</td>';
}
echo '</tr>';
}
echo '</tr></table></div></div>';
}
include('includes/footer.php');
?>