Location: PHPKode > projects > MyZCI > myzci/supervisor/add_reserve.php
<?
include "../zciconfig.php";
include "../engine/zciobject.php";
include "header_include.php";
include "../langconfig.php";
include "../lang/".$Lang.".php";

$masterconf = new masterconfig();
//make database connection
$mydbcon = $masterconf->dbconnect();
$master = new masterobject();
$master->authenticate();
?>
<html><head>
<meta Http-Equiv="Cache-Control" Content="no-cache">
<meta Http-Equiv="Pragma" Content="no-cache">
<meta Http-Equiv="Expires" Content="0">
<link rel=stylesheet type=text/css href="../frontend/content.css">
</head>
<body>
<? echo insertheader();?>
<form id=myform method=post action=add_reserve.php?type=insert style=margin-top:0>
<table width=100% border=1>
<tr><td class=contenttitle colspan=3><? echo $lng_add_dev_res ?></td></tr>
<tr><td width=20%><? echo $lng_sel_dev_type ?></td><td><select id=devtype_select name=devtype onchange="javascript:activedevmodels(myform,pnew_model)"><option value=2><? echo $lng_peripheral ?></option><option value=1><? echo $lng_display ?></option></select></td></tr>
<tr><td><? echo $lng_sel_model_name ?></td>
<td><select id=monitor_models name=mon_value style=display:none>
<?
$result=dbx_query($mydbcon,"select modelid,name from monitor_category order by name");
for ($i=0;$i<$result->rows;$i++) echo "\n<option value=".$result->data[$i][0].">".$result->data[$i][1]."</option>";
?>
</select>
<select id=peripheral_models name=phr_value>
<?
if (isset($_POST['devtype']))	{
	if ($_POST['devtype']==1)	{
		$modelid=$_POST['mon_value'];
		$table="monitor";
	}
	else	{
		if ($_POST['flag_newmodel']==2)	{
			$colnames[0]="name";$colvalues[0]="'".$_POST['new_model']."'";
			$modelid=$master->getid($mydbcon,"peripheral_category",$colnames,$colvalues);
		}
		else	$modelid=$_POST['phr_value'];
		$table="peripheral";
	}
}

$result=dbx_query($mydbcon,"select modelid,name from peripheral_category order by name");
for ($i=0;$i<$result->rows;$i++) echo "\n<option value=".$result->data[$i][0].">".$result->data[$i][1]."</option>";
?>
</select></td></tr>
<tr id=pnew_model><td colspan=2><input type=checkbox value=2 name=flag_newmodel onclick="javascript:new_model_control(this,peripheral_models,new_model_value)"> <? echo $lng_or_enter_new_model ?>
<input type=text disabled=true name=new_model size=100 id=new_model_value>
<p class=myremark style=margin-top:0;font-size:12><? echo $lng_add_res_msg ?></p>
</td></tr>
<tr><td><? echo $lng_own_type ?></td><td><select name=ownership><option value=1000><? echo $lng_1000 ?></option><option value=2000><? echo $lng_2000 ?></option></select>
<? echo "<input type=submit value=".$lng_submit_changes_btn."> <input type=reset value=".$lng_cancel_btn.">" ?></td></tr>
</table>

