From 54b2e8a8815bd690f2195d276745003b8c868f2a Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:12:35 +0200 Subject: [PATCH 1/8] add statusid and fileid in entry of timeline --- SeedDMS_Core/Core/inc.ClassDocument.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 993f22b8c..2f7191408 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -2114,11 +2114,11 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ foreach ($resArr as $row) { $date = date('Y-m-d H:i:s', $row['date']); - $timeline[] = array('date'=>$date, 'msg'=>'Added attachment "'.$row['name'].'"', 'document'=>$this, 'type'=>'add_file'); + $timeline[] = array('date'=>$date, 'msg'=>'Added attachment "'.$row['name'].'"', 'document'=>$this, 'type'=>'add_file', 'fileid'=>$row['id']); } $queryStr= - "SELECT `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ". + "SELECT `tblDocumentStatus`.*, `tblDocumentStatusLog`.`statusLogID`,`tblDocumentStatusLog`.`status`, ". "`tblDocumentStatusLog`.`comment`, `tblDocumentStatusLog`.`date`, ". "`tblDocumentStatusLog`.`userID` ". "FROM `tblDocumentStatus` ". @@ -2136,7 +2136,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ foreach ($resArr as $row) { if($row['date']) { $date = $row['date']; - $timeline[] = array('date'=>$date, 'msg'=>'Version '.$row['version'].': Status change to '.$row['status'], 'type'=>'status_change', 'version'=>$row['version'], 'document'=>$this, 'status'=>$row['status'], 'params'=>array($row['version'], $row['status'])); + $timeline[] = array('date'=>$date, 'msg'=>'Version '.$row['version'].': Status change to '.$row['status'], 'type'=>'status_change', 'version'=>$row['version'], 'document'=>$this, 'status'=>$row['status'], 'statusid'=>$row['statusID'], 'statuslogid'=>$row['statusLogID']); } } return $timeline; From 002fa8df29fed7576ddd5c78637b75c829109747 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:14:14 +0200 Subject: [PATCH 2/8] get timeline data in ajax call --- out/out.Timeline.php | 22 ++++- views/bootstrap/class.Timeline.php | 143 +++++++++++++++++++++++------ 2 files changed, 132 insertions(+), 33 deletions(-) diff --git a/out/out.Timeline.php b/out/out.Timeline.php index e7ce12ef0..baea15a38 100644 --- a/out/out.Timeline.php +++ b/out/out.Timeline.php @@ -44,12 +44,28 @@ if(isset($_GET['skip'])) else $skip = array(); -$data = $dms->getTimeline($from, $to); +if(isset($_GET['documentid']) && $_GET['documentid'] && is_numeric($_GET['documentid'])) { + $document = $dms->getDocument($_GET["documentid"]); + if (!is_object($document)) { + $view->exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); + } +} else + $document = null; + +if(isset($_GET['version']) && $_GET['version'] && is_numeric($_GET['version'])) { + $content = $document->getContentByVersion($_GET['version']); +} else + $content = null; $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'rootfolder'=>$rootfolder, 'from'=>$from, 'to'=>$to, 'skip'=>$_GET['skip'], 'data'=>$data)); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { - $view->show(); + $view->setParam('fromdate', isset($_GET['fromdate']) ? $_GET['fromdate'] : ''); + $view->setParam('todate', isset($_GET['todate']) ? $_GET['todate'] : ''); + $view->setParam('skip', $skip); + $view->setParam('document', $document); + $view->setParam('version', $content); + $view($_GET); exit; } diff --git a/views/bootstrap/class.Timeline.php b/views/bootstrap/class.Timeline.php index 87a49b76c..5cde0510c 100644 --- a/views/bootstrap/class.Timeline.php +++ b/views/bootstrap/class.Timeline.php @@ -30,20 +30,99 @@ require_once("class.Bootstrap.php"); * @version Release: @package_version@ */ class SeedDMS_View_Timeline extends SeedDMS_Bootstrap_Style { - var $dms; - var $folder_count; - var $document_count; - var $file_count; - var $storage_size; + var $dms; + var $folder_count; + var $document_count; + var $file_count; + var $storage_size; + + function iteminfo() { /* {{{ */ + $dms = $this->params['dms']; + $document = $this->params['document']; + $this->contentHeading(getMLText("selected_item")); + echo $document->getName(); + } /* }}} */ + + function data() { /* {{{ */ + $dms = $this->params['dms']; + $skip = $this->params['skip']; + $fromdate = $this->params['fromdate']; + $todate = $this->params['todate']; + + if($fromdate) { + $from = makeTsFromLongDate($fromdate.' 00:00:00'); + } else { + $from = time()-7*86400; + } + + if($todate) { + $to = makeTsFromLongDate($todate.' 00:00:00'); + } else { + $to = time()-7*86400; + } + + $data = $dms->getTimeline($from, $to); + + foreach($data as &$item) { + switch($item['type']) { + case 'add_version': + $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'])); + break; + case 'add_file': + $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()))); + break; + case 'status_change': + $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'], 'status'=> getOverallStatusText($item['status']))); + break; + default: + $msg = '???'; + } + $item['msg'] = $msg; + } + + $jsondata = array(); + foreach($data as $item) { + if($item['type'] == 'status_change') + $classname = $item['type']."_".$item['status']; + else + $classname = $item['type']; + if(!$skip || !in_array($classname, $skip)) { + $d = makeTsFromLongDate($item['date']); + $jsondata[] = array( + 'start'=>date('c', $d), + 'content'=>$item['msg'], + 'className'=>$classname, + 'docid'=>$item['document']->getID(), + 'version'=>isset($item['version']) ? $item['version'] : '', + 'statusid'=>isset($item['statusid']) ? $item['statusid'] : '', + 'statuslogid'=>isset($item['statuslogid']) ? $item['statuslogid'] : '', + 'fileid'=>isset($item['fileid']) ? $item['fileid'] : '' + ); + } + } + header('Content-Type: application/json'); + echo json_encode($jsondata); + } /* }}} */ function show() { /* {{{ */ - $this->dms = $this->params['dms']; + $dms = $this->params['dms']; $user = $this->params['user']; - $data = $this->params['data']; - $from = $this->params['from']; - $to = $this->params['to']; + $fromdate = $this->params['fromdate']; + $todate = $this->params['todate']; $skip = $this->params['skip']; + if($fromdate) { + $from = makeTsFromLongDate($fromdate.' 00:00:00'); + } else { + $from = time()-7*86400; + } + + if($todate) { + $to = makeTsFromLongDate($todate.' 00:00:00'); + } else { + $to = time(); + } + $this->htmlAddHeader(''."\n", 'css'); $this->htmlAddHeader(''."\n", 'js'); $this->htmlAddHeader(''."\n", 'js'); @@ -61,7 +140,7 @@ echo "
\n"; $this->contentHeading(getMLText("timeline")); echo "
\n"; ?> -
+
@@ -90,35 +169,39 @@ echo "
\n";
- +
+$skip))); +?> + \n"; +echo "
"; echo "
\n"; echo "
\n"; $this->contentHeading(getMLText("timeline")); -if($data) { - foreach($data as &$item) { - switch($item['type']) { - case 'add_version': - $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'])); - break; - case 'add_file': - $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()))); - break; - case 'status_change': - $msg = getMLText('timeline_full_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'], 'status'=> getOverallStatusText($item['status']))); - break; - default: - $msg = '???'; - } - $item['msg'] = $msg; - } - $this->printTimeline($data, 550, date('Y-m-d', $from), date('Y-m-d', $to+1), $skip); -} +$this->printTimeline($timelineurl, 550, date('Y-m-d', $from), date('Y-m-d', $to+1), $skip); echo "
\n"; echo "
\n"; From 2c79669c9481f7351187860150009b3258a31ad1 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:14:50 +0200 Subject: [PATCH 3/8] pass $_GET to view --- out/out.ViewDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/out/out.ViewDocument.php b/out/out.ViewDocument.php index 76aa826cb..361a63d8f 100644 --- a/out/out.ViewDocument.php +++ b/out/out.ViewDocument.php @@ -76,7 +76,7 @@ if($view) { $view->setParam('previewWidthList', $settings->_previewWidthList); $view->setParam('previewWidthDetail', $settings->_previewWidthDetail); $view->setParam('currenttab', isset($_GET['currenttab']) ? $_GET['currenttab'] : ""); - $view->show(); + $view($_GET); exit; } From 88e0a57135c7672cbf82337cb46fe760aa64f061 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:15:20 +0200 Subject: [PATCH 4/8] add ajax function for returning the timeline data --- views/bootstrap/class.ViewDocument.php | 41 +++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index 8a2ae362a..0ad2e5857 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -71,6 +71,45 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { } } /* }}} */ + function timelinedata() { /* {{{ */ + $dms = $this->params['dms']; + $user = $this->params['user']; + $document = $this->params['document']; + + $jsondata = array(); + if($user->isAdmin()) { + $data = $document->getTimeline(); + + foreach($data as &$item) { + switch($item['type']) { + case 'add_version': + $msg = getMLText('timeline_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'])); + break; + case 'add_file': + $msg = getMLText('timeline_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()))); + break; + case 'status_change': + $msg = getMLText('timeline_'.$item['type'], array('document'=>htmlspecialchars($item['document']->getName()), 'version'=> $item['version'], 'status'=> getOverallStatusText($item['status']))); + break; + default: + $msg = '???'; + } + $item['msg'] = $msg; + } + + foreach($data as $item) { + if($item['type'] == 'status_change') + $classname = $item['type']."_".$item['status']; + else + $classname = $item['type']; + $d = makeTsFromLongDate($item['date']); + $jsondata[] = array('start'=>date('c', $d)/*$item['date']*/, 'content'=>$item['msg'], 'className'=>$classname); + } + } + header('Content-Type: application/json'); + echo json_encode($jsondata); + } /* }}} */ + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -1132,7 +1171,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { } $item['msg'] = $msg; } - $this->printTimeline($timeline, 300, '', date('Y-m-d')); + $this->printTimeline('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d')); } } ?> From f83ae3eda173971fb18c481c57a64f08d885755a Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:15:52 +0200 Subject: [PATCH 5/8] printTimeline() retrieves data from ajax --- views/bootstrap/class.Bootstrap.php | 52 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index eec9c49c6..c972464b8 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -2018,35 +2018,14 @@ mayscript> * * @param object $document document */ - protected function printTimeline($timeline, $height=300, $start='', $end='', $skip=array()) { /* {{{ */ - if(!$timeline) + protected function printTimeline($timelineurl, $height=300, $start='', $end='', $skip=array()) { /* {{{ */ + if(!$timelineurl) return; ?> From e52059df64ba59be5bd8874a09c4040d486691d5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Oct 2015 13:16:28 +0200 Subject: [PATCH 6/8] set color of div.timeline-event-selected --- styles/bootstrap/application.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/styles/bootstrap/application.css b/styles/bootstrap/application.css index 2cfbfd414..c4e775da1 100644 --- a/styles/bootstrap/application.css +++ b/styles/bootstrap/application.css @@ -144,6 +144,12 @@ div.status_change_-1 { border-color: #F89797; } +div.timeline-event-selected { + background-color: #fff785; + border-color: #ffc200; + z-index: 999; +} + @media (max-width: 480px) { .nav-tabs > li { float:none; From 1972d961f35c77c2affe0ac7c7ad90699f88f98c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 20 Oct 2015 18:14:39 +0200 Subject: [PATCH 7/8] initial test with webkitRelativePath (not used) --- styles/bootstrap/application.js | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/bootstrap/application.js b/styles/bootstrap/application.js index bc750fb96..65f5f830b 100644 --- a/styles/bootstrap/application.js +++ b/styles/bootstrap/application.js @@ -669,6 +669,7 @@ function onAddClipboard(ev) { fd.append('folderid', target); fd.append('formtoken', obj.data('formtoken')); fd.append('userfile', files[i]); +// fd.append('path', files[i].webkitRelativePath); var status = new createStatusbar(obj); status.setFileNameSize(files[i].name,files[i].size); From 47c2083fe607f94dec0cfb88b9f0ab73394eebcf Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 20 Oct 2015 18:15:08 +0200 Subject: [PATCH 8/8] do not set min/max anymore as it can't be changed afterwards --- views/bootstrap/class.Timeline.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/views/bootstrap/class.Timeline.php b/views/bootstrap/class.Timeline.php index 5cde0510c..0845edacf 100644 --- a/views/bootstrap/class.Timeline.php +++ b/views/bootstrap/class.Timeline.php @@ -39,8 +39,10 @@ class SeedDMS_View_Timeline extends SeedDMS_Bootstrap_Style { function iteminfo() { /* {{{ */ $dms = $this->params['dms']; $document = $this->params['document']; - $this->contentHeading(getMLText("selected_item")); - echo $document->getName(); + if($document) { + $this->contentHeading(getMLText("selected_item")); + echo $document->getName(); + } } /* }}} */ function data() { /* {{{ */ @@ -189,6 +191,7 @@ $(document).ready(function () { }); timeline.setData(data); timeline.redraw(); +// timeline.setVisibleChartRange(0,0); } ); }); @@ -201,7 +204,7 @@ echo "
\n"; echo "
\n"; $this->contentHeading(getMLText("timeline")); -$this->printTimeline($timelineurl, 550, date('Y-m-d', $from), date('Y-m-d', $to+1), $skip); +$this->printTimeline($timelineurl, 550, ''/*date('Y-m-d', $from)*/, ''/*date('Y-m-d', $to+1)*/, $skip); echo "
\n"; echo "
\n";