Location: PHPKode > projects > MyZCI > myzci/supervisor/add_peripheral.php
<?
include "../zciconfig.php";
include "../engine/zciobject.php";
$masterconf = new masterconfig();

$master = new masterobject();
$master->authenticate();

if ($_POST['ownership']!=0)	{
	//make database connection
	$mydbcon = $masterconf->dbconnect();

	//make object for common function
	$master = new masterobject();

	if ($_POST['flag_newmodel']==2)	{
		$colnames[0]="name";$colvalues[0]="'".$_POST['peripheral_name']."'";
		$peripheral_id=$master->getid($mydbcon,"peripheral_category",$colnames,$colvalues);
	}
	else	$peripheral_id=$_POST['phr_model'];

	$phr_sn=strtoupper($_REQUEST['peripheral_sn']);
	$result=dbx_query($mydbcon,"select itemid from peripheral where modelid=".$peripheral_id." and serialnumber='".$phr_sn."'");
	if ($result->rows==0)	{
		dbx_query($mydbcon,"insert into peripheral (modelid,serialnumber,invn,registerdate) values (".$peripheral_id.",'".$phr_sn."',now())");
		$result=dbx_query($mydbcon,"select itemid from peripheral where modelid=".$peripheral_id." and serialnumber='".$phr_sn."'");		
	}
	else	dbx_query($mydbcon,"update peripheral set reserved=null where itemid=".$result->data[0][0]);
	$master->singleupdate_phr($mydbcon,"ownership_peripheral",$_GET['compid'],$result->data[0][0],$_REQUEST['ownership']);
}
header("Location: computer_details_spvisor.php?compid=".$_REQUEST['compid']);
?>
Return current item: MyZCI