[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10531] hyttebooking: update serch freetime frontend
From: |
Kjell Arne Espedal |
Subject: |
[Fmsystem-commits] [10531] hyttebooking: update serch freetime frontend & fix for rights management |
Date: |
Fri, 23 Nov 2012 08:07:09 +0000 |
Revision: 10531
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10531
Author: kjell
Date: 2012-11-23 08:07:08 +0000 (Fri, 23 Nov 2012)
Log Message:
-----------
hyttebooking: update serch freetime frontend & fix for rights management
Modified Paths:
--------------
branches/dev-thomasez/booking/inc/class.bocommon_authorized.inc.php
branches/dev-thomasez/booking/inc/class.boevent.inc.php
branches/dev-thomasez/booking/inc/class.boresource.inc.php
branches/dev-thomasez/booking/inc/class.customer_identifier.inc.php
branches/dev-thomasez/booking/inc/class.menu.inc.php
branches/dev-thomasez/booking/inc/class.soevent.inc.php
branches/dev-thomasez/booking/inc/class.somassbooking.inc.php
branches/dev-thomasez/booking/inc/class.uiallocation.inc.php
branches/dev-thomasez/booking/inc/class.uiapplication.inc.php
branches/dev-thomasez/booking/inc/class.uibuilding.inc.php
branches/dev-thomasez/booking/inc/class.uievent.inc.php
branches/dev-thomasez/booking/inc/class.uimassbooking.inc.php
branches/dev-thomasez/booking/inc/class.uireports.inc.php
branches/dev-thomasez/booking/inc/class.uiresource.inc.php
branches/dev-thomasez/booking/setup/setup.inc.php
branches/dev-thomasez/booking/setup/tables_current.inc.php
branches/dev-thomasez/booking/setup/tables_update.inc.php
branches/dev-thomasez/bookingfrontend/inc/class.bosearch.inc.php
branches/dev-thomasez/bookingfrontend/inc/class.uisearch.inc.php
branches/dev-thomasez/bookingfrontend/js/bookingfrontend/search.js
branches/dev-thomasez/bookingfrontend/setup/phpgw_no.lang
branches/dev-thomasez/bookingfrontend/setup/setup.inc.php
branches/dev-thomasez/bookingfrontend/templates/base/search.xsl
branches/dev-thomasez/bookingfrontend/templates/nsf/building.xsl
branches/dev-thomasez/phpgwapi/templates/bkbooking/css/frontend.css
branches/dev-thomasez/phpgwapi/templates/nsf/css/frontend.css
Added Paths:
-----------
branches/dev-thomasez/booking/inc/class.sopermission_event.inc.php
branches/dev-thomasez/booking/inc/class.sopermission_permission_massbooking.inc.php
Modified: branches/dev-thomasez/booking/inc/class.bocommon_authorized.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.bocommon_authorized.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.bocommon_authorized.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -399,7 +399,7 @@
}
$role_permissions =
$this->get_role_permissions($object);
-
+
$object_id = null;
if (!is_null($object))
@@ -407,7 +407,6 @@
$object_id = is_array($object) ? $object['id']
: $object;
$object = is_array($object) ? $object :
parent::read_single($object_id);
}
-
if (false != $permission =
$this->check_authorization($this->get_subject_global_roles(),
$role_permissions, $operation, $object, array('namespace' => 'global')))
{
return $permission;
@@ -674,4 +673,4 @@
$this->authorize_read($entity);
return $this->add_permission_data($entity);
}
- }
\ No newline at end of file
+ }
Modified: branches/dev-thomasez/booking/inc/class.boevent.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.boevent.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.boevent.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -1,14 +1,107 @@
<?php
- phpgw::import_class('booking.bocommon');
+ phpgw::import_class('booking.bocommon_authorized');
- class booking_boevent extends booking_bocommon
+ class booking_boevent extends booking_bocommon_authorized
{
function __construct()
{
parent::__construct();
+ $this->building_bo = CreateObject('booking.bobuilding');
$this->so = CreateObject('booking.soevent');
}
+
+ /**
+ * @see bocommon_authorized
+ */
+ protected function include_subject_parent_roles(array
$for_object = null)
+ {
+ $parent_roles = null;
+ $parent_building = null;
+
+ if (is_array($for_object))
+ {
+ if (!isset($for_object['building_id']))
+ {
+ throw new
InvalidArgumentException('Cannot initialize object parent roles unless
building_id is provided');
+ }
+
+ $parent_building =
$this->building_bo->read_single($for_object['building_id']);
+ }
+
+ //Note that a null value for $parent_building is
acceptable. That only signifies
+ //that any roles specified for any building are
returned instead of roles for a specific building.
+ $parent_roles['building'] =
$this->building_bo->get_subject_roles($parent_building);
+
+ return $parent_roles;
+ }
+ protected function get_object_role_permissions(array
$forObject, $defaultPermissions)
+ {
+ return array_merge(
+ array
+ (
+ booking_sopermission::ROLE_MANAGER =>
array(
+ 'write' => true,
+ 'create' => true,
+ ),
+ booking_sopermission::ROLE_CASE_OFFICER
=> array(
+ 'write' => true,
+ ),
+ 'parent_role_permissions' => array
+ (
+ 'building' => array
+ (
+
booking_sopermission::ROLE_MANAGER => array(
+ 'write' => true,
+ 'create' =>
true,
+ ),
+
booking_sopermission::ROLE_CASE_OFFICER => array(
+ 'write' => true,
+ ),
+ ),
+ ),
+ 'global' => array
+ (
+
booking_sopermission::ROLE_MANAGER => array(
+ 'read' => true,
+ 'write' => true,
+ 'create' => true,
+ 'delete' => true,
+ ),
+ )
+ ),
+ $defaultPermissions
+ );
+ }
+
+ protected function
get_collection_role_permissions($defaultPermissions)
+ {
+ return array_merge(
+ array(
+ booking_sopermission::ROLE_MANAGER =>
array(
+ 'write' => true,
+ 'create' => true,
+ ),
+ 'parent_role_permissions' => array
+ (
+ 'building' => array(
+
booking_sopermission::ROLE_MANAGER => array(
+ 'create' =>
true,
+ ),
+ ),
+ ),
+ 'global' => array
+ (
+
booking_sopermission::ROLE_MANAGER => array
+ (
+ 'create' => true,
+ ),
+ ),
+ ),
+ $defaultPermissions
+ );
+ }
+
public function complete_expired(&$events) {
$this->so->complete_expired($events);
}
Modified: branches/dev-thomasez/booking/inc/class.boresource.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.boresource.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.boresource.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -58,12 +58,17 @@
),
booking_sopermission::ROLE_CASE_OFFICER
=> array
(
+// 'write' => true,
'write' =>
array_fill_keys(array('name', 'description', 'activity_id',
'type','internal_cost','external_cost','cost_type','campsites','bedspaces','heating','kitchen','water','location','communication','usage_time','swiming','sanitation_facilities','animals','internett_phone','handicap','keywords'),
true),
),
'parent_role_permissions' => array
(
'building' => array
(
+
booking_sopermission::ROLE_CASE_OFFICER => array
+ (
+ 'write' => true,
+ ),
booking_sopermission::ROLE_MANAGER => array(
'write' => true,
'create' =>
true,
@@ -115,9 +120,14 @@
public function populate_grid_data($menuaction)
{
+ $frontend = explode(".",$menuaction);
+ $frontend = $frontend[0];
$resources = $this->read();
+ $tlist = array();
foreach($resources['results'] as &$resource)
{
+ $myres = $this->read_single($resource['id']);
+
$resource['link'] =
$this->link(array('menuaction' => $menuaction, 'id' => $resource['id']));
$resource['type'] =
lang($resource['type']);
$resource['full_name'] =
$resource['building_name'] . ' / ' . $resource['name'];
@@ -126,14 +136,18 @@
{
$resource['cost_type'] =
lang($resource['cost_type']);
}
- }
+ if(isset($myres['permission']['write']) ||
$frontend == "bookingfrontend") {
+ $tlist[] = $resource;
+ }
+
+ }
$data = array(
'ResultSet' => array(
- 'totalResultsAvailable' =>
$resources['total_records'],
+ 'totalResultsAvailable' =>
count($tlist),
'startIndex' => $resources['start'],
'sortKey' => $resources['sort'],
'sortDir' => $resources['dir'],
- 'Result' => $resources['results']
+ 'Result' => $tlist
)
);
return $data;
Modified: branches/dev-thomasez/booking/inc/class.customer_identifier.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.customer_identifier.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.customer_identifier.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -160,9 +160,7 @@
if (all_cust_fields[field_type] ==
undefined) { return; }
Dom.setStyle(all_cust_fields[field_type], 'display', 'block');
- if (all_cust_fields[field_type].name ==
'customer_ssn') {
-
all_cust_fields[field_type].value = '6 siffer (DDMMÅÅ) eller 11 siffer';
- } else if
(all_cust_fields[field_type].name == 'customer_organization_number') {
+ if (all_cust_fields[field_type].name ==
'customer_organization_number') {
all_cust_fields[field_type].value = '4 eller 6 siffer';
} else if
(all_cust_fields[field_type].name == 'customer_address') {
YAHOO.util.Dom.get('field_customer_street').value = 'Street';
Modified: branches/dev-thomasez/booking/inc/class.menu.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.menu.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.menu.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -207,12 +207,12 @@
'url' => $GLOBALS['phpgw']->link('/index.php',
array('menuaction'=> 'booking.uireports.participants') ),
'image' =>
array('property', 'report'),
),
- 'free_time' => array
- (
- 'text' => lang('Free time'),
- 'url' => $GLOBALS['phpgw']->link('/index.php',
array('menuaction'=> 'booking.uireports.freetime') ),
- 'image' =>
array('property', 'report'),
- ),
+# 'free_time' => array
+# (
+# 'text' => lang('Free time'),
+# 'url' => $GLOBALS['phpgw']->link('/index.php',
array('menuaction'=> 'booking.uireports.freetime') ),
+# 'image' =>
array('property', 'report'),
+# ),
'search_terms' => array
(
'text' => lang('Search terms'),
Modified: branches/dev-thomasez/booking/inc/class.soevent.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.soevent.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.soevent.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -13,7 +13,8 @@
'activity_id' => array('type' =>
'int', 'required' => true),
'application_id' => array('type'
=> 'int', 'required' => false),
'description' => array('type' =>
'string', 'required'=> true, 'query' => true),
- 'building_name' => array('type' =>
'string', 'required'=> true, 'query' => true),
+ 'building_id' => array('type' =>
'int', 'required' => true),
+ 'building_name' => array('type' =>
'string', 'query' => true),
'from_' => array('type' =>
'string', 'required'=> true),
'to_' => array('type' =>
'string', 'required'=> true),
'cost' => array('type' =>
'decimal', 'required' => true),
@@ -32,7 +33,7 @@
'customer_organization_name' =>
array('type' => 'string', 'required' => False, 'query' => true),
'customer_organization_id'
=> array('type' => 'int', 'required' => False),
'customer_identifier_type'
=> array('type' => 'string', 'required' => False),
- 'customer_ssn'
=> array('type' => 'string', 'sf_validator' =>
createObject('booking.sfValidatorNorwegianSSN'), 'required' => false),
+ 'customer_ssn'
=> array('type' => 'string', 'required' => false),
'customer_organization_number' =>
array('type' => 'string', 'sf_validator' =>
createObject('booking.sfValidatorNorwegianOrganizationNumber', array(),
array('invalid' => '%field% is invalid'))),
'customer_internal'
=> array('type' => 'int', 'required'=>true),
'activity_name' => array('type' =>
'string',
Modified: branches/dev-thomasez/booking/inc/class.somassbooking.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.somassbooking.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.somassbooking.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -22,5 +22,15 @@
)
);
}
+ function get_permission($userid,$buildingid)
+ {
+ $sql = "select role from bb_permission where
subject_id=".$userid." and object_id=".$buildingid.";";
+ $this->db->query($sql);
+ while ($this->db->next_record())
+ {
+ $results[] = $this->db->f('role', false);
+ }
+ return $results;
+ }
}
Added: branches/dev-thomasez/booking/inc/class.sopermission_event.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.sopermission_event.inc.php
(rev 0)
+++ branches/dev-thomasez/booking/inc/class.sopermission_event.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -0,0 +1,13 @@
+<?php
+ phpgw::import_class('booking.sopermission');
+
+ class booking_sopermission_event extends booking_sopermission
+ {
+ /**
+ * @see booking_sopermission
+ */
+ protected function build_object_relations()
+ {
+ return array();
+ }
+ }
Added:
branches/dev-thomasez/booking/inc/class.sopermission_permission_massbooking.inc.php
===================================================================
---
branches/dev-thomasez/booking/inc/class.sopermission_permission_massbooking.inc.php
(rev 0)
+++
branches/dev-thomasez/booking/inc/class.sopermission_permission_massbooking.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -0,0 +1,6 @@
+<?php
+ phpgw::import_class('booking.sopermission_permission');
+
+ class booking_sopermission_permission_massbooking extends
booking_sopermission_permission
+ {
+ }
Modified: branches/dev-thomasez/booking/inc/class.uiallocation.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uiallocation.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uiallocation.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -416,7 +416,6 @@
if ($_POST['recurring'] != 'on' &&
$_POST['outseason'] != 'on' )
{
-
echo"<pre>single:";print_r($step);echo"\n";print_r($from_date);echo"\n";print_r($allocation);exit;
$err = $this->bo->so->check_for_booking($id);
if ($err)
{
Modified: branches/dev-thomasez/booking/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uiapplication.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uiapplication.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -194,11 +194,6 @@
'name' =>
'search',
'value' =>
lang('Search')
),
- array(
- 'type' =>
'link',
- 'value' =>
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
- 'href' =>
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
- ),
),
),
),
@@ -244,7 +239,15 @@
)
)
),
+
);
+ if
(booking_account_helper::current_account_member_of_admins()) {
+ array_push($data['form']['toolbar']['item'],
array(
+ 'type' =>
'link',
+ 'value' =>
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
+ 'href' =>
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
+ ));
+ }
self::render_template('datatable', $data);
}
Modified: branches/dev-thomasez/booking/inc/class.uibuilding.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uibuilding.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uibuilding.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -144,12 +144,26 @@
{
$buildings = $this->bo->read();
+ $list = array();
+ $tlist = array();
foreach($buildings['results'] as &$building)
{
+ $mybuilding =
$this->bo->read_single($building['id']);
+
$building['district']
=lang($building['district']);
$building['link'] =
$this->link(array('menuaction' => 'booking.uibuilding.show', 'id' =>
$building['id']));
$building['active'] = $building['active'] ?
lang('Active') : lang('Inactive');
+
+ if(isset($mybuilding['permission']['write'])) {
+ $tlist[] = $building;
+ }
}
+ $list['total_records'] = count($tlist);
+ $list['results'] = $tlist;
+ $list['start'] = $buildings['start'];
+ $list['sort'] = $buildings['sort'];
+ $list['dir'] = $buildings['dir'];
+ $buildings = $list;
return $this->yui_results($buildings);
}
@@ -241,6 +255,7 @@
{
$building['homepage'] =
'http://'.$building['homepage'];
}
+
self::render_template('building', array('building' =>
$building));
}
Modified: branches/dev-thomasez/booking/inc/class.uievent.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uievent.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uievent.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -149,13 +149,20 @@
'dir' => phpgw::get_var('dir'),
'filters' => $filters
);
- $events = $this->bo->so->read($params);
-
+ $events = $this->bo->read($params);
+ $list = array();
foreach($events['results'] as &$event)
{
+ $myperm = $this->bo->read_single($event['id']);
+
$event['from_'] =
pretty_timestamp($event['from_']);
$event['to_'] = pretty_timestamp($event['to_']);
+ if(isset($myperm['permission']['write'])) {
+ $list[] = $event;
+ }
}
+ $events['results']= $list;
+ $events['total_records'] = count($tlist);
array_walk($events["results"], array($this,
"_add_links"), "booking.uievent.edit");
return $this->yui_results($events);
@@ -507,7 +514,7 @@
if ($organization['customer_internal']
== 0) {
$event['customer_identifier_type'] = $organization['customer_identifier_type'];
$event['customer_internal'] =
$organization['customer_internal'];
- if
(strlen($organization['customer_organization_number']) == 9) {
+ if
((strlen($organization['customer_organization_number']) == 4) ||
(strlen($organization['customer_organization_number']) == 6)) {
$event['customer_organization_number'] =
$organization['customer_organization_number'];
} else {
$errors['organization_number'] = lang('The organization number is wrong or not
present');
@@ -515,7 +522,7 @@
} else {
$event['customer_identifier_type'] = 'organization_number';
$event['customer_internal'] =
$organization['customer_internal'];
- if
(strlen($organization['customer_number']) == 5) {
+ if
((strlen($organization['customer_organization_number']) == 4) ||
(strlen($organization['customer_organization_number']) == 6)) {
$event['customer_organization_number'] = $organization['customer_number'];
} else {
$errors['resource_number'] = lang('The resource number is wrong or not
present');
@@ -533,9 +540,10 @@
if ($_POST['cost'] != 0 and
!$event['customer_organization_number'] and !$event['customer_ssn']) {
$errors['invoice_data'] = lang('There
is set a cost, but no invoice data is filled inn');
}
-
if(!$errors['event'] and
!$errors['resource_number'] and !$errors['organization_number'] and
!$errors['invoice_data'] && !$errors['contact_name'] && !$errors['cost'])
{
+ try {
+ $receipt = $this->bo->update($event);
if (phpgw::get_var('mail', 'POST') ||
phpgw::get_var('sendtorbuilding', 'POST'))
{
if(phpgw::get_var('sendtocollision', 'POST') || phpgw::get_var('sendtocontact',
'POST') || phpgw::get_var('sendtorbuilding', 'POST'))
@@ -630,8 +638,10 @@
$this->send_mailnotification($event['contact_email'], lang('Event changed'),
phpgw::get_var('mail', 'POST'));
}
}
- $receipt = $this->bo->update($event);
$this->redirect(array('menuaction' =>
'booking.uievent.edit', 'id'=>$event['id']));
+ } catch (booking_unauthorized_exception
$e) {
+ $errors['global'] = lang('Could
not update object due to insufficient permissions');
+ }
}
}
Modified: branches/dev-thomasez/booking/inc/class.uimassbooking.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uimassbooking.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uimassbooking.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -24,6 +24,7 @@
$this->bo = CreateObject('booking.bomassbooking');
+ $this->so = CreateObject('booking.somassbooking');
self::set_active_menu('booking::applications::massboooking');
}
@@ -93,13 +94,24 @@
public function index_json()
{
-
- $buildings = $this->bo->read();
+
+ $buildings = $this->bo->read();
+ $userid = $this->current_account_id();
+ $admin =
booking_account_helper::current_account_member_of_admins();
+ $list = array();
foreach($buildings['results'] as &$building)
{
+ $myperm =
$this->so->get_permission($userid,$building['id']);
+
$building['link'] =
$this->link(array('menuaction' => 'booking.uimassbooking.schedule', 'id' =>
$building['id']));
$building['active'] = $building['active'] ?
lang('Active') : lang('Inactive');
+ if(isset($myperm)||$admin) {
+ $list[] = $building;
+ }
}
+ $buildings['results'] = $list;
+ $buildings['total_records'] = count($list);
+
return $this->yui_results($buildings);
}
Modified: branches/dev-thomasez/booking/inc/class.uireports.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uireports.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uireports.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -9,6 +9,7 @@
'index' => true,
'participants' => true,
'freetime' => true,
+ 'freetime2' => true,
'searchterms' => true,
);
@@ -17,6 +18,7 @@
parent::__construct();
$this->building_bo = CreateObject('booking.bobuilding');
+ $this->resource_bo = CreateObject('booking.boresource');
self::set_active_menu('booking::reportcenter');
}
@@ -24,6 +26,7 @@
{
$reports[] = array('name' => lang('Participants Per Age Group
Per Month'), 'url' => self::link(array('menuaction' =>
'booking.uireports.participants')));
$reports[] = array('name' => lang('Free time'), 'url' =>
self::link(array('menuaction' => 'booking.uireports.freetime')));
+ $reports[] = array('name' => lang('Free time2'), 'url' =>
self::link(array('menuaction' => 'booking.uireports.freetime2')));
$reports[] = array('name' => lang('Search terns'), 'url' =>
self::link(array('menuaction' => 'booking.uireports.searchterms')));
self::render_template('report_index',
@@ -138,6 +141,100 @@
array('show' => $show, 'from' => $from, 'to' =>
$to, 'buildings' => $buildings['results'], 'allocations' =>
$allocations['results']));
}
+ public function freetime2()
+ {
+ self::set_active_menu('booking::reportcenter::free_time2');
+ $errors = array();
+ $buildings = $this->getResourceTypes();
+ $show = '';
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST')
+ {
+ $show = 'report';
+
+
+ $days = phpgw::get_var('days', 'POST');
+ $from = phpgw::get_var('from', 'POST');
+
+ $date = new DateTime($from);
+ date_add($date,
date_interval_create_from_date_string($days.' days'));
+ $to = date_format($date, 'Y-m-d');
+
+ $resources = $this->get_free_time(
+ phpgw::get_var('building', 'POST'),
+ $from,
+ $to,
+ $days
+ );
+
+ $counter = 0;
+
+ foreach($resources['results'] as &$resource)
+ {
+ $temp = array();
+ $resource['from_'] = $from." 14:00:00";
+ $resource['to_'] = $to." 14:00:00";
+ $resource['building_id'] =
$resource['building_id'];
+ $resource['building_name'] =
$this->getBuildingName($resource['building_id']);
+ $resource['resources'] = array($resource['id']);
+ $resource['resource_name'] = $resource['name'];
+ $temp[] = array('from_', array($from."
14:00:00"));
+ $temp[] = array('to_', array($to." 14:00:00"));
+ $temp[] = array('building_id',
$resource['building_id']);
+ $temp[] = array('building_name',
$resource['building_name']);
+ $temp[] = array('resources[]',
array($resource['id']));
+ $temp[] = array('reminder', 0);
+ $temp[] = array('from_report', true); //
indicate that no error messages should be shown
+ $resource['counter'] = $counter;
+ $resource['event_params'] = json_encode($temp);
+ $counter++;
+ }
+
+
+ if (count($resources['results']) == 0)
+ {
+ $show = 'gui';
+ $errors[] = lang('no records found.');
+ $to = phpgw::get_var('to', 'POST');
+ $from = phpgw::get_var('from', 'POST');
+ }
+ }
+ else
+ {
+
+ $to = date("Y-m-d", time());
+ $from = date("Y-m-d", time());
+ $show = 'gui';
+ }
+
+ $this->flash_form_errors($errors);
+
+ self::render_template('report_freetime2',
+ array('show' => $show, 'from' => $from, 'to' =>
$to, 'buildings' => $buildings, 'allocations' => $resources['results']));
+ }
+
+ private function getBuildingName($id) {
+
+ $db = & $GLOBALS['phpgw']->db;
+ $sql = "select name from bb_building where id=".$id."";
+ $db->query($sql);
+ if(!$db->next_record())
+ {
+ return False;
+ }
+ return $db->f('name', false);
+ }
+
+ private function getResourceTypes() {
+
+ $db = & $GLOBALS['phpgw']->db;
+ $sql = "select distinct type from bb_resource group by type";
+ $db->query($sql);
+
+ return $db->resultSet;
+
+ }
+
// Merge similar terms from different months. Used when displaying
search counters from several months and/or years.
private function mergeSimilarTerms( $terms ) {
$newTerms = array();
@@ -198,6 +295,52 @@
) );
}
+ private function get_free_time($restype, $from, $to, $days)
+ {
+ $db = & $GLOBALS['phpgw']->db;
+
+ foreach( $restype as $key => $value ) {
+ $restype[$key] = "'" . $value . "'";
+ }
+ $restype = implode(",", $restype);
+
+ $sql2 = "SELECT br.id FROM bb_event be, bb_event_resource ber,
bb_resource br
+ WHERE ('$from 14:00:00'
+ BETWEEN be.from_ AND be.to_ OR '$to 14:00:00'
+ BETWEEN be.from_ AND be.to_
+ OR ('$from 14:00:00' < be.from_
+ AND '$to 14:00:00' > be.to_))";
+
+ if ($restype)
+ $sql2 .= " AND br.type in (".$restype.") ";
+
+ $sql .= " AND be.id = ber.event_id AND ber.resource_id = br.id";
+
+
+ $sql = "SELECT * FROM bb_resource br1
+ WHERE br1.id
+ NOT IN ($sql2)";
+
+ if ($restype)
+ $sql .= " AND br1.type IN (".$restype.") ";
+
+
+ $sql .= " ORDER BY br1.type, br1.name";
+
+ $db->query($sql);
+ $result = $db->resultSet;
+
+
+ $retval = array();
+ $retval['total_records'] = count($result);
+ $retval['results'] = $result;
+ $retval['start'] = 0;
+ $retval['sort'] = null;
+ $retval['dir'] = 'asc';
+
+ return $retval;
+
+ }
private function get_free_allocations($buildings, $from, $to, $weekdays)
{
$db = & $GLOBALS['phpgw']->db;
Modified: branches/dev-thomasez/booking/inc/class.uiresource.inc.php
===================================================================
--- branches/dev-thomasez/booking/inc/class.uiresource.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/inc/class.uiresource.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -221,7 +221,6 @@
$data = array(
'resource' => $resource
);
-
self::render_template('resource', $data);
}
Modified: branches/dev-thomasez/booking/setup/setup.inc.php
===================================================================
--- branches/dev-thomasez/booking/setup/setup.inc.php 2012-11-22 14:24:07 UTC
(rev 10530)
+++ branches/dev-thomasez/booking/setup/setup.inc.php 2012-11-23 08:07:08 UTC
(rev 10531)
@@ -1,5 +1,5 @@
<?php
- $setup_info['booking']['version'] = '0.2.15';
+ $setup_info['booking']['version'] = '0.2.16';
$setup_info['booking']['name'] = 'booking';
$setup_info['booking']['app_order'] = 9;
$setup_info['booking']['enable'] = 1;
Modified: branches/dev-thomasez/booking/setup/tables_current.inc.php
===================================================================
--- branches/dev-thomasez/booking/setup/tables_current.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/setup/tables_current.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -572,6 +572,7 @@
'to_' => array('type' => 'timestamp','nullable'
=> False),
'cost' => array('type' => 'decimal',
'precision' => 10, 'scale' => 2,'nullable' => True,'default' => '0.0'),
'building_name' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
+ 'building_id' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'contact_name' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
'contact_email' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
'contact_phone' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
Modified: branches/dev-thomasez/booking/setup/tables_update.inc.php
===================================================================
--- branches/dev-thomasez/booking/setup/tables_update.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/booking/setup/tables_update.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -2784,3 +2784,16 @@
}
}
+ $test[] = '0.2.15';
+ function booking_upgrade0_2_15()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+ $GLOBALS['phpgw_setup']->oProc->m_odb->query("ALTER TABLE
bb_event ADD COLUMN building_id int DEFAULT NULL");
+ $GLOBALS['phpgw_setup']->oProc->m_odb->query("UPDATE bb_event
SET building_id = br2.building_id FROM bb_resource br2 WHERE EXISTS (SELECT 1
FROM bb_event be, bb_event_resource ber, bb_resource br WHERE be.id =
ber.event_id AND ber.resource_id = br.id AND br2.id = br.id AND
bb_event.id=be.id )");
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['booking']['currentver'] =
'0.2.16';
+ return $GLOBALS['setup_info']['booking']['currentver'];
+ }
+ }
+
Modified: branches/dev-thomasez/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-thomasez/bookingfrontend/inc/class.bosearch.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/inc/class.bosearch.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -11,12 +11,176 @@
$this->soorganization =
CreateObject('booking.soorganization');
$this->soresource = CreateObject('booking.soresource');
}
+
+ private function get_free_time($restype, $from, $to, $wclause)
+ {
+
+ $db = & $GLOBALS['phpgw']->db;
+
+
+ foreach( $restype as $key => $value ) {
+ $restype[$key] = "'" . $value . "'";
+ }
+ $restype = implode(",", $restype);
+
+
+ $sql2 = "SELECT br.id FROM bb_event be,
bb_event_resource ber, bb_resource br
+ WHERE ('$from 14:00:00'
+ BETWEEN be.from_ AND be.to_ OR '$to
14:00:00'
+ BETWEEN be.from_ AND be.to_
+ OR ('$from 14:00:00' < be.from_
+ AND '$to 14:00:00' > be.to_))";
+
+ if ($restype)
+ $sql2 .= " AND br.type in (".$restype.") ";
+
+ $sql2 .= " AND be.id = ber.event_id AND ber.resource_id
= br.id";
+
+
+ $sql = "SELECT br1.*,bu.name as
building_name,bu.district FROM bb_resource br1, bb_building bu
+ WHERE br1.id
+ NOT IN ($sql2) AND br1.building_id =
bu.id";
+
+ if ($restype)
+ $sql .= " AND br1.type IN (".$restype.") ";
+
+ $sql .= " AND ".$wclause;
+
+ $sql .= " ORDER BY br1.type, br1.name";
+
+ $db->query($sql);
+ $result = $db->resultSet;
+
+ $retval = array();
+ $retval['total_records'] = count($result);
+ $retval['results'] = $result;
+ $retval['start'] = 0;
+ $retval['sort'] = null;
+ $retval['dir'] = 'asc';
+
+ return $retval;
+ }
+
function search($searchterm,$resource)
{
+
+
$type = phpgw::get_var('type', 'GET');
$bui_result = $org_result = $res_result = array();
+ if($resource['from_']) {
+ if ($resource['region'] == 'east') {
+ $regions =
"('akerhus','oslo','ostfold','vestfold','hedemark','oppland','buskerud','telemark')";
+ }
+ elseif ($resource['region'] == 'south') {
+ $regions = "('vestagder','austagder')";
+ }
+ elseif ($resource['region'] == 'west') {
+ $regions =
"('rogaland','hordaland','sognogfjordane','moreogromsdal')";
+ }
+ elseif ($resource['region'] == 'middle') {
+ $regions =
"('nordtrodelag','sortrondelag')";
+ }
+ elseif ($resource['region'] == 'north') {
+ $regions =
"('finnmark','nordland','troms')";
+ } else {
+ $regions = '';
+ }
+ if( $resource['fylke'] != '') {
+ $fylke = $resource['fylke'];
+ } else {
+ $fylke = '';
+ }
+ if ($resource['res'] != ''){
+ $ressurs = $resource['res'];
+
if(in_array($ressurs,array('House','Boat','Location'))) {
+ if ($resource['beds']=='one') {
+ $sengeplasser =
'(br1.bedspaces >= 1 and br1.bedspaces <= 10)';
+ }
+ elseif
($resource['beds']=='two') {
+ $sengeplasser =
'br1.bedspaces >= 10 AND br1.bedspaces <= 25';
+ }
+ elseif
($resource['beds']=='three') {
+ $sengeplasser =
'br1.bedspaces >= 25 AND br1.bedspaces <= 50';
+ }
+ elseif
($resource['beds']=='four') {
+ $sengeplasser =
'br1.bedspaces >= 50 AND br1.bedspaces <= 100';
+ }
+ elseif
($resource['beds']=='five') {
+ $sengeplasser =
'br1.bedspaces >= 100 AND br1.bedspaces <= 300';
+ }
+ elseif
($resource['beds']=='six') {
+ $sengeplasser =
'br1.bedspaces >= 300';
+ }
+ $teltplasser = '';
+ }
elseif(in_array($ressurs,array('Campsite'))) {
+ if ($resource['campsite'] !=
'') {
+ $teltplasser =
'br1.campsites > '.$resource['campsite'];
+ $sengeplasser = '';
+ } else {
+ $teltplasser = '';
+ $sengeplasser = '';
+ }
+ } else {
+ $teltplasser = '';
+ $sengeplasser = '';
+ }
+ } else {
+ $ressurs = '';
+ $teltplasser = '';
+ $sengeplasser = '';
+ }
+
+ $wclause = 'br1.active = 1';
+ if($regions != '') {
+ $wclause .= " AND bu.district IN
".$regions;
+ }
+ if($fylke != '') {
+ $wclause .= " AND bu.district =
'".$fylke."'";
+ }
+ if($teltplasser != '') {
+ $wclause .= ' AND '.$teltplasser;
+ }
+ if($sengeplasser != '') {
+ $wclause .= ' AND '.$sengeplasser;
+ }
+ if ($resource['res'] != '' )
+ $restype = array($resource['res']);
+ else
+ $restype = array();
+
+ $resources = $this->get_free_time(
+ $restype,
+ $resource['from_'],
+ $resource['to_'],
+ $wclause
+ );
+
+
+ foreach($resources['results'] as &$res)
+ {
+
+ $res['name'] = $res['building_name']. ' / ' . $res['name'];
+ $res['type'] = "resource";
+ $res['schedule'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uiresource.schedule', 'id' => $res['id']));
+ $res['schedule'] = $res['schedule']."#".$resource['from_'];
+ $res['link'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uiresource.show', 'id' => $res['id']));
+ $res['img_container'] = "resource-" . $res['id'];
+ $res['img_url'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uidocument_resource.index_images', 'filter_owner_id' =>
$res['id'], 'phpgw_return_as' => 'json', 'results' => '3'));
+ }
+
+
+ $final_array = $resources;
+ $final_array['total_records_sum'] =
array_sum((array)$resources['total_records']);
+
+ // Finally increase search counter
+ $counter = new booking_searchcount();
+ $counter->increaseTerm( $searchterm );
+
+ return $final_array;
+
+ } else {
if ((!$type || $type == "building") &&
in_array($resource['res'],array('House','Location','Campsite',''))) {
@@ -126,119 +290,118 @@
# }
# }
# }
- if(!$type || $type == "resource") {
+ if(!$type || $type == "resource") {
+
+ $filters = array();
-
- $filters = array();
+ if (($resource['region'] == '' ||
$resource['region'] == 'all') && $resource['res'] == '')
+ {
+ $filters['active'] = "1";
+ $res_result =
$this->soresource->read(array("query"=>$searchterm, "filters" => $filters));
+ } else {
- if (($resource['region'] == '' ||
$resource['region'] == 'all') && $resource['res'] == '')
- {
- $filters['active'] = "1";
- $res_result =
$this->soresource->read(array("query"=>$searchterm, "filters" => $filters));
- } else {
-
-
- if ($resource['region'] == 'east') {
- $regions =
"('akerhus','oslo','ostfold','vestfold','hedemark','oppland','buskerud','telemark')";
- }
- elseif ($resource['region'] == 'south')
{
- $regions =
"('vestagder','austagder')";
- }
- elseif ($resource['region'] == 'west') {
- $regions =
"('rogaland','hordaland','sognogfjordane','moreogromsdal')";
- }
- elseif ($resource['region'] ==
'middle') {
- $regions =
"('nordtrodelag','sortrondelag')";
- }
- elseif ($resource['region'] == 'north')
{
- $regions =
"('finnmark','nordland','troms')";
- } else {
- $regions = '';
- }
- if( $resource['fylke'] != '') {
- $fylke = $resource['fylke'];
- } else {
- $fylke = '';
- }
- if ($resource['res'] != ''){
- $ressurs = $resource['res'];
-
if(in_array($ressurs,array('House','Boat','Location'))) {
- if
($resource['beds']=='one') {
- $sengeplasser =
'(br.bedspaces >= 1 and br.bedspaces <= 10)';
- }
- elseif
($resource['beds']=='two') {
- $sengeplasser =
'br.bedspaces >= 10 AND br.bedspaces <= 25';
- }
- elseif
($resource['beds']=='three') {
- $sengeplasser =
'br.bedspaces >= 25 AND br.bedspaces <= 50';
- }
- elseif
($resource['beds']=='four') {
- $sengeplasser =
'br.bedspaces >= 50 AND br.bedspaces <= 100';
- }
- elseif
($resource['beds']=='five') {
- $sengeplasser =
'br.bedspaces >= 100 AND br.bedspaces <= 300';
- }
- elseif
($resource['beds']=='six') {
- $sengeplasser =
'br.bedspaces >= 300';
- }
- $teltplasser = '';
- }
elseif(in_array($ressurs,array('Campsite'))) {
- if
($resource['campsite'] != '') {
- $teltplasser =
'br.campsites > '.$resource['campsite'];
- $sengeplasser =
'';
+ if ($resource['region'] ==
'east') {
+ $regions =
"('akerhus','oslo','ostfold','vestfold','hedemark','oppland','buskerud','telemark')";
+ }
+ elseif ($resource['region'] ==
'south') {
+ $regions =
"('vestagder','austagder')";
+ }
+ elseif ($resource['region'] ==
'west') {
+ $regions =
"('rogaland','hordaland','sognogfjordane','moreogromsdal')";
+ }
+ elseif ($resource['region'] ==
'middle') {
+ $regions =
"('nordtrodelag','sortrondelag')";
+ }
+ elseif ($resource['region'] ==
'north') {
+ $regions =
"('finnmark','nordland','troms')";
+ } else {
+ $regions = '';
+ }
+ if( $resource['fylke'] != '') {
+ $fylke =
$resource['fylke'];
+ } else {
+ $fylke = '';
+ }
+ if ($resource['res'] != ''){
+ $ressurs =
$resource['res'];
+
if(in_array($ressurs,array('House','Boat','Location'))) {
+ if
($resource['beds']=='one') {
+
$sengeplasser = '(br.bedspaces >= 1 and br.bedspaces <= 10)';
+ }
+ elseif
($resource['beds']=='two') {
+
$sengeplasser = 'br.bedspaces >= 10 AND br.bedspaces <= 25';
+ }
+ elseif
($resource['beds']=='three') {
+
$sengeplasser = 'br.bedspaces >= 25 AND br.bedspaces <= 50';
+ }
+ elseif
($resource['beds']=='four') {
+
$sengeplasser = 'br.bedspaces >= 50 AND br.bedspaces <= 100';
+ }
+ elseif
($resource['beds']=='five') {
+
$sengeplasser = 'br.bedspaces >= 100 AND br.bedspaces <= 300';
+ }
+ elseif
($resource['beds']=='six') {
+
$sengeplasser = 'br.bedspaces >= 300';
+ }
+ $teltplasser =
'';
+ }
elseif(in_array($ressurs,array('Campsite'))) {
+ if
($resource['campsite'] != '') {
+
$teltplasser = 'br.campsites > '.$resource['campsite'];
+
$sengeplasser = '';
+ } else {
+
$teltplasser = '';
+
$sengeplasser = '';
+ }
} else {
$teltplasser =
'';
$sengeplasser =
'';
}
+
} else {
+ $ressurs = '';
$teltplasser = '';
$sengeplasser = '';
}
- } else {
- $ressurs = '';
- $teltplasser = '';
- $sengeplasser = '';
- }
+ $wclause = '';
- $wclause = '';
-
- if($regions != '') {
- $wclause .= " AND bb.district
IN ".$regions;
- }
- if($fylke != '') {
- $wclause .= " AND bb.district =
'".$fylke."'";
- }
- if($ressurs != '') {
- $wclause .= " AND br.type =
'".$ressurs."'";
- }
- if($teltplasser != '') {
+ if($regions != '') {
+ $wclause .= " AND
bb.district IN ".$regions;
+ }
+ if($fylke != '') {
+ $wclause .= " AND
bb.district = '".$fylke."'";
+ }
+ if($ressurs != '') {
+ $wclause .= " AND
br.type = '".$ressurs."'";
+ }
+ if($teltplasser != '') {
$wclause .= ' AND
'.$teltplasser;
- }
- if($sengeplasser != '') {
- $wclause .= ' AND
'.$sengeplasser;
- }
+ }
+ if($sengeplasser != '') {
+ $wclause .= ' AND
'.$sengeplasser;
+ }
- $res_result =
$this->soresource->getresources($searchterm,$wclause);
+ $res_result =
$this->soresource->getresources($searchterm,$wclause);
- }
+ }
- foreach($res_result['results'] as &$res)
- {
- $res['name'] = $res['building_name']. ' / ' . $res['name'];
- $res['type'] = "resource";
- $res['link'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uiresource.show', 'id' => $res['id']));
- $res['img_container'] = "resource-" . $res['id'];
- $res['img_url'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uidocument_resource.index_images', 'filter_owner_id' =>
$res['id'], 'phpgw_return_as' => 'json', 'results' => '3'));
- }
- }
- $final_array = array_merge_recursive($bui_result,
$org_result, $res_result);
- $final_array['total_records_sum'] =
array_sum((array)$final_array['total_records']);
+ foreach($res_result['results'] as &$res)
+ {
+ $res['name'] = $res['building_name']. ' / ' .
$res['name'];
+ $res['type'] = "resource";
+ $res['link'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uiresource.show', 'id' => $res['id']));
+ $res['img_container'] = "resource-" . $res['id'];
+ $res['img_url'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uidocument_resource.index_images', 'filter_owner_id' =>
$res['id'], 'phpgw_return_as' => 'json', 'results' => '3'));
+ }
+ }
+ $final_array =
array_merge_recursive($bui_result, $org_result, $res_result);
+ $final_array['total_records_sum'] =
array_sum((array)$final_array['total_records']);
- // Finally increase search counter
- $counter = new booking_searchcount();
- $counter->increaseTerm( $searchterm );
- return $final_array;
+ // Finally increase search counter
+ $counter = new booking_searchcount();
+ $counter->increaseTerm( $searchterm );
+ return $final_array;
+ }
}
}
Modified: branches/dev-thomasez/bookingfrontend/inc/class.uisearch.inc.php
===================================================================
--- branches/dev-thomasez/bookingfrontend/inc/class.uisearch.inc.php
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/inc/class.uisearch.inc.php
2012-11-23 08:07:08 UTC (rev 10531)
@@ -83,10 +83,12 @@
$resource['campsite'] = phpgw::get_var('campsites',
'GET', null);
$resource['beds'] = phpgw::get_var('bedspaces', 'GET',
null);
$resource['region'] = phpgw::get_var('regions', 'GET',
null);
-
+ $resource['from_'] = phpgw::get_var('from_', 'GET',
null);
+ $resource['to_'] = phpgw::get_var('to_', 'GET', null);
$search = null;
- if (strlen($searchterm) || $type || $resource['res'] ||
$resource['fylke'] || $resource['region'])
+
+ if (strlen($searchterm) || $type || $resource['res'] ||
$resource['fylke'] || $resource['region'] || $resource['from_'] )
{
$search = array(
'results' =>
$this->bo->search($searchterm,$resource),
@@ -106,20 +108,20 @@
'layout' => $layout,
'resource' => $resource,
);
-
- // Get frontpage picture documents - Resources
- $sodocres =
CreateObject('booking.sodocument_resource');
- $resource_documents = $sodocres->read( array(
"filters" => array( "category" =>
booking_sodocument::CATEGORY_FRONTPAGE_PICTURE ) ) );
-
- // Insert into $params if there are pictures -
Resources
- if( $resource_documents['total_records'] > 0 ) {
- // Convert nl2br on description
- foreach( $resource_documents['results']
as $key => $data ) {
+
+ // Get frontpage picture documents - Resources
+ $sodocres =
CreateObject('booking.sodocument_resource');
+ $resource_documents = $sodocres->read( array(
"filters" => array( "category" =>
booking_sodocument::CATEGORY_FRONTPAGE_PICTURE ) ) );
+
+ // Insert into $params if there are pictures -
Resources
+ if( $resource_documents['total_records'] > 0 ) {
+ // Convert nl2br on description
+ foreach( $resource_documents['results']
as $key => $data ) {
$resource_documents['results'][$key]['description'] = nl2br(
$resource_documents['results'][$key]['description'] );
-
$resource_documents['results'][$key]['type'] = "resource";
- }
- $params['frontimages'] =
$resource_documents['results'];
- }
+
$resource_documents['results'][$key]['type'] = "resource";
+ }
+ $params['frontimages'] =
$resource_documents['results'];
+ }
// Get frontpage picture documents - Buildings
$sodocbuild =
CreateObject('booking.sodocument_building');
@@ -135,7 +137,7 @@
$params['frontimages'] = array_merge(
$params['frontimages'], $building_documents['results'] );
}
}
-// echo "<pre>";print_r($resource);exit;
+// echo "<pre>";print_r($params);exit;
self::render_template('search', $params);
}
Modified: branches/dev-thomasez/bookingfrontend/js/bookingfrontend/search.js
===================================================================
--- branches/dev-thomasez/bookingfrontend/js/bookingfrontend/search.js
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/js/bookingfrontend/search.js
2012-11-23 08:07:08 UTC (rev 10531)
@@ -132,17 +132,32 @@
YAHOO.booking.initializeDataTable = function()
{
+ var oFrom = YAHOO.util.Dom.get('field_from');
+ if (oFrom.value == null || oFrom.value == '') {
+ YAHOO.util.Dom.setStyle('field_freetime', 'display', 'none');
+ } else {
+ YAHOO.util.Dom.setStyle('field_freetime', 'display', 'block');
+ }
+
+
var val = YAHOO.util.Dom.get('field_type').value;
if(['House'].indexOf(val) >= 0) {
YAHOO.util.Dom.setStyle('field_bedspaces', 'display',
'inline');
YAHOO.util.Dom.setStyle('field_campsites', 'display', 'none');
}
- else if (['Location','Campsite','Boat'].indexOf(val) >= 0)
+ else if (['Location','Campsite'].indexOf(val) >= 0)
{
+ if (['Location'].indexOf(val) >= 0) {
+ YAHOO.util.Dom.setStyle('field_campsites2', 'display',
'none');
+ YAHOO.util.Dom.setStyle('field_meetingroom', 'display',
'inline');
+ } else {
+ YAHOO.util.Dom.setStyle('field_campsites2', 'display',
'inline');
+ YAHOO.util.Dom.setStyle('field_meetingroom', 'display',
'none');
+ }
YAHOO.util.Dom.setStyle('field_bedspaces', 'display', 'none');
YAHOO.util.Dom.setStyle('field_campsites', 'display',
'inline');
}
- else if (['Equipment',''].indexOf(val) >= 0)
+ else if (['Equipment','Boat',''].indexOf(val) >= 0)
{
YAHOO.util.Dom.setStyle('field_bedspaces', 'display', 'none');
YAHOO.util.Dom.setStyle('field_campsites', 'display', 'none');
@@ -200,7 +215,6 @@
var val = this.value;
var fylker = document.getElementById('field_fylker');
var bedspaces =
document.getElementById('field_bedspaces');
-
if (this.id == 'field_type') {
if(['House'].indexOf(val) >= 0) {
ResetCampsites();
@@ -260,15 +274,32 @@
GenerateNorth(fylker,fylke);
}
});
+ YAHOO.util.Event.addListener('advanced', "click", function(e){
+ var val = YAHOO.util.Dom.getStyle('field_freetime' , 'display'
);
+ if (val != 'block') {
+ YAHOO.util.Dom.setStyle('field_freetime', 'display',
'block');
+
+ } else {
+ YAHOO.util.Dom.setStyle('field_freetime', 'display',
'none');
+ var oObj1 = YAHOO.util.Dom.get('field_from');
+ var oObj2 = YAHOO.util.Dom.get('field_to');
+ oObj1.value = '';
+ oObj2.value = '';
+ oObj1.innerHTML = '';
+ oObj2.innerHTML = '';
+ }
+ });
+
YAHOO.util.Event.addListener('search', "submit", function(e){
var oInput = YAHOO.util.Dom.get('searchterm');
if (oInput.value == 'Søk leirplass, hytte, utstyr eller
aktivitet') {
- oInput.value = '';
+ oInput.value = '%';
}
});
};
+
YAHOO.util.Event.addListener(window, "load",
YAHOO.booking.initializeDataTable);
Modified: branches/dev-thomasez/bookingfrontend/setup/phpgw_no.lang
===================================================================
--- branches/dev-thomasez/bookingfrontend/setup/phpgw_no.lang 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/setup/phpgw_no.lang 2012-11-23
08:07:08 UTC (rev 10531)
@@ -376,3 +376,6 @@
Internett/phone bookingfrontend no Internett/telefon
Handicap bookingfrontend no Handikap
Home bookingfrontend no Forsiden
+Advanced search bookingfrontend no Søk på ledig tid
+Goto Schedule bookingfrontend no Gå direkte til kalender
+
Modified: branches/dev-thomasez/bookingfrontend/setup/setup.inc.php
===================================================================
--- branches/dev-thomasez/bookingfrontend/setup/setup.inc.php 2012-11-22
14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/setup/setup.inc.php 2012-11-23
08:07:08 UTC (rev 10531)
@@ -21,7 +21,7 @@
$setup_info['bookingfrontend']['depends'][] = array(
'appname' => 'booking',
- 'versions' => Array( '0.2.14', '0.2.15' )
+ 'versions' => Array( '0.2.14', '0.2.15', '0.2.16' )
);
$setup_info['bookingfrontend']['depends'][] = array(
Modified: branches/dev-thomasez/bookingfrontend/templates/base/search.xsl
===================================================================
--- branches/dev-thomasez/bookingfrontend/templates/base/search.xsl
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/templates/base/search.xsl
2012-11-23 08:07:08 UTC (rev 10531)
@@ -12,6 +12,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
+
<xsl:template match="data" xmlns:php="http://php.net/xsl">
<xsl:call-template name="yui_booking_i18n"/>
<xsl:variable name="resource"><xsl:value-of select="resource"
/></xsl:variable>
@@ -27,6 +28,8 @@
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text><input type="submit" value="{php:function('lang',
'Search')}"/>
+ <xsl:text> </xsl:text><input id="advanced" type="button"
value="{php:function('lang', 'Advanced search')}"/>
+
<div class="hint" id="hint">
F.eks. "<i>Solstølen</i>", "<i>Tredalen</i>", "<i>kano</i>" eller
"<i>leir</i>"
</div>
@@ -92,6 +95,22 @@
</xsl:for-each>
</select>
</div>
+ <div class="freetime" id="field_freetime">
+ <label for="field_from"><xsl:value-of
select="php:function('lang', 'From') "/></label><xsl:text> </xsl:text>
+ <span class="date-picker">
+ <input id="field_from" name="from_" type="text">
+ <xsl:attribute name="value"><xsl:value-of
select="resource/from_"/></xsl:attribute>
+ </input>
+ </span>
+ <label for="field_to"><xsl:value-of
select="php:function('lang', 'To') "/></label><xsl:text> </xsl:text>
+ <span class="date-picker">
+ <input id="field_to" name="to_" type="text">
+ <xsl:attribute name="value"><xsl:value-of
select="resource/to_"/></xsl:attribute>
+ </input>
+ </span>
+ </div>
+ <div style="float: right; margin-right: 250px;"><input type="submit"
value="{php:function('lang', 'Search')}"/></div>
+
</form>
<xsl:if test="not(search)">
@@ -158,6 +177,9 @@
<li>
<div class="header">
<a class="bui_single_view_link"><xsl:attribute
name="href"><xsl:value-of select="link"/></xsl:attribute><xsl:value-of
select="name"/></a>
+ <xsl:if test="schedule">
+ <xsl:text> - </xsl:text><a
style="font-size: 90%;" class="bui_calender_view_link"><xsl:attribute
name="href"><xsl:value-of select="schedule"/></xsl:attribute><xsl:value-of
select="php:function('lang', 'Goto schedule')" /></a>
+ </xsl:if>
<xsl:if test="$layout='bergen'">
(<xsl:value-of select="php:function('lang',
string(type))"/>)
</xsl:if>
Modified: branches/dev-thomasez/bookingfrontend/templates/nsf/building.xsl
===================================================================
--- branches/dev-thomasez/bookingfrontend/templates/nsf/building.xsl
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/bookingfrontend/templates/nsf/building.xsl
2012-11-23 08:07:08 UTC (rev 10531)
@@ -30,8 +30,8 @@
<xsl:if test="normalize-space(homepage) or
normalize-space(email) or normalize-space(phone) or normalize-space(street)">
<h3><xsl:value-of
select="php:function('lang', 'Contact information')" /></h3>
+
<xsl:if test="deactivate_sendmessage=0">
-
<div>
<button
onclick="window.location.href='{message_link}'"><xsl:value-of
select="php:function('lang', 'Send message')" /></button>
- Meldig til saksbehandler for bygg
Modified: branches/dev-thomasez/phpgwapi/templates/bkbooking/css/frontend.css
===================================================================
--- branches/dev-thomasez/phpgwapi/templates/bkbooking/css/frontend.css
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/phpgwapi/templates/bkbooking/css/frontend.css
2012-11-23 08:07:08 UTC (rev 10531)
@@ -416,3 +416,4 @@
clear: both;
display: inline-block;
}
+
Modified: branches/dev-thomasez/phpgwapi/templates/nsf/css/frontend.css
===================================================================
--- branches/dev-thomasez/phpgwapi/templates/nsf/css/frontend.css
2012-11-22 14:24:07 UTC (rev 10530)
+++ branches/dev-thomasez/phpgwapi/templates/nsf/css/frontend.css
2012-11-23 08:07:08 UTC (rev 10531)
@@ -367,4 +367,3 @@
padding-top: 1.5em;
}
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10531] hyttebooking: update serch freetime frontend & fix for rights management,
Kjell Arne Espedal <=