fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11381] frontend: try to ease the workload to find da


From: Sigurd Nes
Subject: [Fmsystem-commits] [11381] frontend: try to ease the workload to find data
Date: Fri, 18 Oct 2013 12:31:08 +0000

Revision: 11381
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11381
Author:   sigurdne
Date:     2013-10-18 12:31:08 +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

Modified: trunk/frontend/inc/class.borental.inc.php
===================================================================
--- trunk/frontend/inc/class.borental.inc.php   2013-10-18 12:29:11 UTC (rev 
11380)
+++ trunk/frontend/inc/class.borental.inc.php   2013-10-18 12:31:08 UTC (rev 
11381)
@@ -102,165 +102,12 @@
                return $contracts_in_per_location[$location_code][0];
        }
 
-        /**
-         *
-         * @param integer $org_unit_ids
-         */
-        public static function get_property_locations($array,$top_org_units)
-        {
 
-// _debug_array($array);die();
-                       return 
self::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)
-               {
-                       /*
-             * 1. hent alle kontraktsparter som har org unit id (foreløpig 
bruker vi result_unit_number i rentalparty)
-             * 2. hent alle kontrakter på kontraktspartene
-             * 3. hent alle leieobjekt på kontraktene
-             * 4. hent ut bygg-ider, location_code, fra leieobjektet
-             */
-                       if(is_array($row))
-                       {
-                               if(!isset($row['ORG_UNIT_ID']) || 
$row['ORG_UNIT_ID'] == '')
-                               {
-                                       continue;
-                               }
-                               $parties = 
rental_soparty::get_instance()->get(null, null, null, null, null, null, 
array('org_unit_id' => $row['ORG_UNIT_ID']));
-                       }
-                       else
-                       {
-                               $parties = 
rental_soparty::get_instance()->get(null, null, null, null, null, null, 
array('email' => $row));
-                       }
-
-                       $contracts = array();
-                       $composites = array();
-
-
-                       //For all parties connected to the internal 
organization unit
-                       foreach($parties as $party)
-                       {
-                               //... get the contracts
-                               $contracts = 
rental_socontract::get_instance()->get(null, null, null, null, null, null, 
array('party_id' => $party->get_id()));
-
-                               //... and for each contract connected to this 
contract part
-                               foreach($contracts as $id => $contract)
-                               {
-                                       //... get the composites
-                                       $composites = 
rental_socomposite::get_instance()->get(null, null, null, null, null, null, 
array('contract_id' => $contracts[$id]->get_id()));
-
-                                       //...and for each composite in the 
contract in which this contract part is connected
-                                       foreach($composites as $composite)
-                                       {
-                                               //... get the units
-                                               $units = 
$composite->get_units();
-
-                                               //... and for each unit 
retrieve the property locations we are after
-                                               foreach($units as $unit)
-                                               {
-                                                       $property_location = 
$unit->get_location();
-                                                       
$property_locations[$property_location->get_location_code()] = 
$property_location;
-
-                                                       // Contract holders: 
contracts_per_location (internal) and contracts_in_per_location (in)
-
-                                                       // Internal contract 
should have impact on total price
-                                                       
if($contract->get_location_id() == $location_id_internal)
-                                                       {
-                                                               $total_price = 
rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
-                                                               
$contract->set_total_price($total_price);
-
-                                                               
if(!is_array($contracts_per_location[$property_location->get_location_code()]))
-                                                               {
-                                                                       
$contracts_per_location[$property_location->get_location_code()] = array();
-                                                               }
-                                                               
array_push($contracts_per_location[$property_location->get_location_code()], 
$contract);
-
-                                                               
if($contract->is_active())
-                                                               {
-                                                                       
$property_locations_active[$property_location->get_location_code()] = true;
-                                                                       
$rented_area_per_location[$property_location->get_location_code()] += 
$contract->get_rented_area();
-                                                                       
$rented_price_per_location[$property_location->get_location_code()] += 
$total_price;
-                                                               }
-                                                       }
-                                                       else 
if($contract->get_location_id() == $location_id_in)
-                                                       {
-                                                               $total_price = 
rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
-                                                               
$contract->set_total_price($total_price);
-
-                                                               
if($contract->is_active())
-                                                               {
-                                                                       
$property_locations_active[$property_location->get_location_code()] = true;
-                                                               }
-
-                                                               
if(!is_array($contracts_in_per_location[$property_location->get_location_code()]))
-                                                               {
-                                                                       
$contracts_in_per_location[$property_location->get_location_code()] = array();
-                                                               }
-                                                               
array_push($contracts_in_per_location[$property_location->get_location_code()], 
$contract);
-                                                       }
-                                                       else 
if($contract->get_location_id() == $location_id_ex)
-                                                       {
-                                                               $total_price = 
rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
-                                                               
$contract->set_total_price($total_price);
-
-                                                               
if(!is_array($contracts_ex_per_location[$property_location->get_location_code()]))
-                                                               {
-                                                                       
$contracts_ex_per_location[$property_location->get_location_code()] = array();
-                                                               }
-                                                               
array_push($contracts_ex_per_location[$property_location->get_location_code()], 
$contract);
-
-                                                               
if($contract->is_active())
-                                                               {
-                                                                       
$property_locations_active[$property_location->get_location_code()] = true;
-                                                                       
$rented_area_per_location[$property_location->get_location_code()] += 
$contract->get_rented_area();
-                                                                       
$rented_price_per_location[$property_location->get_location_code()] += 
$total_price;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               //Not used ?
-               phpgwapi_cache::session_set('frontend', 
'contracts_per_location', $contracts_per_location);
-               //Not used ?
-               phpgwapi_cache::session_set('frontend', 
'contracts_in_per_location', $contracts_in_per_location);
-               //Not used ?
-               phpgwapi_cache::session_set('frontend', 
'contracts_ex_per_location', $contracts_ex_per_location);
-               phpgwapi_cache::session_set('frontend', 
'rented_area_per_location', $rented_area_per_location);
-               phpgwapi_cache::session_set('frontend', 
'total_price_per_location', $rented_price_per_location);
-
-               //Serialize the properties
-               $serialized_properties = array();
-               foreach($property_locations as $key => $property_location)
-               {
-                       
if(isset($property_locations_active[$property_location->get_location_code()]) 
&& $property_locations_active[$property_location->get_location_code()])
-                       {
-                               $serialized_properties[] = 
$property_location->serialize();
-                       }
-               }
-
-               return $serialized_properties;
-        }
-
-
         /**
          *
          * @param array $org_unit_ids
          */
-        public static function 
get_property_locations_lean($array,$top_org_units)
+        public static function get_property_locations($array,$top_org_units)
         {
 
                foreach($array as $row)




reply via email to

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