[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15567] Stable: Merge 15542:15566 from trunk
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15567] Stable: Merge 15542:15566 from trunk |
Date: |
Fri, 2 Sep 2016 11:39:37 +0000 (UTC) |
Revision: 15567
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15567
Author: sigurdne
Date: 2016-09-02 11:39:37 +0000 (Fri, 02 Sep 2016)
Log Message:
-----------
Stable: Merge 15542:15566 from trunk
Modified Paths:
--------------
branches/Version-2_0-branch/booking/inc/class.bocommon_authorized.inc.php
branches/Version-2_0-branch/helpdesk/inc/class.uitts.inc.php
branches/Version-2_0-branch/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php
branches/Version-2_0-branch/helpdesk/inc/hook_settings.inc.php
branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
branches/Version-2_0-branch/property/inc/class.bogeneric.inc.php
branches/Version-2_0-branch/property/inc/cron/default/synkroniser_med_boei.php
branches/Version-2_0-branch/rental/inc/class.soapplication.inc.php
branches/Version-2_0-branch/rental/inc/class.socontract_price_item.inc.php
branches/Version-2_0-branch/rental/inc/class.soprice_item.inc.php
branches/Version-2_0-branch/rental/inc/class.uiapplication.inc.php
branches/Version-2_0-branch/rental/inc/class.uibilling.inc.php
branches/Version-2_0-branch/rental/inc/class.uicontract.inc.php
branches/Version-2_0-branch/rental/inc/class.uiprice_item.inc.php
branches/Version-2_0-branch/rental/inc/model/class.application.inc.php
branches/Version-2_0-branch/rental/inc/model/class.contract_price_item.inc.php
branches/Version-2_0-branch/rental/inc/model/class.invoice.inc.php
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
branches/Version-2_0-branch/rental/inc/model/class.model.inc.php
branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php
branches/Version-2_0-branch/rental/js/rental/application.edit.js
branches/Version-2_0-branch/rental/setup/phpgw_no.lang
branches/Version-2_0-branch/rental/setup/setup.inc.php
branches/Version-2_0-branch/rental/setup/tables_update.inc.php
branches/Version-2_0-branch/rental/templates/base/application.xsl
Added Paths:
-----------
branches/Version-2_0-branch/rental/inc/class.boapplication.inc.php
Property Changed:
----------------
branches/Version-2_0-branch/
branches/Version-2_0-branch/booking/
Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14937-15027,15165-15215,15223-15228,15230-15243,15245-15250,15254-15257
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541
+ /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14937-15027,15165-15215,15223-15228,15230-15243,15245-15250,15254-15257
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566
Property changes on: branches/Version-2_0-branch/booking
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541
+ /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541,15543-15566
Modified:
branches/Version-2_0-branch/booking/inc/class.bocommon_authorized.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.bocommon_authorized.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/booking/inc/class.bocommon_authorized.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -776,7 +776,14 @@
function read_single( $id )
{
$entity = parent::read_single($id);
- $this->authorize_read($entity);
- return $this->add_permission_data($entity);
+ if($entity)
+ {
+ $this->authorize_read($entity);
+ return $this->add_permission_data($entity);
+ }
+ else
+ {
+ return array();
+ }
}
}
\ No newline at end of file
Modified: branches/Version-2_0-branch/helpdesk/inc/class.uitts.inc.php
===================================================================
--- branches/Version-2_0-branch/helpdesk/inc/class.uitts.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/helpdesk/inc/class.uitts.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -57,6 +57,7 @@
* @var boolean $_simple use simplified interface
*/
protected $_simple = false;
+ protected $_group_candidates = array();
protected $_show_finnish_date = false;
protected $_category_acl = false;
var $part_of_town_id;
@@ -105,9 +106,19 @@
$this->p_num =
$this->bo->p_num;
$user_groups =
$GLOBALS['phpgw']->accounts->membership($this->account);
$simple_group =
isset($this->bo->config->config_data['fmttssimple_group']) ?
$this->bo->config->config_data['fmttssimple_group'] : array();
+ if
(isset($this->bo->config->config_data['fmtts_assign_group_candidates']) &&
is_array($this->bo->config->config_data['fmtts_assign_group_candidates']))
+ {
+ foreach
($this->bo->config->config_data['fmtts_assign_group_candidates'] as
$group_candidate)
+ {
+ if ($group_candidate)
+ {
+ $this->_group_candidates[] =
$group_candidate;
+ }
+ }
+ }
foreach ( $user_groups as $group => $dummy)
{
- if ( in_array($group, $simple_group))
+ if ( in_array($group, $simple_group) &&
!in_array($group, $this->_group_candidates))
{
$this->_simple = true;
break;
@@ -1904,22 +1915,11 @@
private function _get_user_list($selected)
{
- if
(isset($this->bo->config->config_data['fmtts_assign_group_candidates']) &&
is_array($this->bo->config->config_data['fmtts_assign_group_candidates']))
- {
- foreach
($this->bo->config->config_data['fmtts_assign_group_candidates'] as
$group_candidate)
- {
- if ($group_candidate)
- {
- $_candidates[] =
$group_candidate;
- }
- }
- }
-
$xsl_rootdir = PHPGW_SERVER_ROOT .
"/property/templates/{$GLOBALS['phpgw_info']['server']['template_set']}";
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'), $xsl_rootdir);
- $users =
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_EDIT,
$this->acl_location, 'helpdesk', $_candidates);
+ $users =
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_EDIT,
$this->acl_location, 'helpdesk', $this->_group_candidates);
$user_list = array();
$selected_found = false;
foreach ($users as $user)
Modified:
branches/Version-2_0-branch/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php
===================================================================
---
branches/Version-2_0-branch/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php
2016-09-02 11:28:34 UTC (rev 15566)
+++
branches/Version-2_0-branch/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -57,6 +57,22 @@
{
$data['assignedto'] =
isset($GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault'])
? $GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault']
: '';
}
+
+ $current_prefs_user =
$this->bocommon->create_preferences('helpdesk',$GLOBALS['phpgw_info']['user']['account_id']);
+ if(empty($current_prefs_user['email']))
+ {
+ $GLOBALS['phpgw']->preferences->add('helpdesk',
'email', "{$GLOBALS['phpgw_info']['user']['account_lid'address@hidden");
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+
+ $assigned_prefs = createObject('phpgwapi.preferences',
(int)$data['assignedto']);
+ $assigned_prefs_data = $assigned_prefs->read();
+ if(empty($assigned_prefs_data['helpdesk']['email']))
+ {
+ $assigned_prefs->add('helpdesk', 'email',
"address@hidden");
+ $assigned_prefs->save_repository();
+ }
+
return true;
}
}
Modified: branches/Version-2_0-branch/helpdesk/inc/hook_settings.inc.php
===================================================================
--- branches/Version-2_0-branch/helpdesk/inc/hook_settings.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/helpdesk/inc/hook_settings.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -106,3 +106,4 @@
create_input_box('With of textarea', 'textareacols', 'With of textarea
in forms');
create_input_box('Height of textarea', 'textarearows', 'Height of
textarea in forms');
+ create_input_box('Your Email', 'email', 'Insert your email address');
Modified: branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -169,23 +169,6 @@
*/
public abstract static function get_instance();
- /**
- * Convenience method for getting one single object. Calls
get() with the
- * specified id as a filter.
- *
- * @param $id int with id of object to return.
- * @return object with the specified id, null if not found.
- */
- public function get_single( int $id )
- {
- $objects = $this->get(0, 0, '', false, '', '',
array($this->get_id_field_name() => $id));
- if (count($objects) > 0)
- {
- $keys = array_keys($objects);
- return $objects[$keys[0]];
- }
- return null;
- }
/**
* Method for retrieving the db-object (security "forgotten")
@@ -196,50 +179,6 @@
}
/**
- * Method for retreiving objects.
- *
- * @param $start_index int with index of first object.
- * @param $num_of_objects int with max number of objects to
return.
- * @param $sort_field string representing the object field to
sort on.
- * @param $ascending bool true for ascending sort on sort
field, false
- * for descending.
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @return array of objects. May return an empty
- * array, never null. The array keys are the respective index
numbers.
- */
- public function get( int $start_index, int $num_of_objects,
string $sort_field, bool $ascending, string $search_for, string $search_type,
array $filters )
- {
- // Only allow positive start index
- if ($start_index < 0)
- {
- $start_index = 0;
- }
-
-
- $sql = $this->get_query($sort_field, $ascending,
$search_for, $search_type, $filters, false);
-// $sql_parts = explode('1=1', $sql); // Split the query
to insert extra condition on test for break
-
- if($num_of_objects)
- {
- $this->db->limit_query($sql, $start_index,
__LINE__, __FILE__, (int)$num_of_objects);
- }
- else
- {
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- $results = array();
-
- while ($this->db->next_record())
- {
- $results[] =
$this->populate((int)$this->db->f('id'));
- }
-
- return $results;
- }
- /**
* Return all entries matching $params. Valid parameters:
*
* - $params['start']: Search result offset
@@ -377,6 +316,7 @@
'dir' => $dir
);
}
+
protected function primary_key_conditions( $id_params )
{
if (is_array($id_params))
@@ -482,62 +422,7 @@
}
}
- /**
- * Returns SQL for retrieving matching objects or object count.
- *
- * @param $start_index int with index of first object.
- * @param $num_of_objects int with max number of objects to
return.
- * @param $sort_field string representing the object field to
sort on.
- * @param $ascending bool true for ascending sort on sort
field, false
- * for descending.
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @param $return_count bool telling to return only the count
of the
- * matching objects, or the objects themself.
- * @return string with SQL.
- */
- protected function get_query( string $sort_field, bool
$ascending, string $search_for, string $search_type, array $filters, bool
$return_count )
- {
- //Add columns to this array to include them in the query
- $columns = array();
-
- if ($sort_field != null)
- {
- $dir = $ascending ? 'ASC' : 'DESC';
- if ($sort_field == 'name')
- {
- $order = "ORDER BY
{$this->table_name}.last_name {$dir}, {$this->table_name}.first_name {$dir}";
- $this->sort_field =
array("{$this->table_name}.last_name", "{$this->table_name}.first_name");
- }
- else
- {
- if ($sort_field == 'address')
- {
- $sort_field =
"{$this->table_name}.address1";
- $this->sort_field =
array("{$this->table_name}.address1");
- }
- $order = "ORDER BY
{$this->marshal($sort_field, 'field')} $dir";
- }
- }
-
- $condition = $this->_get_conditions( $search_for,
$filters );
- if ($return_count) // We should only return a count
- {
- $cols =
"COUNT(DISTINCT({$this->table_name}.id)) AS count";
- }
- else
- {
- $columns[] = "{$this->table_name}.*";
- $cols = implode(',', $columns);
- }
-
- $joins = '';
-
- return $sql = "SELECT {$cols} FROM {$this->table_name}
{$joins} WHERE {$condition} {$order}";
- }
-
function _get_conditions( $query, $filters )
{
$clauses = array('1=1');
@@ -655,18 +540,6 @@
return array($cols, $joins);
}
- /**
- * Returns count of matching objects.
- *
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @return int with object count.
- */
- public function get_count( string $search_for, string
$search_type, array $filters )
- {
- return $this->get_query_count($this->get_query('',
false, $search_for, $search_type, $filters, true));
- }
/**
* Implementing classes must return the name of the field used
in the query
@@ -684,7 +557,7 @@
protected function add( &$object )
{
- $object->set_entry_date(time());
+ $object->entry_date = time();
$value_set = array();
$fields = $object::get_fields();
@@ -700,7 +573,7 @@
}
}
- $sql = "INSERT INTO {$this->table_name} (".
implode(',',$cols)
+ $sql = "INSERT INTO {$this->table_name} (".
implode(',', array_keys($value_set))
. ') VALUES ('
.
$this->db->validate_insert(array_values($value_set))
. ')';
@@ -833,21 +706,15 @@
*/
public function store( &$object )
{
- if ($object->validates())
+ if ($object->get_id() > 0)
{
- if ($object->get_id() > 0)
- {
- // We can assume this composite came
from the database since it has an ID. Update the existing row
- return $this->update($object);
- }
- else
- {
- // This object does not have an ID, so
will be saved as a new DB row
- return $this->add($object);
- }
+ // We can assume this composite came from the
database since it has an ID. Update the existing row
+ return $this->update($object);
}
-
- // The object did not validate
- return false;
+ else
+ {
+ // This object does not have an ID, so will be
saved as a new DB row
+ return $this->add($object);
+ }
}
}
Modified: branches/Version-2_0-branch/property/inc/class.bogeneric.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.bogeneric.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/property/inc/class.bogeneric.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -138,6 +138,11 @@
public function read( $data = array() )
{
+ if (isset($data['location_info']) &&
$data['location_info']['type'])
+ {
+
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type_id']);
+ unset($data['location_info']);
+ }
$values = $this->so->read($data);
foreach ($values as &$entry)
@@ -174,7 +179,7 @@
{
if (isset($data['location_info']) &&
$data['location_info']['type'])
{
-
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type']);
+
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type_id']);
unset($data['location_info']);
}
$custom_fields = false;
Modified:
branches/Version-2_0-branch/property/inc/cron/default/synkroniser_med_boei.php
===================================================================
---
branches/Version-2_0-branch/property/inc/cron/default/synkroniser_med_boei.php
2016-09-02 11:28:34 UTC (rev 15566)
+++
branches/Version-2_0-branch/property/inc/cron/default/synkroniser_med_boei.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -79,7 +79,7 @@
function execute()
{
$start = time();
- set_time_limit(1200);
+ set_time_limit(2000);
$this->update_tables();
$this->legg_til_eier_phpgw();
@@ -98,9 +98,10 @@
$this->update_tenant_name();
$this->update_obskode();
$this->oppdater_namssakstatus_pr_leietaker();
+
$msg = 'Tidsbruk: ' . (time() - $start) . ' sekunder';
$this->cron_log($msg, $cron);
-
+ echo "$msg\n";
$this->receipt['message'][] = array('msg' => $msg);
}
@@ -145,7 +146,7 @@
function update_table_eier()
{
- $metadata = $this->db_boei->metadata('Eier');
+// $metadata_boei = $this->db_boei->metadata('Eier');
$metadata = $this->db->metadata('boei_eier');
//_debug_array($metadata);
if (!$metadata)
@@ -162,7 +163,7 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_eier', __LINE__,
__FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Eier';
+ $sql_boei = 'SELECT TOP 100 PERCENT Eier_ID,CAST(Navn
as TEXT) AS Navn,EierType_ID FROM Eier';
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
$sql = 'INSERT INTO boei_eier (eier_id, navn,
eiertype_id)'
@@ -196,8 +197,8 @@
function update_table_Gateadresse()
{
- $metadata = $this->db_boei->metadata('Gateadresse');
-//_debug_array($metadata);
+ $metadata_boei =
$this->db_boei->metadata('Gateadresse');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_gateadresse');
//_debug_array($metadata);
//die();
@@ -215,8 +216,9 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_gateadresse',
__LINE__, __FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Gateadresse';
+ $sql_boei = 'SELECT TOP 100 PERCENT Gateadresse_ID,
CAST(GateNavn as TEXT) AS GateNavn, NasjonalID FROM Gateadresse';
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
+
// using stored prosedures
$sql = 'INSERT INTO boei_gateadresse (gateadresse_id,
gatenavn, nasjonalid)'
. ' VALUES(?, ?, ?)';
@@ -249,8 +251,8 @@
function update_table_Objekt()
{
- $metadata = $this->db_boei->metadata('Objekt');
-//_debug_array($metadata);
+ $metadata_boei = $this->db_boei->metadata('Objekt');
+// _debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_objekt');
//_debug_array($metadata);
//die();
@@ -272,11 +274,12 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_objekt', __LINE__,
__FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Objekt';
+ $sql_boei = 'SELECT TOP 100 PERCENT Objekt_ID,
CAST(Navn as TEXT) AS Navn, Bydel_ID, Postnr_ID, Eier_ID, Tjenestested FROM
Objekt';
+
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
- $sql = 'INSERT INTO boei_objekt (objekt_id, navn,
generelladresse, bydel_id,postnr_id,eier_id,tjenestested)'
- . ' VALUES(?, ?, ?, ?, ?, ?, ?)';
+ $sql = 'INSERT INTO boei_objekt (objekt_id, navn,
bydel_id,postnr_id,eier_id,tjenestested)'
+ . ' VALUES(?, ?, ?, ?, ?, ?)';
$valueset = array();
while ($this->db_boei->next_record())
@@ -290,44 +293,40 @@
),
2 => array
(
- 'value' =>
utf8_encode($this->db_boei->f('Navn')),
+ 'value' =>
$this->db->db_addslashes(utf8_encode($this->db_boei->f('Navn'))),
'type' => PDO::PARAM_STR
),
3 => array
(
- 'value' =>
utf8_encode($this->db_boei->f('GenerellAdresse')),
- 'type' => PDO::PARAM_STR
- ),
- 4 => array
- (
'value' =>
(int)$this->db_boei->f('Bydel_ID'),
'type' => PDO::PARAM_INT
),
- 5 => array
+ 4 => array
(
'value' =>
$this->db_boei->f('Postnr_ID'),
'type' => PDO::PARAM_STR
),
- 6 => array
+ 5 => array
(
'value' =>
(int)$this->db_boei->f('Eier_ID'),
'type' => PDO::PARAM_INT
),
- 7 => array
+ 6 => array
(
'value' =>
(int)$this->db_boei->f('Tjenestested'),
'type' => PDO::PARAM_INT
)
);
}
-
+// _debug_array($valueset);
$this->db->insert($sql, $valueset, __LINE__, __FILE__);
}
function update_table_Bygg()
{
- $metadata = $this->db_boei->metadata('Bygg');
-//_debug_array($metadata);
+//_debug_array($this->db_boei);
+ $metadata_boei = $this->db_boei->metadata('Bygg');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_bygg');
//_debug_array($metadata);
//die();
@@ -347,11 +346,11 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_bygg', __LINE__,
__FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Bygg';
+ $sql_boei = 'SELECT TOP 100 PERCENT Objekt_ID, Bygg_ID,
CAST(ByggNavn as TEXT) AS ByggNavn, Driftstatus FROM Bygg';
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
- $sql = 'INSERT INTO boei_bygg (objekt_id, bygg_id,
byggnavn, generelladresse, driftstatus)'
- . ' VALUES(?, ?, ?, ?, ?)';
+ $sql = 'INSERT INTO boei_bygg (objekt_id, bygg_id,
byggnavn, driftstatus)'
+ . ' VALUES(?, ?, ?, ?)';
$valueset = array();
while ($this->db_boei->next_record())
@@ -370,16 +369,11 @@
),
3 => array
(
- 'value' =>
utf8_encode($this->db_boei->f('ByggNavn')),
+ 'value' =>
$this->db->db_addslashes(utf8_encode($this->db_boei->f('ByggNavn'))),
'type' => PDO::PARAM_STR
),
4 => array
(
- 'value' =>
utf8_encode($this->db_boei->f('GenerellAdresse')),
- 'type' => PDO::PARAM_STR
- ),
- 5 => array
- (
'value' =>
(int)$this->db_boei->f('Driftstatus'),
'type' => PDO::PARAM_INT
),
@@ -391,8 +385,8 @@
function update_table_Seksjon()
{
- $metadata = $this->db_boei->metadata('Seksjon');
-//_debug_array($metadata);
+ $metadata_boei = $this->db_boei->metadata('Seksjon');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_seksjon');
//_debug_array($metadata);
//die();
@@ -411,7 +405,7 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_seksjon', __LINE__,
__FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Seksjon';
+ $sql_boei = 'SELECT TOP 100 PERCENT Objekt_ID, Bygg_ID,
Seksjons_ID, CAST(Beskrivelse as TEXT) AS Beskrivelse FROM Seksjon';
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
$sql = 'INSERT INTO boei_seksjon (objekt_id, bygg_id,
seksjons_id, beskrivelse)'
@@ -450,8 +444,8 @@
function update_table_leieobjekt()
{
- $metadata = $this->db_boei->metadata('Leieobjekt');
-//_debug_array($metadata);
+ $metadata_boei = $this->db_boei->metadata('Leieobjekt');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_leieobjekt');
//_debug_array($metadata);
//die();
@@ -484,10 +478,16 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_leieobjekt',
__LINE__, __FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Leieobjekt';
+ $sql_boei = 'SELECT TOP 100 PERCENT Objekt_ID, Bygg_ID,
Seksjons_ID, Leie_ID, Flyttenr,'
+ . ' Formaal_ID, Gateadresse_ID, Gatenr, Etasje,
AntallRom, Boareal,'
+ . ' AndelAvFellesareal, Livslopsstd, Heis,
Driftsstatus_ID, Leietaker_ID, Beregnet_Boa'
+ . ' FROM Leieobjekt';
+
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
- $sql = 'INSERT INTO boei_leieobjekt (objekt_id,
bygg_id, seksjons_id, leie_id, flyttenr, formaal_id, gateadresse_id, gatenr,
etasje, antallrom, boareal, andelavfellesareal,livslopsstd, heis,
driftsstatus_id, leietaker_id,beregnet_boa)'
+ $sql = 'INSERT INTO boei_leieobjekt (objekt_id,
bygg_id, seksjons_id, leie_id, flyttenr,'
+ . ' formaal_id, gateadresse_id, gatenr, etasje,
antallrom, boareal,'
+ . ' andelavfellesareal,livslopsstd, heis,
driftsstatus_id, leietaker_id,beregnet_boa)'
. ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?)';
$valueset = array();
@@ -588,8 +588,8 @@
function update_table_leietaker()
{
- $metadata = $this->db_boei->metadata('Leietaker');
-//_debug_array($metadata);
+ $metadata_boei = $this->db_boei->metadata('Leietaker');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_leietaker');
//_debug_array($metadata);
//die();
@@ -613,10 +613,14 @@
$this->db->query($sql_table, __LINE__,
__FILE__);
}
$this->db->query('DELETE FROM boei_leietaker',
__LINE__, __FILE__);
- $sql_boei = 'SELECT TOP 100 PERCENT * FROM Leietaker';
+
+ $sql_boei = 'SELECT TOP 100 PERCENT Leietaker_ID,
CAST(Fornavn as TEXT) AS Fornavn, CAST(Etternavn as TEXT) AS Etternavn,
Kjonn_Juridisk,'
+ . ' OppsagtDato, NamssakStatusDrift_ID,
NamssakStatusOkonomi_ID, hemmeligAdresse, OBSKode'
+ . ' FROM Leietaker';
$this->db_boei->query($sql_boei, __LINE__, __FILE__);
// using stored prosedures
- $sql = 'INSERT INTO boei_leietaker (leietaker_id,
fornavn, etternavn,
kjonn_juridisk,oppsagtdato,namssakstatusdrift_id,namssakstatusokonomi_id,hemmeligadresse,obskode)'
+ $sql = 'INSERT INTO boei_leietaker (leietaker_id,
fornavn, etternavn, kjonn_juridisk,'
+ . '
oppsagtdato,namssakstatusdrift_id,namssakstatusokonomi_id,hemmeligadresse,obskode)'
. ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)';
$valueset = array();
@@ -676,8 +680,8 @@
function update_table_reskontro()
{
- $metadata = $this->db_boei->metadata('reskontro');
-//_debug_array($metadata);
+ $metadata_boei = $this->db_boei->metadata('reskontro');
+//_debug_array($metadata_boei);
$metadata = $this->db->metadata('boei_reskontro');
//_debug_array($metadata);
//die();
Copied: branches/Version-2_0-branch/rental/inc/class.boapplication.inc.php
(from rev 15566, trunk/rental/inc/class.boapplication.inc.php)
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.boapplication.inc.php
(rev 0)
+++ branches/Version-2_0-branch/rental/inc/class.boapplication.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -0,0 +1,168 @@
+<?php
+ /**
+ * phpGroupWare
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License v2 or later
+ * @internal
+ * @package rental
+ * @subpackage application
+ * @version $Id:$
+ */
+
+ /*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ phpgw::import_class('rental.soapplication');
+
+ include_class('rental', 'application', 'inc/model/');
+
+ class rental_boapplication
+ {
+ protected static
+ $bo,
+ $fields;
+
+ public $acl_location = '.application';
+
+ public function __construct()
+ {
+ $this->fields = rental_application::get_fields();
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public static function get_instance()
+ {
+ if (self::$bo == null)
+ {
+ self::$bo = new rental_boapplication();
+ }
+ return self::$bo;
+ }
+
+ public function store($object)
+ {
+ $criteria = array(
+ 'appname' => 'rental',
+ 'location' => $this->bo->acl_location,
+ 'allrows' => true
+ );
+
+ $custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+ foreach ($custom_functions as $entry)
+ {
+ // prevent path traversal
+ if (preg_match('/\.\./', $entry['file_name']))
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/rental/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+ if ($entry['active'] && is_file($file) &&
!$entry['client_side'])
+ {
+ require $file;
+ }
+ }
+
+ $ret =
rental_soapplication::get_instance()->store($object);
+
+ reset($custom_functions);
+
+ foreach ($custom_functions as $entry)
+ {
+ // prevent path traversal
+ if (preg_match('/\.\./', $entry['file_name']))
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/rental/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+ if ($entry['active'] && is_file($file) &&
!$entry['client_side'] && !$entry['pre_commit'])
+ {
+ require $file;
+ }
+ }
+ return $ret;
+ }
+
+ public function read($params)
+ {
+ return
rental_soapplication::get_instance()->read($params);
+ }
+
+ public function read_single($id, $return_object = true)
+ {
+ if ($id)
+ {
+ $application =
rental_soapplication::get_instance()->read_single($id, $return_object);
+ }
+ else
+ {
+ $application = new rental_application();
+ }
+
+ return $application;
+ }
+
+ public function build_default_read_params()
+ {
+ $fields = $this->fields;
+
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'sort' => $columns[$order[0]['column']]['data'],
+ 'dir' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1,
+ );
+
+ foreach ($fields as $field => $_params)
+ {
+ if (!empty($_REQUEST["filter_$field"]))
+ {
+ $params['filters'][$field] =
phpgw::get_var("filter_$field", $_params['type']);
+ }
+ }
+
+ return $params;
+ }
+
+ public function populate($application)
+ {
+ $fields = $this->fields;
+
+ foreach ($fields as $field => $field_info)
+ {
+ if(($field_info['action'] & PHPGW_ACL_ADD) ||
($field_info['action'] & PHPGW_ACL_EDIT))
+ {
+ $application->set_field( $field,
phpgw::get_var($field, $field_info['type'] ) );
+ }
+ }
+ return $application;
+ }
+
+ }
\ No newline at end of file
Modified: branches/Version-2_0-branch/rental/inc/class.soapplication.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.soapplication.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.soapplication.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -64,4 +64,59 @@
return $object;
}
+ protected function update( $object )
+ {
+ $this->db->transaction_begin();
+ $status_text = rental_application::get_status_list();
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $original =
$this->read_single($object->get_id());//returned as array()
+ foreach ($this->fields as $field => $params)
+ {
+ $new_value = $object->$field;
+ $old_value = $original[$field];
+ $label = !empty($params['label']) ?
lang($params['label']) : $field;
+ if (!empty($params['history']) && ($new_value
!= $old_value))
+ {
+ switch ($field)
+ {
+ case 'status':
+ $old_value =
$status_text[$old_value];
+ $new_value =
$status_text[$new_value];
+ break;
+ case 'assign_date_start':
+ case 'assign_date_end':
+ $old_value =
$GLOBALS['phpgw']->common->show_date($old_value, $dateformat);
+ $new_value =
$GLOBALS['phpgw']->common->show_date($new_value, $dateformat);
+
+ break;
+ case 'executive_officer':
+ $old_value = $old_value
? $GLOBALS['phpgw']->accounts->get($old_value)->__toString() : '';
+ $new_value = $new_value
? $GLOBALS['phpgw']->accounts->get($new_value)->__toString() : '';
+ break;
+ default:
+ break;
+ }
+ $value_set = array
+ (
+ 'application_id' =>
$object->get_id(),
+ 'time' => time(),
+ 'author' =>
$GLOBALS['phpgw_info']['user']['fullname'],
+ 'comment' => $label . '::
' . lang('old value') . ': ' . $this->db->db_addslashes($old_value) . ', '
.lang('new value') . ': ' . $this->db->db_addslashes($new_value),
+ 'type' => 'history',
+ );
+
+ $this->db->query( 'INSERT INTO
rental_application_comment (' . implode( ',', array_keys( $value_set ) ) .
') VALUES ('
+ . $this->db->validate_insert(
array_values( $value_set ) ) . ')',__LINE__,__FILE__);
+ }
+
+ }
+
+ parent::update($object);
+
+ return $this->db->transaction_commit();
+
+
+ }
+
}
\ No newline at end of file
Modified:
branches/Version-2_0-branch/rental/inc/class.socontract_price_item.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.socontract_price_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.socontract_price_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -118,11 +118,12 @@
}
else if (isset($filters['export']))
{
- $cols = "rental_contract_price_item.id,
rental_contract_price_item.price_item_id,"
+ $cols =
"rental_contract_price_item.id,rental_contract_price_item.location_factor,rental_contract_price_item.standard_factor,"
+ . "
rental_contract_price_item.custom_factor,
rental_contract_price_item.price_item_id,"
. "
rental_contract_price_item.contract_id, rental_contract_price_item.area,
rental_contract_price_item.count,"
. "
rental_contract_price_item.agresso_id, rental_contract_price_item.title,
rental_contract_price_item.is_area,"
. " rental_contract_price_item.price,
rental_contract_price_item.total_price, rental_contract_price_item.is_one_time,"
- . "
rental_contract_price_item.date_start, rental_contract_price_item.date_end";
+ . "
rental_contract_price_item.date_start,
rental_contract_price_item.date_end,rental_price_item.type'";
}
else
{
@@ -158,6 +159,9 @@
$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);
+
$price_item->set_location_factor($this->unmarshal($this->db->f('location_factor'),
'float'));
+
$price_item->set_standard_factor($this->unmarshal($this->db->f('standard_factor'),
'float'));
+
$price_item->set_custom_factor($this->unmarshal($this->db->f('custom_factor'),
'float'));
}
return $price_item;
}
@@ -285,6 +289,40 @@
{
$id = intval($price_item->get_id());
+ /*
+ * Start correction by factors
+ */
+
+ phpgw::import_class('rental.socomposite');
+ $contract =
rental_socontract::get_instance()->get_single($price_item->get_contract_id());
+ $composites = $contract->get_composites();
+ foreach ($composites as $composite_id => $composite)
+ {
+ $composite_obj =
rental_socomposite::get_instance()->get_single($composite_id);
+ break;
+ }
+
+ $custom_factor =
$composite_obj->get_custom_prize_factor();
+ $custom_factor = $custom_factor ? (float)$custom_factor
: 1;
+
+ $location_info = ExecMethod('property.bogeneric.read',
array(
+ 'location_info'=> array('type' =>
'location_factor'),
+ 'custom_filter' => array('part_of_town_id = ' .
(int)$composite_obj->get_part_of_town_id())
+ )
+ );
+ $location_factor =
(float)abs($location_info[0]['factor']) > 0 ?
(float)$location_info[0]['factor'] : 1;
+
+ $standard_info =
ExecMethod('property.bogeneric.read_single', array('type' =>
'composite_standard', 'id' => $composite_obj->get_standard_id()));
+ $standard_factor = (float)abs($standard_info['factor'])
> 0 ? (float)$standard_info['factor'] : 1;
+
+ $factor = $location_factor * $standard_factor *
$custom_factor;
+ $factor = $factor ? (float)$factor : 1;
+
+
+ /*
+ * End correction by factors
+ */
+
$price = $price_item->get_price() ?
$price_item->get_price() : 0;
//$total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
//if($total_price == 0){
@@ -292,11 +330,14 @@
if ($price_item->is_area())
{
- $total_price = $price_item->get_area() *
$price_item->get_price();
+ $total_price = $price_item->get_area() *
$price_item->get_price() * $factor;
}
else
{
$total_price = $price_item->get_count() *
$price_item->get_price();
+ $location_factor = 1;
+ $standard_factor = 1;
+ $custom_factor = 1;
}
// Build a db-friendly array of the composite object
@@ -313,7 +354,10 @@
"date_start=" .
$this->marshal($price_item->get_date_start(), 'int'),
"date_end=" .
$this->marshal($price_item->get_date_end(), 'int'),
"is_one_time=" .
($price_item->get_is_one_time() == "true" ? "true" : "false"),
- "is_billed=" . ($price_item->is_billed() ?
"true" : "false")
+ "is_billed=" . ($price_item->is_billed() ?
"true" : "false"),
+ "location_factor = '{$location_factor}'",
+ "standard_factor = '{$standard_factor}'",
+ "custom_factor = '{$custom_factor}'"
);
$this->db->query('UPDATE rental_contract_price_item SET
' . join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
Modified: branches/Version-2_0-branch/rental/inc/class.soprice_item.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.soprice_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.soprice_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -363,11 +363,32 @@
* @param $price_item the price item to add
* @return true if successful, false otherwise
*/
- function add_price_item( $contract_id, $price_item_id, $factor )
+ function add_price_item( $contract_id, $price_item_id )
{
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+ $composites = $contract->get_composites();
+ foreach ($composites as $composite_id => $composite)
+ {
+ $composite_obj =
rental_socomposite::get_instance()->get_single($composite_id);
+ break;
+ }
+
+ $custom_factor =
$composite_obj->get_custom_prize_factor();
+ $custom_factor = $custom_factor ? (float)$custom_factor
: 1;
+
+ $location_info = ExecMethod('property.bogeneric.read',
array(
+ 'location_info'=> array('type' =>
'location_factor'),
+ 'custom_filter' => array('part_of_town_id = ' .
(int)$composite_obj->get_part_of_town_id())
+ )
+ );
+ $location_factor =
(float)abs($location_info[0]['factor']) > 0 ?
(float)$location_info[0]['factor'] : 1;
+
+ $standard_info =
ExecMethod('property.bogeneric.read_single', array('type' =>
'composite_standard', 'id' => $composite_obj->get_standard_id()));
+ $standard_factor = (float)abs($standard_info['factor'])
> 0 ? (float)$standard_info['factor'] : 1;
+
+ $factor = $location_factor * $standard_factor *
$custom_factor;
$factor = $factor ? (float)$factor : 1;
$price_item = $this->get_single($price_item_id);
- $contract =
rental_socontract::get_instance()->get_single($contract_id);
$rented_area = 0;
$total_price = 0;
if ($price_item->is_area())
@@ -380,6 +401,12 @@
$total_price = ($rented_area *
$price_item->get_price() * $factor);
//var_dump($total_price, $rented_area,
$price_item->get_price());
}
+ else
+ {
+ $location_factor = 1;
+ $standard_factor = 1;
+ $custom_factor = 1;
+ }
if ($price_item)
{
$values = array(
@@ -389,8 +416,11 @@
str_replace(',', '.', $rented_area),
"'" . $price_item->get_agresso_id() .
"'",
$price_item->is_area() ? 'true' :
'false',
- (str_replace(',', '.',
$price_item->get_price()) * $factor),
- str_replace(',', '.', $total_price)
+ (str_replace(',', '.',
$price_item->get_price())),
+ str_replace(',', '.', $total_price),
+ $location_factor,
+ $standard_factor,
+ $custom_factor
);
$start_date_field = '';
$end_date_field = '';
@@ -406,7 +436,7 @@
$end_date_field = ", date_end";
}
- $q = "INSERT INTO rental_contract_price_item
(price_item_id, contract_id, title, area, agresso_id, is_area, price,
total_price {$start_date_field} {$end_date_field}) VALUES (" . join(',',
$values) . ")";
+ $q = "INSERT INTO rental_contract_price_item
(price_item_id, contract_id, title, area, agresso_id, is_area, price,
total_price, location_factor, standard_factor, custom_factor
{$start_date_field} {$end_date_field}) VALUES (" . join(',', $values) . ")";
//var_dump($q);
$result = $this->db->query($q);
if ($result)
Modified: branches/Version-2_0-branch/rental/inc/class.uiapplication.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.uiapplication.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.uiapplication.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -34,8 +34,7 @@
class rental_uiapplication extends rental_uicommon
{
- public $public_functions = array
- (
+ public $public_functions = array(
'add' => true,
'index' => true,
'query' => true,
@@ -54,8 +53,9 @@
parent::__construct();
self::set_active_menu('rental::application');
$GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('application');
+ $this->bo = createObject('rental.boapplication');
$this->acl = & $GLOBALS['phpgw']->acl;
- $this->acl_location = '.application';
+ $this->acl_location = $this->bo->acl_location;
$this->acl_read =
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'rental');
$this->acl_add = $this->acl->check($this->acl_location,
PHPGW_ACL_ADD, 'rental');
$this->acl_edit =
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'rental');
@@ -69,30 +69,20 @@
private function get_status_options( $selected = 0 )
{
$status_options = array();
+ $status_list = rental_application::get_status_list();
+
$status_options[] = array(
'id' => '',
'name' => lang('all')
);
- $status_options[] = array(
- 'id' => rental_application::STATUS_REGISTERED,
- 'name' => lang('registered')
- );
- $status_options[] = array(
- 'id' => rental_application::STATUS_PENDING,
- 'name' => lang('pending')
- );
- $status_options[] = array(
- 'id' => rental_application::STATUS_REJECTED,
- 'name' => lang('rejected')
- );
- $status_options[] = array(
- 'id' => rental_application::STATUS_APPROVED,
- 'name' => lang('approved')
- );
- foreach ($status_options as &$entry)
+ foreach ($status_list as $_key => $_value)
{
- $entry['selected'] = $entry['id'] == $selected
? 1 : 0;
+ $status_options[] = array(
+ 'id' => $_key,
+ 'name' => $_value,
+ 'selected' => $_key == $selected ? 1 : 0
+ );
}
return $status_options;
}
@@ -182,7 +172,7 @@
)
)
);
-
+/*
$data['datatable']['actions'][] = array
(
'my_name' => 'view',
@@ -193,7 +183,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
@@ -244,20 +234,8 @@
}
else
{
- $application_id = phpgw::get_var('id', 'int');
-
- if (!empty($values['application_id']))
- {
- $application_id =
$values['application_id'];
- }
- if ($application_id)
- {
- $application =
rental_application::get($application_id);
- }
- else
- {
- $application = new rental_application();
- }
+ $application_id =
!empty($values['application_id']) ? $values['application_id'] :
phpgw::get_var('id', 'int');
+ $application =
$this->bo->read_single($application_id);
}
if (!$this->acl_edit)
@@ -361,11 +339,11 @@
'status_list' => array('options' =>
$this->get_status_options($application->status)),
'mode' => $mode,
'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+ 'value_active_tab' => $active_tab
);
phpgwapi_jquery::formvalidator_generate(array('date',
'security', 'file'));
phpgwapi_jquery::load_widget('autocomplete');
self::add_javascript('rental', 'rental',
'application.edit.js');
-
self::render_template_xsl(array('application',
'datatable_inline'), array($mode => $data));
}
/*
@@ -389,23 +367,16 @@
{
phpgw::no_access();
}
-// _debug_array($_POST);
- $application_id = phpgw::get_var('id', 'int');
$active_tab = phpgw::get_var('active_tab', 'string',
'REQUEST', 'application');
- if ($application_id)
- {
- $application =
rental_soapplication::get_instance()->read_single($application_id, true);
- }
- else
- {
- $application = new rental_application();
- $application->status =
$application::STATUS_REGISTERED;
- }
+ $application_id = phpgw::get_var('id', 'int');
+
+ $application = $this->bo->read_single($application_id,
true);
+
/*
* Overrides with incoming data from POST
*/
- $application = $this->_populate($application);
+ $application = $this->bo->populate($application);
if($application->validate())
{
@@ -431,75 +402,28 @@
}
}
- private function _populate($application)
- {
- $fields = $this->fields;
-
- foreach ($fields as $field => $field_info)
- {
- if(($field_info['action'] & PHPGW_ACL_ADD) ||
($field_info['action'] & PHPGW_ACL_EDIT))
- {
- $application->set_field( $field,
phpgw::get_var($field, $field_info['type'] ) );
- }
- }
- return $application;
- }
-
-
/**
* (non-PHPdoc)
* @see rental/inc/rental_uicommon#query()
*/
public function query()
{
- $params = $this->build_default_read_params();
- $applications =
rental_soapplication::get_instance()->read($params);
- $status_text = array(
- rental_application::STATUS_REGISTERED =>
lang('registered'),
- rental_application::STATUS_PENDING =>
lang('pending'),
- rental_application::STATUS_REJECTED =>
lang('rejected'),
- rental_application::STATUS_APPROVED =>
lang('approved')
- );
-
+ $params = $this->bo->build_default_read_params();
+ $applications = $this->bo->read($params);
+ $status_text = rental_application::get_status_list();
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
foreach ($applications['results'] as &$application)
{
$application['status'] =
$status_text[$application['status']];
$application['composite_type'] =
$this->composite_types[$application['composite_type']];
- $application['entry_date'] =
$GLOBALS['phpgw']->common->show_date($application['entry_date'], $dateformat);
+ $application['entry_date'] =
$GLOBALS['phpgw']->common->show_date($application['entry_date']);
+ $application['assign_date_start'] =
$GLOBALS['phpgw']->common->show_date($application['assign_date_start'],
$dateformat);
+ $application['assign_date_end'] =
$GLOBALS['phpgw']->common->show_date($application['assign_date_end'],
$dateformat);
$application['executive_officer'] =
$application['executive_officer'] ?
$GLOBALS['phpgw']->accounts->get($application['executive_officer'])->__toString()
: '';
}
array_walk($applications["results"], array($this,
"_add_links"), "rental.uiapplication.edit");
return $this->jquery_results($applications);
}
-
- protected function build_default_read_params()
- {
- $fields = $this->fields;
-
- $search = phpgw::get_var('search');
- $order = phpgw::get_var('order');
- $draw = phpgw::get_var('draw', 'int');
- $columns = phpgw::get_var('columns');
-
- $params = array(
- 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
- 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
- 'query' => $search['value'],
- 'sort' => $columns[$order[0]['column']]['data'],
- 'dir' => $order[0]['dir'],
- 'allrows' => phpgw::get_var('length', 'int') ==
-1,
- );
-
- foreach ($fields as $field => $_params)
- {
- if (!empty($_REQUEST["filter_$field"]))
- {
- $params['filters'][$field] =
phpgw::get_var("filter_$field", $_params['type']);
- }
- }
-
- return $params;
- }
}
\ No newline at end of file
Modified: branches/Version-2_0-branch/rental/inc/class.uibilling.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.uibilling.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.uibilling.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -112,7 +112,7 @@
}
if (($contract_ids != null &&
is_array($contract_ids) && count($contract_ids) > 0) ||
(is_array($contract_bill_only_one_time) && count($contract_bill_only_one_time)
> 0)) // User submitted contracts to bill
{
- $missing_billing_info =
rental_sobilling::get_instance()->get_missing_billing_info(phpgw::get_var('billing_term'),
phpgw::get_var('year'), phpgw::get_var('month'), $contract_ids,
$contract_ids_override, phpgw::get_var('export_format'));
+ $missing_billing_info =
rental_sobilling::get_instance()->get_missing_billing_info(phpgw::get_var('billing_term'),
phpgw::get_var('year'), phpgw::get_var('month'), $contract_ids,
(array)$contract_ids_override, phpgw::get_var('export_format'));
if ($missing_billing_info == null ||
count($missing_billing_info) == 0)
{
@@ -126,7 +126,7 @@
phpgw::get_var('title'),
$GLOBALS['phpgw_info']['user']['account_id'],
$contract_ids,
- $contract_ids_override,
+ (array)
$contract_ids_override,
phpgw::get_var('export_format'),
$existing_billing,
$contract_bill_only_one_time,
@@ -577,11 +577,11 @@
//... 1. Contracts following
regular billing cycle
$filters =
array('contracts_for_billing' => true, 'contract_type' => $contract_type,
'billing_term_id' =>
$billing_term, 'year' => $year, 'month' => $month);
- $contracts =
rental_socontract::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $contracts =
rental_socontract::get_instance()->get($start_index = 0, $num_of_objects = 0,
$sort_field = '', (bool)$sort_ascending, (string)$search_for,
(string)$search_type, $filters);
$filters2 =
array('contract_ids_one_time' => true, 'billing_term_id' => $billing_term,
'year' => $year,
'month' => $month);
}
- $contract_price_items =
$socontract_price_item->get($start_index, $num_of_objects, $sort_field,
$sort_ascending, $search_for, $search_type, $filters2);
+ $contract_price_items =
$socontract_price_item->get($start_index = 0, $num_of_objects = 0, $sort_field
= '', (bool)$sort_ascending, (string)$search_for, (string)$search_type,
$filters2);
foreach ($contract_price_items as
$contract_price_item)
{
@@ -1478,7 +1478,7 @@
$draw = phpgw::get_var('draw', 'int');
$columns = phpgw::get_var('columns');
- $start_index = phpgw::get_var('start', 'int',
'REQUEST', 0);
+ $start_index = (int)phpgw::get_var('start', 'int' );
$num_of_objects = (phpgw::get_var('length', 'int') <=
0) ? $user_rows_per_page : phpgw::get_var('length', 'int');
$sort_field = ($columns[$order[0]['column']]['data']) ?
$columns[$order[0]['column']]['data'] : 'id';
$sort_ascending = ($order[0]['dir'] == 'desc') ? false
: true;
Modified: branches/Version-2_0-branch/rental/inc/class.uicontract.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.uicontract.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.uicontract.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -447,30 +447,69 @@
private function _get_tableDef_price( $mode, $contract_id )
{
- $columns_def = array(
- array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
- 'sortable' => true, 'hidden' => false),
- array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
- 'hidden' => false, 'editor' => $mode ==
'edit' ? true : false),
- array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
- 'hidden' => false),
- array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
- 'formatter' => 'formatterPrice',
'className' => 'right', 'editor' => $mode == 'edit' ? true : false),
- array("key" => "area", "label" => lang('area'),
"formatter" => "formatterArea",
- 'className' => 'right'),
- array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
- array("key" => "total_price", "label" =>
lang('total_price'), 'formatter' => 'formatterPrice',
- 'className' => 'right'),
- array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
- 'className' => 'center'),
- array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
- 'className' => 'center'),
- array("key" => "is_one_time", "label" =>
lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time' :
"",
- 'className' => 'center'),
- array("key" => "price_type_title", "label" =>
lang('type'), 'sortable' => false,
- 'className' => 'center')
- );
+ if
(empty($this->config->config_data['contract_furnished_status']))
+ {
+ $columns_def = array(
+ array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
+ 'sortable' => true, 'hidden' =>
false),
+ array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
+ 'hidden' => false, 'editor' =>
$mode == 'edit' ? true : false),
+ array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
+ 'formatter' =>
'formatterPrice', 'className' => 'right', 'editor' => $mode == 'edit' ? true :
false),
+ array("key" => "area", "label" =>
lang('area'), "formatter" => "formatterArea",
+ 'className' => 'right'),
+ array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
+ array("key" => "total_price", "label"
=> lang('total_price'), 'formatter' => 'formatterPrice',
+ 'className' => 'right'),
+ array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "is_one_time", "label"
=> lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time'
: "",
+ 'className' => 'center'),
+ array("key" => "price_type_title",
"label" => lang('type'), 'sortable' => false,
+ 'className' => 'center')
+ );
+ }
+ else
+ {
+ $columns_def = array(
+ array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
+ 'sortable' => true, 'hidden' =>
false),
+ array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
+ 'hidden' => false, 'editor' =>
$mode == 'edit' ? true : false),
+ array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
+ 'formatter' =>
'formatterPrice', 'className' => 'right', 'editor' => $mode == 'edit' ? true :
false),
+ array('key' => 'location_factor',
'label' => lang('location'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'standard_factor',
'label' => lang('standard'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'custom_factor', 'label'
=> lang('custom prize factor'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array("key" => "area", "label" =>
lang('area'), "formatter" => "formatterArea",
+ 'className' => 'right'),
+ array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
+ array("key" => "total_price", "label"
=> lang('total_price'), 'formatter' => 'formatterPrice',
+ 'className' => 'right'),
+ array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "is_one_time", "label"
=> lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time'
: "",
+ 'className' => 'center'),
+ array("key" => "price_type_title",
"label" => lang('type'), 'sortable' => false,
+ 'className' => 'center')
+ );
+
+ }
+
+
+
if ($mode == 'edit')
{
$tabletools_price1[] = array
@@ -536,7 +575,7 @@
addPrice(oArgs, parameters);
"
);
-
+/*
$sogeneric = CreateObject('property.sogeneric',
'composite_standard');
$composite_standards =
$sogeneric->read(array('allrows' => true));
foreach ($composite_standards as
$composite_standard)
@@ -559,14 +598,29 @@
"
);
}
+*/
+ if
(empty($this->config->config_data['contract_furnished_status']))
+ {
+ unset($columns_def[4]);
+ unset($columns_def[5]);
+ unset($columns_def[6]);
+ unset($columns_def[7]);
+ unset($columns_def[8]);
+ unset($columns_def[9]);
+ }
+ else
+ {
+ unset($columns_def[4]);
+ unset($columns_def[5]);
+ unset($columns_def[6]);
+ unset($columns_def[7]);
+ unset($columns_def[8]);
+ unset($columns_def[9]);
+ unset($columns_def[10]);
+ unset($columns_def[11]);
+ unset($columns_def[12]);
+ }
- unset($columns_def[4]);
- unset($columns_def[5]);
- unset($columns_def[6]);
- unset($columns_def[7]);
- unset($columns_def[8]);
- unset($columns_def[9]);
-
$datatable_def[] = array
(
'container' => 'datatable-container_6',
@@ -1293,14 +1347,14 @@
// Redirect with error message if
responsibility area is eksternleie and contract type not set
if
(!is_numeric(phpgw::get_var('contract_type')) && (strcmp($responsibility_area,
"contract_type_eksternleie") == 0))
{
-
//$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message,
'error' => $error));
+
//$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message,
'error' => $error));
phpgwapi_cache::message_set(lang('billing_removed_external_contract'), 'error');
$this->edit();
}
}
else
{
- // Gets responsibility area from db (ex:
eksternleie, internleie)
+ // Gets responsibility area from db (ex:
eksternleie, internleie)
$responsibility_area =
rental_socontract::get_instance()->get_responsibility_title($location_id);
// Redirect with error message if
responsibility area is eksternleie and contract type not set
@@ -2514,7 +2568,6 @@
{
$contract_id = (int)phpgw::get_var('contract_id');
$list_price_item_id = phpgw::get_var('price_item_id');
- $factor = phpgw::get_var('factor', 'float');
$so_contract = rental_socontract::get_instance();
$contract = $so_contract->get_single($contract_id);
@@ -2524,7 +2577,7 @@
//return
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id, $factor);
foreach ($list_price_item_id as $price_item_id)
{
- $result =
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id, $factor);
+ $result =
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id);
if ($result)
{
$message['message'][] =
array('msg' => 'price_item ' . $price_item_id . ' ' . lang('has been added'));
@@ -2678,8 +2731,8 @@
}
/**
- *
- * Public function scans the contract template directory for
pdf contract templates
+ *
+ * Public function scans the contract template directory for
pdf contract templates
*/
public function get_pdf_templates()
{
Modified: branches/Version-2_0-branch/rental/inc/class.uiprice_item.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/class.uiprice_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/class.uiprice_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -350,13 +350,12 @@
$price_item->set_responsibility_id($responsibility_id);
$price_item->set_price_type_id(1); // defaults
to year
}
-
$price_item->set_title(phpgw::get_var('title'));
$price_item->set_agresso_id(phpgw::get_var('agresso_id'));
$price_item->set_is_area(phpgw::get_var('is_area') ==
'true' ? true : false);
$price_item->set_is_inactive(phpgw::get_var('is_inactive') == 'on' ? true :
false);
$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_standard(phpgw::get_var('is_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)
@@ -429,21 +428,16 @@
*/
public function query()
{
- if
($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
- {
- $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $user_rows_per_page = 10;
- }
+ $length = phpgw::get_var('length', 'int');
+ $user_rows_per_page = $length > 0 ? $length :
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $num_of_objects = $length == -1 ? 0 :
$user_rows_per_page;
+
$order = phpgw::get_var('order');
$draw = phpgw::get_var('draw', 'int');
$columns = phpgw::get_var('columns');
$start_index = phpgw::get_var('start', 'int',
'REQUEST', 0);
- $num_of_objects = (phpgw::get_var('length', 'int') <=
0) ? $user_rows_per_page : phpgw::get_var('length', 'int');
$sort_field = ($columns[$order[0]['column']]['data']) ?
$columns[$order[0]['column']]['data'] : 'agresso_id';
$sort_ascending = ($order[0]['dir'] == 'desc') ? false
: true;
Modified: branches/Version-2_0-branch/rental/inc/model/class.application.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/model/class.application.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/model/class.application.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -27,7 +27,7 @@
* @version $Id: $
*/
- phpgw::import_class('rental.soapplication');
+ phpgw::import_class('rental.boapplication');
include_class('rental', 'model', 'inc/model/');
@@ -83,7 +83,17 @@
{
return array(1 => 'Hybel', 2 => 'Leilighet');
}
+ public static function get_status_list()
+ {
+ return array(
+ self::STATUS_REGISTERED => lang('registered'),
+ self::STATUS_PENDING => lang('pending'),
+ self::STATUS_REJECTED => lang('rejected'),
+ self::STATUS_APPROVED => lang('approved')
+ );
+ }
+
public static function get_payment_methods()
{
return array(1 => 'Faktura', 2 => 'Trekk i lønn',3 =>
'intern faktura');
@@ -187,11 +197,19 @@
'related' => true,
),
'assign_date_start' => array('action'=>
PHPGW_ACL_READ | PHPGW_ACL_EDIT,
- 'type' => 'date'),
+ 'type' => 'date',
+ 'label'=> 'assign_start',
+ 'history' => true
+ ),
'assign_date_end' => array('action'=>
PHPGW_ACL_READ | PHPGW_ACL_EDIT,
- 'type' => 'date'),
+ 'type' => 'date',
+ 'label'=> 'assign_end',
+ 'history' => true
+ ),
'status' => array('action'=> PHPGW_ACL_READ |
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
- 'type' => 'int'),
+ 'type' => 'int',
+ 'history' => true,
+ ),
'entry_date' => array('action'=> PHPGW_ACL_READ
| PHPGW_ACL_ADD,
'type' => 'int',
'label' => 'entry_date',
@@ -201,7 +219,7 @@
'type' => 'int',
'label' => 'executive_officer',
'sortable' => true,
- 'hidden' => false
+ 'history' => true,
),
'identifier' => array('action'=> PHPGW_ACL_ADD
| PHPGW_ACL_EDIT,
'type' => 'string'),
@@ -235,6 +253,11 @@
'type' => 'comment'
);
}
+
+ if(!$entity->get_id())
+ {
+ $entity->status =
rental_application::STATUS_REGISTERED;
+ }
}
public function serialize()
@@ -244,12 +267,12 @@
public function store()
{
- return
rental_soapplication::get_instance()->store($this);
+ return
rental_boapplication::get_instance()->store($this);
}
- public function get($id)
+ public function read_single($id)
{
- return
rental_soapplication::get_instance()->read_single($id, true);
+ return
rental_boapplication::get_instance()->read_single($id, true);
}
}
\ No newline at end of file
Modified:
branches/Version-2_0-branch/rental/inc/model/class.contract_price_item.inc.php
===================================================================
---
branches/Version-2_0-branch/rental/inc/model/class.contract_price_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++
branches/Version-2_0-branch/rental/inc/model/class.contract_price_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -18,6 +18,10 @@
protected $date_end;
protected $is_one_time;
protected $is_billed;
+ protected $location_factor;
+ protected $standard_factor;
+ protected $custom_factor;
+ protected $price_type_id;
/**
* Constructor. Takes an optional ID. If a price item is
created from outside
@@ -119,6 +123,33 @@
$this->date_end = $date_end;
}
+ public function get_location_factor()
+ {
+ return $this->location_factor;
+ }
+
+ public function set_location_factor( $location_factor )
+ {
+ $this->location_factor = $location_factor;
+ }
+ public function get_standard_factor()
+ {
+ return $this->standard_factor;
+ }
+
+ public function set_standard_factor( $standard_factor )
+ {
+ $this->standard_factor = $standard_factor;
+ }
+ public function get_custom_factor()
+ {
+ return $this->custom_factor;
+ }
+
+ public function set_custom_factor( $custom_factor )
+ {
+ $this->custom_factor = $custom_factor;
+ }
/**
* Returns true if the price item is active at the given date,
false otherwise
*
@@ -199,6 +230,9 @@
//'total_price' => $currency_prefix.'
'.$this->get_total_price(),
'total_price' => $this->get_total_price(),
'is_one_time' => $this->is_one_time(),
+ 'location_factor' =>
$this->get_location_factor(),
+ 'standard_factor' =>
$this->get_standard_factor(),
+ 'custom_factor' => $this->get_custom_factor(),
// We set a format fitting for the
DateCellEditor here because
// this table has inline editing enabled. The
DateCellEditor is not
// happy about empty values if a custom parser
is set, so we use the
Modified: branches/Version-2_0-branch/rental/inc/model/class.invoice.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/model/class.invoice.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/model/class.invoice.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -515,7 +515,8 @@
$contract_price_item->get_area(), //
the rented area on this contract (derived from contract)
$contract_price_item->get_count(), //
the number of items on this price item
$invoice_price_item_start, // the
start date from which this price item should be calculated
- $invoice_price_item_end // the end
date to which this price item should be calculated
+ $invoice_price_item_end, // the end
date to which this price item should be calculated
+
$contract_price_item->get_price_type_id() // The price type, default: year
);
// If the contract price item is of type
one-time and it's dates are within the invoice period ...
Modified:
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
===================================================================
---
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -14,7 +14,8 @@
protected $invoice_id;
protected $is_area;
protected $is_one_time;
- protected $price_per_year;
+ protected $price_per_type;
+ protected $price_type_id;
protected $area;
protected $count;
protected $total_price;
@@ -22,7 +23,7 @@
protected $timestamp_end; // End date for the given invoice
public static $so;
- public function __construct( int $decimals, int $id, int
$invoice_id, string $title, string $agresso_id, bool $is_area, float
$price_per_year, float $area, int $count, int $timestamp_start, int
$timestamp_end )
+ public function __construct( int $decimals, int $id, int
$invoice_id, string $title, string $agresso_id, bool $is_area, float
$price_per_type, float $area, int $count, int $timestamp_start, int
$timestamp_end, int $price_type_id )
{
$this->decimals = (int)$decimals;
$this->id = (int)$id;
@@ -30,12 +31,13 @@
$this->title = $title;
$this->agresso_id = $agresso_id;
$this->is_area = (bool)$is_area;
- $this->price_per_year = (float)$price_per_year;
+ $this->price_per_type = (float)$price_per_type;
$this->area = (float)$area;
$this->count = (int)$count;
$this->timestamp_start = (int)$timestamp_start;
$this->timestamp_end = (int)$timestamp_end;
$this->total_price = null; // Needs to be re-calculated
+ $this->price_type_id = $price_type_id ? $price_type_id
: 1;
}
public function set_invoice_id( int $invoice_id )
@@ -65,17 +67,26 @@
$this->total_price = null; // Needs to be re-calculated
}
- public function set_price( $price_per_year )
+ public function set_price( $price_per_type )
{
- $this->price_per_year = (float)$price_per_year;
+ $this->price_per_type = (float)$price_per_type;
$this->total_price = null; // Needs to be re-calculated
}
public function get_price()
{
- return $this->price_per_year;
+ return $this->price_per_type;
}
+ public function set_price_type_id( $price_type_id = 1)
+ {
+ $this->price_type_id = (int)$price_type_id;
+ }
+ public function get_price_type_id()
+ {
+ return $this->price_type_id;
+ }
+
public function set_area( $area )
{
$this->area = (float)$area;
@@ -173,9 +184,21 @@
else // Incomplete month
{
// YYY: There must be a
better day to do this!?
-
$num_of_days_in_current_year = (date('L', strtotime($current_year . '01-01'))
== 0) ? 365 : 366;
- $num_of_days =
$last_day - $first_day + 1;
- $incomplete_months[] =
array($num_of_days_in_current_year, $num_of_days);
+ if($this->price_type_id
== 1) // year
+ {
+
$num_of_days_in_current_year = (date('L', strtotime($current_year . '01-01'))
== 0) ? 365 : 366;
+ $num_of_days =
$last_day - $first_day + 1;
+
$incomplete_months[] = array($num_of_days_in_current_year, $num_of_days);
+ }
+ else
if($this->price_type_id == 2) //month
+ {
+ $num_of_days =
$last_day - $first_day + 1;
+
$incomplete_months[] = array($num_of_days_in_current_month, $num_of_days);
+ }
+ else
+ {
+ throw new
Exception('Price type not supported');
+ }
}
}
}
@@ -184,18 +207,30 @@
$amount = $this->is_area() ? $this->get_area()
: $this->get_count();
// The total price of this price element for
complete months
- $this->total_price = (($this->get_price() *
$num_of_complete_months) / 12.0) * $amount;
+
+ if($this->price_type_id == 1) // year
+ {
+ $this->total_price =
(($this->get_price() * $num_of_complete_months) / 12.0) * $amount;
+ }
+ else if($this->price_type_id == 2) //month
+ {
+ $this->total_price =
($this->get_price() * $num_of_complete_months) * $amount;
+ }
+ else
+ {
+ throw new Exception('Price type not
supported');
+ }
// ---- Calculate incomplete months
- $price_per_year = $this->get_price() * $amount;
+ $price_per_type = $this->get_price() * $amount;
// Run through all the incomplete months ...
foreach ($incomplete_months as $day_factors)
{
// ... and add the sum of each
incomplete month to the total price of the price item
// Calculation: Price per day (price
per year divided with number of days in year) multiplied with number of days in
incomplete month
- $this->total_price += ($price_per_year
/ $day_factors[0]) * $day_factors[1];
+ $this->total_price += ($price_per_type
/ $day_factors[0]) * $day_factors[1];
}
// We round the total price for each price item
with the specified number of decimals precision
$this->total_price = round($this->total_price,
$this->decimals);
Modified: branches/Version-2_0-branch/rental/inc/model/class.model.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/model/class.model.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/model/class.model.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -263,7 +263,7 @@
}
- private function _validate( $entity, array &$errors,
$field_prefix = '' )
+ private function _validate( $entity, array &$errors )
{
$fields = $this->get_fields();
foreach ($fields as $field => $params)
@@ -318,7 +318,7 @@
$alternatives_ok = true;
}
}
- $error_key = empty($field_prefix) ? $field :
"{$field_prefix}[{$field}]";
+ $error_key = empty($params['label']) ? $field :
$params['label'];
if ($params['required'] && (!isset($value) ||
($value !== '0' && empty($value))) && !$alternatives_ok)
{
Modified: branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -24,8 +24,8 @@
protected $price_types = array(
1 => 'year',
2 => 'month',
- 3 => 'day',
- 4 => 'hour',
+// 3 => 'day',
+// 4 => 'hour',
);
//protected $is_one_time;
@@ -148,6 +148,7 @@
'responsibility_id' =>
$this->get_responsibility_id(),
'responsibility_title' =>
lang($this->get_responsibility_title()),
'price_type_title' =>
lang($this->get_price_type_title()),
+ 'price_type_id' => $this->get_price_type_id(),
//'is_one_time' => $this->is_one_time()
);
}
Modified: branches/Version-2_0-branch/rental/js/rental/application.edit.js
===================================================================
--- branches/Version-2_0-branch/rental/js/rental/application.edit.js
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/js/rental/application.edit.js
2016-09-02 11:39:37 UTC (rev 15567)
@@ -1,7 +1,7 @@
var oArgs = {menuaction: 'property.uigeneric.index', type: 'dimb', type_id:0};
var strURL = phpGWLink('index.php', oArgs, true);
-JqueryPortico.autocompleteHelper(strURL, 'ecodimb_name', 'ecodimb',
'ecodimb_container', 'descr');
+JqueryPortico.autocompleteHelper(strURL, 'ecodimb_name', 'ecodimb_id',
'ecodimb_container', 'descr');
$(document).ready(function ()
{
Modified: branches/Version-2_0-branch/rental/setup/phpgw_no.lang
===================================================================
--- branches/Version-2_0-branch/rental/setup/phpgw_no.lang 2016-09-02
11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/setup/phpgw_no.lang 2016-09-02
11:39:37 UTC (rev 15567)
@@ -634,4 +634,5 @@
rejected rental no Avvist
approved rental no Godkjent
location rental no Lokalisering
-custom prize factor rental no Prisfaktor
\ No newline at end of file
+custom prize factor rental no Prisfaktor
+standard rental no Standard
\ No newline at end of file
Modified: branches/Version-2_0-branch/rental/setup/setup.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/setup/setup.inc.php 2016-09-02
11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/setup/setup.inc.php 2016-09-02
11:39:37 UTC (rev 15567)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module identifier
- $setup_info['rental']['version'] = '0.1.0.26'; // Current module version
+ $setup_info['rental']['version'] = '0.1.0.27'; // Current module version
$setup_info['rental']['app_order'] = 51; // (?)
$setup_info['rental']['tables'] = array(
'rental_party', // All contract participants, tenants etc.
Modified: branches/Version-2_0-branch/rental/setup/tables_update.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/setup/tables_update.inc.php
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/setup/tables_update.inc.php
2016-09-02 11:39:37 UTC (rev 15567)
@@ -596,3 +596,38 @@
}
}
+ $test[] = '0.1.0.26';
+ function rental_upgrade0_1_0_26()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'location_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'standard_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'custom_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['rental']['currentver'] =
'0.1.0.27';
+ return $GLOBALS['setup_info']['rental']['currentver'];
+ }
+ }
+
Modified: branches/Version-2_0-branch/rental/templates/base/application.xsl
===================================================================
--- branches/Version-2_0-branch/rental/templates/base/application.xsl
2016-09-02 11:28:34 UTC (rev 15566)
+++ branches/Version-2_0-branch/rental/templates/base/application.xsl
2016-09-02 11:39:37 UTC (rev 15567)
@@ -10,10 +10,10 @@
</xsl:when>
<xsl:when test="adjustment_price">
<xsl:apply-templates select="adjustment_price" />
-
+
</xsl:when>
</xsl:choose>
-
+
</xsl:template>
<!-- add / edit -->
@@ -33,7 +33,7 @@
<form id="form" name="form" method="post"
action="{$form_action}" class="pure-form pure-form-aligned">
<div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="tabs"/>
- <input type="hidden" id="active_tab"
name="active_tab"/>
+ <input type="hidden" id="active_tab"
name="active_tab" value="{value_active_tab}"/>
<div id="application">
<fieldset>
<xsl:if test="application/id !=
''">
@@ -288,7 +288,7 @@
</label>
<input type="text"
name="email" id="email" value="{application/email}">
<xsl:attribute
name="data-validation">
-
<xsl:text>required</xsl:text>
+
<xsl:text>email</xsl:text>
</xsl:attribute>
</input>
<xsl:choose>
@@ -410,28 +410,20 @@
<label>
<xsl:value-of select="php:function('lang', 'details')"/>
</label>
- <xsl:choose>
-
<xsl:when test="additional_notes=''">
-
<xsl:value-of select="php:function('lang', 'no additional notes')"/>
-
</xsl:when>
-
<xsl:otherwise>
-
<div class = 'pure-u-md-1-2'>
-
<xsl:for-each select="datatable_def">
-
<xsl:if test="container = 'datatable-container_0'">
-
<xsl:call-template name="table_setup">
-
<xsl:with-param name="container" select
='container'/>
-
<xsl:with-param name="requestUrl" select
='requestUrl'/>
-
<xsl:with-param name="ColumnDefs" select
='ColumnDefs'/>
-
<xsl:with-param name="data" select ='data'/>
-
<xsl:with-param name="config" select ='config'/>
-
</xsl:call-template>
-
</xsl:if>
-
</xsl:for-each>
-
</div>
-
</xsl:otherwise>
- </xsl:choose>
+ <div
class="pure-custom">
+
<xsl:for-each select="datatable_def">
+
<xsl:if test="container = 'datatable-container_0'">
+
<xsl:call-template name="table_setup">
+
<xsl:with-param name="container" select ='container'/>
+
<xsl:with-param name="requestUrl" select ='requestUrl'/>
+
<xsl:with-param name="ColumnDefs" select ='ColumnDefs'/>
+
<xsl:with-param name="data" select ='data'/>
+
<xsl:with-param name="config" select ='config'/>
+
</xsl:call-template>
+
</xsl:if>
+
</xsl:for-each>
+ </div>
</div>
-
</fieldset>
</div>
</xsl:if>
@@ -445,7 +437,7 @@
</input>
<xsl:variable name="cancel_url">
<xsl:value-of select="cancel_url"/>
- </xsl:variable>
+ </xsl:variable>
<input type="button" class="pure-button
pure-button-primary" name="cancel" onClick="window.location = '{cancel_url}';">
<xsl:attribute name="value">
<xsl:value-of
select="php:function('lang', 'cancel')"/>
@@ -482,7 +474,7 @@
<div class="pure-control-group">
<label>
<xsl:value-of
select="php:function('lang', 'field_of_responsibility')"/>
- </label>
+ </label>
<xsl:value-of
select="value_field_of_responsibility"/>
</div>
<div class="pure-control-group">
@@ -501,7 +493,7 @@
<xsl:if test="is_area = 1">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
-
</input>
+ </input>
<xsl:value-of select="php:function('lang', 'calculate_price_per_area')"/>
</div>
<div>
@@ -509,7 +501,7 @@
<xsl:if test="is_area = 0">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
-
</input>
+ </input>
<xsl:value-of select="php:function('lang', 'calculate_price_apiece')"/>
</div>
</div>
@@ -537,7 +529,7 @@
</input>
<xsl:if
test="has_active_contract = 1">
<xsl:value-of
select="lang_price_element_in_use"/>
- </xsl:if>
+ </xsl:if>
</div>
<div class="pure-control-group">
<label>
@@ -557,7 +549,7 @@
<div class="proplist-col">
<xsl:variable name="cancel_url">
<xsl:value-of select="cancel_url"/>
- </xsl:variable>
+ </xsl:variable>
<input type="button" class="pure-button
pure-button-primary" name="cancel" value="{lang_cancel}"
onMouseout="window.status='';return true;" onClick="window.location =
'{cancel_url}';"/>
</div>
</form>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15567] Stable: Merge 15542:15566 from trunk,
sigurdne <=