[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11487] frontend: fetch contracts
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11487] frontend: fetch contracts |
Date: |
Mon, 25 Nov 2013 12:44:41 +0000 |
Revision: 11487
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11487
Author: sigurdne
Date: 2013-11-25 12:44:37 +0000 (Mon, 25 Nov 2013)
Log Message:
-----------
frontend: fetch contracts
Modified Paths:
--------------
trunk/frontend/inc/class.borental.inc.php
trunk/frontend/inc/class.uicontract.inc.php
trunk/frontend/inc/class.uicontract_ex.inc.php
trunk/frontend/inc/class.uicontract_in.inc.php
trunk/frontend/inc/class.uicontract_internal.inc.php
trunk/frontend/inc/class.uifrontend.inc.php
Modified: trunk/frontend/inc/class.borental.inc.php
===================================================================
--- trunk/frontend/inc/class.borental.inc.php 2013-11-24 20:13:53 UTC (rev
11486)
+++ trunk/frontend/inc/class.borental.inc.php 2013-11-25 12:44:37 UTC (rev
11487)
@@ -33,6 +33,7 @@
class frontend_borental
{
+/* //FIXME Sigurd 22. nov 2013: - not used?
public static function contract_exist_per_location($contract_id,
$location_code, $contract_state_identifier)
{
$contracts_per_location =
phpgwapi_cache::session_get('frontend', $contract_state_identifier);
@@ -46,7 +47,7 @@
}
return $exist;
}
-
+*/
public static function send_contract_message(int $contract_id, string
$contract_message, string $from_address)
{
$contract =
rental_socontract::get_instance()->get_single($contract_id);
Modified: trunk/frontend/inc/class.uicontract.inc.php
===================================================================
--- trunk/frontend/inc/class.uicontract.inc.php 2013-11-24 20:13:53 UTC (rev
11486)
+++ trunk/frontend/inc/class.uicontract.inc.php 2013-11-25 12:44:37 UTC (rev
11487)
@@ -14,15 +14,18 @@
protected $form_url;
- public $public_functions = array(
- 'index' => true
+ public $public_functions = array
+ (
+ 'index' => true
);
public function __construct()
{
parent::__construct();
+// $this->get_contracts_per_location();
}
+
/**
* Show single contract details
*/
@@ -36,19 +39,19 @@
// The user wants to change the contract status filter
if(isset($filter))
{
- $this->contract_filter = $filter;
- phpgwapi_cache::session_set('frontend',
'contract_filter', $filter);
+ $this->contract_filter = $filter;
+ phpgwapi_cache::session_set('frontend',
'contract_filter', $filter);
- // ... if the user changes filter that may
cause the
- if($filter == 'active' || $filter ==
'not_active')
- {
- $change_contract = true;
- }
+ // ... if the user changes filter that may cause the
+ if($filter == 'active' || $filter == 'not_active')
+ {
+ $change_contract = true;
+ }
}
else
{
$filter = phpgwapi_cache::session_get('frontend',
'contract_filter');
- $this->contract_filter = isset($filter) ? $filter :
'active';
+ $this->contract_filter = isset($filter) && $filter ?
$filter : 'active';
}
if(isset($_POST['send']))
@@ -99,9 +102,12 @@
// The current state of the contract view of this user's session
$this->contract_state = phpgwapi_cache::session_get('frontend',
$this->contract_state_identifier);
$new_contract = phpgw::get_var('contract_id');
- $contracts_per_location =
phpgwapi_cache::session_get('frontend',
$this->contracts_per_location_identifier);
+
+ $contracts_per_location = $this->get_contracts_per_location();
+
$contracts_for_selection = array();
$number_of_valid_contracts = 0;
+
foreach($contracts_per_location[$this->header_state['selected_location']] as
$contract)
{
if( ($this->contract_filter == 'active' &&
$contract->is_active()) ||
@@ -186,9 +192,105 @@
'form_url' => $this->form_url
)
);
-
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('app_data' =>
$data));
$GLOBALS['phpgw']->xslttpl->add_file(array('frontend','contract'));
+ }
+
+
+ private function get_contracts_per_location()
+ {
+ $org_unit = $this->header_state['selected_org_unit'];
+ if($org_unit == 'all' || $org_unit == 'none')
+ {
+ phpgwapi_cache::message_set('Velg organisasjon',
'error');
+ return array();
+ }
+
+ $values = phpgwapi_cache::session_get('frontend',
$this->contracts_per_location_identifier);
+ if(isset($values[$org_unit]))
+ {
+ return $values[$org_unit];
+ }
+
+ $parties = rental_soparty::get_instance()->get(null, null,
null, null, null, null, array('org_unit_id' => $org_unit));
+
+ $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);
+
+ $contracts_per_location = array();
+ $contracts_in_per_location = array();
+ $contracts_ex_per_location = 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[$org_unit][$property_location->get_location_code()]))
+ {
+
$contracts_per_location[$org_unit][$property_location->get_location_code()] =
array();
+ }
+
array_push($contracts_per_location[$org_unit][$property_location->get_location_code()],
$contract);
+ }
+ 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(!is_array($contracts_in_per_location[$org_unit][$property_location->get_location_code()]))
+ {
+
$contracts_in_per_location[$org_unit][$property_location->get_location_code()]
= array();
+ }
+
array_push($contracts_in_per_location[$org_unit][$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[$org_unit][$property_location->get_location_code()]))
+ {
+
$contracts_ex_per_location[$org_unit][$property_location->get_location_code()]
= array();
+ }
+
array_push($contracts_ex_per_location[$org_unit][$property_location->get_location_code()],
$contract);
+ }
+ }
+ }
+ }
+ }
+ phpgwapi_cache::session_set('frontend',
'contracts_per_location', $contracts_per_location);
+ phpgwapi_cache::session_set('frontend',
'contracts_in_per_location', $contracts_in_per_location);
+ phpgwapi_cache::session_set('frontend',
'contracts_ex_per_location', $contracts_ex_per_location);
+ return $$this->contracts_per_location_identifier[$org_unit];
}
}
Modified: trunk/frontend/inc/class.uicontract_ex.inc.php
===================================================================
--- trunk/frontend/inc/class.uicontract_ex.inc.php 2013-11-24 20:13:53 UTC
(rev 11486)
+++ trunk/frontend/inc/class.uicontract_ex.inc.php 2013-11-25 12:44:37 UTC
(rev 11487)
@@ -31,7 +31,8 @@
{
$this->contract_state_identifier = "contract_state_ex";
$this->contracts_per_location_identifier =
"contracts_ex_per_location";
- $this->form_url =
"index.php?menuaction=frontend.uicontract_ex.index";
+ // $this->form_url =
"index.php?menuaction=frontend.uicontract_ex.index";
+ $this->form_url =
$GLOBALS['phpgw']->link('/',array('menuaction' =>
'frontend.uicontract_ex.index'));
phpgwapi_cache::session_set('frontend','tab',$GLOBALS['phpgw']->locations->get_id('frontend','.rental.contract_ex'));
parent::__construct();
}
Modified: trunk/frontend/inc/class.uicontract_in.inc.php
===================================================================
--- trunk/frontend/inc/class.uicontract_in.inc.php 2013-11-24 20:13:53 UTC
(rev 11486)
+++ trunk/frontend/inc/class.uicontract_in.inc.php 2013-11-25 12:44:37 UTC
(rev 11487)
@@ -8,7 +8,8 @@
{
$this->contract_state_identifier = "contract_state_in";
$this->contracts_per_location_identifier =
"contracts_in_per_location";
- $this->form_url =
"index.php?menuaction=frontend.uicontract_in.index";
+// $this->form_url =
"index.php?menuaction=frontend.uicontract_in.index";
+ $this->form_url =
$GLOBALS['phpgw']->link('/',array('menuaction' =>
'frontend.uicontract_in.index'));
phpgwapi_cache::session_set('frontend','tab',$GLOBALS['phpgw']->locations->get_id('frontend','.rental.contract_in'));
parent::__construct();
}
Modified: trunk/frontend/inc/class.uicontract_internal.inc.php
===================================================================
--- trunk/frontend/inc/class.uicontract_internal.inc.php 2013-11-24
20:13:53 UTC (rev 11486)
+++ trunk/frontend/inc/class.uicontract_internal.inc.php 2013-11-25
12:44:37 UTC (rev 11487)
@@ -8,7 +8,8 @@
{
$this->contract_state_identifier = "contract_state";
$this->contracts_per_location_identifier =
"contracts_per_location";
- $this->form_url =
"index.php?menuaction=frontend.uicontract_internal.index";
+ // $this->form_url =
"index.php?menuaction=frontend.uicontract_internal.index";
+ $this->form_url =
$GLOBALS['phpgw']->link('/',array('menuaction' =>
'frontend.uicontract_internal.index'));
phpgwapi_cache::session_set('frontend','tab',$GLOBALS['phpgw']->locations->get_id('frontend','.rental.contract'));
parent::__construct();
}
Modified: trunk/frontend/inc/class.uifrontend.inc.php
===================================================================
--- trunk/frontend/inc/class.uifrontend.inc.php 2013-11-24 20:13:53 UTC (rev
11486)
+++ trunk/frontend/inc/class.uifrontend.inc.php 2013-11-25 12:44:37 UTC (rev
11487)
@@ -346,7 +346,8 @@
$vfs->override_acl = 1;
$file = array('string' => $fileName, RELATIVE_NONE);
- if($vfs->file_exists($file)){
+ if($vfs->file_exists($file))
+ {
$help_in_vfs = true;
}
@@ -358,7 +359,9 @@
'menuaction'=>
'frontend.uidocumentupload.read_helpfile_from_vfs',
'app' => 'frontend'
)) . "','700','600')";
- }else{
+ }
+ else
+ {
$help_url = "javascript:openwindow('"
.
$GLOBALS['phpgw']->link('/index.php', array
(
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11487] frontend: fetch contracts,
Sigurd Nes <=