1<?php
2
3include('includes/session.php');
4$Title = _('Select QA Samples');
5$ViewTopic= 'QualityAssurance';// Filename in ManualContents.php's TOC.
6$BookMark = 'QA_Samples';// Anchor's id in the manual's html document.
7include('includes/header.php');
8include('includes/SQL_CommonFunctions.inc');
9
10if (isset($_GET['SelectedSampleID'])){
11	$SelectedSampleID =mb_strtoupper($_GET['SelectedSampleID']);
12} elseif(isset($_POST['SelectedSampleID'])){
13	$SelectedSampleID =mb_strtoupper($_POST['SelectedSampleID']);
14}
15
16if (isset($_GET['SelectedStockItem'])) {
17	$SelectedStockItem = $_GET['SelectedStockItem'];
18} elseif (isset($_POST['SelectedStockItem'])) {
19	$SelectedStockItem = $_POST['SelectedStockItem'];
20}
21if (isset($_GET['LotNumber'])) {
22	$LotNumber = $_GET['LotNumber'];
23} elseif (isset($_POST['LotNumber'])) {
24	$LotNumber = $_POST['LotNumber'];
25}
26if (isset($_GET['SampleID'])) {
27	$SampleID = $_GET['SampleID'];
28} elseif (isset($_POST['SampleID'])) {
29	$SampleID = $_POST['SampleID'];
30}
31if (!isset($_POST['FromDate'])){
32	$_POST['FromDate']=Date(($_SESSION['DefaultDateFormat']), Mktime(0, 0, 0, Date('m'), Date('d')-15, Date('Y')));
33}
34if (!isset($_POST['ToDate'])){
35	$_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']);
36}
37
38if (isset($Errors)) {
39	unset($Errors);
40}
41
42$Errors = array();
43
44echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p>';
45
46if (isset($_POST['submit'])) {
47
48	//initialise no input errors assumed initially before we test
49	$InputError = 0;
50
51	/* actions to take once the user has clicked the submit button
52	ie the page has called itself with some user input */
53	$i=1;
54
55	//first off validate inputs sensible
56
57	if (isset($SelectedSampleID) AND $InputError !=1) {
58		//check to see all values are in spec or at least entered
59		$result = DB_query("SELECT count(sampleid) FROM sampleresults
60							WHERE sampleid = '" . $SelectedSampleID . "'
61							AND showoncert='1'
62							AND testvalue=''");
63		$myrow = DB_fetch_row($result);;
64		if($myrow[0]>0 AND $_POST['Cert']=='1') {
65			 $_POST['Cert']='0';
66			 $msg = _('Test Results have not all been entered.  This Lot is not able to be used for a a Certificate of Analysis');
67			 prnMsg($msg , 'error');
68		}
69		$result = DB_query("SELECT count(sampleid) FROM sampleresults
70							WHERE sampleid = '".$SelectedSampleID."'
71							AND showoncert='1'
72							AND isinspec='0'");
73		$myrow = DB_fetch_row($result);;
74		if($myrow[0]>0 AND $_POST['Cert']=='1') {
75			 $msg = _('Some Results are out of Spec');
76			 prnMsg($msg , 'warning');
77		}
78		$sql = "UPDATE qasamples SET identifier='" . $_POST['Identifier'] . "',
79									comments='" . $_POST['Comments'] . "',
80									sampledate='" . FormatDateForSQL($_POST['SampleDate']) . "',
81									cert='" . $_POST['Cert'] . "'
82				WHERE sampleid = '" . $SelectedSampleID . "'";
83
84		$msg = _('QA Sample record for') . ' ' . $SelectedSampleID  . ' ' .  _('has been updated');
85		$ErrMsg = _('The update of the QA Sample failed because');
86		$DbgMsg = _('The SQL that was used and failed was');
87		$result = DB_query($sql,$ErrMsg, $DbgMsg);
88		prnMsg($msg , 'success');
89		if ( $_POST['Cert']==1) {
90			$result = DB_query("SELECT prodspeckey, lotkey FROM qasamples
91							WHERE sampleid = '".$SelectedSampleID."'");
92			$myrow = DB_fetch_row($result);;
93			if($myrow[0]>'') {
94				$sql = "UPDATE qasamples SET cert='0'
95						WHERE sampleid <> '".$SelectedSampleID . "'
96						AND prodspeckey='" . $myrow[0] . "'
97						AND lotkey='" . $myrow[1] . "'";
98				$msg = _('All other samples for this Specification and Lot was marked as Cert=No');
99				$ErrMsg = _('The update of the QA Sample failed because');
100				$DbgMsg = _('The SQL that was used and failed was');
101				$result = DB_query($sql,$ErrMsg, $DbgMsg);
102				prnMsg($msg , 'success');
103			}
104		}
105
106	} else {
107		CreateQASample($_POST['ProdSpecKey'],$_POST['LotKey'], $_POST['Identifier'], $_POST['Comments'], $_POST['Cert'], $_POST['DuplicateOK']);
108		$SelectedSampleID=DB_Last_Insert_ID('qasamples','sampleid');
109		if ($SelectedSampleID > '') {
110			$msg = _('Created New Sample');
111			prnMsg($msg , 'success');
112		}
113	}
114	unset($SelectedSampleID);
115	unset($_POST['ProdSpecKey']);
116	unset($_POST['LotKey']);
117	unset($_POST['Identifier']);
118	unset($_POST['Comments']);
119	unset($_POST['Cert']);
120} elseif (isset($_GET['delete'])) {
121//the link to delete a selected record was clicked instead of the submit button
122
123// PREVENT DELETES IF DEPENDENT RECORDS
124
125	$sql= "SELECT COUNT(*) FROM sampleresults WHERE sampleresults.sampleid='".$SelectedSampleID."'
126											AND sampleresults.testvalue > ''";
127	$result = DB_query($sql);
128	$myrow = DB_fetch_row($result);
129	if ($myrow[0]>0) {
130		prnMsg(_('Cannot delete this Sample ID because there are test results tied to it'),'error');
131	} else {
132		$sql="DELETE FROM sampleresults WHERE sampleid='" . $SelectedSampleID . "'";
133		$ErrMsg = _('The sample results could not be deleted because');
134		$result = DB_query($sql,$ErrMsg);
135		$sql="DELETE FROM qasamples WHERE sampleid='" . $SelectedSampleID ."'";
136		$ErrMsg = _('The QA Sample could not be deleted because');
137		$result = DB_query($sql,$ErrMsg);
138		echo $sql;
139		prnMsg(_('QA Sample') . ' ' . $SelectedSampleID . _('has been deleted from the database'),'success');
140		unset ($SelectedSampleID);
141		unset($delete);
142		unset ($_GET['delete']);
143	}
144}
145
146if (!isset($SelectedSampleID)) {
147
148	echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
149		<div>
150		<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
151	if (isset($_POST['ResetPart'])) {
152		unset($SelectedStockItem);
153	}
154
155	if (isset($SampleID) AND $SampleID != '') {
156		if (!is_numeric($SampleID)) {
157			prnMsg(_('The Sample ID entered') . ' <U>' . _('MUST') . '</U> ' . _('be numeric'), 'error');
158			unset($SampleID);
159		} else {
160			echo _('Sample ID') . ' - ' . $SampleID;
161		}
162	}
163	if (!Is_Date($_POST['FromDate'])) {
164		$InputError = 1;
165		prnMsg(_('Invalid From Date'),'error');
166		$_POST['FromDate']=Date(($_SESSION['DefaultDateFormat']), mktime(0, 0, 0, Date('m'), Date('d')-15, Date('Y')));
167	}
168	if (!Is_Date($_POST['ToDate'])) {
169		$InputError = 1;
170		prnMsg(_('Invalid To Date'),'error');
171		$_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']);
172	}
173	if (isset($_POST['SearchParts'])) {
174		if ($_POST['Keywords'] AND $_POST['StockCode']) {
175			prnMsg(_('Stock description keywords have been used in preference to the Stock code extract entered'), 'info');
176		}
177		if ($_POST['Keywords']) {
178			//insert wildcard characters in spaces
179			$SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%';
180			$SQL = "SELECT stockmaster.stockid,
181					stockmaster.description,
182					stockmaster.decimalplaces,
183					SUM(locstock.quantity) as qoh,
184					stockmaster.units,
185				FROM stockmaster INNER JOIN locstock
186				ON stockmaster.stockid = locstock.stockid
187				INNER JOIN locationusers ON locationusers.loccode = locstock.loccode
188						AND locationusers.userid='" .  $_SESSION['UserID'] . "'
189						AND locationusers.canview=1
190				WHERE stockmaster.description " . LIKE  . " '" . $SearchString ."'
191				AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
192				GROUP BY stockmaster.stockid,
193					stockmaster.description,
194					stockmaster.decimalplaces,
195					stockmaster.units
196				ORDER BY stockmaster.stockid";
197		} elseif ($_POST['StockCode']) {
198			$SQL = "SELECT stockmaster.stockid,
199					stockmaster.description,
200					stockmaster.decimalplaces,
201					SUM(locstock.quantity) AS qoh,
202					stockmaster.units
203				FROM stockmaster INNER JOIN locstock
204					ON stockmaster.stockid = locstock.stockid
205				INNER JOIN locationusers ON locationusers.loccode = locstock.loccode
206						AND locationusers.userid='" .  $_SESSION['UserID'] . "'
207						AND locationusers.canview=1
208				WHERE stockmaster.stockid " . LIKE  . " '%" . $_POST['StockCode'] . "%'
209				AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
210				GROUP BY stockmaster.stockid,
211					stockmaster.description,
212					stockmaster.decimalplaces,
213					stockmaster.units
214				ORDER BY stockmaster.stockid";
215		} elseif (!$_POST['StockCode'] AND !$_POST['Keywords']) {
216			$SQL = "SELECT stockmaster.stockid,
217					stockmaster.description,
218					stockmaster.decimalplaces,
219					SUM(locstock.quantity) AS qoh,
220					stockmaster.units
221				FROM stockmaster INNER JOIN locstock ON stockmaster.stockid = locstock.stockid
222				INNER JOIN locationusers ON locationusers.loccode = locstock.loccode
223						AND locationusers.userid='" .  $_SESSION['UserID'] . "'
224						AND locationusers.canview =1
225				WHERE stockmaster.categoryid='" . $_POST['StockCat'] . "'
226				GROUP BY stockmaster.stockid,
227					stockmaster.description,
228					stockmaster.decimalplaces,
229					stockmaster.units
230				ORDER BY stockmaster.stockid";
231		}
232
233		$ErrMsg = _('No stock items were returned by the SQL because');
234		$DbgMsg = _('The SQL used to retrieve the searched parts was');
235		$StockItemsResult = DB_query($SQL, $ErrMsg, $DbgMsg);
236	}
237
238	if (true or !isset($LotNumber) or $LotNumber == '') { //revisit later, right now always show all inputs
239		echo '<table class="selection"><tr><td>';
240		if (!isset($LotNumber)){
241			$LotNumber ='';
242		}
243		if (!isset($SampleID)){
244			$SampleID='';
245		}
246		if (isset($SelectedStockItem)) {
247			echo _('For the part') . ':<b>' . $SelectedStockItem . '</b> ' . _('and') . ' <input type="hidden" name="SelectedStockItem" value="' . $SelectedStockItem . '" />';
248		}
249		echo _('Lot Number') . ': <input name="LotNumber" autofocus="autofocus" maxlength="20" size="12" value="' . $LotNumber . '"/> ' . _('Sample ID') . ': <input name="SampleID" maxlength="10" size="10" value="' . $SampleID . '"/> ';
250		echo _('From Sample Date') . ': <input name="FromDate" size="10" class="date" value="' . $_POST['FromDate'] . '" /> ' . _('To Sample Date') . ': <input name="ToDate" size="10" class="date" value="' . $_POST['ToDate'] . '" /> ';
251		echo '<input type="submit" name="SearchSamples" value="' . _('Search Samples') . '" /></td>
252			</tr>
253			</table>';
254	}
255	$SQL = "SELECT categoryid,
256				categorydescription
257			FROM stockcategory
258			ORDER BY categorydescription";
259	$result1 = DB_query($SQL);
260	echo '<table class="selection">
261			<tr>
262				<td>' . _('To search for Pick Lists for a specific part use the part selection facilities below') . '</td>
263			</tr>
264			<tr>
265				<td>' . _('Select a stock category') . ':<select name="StockCat">';
266	while ($myrow1 = DB_fetch_array($result1)) {
267		if (isset($_POST['StockCat']) and $myrow1['categoryid'] == $_POST['StockCat']) {
268			echo '<option selected="selected" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
269		} else {
270			echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
271		}
272	}
273	echo '</select></td>
274			<td>' . _('Enter text extracts in the') . ' <b>' . _('description') . '</b>:</td>
275			<td><input type="text" name="Keywords" size="20" maxlength="25" /></td>
276		</tr>
277		<tr>
278			<td></td>
279			<td><b>' . _('OR') . ' </b>' . _('Enter extract of the') . '<b> ' . _('Stock Code') . '</b>:</td>
280			<td><input type="text" name="StockCode" size="20" maxlength="25" /></td>
281		</tr>
282		<tr>
283			<td colspan="3">
284				<div class="centre">
285					<input type="submit" name="SearchParts" value="' . _('Search Parts Now') . '" />
286					<input type="submit" name="ResetPart" value="' . _('Show All') . '" />
287				</div>
288			</td>
289		</tr>
290		</table>
291		<br />
292		<br />';
293
294	if (isset($StockItemsResult)) {
295		echo '<table class="selection">
296			<thead>
297				<tr>
298							<th class="ascending">' . _('Code') . '</th>
299							<th class="ascending">' . _('Description') . '</th>
300							<th class="ascending">' . _('On Hand') . '</th>
301							<th class="ascending">' . _('Units') . '</th>
302				</tr>
303			</thead>
304			<tbody>';
305
306		while ($myrow = DB_fetch_array($StockItemsResult)) {
307			echo '<tr class="striped_row">
308				<td><input type="submit" name="SelectedStockItem" value="' . $myrow['stockid'] . '"</td>
309				<td>' . $myrow['description'] . '</td>
310				<td class="number">' . locale_number_format($myrow['qoh'],$myrow['decimalplaces']) . '</td>
311				<td>' . $myrow['units'] . '</td>
312				</tr>';
313		}
314		//end of while loop
315		echo '</tbody></table>';
316	}
317	//end if stock search results to show
318	else {
319		$FromDate = FormatDateForSQL($_POST['FromDate']);
320		$ToDate = FormatDateForSQL($_POST['ToDate']);
321		if (isset($LotNumber) AND $LotNumber != '') {
322			$SQL = "SELECT sampleid,
323							prodspeckey,
324							description,
325							lotkey,
326							identifier,
327							createdby,
328							sampledate,
329							cert
330						FROM qasamples
331						LEFT OUTER JOIN stockmaster on stockmaster.stockid=qasamples.prodspeckey
332						WHERE lotkey='" . filter_number_format($LotNumber) . "'";
333		} elseif (isset($SampleID) AND $SampleID != '') {
334			$SQL = "SELECT sampleid,
335							prodspeckey,
336							description,
337							lotkey,
338							identifier,
339							createdby,
340							sampledate,
341							cert
342						FROM qasamples
343						LEFT OUTER JOIN stockmaster on stockmaster.stockid=qasamples.prodspeckey
344						WHERE sampleid='" . filter_number_format($SampleID) . "'";
345		} else {
346			if (isset($SelectedStockItem)) {
347				$SQL = "SELECT sampleid,
348							prodspeckey,
349							description,
350							lotkey,
351							identifier,
352							createdby,
353							sampledate,
354							cert
355						FROM qasamples
356						INNER JOIN stockmaster on stockmaster.stockid=qasamples.prodspeckey
357						WHERE stockid='" . $SelectedStockItem . "'
358						AND sampledate>='".$FromDate."'
359						AND sampledate <='".$ToDate."'";
360			} else {
361				$SQL = "SELECT sampleid,
362							prodspeckey,
363							description,
364							lotkey,
365							identifier,
366							createdby,
367							sampledate,
368							comments,
369							cert
370						FROM qasamples
371						LEFT OUTER JOIN stockmaster on stockmaster.stockid=qasamples.prodspeckey
372						WHERE sampledate>='".$FromDate."'
373						AND sampledate <='".$ToDate."'";
374			} //no stock item selected
375		} //end no sample id selected
376		$ErrMsg = _('No QA samples were returned by the SQL because');
377		$SampleResult = DB_query($SQL, $ErrMsg);
378		if (DB_num_rows($SampleResult) > 0) {
379
380			echo '<table cellpadding="2" width="90%" class="selection">
381				<thead>
382					<tr>
383								<th class="ascending">' . _('Enter Results') . '</th>
384								<th class="ascending">' . _('Specification') . '</th>
385								<th class="ascending">' . _('Description') . '</th>
386								<th class="ascending">' . _('Lot / Serial') . '</th>
387								<th class="ascending">' . _('Identifier') . '</th>
388								<th class="ascending">' . _('Created By') . '</th>
389								<th class="ascending">' . _('Sample Date') . '</th>
390								<th class="ascending">' . _('Comments') . '</th>
391								<th class="ascending">' . _('Cert Allowed') . '</th>
392					</tr>
393				</thead>
394				<tbody>';
395
396			while ($myrow = DB_fetch_array($SampleResult)) {
397				$ModifySampleID = $RootPath . '/TestPlanResults.php?SelectedSampleID=' . $myrow['sampleid'];
398				$Edit = '<a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?SelectedSampleID=' . $myrow['sampleid'] .'">' . _('Edit') .'</a>';
399				$Delete = '<a href="' .htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8')  .'?delete=yes&amp;SelectedSampleID=' . $myrow['sampleid'].'" onclick="return confirm(\'' . _('Are you sure you wish to delete this Sample ID ?') . '\');">' . _('Delete').'</a>';
400				$FormatedSampleDate = ConvertSQLDate($myrow['sampledate']);
401
402				//echo '<div class="centre"><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?CopyTest=yes&amp;SelectedSampleID=' .$SelectedSampleID .'">' . _('Copy These Results') . '</a></div>';
403				//echo '<div class="centre"><a target="_blank" href="'. $RootPath . '/PDFTestPlan.php?SelectedSampleID=' .$SelectedSampleID .'">' . _('Print Testing Worksheet') . '</a></div>';
404				if ($myrow['cert']==1) {
405					$CertAllowed='<a target="_blank" href="'. $RootPath . '/PDFCOA.php?LotKey=' .$myrow['lotkey'] .'&ProdSpec=' .$myrow['prodspeckey'] .'">' . _('Yes') . '</a>';
406				} else {
407					$CertAllowed=_('No');
408				}
409
410				echo '<tr class="striped_row">
411						<td><a href="' . $ModifySampleID . '">' . str_pad($myrow['sampleid'],10,'0',STR_PAD_LEFT) . '</a></td>
412						<td>' . $myrow['prodspeckey'] . '</td>
413						<td>' . $myrow['description'] . '</td>
414						<td>' . $myrow['lotkey'] . '</td>
415						<td>' .  $myrow['identifier']  . '</td>
416						<td>' .  $myrow['createdby']  . '</td>
417						<td>' . $FormatedSampleDate . '</td>
418						<td>' . $myrow['comments'] . '</td>
419						<td>' . $CertAllowed . '</td>
420						<td>' . $Edit . '</td>
421						<td>' . $Delete . '</td>
422						</tr>';
423			} //end of while loop
424			echo '</tbody></table>';
425		} // end if Pick Lists to show
426	}
427	echo '</div>
428		  </form>';
429} //end of ifs and buts!
430
431if (isset($SelectedSampleID)) {
432	echo '<div class="centre"><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">' . _('Show All Samples') . '</a></div>';
433
434}
435
436if (! isset($_GET['delete'])) {
437
438	echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">';
439    echo '<div>';
440	echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
441
442	if (isset($SelectedSampleID)) {
443
444		$sql = "SELECT prodspeckey,
445						lotkey,
446						identifier,
447						comments,
448						cert,
449						sampledate
450				FROM qasamples
451				WHERE sampleid='".$SelectedSampleID."'";
452
453		$result = DB_query($sql);
454		$myrow = DB_fetch_array($result);
455
456		$_POST['ProdSpecKey'] = $myrow['prodspeckey'];
457		$_POST['LotKey'] = $myrow['lotkey'];
458		$_POST['Identifier'] = $myrow['identifier'];
459		$_POST['Comments'] = $myrow['comments'];
460		$_POST['SampleDate'] = ConvertSQLDate($myrow['sampledate']);
461		$_POST['Cert'] = $myrow['cert'];
462
463		echo '<input type="hidden" name="SelectedSampleID" value="' . $SelectedSampleID . '" />';
464		echo '<table class="selection">
465				<tr>
466					<td>' . _('Sample ID') . ':</td>
467					<td>' . str_pad($SelectedSampleID,10,'0',STR_PAD_LEFT)  . '</td>
468				</tr>';
469
470		echo '<tr>
471				<td>' . _('Specification') . ':</td>
472				<td>' . $_POST['ProdSpecKey']. '</td>
473			</tr>
474			<tr>
475				<td>' . _('Lot') . ':</td>
476				<td>' . $_POST['LotKey']. '</td>
477			</tr>
478			<tr>
479				<td>' . _('Identifier') . ':</td>
480				<td><input type="text" name="Identifier" size="10" maxlength="10" value="' . $_POST['Identifier']. '" /></td>
481			</tr>
482			<tr>
483				<td>' . _('Comments') . ':</td>
484				<td><input type="text" name="Comments" size="30" maxlength="255" value="' . $_POST['Comments']. '" /></td>
485			</tr>
486			<tr>
487				<td>' . _('Sample Date') . ':</td>
488				<td><input class="date" type="text" name="SampleDate" size="10" maxlength="10" value="' . $_POST['SampleDate']. '" /></td>
489			</tr>
490			<tr>
491				<td>' . _('Use for Cert?') . ':</td>
492				<td><select name="Cert">';
493		if ($_POST['Cert']==1){
494			echo '<option selected="selected" value="1">' . _('Yes') . '</option>';
495		} else {
496			echo '<option value="1">' . _('Yes') . '</option>';
497		}
498		if ($_POST['Cert']==0){
499			echo '<option selected="selected" value="0">' . _('No') . '</option>';
500		} else {
501			echo '<option value="0">' . _('No') . '</option>';
502		}
503		echo '</select></td></tr>
504			</table>
505			<br />
506			<div class="centre">
507				<input type="submit" name="submit" value="' . _('Enter Information') . '" />
508			</div>
509			</div>
510			</form>';
511
512	} else { //end of if $SelectedSampleID only do the else when a new record is being entered
513		if (!isset($_POST['Cert'])) {
514			$_POST['Cert']=0;
515		}
516		echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">';
517		echo '<div>';
518		echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
519		echo '<table class="selection">';
520		$SQLSpecSelect="SELECT DISTINCT(keyval),
521								description
522							FROM prodspecs LEFT OUTER JOIN stockmaster
523							ON stockmaster.stockid=prodspecs.keyval";
524
525		$ResultSelection=DB_query($SQLSpecSelect);
526		echo '<tr>
527				<td>' . _('Specification') . ':</td>';
528		echo '<td><select name="ProdSpecKey">';
529		while ($MyRowSelection=DB_fetch_array($ResultSelection)){
530			echo '<option value="' . $MyRowSelection['keyval'] . '">' . $MyRowSelection['keyval'].' - ' .htmlspecialchars($MyRowSelection['description'], ENT_QUOTES,'UTF-8', false)  . '</option>';
531		}
532		echo '</select></td>
533			</tr>
534			<tr>
535				<td>' . _('Lot') . ':</td>
536				<td><input type="text" required="required" name="LotKey" size="25" maxlength="25" value="' . (isset($_POST['LotKey'])? $_POST['LotKey']:'') . '" /></td>
537			</tr>
538			<tr>
539				<td>' . _('Identifier') . ':</td>
540				<td><input type="text" name="Identifier" size="10" maxlength="10" value="' . (isset($_POST['Identifier'])? $_POST['Identifier']:'') . '" /></td>
541			</tr>
542			<tr>
543				<td>' . _('Comments') . ':</td>
544				<td><input type="text" name="Comments" size="30" maxlength="255" value="' . (isset($_POST['Comments'])? $_POST['Comments']:'') . '" /></td>
545			</tr>
546			<tr>
547				<td>' . _('Use for Cert?') . ':</td>
548				<td><select name="Cert">';
549		if ($_POST['Cert']==1){
550			echo '<option selected="selected" value="1">' . _('Yes') . '</option>';
551		} else {
552			echo '<option value="1">' . _('Yes') . '</option>';
553		}
554		if ($_POST['Cert']==0){
555			echo '<option selected="selected" value="0">' . _('No') . '</option>';
556		} else {
557			echo '<option value="0">' . _('No') . '</option>';
558		}
559		echo '</select></td></tr>';
560		echo '<tr>
561				<td>' . _('Duplicate for Lot OK?') . ':</td>
562				<td><select name="DuplicateOK">';
563		if ($_POST['DuplicateOK']==1){
564			echo '<option selected="selected" value="1">' . _('Yes') . '</option>';
565		} else {
566			echo '<option value="1">' . _('Yes') . '</option>';
567		}
568		if ($_POST['DuplicateOK']==0){
569			echo '<option selected="selected" value="0">' . _('No') . '</option>';
570		} else {
571			echo '<option value="0">' . _('No') . '</option>';
572		}
573		echo '</select></td></tr>
574			</table>
575			<br />
576			<div class="centre">
577				<input type="submit" name="submit" value="' . _('Enter Information') . '" />
578			</div>
579			</div>
580			</form>';
581	}
582} //end if record deleted no point displaying form to add record
583
584include('includes/footer.php');
585?>