fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [14846] Merge 14843:14845 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [14846] Merge 14843:14845 from trunk
Date: Wed, 16 Mar 2016 14:11:21 +0000

Revision: 14846
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14846
Author:   sigurdne
Date:     2016-03-16 14:11:21 +0000 (Wed, 16 Mar 2016)
Log Message:
-----------
Merge 14843:14845 from trunk

Modified Paths:
--------------
    branches/Version-2_0-branch/booking/inc/class.boapplication.inc.php
    branches/Version-2_0-branch/booking/inc/class.uiapplication.inc.php
    branches/Version-2_0-branch/booking/inc/class.uidashboard.inc.php
    branches/Version-2_0-branch/booking/inc/class.uisystem_message.inc.php
    branches/Version-2_0-branch/booking/templates/base/application.xsl

Property Changed:
----------------
    branches/Version-2_0-branch/
    branches/Version-2_0-branch/booking/


Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842
   + /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845


Property changes on: branches/Version-2_0-branch/booking
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842
   + /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845

Modified: branches/Version-2_0-branch/booking/inc/class.boapplication.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.boapplication.inc.php 
2016-03-16 14:08:23 UTC (rev 14845)
+++ branches/Version-2_0-branch/booking/inc/class.boapplication.inc.php 
2016-03-16 14:11:21 UTC (rev 14846)
@@ -215,20 +215,34 @@
                 * which the given user has access to
                 *
                 * @param int $user_id
+                * @param int $building_id
                 */
