Le repo des sources pour le site web des JM2L
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

246 lines
9.3 KiB

  1. # -*- coding: utf-8 -*-
  2. <%inherit file="jm2l:templates/layout.mako"/>
  3. <%def name="cssAddOn()">
  4. <style>
  5. .data {
  6. display:none;
  7. }
  8. .table thead th {
  9. background-color: lightblue;
  10. vertical-align:middle;
  11. text-align:center;
  12. }
  13. th.SortUp {
  14. background: url("/static/img/up.gif") right center no-repeat;
  15. }
  16. th.SortDown {
  17. background: url("/static/img/down.gif") right center no-repeat;
  18. }
  19. </style>
  20. </%def>
  21. <script src="/vendor/jquery.min.js"></script>
  22. <script>
  23. $(function () {
  24. $('th').click(function(){
  25. var table = $(this).parents('table').eq(0)
  26. var rows = table.find("tr:not(:has('th'))").toArray().sort(comparer($(this).index(),this.asc))
  27. this.asc = !this.asc
  28. table.find('th').removeClass( "SortDown SortUp" );
  29. if (!this.asc){
  30. rows = rows.reverse();
  31. table.find('th:eq('+$(this).index()+')').toggleClass('SortDown');
  32. } else {
  33. table.find('th:eq('+$(this).index()+')').toggleClass('SortUp');
  34. }
  35. for (var i = 0; i < rows.length; i++){table.append(rows[i])}
  36. })
  37. function comparer(index, order) {
  38. if (index==3 || index==7)
  39. return function(a, b) {
  40. var dateA = new Date(getCellValue(a, index)).getTime();
  41. var dateB = new Date(getCellValue(b, index)).getTime();
  42. if (isNaN(dateA) && isNaN(dateB)) return 0
  43. if (isNaN(dateA)) return order ? -1 : 1
  44. if (isNaN(dateB)) return order ? 1 : -1
  45. return dateA > dateB ? 1 : -1;
  46. }
  47. else
  48. return function(a, b) {
  49. var valA = getCellValue(a, index), valB = getCellValue(b, index)
  50. if (valA==="" && valB==="") return 0
  51. if (valA==="") return order ? -1 : 1
  52. if (valB==="") return order ? 1 : -1
  53. return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.localeCompare(valB)
  54. }
  55. }
  56. function no_accent(my_string) {
  57. var new_string = "";
  58. var pattern_accent = new Array("é", "è", "ê", "ë", "ç", "à", "â", "ä", "î", "ï", "ù", "ô", "ó", "ö");
  59. var pattern_replace_accent = new Array("e", "e", "e", "e", "c", "a", "a", "a", "i", "i", "u", "o", "o", "o");
  60. if (my_string && my_string!= "") {
  61. for(var i = 0; i < pattern_accent.length; i++){
  62. my_string = my_string.replace(pattern_accent[i], pattern_replace_accent[i]);
  63. }
  64. }
  65. return my_string;
  66. }
  67. function getCellValue(row, index){
  68. switch (index) {
  69. case 0: // Name
  70. return no_accent( $(row).children('td').eq(index).children('a').text().toLowerCase() );
  71. break;
  72. default:
  73. return no_accent( $(row).children('td').eq(index).children('span').text() );
  74. //return $(row).children('td').eq(index).html();
  75. }
  76. }
  77. // additional code to apply a filter
  78. $('table').each(function(){
  79. var table = $(this)
  80. var headers = table.find('th').length;
  81. var filterrow = table.find('th:first()').prepend($('<div>').attr('class','input-append').click(function(){return false;}));
  82. filterrow.find('div').append($('<input>').attr('type','text').keyup(function(){
  83. table.find('tr').show()
  84. filterrow.find('input[type=text]').each(function(){
  85. var index = $(this).parent().index() + 1;
  86. var filter = $(this).val() != '';
  87. $(this).toggleClass('filtered', filter);
  88. if (filter){
  89. var el = 'td:nth-child('+index+') > span.data';
  90. var criteria = ":contains('"+$(this).val().toLowerCase()+"')";
  91. table.find(el+':not('+no_accent(criteria)+')').parent().parent().hide();
  92. }
  93. });
  94. }));
  95. filterrow.find('div').append($('<span>').attr('class','btn').attr('type','button').text('C').click(function(){
  96. $(this).parent().parent().find('input[type=text]').val('').toggleClass('filtered', false)
  97. table.find('tr').show()
  98. }))
  99. })
  100. });
  101. </script>
  102. <%
  103. import datetime
  104. import itertools
  105. now = datetime.datetime.now()
  106. %>
  107. <form class="filterform" action="#">
  108. <table class="table table-bordered table-hover">
  109. <thead>
  110. <tr>
  111. <th style="width:7em;text-align:center;"></th>
  112. <th style="width:5em;text-align:center;">Visite</th>
  113. <th style="width:7em;text-align:center;">Activité</th>
  114. <th style="text-align:center;">Arrivée prévue</th>
  115. <th style="width:5em;text-align:center;">${DicRepas['Ven']} Repas Vendredi</th>
  116. <th style="width:5em;text-align:center;">${DicRepas['Midi']} Repas Midi </th>
  117. <th style="width:5em;text-align:center;">${DicRepas['Soir']} Repas Soir</th>
  118. <th style="text-align:center;">Départ prévu</th>
  119. <th style="text-align:center;">Notes</th>
  120. </tr>
  121. </thead>
  122. <tbody id="list">
  123. % for u, s in Users:
  124. <tr>
  125. <td style="text-align:center;">
  126. <span class="data">${u.slug}</span>
  127. <a href="/MesJM2L?user=${u.uid}">${u.nom} ${u.prenom}</a><br />
  128. <span style="align:center">
  129. ${u.vote_logo}
  130. <a href="mailto:${u.mail}">
  131. <i class="icon-envelope"></i>
  132. </a>
  133. % if u.Staff==1:
  134. <a href="javascript:alert('${u.nom}, ${u.prenom}\nStaff JM2L');">
  135. <i class="icon-star"></i>
  136. </a>
  137. % endif
  138. % if u.Staff==0:
  139. <a href="javascript:alert('${u.nom}, ${u.prenom}\nIntervenant');">
  140. <i class="icon-user"></i>
  141. </a>
  142. % endif
  143. % if u.active==0:
  144. <a href="javascript:alert('${u.nom}, ${u.prenom}\nInactive');">
  145. <i class="icon-ban-circle"></i>
  146. </a>
  147. % endif
  148. % if u.phone:
  149. <a href="javascript:alert('${u.nom}, ${u.prenom}\n${u.phone}');">
  150. <i class="icon-headphones"></i>
  151. </a>
  152. % endif
  153. </span>
  154. </td>
  155. <td style="text-align:center;">
  156. <span class="data">${(now - u.last_logged).days}</span>${(now - u.last_logged).days} j
  157. </td>
  158. <td style="text-align:center;">
  159. % if u.events:
  160. <span class="data">${len(u.events)}</span>
  161. <select style="width:7em;">
  162. <option><strong>${len(u.events)} Intérv.</strong></option>
  163. % for y, g in itertools.groupby(sorted(u.events, key=lambda k:k.for_year, reverse=True), key=lambda k:k.for_year):
  164. <OPTGROUP LABEL="${y}">
  165. % for event in g:
  166. ${event.for_year}
  167. <OPTION onclick="location='/event/${event.for_year}/${event.slug}';">${event.event_type} - ${event.name}</OPTION>
  168. % endfor
  169. </OPTGROUP>
  170. % endfor
  171. </select>
  172. %else:
  173. <span class="data"></span>
  174. <i> - </i>
  175. % endif
  176. </td>
  177. <td style="text-align:center;">
  178. % if s and s.arrival_time:
  179. <span class="data">${s.arrival_time.strftime('%m/%d/%Y %H:%M:%S')}</span>
  180. ${s.arrival_time.strftime('%a %d <strong>%H:%M</strong>') | n}<br/>
  181. ${s.arrival_place}
  182. % if s.arrival_text:
  183. - NB: <strong>${s.arrival_text}</strong>
  184. % endif
  185. %else:
  186. <span class="data"></span>
  187. <i>Pas d'informations</i>
  188. % endif
  189. </td>
  190. % if s and s.repas:
  191. % for i, d in enumerate(['Ven Soir', 'Sam midi', 'Sam soir']):
  192. <td style="text-align:center">
  193. % if (s.repas & 2**i):
  194. <span class="data">Oui</span>Oui
  195. % else:
  196. <span class="data">Non</span>Non
  197. % endif
  198. </td>
  199. % endfor
  200. %else:
  201. <td style="text-align:center;" colspan="3">
  202. <i>Pas d'informations</i>
  203. </td>
  204. % endif
  205. </td>
  206. <td style="text-align:center;">
  207. % if s and s.depart_time:
  208. <span class="data">${s.depart_time.strftime('%m/%d/%Y %H:%M:%S')}</span>
  209. ${s.depart_time.strftime('%a %d <strong>%H:%M</strong>') | n}<br/>
  210. ${s.depart_place}
  211. % if s.depart_text:
  212. - NB: <strong>${s.arrival_text}</strong>
  213. % endif
  214. %else:
  215. <span class="data"></span>
  216. <i>Pas d'informations</i>
  217. % endif
  218. </td>
  219. <td>
  220. % if s:
  221. % if s.repas_allerg:
  222. <u>Allergies</u> : ${s.repas_allerg}<br/>
  223. % endif
  224. % if s.repas_contr:
  225. <u>Contraintes</u> : ${s.repas_contr}<br/>
  226. % endif
  227. % endif
  228. </td>
  229. </tr>
  230. % endfor
  231. </tbody>
  232. </table>
  233. </form>