<?
if (isset($_GET['type'])&& $_GET['type']="insert")	{
	$result=dbx_query($mydbcon,"select name from ".$table."_category where modelid=".$modelid);
	echo "<hr><center><button onclick=\"javascript:result_control(result_table.style)\" type=button>".$lng_show_hide_result." ".$result->data[0][0]."</button>";
	echo "<table id=result_table border=1 style=margin-top:2><tr class=catgmenu><th>".$lng_num."</th><th>".$lng_sn."</th><th>".$lng_result."</th><th>".$lng_num."</th><th>".$lng_sn."</th><th>".$lng_result."</th></tr>";
	$newline=true;
	for ($i=0;$i<20;$i++)	{
		if ($_POST['sn'][$i]=="")	continue;
		$sn=strtoupper($_POST['sn'][$i]);
		if ($newline) echo "<tr>";
		$newline=!$newline;
		echo "<td align=center>".($i+1)."</td><td>".$sn."</td><td>";
		if (preg_match("/[1-9].*[1-9]/",$_POST['sn'][$i]) && !preg_match("/123456789/",$_POST['sn'][$i]))	{
			$result=dbx_query($mydbcon,"select itemid from ".$table." where modelid=".$modelid." and serialnumber='".$sn."'");
			if ($result->rows==0)	{
				dbx_query($mydbcon,"insert into ".$table." (modelid,serialnumber,registerdate,reserved) values (".$modelid.",'".$sn."',now(),'Y')");
				$result=dbx_query($mydbcon,"select itemid from ".$table." where modelid=".$modelid." and serialnumber='".$_POST['sn'][$i]."'");
				dbx_query($mydbcon,"insert into ownership_".$table." (componentid,modelid,registerdate) values (".$result->data[0][0].",".$_POST['ownership'].",now())");
				echo $lng_add_new_device;
			}
			else	echo $lng_dev_exists;
		}
		else	echo $lng_sn_incorr;
		echo "</td>";
		if ($newline)	echo "</tr>";
	}
	echo "</table></center>";
}
dbx_close($mydbcon);
?>
<hr>
<table border=1 width=100%>
<tr class=myth><th><? echo $lng_num ?></th><th><? echo $lng_sn_add ?></th></tr>
<tr><td width=3%>1</td><td><input type=text size=100 name=sn[0]></td></tr>
<tr><td>2</td><td><input type=text size=100 name=sn[1]></td></tr>
<tr><td>3</td><td><input type=text size=100 name=sn[2]></td></tr>
<tr><td>4</td><td><input type=text size=100 name=sn[3]></td></tr>
<tr><td>5</td><td><input type=text size=100 name=sn[4]></td></tr>
<tr><td>6</td><td><input type=text size=100 name=sn[5]></td></tr>
<tr><td>7</td><td><input type=text size=100 name=sn[6]></td></tr>
<tr><td>8</td><td><input type=text size=100 name=sn[7]></td></tr>
<tr><td>9</td><td><input type=text size=100 name=sn[8]></td></tr>
<tr><td>10.</td><td><input type=text size=100 name=sn[9]></td></tr>
<tr><td>11</td><td><input type=text size=100 name=sn[10]></td></tr>
<tr><td>12</td><td><input type=text size=100 name=sn[11]></td></tr>
<tr><td>13</td><td><input type=text size=100 name=sn[12]></td></tr>
<tr><td>14</td><td><input type=text size=100 name=sn[13]></td></tr>
<tr><td>15</td><td><input type=text size=100 name=sn[14]></td></tr>
<tr><td>16</td><td><input type=text size=100 name=sn[15]></td></tr>
<tr><td>17</td><td><input type=text size=100 name=sn[16]></td></tr>
<tr><td>18</td><td><input type=text size=100 name=sn[17]></td></tr>
<tr><td>19</td><td><input type=text size=100 name=sn[18]></td></tr>
<tr><td>20</td><td><input type=text size=100 name=sn[19]></td></tr>
</table></form>
<script language=javascript>
function activedevmodels(myobject,pnew_model)	{
	if (myobject.monitor_models.style.display=='none')	{
		myobject.monitor_models.style.display='inline';
		myobject.peripheral_models.style.display='none';
		pnew_model.style.display='none';
	}
	else	{
		myobject.monitor_models.style.display='none';
		myobject.peripheral_models.style.display='inline';
		pnew_model.style.display='block';
	}

}
function new_model_control(mycheckbox,selection,pnew_model)	{
	if (mycheckbox.checked)	{
		selection.disabled=true;
		pnew_model.disabled=false;
	}
	else	{
		selection.disabled=false;
		pnew_model.disabled=true;
	}
}
function result_control(myvalue)	{
	if (myvalue.display=="none")	myvalue.display="block";
	else myvalue.display="none";
}
</script>


	
</body>
</html>
	

		
Return current item: MyZCI