[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16270] rental: status on composites
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16270] rental: status on composites |
Date: |
Tue, 7 Feb 2017 14:42:49 -0500 (EST) |
Revision: 16270
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16270
Author: sigurdne
Date: 2017-02-07 14:42:49 -0500 (Tue, 07 Feb 2017)
Log Message:
-----------
rental: status on composites
Modified Paths:
--------------
trunk/rental/inc/class.socomposite.inc.php
trunk/rental/inc/class.uicomposite.inc.php
trunk/rental/inc/model/class.composite.inc.php
trunk/rental/setup/phpgw_no.lang
trunk/rental/setup/setup.inc.php
trunk/rental/setup/tables_current.inc.php
trunk/rental/setup/tables_update.inc.php
trunk/rental/templates/base/composite.xsl
Modified: trunk/rental/inc/class.socomposite.inc.php
===================================================================
--- trunk/rental/inc/class.socomposite.inc.php 2017-02-07 15:34:39 UTC (rev
16269)
+++ trunk/rental/inc/class.socomposite.inc.php 2017-02-07 19:42:49 UTC (rev
16270)
@@ -65,14 +65,20 @@
switch ($filters['is_active'])
{
case "active":
- $filter_clauses[] =
"rental_composite.is_active = TRUE";
+ $filter_clauses[] =
"rental_composite.status_id = 1";
break;
case "non_active":
- $filter_clauses[] =
"rental_composite.is_active = FALSE";
+ $filter_clauses[] =
"rental_composite.status_id = 2";
break;
case "both":
break;
}
+
+ if ((int)$filters['status_id'] > 0)
+ {
+ $filter_clauses[] = "rental_composite.status_id
= " . (int) $filters['status_id'];
+ }
+
$special_query = false; //specify if the query should
use distinct on rental_composite.id (used for selecting composites that has an
active or inactive contract)
$ts_query = strtotime(date('Y-m-d')); // timestamp for
query (today)
$availability_date_from = $ts_query;
@@ -236,7 +242,7 @@
rental_composite.has_custom_address,
rental_composite.address_1, rental_composite.house_number,
rental_composite.address_2,
rental_composite.postcode, rental_composite.place,
rental_composite.is_active,
rental_composite.area, rental_composite.description,
- rental_composite.furnish_type_id,
rental_composite.standard_id,rental_composite.composite_type_id,
+ rental_composite.furnish_type_id,
rental_composite.standard_id,rental_composite.composite_type_id,rental_composite.status_id,
rental_composite.part_of_town_id,
rental_composite.custom_price_factor, rental_composite.custom_price,
rental_composite.price_type_id,";
$cols .= "rental_contract.id AS contract_id,
rental_contract.date_start, rental_contract.date_end,
rental_contract.old_contract_id, ";
$cols .= "rental_application.id AS
application_id, rental_application.date_start AS application_date_start,
rental_application.date_end AS application_date_end, ";
@@ -318,6 +324,7 @@
$composite->set_custom_price_factor($this->unmarshal($this->db->f('custom_price_factor',
true), 'float'));
$composite->set_price_type_id($this->unmarshal($this->db->f('price_type_id'),
'int'));
$composite->set_custom_price($this->unmarshal($this->db->f('custom_price'),
'float'));
+
$composite->set_status_id($this->unmarshal($this->db->f('status_id'), 'int'));
}
// Location code
$location_code =
$this->unmarshal($this->db->f('location_code', true), 'string');
@@ -457,7 +464,7 @@
'house_number = \'' .
$composite->get_custom_house_number() . '\'',
'postcode = \'' .
$composite->get_custom_postcode() . '\'',
'place = \'' . $composite->get_custom_place() .
'\'',
- 'is_active = \'' . ($composite->is_active() ?
'true' : 'false') . '\'',
+// 'is_active = \'' . ($composite->is_active() ?
'true' : 'false') . '\'',
'object_type_id = ' .
$composite->get_object_type_id(),
'area = ' .
$this->marshal($composite->get_area(), 'float'),
'furnish_type_id = ' .
$composite->get_furnish_type_id(),
@@ -466,6 +473,7 @@
'part_of_town_id = ' .
$composite->get_part_of_town_id(),
'custom_price_factor = \'' .
$composite->get_custom_price_factor() . '\'',
'price_type_id = ' .
$composite->get_price_type_id(),
+ 'status_id = ' . $composite->get_status_id(),
'custom_price = \'' .
$composite->get_custom_price() . '\''
);
@@ -486,7 +494,7 @@
// Build a db-friendly array of the composite object
$cols = array('name', 'description',
'has_custom_address', 'address_1', 'address_2',
'house_number', 'postcode', 'place',
'object_type_id', 'area', 'furnish_type_id',
- 'standard_id','composite_type_id',
'part_of_town_id', 'custom_price_factor','price_type_id', 'custom_price');
+ 'standard_id','composite_type_id',
'part_of_town_id', 'custom_price_factor','price_type_id', 'status_id',
'custom_price');
$values = array(
"'" . $composite->get_name() . "'",
"'" . $composite->get_description() . "'",
@@ -504,6 +512,7 @@
$composite->get_part_of_town_id(),
"'" . $composite->get_custom_price_factor() .
"'",
$composite->get_price_type_id(),
+ $composite->get_status_id(),
"'" . $composite->get_custom_price() . "'"
);
Modified: trunk/rental/inc/class.uicomposite.inc.php
===================================================================
--- trunk/rental/inc/class.uicomposite.inc.php 2017-02-07 15:34:39 UTC (rev
16269)
+++ trunk/rental/inc/class.uicomposite.inc.php 2017-02-07 19:42:49 UTC (rev
16270)
@@ -40,6 +40,22 @@
$this->config->read();
}
+ private function get_status_options( $selected = 0 )
+ {
+ $status_options = array();
+ $status_list = rental_composite::get_status_list();
+
+ foreach ($status_list as $_key => $_value)
+ {
+ $status_options[] = array(
+ 'id' => $_key,
+ 'name' => $_value,
+ 'selected' => $_key == $selected ? 1 : 0
+ );
+ }
+ return $status_options;
+ }
+
public function get_filters()
{
$filters = array();
@@ -82,6 +98,19 @@
);
}
+ $status_options = $this->get_status_options();
+
+ array_unshift($status_options, array('id'=> 'all',
'name' => lang('all')));
+
+
+ $filters[] = array
+ (
+ 'type' => 'filter',
+ 'name' => 'status_id',
+ 'text' => lang('status'),
+ 'list' => $status_options
+ );
+
$districts_arr =
execMethod('property.sogeneric.get_list', array('type' => 'district'));
$districts = array();
array_unshift($districts, array('id' => '', 'name' =>
lang('select')));
@@ -157,6 +186,7 @@
$result_objects = array();
$object_count = 0;
$district_id = phpgw::get_var('district_id', 'int');
+ $status_id = phpgw::get_var('status_id', 'int');
//Retrieve a contract identifier and load corresponding
contract
$contract_id = phpgw::get_var('contract_id');
@@ -184,8 +214,12 @@
$object_count =
rental_socomposite::get_instance()->get_count($search_for, $search_type,
$filters);
break;
case 'not_included_composites': // ... get all
vacant and active composites not in contract
- $filters = array('is_active' =>
phpgw::get_var('is_active'), 'is_vacant' =>
phpgw::get_var('occupancy'),//is_vacant seems to be unused
- 'not_in_contract' =>
phpgw::get_var('contract_id'),'has_contract' =>
phpgw::get_var('has_contract'),'furnished_status' =>
phpgw::get_var('furnished_status'));
+ $filters = array('is_active' =>
phpgw::get_var('is_active'),
+ 'district_id' => $status_id,
+ 'is_vacant' =>
phpgw::get_var('occupancy'),//is_vacant seems to be unused
+ 'not_in_contract' =>
phpgw::get_var('contract_id'),
+ 'has_contract' =>
phpgw::get_var('has_contract'),
+ 'furnished_status' =>
phpgw::get_var('furnished_status'));
$result_objects =
rental_socomposite::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
$object_count =
rental_socomposite::get_instance()->get_count($search_for, $search_type,
$filters);
break;
@@ -193,6 +227,7 @@
phpgwapi_cache::session_set('rental',
'composite_query', $search_for);
phpgwapi_cache::session_set('rental',
'composite_search_type', $search_type);
phpgwapi_cache::session_set('rental',
'composite_status', phpgw::get_var('is_active'));
+ phpgwapi_cache::session_set('rental',
'composite_status_id', phpgw::get_var('status_id'));
phpgwapi_cache::session_set('rental',
'composite_status_contract', phpgw::get_var('has_contract'));
phpgwapi_cache::session_set('rental',
'composite_furnished_status', phpgw::get_var('furnished_status'));
$filters = array(
@@ -203,6 +238,7 @@
'availability_date_from' =>
phpgw::get_var('availability_date_from'),
'availability_date_to' =>
phpgw::get_var('availability_date_to'),
'district_id' => $district_id,
+ 'status_id' => $status_id,
'composite_type_id' =>
phpgw::get_var('composite_type_id', 'int'),
);
if ($application_id > 0)
@@ -233,15 +269,19 @@
}
//Create an empty row set
+
+ $status_list = rental_composite::get_status_list();
$rows = array();
foreach ($result_objects as $result)
{
if (isset($result))
{
- if (!$result->is_active())
- {
- $result->set_status('Ikke i
drift');
- }
+// if (!$result->is_active())
+// {
+// $result->set_status('Ikke i
drift');
+// }
+
+
$result->set_status($status_list[$result->get_status_id()]);
$row = $result->serialize();
$row['price_type'] =
$price_types[$row['price_type_id']];
$rows[] = $row;
@@ -1054,6 +1094,7 @@
'list_price_type' => array('options' =>
$price_type_options),
'value_composite_type_name' =>
$composite_type_name,
'list_composite_type' => array('options' =>
$composite_type_options),
+ 'list_status_id' => array('options' =>
$this->get_status_options($composite->get_status_id())),
'value_furnish_type_name' => $furnish_type_name,
'list_furnish_type' => array('options' =>
$furnish_types_options),
'contract_furnished_status' =>
!empty($this->config->config_data['contract_furnished_status']),
@@ -1127,6 +1168,7 @@
$composite->set_custom_price_factor(phpgw::get_var('custom_price_factor',
'float'));
$composite->set_custom_price(phpgw::get_var('custom_price', 'float'));
$composite->set_price_type_id(phpgw::get_var('price_type_id', 'int'));
+
$composite->set_status_id(phpgw::get_var('status_id', 'int'));
if
(rental_socomposite::get_instance()->store($composite))
{
Modified: trunk/rental/inc/model/class.composite.inc.php
===================================================================
--- trunk/rental/inc/model/class.composite.inc.php 2017-02-07 15:34:39 UTC
(rev 16269)
+++ trunk/rental/inc/model/class.composite.inc.php 2017-02-07 19:42:49 UTC
(rev 16270)
@@ -9,10 +9,15 @@
*/
class rental_composite extends rental_model
{
+ const STATUS_ACTIVE = 1;
+ const STATUS_INACTIVE = 2;
+ const STATUS_EXPIRED = 3;
+
protected $name;
protected $description;
protected $is_active;
+ protected $status_id;
protected $has_custom_address;
// These are custom fields that may be set on the composite
protected $custom_address_1;
@@ -47,6 +52,15 @@
$this->contracts = array();
}
+ public static function get_status_list()
+ {
+
+ return array(
+ self::STATUS_ACTIVE => lang('active'),
+ self::STATUS_INACTIVE => lang('inactive'),
+ self::STATUS_EXPIRED => lang('expired'),
+ );
+ }
/**
* Adds a composite to the composite object. Note that this
method is
* meant for populating the object and will not fetch anything
from
@@ -185,7 +199,16 @@
{
return $this->description;
}
+ public function set_status_id( $status_id )
+ {
+ $this->status_id = $status_id;
+ }
+ public function get_status_id()
+ {
+ return $this->status_id;
+ }
+
public function set_is_active( $is_active )
{
$this->is_active = (bool)$is_active;
@@ -519,6 +542,7 @@
'id' => $this->get_id(),
'location_code' => $location_codes,
'description' => $this->get_description(),
+ 'status_id' => $this->get_status_id(),
'is_active' => $this->is_active(),
'name' => $this->get_name(),
'address' => $addresses,
Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang 2017-02-07 15:34:39 UTC (rev 16269)
+++ trunk/rental/setup/phpgw_no.lang 2017-02-07 19:42:49 UTC (rev 16270)
@@ -664,4 +664,5 @@
content rental no Innhold
select all rental no Velg alle
planned rental no Planlagt
-email template rental no Standardtekster
\ No newline at end of file
+email template rental no Standardtekster
+expired rental no Utgått
\ No newline at end of file
Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php 2017-02-07 15:34:39 UTC (rev 16269)
+++ trunk/rental/setup/setup.inc.php 2017-02-07 19:42:49 UTC (rev 16270)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module identifier
- $setup_info['rental']['version'] = '0.1.0.35'; // Current module version
+ $setup_info['rental']['version'] = '0.1.0.36'; // Current module version
$setup_info['rental']['app_order'] = 51; // (?)
$setup_info['rental']['tables'] = array(
'rental_party', // All contract participants, tenants etc.
Modified: trunk/rental/setup/tables_current.inc.php
===================================================================
--- trunk/rental/setup/tables_current.inc.php 2017-02-07 15:34:39 UTC (rev
16269)
+++ trunk/rental/setup/tables_current.inc.php 2017-02-07 19:42:49 UTC (rev
16270)
@@ -18,6 +18,7 @@
'name' => array('type' => 'varchar',
'precision' => '255', 'nullable' => false),
'description' => array('type' => 'text'),
'is_active' => array('type' => 'bool',
'nullable' => false, 'default' => 'true'),
+ 'status_id' => array('type' => 'int',
'precision' => 2, 'nullable' => false,'default' => 1),
'address_1' => array('type' => 'varchar',
'precision' => '255'),
'address_2' => array('type' => 'varchar',
'precision' => '255'),
'house_number' => array('type' => 'varchar',
'precision' => '255'),
Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php 2017-02-07 15:34:39 UTC (rev
16269)
+++ trunk/rental/setup/tables_update.inc.php 2017-02-07 19:42:49 UTC (rev
16270)
@@ -932,3 +932,30 @@
+ $test[] = '0.1.0.35';
+ function rental_upgrade0_1_0_35()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->AddColumn('rental_composite',
'status_id', array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => true,
+ 'default' => 1
+ ));
+
+ $GLOBALS['phpgw_setup']->oProc->query("UPDATE rental_composite
SET status_id = 2 WHERE is_active = FALSE", __LINE__, __FILE__);
+
+ $GLOBALS['phpgw_setup']->oProc->AlterColumn('rental_composite',
'status_id', array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => false,
+ 'default' => 1
+ ));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['rental']['currentver'] =
'0.1.0.36';
+ return $GLOBALS['setup_info']['rental']['currentver'];
+ }
+ }
Modified: trunk/rental/templates/base/composite.xsl
===================================================================
--- trunk/rental/templates/base/composite.xsl 2017-02-07 15:34:39 UTC (rev
16269)
+++ trunk/rental/templates/base/composite.xsl 2017-02-07 19:42:49 UTC (rev
16270)
@@ -178,7 +178,7 @@
</label>
<xsl:value-of
select="value_area_net"/>
</div>
- <div class="pure-control-group">
+ <!--div
class="pure-control-group">
<label>
<xsl:value-of
select="php:function('lang', 'available ?')"/>
</label>
@@ -187,7 +187,18 @@
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
+ </div-->
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'available ?')"/>
+ </label>
+ <xsl:if
test="count(//list_status_id/options) > 0">
+ <select
id="status_id" name="status_id">
+
<xsl:apply-templates select="list_status_id/options"/>
+ </select>
+ </xsl:if>
</div>
+
</div>
</div>
<xsl:choose>
@@ -456,7 +467,7 @@
</label>
<xsl:value-of
select="value_area_net"/>
</div>
- <div class="pure-control-group">
+ <!--div
class="pure-control-group">
<label>
<xsl:value-of
select="php:function('lang', 'available ?')"/>
</label>
@@ -465,6 +476,16 @@
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
+ </div-->
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'available ?')"/>
+ </label>
+ <xsl:for-each
select="list_status_id/options">
+ <xsl:if
test="selected != 0">
+
<xsl:value-of disable-output-escaping="yes" select="name"/>
+ </xsl:if>
+ </xsl:for-each>
</div>
</div>
</div>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16270] rental: status on composites,
sigurdne <=