[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13479] rental: add price item period type
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13479] rental: add price item period type |
Date: |
Tue, 23 Jun 2015 09:19:56 +0000 |
Revision: 13479
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13479
Author: sigurdne
Date: 2015-06-23 09:19:54 +0000 (Tue, 23 Jun 2015)
Log Message:
-----------
rental: add price item period type
Modified Paths:
--------------
trunk/rental/inc/class.socomposite.inc.php
trunk/rental/inc/class.soprice_item.inc.php
trunk/rental/inc/class.uiprice_item.inc.php
trunk/rental/inc/model/class.agresso_lg04.inc.php
trunk/rental/inc/model/class.price_item.inc.php
trunk/rental/setup/setup.inc.php
trunk/rental/setup/tables_current.inc.php
trunk/rental/setup/tables_update.inc.php
trunk/rental/templates/base/admin_price_item.php
trunk/rental/templates/base/admin_price_item_list.php
Modified: trunk/rental/inc/class.socomposite.inc.php
===================================================================
--- trunk/rental/inc/class.socomposite.inc.php 2015-06-22 23:09:01 UTC (rev
13478)
+++ trunk/rental/inc/class.socomposite.inc.php 2015-06-23 09:19:54 UTC (rev
13479)
@@ -24,7 +24,9 @@
}
protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
+ {
+ $location_id_into = $GLOBALS['phpgw']->locations->get_id(
'rental', '.RESPONSIBILITY.INTO');
+
$clauses = array('1=1');
if($search_for)
{
@@ -180,7 +182,8 @@
{
$cols = "rental_composite.id AS composite_id,";
}
- $cols .= "rental_unit.id AS unit_id,
rental_unit.location_code, rental_composite.name,
rental_composite.has_custom_address, rental_composite.address_1,
rental_composite.house_number,
+
+ $cols .= "rental_unit.id AS unit_id,
rental_unit.location_code, rental_composite.name,
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, ";
$cols .= "rental_contract.id AS contract_id,
rental_contract.date_start, rental_contract.date_end,
rental_contract.old_contract_id, ";
$cols .= "
@@ -188,6 +191,7 @@
(
NOT rental_contract_composite.contract_id IS
NULL AND
NOT rental_contract.date_start IS NULL AND
+ NOT rental_contract.location_id =
{$location_id_into} AND
((NOT rental_contract.date_start >
$availability_date_to AND rental_contract.date_end IS NULL)
OR
(NOT rental_contract.date_start >
$availability_date_to AND NOT rental_contract.date_end IS NULL AND NOT
rental_contract.date_end < $availability_date_from))
Modified: trunk/rental/inc/class.soprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.soprice_item.inc.php 2015-06-22 23:09:01 UTC (rev
13478)
+++ trunk/rental/inc/class.soprice_item.inc.php 2015-06-23 09:19:54 UTC (rev
13479)
@@ -45,6 +45,9 @@
$price_item->set_price($this->unmarshal($this->db->f('price',
true), 'float'));
$price_item->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'string'));
$price_item->set_responsibility_title($this->unmarshal($this->db->f('resp_title',
true), 'string'));
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+ $price_item->set_price_type_title($price_type_id);
return $price_item;
}
@@ -73,7 +76,9 @@
$price_item->set_price($this->unmarshal($this->db->f('price', true), 'float'));
$price_item->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'string'));
$price_item->set_responsibility_title($this->unmarshal($this->db->f('resp_title',
true), 'string'));
-
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+ $price_item->set_price_type_title($price_type_id);
return $price_item;
}
@@ -102,6 +107,9 @@
$price_item->set_price($this->unmarshal($this->db->f('price', true), 'float'));
$price_item->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'string'));
$price_item->set_responsibility_title($this->unmarshal($this->db->f('resp_title',
true), 'string'));
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+ $price_item->set_price_type_title($price_type_id);
return $price_item;
}
@@ -139,6 +147,9 @@
$price_item->set_standard($this->unmarshal($this->db->f('standard', true),
'bool'));
$price_item->set_price($this->unmarshal($this->db->f('price', true), 'float'));
$price_item->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+ $price_item->set_price_type_title($price_type_id);
$results[] = $price_item;
}
@@ -190,6 +201,11 @@
case "both":
break;
}
+
+ if(isset($filters['type']) && $filters['type'])
+ {
+ $filter_clauses[] = 'rental_price_item.type = '
. (int)$filters['type'];
+ }
if(count($filter_clauses))
{
@@ -217,10 +233,11 @@
($price_item->is_adjustable() ? "true" : "false"),
($price_item->is_standard() ? "true" : "false"),
str_replace(',','.',$price),
- $price_item->get_responsibility_id()
+ $price_item->get_responsibility_id(),
+ $price_item->get_price_type_id()
);
- $cols = array('title', 'agresso_id', 'is_area', 'is_inactive',
'is_adjustable', 'standard', 'price', 'responsibility_id');
+ $cols = array('title', 'agresso_id', 'is_area', 'is_inactive',
'is_adjustable', 'standard', 'price', 'responsibility_id', 'type');
$q ="INSERT INTO rental_price_item (" . join(',', $cols) . ")
VALUES (" . join(',', $values) . ")";
@@ -250,7 +267,8 @@
'is_adjustable = ' . ($price_item->is_adjustable() ?
"true" : "false"),
'standard = ' . ($price_item->is_standard() ? "true" :
"false"),
'price = ' .
str_replace(',','.',$price_item->get_price()),
- 'responsibility_id = ' .
$price_item->get_responsibility_id()
+ 'responsibility_id = ' .
$price_item->get_responsibility_id(),
+ 'type = ' . $price_item->get_price_type_id()
);
$this->db->query('UPDATE rental_price_item SET ' . join(',',
$values) . " WHERE id=$id", __LINE__,__FILE__);
@@ -466,6 +484,10 @@
$price_item->set_price($this->unmarshal($this->db->f('price'),'float'));
$price_item->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
$price_item->set_responsibility_title($this->unmarshal($this->db->f('resp_title',
true), 'string'));
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+ $price_item->set_price_type_title($price_type_id);
+
}
return $price_item;
}
Modified: trunk/rental/inc/class.uiprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.uiprice_item.inc.php 2015-06-22 23:09:01 UTC (rev
13478)
+++ trunk/rental/inc/class.uiprice_item.inc.php 2015-06-23 09:19:54 UTC (rev
13479)
@@ -72,9 +72,21 @@
return;
}
- $id = (int)phpgw::get_var('id');
- $price_item = rental_price_item::get($id);
+ if($id = phpgw::get_var('id', 'int'))
+ {
+ $price_item = rental_price_item::get($id);
+ }
+ else
+ {
+ $title = phpgw::get_var('price_item_title');
+ $responsibility_id =
phpgw::get_var('responsibility_id');
+ $price_item = new rental_price_item();
+ $price_item->set_title($title);
+ $price_item->set_responsibility_id($responsibility_id);
+ $price_item->set_price_type_id(1); // defaults to year
+ }
+
// Save the price item if it was posted
if(isset($_POST['save']))
{
@@ -85,6 +97,7 @@
$price_item->set_is_adjustable(phpgw::get_var('is_adjustable') == 'on' ? true :
false);
$price_item->set_standard(phpgw::get_var('standard') ==
'on' ? true : false);
$price_item->set_price(phpgw::get_var('price'));
+
$price_item->set_price_type_id(phpgw::get_var('price_type_id', 'int'));
if($price_item->get_agresso_id() == null)
{
return $this->viewedit(true, $price_item, '',
lang('missing_agresso_id'));
@@ -103,6 +116,7 @@
}
/*
+ * To be removed
* Add a new price item to the database. Requires only a title.
*/
public function add()
Modified: trunk/rental/inc/model/class.agresso_lg04.inc.php
===================================================================
--- trunk/rental/inc/model/class.agresso_lg04.inc.php 2015-06-22 23:09:01 UTC
(rev 13478)
+++ trunk/rental/inc/model/class.agresso_lg04.inc.php 2015-06-23 09:19:54 UTC
(rev 13479)
@@ -146,7 +146,7 @@
$stop =
$price_item->get_timestamp_end();
if(isset($start) && isset($stop))
{
- $description .= ' ' .
date('j/n', $start) . '-' . date('j/n', $stop);
+// $description .= ' ' .
date('j/n', $start) . '-' . date('j/n', $stop);
}
$data['article_description'] =
$description;
$data['article_code'] =
$price_item->get_agresso_id();
Modified: trunk/rental/inc/model/class.price_item.inc.php
===================================================================
--- trunk/rental/inc/model/class.price_item.inc.php 2015-06-22 23:09:01 UTC
(rev 13478)
+++ trunk/rental/inc/model/class.price_item.inc.php 2015-06-23 09:19:54 UTC
(rev 13479)
@@ -19,6 +19,15 @@
protected $standard;
protected $responsibility_id;
protected $responsibility_title;
+ protected $price_type_id;
+ protected $price_type_title;
+ protected $price_types = array(
+ 1 => 'year',
+ 2 => 'month',
+ 3 => 'day',
+ 4 => 'hour',
+ );
+
//protected $is_one_time;
/**
@@ -131,7 +140,8 @@
'standard' => $this->get_standard_text(),
'price' => $this->get_price(),
'responsibility_id' =>
$this->get_responsibility_id(),
- 'responsibility_title' =>
lang($this->get_responsibility_title())
+ 'responsibility_title' =>
lang($this->get_responsibility_title()),
+ 'price_type_title' =>
lang($this->get_price_type_title()),
//'is_one_time' => $this->is_one_time()
);
}
@@ -199,6 +209,30 @@
return $valid;
}
+ public function get_price_types()
+ {
+ return $this->price_types;
+ }
+ public function get_price_type_id()
+ {
+ return $this->price_type_id;
+ }
+
+ public function set_price_type_id($price_type_id)
+ {
+ $this->price_type_id = $price_type_id;
+ }
+
+ public function get_price_type_title()
+ {
+ return $this->price_type_title;
+ }
+
+ public function set_price_type_title($price_type_id)
+ {
+ $this->price_type_title =
$this->price_types[$price_type_id];
+ }
+
public function get_responsibility_id()
{
return $this->responsibility_id;
Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php 2015-06-22 23:09:01 UTC (rev 13478)
+++ trunk/rental/setup/setup.inc.php 2015-06-23 09:19:54 UTC (rev 13479)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module
identifier
- $setup_info['rental']['version'] = '0.1.0.21'; // Current module
version
+ $setup_info['rental']['version'] = '0.1.0.22'; // 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 2015-06-22 23:09:01 UTC (rev
13478)
+++ trunk/rental/setup/tables_current.inc.php 2015-06-23 09:19:54 UTC (rev
13479)
@@ -238,7 +238,8 @@
'is_adjustable' => array('type' =>
'bool','nullable' => true,'default' => 'true'),
'standard' => array('type' =>
'bool','nullable' => true,'default' => 'false'),
'price' => array('type' =>
'decimal', 'precision' => '20','scale' => '2', 'nullable' => true),
- 'responsibility_id' => array('type' =>
'int','precision' => '4', 'nullable' => false)
+ 'responsibility_id' => array('type' =>
'int','precision' => '4', 'nullable' => false),
+ 'type' => array('type' => 'int',
'precision' => 2, 'nullable' => false,'default' => 1),
),
'pk' => array('id'),
'fk' => array(),
Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php 2015-06-22 23:09:01 UTC (rev
13478)
+++ trunk/rental/setup/tables_update.inc.php 2015-06-23 09:19:54 UTC (rev
13479)
@@ -376,3 +376,18 @@
$GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.21';
return $GLOBALS['setup_info']['rental']['currentver'];
}
+
+ $test[] = '0.1.0.21';
+ function rental_upgrade0_1_0_21()
+ {
+
+ $GLOBALS['phpgw_setup']->oProc->AddColumn('rental_price_item',
'type', array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => false,
+ 'default' => 1
+ ));
+
+ $GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.22';
+ return $GLOBALS['setup_info']['rental']['currentver'];
+ }
Modified: trunk/rental/templates/base/admin_price_item.php
===================================================================
--- trunk/rental/templates/base/admin_price_item.php 2015-06-22 23:09:01 UTC
(rev 13478)
+++ trunk/rental/templates/base/admin_price_item.php 2015-06-23 09:19:54 UTC
(rev 13479)
@@ -52,6 +52,33 @@
<input type="radio" name="is_area" value="false"
id="is_area"<?php echo !$price_item->is_area() ? ' checked="checked"' : '' ?>
<?php echo !$editable ? ' disabled="disabled"' : '' ?>/>
<label for="is_area"><?php echo
lang('calculate_price_apiece') ?></label>
</dd>
+ <dt>
+ <label for="is_area"><?php echo lang('type') ?></label>
+ </dt>
+ <dd>
+ <?php
+ $current_price_type_id =
$price_item->get_price_type_id();
+ if ($editable)
+ {
+ ?>
+ <select name="price_type_id">
+ <?php
+ foreach($price_item->get_price_types()
as $price_type_id => $price_type_title)
+ {
+ echo "<option
".($current_price_type_id == $price_type_id ? 'selected="selected"' : "")."
value=\"{$price_type_id}\">".lang($price_type_title)."</option>";
+ }
+ ?>
+ </select>
+ <?php
+ ?>
+ <?php
+ }
+ else // Non-editable
+ {
+ echo
lang($price_item->get_price_types($current_price_type_id));
+ }
+ ?>
+ </dd>
<dt>
<label for="price"><?php echo lang('price') ?></label>
Modified: trunk/rental/templates/base/admin_price_item_list.php
===================================================================
--- trunk/rental/templates/base/admin_price_item_list.php 2015-06-22
23:09:01 UTC (rev 13478)
+++ trunk/rental/templates/base/admin_price_item_list.php 2015-06-23
09:19:54 UTC (rev 13479)
@@ -51,7 +51,7 @@
YAHOO.util.Event.stopEvent(e);
newName =
document.getElementById('ctrl_add_price_item_name').value;
resp_id = document.getElementById('responsibility_id').value;
- window.location =
'index.php?menuaction=rental.uiprice_item.add&price_item_title=' + newName
+ '&responsibility_id=' + resp_id;
+ window.location =
'index.php?menuaction=rental.uiprice_item.edit&price_item_title=' + newName
+ '&responsibility_id=' + resp_id;
}
);
@@ -110,6 +110,10 @@
label: "<?php echo lang('is_standard') ?>"
},
{
+ key: "price_type_title",
+ label: "<?php echo lang('type') ?>"
+ },
+ {
key: "actions",
hidden: true
},
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13479] rental: add price item period type,
Sigurd Nes <=