<?php
if($tbTN==''){

	  		$s="SELECT tbTN,tbReportNo,tbTestedID FROM ". $GLOBALS['prefix']->table('tested')." WHERE tbReportNo='" . $rep . "' AND tbTestedID='" . $tbTestedID . "' LIMIT 1";
			$exi=$GLOBALS['db']->getRow($s);
			if($exi !='')
		  	{
			$exist=true;
			require(str_replace('sicms','',dirname(__FILE__)) . '/includes/show_titem_bak.php');
	        echo json_encode($str);
		  	}else{
				   $exist=false;
				   $sql = "INSERT INTO ". $GLOBALS['prefix']->table('tested') . " (tbReportNo,tbTestedID,tbQty,tbResult,tbSpec,tbPosition) VALUES ('$rep','$tbTestedID','$tbQty','$tbTestResult','$tbSpec','$tbPosition')";
			}
		
		}else{
			$exist=false;
			$sql = "UPDATE ". $GLOBALS['prefix']->table('tested'). " SET" . " 
	tbReportNo='$rep',tbTestedID='$tbTestedID',tbQty='$tbQty',tbResult='$tbTestResult',tbSpec='$tbSpec',tbPosition='$tbPosition' WHERE tbTN='$tbTN'";
		}
?>