[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11380] frontend: try to ease the workload to find da
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11380] frontend: try to ease the workload to find data |
Date: |
Fri, 18 Oct 2013 12:29:11 +0000 |
Revision: 11380
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11380
Author: sigurdne
Date: 2013-10-18 12:29:11 +0000 (Fri, 18 Oct 2013)
Log Message:
-----------
frontend: try to ease the workload to find data
Modified Paths:
--------------
trunk/frontend/inc/class.borental.inc.php
trunk/frontend/inc/class.sorental.inc.php
trunk/frontend/inc/class.uifrontend.inc.php
trunk/frontend/templates/base/frontend.xsl
Modified: trunk/frontend/inc/class.borental.inc.php
===================================================================
--- trunk/frontend/inc/class.borental.inc.php 2013-10-18 09:28:41 UTC (rev
11379)
+++ trunk/frontend/inc/class.borental.inc.php 2013-10-18 12:29:11 UTC (rev
11380)
@@ -263,18 +263,7 @@
public static function
get_property_locations_lean($array,$top_org_units)
{
- $property_locations = array();
- $property_locations_active = array();
-
- $total_price_all_buildings = 0;
- $total_rented_area_all_builings = 0;
-
- $types =
rental_socontract::get_instance()->get_fields_of_responsibility();
- $location_id_internal =
array_search('contract_type_internleie', $types);
- $location_id_in = array_search('contract_type_innleie', $types);
- $location_id_ex = array_search('contract_type_eksternleie',
$types);
-
- foreach($array as $row)
+ foreach($array as $row)
{
/*
* 1. hent alle kontraktsparter som har org unit id (foreløpig
bruker vi result_unit_number i rentalparty)
@@ -288,9 +277,7 @@
{
continue;
}
- // $parties =
rental_soparty::get_instance()->get(null, null, null, null, null, null,
array('org_unit_id' => $row['ORG_UNIT_ID']));
- // $parties = array_keys($parties);
- $parties =
self::get_all_parties($top_org_units);
+ $parties =
self::get_all_parties($top_org_units, $row['ORG_UNIT_ID']);
}
else
{
@@ -305,7 +292,6 @@
//For all parties connected to the internal
organization unit
$locations = $sorental->get_location($parties);
-
}
return $locations;
@@ -315,7 +301,7 @@
/**
* Get the org_units by hierarchical inheritance
*/
- function get_all_parties($top_org_units)
+ function get_all_parties($top_org_units =
array(),$selected_org_unit = 0)
{
static $parties =array(); // cache result
@@ -331,7 +317,7 @@
*/
$org_units = array();
- $selected_org_unit = phpgw::get_var('org_unit_id');
// New organisational unit selected from organisational units
list
+
if($selected_org_unit == 'all')
{
foreach($top_org_units as $entry)
@@ -339,7 +325,7 @@
$org_units[] = $entry['ORG_UNIT_ID'];
}
}
- else
+ else if ($selected_org_unit != 'none')
{
$org_units[] = $selected_org_unit;
}
@@ -361,10 +347,10 @@
}
- public static function get_total_cost_and_area($org_units =
array())
+ public static function get_total_cost_and_area($org_units =
array(),$selected_location ='')
{
$sorental = CreateObject('frontend.sorental');
- return $sorental->get_total_cost_and_area($org_units);
+ return $sorental->get_total_cost_and_area($org_units,
$selected_location);
}
}
Modified: trunk/frontend/inc/class.sorental.inc.php
===================================================================
--- trunk/frontend/inc/class.sorental.inc.php 2013-10-18 09:28:41 UTC (rev
11379)
+++ trunk/frontend/inc/class.sorental.inc.php 2013-10-18 12:29:11 UTC (rev
11380)
@@ -1,6 +1,6 @@
<?php
/**
- * Common so-functions, database related helpers
+ * Frontend : a simplified tool for end users.
* @author Sigurd Nes <address@hidden>
* @copyright Copyright (C) 2012 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License v2 or later
@@ -182,7 +182,7 @@
return $values;
}
- public function get_total_cost_and_area($org_units = array())
+ public function get_total_cost_and_area($org_units = array(),
$selected_location = '')
{
if(!$org_units)
{
@@ -194,22 +194,35 @@
//active contract
$filtermethod .= " AND ({$ts} >=
rental_contract.date_start AND (rental_contract.date_end IS NULL OR {$ts} <=
rental_contract.date_end))";
+
+ $join_method = '';
+ if($selected_location)
+ {
+ $filtermethod .= " AND location_code
{$this->_db->like} '{$selected_location}%'";
+ $join_method = " {$this->_db->join}
rental_contract_composite ON (rental_contract.id =
rental_contract_composite.contract_id)"
+ . " {$this->_db->join} rental_composite
ON (rental_contract_composite.composite_id = rental_composite.id)"
+ . " {$this->_db->join} rental_unit ON
(rental_composite.id = rental_unit.composite_id) ";
+
+ }
+
$sql = "SELECT sum(total_price::numeric) AS
sum_total_price FROM"
. " rental_contract {$this->_db->join}
rental_contract_party ON (rental_contract.id =
rental_contract_party.contract_id)"
. " {$this->_db->join} rental_party ON (rental_party.id
= rental_contract_party.party_id)"
. " {$this->_db->join} rental_contract_price_item ON
(rental_contract.id = rental_contract_price_item.contract_id)"
- . " {$filtermethod} AND NOT is_one_time";
+ . " {$join_method}{$filtermethod} AND NOT is_one_time";
+
$this->_db->query($sql,__LINE__,__FILE__);
$values = array();
$this->_db->next_record();
$values['sum_total_price'] =
$this->_db->f('sum_total_price');
+
$sql = "SELECT
sum(rental_contract.rented_area::numeric) AS sum_total_area FROM"
. " rental_contract {$this->_db->join}
rental_contract_party ON (rental_contract.id =
rental_contract_party.contract_id)"
. " {$this->_db->join} rental_party ON (rental_party.id
= rental_contract_party.party_id)"
- . " {$filtermethod}";
+ . " {$join_method}{$filtermethod}";
$this->_db->query($sql,__LINE__,__FILE__);
Modified: trunk/frontend/inc/class.uifrontend.inc.php
===================================================================
--- trunk/frontend/inc/class.uifrontend.inc.php 2013-10-18 09:28:41 UTC (rev
11379)
+++ trunk/frontend/inc/class.uifrontend.inc.php 2013-10-18 12:29:11 UTC (rev
11380)
@@ -88,7 +88,7 @@
$property_locations_update = false;
/* If the user has selected an organisational unit or
all units */
- if(isset($param_selected_org_unit) &&
$param_selected_org_unit)
+ if(isset($param_selected_org_unit) &&
$param_selected_org_unit && $param_selected_org_unit != 'none')
{
//Specify which unit(s)
if($param_selected_org_unit == 'all')
@@ -112,7 +112,7 @@
{
//If the organisational unit
selected is not in list; do default 'all'
$org_unit_ids =
$this->header_state['org_unit'];
- $param_selected_org_unit =
'all';
+ $param_selected_org_unit =
'none';
}
}
$this->header_state['selected_org_unit'] =
$param_selected_org_unit;
@@ -123,8 +123,16 @@
$property_locations_update = true;
}
+ else if($param_selected_org_unit == 'none')
+ {
+ $this->header_state['selected_org_unit'] =
$param_selected_org_unit;
+ $property_locations = array();
+ $this->header_state['locations'] =
$property_locations;
+ $this->header_state['number_of_locations'] =
count($property_locations);
+ }
+
/* If the user selects a organisational unit in rental
module */
- else if(isset($param_only_org_unit) &&
$param_only_org_unit)
+ else if(isset($param_only_org_unit) &&
$param_only_org_unit && $param_selected_org_unit != 'none')
{
//TODO: check permissions
if($use_fellesdata)
@@ -175,13 +183,13 @@
//Update org units on header state
$this->header_state['org_unit'] =
$org_units;
$this->header_state['number_of_org_units'] = count($org_units);
-
$this->header_state['selected_org_unit'] = 'all';
+
$this->header_state['selected_org_unit'] = 'none';
//Update locations
//FIXME Sigurd 15. okt 2013: deselect
'all' on initial view
//$property_locations =
frontend_borental::get_property_locations($org_units,
$this->header_state['org_unit']);
}
- else
+ else if ( $param_selected_org_unit != 'none')
{
//If no organisational database is in
use: get rented properties based on username
$usernames[] =
$GLOBALS['phpgw_info']['user']['account_lid'];
@@ -215,7 +223,7 @@
/* If the user has selected a location or as a
side-effect from selecting organisational unit */
- if(isset($param_selected_location))
+ if($param_selected_location)
{
$locs = $this->header_state['locations'];
$exist = false;
@@ -229,11 +237,14 @@
if($exist)
{
- $tppl =
phpgwapi_cache::session_get('frontend','total_price_per_location');
- $tapl =
phpgwapi_cache::session_get('frontend','rented_area_per_location');
$this->header_state['selected_location'] = $param_selected_location;
-
$this->header_state['selected_total_price'] =
number_format($tppl[$param_selected_location],2,","," ")." ".lang('currency');
-
$this->header_state['selected_total_area'] =
number_format($tapl[$param_selected_location],2,","," ")."
".lang('square_meters');
+
+ $parties =
frontend_borental::get_all_parties(array(),
$this->header_state['selected_org_unit']);
+ $totals =
frontend_borental::get_total_cost_and_area($parties, $param_selected_location);
+
+
$this->header_state['selected_total_price'] =
number_format($totals['sum_total_price'],2,","," ")." ".lang('currency');
+
$this->header_state['selected_total_area'] =
number_format($totals['sum_total_area'],2,","," ")." ".lang('square_meters');
+
phpgwapi_cache::session_set('frontend',
'header_state', $this->header_state);
}
else
Modified: trunk/frontend/templates/base/frontend.xsl
===================================================================
--- trunk/frontend/templates/base/frontend.xsl 2013-10-18 09:28:41 UTC (rev
11379)
+++ trunk/frontend/templates/base/frontend.xsl 2013-10-18 12:29:11 UTC (rev
11380)
@@ -44,32 +44,27 @@
<li>
<form
action="{form_action}" method="post">
<select
size="3" onchange="this.form.submit()" name="org_unit_id">
-
<xsl:choose>
-
<xsl:when test="selected_org_unit = 'all'">
-
<!-- <option value="all" selected="selected"><xsl:value-of
select="php:function('lang', 'all_organisational_units')"/></option> -->
-
<option value="" selected="selected"><xsl:value-of
select="php:function('lang', 'select')"/></option>
-
<xsl:for-each select="org_unit">
-
<xsl:sort select="ORG_NAME"/>
-
<option value="{ORG_UNIT_ID}"><xsl:value-of
select="ORG_NAME"/></option>
-
</xsl:for-each>
-
</xsl:when>
-
<xsl:otherwise>
- <!--
<option value="all"><xsl:value-of select="php:function('lang',
'all_organisational_units')"/></option> -->
-
<option value=""><xsl:value-of select="php:function('lang',
'select')"/></option>
-
<xsl:for-each select="org_unit">
-
<xsl:sort select="ORG_NAME"/>
-
<xsl:choose>
-
<xsl:when test="ORG_UNIT_ID =
//header/selected_org_unit">
-
<option value="{ORG_UNIT_ID}"
selected="selected"><xsl:value-of select="ORG_NAME"/></option>
-
</xsl:when>
-
<xsl:otherwise>
-
<option
value="{ORG_UNIT_ID}"><xsl:value-of select="ORG_NAME"/></option>
-
</xsl:otherwise>
-
</xsl:choose>
-
</xsl:for-each>
-
</xsl:otherwise>
-
-
</xsl:choose>
+ <option
value="none">
+
<xsl:if test="'none' = //header/selected_org_unit">
+
<xsl:attribute name="selected" value="selected"/>
+
</xsl:if>
+
<xsl:value-of select="php:function('lang', 'none')"/>
+
</option>
+ <option
value="all">
+
<xsl:if test="'all' = //header/selected_org_unit">
+
<xsl:attribute name="selected" value="selected"/>
+
</xsl:if>
+
<xsl:value-of select="php:function('lang', 'all_organisational_units')"/>
+
</option>
+
<xsl:for-each select="org_unit">
+
<xsl:sort select="ORG_NAME"/>
+
<option value="{ORG_UNIT_ID}" >
+
<xsl:if test="ORG_UNIT_ID = //header/selected_org_unit">
+
<xsl:attribute name="selected" value="selected"/>
+
</xsl:if>
+
<xsl:value-of disable-output-escaping="yes" select="ORG_NAME"/>
+
</option>
+
</xsl:for-each>
</select>
</form>
</li>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11380] frontend: try to ease the workload to find data,
Sigurd Nes <=