[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15530] rental: more on application
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15530] rental: more on application |
Date: |
Mon, 29 Aug 2016 18:54:56 +0000 (UTC) |
Revision: 15530
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15530
Author: sigurdne
Date: 2016-08-29 18:54:56 +0000 (Mon, 29 Aug 2016)
Log Message:
-----------
rental: more on application
Modified Paths:
--------------
trunk/rental/inc/class.uiapplication.inc.php
trunk/rental/inc/model/class.application.inc.php
trunk/rental/inc/model/class.model.inc.php
trunk/rental/js/rental/application.edit.js
trunk/rental/setup/setup.inc.php
trunk/rental/setup/tables_current.inc.php
trunk/rental/setup/tables_update.inc.php
trunk/rental/templates/base/application.xsl
Modified: trunk/rental/inc/class.uiapplication.inc.php
===================================================================
--- trunk/rental/inc/class.uiapplication.inc.php 2016-08-29 18:54:09 UTC
(rev 15529)
+++ trunk/rental/inc/class.uiapplication.inc.php 2016-08-29 18:54:56 UTC
(rev 15530)
@@ -231,6 +231,7 @@
public function edit( $values = array(), $mode = 'edit' )
{
+ $active_tab = !empty($values['active_tab']) ?
$values['active_tab'] : phpgw::get_var('active_tab', 'string', 'REQUEST',
'application');
$GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('edit');
if (!$this->acl_add)
{
@@ -269,15 +270,25 @@
}
$tabs = array();
- $tabs['application'] = array('label' =>
lang('application'), 'link' => '#application');
- $tabs['party'] = array('label' => lang('party'), 'link'
=> '#party');
+ $tabs['application'] = array(
+ 'label' => lang('application'),
+ 'link' => '#application',
+ 'function' => "set_tab('application')"
+ );
+ $tabs['party'] = array(
+ 'label' => lang('party'),
+ 'link' => '#party',
+ 'function' => "set_tab('party')"
+ );
if($step > 1)
{
- $tabs['assignment'] = array('label' =>
lang('assignment'), 'link' => '#assignment');
+ $tabs['assignment'] = array(
+ 'label' => lang('assignment'),
+ 'link' => '#assignment',
+ 'function' => "set_tab('assignment')"
+ );
}
- $active_tab = 'showing';
-
$composite_type = array();
foreach ($this->composite_types as $_key => $_value)
{
@@ -307,8 +318,33 @@
'selected' => ($account['account_id']
== $application->executive_officer) ? 1 : 0
);
}
+ $comments = (array)$application->comments;
+ foreach ($comments as $key => &$comment)
+ {
+ $comment['value_count'] = $key +1;
+ $comment['value_date'] =
$GLOBALS['phpgw']->common->show_date($comment['time']);
+ }
+ $comments_def = array(
+ array('key' => 'value_count', 'label' => '#',
'sortable' => true, 'resizeable' => true),
+ array('key' => 'value_date', 'label' =>
lang('Date'), 'sortable' => true, 'resizeable' => true),
+ array('key' => 'author', 'label' =>
lang('User'), 'sortable' => true, 'resizeable' => true),
+ array('key' => 'comment', 'label' =>
lang('Note'), 'sortable' => true, 'resizeable' => true)
+ );
+
+ $datatable_def[] = array(
+ 'container' => 'datatable-container_0',
+ 'requestUrl' => "''",
+ 'ColumnDefs' => $comments_def,
+ 'data' => json_encode($comments),
+ 'config' => array(
+ array('disableFilter' => true),
+ array('disablePagination' => true)
+ )
+ );
+
$data = array(
+ 'datatable_def' => $datatable_def,
'form_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'rental.uiapplication.save')),
'cancel_url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'rental.uiapplication.index',)),
'application' => $application,//->toArray(),
@@ -330,7 +366,7 @@
phpgwapi_jquery::load_widget('autocomplete');
self::add_javascript('rental', 'rental',
'application.edit.js');
- self::render_template_xsl(array('application'),
array($mode => $data));
+ self::render_template_xsl(array('application',
'datatable_inline'), array($mode => $data));
}
/*
* To be removed
@@ -353,8 +389,9 @@
{
phpgw::no_access();
}
- _debug_array($_POST);
+// _debug_array($_POST);
$application_id = phpgw::get_var('id', 'int');
+ $active_tab = phpgw::get_var('active_tab', 'string',
'REQUEST', 'application');
if ($application_id)
{
@@ -377,19 +414,20 @@
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
self::redirect(array(
'menuaction' =>
'rental.uiapplication.edit',
- 'id' =>
$application->get_id()
+ 'id' =>
$application->get_id(),
+ 'active_tab' => $active_tab
)
);
}
else
{
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
-
+ $this->edit(array('application' =>
$application, 'active_tab' => $active_tab));
}
}
else
{
- $this->edit(array('application' =>
$application));
+ $this->edit(array('application' =>
$application, 'active_tab' => $active_tab));
}
}
@@ -399,7 +437,7 @@
foreach ($fields as $field => $field_info)
{
- if($field_info['action'] & PHPGW_ACL_ADD)
+ if(($field_info['action'] & PHPGW_ACL_ADD) ||
($field_info['action'] & PHPGW_ACL_EDIT))
{
$application->set_field( $field,
phpgw::get_var($field, $field_info['type'] ) );
}
Modified: trunk/rental/inc/model/class.application.inc.php
===================================================================
--- trunk/rental/inc/model/class.application.inc.php 2016-08-29 18:54:09 UTC
(rev 15529)
+++ trunk/rental/inc/model/class.application.inc.php 2016-08-29 18:54:56 UTC
(rev 15530)
@@ -65,6 +65,8 @@
$email,
$unit_leader,
$comment,
+ $comments,
+ $comment_input,
$assign_date_start,
$assign_date_end,
$entry_date,
@@ -169,26 +171,31 @@
'sf_validator' =>
createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field%
is invalid'))),
'unit_leader' => array('action'=> PHPGW_ACL_ADD
| PHPGW_ACL_EDIT,
'type' => 'string'),
- 'comment' => array('action'=> PHPGW_ACL_ADD |
PHPGW_ACL_EDIT,
- 'type' => 'string'),
+ 'comments' => array(
+ 'action'=> PHPGW_ACL_ADD |
PHPGW_ACL_EDIT,
+ 'type' => 'string',
+ 'manytomany' => array(
+ 'input_field' =>
'comment_input',
+ 'table' =>
'rental_application_comment',
+ 'key' => 'application_id',
+ 'column' => array('time',
'author', 'comment', 'type'),
+ 'order' => array('sort' =>
'time', 'dir' => 'ASC')
+ )),
+ 'comment' => array(
+ 'action'=> PHPGW_ACL_ADD |
PHPGW_ACL_EDIT,
+ 'type' => 'string',
+ 'related' => true,
+ ),
'assign_date_start' => array('action'=>
PHPGW_ACL_READ | PHPGW_ACL_EDIT,
'type' => 'date'),
'assign_date_end' => array('action'=>
PHPGW_ACL_READ | PHPGW_ACL_EDIT,
'type' => 'date'),
'status' => array('action'=> PHPGW_ACL_READ |
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
'type' => 'int'),
- /* 'status_text' => array('action'=>
PHPGW_ACL_READ,
- 'type' => 'string',
- 'label' => 'status',
- 'className' => '',
- 'sortable' => true,
- 'hidden' => false
- ),*/
'entry_date' => array('action'=> PHPGW_ACL_READ
| PHPGW_ACL_ADD,
'type' => 'int',
'label' => 'entry_date',
'sortable' => true,
-
),
'executive_officer' => array('action'=>
PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
'type' => 'int',
@@ -214,6 +221,21 @@
return $fields;
}
+ /**
+ * Implement in subclasses to perform actions on entity before
validation
+ */
+ protected function preValidate( &$entity )
+ {
+ if (!empty($entity->comment))
+ {
+ $entity->comment_input = array(
+ 'time' => time(),
+ 'author' =>
$GLOBALS['phpgw_info']['user']['fullname'],
+ 'comment' => $entity->comment,
+ 'type' => 'comment'
+ );
+ }
+ }
public function serialize()
{
Modified: trunk/rental/inc/model/class.model.inc.php
===================================================================
--- trunk/rental/inc/model/class.model.inc.php 2016-08-29 18:54:09 UTC (rev
15529)
+++ trunk/rental/inc/model/class.model.inc.php 2016-08-29 18:54:56 UTC (rev
15530)
@@ -238,7 +238,7 @@
{
$errors = array();
$this->preValidate( $this );
- $this->_validate( $this, $this->get_fields(), $errors);
+ $this->_validate( $this, $errors);
$this->doValidate( $this, $errors);
foreach ($errors as $key => $message)
{
@@ -263,9 +263,9 @@
}
- private function _validate( $entity, array $fields, array
&$errors, $field_prefix = '' )
+ private function _validate( $entity, array &$errors,
$field_prefix = '' )
{
-
+ $fields = $this->get_fields();
foreach ($fields as $field => $params)
{
if (!is_array($params))
Modified: trunk/rental/js/rental/application.edit.js
===================================================================
--- trunk/rental/js/rental/application.edit.js 2016-08-29 18:54:09 UTC (rev
15529)
+++ trunk/rental/js/rental/application.edit.js 2016-08-29 18:54:56 UTC (rev
15530)
@@ -24,3 +24,8 @@
errorMessageKey: ''
});
});
+
+function set_tab(tab)
+{
+ $("#active_tab").val(tab);
+}
Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php 2016-08-29 18:54:09 UTC (rev 15529)
+++ trunk/rental/setup/setup.inc.php 2016-08-29 18:54:56 UTC (rev 15530)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module identifier
- $setup_info['rental']['version'] = '0.1.0.25'; // Current module version
+ $setup_info['rental']['version'] = '0.1.0.26'; // Current module version
$setup_info['rental']['app_order'] = 51; // (?)
$setup_info['rental']['tables'] = array(
'rental_party', // All contract participants, tenants etc.
@@ -28,6 +28,7 @@
'rental_billing_info', // Term information for each billing
'rental_adjustment', // Price regulations
'rental_application',
+ 'rental_application_comment',
'rental_application_composite'
);
$setup_info['rental']['enable'] = 1;
Modified: trunk/rental/setup/tables_current.inc.php
===================================================================
--- trunk/rental/setup/tables_current.inc.php 2016-08-29 18:54:09 UTC (rev
15529)
+++ trunk/rental/setup/tables_current.inc.php 2016-08-29 18:54:56 UTC (rev
15530)
@@ -518,7 +518,6 @@
'email' => array('type' => 'varchar',
'precision' => '255', 'nullable' => true),
'account_number' => array('type' => 'varchar',
'precision' => '255', 'nullable' => true),
'unit_leader' => array('type' => 'varchar',
'precision' => '255', 'nullable' => true),
- 'comment' => array('type' => 'text', 'nullable'
=> true),
'status' => array('type' => 'int', 'precision'
=> '2', 'nullable' => false),
'executive_officer' => array('type' => 'int',
'precision' => '4', 'nullable' => true),
),
@@ -527,6 +526,22 @@
'ix' => array(),
'uc' => array()
),
+ 'rental_application_comment' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'nullable' =>
False),
+ 'application_id' => array('type' => 'int',
'precision' => '4', 'nullable' => False),
+ 'time' => array('type' => 'int', 'precision' =>
'8', 'nullable' => False),
+ 'author' => array('type' => 'text', 'nullable'
=> False),
+ 'comment' => array('type' => 'text', 'nullable'
=> False),
+ 'type' => array('type' => 'varchar',
'precision' => '20', 'nullable' => false,
+ 'default' => 'comment'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'rental_application' => array('application_id'
=> 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
'rental_application_composite' => array(
'fd' => array(
'id' => array('type' => 'auto', 'nullable' =>
false),
Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php 2016-08-29 18:54:09 UTC (rev
15529)
+++ trunk/rental/setup/tables_update.inc.php 2016-08-29 18:54:56 UTC (rev
15530)
@@ -562,3 +562,37 @@
}
}
+ $test[] = '0.1.0.25';
+ function rental_upgrade0_1_0_25()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('rental_application', array(),
'comment');
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'rental_application_comment', array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto',
'nullable' => False),
+ 'application_id' =>
array('type' => 'int', 'precision' => '4', 'nullable' => False),
+ 'time' => array('type' =>
'int', 'precision' => '8', 'nullable' => False),
+ 'author' => array('type' =>
'text', 'nullable' => False),
+ 'comment' => array('type' =>
'text', 'nullable' => False),
+ 'type' => array('type' =>
'varchar', 'precision' => '20', 'nullable' => false,
+ 'default' => 'comment'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'rental_application' =>
array('application_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['rental']['currentver'] =
'0.1.0.26';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
Modified: trunk/rental/templates/base/application.xsl
===================================================================
--- trunk/rental/templates/base/application.xsl 2016-08-29 18:54:09 UTC (rev
15529)
+++ trunk/rental/templates/base/application.xsl 2016-08-29 18:54:56 UTC (rev
15530)
@@ -33,6 +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"/>
<div id="application">
<fieldset>
<xsl:if test="application/id !=
''">
@@ -238,11 +239,10 @@
<label>
<xsl:value-of
select="php:function('lang', 'company')"/>
</label>
- <input type="text"
id="company_name" name="company_name" value="{application/company}">
+ <input type="text"
id="company_name" name="company_name" value="{application/company_name}">
<xsl:attribute
name="data-validation">
<xsl:text>naming</xsl:text>
</xsl:attribute>
-
</input>
</div>
<div class="pure-control-group">
@@ -306,14 +306,6 @@
</label>
<input type="text"
id="unit_leader" name="unit_leader" value="{application/unit_leader}"></input>
</div>
- <div class="pure-control-group">
- <label>
- <xsl:value-of
select="php:function('lang', 'comment')"/>
- </label>
- <textarea cols="47"
rows="7" name="comment">
- <xsl:value-of
select="application/comment"/>
- </textarea>
- </div>
<xsl:choose>
<xsl:when
test="use_fellesdata = 1">
<div
class="pure-control-group">
@@ -347,11 +339,11 @@
<xsl:value-of select="$lang_date_start"/>
</label>
<input
type="text" id="assign_date_start" name="assign_date_start" size="10"
readonly="readonly">
- <xsl:if
test="application/assign_date_start != 0 and application/assign_date_start !=
''">
-
<xsl:attribute name="value">
-
<xsl:value-of select="php:function('date', $date_format,
number(application/assign_date_start))"/>
-
</xsl:attribute>
- </xsl:if>
+ <xsl:if
test="application/assign_date_start != 0 and application/assign_date_start !=
''">
+
<xsl:attribute name="value">
+
<xsl:value-of select="php:function('date', $date_format,
number(application/assign_date_start))"/>
+
</xsl:attribute>
+
</xsl:if>
<!--xsl:attribute name="data-validation">
<xsl:text>required</xsl:text>
</xsl:attribute>
@@ -369,11 +361,11 @@
<xsl:value-of select="$lang_date_end"/>
</label>
<input
type="text" id="assign_date_end" name="assign_date_end" size="10"
readonly="readonly">
- <xsl:if
test="application/assign_date_end != 0 and application/assign_date_end != ''">
-
<xsl:attribute name="value">
-
<xsl:value-of select="php:function('date', $date_format,
number(application/assign_date_end))"/>
-
</xsl:attribute>
- </xsl:if>
+ <xsl:if
test="application/assign_date_end != 0 and application/assign_date_end != ''">
+
<xsl:attribute name="value">
+
<xsl:value-of select="php:function('date', $date_format,
number(application/assign_date_end))"/>
+
</xsl:attribute>
+
</xsl:if>
<!--xsl:attribute name="data-validation">
<xsl:text>required</xsl:text>
</xsl:attribute>
@@ -406,6 +398,39 @@
<xsl:apply-templates select="status_list/options"/>
</select>
</div>
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'comment')"/>
+ </label>
+ <textarea
cols="47" rows="7" name="comment">
+
<xsl:value-of select="application/comment"/>
+ </textarea>
+ </div>
+ <div
class="pure-control-group">
+ <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>
</fieldset>
</div>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15530] rental: more on application,
sigurdne <=