forked from smuwanga/ViralLoad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tpl.envelopes.capture.php
207 lines (200 loc) · 9.47 KB
/
tpl.envelopes.capture.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
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
<?
//security check
if(!$GLOBALS['vlDC'] || !$_SESSION["VLEMAIL"]) {
die("<font face=arial size=2>You must be logged in to view this page.</font>");
}
//validation
$envelopeNumber=validate($envelopeNumber);
$batchNumber=validate($batchNumber);
if($saveEnvelope) {
//validate data
$error=0;
$error=checkFormFields("Envelope_Number::$envelopeNumber Batch_Number::$batchNumber Facility_Name::$facilityID");
//is this Envelopes's envelopeNumber unique
if(getDetailedTableInfo2("vl_envelopes","envelopeNumber='$envelopeNumber' limit 1","id")) {
$error.="<br />Another Envelope with the same Envelope Number <strong>$envelopeNumber</strong> already exists.<br />Kindly provide an alternative Envelope Number<br />";
}
//is this Batch's batchNumber unique
if(getDetailedTableInfo2("vl_envelopes","batchNumber='$batchNumber' limit 1","id")) {
$error.="<br />Another Envelope with the same Batch Number <strong>$batchNumber</strong> already exists.<br />Kindly provide an alternative Batch Number<br />";
}
//input data
if(!$error) {
//formate date
$currentDateTime=0;
$currentDateTime="$receivedDateYear-$receivedDateMonth-$receivedDateDay ".getFormattedTime($datetime);
//log issue
mysqlquery("insert into vl_envelopes
(envelopeNumber,batchNumber,districtID,hubID,facilityID,created,createdby)
values
('$envelopeNumber','$batchNumber','$districtID','$hubID','$facilityID','$currentDateTime','$trailSessionUser')");
//redirect to home with updates on the tracking number
go("/envelopes/success/");
}
}
?>
<script Language="JavaScript" Type="text/javascript">
<!--
function validate(envelopes) {
//check for missing information
if(!document.envelopes.envelopeNumber.value) {
alert('Missing Mandatory Field: Envelope Code');
document.envelopes.envelopeNumber.focus();
return (false);
}
if(!document.envelopes.batchNumber.value) {
alert('Missing Mandatory Field: Envelope Pack Size');
document.envelopes.batchNumber.focus();
return (false);
}
if(!document.envelopes.facilityID.value) {
alert('Missing Mandatory Field: Facility Name');
document.envelopes.facilityID.focus();
return (false);
}
return (true);
}
//-->
</script>
<!--<form name="envelopes" method="post" action="/envelopes/capture/" onsubmit="return validate(this)">-->
<form name="envelopes" method="post" action="/envelopes/capture/">
<table width="100%" border="0" class="vl">
<? if($success) { ?>
<tr>
<td class="vl_success">Data Captured Successfully!</td>
</tr>
<tr>
<td> </td>
</tr>
<? } elseif($error) { ?>
<tr>
<td class="vl_error"><?=$error?></td>
</tr>
<tr>
<td> </td>
</tr>
<? } ?>
<tr>
<td class="toplinks" style="padding:0px 0px 10px 0px"><a class="toplinks" href="/dashboard/">HOME</a> <a class="toplinks" href="/envelopes/">ENVELOPES</a> <a class="toplinks" href="/envelopes/capture/">Envelopes Capture</a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<fieldset style="width: 85%">
<legend><strong>ENVELOPE SPECIFICATIONS</strong></legend>
<table width="100%" border="0" class="vl">
<tr>
<td width="20%">Envelope # <font class="vl_red">*</font></td>
<td width="80%"><input type="text" name="envelopeNumber" id="envelopeNumber" value="<?=$envelopeNumber?>" class="search_pre" size="20" maxlength="100" /></td>
</tr>
<tr>
<td>Batch # <font class="vl_red">*</font></td>
<td><input type="text" name="batchNumber" id="batchNumber" value="<?=$batchNumber?>" class="search_pre" size="20" maxlength="100" /></td>
</tr>
<tr>
<td>Facility Name <font class="vl_red">*</font></td>
<td>
<select name="facilityID" id="facilityID" class="search">
<?
$query=0;
$query=mysqlquery("select * from vl_facilities where facility!='' order by facility");
echo "<option value=\"\" selected=\"selected\">Select Facility</option>";
if(mysqlnumrows($query)) {
while($q=mysqlfetcharray($query)) {
echo "<option value=\"$q[id]\">$q[facility]</option>";
}
}
?>
</select>
<script>
var z = dhtmlXComboFromSelect("facilityID");
z.enableFilteringMode(true);
</script>
</td>
</tr>
<tr>
<td>Hub</td>
<td>
<select name="hubID" id="hubID" class="search">
<?
$query=0;
$query=mysqlquery("select * from vl_hubs order by hub");
echo "<option value=\"\" selected=\"selected\">Select Hub</option>";
if(mysqlnumrows($query)) {
while($q=mysqlfetcharray($query)) {
echo "<option value=\"$q[id]\">$q[hub]</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td>District</td>
<td>
<select name="districtID" id="districtID" class="search">
<?
$query=0;
$query=mysqlquery("select * from vl_districts order by district");
echo "<option value=\"\" selected=\"selected\">Select District</option>";
if(mysqlnumrows($query)) {
while($q=mysqlfetcharray($query)) {
echo "<option value=\"$q[id]\">$q[district]</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Date Received <font class="vl_red">*</font></td>
<td>
<table width="10%" border="0" cellspacing="0" cellpadding="0" class="vl">
<tr>
<td><select name="receivedDateDay" id="receivedDateDay" class="search">
<?
echo "<option value=\"".getFormattedDateDay($datetime)."\" selected=\"selected\">".getFormattedDateDay($datetime)."</option>";
for($j=1;$j<=31;$j++) {
echo "<option value=\"".($j<10?"0$j":$j)."\">$j</option>";
}
?>
</select></td>
<td style="padding:0px 0px 0px 5px"><select name="receivedDateMonth" id="receivedDateMonth" class="search">
<? echo "<option value=\"".getFormattedDateMonth($datetime)."\" selected=\"selected\">".getFormattedDateMonthname($datetime)."</option>"; ?>
<option value="01">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">Jun</option>
<option value="07">Jul</option>
<option value="08">Aug</option>
<option value="09">Sept</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select></td>
<td style="padding:0px 0px 0px 5px"><select name="receivedDateYear" id="receivedDateYear" class="search">
<?
for($j=getFormattedDateYear($datetime);$j>=(getCurrentYear()-10);$j--) {
echo "<option value=\"$j\">$j</option>";
}
?>
</select></td>
</tr>
</table></td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td style="padding:10px 0px 0px 0px"><input type="submit" name="saveEnvelope" id="saveEnvelope" class="button" value=" Save Envelope " /></td>
</tr>
<tr>
<td style="padding:20px 0px 0px 0px"><a href="/envelopes/">Return to Envelopes</a> :: <a href="/dashboard/">Return to Dashboard</a></td>
</tr>
</table>
</form>