Skip to content

Commit

Permalink
Merge pull request #662 from coral-erm/sirsidynix
Browse files Browse the repository at this point in the history
Fix to downtime logging feature
  • Loading branch information
andyp-uk authored Sep 1, 2020
2 parents 9d82d12 + 6a9c6fd commit a12c3ec
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 12 deletions.
6 changes: 3 additions & 3 deletions organizations/ajax_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
case 'updateDowntime':
if (is_numeric($_POST['downtimeID'])) {
$downtime = new Downtime(new NamedArguments(array('primaryKey' => $_POST['downtimeID'])));
$downtime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian']) : null;
$downtime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian'])) : null;
$downtime->note = ($_POST['note']) ? $_POST['note']:null;
$downtime->save();
}
Expand All @@ -373,8 +373,8 @@
$newDowntime->downtimeTypeID = $_POST['downtimeType'];
$newDowntime->issueID = $_POST['issueID'];

$newDowntime->startDate = date('Y-m-d H:i:s', create_date_from_js_format($_POST['statDate'])->format('Y-m-d')." ".$_POST['startTime']['hour'].":".$_POST['startTime']['minute'].$_POST['startTime']['meridian']);
$newDowntime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian']):null;
$newDowntime->startDate = date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['startDate'])->format('Y-m-d')." ".$_POST['startTime']['hour'].":".$_POST['startTime']['minute'].$_POST['startTime']['meridian']));
$newDowntime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian'])):null;

$newDowntime->dateCreated = date( 'Y-m-d H:i:s');
$newDowntime->entityTypeID = 1;
Expand Down
10 changes: 10 additions & 0 deletions organizations/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2053,3 +2053,13 @@ table.titleTable {
.editIcon {
padding-left: 8px;
}

/*--- Add space before and after each downtime definition ---*/

dt:first-child {
padding-top: .5em;
}

div.downtime {
padding-bottom: 1em;
}
1 change: 0 additions & 1 deletion organizations/templates/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="../js/plugins/jquery-1.8.0.js"></script>
<script type="text/javascript" src="js/plugins/thickbox.js"></script>
<script type="text/javascript" src="../js/plugins/jquery.datePicker-patched-for-i18n.js"></script>
<script type="text/javascript" src="../js/plugins/jquery.autocomplete.js"></script>
<script type="text/javascript" src="../js/plugins/jquery.tooltip.js"></script>
<script type="text/javascript" src="../js/plugins/Gettext.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions resources/admin/classes/domain/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public function getDowntime($archivedOnly=false) {
return $objects;
}

public function getExportableDowntimes($archivedOnly=false){
public function getExportableDowntimes($archivedOnly=false) {
$result = $this->getDownTimeResults($archivedOnly);

$objects = array();

//need to do this since it could be that there's only one request and this is how the dbservice returns result
if (isset($result['downtimeID'])){
if (isset($result['downtimeID'])) {
return array($result);
}else{
} else {
return $result;
}
}
Expand Down
20 changes: 18 additions & 2 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,33 @@ public function getExportableIssues($archivedOnly=false){



private function getDownTimeResults($archivedOnly=false) {
$query = "SELECT d.*
FROM Downtime d
WHERE d.entityID='{$this->primaryKey}'
AND d.entityTypeID=2";

if ($archivedOnly) {
$query .= " AND d.endDate < CURDATE()";
} else {
$query .= " AND (d.endDate >= CURDATE() OR d.endDate IS NULL)";
}
$query .= " ORDER BY d.dateCreated DESC";

return $this->db->processQuery($query, 'assoc');
}

public function getExportableDowntimes($archivedOnly=false){


public function getExportableDowntimes($archivedOnly=false) {
$result = $this->getDownTimeResults($archivedOnly);

$objects = array();

//need to do this since it could be that there's only one request and this is how the dbservice returns result
if (isset($result['downtimeID'])) {
return array($result);
}else{
} else {
return $result;
}
}
Expand Down
4 changes: 2 additions & 2 deletions resources/ajax_processing/insertDowntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
$newDowntime->downtimeTypeID = $_POST['downtimeType'];
$newDowntime->issueID = $_POST['issueID'];

$newDowntime->startDate = date('Y-m-d H:i:s', create_date_from_js_format($_POST['startDate'])->format('Y-m-d')." ".$_POST['startTime']['hour'].":".$_POST['startTime']['minute'].$_POST['startTime']['meridian']);
$newDowntime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian']) : null;
$newDowntime->startDate = date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['startDate'])->format('Y-m-d')." ".$_POST['startTime']['hour'].":".$_POST['startTime']['minute'].$_POST['startTime']['meridian']));
$newDowntime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian'])) : null;

$newDowntime->dateCreated = date( 'Y-m-d H:i:s');
$newDowntime->note = ($_POST['note']) ? $_POST['note']:null;
Expand Down
2 changes: 1 addition & 1 deletion resources/ajax_processing/updateDowntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if (is_numeric($_POST['downtimeID'])) {
$downtime = new Downtime(new NamedArguments(array('primaryKey' => $_POST['downtimeID'])));

$downtime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian']):null;
$downtime->endDate = ($_POST['endDate']) ? date('Y-m-d H:i:s', strtotime(create_date_from_js_format($_POST['endDate'])->format('Y-m-d')." ".$_POST['endTime']['hour'].":".$_POST['endTime']['minute'].$_POST['endTime']['meridian'])):null;

$downtime->note = ($_POST['note']) ? $_POST['note']:null;

Expand Down
10 changes: 10 additions & 0 deletions resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3316,3 +3316,13 @@ input#archiveInd {
.addIconAlert {
vertical-align: 3px;
}

/*--- Add space before and after each downtime definition ---*/

dt:first-child {
padding-top: .5em;
}

div.downtime {
padding-bottom: 1em;
}

0 comments on commit a12c3ec

Please sign in to comment.