-               public function accessable_applications( $user_id )
+               public function accessable_applications( $user_id, $building_id 
)
                {
                        $applications = array();
                        $this->db = & $GLOBALS['phpgw']->db;
 
-                       $sql = "SELECT DISTINCT ap.id
-                                       FROM bb_application ap
-                                       INNER JOIN bb_application_resource ar 
ON ar.application_id = ap.id
-                                       INNER JOIN bb_resource re ON re.id = 
ar.resource_id
-                                       INNER JOIN bb_building_resource br ON 
re.id = br.resource_id
-                                       INNER JOIN bb_building bu ON bu.id = 
br.resource_id
-                                       INNER JOIN bb_permission pe ON 
pe.object_id = bu.id and pe.object_type = 'building'
-                                       WHERE pe.subject_id = " . $user_id;
+                       $filtermethod = array();
+
+                       $filtermethod[] = '1=1';
+
+                       if($user_id)
+                       {
+                               $filtermethod[] = "pe.subject_id = {$user_id}";
+                       }
+                       if($building_id)
+                       {
+                               $filtermethod[] = "bu.id = {$building_id}";
+                       }
+
+                       $sql = "SELECT DISTINCT ap.id"
+                               . " FROM bb_application ap"
+                               . " INNER JOIN bb_application_resource ar ON 
ar.application_id = ap.id"
+                               . " INNER JOIN bb_building_resource br ON 
br.resource_id = ar.resource_id"
+                               . " INNER JOIN bb_building bu ON bu.id = 
br.building_id"
+                               . " INNER JOIN bb_permission pe ON pe.object_id 
= bu.id and pe.object_type = 'building'"
+                               . " WHERE " . implode(' AND ', $filtermethod);
+
                        $this->db->query($sql);
                        $result = $this->db->resultSet;
 

Modified: branches/Version-2_0-branch/booking/inc/class.uiapplication.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.uiapplication.inc.php 
2016-03-16 14:08:23 UTC (rev 14845)
+++ branches/Version-2_0-branch/booking/inc/class.uiapplication.inc.php 
2016-03-16 14:11:21 UTC (rev 14846)
@@ -137,7 +137,7 @@
 
                protected function is_assigned_to_current_user( &$application )
                {
-                       $current_account_id = 7;
+                       $current_account_id = $this->current_account_id();
                        if (empty($current_account_id) || 
!isset($application['case_officer_id']))
                        {
                                return false;
@@ -157,7 +157,7 @@
 
                protected function assign_to_current_user( &$application )
                {
-                       $current_account_id = 7;
+                       $current_account_id = $this->current_account_id();
 
                        if (!empty($current_account_id) && 
is_array($application) &&
                                !isset($application['case_officer_id']) || 
$application['case_officer_id'] != $current_account_id)
@@ -248,8 +248,10 @@
                        {
                                return $this->query();
                        }
+                       phpgwapi_jquery::load_widget('autocomplete');
 
                        $data = array(
+                               'datatable_name' => lang('application'),
                                'form' => array(
                                        'toolbar' => array(
                                                'item' => array(
@@ -280,21 +282,29 @@
                                                                        )
                                                                )
                                                        ),
-                                                       array('type' => 
'filter',
+/*                                                     array('type' => 
'filter',
                                                                'name' => 
'buildings',
                                                                'text' => 
lang('Building') . ':',
                                                                'list' => 
$this->bo->so->get_buildings(),
                                                        ),
+*/
+                                                       array('type' => 
'autocomplete',
+                                                               'name' => 
'building',
+                                                               'ui' => 
'building',
+                                                               'text' => 
lang('Building') . ':',
+                                                               'onItemSelect' 
=> 'updateBuildingFilter',
+                                                               
'onClearSelection' => 'clearBuildingFilter'
+                                                       ),
                                                        array('type' => 
'filter',
                                                                'name' => 
'activities',
                                                                'text' => 
lang('Activity') . ':',
                                                                'list' => 
$this->bo->so->get_activities_main_level(),
                                                        ),
-                                                       array(
+                                               /*      array(
                                                                'type' => 
'link',
                                                                'value' => 
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
                                                                'href' => 
self::link(array('menuaction' => $this->url_prefix . '.toggle_show_inactive'))
-                                                       ),
+                                                       ),*/
                                                ),
                                        ),
                                ),
@@ -359,36 +369,31 @@
 
                public function query()
                {
-
+                       $building_id = phpgw::get_var('filter_building_id', 
'int', 'REQUEST', null);
                        // users with the booking role admin should have access 
to all buildings
                        // admin users should have access to all buildings
-                       if 
(!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) &&
-                               
!$this->bo->has_role(booking_sopermission::ROLE_MANAGER))
+                       if 
(!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) && 
!$this->bo->has_role(booking_sopermission::ROLE_MANAGER))
                        {
-                               $filters['id'] = 
$this->bo->accessable_applications($GLOBALS['phpgw_info']['user']['id']);
+                               $filters['id'] = 
$this->bo->accessable_applications($GLOBALS['phpgw_info']['user']['id'], 
$building_id);
                        }
+                       else if($building_id)
+                       {
+                               $filters['id'] = 
$this->bo->accessable_applications(null, $building_id);
+                       }
+
+                       $activity_id = phpgw::get_var('activities', 'int', 
'REQUEST', null);
+                       if ($activity_id)
+                       {
+                               $filters['activity_id'] = 
$this->bo->so->get_activities($activity_id);
+                       }
+                       else
+                       {
+                               unset($filters['activity_id']);
+                       }
                        $filters['status'] = 'NEW';
                        if (isset($_SESSION['showall']))
                        {
                                $filters['status'] = array('NEW', 'PENDING', 
'REJECTED', 'ACCEPTED');
-                               $testdata = phpgw::get_var('buildings', 'int', 
'REQUEST', null);
-                               if ($testdata != 0)
-                               {
-                                       $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('buildings', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['building_name']);
-                               }
-                               $testdata2 = phpgw::get_var('activities', 
'int', 'REQUEST', null);
-                               if ($testdata2 != 0)
-                               {
-                                       $filters['activity_id'] = 
$this->bo->so->get_activities(phpgw::get_var('activities', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['activity_id']);
-                               }
                        }
                        else
                        {
@@ -399,30 +404,12 @@
                                }
                                elseif (isset($test))
                                {
-                                       $filters['status'] = 
phpgw::get_var('status');
+                                       $filters['status'] = $test;
                                }
                                else
                                {
                                        $filters['status'] = 'NEW';
                                }
-                               $testdata = phpgw::get_var('buildings', 'int', 
'REQUEST', null);
-                               if ($testdata != 0)
-                               {
-                                       $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('buildings', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['building_name']);
-                               }
-                               $testdata2 = phpgw::get_var('activities', 
'int', 'REQUEST', null);
-                               if ($testdata2 != 0)
-                               {
-                                       $filters['activity_id'] = 
$this->bo->so->get_activities(phpgw::get_var('activities', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['activity_id']);
-                               }
                        }
 
                        $search = phpgw::get_var('search');
@@ -482,123 +469,6 @@
                        return $this->jquery_results($applications);
                }
 
-               public function index_json()
-               {
-                       // users with the booking role admin should have access 
to all buildings
-                       // admin users should have access to all buildings
-                       if 
(!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) &&
-                               
!$this->bo->has_role(booking_sopermission::ROLE_MANAGER))
-                       {
-                               $filters['id'] = 
$this->bo->accessable_applications($GLOBALS['phpgw_info']['user']['id']);
-                       }
-                       $filters['status'] = 'NEW';
-                       if (isset($_SESSION['showall']))
-                       {
-                               $filters['status'] = array('NEW', 'PENDING', 
'REJECTED', 'ACCEPTED');
-                               $testdata = phpgw::get_var('buildings', 'int', 
'REQUEST', null);
-                               if ($testdata != 0)
-                               {
-                                       $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('buildings', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['building_name']);
-                               }
-                               $testdata2 = phpgw::get_var('activities', 
'int', 'REQUEST', null);
-                               if ($testdata2 != 0)
-                               {
-                                       $filters['activity_id'] = 
$this->bo->so->get_activities(phpgw::get_var('activities', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['activity_id']);
-                               }
-                       }
-                       else
-                       {
-                               $test = phpgw::get_var('status', 'string', 
'REQUEST', null);
-                               if (phpgw::get_var('status') == 'none')
-                               {
-                                       $filters['status'] = array('NEW', 
'PENDING', 'REJECTED', 'ACCEPTED');
-                               }
-                               elseif (isset($test))
-                               {
-                                       $filters['status'] = 
phpgw::get_var('status');
-                               }
-                               else
-                               {
-                                       $filters['status'] = 'NEW';
-                               }
-                               $testdata = phpgw::get_var('buildings', 'int', 
'REQUEST', null);
-                               if ($testdata != 0)
-                               {
-                                       $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('buildings', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['building_name']);
-                               }
-                               $testdata2 = phpgw::get_var('activities', 
'int', 'REQUEST', null);
-                               if ($testdata2 != 0)
-                               {
-                                       $filters['activity_id'] = 
$this->bo->so->get_activities(phpgw::get_var('activities', 'int', 'REQUEST', 
null));
-                               }
-                               else
-                               {
-                                       unset($filters['activity_id']);
-                               }
-                       }
-
-                       $params = array(
-                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
-                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', null),
-                               'query' => phpgw::get_var('query'),
-                               'sort' => phpgw::get_var('sort'),
-                               'dir' => phpgw::get_var('dir'),
-                               'filters' => $filters
-                       );
-
-                       $applications = $this->bo->so->read($params);
-
-                       foreach ($applications['results'] as &$application)
-                       {
-                               if (strstr($application['building_name'], "%"))
-                               {
-                                       $search = array('%2C', '%C3%85', 
'%C3%A5', '%C3%98', '%C3%B8', '%C3%86',
-                                               '%C3%A6');
-                                       $replace = array(',', 'Å', 'å', 'Ø', 
'ø', 'Æ', 'æ');
-                                       $application['building_name'] = 
str_replace($search, $replace, $application['building_name']);
-                               }
-
-                               $dates = array();
-                               foreach ($application['dates'] as $data)
-                               {
-                                       $dates[] = $data['from_'];
-                                       break;
-                               }
-                               $fromdate = implode(',', $dates);
-                               $application['from_'] = 
pretty_timestamp($fromdate);
-                               $application['status'] = 
lang($application['status']);
-                               $application['created'] = 
pretty_timestamp($application['created']);
-                               $application['modified'] = 
pretty_timestamp($application['modified']);
-                               $application['frontend_modified'] = 
pretty_timestamp($application['frontend_modified']);
-                               $application['resources'] = 
$this->resource_bo->so->read(array('filters' => array(
-                                               'id' => 
$application['resources'])));
-                               $application['resources'] = 
$application['resources']['results'];
-                               if ($application['resources'])
-                               {
-                                       $names = array();
-                                       foreach ($application['resources'] as 
$res)
-                                       {
-                                               $names[] = $res['name'];
-                                       }
-                                       $application['what'] = 
$application['resources'][0]['building_name'] . ' (' . join(', ', $names) . ')';
-                               }
-                       }
-                       array_walk($applications["results"], array($this, 
"_add_links"), "booking.uiapplication.show");
-                       return $this->yui_results($applications);
-               }
-
                public function associated()
                {
                        $associations = $this->assoc_bo->read();
@@ -655,7 +525,7 @@
                                        'name' => 
$application['case_officer_name'],
                                );
 
-                               if ($application['case_officer_id'] == 7)
+                               if ($application['case_officer_id'] == 
$this->current_account_id())
                                {
                                        
$application['case_officer']['is_current_user'] = true;
                                }
@@ -1278,10 +1148,14 @@
                        }
                        $from = array("data" => implode(',', $from));
                        $num_associations = $associations['total_records'];
-                       if ($this->is_assigned_to_current_user($application) && 
$GLOBALS['phpgw']->acl->check('admin', phpgwapi_acl::ADD, 'booking'))
+                       if ($this->is_assigned_to_current_user($application) || 
$GLOBALS['phpgw']->acl->check('admin', phpgwapi_acl::ADD, 'booking'))
+                       {
                                $application['currentuser'] = true;
+                       }
                        else
+                       {
                                $application['currentuser'] = false;
+                       }
 
                        $collision_dates = array();
                        foreach ($application['dates'] as &$date)

Modified: branches/Version-2_0-branch/booking/inc/class.uidashboard.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.uidashboard.inc.php   
2016-03-16 14:08:23 UTC (rev 14845)
+++ branches/Version-2_0-branch/booking/inc/class.uidashboard.inc.php   
2016-03-16 14:11:21 UTC (rev 14846)
@@ -81,6 +81,7 @@
                        phpgwapi_jquery::load_widget('autocomplete');
 
                        $data = array(
+                               'datatable_name' => lang('dashboard'),
                                'form' => array(
                                        'toolbar' => array(
                                                'item' => array(

Modified: branches/Version-2_0-branch/booking/inc/class.uisystem_message.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.uisystem_message.inc.php      
2016-03-16 14:08:23 UTC (rev 14845)
+++ branches/Version-2_0-branch/booking/inc/class.uisystem_message.inc.php      
2016-03-16 14:11:21 UTC (rev 14846)
@@ -147,10 +147,9 @@
                {
                        $this->db = & $GLOBALS['phpgw']->db;
 
-//            $current_user = $this->current_account_id();
-                       $current_user = 7;
+            $current_user = (int)$this->current_account_id();
                        $current_user_building_data = array();
-                       $sql = "select object_id from bb_permission where 
subject_id=" . $current_user . " and role='case_officer';";
+                       $sql = "SELECT object_id FROM bb_permission WHERE 
subject_id= {$current_user} AND role='case_officer';";
                        $this->db->query($sql);
                        while ($record = array_shift($this->db->resultSet))
                        {
@@ -221,8 +220,11 @@
                                $this->db->query($sql);
                                while ($record = 
array_shift($this->db->resultSet))
                                {
-                                       $building_case_officers_data[] = 
array('account_id' => $record['account_id'],
-                                               'account_lid' => 
$record['account_lid'], 'account_name' => $record['account_firstname'] . " " . 
$record['account_lastname']);
+                                       $building_case_officers_data[] = array(
+                                               'account_id' => 
$record['account_id'],
+                                               'account_lid' => 
$record['account_lid'],
+                                               'account_name' => 
$record['account_firstname'] . " " . $record['account_lastname']
+                                       );
                                        $building_case_officers[] = 
$record['account_id'];
                                }
 
@@ -245,7 +247,9 @@
                                while ($case_officer = 
array_shift($building_case_officers_data))
                                {
                                        if 
($system_message['case_officer_name'] = $case_officer['account_id'])
+                                       {
                                                
$system_message['case_officer_name'] = $case_officer['account_name'];
+                                       }
                                }
                        }
                        return $this->jquery_results($system_messages);

Modified: branches/Version-2_0-branch/booking/templates/base/application.xsl
===================================================================
--- branches/Version-2_0-branch/booking/templates/base/application.xsl  
2016-03-16 14:08:23 UTC (rev 14845)
+++ branches/Version-2_0-branch/booking/templates/base/application.xsl  
2016-03-16 14:11:21 UTC (rev 14846)
@@ -429,16 +429,14 @@
                                                                        <label>
                                                                                
<xsl:value-of select="php:function('lang', 'organization number')" />
                                                                        </label>
-                                                                       <span>
-                                                                               
<xsl:value-of select="application/customer_organization_number"/>
-                                                                       </span>
+                                                                       <br/>
+                                                                       
<xsl:value-of select="application/customer_organization_number"/>
                                                                </xsl:if>
-                                                       </div>
-                                                       <div 
class="pure-control-group">
                                                                <xsl:if 
test="application/customer_identifier_type = 'ssn'">
                                                                        <label>
                                                                                
<xsl:value-of select="php:function('lang', 'Date of birth or SSN')" />
                                                                        </label>
+                                                                       <br/>
                                                                        
<xsl:value-of select="application/customer_ssn"/>
                                                                </xsl:if>
                                                        </div>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]