[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14637] more on bookingfrontend
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14637] more on bookingfrontend |
Date: |
Wed, 13 Jan 2016 10:28:54 +0000 |
Revision: 14637
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14637
Author: sigurdne
Date: 2016-01-13 10:28:53 +0000 (Wed, 13 Jan 2016)
Log Message:
-----------
more on bookingfrontend
Modified Paths:
--------------
branches/dev-syncromind/bookingfrontend/inc/class.uiresource.inc.php
branches/dev-syncromind/bookingfrontend/templates/base/resource.xsl
Modified: branches/dev-syncromind/bookingfrontend/inc/class.uiresource.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uiresource.inc.php
2016-01-13 09:56:44 UTC (rev 14636)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uiresource.inc.php
2016-01-13 10:28:53 UTC (rev 14637)
@@ -9,6 +9,7 @@
'index_json' => true,
'query' => true,
'show' => true,
+ 'get_custom' => true,
'schedule' => true
);
@@ -17,6 +18,7 @@
parent::__construct();
$this->bo =
CreateObject('booking.boresource');
$this->building_bo =
CreateObject('booking.bobuilding');
+ $this->activity_bo =
CreateObject('booking.boactivity');
$old_top =
array_pop($this->tmpl_search_path);
array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT .
'/bookingfrontend/templates/base');
array_push($this->tmpl_search_path, $old_top);
@@ -57,6 +59,54 @@
self::render_template_xsl('resource', $data);
}
+ private function get_location()
+ {
+ $activity_id =
phpgw::get_var('activity_id', 'int');
+ $activity_path =
$this->activity_bo->get_path($activity_id);
+ $top_level_activity = $activity_path ?
$activity_path[0]['id'] : 0;
+ return ".resource.{$top_level_activity}";
+ }
+
+ public function get_custom()
+ {
+ $resource_id = phpgw::get_var('resource_id',
'int');
+ $resource =
$this->bo->read_single($resource_id);
+ $custom_values =
$resource['json_representation']->data;
+// _debug_array($custom_values);
+
+
+ $location =
$this->get_location();
+ $custom_fields =
createObject('booking.custom_fields');
+ $fields = $custom_fields->get_fields($location);
+ foreach($fields as $attrib_id => &$attrib)
+ {
+ $attrib['value'] =
isset($custom_values->$attrib['name']) ? $custom_values->$attrib['name'] : null;
+
+ if(isset($attrib['choice']) &&
is_array($attrib['choice']) && $attrib['value'])
+ {
+ foreach($attrib['choice'] as &$choice)
+ {
+ if(is_array($attrib['value']))
+ {
+ $choice['selected'] =
in_array($choice['id'], $attrib['value']) ? 1 : 0;
+ }
+ else
+ {
+ $choice['selected'] =
$choice['id'] == $attrib['value'] ? 1 : 0;
+ }
+ }
+ }
+ }
+// _debug_array($fields);
+ $organized_fields =
$custom_fields->organize_fields($location, $fields);
+
+ $data = array(
+ 'attributes_group' => $organized_fields,
+ );
+
$GLOBALS['phpgw']->xslttpl->add_file(array('attributes_form'));
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
array('custom_fields' => $data));
+ }
+
public function schedule()
{
$resource
= $this->bo->get_schedule(phpgw::get_var('id', 'int', 'GET'),
'bookingfrontend.uibuilding', 'bookingfrontend.uiresource',
'bookingfrontend.uisearch.index');
Modified: branches/dev-syncromind/bookingfrontend/templates/base/resource.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/resource.xsl
2016-01-13 09:56:44 UTC (rev 14636)
+++ branches/dev-syncromind/bookingfrontend/templates/base/resource.xsl
2016-01-13 10:28:53 UTC (rev 14637)
@@ -51,7 +51,10 @@
</h3>
<div id="documents_container"/>
</dl>
+ <div id="custom_fields"></div>
</div>
+ <input type= "hidden" id="field_activity_id"
value="{resource/activity_id}"/>
+
<div class="pure-u-1 pure-u-lg-1-2">
<dl class="proplist-col images">
<div id="images_container">
@@ -96,6 +99,34 @@
}
});
+ <![CDATA[
+ $(document).ready(function () {
+
+ get_custom_fields();
+ });
+
+ get_custom_fields = function () {
+ var oArgs = {menuaction:
'bookingfrontend.uiresource.get_custom', resource_id: resource_id};
+ var requestUrl = phpGWLink('bookingfrontend/', oArgs);
+ requestUrl += "&phpgw_return_as=stripped_html";
+ var activity_id = $("#field_activity_id").val();
+ $.ajax({
+ type: 'POST',
+ data: {activity_id: activity_id},
+ dataType: 'html',
+ url: requestUrl,
+ success: function (data) {
+ if (data != null)
+ {
+ var custom_fields = data;
+
$("#custom_fields").html(custom_fields);
+ }
+ }
+ });
+ };
+ ]]>
+
+
</script>
</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14637] more on bookingfrontend,
Sigurd Nes <=