[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14218] booking: configurable agegroups and target au
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14218] booking: configurable agegroups and target audiences per top level activity |
Date: |
Tue, 20 Oct 2015 10:44:27 +0000 |
Revision: 14218
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14218
Author: sigurdne
Date: 2015-10-20 10:44:26 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
booking: configurable agegroups and target audiences per top level activity
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.boactivity.inc.php
branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
branches/dev-syncromind/booking/inc/class.boaudience.inc.php
branches/dev-syncromind/booking/inc/class.soactivity.inc.php
branches/dev-syncromind/booking/inc/class.soagegroup.inc.php
branches/dev-syncromind/booking/inc/class.soaudience.inc.php
branches/dev-syncromind/booking/inc/class.uiagegroup.inc.php
branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
branches/dev-syncromind/booking/inc/class.uiaudience.inc.php
branches/dev-syncromind/booking/inc/class.uireports.inc.php
branches/dev-syncromind/booking/js/booking/application.js
branches/dev-syncromind/booking/setup/setup.inc.php
branches/dev-syncromind/booking/setup/tables_current.inc.php
branches/dev-syncromind/booking/setup/tables_update.inc.php
branches/dev-syncromind/booking/templates/base/agegroup_edit.xsl
branches/dev-syncromind/booking/templates/base/agegroup_new.xsl
branches/dev-syncromind/booking/templates/base/application_new.xsl
branches/dev-syncromind/booking/templates/base/audience_edit.xsl
branches/dev-syncromind/booking/templates/base/audience_new.xsl
branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
Modified: branches/dev-syncromind/booking/inc/class.boactivity.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boactivity.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.boactivity.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -61,4 +61,17 @@
return $this->so->get_path($id);
}
+ public function get_top_level($selected = 0)
+ {
+ $values = $this->so->get_top_level();
+ if($selected)
+ {
+ foreach ($values as $entry)
+ {
+ $entry['selected'] = $entry['id'] ==
$selected ? 1 : 0;
+ }
+ }
+ return $values;
+ }
+
}
Modified: branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.boagegroup.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -9,9 +9,15 @@
$this->so = CreateObject('booking.soagegroup');
}
- function fetch_age_groups()
+ function fetch_age_groups($top_level_activity = 0)
{
- return
$this->so->read(array('filters'=>array('active'=>'1'), 'sort'=>'sort'));
+ $filters = array('active'=>'1');
+ if($top_level_activity)
+ {
+ $filters['activity_id'] = $top_level_activity;
+ }
+
+ return $this->so->read(array('filters'=>$filters,
'sort'=>'sort'));
}
// Extract agegroup info from _POST into $data
Modified: branches/dev-syncromind/booking/inc/class.boaudience.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boaudience.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.boaudience.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -19,8 +19,14 @@
unset($_SESSION['ActiveSession']);
}
- function fetch_target_audience()
+ function fetch_target_audience($top_level_activity = 0)
{
- return
$this->so->read(array('filters'=>array('active'=>'1'), 'sort'=>'sort'));
+ $filters = array('active'=>'1');
+ if($top_level_activity)
+ {
+ $filters['activity_id'] = $top_level_activity;
+ }
+
+ return $this->so->read(array('filters'=>$filters,
'sort'=>'sort'));
}
}
Modified: branches/dev-syncromind/booking/inc/class.soactivity.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soactivity.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.soactivity.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -56,4 +56,21 @@
return $path;
}
+ public function get_top_level()
+ {
+
+ $sql = "SELECT name, id FROM bb_activity WHERE
parent_id = 0 OR parent_id IS NULL" ;
+
+ $this->db->query($sql, __LINE__, __FILE__);
+ $values = array();
+
+ while ($this->db->next_record())
+ {
+ $values[] = array(
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name', true),
+ );
+ }
+ return $values;
+ }
}
Modified: branches/dev-syncromind/booking/inc/class.soagegroup.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soagegroup.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.soagegroup.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -8,6 +8,16 @@
parent::__construct( 'bb_agegroup',
array(
'id'
=> array( 'type' => 'int'),
+
'activity_id' => array( 'type' => 'int',
+
'required' => true),
+
'activity_name' => array('type' => 'string',
+
'query' => true,
+
'join' => array(
+
'table' => 'bb_activity',
+
'fkey' => 'activity_id',
+
'key' => 'id',
+
'column' => 'name'
+
)),
'name'
=> array( 'type' => 'string',
'query' => true,
'required' => true ),
Modified: branches/dev-syncromind/booking/inc/class.soaudience.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soaudience.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.soaudience.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -1,27 +1,37 @@
<?php
phpgw::import_class('booking.socommon');
-
+
class booking_soaudience extends booking_socommon
{
+
function __construct()
{
- parent::__construct('bb_targetaudience',
- array(
- 'id' => array(
'type' => 'int'),
- 'name' => array(
'type' => 'string',
-
'query' => true,
-
'required' => true ),
- 'sort' => array(
'type' => 'int',
+ parent::__construct('bb_targetaudience', array(
+ 'id' =>
array('type' => 'int'),
+ 'activity_id' => array( 'type'
=> 'int',
'required' => true),
- 'description' => array( 'type'
=> 'string',
-
'query' => true,
-
'required' => false),
- 'active' => array(
'type' => 'int')
+ 'activity_name' => array('type'
=> 'string',
+ 'query' => true,
+ 'join' => array(
+ 'table' =>
'bb_activity',
+ 'fkey' =>
'activity_id',
+ 'key' => 'id',
+ 'column' => 'name'
+ )),
+ 'name' =>
array('type' => 'string',
+ 'query' => true,
+ 'required' => true),
+ 'sort' =>
array('type' => 'int',
+ 'required' => true),
+ 'description' => array('type'
=> 'string',
+ 'query' => true,
+ 'required' => false),
+ 'active' =>
array('type' => 'int')
)
);
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
}
-
+
function set_active_session()
{
$this->so->set_active_session();
@@ -31,4 +41,4 @@
{
$this->so->unset_active_session();
}
- }
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/booking/inc/class.uiagegroup.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uiagegroup.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.uiagegroup.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -13,7 +13,6 @@
'index' => true,
'query' => true,
'add' => true,
- 'show' => true,
'active' => true,
'edit' => true
);
@@ -25,6 +24,7 @@
// Analizar esta linea de permisos
self::process_booking_unauthorized_exceptions();
$this->bo = CreateObject('booking.boagegroup');
+ $this->activity_bo = CreateObject('booking.boactivity');
self::set_active_menu('booking::settings::agegroup');
}
@@ -90,6 +90,10 @@
'formatter' =>
'JqueryPortico.formatLink'
),
array(
+ 'key' =>
'activity_name',
+ 'label' =>
lang('activity')
+ ),
+ array(
'key' => 'active',
'label' =>
lang('Active')
),
@@ -143,9 +147,13 @@
{
$errors = array();
$agegroup = array();
+
+ $activity_id = phpgw::get_var('activity_id', int,
'POST');
+ $activities =
$this->activity_bo->get_top_level($activity_id);
+
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
- $agegroup = extract_values($_POST,
array('name', 'sort', 'description'));
+ $agegroup = extract_values($_POST,
array('activity_id', 'name', 'sort', 'description'));
$agegroup['active'] = true;
$errors = $this->bo->validate($agegroup);
if(!$errors)
@@ -163,14 +171,17 @@
$active_tab = 'generic';
$agegroup['tabs'] =
phpgwapi_jquery::tabview_generate($tabs, $active_tab);
-
- self::render_template_xsl('agegroup_new',
array('agegroup' => $agegroup));
+ phpgwapi_jquery::formvalidator_generate(array());
+
+ self::render_template_xsl('agegroup_new',
array('agegroup' => $agegroup, 'activities' => $activities));
}
public function edit()
{
$id = intval(phpgw::get_var('id', 'GET'));
$resource = $this->bo->read_single($id);
+ $activities =
$this->activity_bo->get_top_level($resource['activity_id']);
+
$resource['id'] = $id;
$resource['resource_link'] =
self::link(array('menuaction' => 'booking.uiagegroup.show', 'id' =>
$resource['id']));
$resource['resources_link'] =
self::link(array('menuaction' => 'booking.uiresource.index'));
@@ -196,6 +207,7 @@
$resource['tabs'] =
phpgwapi_jquery::tabview_generate($tabs, $active_tab);
$resource['cancel_link'] =
self::link(array('menuaction' => 'booking.uiagegroup.index'));
- self::render_template_xsl('agegroup_edit',
array('resource' => $resource, 'lang' => $lang));
+ phpgwapi_jquery::formvalidator_generate(array());
+ self::render_template_xsl('agegroup_edit',
array('resource' => $resource, 'activities' => $activities));
}
}
Modified: branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -756,11 +756,14 @@
{
$application['cancel_link'] =
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' =>
phpgw::get_var('building_id', 'GET')));
}
+ $activity_id = phpgw::get_var('activity_id', 'int',
'REQUEST', -1);
+ $activity_path =
$this->activity_bo->get_path($activity_id);
+ $top_level_activity = $activity_path ?
$activity_path[0]['id'] : -1;
$activities = $this->activity_bo->fetch_activities();
$activities = $activities['results'];
- $agegroups = $this->agegroup_bo->fetch_age_groups();
+ $agegroups =
$this->agegroup_bo->fetch_age_groups($top_level_activity);
$agegroups = $agegroups['results'];
- $audience = $this->audience_bo->fetch_target_audience();
+ $audience =
$this->audience_bo->fetch_target_audience($top_level_activity);
$application['audience_json'] =
json_encode(array_map('intval',$application['audience']));
$audience = $audience['results'];
@@ -807,6 +810,8 @@
{
$id = intval(phpgw::get_var('id', 'GET'));
$application = $this->bo->read_single($id);
+ $activity_path =
$this->activity_bo->get_path($application['activity_id']);
+ $top_level_activity = $activity_path ?
$activity_path[0]['id'] : 0;
$this->check_application_assigned_to_current_user($application);
@@ -869,9 +874,9 @@
$application['cancel_link'] =
self::link(array('menuaction' => 'booking.uiapplication.index'));
$activities = $this->activity_bo->fetch_activities();
$activities = $activities['results'];
- $agegroups = $this->agegroup_bo->fetch_age_groups();
+ $agegroups =
$this->agegroup_bo->fetch_age_groups($top_level_activity);
$agegroups = $agegroups['results'];
- $audience = $this->audience_bo->fetch_target_audience();
+ $audience =
$this->audience_bo->fetch_target_audience($top_level_activity);
$audience = $audience['results'];
$this->install_customer_identifier_ui($application);
$application['customer_identifier_types']['ssn'] =
'Date of birth or SSN';
@@ -953,6 +958,8 @@
$id = intval(phpgw::get_var('id', 'GET'));
$application = $this->bo->read_single($id);
+ $activity_path =
$this->activity_bo->get_path($application['activity_id']);
+ $top_level_activity = $activity_path ?
$activity_path[0]['id'] : 0;
$tabs = array();
$tabs['generic'] = array('label' =>
lang('Application'), 'link' => '#application');
$active_tab = 'generic';
@@ -1057,7 +1064,9 @@
$this->set_case_officer($application);
// $comments = array_reverse($application['comments']);
//fixed in db
- $agegroups = $this->agegroup_bo->fetch_age_groups();
+ $agegroups =
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+// _debug_array($application);
+// _debug_array($agegroups);
$agegroups = $agegroups['results'];
$audience = $this->audience_bo->fetch_target_audience();
$audience = $audience['results'];
@@ -1103,4 +1112,17 @@
// var_dump($application);
// exit();
}
+
+ function get_activity_data()
+ {
+ $activity_id = phpgw::get_var('activity_id', 'int',
'REQUEST', -1);
+ $activity_path =
$this->activity_bo->get_path($activity_id);
+ $top_level_activity = $activity_path ?
$activity_path[0]['id'] : -1;
+ $agegroups =
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+ $audience =
$this->audience_bo->fetch_target_audience($top_level_activity);
+ return array(
+ 'agegroups' => $agegroups['results'],
+ 'audience' => $audience['results'],
+ );
+ }
}
Modified: branches/dev-syncromind/booking/inc/class.uiaudience.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uiaudience.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.uiaudience.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -25,6 +25,7 @@
// Analizar esta linea de permisos
self::process_booking_unauthorized_exceptions();
$this->bo = CreateObject('booking.boaudience');
+ $this->activity_bo = CreateObject('booking.boactivity');
self::set_active_menu('booking::settings::audience');
}
@@ -110,6 +111,10 @@
'label' =>
lang('Description')
),
array(
+ 'key' =>
'activity_name',
+ 'label' =>
lang('activity')
+ ),
+ array(
'key' => 'link',
'hidden' => true
)
@@ -130,7 +135,7 @@
}
// self::render_template('datatable', $data);
- self::render_template_xsl('datatable_jquery',$data);
+
self::render_template_xsl('datatable_jquery',$data);
}
public function query()
@@ -163,9 +168,11 @@
{
$errors = array();
$audience = array();
+ $activity_id = phpgw::get_var('activity_id', int,
'POST');
+ $activities =
$this->activity_bo->get_top_level($activity_id);
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
- $audience = extract_values($_POST,
array('name', 'sort', 'description'));
+ $audience = extract_values($_POST,
array('activity_id','name', 'sort', 'description'));
$audience['active'] = 1;
$errors = $this->bo->validate($audience);
if(!$errors)
@@ -184,14 +191,16 @@
// $data = array();
$audience['tabs'] =
phpgwapi_jquery::tabview_generate($tabs, $active_tab);
-
- self::render_template_xsl('audience_new',
array('audience' => $audience));
+ phpgwapi_jquery::formvalidator_generate(array());
+ self::render_template_xsl('audience_new',
array('audience' => $audience, 'activities' => $activities));
}
public function edit()
{
$id = intval(phpgw::get_var('id', 'GET'));
$audience = $this->bo->read_single($id);
+ $activities =
$this->activity_bo->get_top_level($audience['activity_id']);
+
$audience['id'] = $id;
$audience['resource_link'] =
self::link(array('menuaction' => 'booking.uiaudience.show', 'id' =>
$audience['id']));
$audience['resources_link'] =
self::link(array('menuaction' => 'booking.uiresource.index'));
@@ -217,7 +226,9 @@
$audience['tabs'] =
phpgwapi_jquery::tabview_generate($tabs, $active_tab);
$audience['cancel_link'] =
self::link(array('menuaction' => 'booking.uiaudience.index'));
- self::render_template_xsl('audience_edit',
array('audience' => $audience));
+ phpgwapi_jquery::formvalidator_generate(array());
+
+ self::render_template_xsl('audience_edit',
array('audience' => $audience, 'activities' => $activities));
}
public function show()
Modified: branches/dev-syncromind/booking/inc/class.uireports.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uireports.inc.php 2015-10-20
10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/inc/class.uireports.inc.php 2015-10-20
10:44:26 UTC (rev 14218)
@@ -178,13 +178,11 @@
$report['resources_json'] =
json_encode(array_map('intval', $report['resources']));
$report['cancel_link'] =
self::link(array('menuaction' => 'booking.uireports.index'));
array_set_default($report, 'cost', '0');
- $activities =
$this->activity_bo->fetch_activities();
- $activities =
$activities['results'];
+ $activities =
$this->activity_bo->get_top_level();
// $agegroups =
$this->agegroup_bo->fetch_age_groups();
// $agegroups =
$agegroups['results'];
// $audience =
$this->audience_bo->fetch_target_audience();
// $audience =
$audience['results'];
-
$report['days'] = array(
array('id' => 1, 'name' => lang('Monday')),
array('id' => 2, 'name' => lang('Tuesday')),
Modified: branches/dev-syncromind/booking/js/booking/application.js
===================================================================
--- branches/dev-syncromind/booking/js/booking/application.js 2015-10-20
10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/js/booking/application.js 2015-10-20
10:44:26 UTC (rev 14218)
@@ -4,6 +4,53 @@
$(document).ready(function() {
JqueryPortico.autocompleteHelper('index.php?menuaction=bookingfrontend.uibuilding.index&phpgw_return_as=json&',
'field_building_name',
'field_building_id', 'building_container');
+
+ $("#field_activity").change(function(){
+ var oArgs =
{menuaction:'bookingfrontend.uiapplication.get_activity_data',
activity_id:$(this).val()};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function(data) {
+ var html_agegroups = '';
+ var html_audience = '';
+
+ if( data != null)
+ {
+ var agegroups = data.agegroups;
+ for ( var i = 0; i < agegroups.length;
++i )
+ {
+ html_agegroups += "<tr>";
+ html_agegroups += "<th>" + agegroups[i]['name'] +
"</th>";
+ html_agegroups += "<td>";
+ html_agegroups += "<input class=\"input50\"
type=\"text\" name='male[" +agegroups[i]['id'] + "]' value='0'></input>";
+ html_agegroups += "</td>";
+ html_agegroups += "<td>";
+ html_agegroups += "<input
class=\"input50\" type=\"text\" name='female[" +agegroups[i]['id'] + "]'
value='0'></input>";
+ html_agegroups += "</td>";
+ html_agegroups += "</tr>";
+ }
+ $("#agegroup_tbody").html(
html_agegroups );
+
+ var audience = data.audience;
+ for ( var i = 0; i < audience.length;
++i )
+ {
+ html_audience += "<li>";
+ html_audience += "<label>";
+ html_audience += "<input
type=\"radio\" name=\"audience[]\" value='" +audience[i]['id'] + "'></input>";
+ html_audience +=
audience[i]['name'];
+ html_audience += "</label>";
+ html_audience += "</li>";
+ }
+ $("#audience").html( html_audience );
+
+ }
+ }
+ });
+ });
+
});
$(window).load(function(){
Modified: branches/dev-syncromind/booking/setup/setup.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/setup.inc.php 2015-10-20 10:42:54 UTC
(rev 14217)
+++ branches/dev-syncromind/booking/setup/setup.inc.php 2015-10-20 10:44:26 UTC
(rev 14218)
@@ -1,6 +1,6 @@
<?php
$setup_info['booking']['name'] = 'booking';
- $setup_info['booking']['version'] = '0.2.21';
+ $setup_info['booking']['version'] = '0.2.22';
$setup_info['booking']['app_order'] = 9;
$setup_info['booking']['enable'] = 1;
$setup_info['booking']['app_group'] = 'office';
Modified: branches/dev-syncromind/booking/setup/tables_current.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/tables_current.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/setup/tables_current.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -49,9 +49,10 @@
'bb_targetaudience' => array(
'fd' => array(
'id' => array('type' => 'auto',
'nullable' => False),
+ 'activity_id' => array('type' =>
'int','precision' => '4','nullable' => false),
'name' => array('type' => 'text',
'nullable' => False),
'sort' => array('type' =>
'int','precision' => '4', 'nullable' => False, 'default'=> 0),
- 'description' => array('type' =>
'text', 'nullable' => False),
+ 'description' => array('type' =>
'text', 'nullable' => true),
'active' => array('type' =>
'int','precision' => '4', 'nullable' => False, 'default' => 1),
),
'pk' => array('id'),
@@ -384,9 +385,10 @@
'bb_agegroup' => array(
'fd' => array(
'id' => array('type' => 'auto', 'nullable' =>
False),
+ 'activity_id' => array('type' =>
'int','precision' => '4','nullable' => false),
'name' => array('type' => 'text', 'nullable' =>
False),
'sort' => array('type' => 'int','precision' =>
'4', 'nullable' => False, 'default'=> 0),
- 'description' => array('type' => 'text',
'nullable' => False),
+ 'description' => array('type' => 'text',
'nullable' => true),
'active' => array('type' => 'int','precision'
=> '4', 'nullable' => False, 'default' => 1),
),
'pk' => array('id'),
@@ -426,6 +428,8 @@
'agegroup_id' => array('type' =>
'int','precision' => '4', 'nullable' => False),
'male' => array('type' => 'int','precision' =>
'4', 'nullable' => False),
'female' => array('type' => 'int','precision'
=> '4', 'nullable' => False),
+ 'male_actual' => array('type' =>
'int','precision' => '4', 'nullable' => true),
+ 'female_actual' => array('type' =>
'int','precision' => '4', 'nullable' => true),
),
'pk' => array('booking_id', 'agegroup_id'),
'fk' => array(
@@ -590,6 +594,8 @@
'agegroup_id' => array('type' =>
'int','precision' => '4', 'nullable' => False),
'male' => array('type' => 'int','precision' =>
'4', 'nullable' => False),
'female' => array('type' => 'int','precision'
=> '4', 'nullable' => False),
+ 'male_actual' => array('type' =>
'int','precision' => '4', 'nullable' => true),
+ 'female_actual' => array('type' =>
'int','precision' => '4', 'nullable' => true),
),
'pk' => array('event_id', 'agegroup_id'),
'fk' => array(
Modified: branches/dev-syncromind/booking/setup/tables_update.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/tables_update.inc.php 2015-10-20
10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/setup/tables_update.inc.php 2015-10-20
10:44:26 UTC (rev 14218)
@@ -3059,3 +3059,199 @@
return $GLOBALS['setup_info']['booking']['currentver'];
}
}
+
+ $test[] = '0.2.21';
+ /**
+ * Update booking version from 0.2.21 to 0.2.22
+ *
+ */
+ function booking_upgrade0_2_21()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_agegroup','activity_id',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_targetaudience','activity_id',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('bb_agegroup','description',
array('type' => 'text', 'nullable' => true));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('bb_targetaudience','description',
array('type' => 'text', 'nullable' => true));
+
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT id FROM
bb_activity WHERE parent_id IS NULL");
+
+ $activities = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $activities[] = $GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM
bb_agegroup ORDER BY id");
+
+ $agegroups = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $agegroups[] = array(
+ 'old_id' =>
$GLOBALS['phpgw_setup']->oProc->f('id'),
+ 'name' =>
$GLOBALS['phpgw_setup']->oProc->f('name'),
+ 'description' =>
$GLOBALS['phpgw_setup']->oProc->f('description'),
+ 'active' =>
$GLOBALS['phpgw_setup']->oProc->f('active'),
+ 'sort' =>
$GLOBALS['phpgw_setup']->oProc->f('sort')
+ );
+ }
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM
bb_targetaudience ORDER BY id");
+
+ $targets = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $targets[] = array(
+ 'old_id' =>
$GLOBALS['phpgw_setup']->oProc->f('id'),
+ 'name' =>
$GLOBALS['phpgw_setup']->oProc->f('name'),
+ 'description' =>
$GLOBALS['phpgw_setup']->oProc->f('description'),
+ 'active' =>
$GLOBALS['phpgw_setup']->oProc->f('active'),
+ 'sort' =>
$GLOBALS['phpgw_setup']->oProc->f('sort')
+ );
+ }
+
+ $first_run = true;
+ foreach($activities as $activity_id)
+ {
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT id FROM
bb_activity WHERE parent_id = $activity_id");
+
+ $sub_activities = array($activity_id);
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $sub_activities[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($first_run)
+ {
+ $GLOBALS['phpgw_setup']->oProc->query("UPDATE
bb_agegroup SET activity_id = {$activity_id}");
+ $GLOBALS['phpgw_setup']->oProc->query("UPDATE
bb_targetaudience SET activity_id = {$activity_id}");
+ $first_run = false;
+ }
+ else
+ {
+ foreach($agegroups as &$agegroup)
+ {
+ $old_id = $agegroup['old_id'];
+ $insert_values = $agegroup;
+ unset($insert_values['old_id']);
+ $insert_values['activity_id'] =
$activity_id;
+ $cols = implode(',',
array_keys($insert_values));
+ $values =
$GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($insert_values));
+ $sql = "INSERT INTO bb_agegroup
({$cols}) VALUES ({$values})";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $new_id =
$GLOBALS['phpgw_setup']->oProc->get_last_insert_id('bb_agegroup');
+//bb_application_agegroup
+ $sql = "SELECT id FROM bb_application
WHERE activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $applications = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $applications[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($applications)
+ {
+ $sql = "UPDATE
bb_application_agegroup SET agegroup_id = $new_id WHERE agegroup_id = $old_id
AND application_id IN (" . implode(',', $applications) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+//bb_booking_agegroup
+ $sql = "SELECT id FROM bb_booking WHERE
activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $bookings = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $bookings[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($bookings)
+ {
+ $sql = "UPDATE
bb_booking_agegroup SET agegroup_id = $new_id WHERE agegroup_id = $old_id AND
booking_id IN (" . implode(',', $bookings) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+//bb_event_agegroup
+ $sql = "SELECT id FROM bb_event WHERE
activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $events = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $events[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($events)
+ {
+ $sql = "UPDATE
bb_event_agegroup SET agegroup_id = $new_id WHERE agegroup_id = $old_id AND
event_id IN (" . implode(',', $events) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+ }
+ foreach($targets as &$target)
+ {
+ $old_id = $target['old_id'];
+ $insert_values = $target;
+ unset($insert_values['old_id']);
+ $insert_values['activity_id'] =
$activity_id;
+ $cols = implode(',',
array_keys($insert_values));
+ $values =
$GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($insert_values));
+ $sql = "INSERT INTO bb_targetaudience
({$cols}) VALUES ({$values})";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $new_id =
$GLOBALS['phpgw_setup']->oProc->get_last_insert_id('bb_targetaudience');
+//bb_application_targetaudience
+ $sql = "SELECT id FROM bb_application
WHERE activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $applications = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $applications[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($applications)
+ {
+ $sql = "UPDATE
bb_application_targetaudience SET targetaudience_id = $new_id WHERE
targetaudience_id = $old_id AND application_id IN (" . implode(',',
$applications) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+//bb_booking_targetaudience
+ $sql = "SELECT id FROM bb_booking WHERE
activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $bookings = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $bookings[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+
+ if($bookings)
+ {
+ $sql = "UPDATE
bb_booking_targetaudience SET targetaudience_id = $new_id WHERE
targetaudience_id = $old_id AND booking_id IN (" . implode(',', $bookings) .
')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+//bb_event_targetaudience
+ $sql = "SELECT id FROM bb_event WHERE
activity_id IN (" . implode(',', $sub_activities) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ $events = array();
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $events[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+ if($events)
+ {
+ $sql = "UPDATE
bb_event_targetaudience SET targetaudience_id = $new_id WHERE targetaudience_id
= $old_id AND event_id IN (" . implode(',', $events) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+ }
+ }
+ }
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_booking_agegroup','male_actual',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_booking_agegroup','female_actual',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_event_agegroup','male_actual',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('bb_event_agegroup','female_actual',
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('bb_agegroup','activity_id',
array('type' => 'int', 'precision' => 4,'nullable' => false));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('bb_targetaudience','activity_id',
array('type' => 'int', 'precision' => 4,'nullable' => false));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['booking']['currentver'] =
'0.2.22';
+ return $GLOBALS['setup_info']['booking']['currentver'];
+ }
+ }
Modified: branches/dev-syncromind/booking/templates/base/agegroup_edit.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/agegroup_edit.xsl
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/templates/base/agegroup_edit.xsl
2015-10-20 10:44:26 UTC (rev 14218)
@@ -5,9 +5,33 @@
<div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="resource/tabs"/>
<div id="agegroup_edit" class="booking-container">
+ <div class="pure-control-group">
+ <label for="field_activity">
+ <xsl:value-of
select="php:function('lang', 'Activity')" />
+ </label>
+ <select name="activity_id"
id="field_activity">
+ <xsl:attribute
name="disabled">disabled</xsl:attribute>
+
+ <xsl:for-each
select="activities">
+ <option>
+ <xsl:if
test="selected = 1">
+
<xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute
name="value">
+
<xsl:value-of select="id"/>
+ </xsl:attribute>
+ <xsl:value-of
select="name"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </div>
+
<div class="pure-control-group">
<label for="field_name"><xsl:value-of
select="php:function('lang', 'Name')" /></label>
<input id="field_name" name="name" type="text">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
<xsl:attribute name="value"><xsl:value-of
select="resource/name"/></xsl:attribute>
</input>
</div>
Modified: branches/dev-syncromind/booking/templates/base/agegroup_new.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/agegroup_new.xsl
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/templates/base/agegroup_new.xsl
2015-10-20 10:44:26 UTC (rev 14218)
@@ -3,11 +3,46 @@
<form action="" method="POST" class="pure-form pure-form-aligned"
id="form" name="form">
<input type="hidden" name="tab" value=""/>
<div id="tab-content">
+ <xsl:variable name="lang_select_activity">
+ <xsl:value-of
select="php:function('lang', '-- select an activity --')" />
+ </xsl:variable>
+
<xsl:value-of disable-output-escaping="yes"
select="agegroup/tabs"/>
<div id="agegroup_add" class="booking-container">
- <div class="pure-control-group">
+ <div class="pure-control-group">
+ <label for="field_activity">
+ <xsl:value-of
select="php:function('lang', 'Activity')" />
+ </label>
+ <select name="activity_id"
id="field_activity">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
+ <xsl:attribute
name="data-validation-error-msg">
+ <xsl:value-of
select="$lang_select_activity" />
+ </xsl:attribute>
+
+ <option value="">
+ <xsl:value-of
select="$lang_select_activity" />
+ </option>
+ <xsl:for-each
select="activities">
+ <option>
+ <xsl:if
test="selected = 1">
+
<xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute
name="value">
+
<xsl:value-of select="id"/>
+ </xsl:attribute>
+ <xsl:value-of
select="name"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </div>
+ <div class="pure-control-group">
<label for="field_name"><xsl:value-of
select="php:function('lang', 'Name')" /></label>
<input id="field_name" name="name" type="text">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
<xsl:attribute name="value"><xsl:value-of
select="agegroup/name"/></xsl:attribute>
</input>
</div>
Modified: branches/dev-syncromind/booking/templates/base/application_new.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/application_new.xsl
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/templates/base/application_new.xsl
2015-10-20 10:44:26 UTC (rev 14218)
@@ -64,7 +64,7 @@
</th>
</tr>
</thead>
- <tbody>
+ <tbody id = "agegroup_tbody">
<xsl:for-each select="agegroups">
<xsl:variable name="id"><xsl:value-of
select="id"/></xsl:variable>
<tr>
@@ -195,11 +195,11 @@
<p><xsl:value-of
select="config/application_who"/></p>
</xsl:if>
<label><xsl:value-of select="php:function('lang',
'Target audience')" /></label>
- <ul style="list-style:none;padding-left:10px;">
+ <ul id= "audience"
style="list-style:none;padding-left:10px;">
<xsl:for-each select="audience">
<li>
<label>
- <input type="checkbox"
name="audience[]">
+ <input type="radio"
name="audience[]">
<xsl:attribute
name="value"><xsl:value-of select="id"/></xsl:attribute>
<xsl:if
test="../application/audience=id">
<xsl:attribute
name="checked">checked</xsl:attribute>
@@ -207,7 +207,7 @@
</input>
<xsl:value-of select="name"/>
</label>
- </li>
+ </li>
</xsl:for-each>
</ul>
</fieldset>
Modified: branches/dev-syncromind/booking/templates/base/audience_edit.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/audience_edit.xsl
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/templates/base/audience_edit.xsl
2015-10-20 10:44:26 UTC (rev 14218)
@@ -6,9 +6,33 @@
<xsl:value-of disable-output-escaping="yes"
select="audience/tabs"/>
<div id="audience_edit" class="booking-container">
<fieldset>
+ <div class="pure-control-group">
+ <label for="field_activity">
+ <xsl:value-of
select="php:function('lang', 'Activity')" />
+ </label>
+ <select name="activity_id"
id="field_activity">
+ <xsl:attribute
name="disabled">disabled</xsl:attribute>
+
+ <xsl:for-each
select="activities">
+ <option>
+ <xsl:if
test="selected = 1">
+
<xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute
name="value">
+
<xsl:value-of select="id"/>
+ </xsl:attribute>
+ <xsl:value-of
select="name"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </div>
+
<div class="pure-control-group">
<label for="field_name"><xsl:value-of
select="php:function('lang', 'Target audience')" /></label>
<input id="field_name" name="name" type="text">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
<xsl:attribute name="value"><xsl:value-of
select="audience/name"/></xsl:attribute>
</input>
</div>
Modified: branches/dev-syncromind/booking/templates/base/audience_new.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/audience_new.xsl
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/booking/templates/base/audience_new.xsl
2015-10-20 10:44:26 UTC (rev 14218)
@@ -2,12 +2,46 @@
<xsl:call-template name="msgbox"/>
<form action="" method="POST" class="pure-form pure-form-aligned"
id="form" name="form">
<input type="hidden" name="tab" value=""/>
- <div id="tab-content">
+ <xsl:variable name="lang_select_activity">
+ <xsl:value-of select="php:function('lang', '--
select an activity --')" />
+ </xsl:variable>
+ <div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="audience/tabs"/>
<div id="audience_add" class="booking-container">
- <div class="pure-control-group">
+ <div class="pure-control-group">
+ <label for="field_activity">
+ <xsl:value-of
select="php:function('lang', 'Activity')" />
+ </label>
+ <select name="activity_id"
id="field_activity">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
+ <xsl:attribute
name="data-validation-error-msg">
+ <xsl:value-of
select="$lang_select_activity" />
+ </xsl:attribute>
+
+ <option value="">
+ <xsl:value-of
select="$lang_select_activity" />
+ </option>
+ <xsl:for-each
select="activities">
+ <option>
+ <xsl:if
test="selected = 1">
+
<xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:attribute
name="value">
+
<xsl:value-of select="id"/>
+ </xsl:attribute>
+ <xsl:value-of
select="name"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </div>
+ <div class="pure-control-group">
<label for="field_name"><xsl:value-of
select="php:function('lang', 'Target audience')" /></label>
<input id="field_name" name="name" type="text">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
<xsl:attribute name="value"><xsl:value-of
select="audience/name"/></xsl:attribute>
</input>
</div>
Modified:
branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
2015-10-20 10:42:54 UTC (rev 14217)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
2015-10-20 10:44:26 UTC (rev 14218)
@@ -8,8 +8,14 @@
'add' => true,
'edit' => true,
'show' => true,
+ 'get_activity_data' => true
);
+ function get_activity_data()
+ {
+ return parent::get_activity_data();
+ }
+
function show()
{
$id = intval(phpgw::get_var('id', 'GET'));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14218] booking: configurable agegroups and target audiences per top level activity,
Sigurd Nes <=