You are about to insert: ROB #".$_REQUEST['serial'];
$message .= ", type ".$_REQUEST['type']."
\n";
} else if ($_REQUEST['item_type'] == 'roc') {
$message .= "You are about to insert: ROC ";
$message .= $_REQUEST['type']."_".$_REQUEST['serial'];
} else if ($_REQUEST['item_type'] == 'dcs') {
$message .= "
";
} else {
echo "Successfully entered F".$_REQUEST["form"].
"_T".$_REQUEST["type"].
"_V".$_REQUEST["ver"].
"_N".$_REQUEST["serial"].
" into database. Current location is ".
$_REQUEST["loc"]."\n";
}
} else if ($_REQUEST["item_type"] == 'roc') {
$query = "INSERT INTO roc(roc_type,roc_serial,loc_id,person) VALUES ".
"('".$_REQUEST["type"]."',".$_REQUEST["serial"].",".
"(SELECT loc_id FROM loc WHERE name='".$_REQUEST["loc"]."'),'".
$_SESSION["person"]."');";
$result = pg_query ($query);
if ( ! $result )
echo "You are about to insert: DCS Board #".$_REQUEST['serial'];
$message .= "
\n";
} else if ($_REQUEST['item_type'] == 'ori') {
$message .= "You are about to insert: ORI_V".$_REQUEST['version'].
"_N".$_REQUEST['serial'];
$message .= "
\n";
} else if ($_REQUEST['item_type'] == 'oricfg') {
$message .= "You are about to insert: configuration for ORI ".$_REQUEST['cfgser'];
$message .= "
\n";
} else if ($_REQUEST['item_type'] == 'loc') {
$message .= "You are about to insert a new location:".$_REQUEST['name'];
$message .= "
\n";
}
gate_check_confirmation("insert.php",$message);
?>
Insertion of new item
Insertion failedInsertion failed
";
else
echo "Successfully entered " .$_REQUEST["type"]."_".$_REQUEST["serial"].
" into database. Current location is ".
$_REQUEST["loc"]."\n";
} else if ($_REQUEST["item_type"] == 'dcs') {
$query = "INSERT INTO dcs(dcs_id,type,loc_id,person) VALUES ".
"(".$_REQUEST["serial"].",'".$_REQUEST["type"]."',".
"(SELECT loc_id FROM loc WHERE name='".$_REQUEST["loc"]."'),'".
$_SESSION["person"]."');";
$result = pg_query ($query);
if ( ! $result )
echo "Insertion failed
";
else
echo "Successfully entered DCS Board #".$_REQUEST["serial"].
" into database. Current location is ".
$_REQUEST["loc"]."\n";
} else if ($_REQUEST["item_type"] == 'ori') {
$query = "INSERT INTO ori(ori_id,version,rob_id,loc_id,person) VALUES "."(".$_REQUEST["serial"].",'".$_REQUEST["version"]."',";
if($_REQUEST["robID"]=='rob_id' || $_REQUEST["robID"]=='')
$query .= "NULL,(SELECT loc_id FROM loc WHERE name='".$_REQUEST["loc"]."'),'";
else
$query .= "'".$_REQUEST["robID"]."',NULL,'";
$query .= $_SESSION["person"]."');";
$result = pg_query ($query);
if(!$result){
echo "Insertion failed
";
print "Query:".$query; } else echo "Successfully entered ". hrefname("ORI_V".$_REQUEST["version"]."_N".$_REQUEST["serial"])." into database.\n"; } else if ($_REQUEST["item_type"] == 'oricfg') { if(!isset($_REQUEST["cfgser"])){ print "
Please specify the serial of the ORI to be updated!
";
exit(0);
}
$qori="SELECT ori_id FROM ori WHERE ori_id=".$_REQUEST["cfgser"];
$rori = pg_query($qori);
if(!$rori) {print "ERROR: ORI table query failed!"; exit(0);} $row = pg_fetch_assoc($rori); if($row['ori_id']<1) { print "
Update failed: serial no. ".$_REQUEST["cfgser"]." does not exist in the ORI table. Please go back and insert it first!
";
exit(0);
}
$qcfg = "UPDATE oricfg SET";
if(isset($_REQUEST["cpldver"])) $qcfg .= " cpld_version=".$_REQUEST["cpldver"].",";
if(isset($_REQUEST["threshc"]) && $_REQUEST["threshc"]>0)
$qcfg .= " thrshld_curr=".$_REQUEST["threshc"].",";
if(isset($_REQUEST["lsrrdyn"]) && $_REQUEST["lsrrdyn"]>0)
$qcfg .= " lsrdiod_rdyn=".$_REQUEST["lsrrdyn"].",";
if(isset($_REQUEST["slimdib"]) && $_REQUEST["slimdib"]>0)
$qcfg .= " slope_imd_ib=".$_REQUEST["slimdib"].",";
if(isset($_REQUEST["raopimd"]) && $_REQUEST["raopimd"]>0)
$qcfg .= " ratio_op_imd=".$_REQUEST["raopimd"].",";
for($idx=0; $idx<16; $idx++){
$register = "reg".$idx;
$regname = "reg".$idx; if($idx<10) $regname = "reg0".$idx;
if(isset($_REQUEST[$register]) &&$_REQUEST[$register]>0)
$qcfg .= " ".$regname."=".$_REQUEST[$register].",";
}
$qcfg .= " person='".$_REQUEST["person"]."'";
$qcfg .= " WHERE ori_id=".$_REQUEST["cfgser"];
$rcfg = pg_query($qcfg);
if(!$rcfg) print "Update failed!
SQL: ".$qcfg; else print "
Successfully commited ORI configuration!
\n"; } else if ($_REQUEST["item_type"] == 'loc') { $query = "INSERT INTO loc(name,description) VALUES ". "('".$_REQUEST["name"]."','".$_REQUEST["desc"]."');"; $result = pg_query ($query); if ( ! $result ) echo "Insertion failed
";
else
echo "Successfully entered location '". $_REQUEST["name"]."' into database.
\n"; } else { echo 'Insertion of unknown item type '.
$_REQUEST["item_type"].' failed!
';
require('gate_footer.php');
exit(1);
}
?>