Merge branch 'seeddms-4.3.8' into develop

This commit is contained in:
Uwe Steinmann 2014-04-09 09:26:22 +02:00
commit 89ea53caf4
3 changed files with 52 additions and 12 deletions

View File

@ -2073,14 +2073,14 @@ class SeedDMS_Core_DMS {
return $resArr;
case 'docspermonth':
$queryStr = "select `key`, count(`key`) as total from (select ".$this->db->getDateExtract("date")." as `key` from tblDocuments) a group by `key` order by `key`";
$queryStr = "select *, count(`key`) as total from (select ".$this->db->getDateExtract("date", '%Y-%m')." as `key` from tblDocuments) a group by `key` order by `key`";
$resArr = $this->db->getResultArray($queryStr);
if (!$resArr)
return false;
return $resArr;
case 'docsaccumulated':
$queryStr = "select `key`, count(`key`) as total from (select ".$this->db->getDateExtract("date")." as `key` from tblDocuments) a group by `key` order by `key`";
$queryStr = "select *, count(`key`) as total from (select ".$this->db->getDateExtract("date")." as `key` from tblDocuments) a group by `key` order by `key`";
$resArr = $this->db->getResultArray($queryStr);
if (!$resArr)
return false;
@ -2091,9 +2091,7 @@ class SeedDMS_Core_DMS {
/* auxially variable $key is need because sqlite returns
* a key '`key`'
*/
$key = mktime(12, 0, 0, substr($res['key'], 5, 2), substr($res['key'], 8, 2), substr($res['key'], 0, 4)) * 1000;
unset($res['key']);
$res['key'] = $key;
$res['key'] = mktime(12, 0, 0, substr($res['key'], 5, 2), substr($res['key'], 8, 2), substr($res['key'], 0, 4)) * 1000;
$res['total'] = $sum;
}
return $resArr;

View File

@ -440,13 +440,13 @@ class SeedDMS_Core_DatabaseAccess {
* @param string $fieldname name of field containing the timestamp
* @return string sql code
*/
function getDateExtract($fieldname) { /* {{{ */
function getDateExtract($fieldname, $format='%Y-%m-%d') { /* {{{ */
switch($this->_driver) {
case 'mysql':
return "from_unixtime(`".$fieldname."`, '%Y-%m-%d')";
return "from_unixtime(`".$fieldname."`, ".$this->qstr($format).")";
break;
case 'sqlite':
return "date(`".$fieldname."`, 'unixepoch')";
return "strftime(".$this->qstr($format).", `".$fieldname."`, 'unixepoch')";
break;
}
return '';

View File

@ -46,6 +46,7 @@ class SeedDMS_View_Charts extends SeedDMS_Bootstrap_Style {
$this->htmlAddHeader(
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.min.js"></script>'."\n".
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.pie.min.js"></script>'."\n".
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.categories.min.js"></script>'."\n".
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.time.min.js"></script>'."\n");
$this->htmlStartPage(getMLText("folders_and_documents_statistic"));
@ -85,7 +86,48 @@ echo "<div class=\"well\">\n";
}).appendTo("body");
<?php
if($type == 'docsaccumulated') {
if(in_array($type, array('docspermonth'))) {
?>
var data = [
<?php
foreach($data as $i=>$rec) {
$key = mktime(12, 0, 0, substr($rec['key'], 5, 2), 1, substr($rec['key'], 0, 4)) * 1000;
echo '["'.$rec['key'].'",'.$rec['total'].'],'."\n";
// echo '['.$i.','.$rec['total'].'],'."\n";
}
?>
];
$.plot("#chart", [data], {
xaxis: {
mode: "categories",
tickLength: 0,
},
series: {
bars: {
show: true,
align: "center",
barWidth: 0.8,
},
},
grid: {
hoverable: true,
clickable: true
},
});
$("#chart").bind("plothover", function (event, pos, item) {
if(item) {
var x = item.datapoint[0];//.toFixed(2),
y = item.datapoint[1];//.toFixed(2);
$("#tooltip").html(item.series.xaxis.ticks[x].label + ": " + y)
.css({top: pos.pageY-35, left: pos.pageX+5})
.fadeIn(200);
} else {
$("#tooltip").hide();
}
});
<?php
} elseif(in_array($type, array('docsaccumulated'))) {
?>
var data = [
<?php
@ -126,9 +168,9 @@ if($type == 'docsaccumulated') {
?>
var data = [
<?php
foreach($data as $rec) {
echo '{ label: "'.$rec['key'].'", data: [[1,'.$rec['total'].']]},'."\n";
}
foreach($data as $rec) {
echo '{ label: "'.$rec['key'].'", data: [[1,'.$rec['total'].']]},'."\n";
}
?>
];
$.plot('#chart', data, {