-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TAMULib/sprint10_02511
Sprint10 02511
- Loading branch information
Showing
11 changed files
with
532 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
class Downtime extends DatabaseObject { | ||
|
||
protected function defineRelationships() {} | ||
|
||
protected function overridePrimaryKeyName() {} | ||
|
||
public function load() { | ||
|
||
//This is a custom load method that joins the downtime type name into the attributes | ||
|
||
//if exists in the database | ||
if (isset($this->primaryKey)) { | ||
$query = "SELECT d.*, dt.name, i.subjectText | ||
FROM Downtime d | ||
LEFT JOIN DowntimeType dt ON dt.downtimeTypeID=d.downtimeTypeID | ||
LEFT JOIN Issue i ON i.issueID=d.issueID | ||
WHERE d.downtimeID={$this->primaryKey}"; | ||
|
||
$result = $this->db->processQuery($query, 'assoc'); | ||
|
||
foreach (array_keys($result) as $attributeName) { | ||
$this->addAttribute($attributeName); | ||
$this->attributes[$attributeName] = $result[$attributeName]; | ||
} | ||
|
||
}else{ | ||
// Figure out attributes from existing database | ||
$query = "SELECT COLUMN_NAME FROM information_schema.`COLUMNS` WHERE table_schema = '"; | ||
$query .= $this->db->config->database->name . "' AND table_name = '$this->tableName'";// MySQL-specific | ||
foreach ($this->db->processQuery($query) as $result) { | ||
$attributeName = $result[0]; | ||
$this->addAttribute($attributeName); | ||
} | ||
} | ||
} | ||
|
||
public function save() { | ||
|
||
//We have added the name attribute after the fact, and here, we are cleaning it up | ||
unset($this->attributes["name"]); | ||
unset($this->attributesNames["name"]); | ||
|
||
unset($this->attributes["subjectText"]); | ||
unset($this->attributesNames["subjectText"]); | ||
|
||
parent::save(); | ||
} | ||
|
||
public function getDowntimeTypesArray() { | ||
$query = "SELECT dt.* | ||
FROM DowntimeType dt"; | ||
|
||
$result = $this->db->processQuery($query, "assoc"); | ||
$names = array(); | ||
|
||
foreach ($result as $name) { | ||
array_push($names, $name); | ||
} | ||
|
||
return $names; | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
$util = new utility(); | ||
|
||
$resourceID = $_GET["resourceID"]; | ||
|
||
$resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID))); | ||
$issues = $resource->getIssues(); | ||
|
||
$organizationArray = $resource->getOrganizationArray(); | ||
$organizationData = $organizationArray[0]; | ||
|
||
if ($organizationData['organizationID']) { | ||
|
||
$organization = new Organization(new NamedArguments(array('primaryKey' => $organizationData['organizationID']))); | ||
|
||
$orgIssues = $organization->getIssues(); | ||
|
||
foreach ($orgIssues as $issue) { | ||
array_push($issues, $issue); | ||
} | ||
|
||
$downtimeObj = new Downtime(); | ||
$downtimeTypeNames = $downtimeObj->getDowntimeTypesArray(); | ||
|
||
$organizationContactsArray = $resource->organizationContactsArray($organizationData['organizationID']); | ||
$organizationResourcesArray = $resource->getSiblingResourcesArray($organizationData['organizationID']); | ||
|
||
$defaultStart = date("Y-m-d\TH:i"); | ||
$defaultEnd = date("Y-m-d\TH:i", strtotime("+1 day")); | ||
|
||
?> | ||
|
||
<form id='newDowntimeForm'> | ||
<input type="hidden" name="sourceOrganizationID" value="<?php echo $organizationData['organizationID'];?>" /> | ||
<input type="hidden" name="sourceResourceID" value="<?php echo $resourceID;?>" /> | ||
<table class="thickboxTable" style="width:98%;background-image:url('images/title.gif');background-repeat:no-repeat;"> | ||
<tr> | ||
<td colspan="2"> | ||
<h1> Resource Downtime Report</h1> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><label>Downtime Start:</label></td> | ||
<td> | ||
<input value="<?php echo $defaultStart; ?>" type="datetime-local" name="startDate" id="startDate" /> | ||
<span id='span_error_contactName' class='smallDarkRedText'> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><label>Downtime Resolution:</label></td> | ||
<td> | ||
<input value="<?php echo $defaultEnd; ?>" type="datetime-local" name="endDate" id="endDate" /> | ||
<span id='span_error_contactName' class='smallDarkRedText'> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><label>Problem Type:</label></td> | ||
<td> | ||
<select class="downtimeType" name="downtimeType"> | ||
<?php | ||
foreach ($downtimeTypeNames as $downtimeType) { | ||
echo "<option value=".$downtimeType["downtimeTypeID"].">".$downtimeType["name"]."</option>"; | ||
} | ||
?> | ||
</select> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><label>Link to open issue:</label></td> | ||
<td> | ||
<select class="issueID" name="issueID"> | ||
<option value="">none</option> | ||
<?php | ||
foreach ($issues as $issue) { | ||
echo "<option value=".$issue->issueID.">".$issue->subjectText."</option>"; | ||
} | ||
?> | ||
</select> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<table class='noBorderTable' style='width:125px;'> | ||
<tr> | ||
<td style='text-align:left'><input type='button' value='submit' name='submitNewDowntime' id='submitNewDowntime'></td> | ||
<td style='text-align:right'><input type='button' value='cancel' onclick="tb_remove();"></td> | ||
</tr> | ||
</table> | ||
|
||
</form> | ||
|
||
<?php | ||
} else { | ||
echo ' | ||
<p> | ||
Opening an issue requires a resource to be associated with an organization. | ||
</p> | ||
<input type="button" value="cancel" onclick="tb_remove();">'; | ||
} | ||
?> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
$resourceID = $_GET['resourceID']; | ||
$archivedFlag = (!empty($_GET['archived']) && $_GET['archived'] == 1) ? true:false; | ||
|
||
$resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID))); | ||
$util = new Utility(); | ||
|
||
|
||
//shared html template for organization and resource downtimes | ||
function generateDowntimeHTML($downtime,$associatedEntities=null) { | ||
|
||
$html = " | ||
<div class=\"downtime\">"; | ||
|
||
$html .= " | ||
<dl> | ||
<dt>Type:</dt> | ||
<dd>{$downtime->name}</dd> | ||
<dt>Downtime Start:</dt> | ||
<dd>{$downtime->startDate}</dd> | ||
<dt>Downtime Resolved:</dt> | ||
<dd>{$downtime->endDate}</dd>"; | ||
|
||
if($downtime->subjectText) { | ||
$html .= " | ||
<dt>Linked issue:</dt> | ||
<dd>{$downtime->subjectText}</dd>"; | ||
} | ||
|
||
$html .= " | ||
</dl> | ||
</div>"; | ||
|
||
return $html; | ||
} | ||
|
||
//display any organization level downtimes for the resource | ||
$organizationArray = $resource->getOrganizationArray(); | ||
|
||
if (count($organizationArray) > 0) { | ||
echo '<h3 class="text-center">Organizational</h3>'; | ||
|
||
$downtimedOrgs = array(); | ||
foreach ($organizationArray as $orgData) { | ||
if (!in_array($orgData['organizationID'],$downtimedOrgs)) { | ||
$organization = new Organization(new NamedArguments(array('primaryKey' => $orgData['organizationID']))); | ||
|
||
$orgDowntimes = $organization->getDowntime($archivedFlag); | ||
|
||
if(count($orgDowntimes) > 0) { | ||
foreach ($orgDowntimes as $downtime) { | ||
echo generateDowntimeHTML($downtime,array(array("name"=>$orgData['organization'],"id"=>$organization->organizationID,"entityType"=>1))); | ||
} | ||
} else { | ||
echo "<br><p>There are no organization level downtimes.</p><br>"; | ||
} | ||
|
||
$orgDowntimes = null; | ||
$downtimedOrgs[] = $orgData['organizationID']; | ||
} | ||
} | ||
} | ||
|
||
//display any resource level downtimes for the resource (shows any other resources associated with the downtime, too) | ||
$resourceDowntimes = $resource->getDowntime($archivedFlag); | ||
echo '<h3 class="text-center">Resources</h3>'; | ||
if(count($resourceDowntimes) > 0) { | ||
foreach ($resourceDowntimes as $downtime) { | ||
$associatedEntities = array(); | ||
if ($associatedResources = $downtime->getAssociatedResources()) { | ||
foreach ($associatedResources as $resource) { | ||
$associatedEntities[] = array("name"=>$resource->titleText,"id"=>$resource->resourceID,"entityType"=>2); | ||
} | ||
} | ||
echo generateDowntimeHTML($downtime,$associatedEntities); | ||
} | ||
} else { | ||
echo "<br><p>There are no resource level downtimes.</p><br>"; | ||
} | ||
?> |
Oops, something went wrong.