add initial support for timeline of recent changes

This commit is contained in:
Uwe Steinmann 2015-09-16 21:19:46 +02:00
parent 4206f5d32a
commit b55627f213
3 changed files with 103 additions and 0 deletions

View File

@ -2085,6 +2085,57 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return $resArr[0]['sum'];
} /* }}} */
/**
* Returns a list of events happend during the life of the document
*
* This includes the creation of new versions, approval and reviews, etc.
*
* @return array list of events
*/
function getTimeline() { /* {{{ */
$db = $this->_dms->getDB();
$timeline = array();
$queryStr = "SELECT * FROM tblDocumentContent WHERE document = " . $this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
foreach ($resArr as $row) {
$date = date('Y-m-d H:i:s', $row['date']);
$timeline[] = array('date'=>$date, 'msg'=>'Added version '.$row['version']);
}
$queryStr = "SELECT * FROM tblDocumentFiles WHERE document = " . $this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
foreach ($resArr as $row) {
$date = date('Y-m-d H:i:s', $row['date']);
$timeline[] = array('date'=>$date, 'msg'=>'Added attachment "'.$row['name'].'"');
}
$queryStr=
"SELECT `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ".
"`tblDocumentStatusLog`.`comment`, `tblDocumentStatusLog`.`date`, ".
"`tblDocumentStatusLog`.`userID` ".
"FROM `tblDocumentStatus` ".
"LEFT JOIN `tblDocumentStatusLog` USING (`statusID`) ".
"WHERE `tblDocumentStatus`.`documentID` = '". $this->_id ."' ".
"ORDER BY `tblDocumentStatusLog`.`statusLogID` DESC";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
foreach ($resArr as $row) {
$date = $row['date'];
$timeline[] = array('date'=>$date, 'msg'=>'Version '.$row['version'].': Status change to '.$row['status']);
}
return $timeline;
} /* }}} */
} /* }}} */

View File

@ -2009,5 +2009,50 @@ mayscript>
</div>';
return $html;
} /* }}} */
/**
* Output a timeline for a document
*
* @param object $document document
*/
protected function printTimeline($document) { /* {{{ */
$timeline = $document->getTimeline();
?>
<script type="text/javascript">
var timeline;
var data;
data = [
<?php
foreach($timeline as $item) {
echo "{'start': new Date('".$item['date']."'), 'content': '".$item['msg']."'},";
}
?>
{
'start': new Date(),
'content': 'Today'
}
];
// specify options
var options = {
'width': '100%',
'height': '300px',
'editable': false, // enable dragging and editing events
'style': 'box',
'locale': 'de_DE'
};
$(document).ready(function () {
// Instantiate our timeline object.
timeline = new links.Timeline(document.getElementById('timeline'), options);
timeline.draw(data);
});
</script>
<div id="timeline"></div>
<?php
} /* }}} */
}
?>

View File

@ -88,6 +88,10 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
$versions = $document->getContent();
$this->htmlAddHeader('<link href="../styles/'.$this->theme.'/timeline/timeline.css" rel="stylesheet">'."\n");
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/timeline/timeline-min.js"></script>'."\n");
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/timeline/timeline-locales.js"></script>'."\n");
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
@ -451,6 +455,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
print "</tbody>\n</table>\n";
$this->contentContainerEnd();
}
$this->contentHeading(getMLText("timeline"));
$this->printTimeline($document);
}
?>
</div>