ERROR - Couldn't execute location query");
$idarray = array(); $locarray = array();
if(pg_num_rows($locres) != 0){
while ($locrow = pg_fetch_array($locres)){
extract($locrow);
$idarray[] = $loc_id;
$locarray[] = $name;
}
} else die (" ERROR: cannot get the list of current locations.");
print "
Low Voltage:
";
print "Insert a new Wiener PSU into table psu of gateDB (use 'NULL' for empty record):";
$WienerPars = array('serial','bin','location','type','status','mac_addr','firmware');
$NumPars = sizeof($WienerPars);
echo '
when located in a LV bin, the bin and Wiener types must match!";
print "
the 'bin' and 'location' entries are mutually exclusive: one must be 'NULL'";
print "and the other one not.
";
print "
High Voltage:
";
print "Insert a new ISEG PSU into table psuhv of gateDB (use 'NULL' for empty record):";
$IsegPars = array('serial','sm','location','type','channels','status','firmware');
$NumPars = sizeof($IsegPars);
echo '
enter the SM sector (0-17) in TRD (convertion to SM serial is done internally).";
print "
the 'sm' and 'location' entries are mutually exclusive: one must be 'NULL' and the other one not.";
print "
when a HV module supplies power to a SM, please locate it to that SM, rather than placing it on location CR4; when a HV module has a non-NULL SM serial, it is linked to the rest of the TRD components in gateDB (joint queries are possible).";
print "
status is a (short) string; please use 'Add comment' link for individual PSUs for long strings.";
print "
";
}
?>
ERROR: serial cannot be NULL!";
print " Back";
exit;
}
$serial=$_POST['serial'];
// process Wiener location:
if (!$_POST['bin'] || !$_POST['loc']){
print " ERROR: Please enter either a bin location OR a physical location! For the one not filled specify 'NULL'.";
print " Examples: bin='I28-33' and location='NULL' or bin='NULL' and location='10'";
print " Back";
exit;
} else if($_POST['bin']!='NULL' && $_POST['loc']!='NULL'){
print " ERROR: a Wiener cannot be located in both a bin and at a physical location - one of them must be NULL!";
print " Back";
exit;
} else if($_POST['bin']!='NULL' && $_POST['loc']=='NULL'){
$rack_id=substr($_POST['bin'],0,3);
$height=substr($_POST['bin'],4,2);
$loc='NULL';
} else if($_POST['bin']=='NULL' && $_POST['loc']!='NULL'){
$rack_id='NULL';
$height='NULL';
$loc=$_POST['loc'];
}
// process the other attributes:
if(!$_POST['status']) {
print " WARNING: Wiener status not entered! Default value 'LeakFixed' will be used.";
$status='LeakFixed';
} else {
$status=$_POST['status'];
}
if(!$_POST['type']) {
print " WARNING: Wiener type not entered! Default value 0 will be used.";
$type='0';
} else {
$type=$_POST['type'];
}
if(!$_POST['mac'] || $_POST['mac']=='NULL'){
print " ERROR: Please enter MAC address! It cannot be NULL.";
print " Back";
exit;
}
$mac=$_POST['mac'];
if(!$_POST['firmware']) {
print " ERROR: Please enter the firmware version! It can be NULL.";
print " Back";
exit;
}
$firmware=$_POST['firmware'];
print "Inserting following new Wiener LV PSU:";
$InsertPars =array('serial','rack_id','height','location','status','type','mac_addr','firmware','person');
$NumPars = sizeof($InsertPars);
echo '
'; // close table
print " If this is not what you intended, please go back and change it!";
print " If it looks OK, commit it:";
print '';
} // new Wiener PSU (low voltage)
?>
ERROR: PSU serial cannot be NULL!";
print " Back";
exit;
}
$psuhv_id = $_POST['hvser'];
if(!$_POST['hvsm'] || !$_POST['hvloc']){
print " ERROR: Please enter either a sm location OR a physical location! For the one not filled specify 'NULL'.";
print " Back";
exit;
} else if($_POST['hvsm']!='NULL' && $_POST['hvloc']!='NULL'){
print " ERROR: a PSU cannot be located in both a sm and at a physical location - one of them must be NULL!";
print " Back";
exit;
}
$sm_id = "NULL";
if(isset($_POST['hvsm']) && $_POST['hvsm']!='NULL'){ // query SM serial with this sector
$sql = "SELECT sm_id FROM sm WHERE trd_pos=".$_POST['hvsm'];
$smres = pg_query($sql) or die (" ERROR: Cannot execute SM query:".$sql);
if(pg_num_rows($smres) != 0){
$smrow = pg_fetch_array($smres);
$sm_id = $smrow['sm_id'];
} else die (" ERROR: did not find the SM serial for sector ".$_POST['hvsm']);
}
$type=$_POST['hvtype'];
$chann=$_POST['hvchann'];
$loc_id=$_POST['hvloc'];
$firmware=$_POST['hvfirmware'];
$status=$_POST['hvstatus'];
print "Inserting following new ISEG HV PSU:";
$InsertPars =array('serial','sm_id','location','type','channels','status','firmware','person');
$NumPars = sizeof($InsertPars);
echo '
'; // close table
print " If this is not what you intended, please go back and change it!";
print " If it looks OK, commit it:";
print '';
} // new ISEG PSU (high voltage)
?>