|
|
@@ -31,12 +31,20 @@ class Route_Budget extends RouteBase {
|
|
|
public function yearBudgetAction() {
|
|
|
$args = array();
|
|
|
$args['year'] = V::get('year', '', $_REQUEST, 'int');
|
|
|
+ $args['groups'] = V::get('fltrGroups', array(), $_REQUEST, 'array', array('V', 'filterPositiveInteger'));
|
|
|
$args['_print'] = V::get('_print', '', $_REQUEST, 'int');
|
|
|
|
|
|
+ $hasData = false;
|
|
|
+ $groups = null;
|
|
|
+ if ($args['year'] > 0) {
|
|
|
+ $hasData = $this->fetchDataByYear($args['year']);
|
|
|
+ $groups = $this->getUsedUserGroups();
|
|
|
+ }
|
|
|
+
|
|
|
SE_Layout::gora();
|
|
|
SE_Layout::menu();
|
|
|
if (!$args['_print']) {
|
|
|
- $this->menu($args['year']);
|
|
|
+ $this->menu($args['year'], $groups, $args['groups']);
|
|
|
}
|
|
|
|
|
|
if (empty($args['year'])) {
|
|
|
@@ -49,7 +57,6 @@ class Route_Budget extends RouteBase {
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
- $hasData = $this->fetchDataByYear($args['year']);
|
|
|
if (!$hasData) {
|
|
|
?>
|
|
|
<div class="alert alert-warning">
|
|
|
@@ -60,12 +67,12 @@ class Route_Budget extends RouteBase {
|
|
|
}
|
|
|
//echo'<pre style="border:1px solid red;overflow:auto;max-height:400px">$costs: ';print_r($costs);echo'</pre>';
|
|
|
|
|
|
- $this->printCostsForYear($args['year']);
|
|
|
+ $this->printCostsForYear($args['year'], $args['groups']);
|
|
|
|
|
|
SE_Layout::dol();
|
|
|
}
|
|
|
|
|
|
- private function menu($selectedYear) {
|
|
|
+ private function menu($selectedYear, $groups, $selectedGroups) {
|
|
|
//SE_Layout::menu();
|
|
|
$year = ($selectedYear)? $selectedYear : date("Y");
|
|
|
?>
|
|
|
@@ -73,11 +80,25 @@ class Route_Budget extends RouteBase {
|
|
|
<div class="container">
|
|
|
<form class="form-inline" method="POST">
|
|
|
<input type="hidden" name="_task" value="yearBudget" />
|
|
|
- <label for="year">Zestawienie kosztów projektów na podstawie korespondencji:</label>
|
|
|
+ <label for="year">Zestawienie kosztów projektów. Wybierz rok:</label>
|
|
|
<div class="input-group date" id="fldZestYear">
|
|
|
<input type="text" name="year" class="form-control" value="" />
|
|
|
<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
|
|
|
</div>
|
|
|
+ <?php if (!empty($groups)) : ?>
|
|
|
+ <div style="margin:8px 0">
|
|
|
+ <label for="fltrGroups">Pokaż tylko projekty dostępne dla grup:</label>
|
|
|
+ <select multiple name="fltrGroups[]" size="<?php echo min(5, count($groups)); ?>" class="form-control">
|
|
|
+ <option value=""> [ Wszystkie ] </option>
|
|
|
+ <?php foreach ($groups as $idGroup => $groupLdapName) : ?>
|
|
|
+ <option
|
|
|
+ value="<?php echo $idGroup; ?>"
|
|
|
+ <?php if (in_array($idGroup, $selectedGroups)) { echo 'selected="selected"'; } ?>
|
|
|
+ ><?php echo $groupLdapName; ?></option>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <?php endif; ?>
|
|
|
<button type="submit" id="fldZestYearBtn" class="btn btn-primary" autocomplete="off">
|
|
|
Pokaż
|
|
|
</button>
|
|
|
@@ -140,7 +161,7 @@ jQuery(document).ready(function () {
|
|
|
<?php
|
|
|
}
|
|
|
|
|
|
- function printCostsForYear($year) {
|
|
|
+ function printCostsForYear($year, $groups) {
|
|
|
$months = array();
|
|
|
for ($i = 0; $i < 12; $i++) {
|
|
|
$months[] = $i + 1;
|
|
|
@@ -183,6 +204,16 @@ jQuery(document).ready(function () {
|
|
|
$projectDesc = $this->_projectInfo[$projId]->M_DIST_DESC;
|
|
|
$projectPath = $this->_projectInfo[$projId]->path;
|
|
|
$projectAccess = $this->hasAccessToProject($projectID);
|
|
|
+ if (!empty($groups)) {
|
|
|
+ if (!$projectAccess) {
|
|
|
+ //echo '<pre>TODO: filtered by acl for project';print_r($this->_projectInfo[$projId]);echo'</pre>';
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!$this->hasGroupsAccessToProjects($projectID, $groups)) {
|
|
|
+ //echo '<pre>TODO: filtered by acl and groups';print_r($this->_projectInfo[$projId]);echo'</pre>';
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
?>
|
|
|
<tr class="row-<?php echo ($t = 1 - $t); ?>"
|
|
|
data-proj_id="<?php echo $projectID; ?>"
|
|
|
@@ -609,6 +640,7 @@ jQuery(document).ready(function() {
|
|
|
while ($r = $db->fetch($res)) {
|
|
|
$this->_projectInfo[$r->ID]->path = $r->path;
|
|
|
$this->_projectInfo[$r->ID]->M_DIST_DESC = $r->M_DIST_DESC;
|
|
|
+ $this->_projectInfo[$r->ID]->aclGroupRead = $r->aclGroupRead;
|
|
|
$this->_projectInfo[$r->ID]->hasAccess = $this->_userHasAccessToProject($r);
|
|
|
if (!$this->_projectInfo[$r->ID]->hasAccess) $hasAccessForAllProjects = false;
|
|
|
}
|
|
|
@@ -626,6 +658,26 @@ jQuery(document).ready(function() {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public function hasGroupsAccessToProjects($idProject, $groups) {
|
|
|
+ $selectedUserGroupNames = array();
|
|
|
+ $userGroups = User::getLdapGroupsNames();
|
|
|
+ foreach ($groups as $idGroup) {
|
|
|
+ $selectedUserGroupNames[$idGroup] = $userGroups[$idGroup];
|
|
|
+ }
|
|
|
+ if ($idProject >= 0) {
|
|
|
+ if (array_key_exists($idProject, $this->_projectInfo)) {
|
|
|
+ $alcGroupRead = V::get('aclGroupRead', null, $this->_projectInfo[$idProject]);
|
|
|
+ if (!$alcGroupRead) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (in_array($alcGroupRead, $selectedUserGroupNames)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private function _userHasAccessToProject($project) {
|
|
|
$groups = User::getLdapGroupsNames();
|
|
|
$userLogin = User::getLogin();
|
|
|
@@ -638,6 +690,20 @@ jQuery(document).ready(function() {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public function getUsedUserGroups() {
|
|
|
+ $groups = array();
|
|
|
+ $userGroups = User::getLdapGroupsNames();
|
|
|
+ foreach ($this->_projectInfo as $projectInfo) {
|
|
|
+ if (!empty($projectInfo->aclGroupRead)) {
|
|
|
+ $groupKey = array_search($projectInfo->aclGroupRead, $userGroups);
|
|
|
+ if ($groupKey !== false) {
|
|
|
+ $groups[$groupKey] = $projectInfo->aclGroupRead;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $groups;
|
|
|
+ }
|
|
|
+
|
|
|
private function _reacountCostsFromKoresp() {
|
|
|
$projMonthHasCostSelfIds = array();
|
|
|
foreach ($this->_costs as $kProjId => $vProjInfo) {
|