mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
add initial support for timeline of recent changes
This commit is contained in:
parent
4206f5d32a
commit
b55627f213
|
@ -2085,6 +2085,57 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $resArr[0]['sum'];
|
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;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2009,5 +2009,50 @@ mayscript>
|
||||||
</div>';
|
</div>';
|
||||||
return $html;
|
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
|
||||||
|
} /* }}} */
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -88,6 +88,10 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
||||||
|
|
||||||
$versions = $document->getContent();
|
$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->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -451,6 +455,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
||||||
print "</tbody>\n</table>\n";
|
print "</tbody>\n</table>\n";
|
||||||
$this->contentContainerEnd();
|
$this->contentContainerEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->contentHeading(getMLText("timeline"));
|
||||||
|
$this->printTimeline($document);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user