fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [17459] added booking.js to aalesund temp


From: roger . kolseth
Subject: [Fmsystem-commits] [17459] added booking.js to aalesund temp
Date: Wed, 20 Dec 2017 06:04:53 -0500 (EST)

Revision: 17459
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17459
Author:   rogkol
Date:     2017-12-20 06:04:52 -0500 (Wed, 20 Dec 2017)
Log Message:
-----------
added booking.js to aalesund temp

Added Paths:
-----------
    trunk/bookingfrontend/js/aalesund/booking.js

Added: trunk/bookingfrontend/js/aalesund/booking.js
===================================================================
--- trunk/bookingfrontend/js/aalesund/booking.js                                
(rev 0)
+++ trunk/bookingfrontend/js/aalesund/booking.js        2017-12-20 11:04:52 UTC 
(rev 17459)
@@ -0,0 +1,170 @@
+$(document).ready(function ()
+{
+       $("#field_activity").change(function ()
+       {
+               var oArgs = {menuaction: 
'bookingfrontend.uiapplication.get_activity_data', activity_id: $(this).val()};
+               var requestUrl = phpGWLink('bookingfrontend/', 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;
+                                       var checked = '';
+                                       for (var i = 0; i < audience.length; 
++i)
+                                       {
+                                               checked = '';
+                                               if (initialAudience)
+                                               {
+                                                       for (var j = 0; j < 
initialAudience.length; ++j)
+                                                       {
+                                                               if 
(audience[i]['id'] == initialAudience[j])
+                                                               {
+                                                                       checked 
= " checked='checked'";
+                                                               }
+                                                       }
+                                               }
+                                               html_audience += "<li>";
+                                               html_audience += "<label>";
+                                               html_audience += "<input 
type=\"radio\" name=\"audience[]\" value='" + audience[i]['id'] + "'" + checked 
+ "></input>";
+                                               html_audience += 
audience[i]['name'];
+                                               html_audience += "</label>";
+                                               html_audience += "</li>";
+                                       }
+                                       $("#audience").html(html_audience);
+                               }
+                       }
+               });
+       });
+});
+
+$(window).on('load', function()
+{
+       var building_id = $('#field_building_id').val();
+       var organization_id = $('#field_org_id').val();
+       var building_id_selection;
+       var organization_id_selection;
+       if (!group_id)
+       {
+               var group_id = "";
+       }
+       if (building_id)
+       {
+               populateTableChkResources(building_id, initialSelection);
+               building_id_selection = building_id
+       }
+       if (organization_id)
+       {
+               populateSelectGroup(organization_id, group_id);
+               organization_id_selection = organization_id;
+       }
+});
+
+if ($.formUtils)
+{
+       $.formUtils.addValidator({
+               name: 'target_audience',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       $('#audience input[name="audience[]"]').each(function ()
+                       {
+                               if ($(this).is(':checked'))
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Please choose at least 1 target audience',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'number_participants',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       $('#agegroup_tbody input').each(function ()
+                       {
+                               if ($(this).val() != "" && $(this).val() > 0)
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Number of participants is required',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'application_resources',
+               validatorFunction: function (value, $el, config, language, 
$form)
+               {
+                       var n = 0;
+                       $('#resources_container table 
input[name="resources[]"]').each(function ()
+                       {
+                               if ($(this).is(':checked'))
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Please choose at least 1 resource',
+               errorMessageKey: 'application_resources'
+       });
+}
+
+function populateTableChk(url, container, colDefs)
+{
+       createTable(container, url, colDefs, 'results');
+}
+
+function populateTableChkResources(building_id, selection)
+{
+        alert("test");
+       var url = phpGWLink('bookingfrontend/', {menuaction: 
'bookingfrontend.uiresource.index_json', sort: 'name', filter_building_id: 
building_id}, true);
+       var container = "resources_container";
+       var colDefsResources = [{label: '', object: [{type: 'input', attrs: [
+                                               {name: 'type', value: 
'checkbox'}, {name: 'name', value: 'resources[]'}
+                                       ]}
+                       ], value: 'id', checked: selection}, {key: 'name', 
label: lang['Name']}, {key: 'type', label: lang['Resource Type']}
+       ];
+       populateTableChk(url, container, colDefsResources);
+}
+
+function populateSelectGroup(organization_id, selection)
+{
+       var url = phpGWLink('bookingfrontend/', {menuaction: 
'booking.uigroup.index', filter_organization_id: organization_id}, true);
+       var container = $('#group_container');
+       var attr = [
+               {name: 'name', value: 'group_id'}, {name: 'data-validation', 
value: 'required'}
+       ];
+       populateSelect(url, selection, container, attr);
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]