form with following fields:
Location: Date: Set1 Set2 Set3 |
Form
All records
Order by date asc
Using REST API to show data PER WEEK
https://wiki.vertuna.com/ajax/confiforms/rest/filter.action?pageId=23265387&f=f&q=&sort=mydate%20ASC |
Report is loaded with JavaScript and ConfiForms REST API
<div id="confiReport"></div> <script> AJS.toInit(function() { var isPageEdit = AJS.$('#content').hasClass('page edit'); if (!isPageEdit) { var url = 'https://wiki.vertuna.com/ajax/confiforms/rest/filter.action?pageId=23265387&f=f&q=&sort=mydate%20ASC'; var xhr = AJS.$.ajax({ url: url, timeout: 10000, // 10 sec success: function (data) { var currentWeek = confimoment().format('W'); var runningWeek = null; var rows = data.list.entry; for (i=0;i<rows.length;i++) { var recordWeek = confimoment(new Date(rows[i].fields.mydate)).format('W'); console.log(confimoment(new Date(rows[i].fields.mydate)).format('W')); if (runningWeek == null || runningWeek != recordWeek) { AJS.$('#confiReport').append('<h2>' + ((recordWeek == currentWeek ) ? 'Current week' : ( recordWeek + ' week')) + '</h2>'); } AJS.$('#confiReport').append('<p> Set1: ' + rows[i].fields.set1 + '</p>'); AJS.$('#confiReport').append('<p> Set2: ' + rows[i].fields.set2 + '</p>'); AJS.$('#confiReport').append('<p> Set2: ' + rows[i].fields.set2 + '</p><br/>'); runningWeek = recordWeek; } console.log(data); }, error: function (jqXHR, textStatus, errorThrown) { console.log('request to get data from ConfiForms has failed... ' + textStatus); } }); } }); </script> |