diff --git a/module/bi/config/pivots.php b/module/bi/config/pivots.php index 4db0d247b6..c649e70e52 100644 --- a/module/bi/config/pivots.php +++ b/module/bi/config/pivots.php @@ -704,10 +704,10 @@ left join zt_project as t3 on t3.id=t1.project where t1.deleted='0' and t1.type in ('sprint','stage') and t2.deleted='0' -and (case when $project='' then 1 else t3.id=$project end) -and (case when $status='' then 1 else t1.status=$status end) -and (case when $beginDate='' then 1 else t1.begin>=$beginDate end) -and (case when $endDate='' then 1 else t1.end<=$endDate end) +and (case when \$project='' then 1 else t3.id=\$project end) +and (case when \$status='' then 1 else t1.status=\$status end) +and (case when \$beginDate='' then 1 else t1.begin>=\$beginDate end) +and (case when \$endDate='' then 1 else t1.end<=\$endDate end) EOT, 'settings' => array ( @@ -1526,14 +1526,15 @@ select t1.id, t5.name as project, (case when t5.multiple='1' then t1.name else '' end) as execution, - t2.stories, - (t2.stories-t2.undone) as doneStory, - t3.number,(t3.number-t3.undone) as doneTask, - t4.bugs, - t4.resolutions, - round(t4.bugs/(t2.stories-t2.undone),2) as bugthanstory, - round(t4.bugs/(t3.number-t3.undone),2) as bugthantask, - t4.seriousBugs + ifnull(t2.stories, 0) as stories, + ifnull((t2.stories-t2.undone), 0) as doneStory, + ifnull(t3.number, 0) as number, + ifnull((t3.number-t3.undone), 0) as doneTask, + ifnull(t4.bugs, 0) as bugs, + ifnull(t4.resolutions, 0) as resolutions, + ifnull(round(t4.bugs/(t2.stories-t2.undone),2), 0) as bugthanstory, + ifnull(round(t4.bugs/(t3.number-t3.undone),2), 0) as bugthantask, + ifnull(t4.seriousBugs, 0) as seriousBugs from zt_project as t1 left join ztv_projectstories as t2 on t1.id=t2.execution left join ztv_executionsummary as t3 on t1.id=t3.execution @@ -1674,12 +1675,12 @@ $config->bi->builtin->pivots[] = array select t1.id, t1.name, - t2.stories, - (t2.stories-t2.undone) as doneStory, - t3.bugs, - t3.resolutions, - round(t3.bugs/(t2.stories-t2.undone),2) as bugthanstory, - t3.seriousBugs + ifnull(t2.stories, 0) as stories, + ifnull((t2.stories-t2.undone), 0) as doneStory, + ifnull(t3.bugs, 0) as bugs, + ifnull(t3.resolutions, 0) as resolutions, + ifnull(round(t3.bugs/(t2.stories-t2.undone),2), 0) as bugthanstory, + ifnull(t3.seriousBugs, 0) as seriousBugs from zt_product as t1 left join ztv_productstories as t2 on t1.id=t2.product left join ztv_productbugs as t3 on t1.id=t3.product @@ -1797,14 +1798,16 @@ select t1.account, t1.consumed, t1.`date`, - (case when \$dept='' then 0 else t2.dept end) as dept + t2.dept as dept from zt_effort as t1 left join zt_user as t2 on t1.account = t2.account left join zt_dept as t3 on t2.dept = t3.id where t1.`deleted` = '0' and (case when \$startDate='' then 1 else t1.`date` >= cast(\$startDate as date) end) and (case when \$endDate='' then 1 else t1.`date` <= cast(\$endDate as date) end) -and (t3.path like concat((select path from zt_dept where id=\$dept), '%') or \$dept=0) +and (case when \$dept='' then 1 +else t3.path like concat((select path from zt_dept where id=coalesce(cast(nullif(\$dept, '') as integer), 0)), '%') +end) order by t1.`date` asc EOT, 'settings' => array @@ -1861,33 +1864,33 @@ $config->bi->builtin->pivots[] = array 'sql' => <<=\$startDate end) and (case when \$endDate='' then 1 else day<=\$endDate end) @@ -1896,7 +1899,6 @@ EOT, 'settings' => array ( 'group1' => 'day', - 'group2' => '', 'columnTotal' => 'sum', 'columns' => array ( @@ -1973,7 +1975,7 @@ and t2.deleted='0' and t1.resolution!='' and (case when \$startDate='' then 1 else t1.resolvedDate>=cast(\$startDate as date) end) and (case when \$endDate='' then 1 else t1.resolvedDate<=cast(\$endDate as date) end) -having customproduct=\$product +and (case when \$product = '' then 1 else customproduct=\$product end) EOT, 'settings' => array ( @@ -2087,7 +2089,7 @@ $config->bi->builtin->pivots[] = array select t1.id, t4.name as project, - (case when t4.multiple="1" then t1.name else '' end) as execution, + (case when t4.multiple='1' then t1.name else '' end) as execution, t1.status, t2.number as tasks, round(t2.consumed,2) as consumed, diff --git a/module/bi/model.php b/module/bi/model.php index 6a0953087a..4f1c479cf1 100644 --- a/module/bi/model.php +++ b/module/bi/model.php @@ -98,7 +98,7 @@ class biModel extends model elseif($driverName == 'duckdb') { $rows = $dbh->query($limitSql)->fetchAll(); - $allRows = $dbh->query("SELECT COUNT(1) as count FROM ($sql)")->fetch(); + $allRows = $dbh->query("SELECT COUNT(1) as count FROM ( $sql )")->fetch(); $rowsCount = $allRows->count; } }