Skip to content

Commit

Permalink
Added in the new fields for the linked list of panels and updated the…
Browse files Browse the repository at this point in the history
… input screen. Leaving the Power Source in for now since we won't have time to remove all elements of that before 4.0-release. Also wrote a conversion script to create panels that match the existing sources and set the ParentPanelID on all of the children to point that way. In the next release we'll drop the column from the db and remove the table for PowerSource.

#553
  • Loading branch information
samilliken committed Mar 28, 2015
1 parent eaf1bee commit cc6ffc0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
15 changes: 15 additions & 0 deletions panelconversion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require_once( "db.inc.php" );
require_once( "facilities.inc.php" );

$ss = $dbh->prepare( "select * from fac_PowerSource" );
$ss->setFetchMode( PDO::FETCH_CLASS, "PowerSource" );
$ss->execute();

$ps = $dbh->prepare( "insert into fac_PowerPanel set PanelLabel=:PanelLabel" );
$us = $dbh->prepare( "update fac_PowerPanel set ParentPanelID=:PanelID where PowerSourceID=:SourceID" );
while ( $row = $ss->fetch() ) {
$ps->execute( array( ":PanelLabel"=>$row->SourceName ));
$us->execute( array( ":PanelID"=>$dbh->LastInsertId(), ":SourceID"=>$row->PowerSourceID ) );
}
?>
4 changes: 2 additions & 2 deletions power.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ function MakeSafe(){
$this->PanelVoltage=intval($this->PanelVoltage);
$this->NumberScheme=($this->NumberScheme=='Sequential')?$this->NumberScheme:'Odd/Even';
$this->ParentPanelID=intval($this->ParentPanelID);
$this->ParentBreakerID=sanitize($this->ParentBreakerID;
$this->ParentBreakerID=sanitize($this->ParentBreakerID);
}

function MakeDisplay(){
Expand Down Expand Up @@ -1432,7 +1432,7 @@ function CreatePanel(){
":NumberOfPoles"=>$this->NumberOfPoles,
":MainBreakerSize"=>$this->MainBreakerSize,
":PanelVoltage"=>$this->PanelVoltage,
":NumberScheme"=>this->NumberScheme,
":NumberScheme"=>$this->NumberScheme,
":ParentPanelID"=>$this->ParentPanelID,
":ParentBreakerID"=>$this->ParentBreakerID ))){
$this->PanelID=$dbh->lastInsertId();
Expand Down
20 changes: 20 additions & 0 deletions power_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
$panel->MainBreakerSize=$_POST["mainbreakersize"];
$panel->PanelVoltage=$_POST["panelvoltage"];
$panel->NumberScheme=$_POST["numberscheme"];
$panel->ParentPanelID=$_POST["parentpanelid"];
$panel->ParentBreakerID=$_POST["parentbreakerid"];

if($_POST["action"]=="Create"){
$panel->CreatePanel();
Expand Down Expand Up @@ -156,6 +158,24 @@
</select>
</div>
</div>
<div>
<div label for="parentpanelid"><?php print __("Parent Panel"); ?></label></div>
<div><select name="parentpanelid" id="parentpanelid">
<?php
foreach ( $panelList as $pnl ) {
$selected = $pnl->PanelID == $panel->ParentPanelID ? "selected" : "";
// Avoid making medieval royalty - panels that are children of themselves
if ( $panel->PanelID != $pnl->PanelID ) {
print "<option value='$pnl->PanelID' $selected>$pnl->PanelLabel</option>\n";
}
}
?>
</select></div>
</div>
<div>
<div label for="parentbreakerid"><?php print __("Parent Breaker ID"); ?></label></div>
<div><input type="text" name="parentbreakerid" id="parentbreakerid" size="40" value="<?php print $panel->ParentBreakerID; ?>"></div>
</div>
<div class="caption">
<?php
if($panel->PanelID >0){
Expand Down
8 changes: 8 additions & 0 deletions unauthorized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Unauthorized</title>
</head>
<body>
<h1>UserID not found in the database for authorized access. Please contact your site administrator if this is in error.</h1>
</body>
</html>

0 comments on commit cc6ffc0

Please sign in to comment.