<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");
include("Functions_Purchase.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

							
$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];} 
$message 	= $_POST["message"]; if ($message == ""){$message = $_GET["message"];} 

$salesJvId = $_GET['jvId'];
  
print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<title>Remark</title>
<script type="text/javascript" language="javascript">
function setremark(vId){
	if(document.getElementById('remarkchk'+vId).checked)
		document.getElementById('remarkchk'+vId).value=1;
	else
		document.getElementById('remarkchk'+vId).value=0;
}

function SubmitForm(){
	document.remarkdt.action = 'Form_SalesJV_Actions.php?actionmode=addRemark&salesJvId='+document.remarkdt.salesJvId.value;
	document.remarkdt.submit();	
}

</script>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}

.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; }
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}

.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #000000 ;font-size: 10px;}

</style>

</head>
<body class='bodybackground'>
<form name='remarkdt' method='post' action=''>
<input type='hidden' name='salesJvId' id='salesJvId' value='$salesJvId'>		    
HERE;




echo"<table cellpadding='0' cellspacing='0' border='0'  align='left' style='table-layout:fixed' >";
echo"<tr>
		<td id='search-top1' style='height:34px; width:31px;'>&nbsp;</td>
	  	<td id='search-top2' style='height:34px; width:690px' align='center' valign='middle'>
			<table border='0'>
			<tr><td><span class='style3'>Remark
			</span></td></tr>
			</table>
		</td>
		<td id='search-top3' style='height:34px; width:31px;'>&nbsp;</td>
	</tr>";

echo"<tr><td id='search-content1' style='width:31px;'>&nbsp;</td>
		 <td id='search-content2' >";
echo"<table border='0' style='table-layout:fixed'>
	  <col width=120>
	  <col width=120>
	  <col width=100>
	  <col width=100>
	  <col width=100>
	  <col width=130>
		     
 <tr bgcolor='#F7F7F7'>	
	    <td height='20' align='center' colspan='6'>&nbsp;</td> 
	  </tr>
	  <tr class='Search-header-bg'>
		<td align='center' colspan='6'><span class='style4'>
			 <button type='button' id='btnSubmit' name='btnSubmit' onclick='SubmitForm(); return false;' title='Submit'><span><span>Submit</span></span></button>
			
		</span></td>
      </tr>
	  <tr class='Search-header-bg'>
		<td height='15' align='center' colspan='6'><font size='1' color='#FF0000' face='Verdana'><b>".$message."</b></font></td>
	  </tr>	";
$query = "select setup_id, remark_description from sorderJv_RemarkSetup order by remark_description";
$result = mysql_query($query,$connection);

while($row = mysql_fetch_array($result)){
	$remarkchk = 'remarkchk'.$row[0];
	$$remarkchk = 1;
	
	$querychk = "select salesJvRemarkdt_chk from temp_salesJvRemarkdt where salesJv_id = $salesJvId and Remarkdt_id = $row[0] ";
	$reschk = mysql_query($querychk,$connection);
	$numr = mysql_num_rows($reschk);
	$rowchk = mysql_fetch_row($reschk);
	if($numr>0) $$remarkchk = $rowchk[0];
	
	echo "<tr><td colspan='2'>$row[1]</td>
			<td><input type='checkbox' id='$remarkchk' name='$remarkchk' value='".$$remarkchk."' ".($$remarkchk==1?'checked':'')." onclick=\"setremark('$row[0]');\"></td>
		</tr>";
}


echo"   </table><td id='search-content3' style='width:31px;'>&nbsp;</td></tr>
	  <tr >
		<td id='search-bottom1' style='height:34px; width:31px;'>&nbsp;</td>
		<td id='search-bottom2' style='height:34px; ' valign='top'><td id='search-bottom3' style='height:34px; width:31px;'>&nbsp;</td></tr></table>";

print <<<HERE
</form>
</body>

HERE;

?>