· 9 years ago · Feb 22, 2017, 12:38 PM
1<?php
2/**
3 *
4 * @author James Boag <j.boag@abdn.ac.uk>
5 * @version 07-Jan-2014
6 * @copyright Medi-CAL Unit, University of Aberdeen
7 */
8$url_academicyear = $this->uri->segment(3);
9$url_programmeyear = $this->uri->segment(4);
10$url_audience = $this->uri->segment(5);
11$a_audence[1] = 'MYVLE';
12$a_audence[2] = 'MYMBCHB';
13$a_audence[3] = 'MYDBS';
14$a_audence[4] = 'MYPA';
15$a_audence[5] = 'MYMEDSCI';
16
17
18// get all data required and post it to js ..
19?>
20
21<!-- Define the edit group popup -->
22<div id="edit_group_popup" class="modal hide fade" role="dialog" style="height:550px; top:50px;">
23
24 <div class="modal-header" >
25 <button type="button" class="close" data-dismiss="modal">×</button>
26 <h3 class="editgrouptitle" name="editgrouptitle" id="editgrouptitle">Edit Group</h3>
27 </div>
28 <div class="modal-body">
29 <table cellpadding ='5px'>
30 <tr>
31 <td>
32
33 <div class="control-group">
34 <label class="control-label" for="popup_group_name">Group Name</label>
35 <div class="controls">
36 <div class="div_popup_group_name" id="div_popup_group_name" name="div_popup_group_name">
37 <input type="text" id="group_name" name="group_name" placeholder="Group Name" class="input-xxlarge" style="width:500px;"/>
38
39 </div>
40 </div>
41 </div>
42 </td>
43 </tr>
44
45 <tr><td>
46 <div class="control-group">
47 <label class="control-label" for="group_dpyr">Programme Year</label>
48 <div class="control">
49 <div class="div_popup_group_dpyr" id="div_popup_group_dpyr" name="div_popup_group_dpyr">
50 <div id="popup_group_dpyr" class="ui-buttonset">
51 <a href="javascript: void(0)" onclick="javascript:edit_group_dpy(1);
52 return false;"><label id ="dpyr_1" class="checked">1</label></a>
53 <a href="javascript: void(0)" onclick="javascript:edit_group_dpy(2);
54 return false;"><label id ="dpyr_2" >2</label></a>
55 <a href="javascript: void(0)" onclick="javascript:edit_group_dpy(3);
56 return false;"><label id ="dpyr_3" >3</label> </a>
57 <a href="javascript: void(0)" onclick="javascript:edit_group_dpy(4);
58 return false;"><label id ="dpyr_4" >4</label></a>
59 <a href="javascript: void(0)" onclick="javascript:edit_group_dpy(5);
60 return false;"><label id ="dpyr_5" >5</label></a>
61 </div>
62 </div>
63 </div>
64 </div>
65 </td></tr>
66 <tr><td>
67 <div class="control-group">
68 <label class="control-label" for="group_isyearlist">Is Year List</label>
69 <div class="controls">
70 <div id="isyearlistbtnset" class="ui-buttonset">
71 <a href="javascript: void(0)" onclick="javascript:edit_group_yearlist(true);
72 return false;"><label id="isyearlist_true" for="isyearlist_true">Yes</label></a>
73 <a href="javascript: void(0)" onclick="javascript:edit_group_yearlist(false);
74 return false;"><label id="isyearlist_false" for="isyearlist_false" class="checked">No</label></a>
75 </div>
76 </div>
77 </div>
78 </td></tr>
79 <tr><td>
80 <div class="control-group">
81 <label class="control-label" for="group_isward">Is Ward Teaching</label>
82 <div class="controls">
83 <div id="iswardbtnset" class="ui-buttonset">
84 <a href="javascript: void(0)" onclick="javascript:edit_group_isward(true);
85 return false;"><label id="isward_true" for="isward_true">Yes</label> </a>
86 <a href="javascript: void(0)" onclick="javascript:edit_group_isward(false);
87 return false;"><label id="isward_false" for="isward_false" class="checked">No</label></a>
88 </div>
89 </div>
90 </div>
91 </td></tr>
92 <tr><td>
93 <div class="control-group">
94 <label class="control-label" for="group_issuppressed">Is Suppressed</label>
95 <div class="controls">
96 <div id="issuppressedbtnset" class="ui-buttonset" >
97 <a href="javascript: void(0)" onclick="javascript:edit_group_issuppressed(true);
98 return false;"><label id="issuppressed_true" for="issuppressed_true">Yes</label> </a>
99 <a href="javascript: void(0)" onclick="javascript:edit_group_issuppressed(false);
100 return false;"><label id="issuppressed_false" for="issuppressed_false" class="checked">No</label> </a>
101 </div>
102 </div>
103 </div>
104 </td>
105 </tr>
106 <tr>
107 <td>
108 <div class="Processing" id ="Processing" name ="Processing">
109 <i class="icon-spinner icon-spin icon-large"></i> <b>Saving Changes...</b>
110
111 </div>
112 </td>
113 </tr>
114 <tr>
115
116 </tr></table>
117 </div>
118 <div class="modal-footer"><div class="info-edit-group"></div>
119 <a href="javascript: void(0)" onclick="javascript:closegroupchanges();
120 return false;"><input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal"></a>
121 <a href="javascript: void(0)" onclick="javascript:savegroupchanges();
122 return false;"><input class="btn-popup-add btn btn-success" type ="button" name="button" id="save_group_changes" value="Save" ></a>
123 </div>
124
125</div>
126<!-- Advanced User Search -->
127<div id="advanced_user_search_popup" class="modal hide fade" role="dialog" style="height:400px; top:100px" >
128 <div class="modal-header">
129 <button type="button" class="close" data-dismiss="modal" >×</button>
130 <h3>Advanced Group Users</h3>
131 </div>
132 <div class="modal-body">
133 </div>
134</div>
135
136<!-- edit group users popup -->
137<div id="edit_group_user_popup" class="modal hide fade" role="dialog" style="width: 660px; height:520px; top:50px;webkit-transform:translateZ(0);">
138 <div class="modal-header">
139 <button type="button" class="close" data-dismiss="modal" >×</button>
140 <h3>Edit Group Users</h3>
141 </div>
142
143 <div class="modal-body">
144
145
146 <div class="control-group">
147 <label class="control-label" for="popup_group_users_name" id ='popup_group_users_name'>Group Name</label>
148 </div>
149 <!-- <div class="Advanced-search" id="Advanced-search" name ="Advanced-search" style="height:225px;display:none !important;">
150
151 <div class="content">
152 <table border ="0px">
153 <tr><td width="20%">Context</td><td width="70%">Search criteria </td><td width="10%"></td></tr>
154 <tr><td class="actionicon"><select class="selcontext actionicon" name ="selcontext" id="selcontext" width="20%">
155 <option value="0">All</option>
156 <option value="1">First Name</option>
157 <option value="2">Last Name</option>
158 <option value="3">Email</option>
159 </select>
160 </td><td class="actionicon">
161 <input id="searchfor" class="input-xxlarge actionicon" type="text" style="width:98%;" placeholder="Search For" name="searchfor">
162 </td><td valign="top" align="center"><a href="#" onclick="javascript:advancesearch();
163 return false;" ><i class='icon-search'></i></a></td></tr>
164 <tr><td colspan="3">
165 <div class="Search-results" style="height:120px">
166 <div class="scrollable" width="100%" style="overflow-y: scroll; height:150px">
167 <table class="advsearchcontents" id="advsearchcontents" name ="advsearchcontents">
168 <tbody>
169 <tr><td>
170 <div class="advsearchcontent">
171
172 </div>
173 </td></tr>
174 </tbody>
175 </table>
176 </div>
177 </div>
178 </td></tr> </table>
179
180
181 </div>
182 </div>-->
183 <div class="std-search" id="std-search" name="std-search">
184 <div class="control-group" >
185 <label class="control-label" for="popup_group_name_userlist">Users</label>
186 <div class="controls">
187 <div class="popup_group_name_userlist" id="popup_group_name_userlist" name="popup_group_name_userlist">
188 <table width='100%' valign="middle"><tr valign="middle"><td valign="middle" width='90%'>
189 <select id="selAttendees_Chosen" name="building" placeholder="Users" class="chzn-container chzn-container-single chzn-with-drop chzn-container-active" style="width:200px;" tabindex ="-1" >
190 <option value=""></option>
191 </select>
192
193 </td><td width='10%' align="center" valign="middle"><div><a href="javascript: void(0)" onclick="javascript:addusershtml();
194 return false;"><i class='icon-plus'></i></a></div></td></tr></table>
195 </div>
196 </div>
197 </div>
198 </div>
199 <?php
200 $attributes = array('name' => 'addgroupusers');
201 ?>
202 <div class='table_all' id='table_all' style='height:280px' width ='100%'>
203 <table name='header' border ='0' width ='100%' class='table-hdr'>
204 <!-- no longer a form ! -->
205 <!--<?php //echo form_open('/groups/ajax_updategroupusers', $attributes); ?> -->
206
207
208 <thead>
209 <tr>
210
211 <td>
212 <input type="hidden" name='addusers' id='addusers' class='addusers' value =''>
213 <input type="hidden" name='delusers' id='delusers' class='delusers' value =''>
214 <input type="hidden" name='groupid' id='groupid' class='groupid' value ='0'>
215 <input type="hidden" name='menustring' id='menustring' class='menustring' value =''>
216 User </td>
217
218 <td> </td>
219 </tr>
220 </thead>
221 </table>
222
223 <div class='scrollable' style='overflow-y: scroll; height:230px' width ='100%'>
224 <table name='content' id='usercontent' border ='0' width ='100%' class='table-body'>
225
226 <tbody>
227
228 </tbody>
229 </table>
230 </div>
231
232
233
234 </div>
235 </div>
236
237
238 <div class="modal-footer">
239 <table width='100%'><tr><td align='left'>
240 <div class="Processingusers" id ="Processingusers" name ="Processingusers">
241
242 </div>
243 </td><td align='right'>
244
245 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
246 <a href="javascript: void(0)" onclick="javascript:posteditusers();
247 return false;"><input class="btn-popup-add btn btn-success" type ="button" value="Save changes" name="button" id="save_group_changes" ></a>
248 </td></tr></table>
249 </div>
250</div>
251
252<!-- Excel link -->
253<div id="excel_popup" class="modal hide fade" role="dialog" style="height:120px; top:50px; width:220px;">
254 <div class="modal-header">
255 Export group to excel.
256 </div>
257 <div class="modal-body">
258 <a download="grouplist.xls"
259 href="javascript: void(0)"
260 onclick="javascript: getcsvhdr();" ><input class="btn-popup-close btn btn-success" type="button" value="Export" > </a>
261 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
262 </div>
263 <div class="modal-footer">
264
265 </div>
266</div>
267
268<!-- Print filters-->
269<div id="print_popup" class="modal hide fade" role="dialog" style="height:400px; top:50px; width:370px;">
270 <div class="modal-header">
271 <h3>Class List Print Options</h3>
272 </div>
273
274 <div class="modal-body">
275 <div class="control-group">
276 <label class="control-label" for="popup_Print_Username">Username</label>
277 <div class="controls">
278 <div id="printusernamebtnset" >
279 <div class="div_popup_Print_Username" id="div_popup_Print_Username" name="div_popup_Print_Username" class="ui-buttonset">
280 <a href="javascript: void(0)" onclick="javascript:setprintdialogusername(1);
281 return false;"><label id="popupprintusername_true" for="popupprintusername_true" class="checked">Yes</label> </a>
282 <a href="javascript: void(0)" onclick="javascript:setprintdialogusername(0);
283 return false;"><label id="popupprintusername_false" for="popupprintusername_false">No</label> </a>
284 </div>
285 </div>
286 </div>
287 </div>
288
289 <div class="control-group">
290 <label class="control-label" for="popup_Print_Tickbox">Tick Box</label>
291 <div class="controls">
292 <div class="div_popup_Print_Tickbox" id="div_popup_Print_Tickbox" name="div_popup_Print_Tickbox" class="ui-buttonset">
293 <a href="javascript: void(0)" onclick="javascript:setprintdilalogtickbox(1);
294 return false;"><label id="popupprinttickbox_true" for="popupprinttickbox_true" class="checked" >Yes</label> </a>
295 <a href="javascript: void(0)" onclick="javascript:setprintdilalogtickbox(0);
296 return false;"><label id="popupprinttickbox_false" for="popupprinttickbox_false">No</label> </a>
297 </div>
298 </div>
299 </div>
300
301 <div class="control-group">
302 <label class="control-label" for="popup_Print_Sigbox">Signature Box</label>
303 <div class="controls">
304 <div class="div_popup_Print_Sigbox" id="div_popup_Print_Sigbox" name="div_popup_Print_Sigbox" class="ui-buttonset">
305 <a href="javascript: void(0)" onclick="javascript:setprintdialogsignature(1);
306 return false;"><label id="popupprintsigbox_true" for="popupprintsigbox_true" class="checked" >Yes</label> </a>
307 <a href="javascript: void(0)" onclick="javascript:setprintdialogsignature(0);
308 return false;"><label id="popupprintsigbox_false" for="popupprintsigbox_false">No</label> </a>
309 </div>
310 </div>
311 </div>
312 <div class="control-group">
313 <label class="control-label" for="popup_Print_Photobox">Photo Box</label>
314 <div class="controls">
315 <div class="div_popup_Print_Photobox" id="div_popup_Print_Photobox" name="div_popup_Print_Photobox" class="ui-buttonset">
316 <a href="javascript: void(0)" onclick="javascript:setprintdilaogphoto(1);
317 return false;"><label id="popupprintphotobox_true" for="popupprintphotobox_true" class="checked" >Yes</label> </a>
318 <a href="javascript: void(0)" onclick="javascript:setprintdilaogphoto(0);
319 return false;"><label id="popupprintphotobox_false" for="popupprintphotobox_false">No</label> </a>
320 </div>
321 </div>
322 </div>
323 <div class="Processingrpt" id ="Processingrpt" name ="Processingrpt">
324
325 </div>
326
327 </div>
328 <div class="modal-footer">
329 <a href="javascript: void(0)" onclick="javascript:producereport();
330 return false;"><input class="btn-popup-close btn btn-success" type="button" value="Print" ></a>
331 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
332 </div>
333</div>
334
335
336
337<!-- Badge filters-->
338<div id="print_badge_popup" class="modal hide fade" role="dialog" style="height:260px; top:50px; width:370px;">
339 <div class="modal-header">
340 <h3>Class List Badge Options</h3>
341 </div>
342 <div class="modal-header">
343 Please select your options :
344 </div>
345 <div class="modal-body">
346 <div class="control-group">
347 <label class="control-label" for="popup_Print_Photobox">Photo Box</label>
348 <div class="controls">
349 <div class="div_popup_Print_Badge_Photobox" id="div_popup_Print_Badge_Photobox" name="div_popup_Print_Badge_Photobox" class="ui-buttonset">
350 <a href="javascript: void(0)" onclick="javascript:setprintbadgephoto(1);
351 return false;"><label id="popupprintbadgephotobox_true" for="popupprintbadgephotobox_true" class="checked" >Yes</label> </a>
352 <a href="javascript: void(0)" onclick="javascript:setprintbadgephoto(0);
353 return false;"><label id="popupprintbadgephotobox_false" for="popupprintbadgephotobox_false">No</label> </a>
354 </div>
355 <div class="yourreport">
356 <!-- <a>Your Report ! </a> -->
357 </div>
358 </div>
359 </div>
360 <div class="Processingbadge" id ="Processingbadge" name ="Processingbadge">
361
362 </div>
363 </div>
364 <div class="modal-footer">
365 <a href="javascript: void(0)" onclick="javascript:dobadges();
366 return false;"><input class="btn-popup-close btn btn-success" type="button" value="Print" ></a>
367 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
368 </div>
369</div>
370
371
372<!-- Delete popup -->
373<div id="delete_popup" class="modal hide fade" role="dialog" style="height:160px; top:50px; width:400px;">
374 <div class="modal-header">
375 <h3>Are you sure you want to delete</h3>
376 </div>
377
378 <div class="modal-body">
379 <label class="delete_label" id="delete_label" name ="delete_label">This Group</label>
380 </div>
381
382 <div class="modal-footer">
383 <a href="javascript: void(0)" onclick="javascript:deletegroup();
384 return false;"><input class="btn-popup-close btn btn-danger" type="button" value="Delete" ></a>
385 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
386 </div>
387</div>
388
389<!-- Auto Create Group Popup-->
390<div id="ac_groups_popup" class="modal hide fade" role="dialog" style="height:430px; top:50px;">
391 <div class="modal-header">
392 Auto Create Groups
393 <button type="button" class="close" data-dismiss="modal" >×</button>
394 </div>
395 <div class="modal-body">
396 <div class="control-group">
397 <label class="control-label" for="popup_ac_group_name">Group Name</label>
398 <div class="controls">
399 <div class="div_popup_group_name" id="div_popup_group_name" name="div_popup_group_name">
400 <input type="text" id="ac_group_name" name="ac_group_name" placeholder="Group Name" class="input-xxlarge" style="width:500px;"/>
401 </div>
402 </div>
403 </div>
404
405 <div class="control-group">
406 <label class="control-label" for="popup_ac_group_number">Number of Groups</label>
407 <div class="controls">
408 <div class="div_popup_group_number" id="div_popup_group_number" name="div_popup_group_number">
409 <input type="text" id="ac_group_number" name="ac_group_number" placeholder="Number of Groups" class="input-xxlarge" style="width:500px;"/>
410 </div>
411 </div>
412 </div>
413
414
415 <div class="control-group">
416 <label class="control-label" for="popup_ac_yearlist">Year List</label>
417 <div class="controls">
418 <div class="popup_ac_yearlist" id="popup_ac_yearlist" name="popup_ac_yearlist">
419 <table width='100%'><tr><td width='80%'><select data-placeholder="Find" class="chzn-container chzn-container-single chzn-with-drop chzn-container-active" style="width:400px; z-index:39001" tabindex ="-1" id="ac_yearlist" name="yearlist[]"></select></td><td width='20%'><div></div></td></tr></table>
420 </div>
421 </div>
422 </div>
423
424
425 <div class="control-group">
426 <label class="control-label" for="popup_ac_type">Auto Append</label>
427 <div class="controls">
428 <div class="div_popup_ac_type" id="div_popup_ac_type" name="div_popup_ac_type" class="ui-buttonset">
429 <a href="javascript: void(0)" onclick="javascript:setacgroupappend(1);
430 return false;"><label id="popup_ac_type_true" for="popup_ac_type_true" class="checked" >Numbers (1,2,3,...)</label> </a>
431 <a href="javascript: void(0)" onclick="javascript:setacgroupappend(0);
432 return false;"><label id="popup_ac_type_false" for="popup_ac_type_false">Letters (A,B,C,...)</label> </a>
433 </div>
434 </div>
435 </div>
436
437 <div id="section_progressbar" class="control-group" style="display:none;">
438 <label class="control-label" for="popup_ac_progress">Processing Groups Progress</label>
439 <div id ="progressbar">
440
441 </div>
442 </div>
443 </div>
444 <div class="modal-footer">
445 <a href="javascript: void(0)" onclick="javascript:autocreategroups();
446 return false;"><input class="btn-popup-close btn btn-success" type="button" value="Create Groups" ></a>
447 <input class="btn-popup-close btn btn-success" type="button" value="Cancel" data-dismiss="modal">
448 </div>
449</div>
450<!-- Direct Entry Group Popup-->
451<div id="direct_entry_groups_popup" name ="direct_entry_groups_popup" class="modal hide fade" role="dialog" style="height:300px; top:50px;">
452 <div class="modal-header">
453 Direct Entry Students
454 <button type="button" class="close" data-dismiss="modal" >×</button>
455 </div>
456 <div class="modal-body">
457 <div class="control-group">
458 <p>
459 This will create a new group (if one does not exist) for the students joining us from
460 other establishments.<br><br>
461 This group will be inserted into all relevant year 1 and year 2
462 events, Once this has been done, you can add and remove students from this group.<br><br>
463 These students will have access to al the relevant resources.
464 </p>
465 <div class="Processing-di" id ="Processing-di" name ="Processing-di">
466 <i class="icon-spinner icon-spin icon-large"></i> <b>processing ...</b>
467
468 </div>
469
470 </div>
471 <div class="modal-footer">
472 <a href="javascript: void(0)" onclick="javascript:createdirectentry(); return false;">
473 <input class="btn-popup-close btn btn-success" type="button" value="Create Direct Entry Group" ></a>
474 <input class="btn-popup-close btn btn-success" type="button" value="Cancel" data-dismiss="modal">
475 </div>
476 </div>
477</div>
478
479<!-- open the next container for the main page content -->
480<div class="container-fluid">
481
482 <div class="row-fluid" >
483 <div class="content-panel" >
484 <div class="row-fluid">
485 <div class="span12">
486 <!-- top panel -->
487 <ul class="nav nav-pills pull-left">
488 <li> Audience </li>
489 <?php
490 if(is_null($url_audience)){
491 $url_audience = "empty";
492 }
493 switch ($url_audience) {
494 case 'MYVLE':
495 $id = 1;
496 break;
497 case 'MYMBCHB' :
498 $id = 2;
499 break;
500 case 'MYDBS':
501 $id = 3;
502 break;
503 case 'MYPA';
504 $id = 4;
505 break;
506 case 'MYMEDSCI':
507 $id = 5;
508 break;
509 default :
510 $id = 2;
511 }
512 ?>
513
514 <li id="menu_mymbchb" class="<?php echo ($id == 2) ? 'active' : ''; ?>">
515 <a href='javascript: void(0)' onclick='javascript:setaudience("MYMBCHB");
516 return false;'>MyMBChB</a>
517 </li>
518 <li id ="menu_mybds" class="<?php echo ($id == 3) ? 'active' : ''; ?>">
519 <a href='javascript: void(0)' onclick='javascript:setaudience("MYBDS");
520 return false;'>MyBDS</a>
521 </li>
522 <li id ="menu_mypa" class="<?php echo ($id == 4) ? 'active' : ''; ?>">
523 <a href='javascript: void(0)' onclick='javascript:setaudience("MYPA");
524 return false;'>MyPA</a>
525 </li>
526 <li id ="menu_mymedsci" class="<?php echo ($id == 5) ? 'active' : ''; ?>">
527 <a href='javascript: void(0)' onclick='javascript:setaudience("MYMEDSCI");
528 return false;'>MyMedSci</a>
529 </li>
530 </ul>
531
532
533 <ul class="nav nav-pills pull-left" >
534 <li>Academic Year</li>
535 <?php
536 if($url_programmeyear === ''){
537 $url_programmeyear = 1;
538 }
539 if($url_audience == ''){
540 $url_audience = 'MYMBCHB';
541 }
542 if($url_academicyear == ''){
543 $url_academicyear = date('Y');
544 }
545 $cnt = 1;
546 $cacyr = date('Y');
547 for($i = $cacyr - 2; $i <= $cacyr + 2; $i++):
548 $id = 'menu_acyr_' . $cnt;
549 ?>
550
551 <li id='<?php echo $id; ?>' class="<?php echo ($cacyr == $i) ? 'active' : ''; ?>">
552 <a href='javascript: void(0)' onclick='javascript:setacyr(<?php echo $cnt; ?>);
553 return false;'><?php echo $i; ?> </a>
554 </li>
555 <?php
556 $cnt++;
557 endfor;
558 ?>
559 </ul>
560 <ul class="nav nav-pills pull-left" >
561 <li>Programme Year</li>
562 <?php
563 if($url_programmeyear == ''){
564 $dpy = 1;
565 $url_programmeyear = 1;
566 } else {
567 $dpy = $url_programmeyear;
568 }
569
570 for($i = 1; $i <= 5; $i++):
571 $id = 'menu_dpyr_' . $i;
572 ?>
573 <li id='<?php echo $id; ?>' class="<?php echo ($url_programmeyear == $i) ? 'active' : ''; ?>">
574 <a href='javascript: void(0)' onclick='javascript:setdpyr(<?php echo $i; ?>);
575 return false;'><?php echo $i; ?> </a>
576 </li>
577 <?php endfor; ?>
578 </ul>
579 <ul class="nav nav-pills pull-left">
580 <li>Suppressed</li>
581 <li id='suppressed_yes'><a href='javascript: void(0)' onclick='javascript:setsuppressedflag("true");
582 return false;'>Yes</a></li>
583 <li id='suppressed_no' class='active'><a href='javascript: void(0)' onclick='javascript:setsuppressedflag("false");
584 return false;'>No</a></li>
585 </ul>
586 <ul class="nav nav-pills pull-left">
587 <li>Ward Teaching</li>
588 <li id ="ward_yes"><a href='javascript: void(0)' onclick='javascript:setwardteachingflag("true");
589 return false;'>Yes</a></li>
590 <li id ="ward_no" class='active'><a href='javascript: void(0)' onclick='javascript:setwardteachingflag("false");
591 return false;'>No</a></li>
592 </ul>
593
594
595
596
597 </div>
598 </div>
599
600
601 <div class="row-fluid" style='height:100%'>
602 <div class="span12">
603 <!-- group list -->
604
605 <div id="grouplist" class="grouplist">
606 <div id="group-centre-pane" class="group-centre-pane" style='height:90%'>
607 <div id="group-header" class="group-header" >
608
609 <table class="group-centre-pane" cellpadding ="1px" style="background-color:#666" name="grouplist_hdr" id="grouplist" width ='100%'>
610 <thead>
611
612 <tr>
613 <td width='5%' align='middle' >
614 <input type='checkbox' value='ALL' class='selectall' name='selectall' id='selectall' onchange='selectall(this)'>
615 </td>
616 <td width="2%"> </td>
617 <td width="60%" align='left' >
618
619 Group Name
620 <a href='javascript: void(0)' onclick='javascript:sort("name", "asc");
621 return false;'><i class='icon-caret-up'></i></a>
622 <a href='javascript: void(0)' onclick='javascript:sort("name", "desc");
623 return false;'><i class='icon-caret-down'></i></a>
624 </td>
625 <td width="15%" align ='left'>
626
627 Members
628 <a href='javascript: void(0)' onclick='javascript:sort("count", "asc");
629 return false;'><i class='icon-caret-up'></i></a>
630 <a href='javascript: void(0)' onclick='javascript:sort("count", "desc");
631 return false;'><i class='icon-caret-down'></i></a>
632
633 </td>
634 <td align='left'>Tools </td>
635 </tr>
636 </thead>
637 </table>
638
639
640 </div>
641
642
643 <div id="group-panel" class="group-panel" style='overflow-y: scroll; height:85%'>
644 <table class="group-centre-pane" cellpadding ="1px" style="background-color:#75838C" name="grouplist" id="grouplistbody" width ='100%'>
645
646 <tbody width='100%' >
647
648 </tbody>
649 </table>
650 </div>
651
652
653 <div id="group-footer" class="group-footer" style="background-color:#666">
654 <table width='100%'>
655 <tr>
656 <td width='20%'><a href='javascript: void(0)' onclick='javascript:directentrygroupdialog(); return false;'>
657 <input class="btn-popup-add btn btn-success" type ="button" value="Direct Entry" name="direct_entry_button" id="direct_entry_button" ></a>
658 </td>
659 <td width='60%'><!--<input type="text" id="new_group_name" name="new_group_name" placeholder="New Group Name" class="input-xxlarge" style="width:80%;"/>--></td>
660 <td width='20%'><a href='javascript: void(0)' onclick='javascript:opencombinedgroupsdialog();
661 return false;'> <input class="btn-popup-add btn btn-success" type ="button" value="Combine Selected Groups" name="combine_button" id="combine_button" ></a></td>
662 <td><a href="javascript: void(0)" onclick="javascript:editrow(-1);
663 return false;"><input class="btn-popup-add btn btn-success" type ="button" value="Create Group" name="new_group" id="new_group" ></a></td>
664 <td><a href="javascript: void(0)" onclick="javascript:createrangeofnewgroups();
665 return false;"><input class="btn-popup-add btn btn-success" type ="button" value="Auto Create Groups" name="new_groups" id="new_groups" ></a></td>
666 </tr>
667 </table>
668 </div>
669 </div>
670 </div>
671 </div>
672 </div>
673 </div>
674 </div>
675</div>
676
677<!-- Combined group information (and Name entry)
678 having looked at this i feel we should have
679 a dilaog showing the user what they have selected
680 to be added to the new combined group. -->
681
682<div id="combined_groups" class="modal hide fade" role="dialog" style="height:230px; top:50px;">
683 <div class="modal-header">
684 Combined group
685 <button type="button" class="close" data-dismiss="modal" >×</button>
686 </div>
687 <div class="modal-body">
688 <div class="control-group" id="div_popup_combined_group_name">
689 <label class="control-label" for="popup_combined_group_name" id="new_group_label">Group Name</label>
690 <div class="controls">
691 <div class="div_popup_combined_group_name" id="div_popup_combined_group_name" name="div_popup_combined_group_name">
692 <input type="text" id="combined_group_name" name="combined_group_name" placeholder="Group Name" class="input-xxlarge" style="width:500px;"/>
693 </div>
694 </div>
695 </div>
696 <div class="control-group">
697 <p class="combine-text" id="combine-text" name ="combine-text"> You have selected n Groups, to be combined, this new group will contain x Users.</p>
698 </div>
699 </div>
700 <div class="modal-footer">
701 <table width="100%"><tr><td align ="left"><table><tr><td>
702 <div class="Processing-combi" id ="Processing-combi" name ="Processing-combi">
703 <i class="icon-spinner icon-spin icon-large"></i> <b>Creating new group...</b>
704
705 </div></td></tr></table>
706 </td><td align = "right"> <table><tr><td>
707 <a href="javascript: void(0)" onclick="javascript: combineselectedgroups();
708 return false;"><input class="btn-popup-close btn btn-success create-combi" name="create-combi" id="create-combi" type="button" value="Create Group" ></a>
709 </td><td>
710 <input class="btn-popup-close btn btn-success" type="button" value="Close" data-dismiss="modal">
711 </td></tr></table></td></tr></table>
712 </div>
713</div>
714
715
716
717<div id="hiddenexportdiv" style="display: none !important;" ></div>
718<div class="stage" name ="stage" id="stage" style="display: none !important; z-index: 1000000" >
719 <div id="innerspin">
720 <p><h1><i class="icon-spinner icon-spin icon-large"></i></h1></p>
721 </div>
722
723</div>
724<!-- the list of groups (select from the is {filtered} to edit etc) -->
725<script type="text/javascript">
726
727 resize();
728 $(function(){
729 $(window).resize(function(){
730
731 resize();
732
733
734 });
735 });
736 $('#Processing-di').hide();
737 $('#stage').show();
738 $('#Processing').hide();
739 $('#selectall').attr('checked', false);
740 var height = $(window).height();
741 var jsData = new Object();
742 var jsGlobal = new Object();
743 var $modal = $('#ajax-modal');
744
745 jsGlobal.currentGroup = "";
746 jsGlobal.currentUsers = Array();
747 jsGlobal.currentGroups = Array();
748 jsGlobal.userslistatload = Array();
749 jsGlobal.suppressedflag = 0;
750 jsGlobal.addedusers = Array();
751 jsGlobal.deletedusers = Array();
752 jsGlobal.AjaxRunning = false;
753 jsGlobal.wardflag = 0;
754 jsGlobal.audience = "";
755 jsGlobal.acyr = "";
756 jsGlobal.dpyr = "";
757
758 jsGlobal.images = "";
759 // edit group settings
760 jsGlobal.eg_id = "";
761 jsGlobal.eg_dypy = "";
762 jsGlobal.eg_isYearList = "";
763 jsGlobal.eg_isWardTeaching = "";
764 jsGlobal.eg_isSuppressed = "";
765 // Print Filter Dialog settings
766 jsGlobal.pr_filter_username = 1;
767 jsGlobal.pr_filter_tickbox = 1;
768 jsGlobal.pr_filter_signature = 1;
769 jsGlobal.pr_filter_photo = 1;
770 // auto create groups
771 jsGlobal.ac_groups_append = 1;
772 // print badges
773 jsGlobal.pr_badge_photo = 1;
774
775
776 // windows size
777 jsGlobal.height = 800;
778 jsGlobal.width = 600;
779 jsData.grouplist = <?php echo json_encode($grouplist); ?>;
780
781
782 $('#group-centre-pane').height(((height / 100) * 75) + 'px');
783 $('#grouplist').height(((height / 100) * 75) + 'px');
784 $('#grouplistbody').height(((height / 100) * 75) + 'px');
785
786 $(document).ready(function() {
787 // code for Year list icon tool tip (chrome compatability)
788 $("[rel=popover]").popover({'trigger': 'hover'});
789
790 // limit Number of group input on auto creat groups to numbers
791 $("#ac_group_number").keyup(function() {
792 this.value = this.value.replace(/[^0-9\.]/g, '');
793 });
794
795 jsGlobal.advsearchcontext = 0;
796 $('#selcontext').on("change", function() {
797 jsGlobal.advsearchcontext = parseInt($(this).val());
798 });
799
800 getbrowsersize();
801 setupeditgroupdialog();
802
803 setupprintfilterdialogbox();
804 setupacgroupsdialogbox();
805 checkandsetmenuitems(true);
806 setTimeout(function() {
807 populategrouplist(jsData.grouplist['custom']);
808 setupuserlist();
809 }, 1000);
810 setTimeout(function() {
811 //$('#stage').hide();
812 document.getElementById('stage').style.display = 'none !important';
813
814 }, 1000);
815 });
816
817
818 /**
819 * header sort function
820 * @author James Boag <j.boag@abdn.ac.uk>
821 * @version Feb-2014
822 * @copyright Medi-CAL Unit, University of Aberdeen
823 * @param {string} sorton the field to sort on
824 * @param {string} direction
825 * @returns {void}
826 */
827 function sort(sorton, direction) {
828 if (direction === "desc") {
829 sort_des(sorton);
830
831 } else {
832 sort_asc(sorton);
833 }
834 sort_yearlist();
835 populategrouplist(jsData.grouplist['custom']);
836 }
837
838
839 /**
840 * Sort so that the year list items are always at the top !
841 * @returns {year list at the top }
842 */
843 function sort_yearlist() {
844 var a = jsData.grouplist['custom'];
845 var swapped;
846 do {
847 swapped = false;
848 for (var i = 0; i < a.length - 1; i++) {
849 var temp = a[i];
850 if (a[i].isyearlist < a[i + 1].isyearlist) {
851 a[i] = a[i + 1];
852 a[i + 1] = temp;
853 swapped = true;
854 }
855 }
856 } while (swapped);
857 jsData.grouplist['custom'] = a;
858 }
859
860 /**
861 * sort assending
862 * @author James Boag <j.boag@abdn.ac.uk>
863 * @version Feb-2014
864 * @copyright Medi-CAL Unit, University of Aberdeen
865 * @param {string} sorton
866 * @returns {void}
867 */
868 function sort_asc(sorton) {
869 //showspinner(this);
870 var a = jsData.grouplist['custom'];
871 var swapped;
872 do {
873 swapped = false;
874 for (var i = 0; i < a.length - 1; i++) {
875 var temp = a[i];
876 if (sorton === "name") {
877 if (a[i].name.trim().toUpperCase().charCodeAt(0) > a[i + 1].name.trim().toUpperCase().charCodeAt(0)) {
878 a[i] = a[i + 1];
879 a[i + 1] = temp;
880 swapped = true;
881 }
882 }
883 if (sorton === "count") {
884 if (a[i].user.length > a[i + 1].user.length) {
885 a[i] = a[i + 1];
886 a[i + 1] = temp;
887 swapped = true;
888 }
889 }
890 }
891 } while (swapped);
892 jsData.grouplist['custom'] = a;
893 }
894
895
896
897 /**
898 * sort desending
899 * @author James Boag <j.boag@abdn.ac.uk>
900 * @version Feb-2014
901 * @copyright Medi-CAL Unit, University of Aberdeen
902 * @param {string} sorton
903 * @returns {void}
904 */
905 function sort_des(sorton) {
906 // hidespinner();
907 var a = jsData.grouplist['custom'];
908 var swapped;
909 do {
910 swapped = false;
911 for (var i = 0; i < a.length - 1; i++) {
912 var temp = a[i];
913 if (sorton === "name") {
914 if (a[i].name.trim().toUpperCase().charCodeAt(0) < a[i + 1].name.trim().toUpperCase().charCodeAt(0)) {
915 a[i] = a[i + 1];
916 a[i + 1] = temp;
917 swapped = true;
918 }
919 }
920 if (sorton === "count") {
921 if (a[i].user.length < a[i + 1].user.length) {
922 a[i] = a[i + 1];
923 a[i + 1] = temp;
924 swapped = true;
925 }
926 }
927 }
928 } while (swapped);
929 jsData.grouplist['custom'] = a;
930 }
931
932
933 function savegroupchanges() {
934 if ($('#group_name').val() !== "") {
935 $("#Processing").hide();
936 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Saving Changes...</b>';
937 $("#Processing").show().html(data).fadeIn('fast');
938 setTimeout(function() {
939
940 var x = true;
941 var ms = buildmenustring();
942
943 if ($('#group_name').val() === "") {
944 return;
945 }
946 if (jsGlobal.eg_id < 1) {
947 if ($('#group_name').val() !== "") {
948 x = checkgroupnamejs($('#group_name').val());
949 }
950 } else {
951 x = false;
952 }
953
954 if (x === false) {
955 checkEditGroupbuttons();
956 $.ajax({
957 type: "GET",
958 async: false,
959 cache: true,
960 url: window.location + "/ajax_editgroup",
961 data: {
962 id: jsGlobal.eg_id,
963 degprogyr: jsGlobal.eg_dypy,
964 suppressed: jsGlobal.eg_isSuppressed,
965 ward: jsGlobal.eg_isWardTeaching,
966 yearlist: jsGlobal.eg_isYearList,
967 groupname: $('#group_name').val(),
968 newgroup: jsGlobal.newGroup,
969 audience: jsGlobal.audience,
970 acyr: jsGlobal.acyr,
971 menustring: ms
972 }, dataType: "json"
973
974 });
975
976 $('#edit_group_popup').modal('hide');
977 reloaddata();
978 } else {
979 alert("Group name already taken in this context !");
980 }
981 }, 1000);
982 } else {
983 alert("Please enter a name for the Group");
984 }
985 }
986
987
988
989 // edit group buttons
990 /*
991 * set the value of the degree program year Var
992 * javascript
993 *
994 * based on the current group.
995 * @author James Boag <j.boag@abdn.ac.uk>
996 * @version 27-January-2014
997 * @copyright Medi-CAL Unit, University of Aberdeen
998 *
999 * @param int value 1 to 5
1000
1001 */
1002 function edit_group_dpy(value) {
1003 edit_group_dyp_alloff();
1004 if (parseInt(value) === 1) {
1005 $("#dpyr_1").addClass('checked');
1006 $("#dpyr_2").addClass('unchecked');
1007 $("#dpyr_3").addClass('unchecked');
1008 $("#dpyr_4").addClass('unchecked');
1009 $("#dpyr_5").addClass('unchecked');
1010 jsGlobal.eg_dypy = 1;
1011 }
1012 if (parseInt(value) === 2) {
1013 $("#dpyr_1").addClass('unchecked');
1014 $("#dpyr_2").addClass('checked');
1015 $("#dpyr_3").addClass('unchecked');
1016 $("#dpyr_4").addClass('unchecked');
1017 $("#dpyr_5").addClass('unchecked');
1018 jsGlobal.eg_dypy = 2;
1019 }
1020 if (parseInt(value) === 3) {
1021 $("#dpyr_1").addClass('unchecked');
1022 $("#dpyr_2").addClass('unchecked');
1023 $("#dpyr_3").addClass('checked');
1024 $("#dpyr_4").addClass('unchecked');
1025 $("#dpyr_5").addClass('unchecked');
1026 jsGlobal.eg_dypy = 3;
1027 }
1028 if (parseInt(value) === 4) {
1029 $("#dpyr_1").addClass('unchecked');
1030 $("#dpyr_2").addClass('unchecked');
1031 $("#dpyr_3").addClass('unchecked');
1032 $("#dpyr_4").addClass('checked');
1033 $("#dpyr_5").addClass('unchecked');
1034 jsGlobal.eg_dypy = 4;
1035 }
1036 if (parseInt(value) === 5) {
1037 $("#dpyr_1").addClass('unchecked');
1038 $("#dpyr_2").addClass('unchecked');
1039 $("#dpyr_3").addClass('unchecked');
1040 $("#dpyr_4").addClass('unchecked');
1041 $("#dpyr_5").addClass('checked');
1042 jsGlobal.eg_dypy = 5;
1043 }
1044 }
1045
1046 /*
1047 * reset the degree program year value.
1048 * javascript
1049 *
1050 * based on the current group.
1051 * @author James Boag <j.boag@abdn.ac.uk>
1052 * @version 27-January-2014
1053 * @copyright Medi-CAL Unit, University of Aberdeen
1054
1055
1056 */
1057 function edit_group_dyp_alloff() {
1058 $('#dpyr_1').removeClass('checked');
1059 $('#dpyr_2').removeClass('checked');
1060 $('#dpyr_3').removeClass('checked');
1061 $('#dpyr_4').removeClass('checked');
1062 $('#dpyr_5').removeClass('checked');
1063 $('#dpyr_1').removeClass('unchecked');
1064 $('#dpyr_2').removeClass('unchecked');
1065 $('#dpyr_3').removeClass('unchecked');
1066 $('#dpyr_4').removeClass('unchecked');
1067 $('#dpyr_5').removeClass('unchecked');
1068 }
1069
1070 /*
1071 * Changes the value of the isSuppressed Var
1072 * javascript
1073 *
1074 * based on the current group.
1075 * @author James Boag <j.boag@abdn.ac.uk>
1076 * @version 27-January-2014
1077 * @copyright Medi-CAL Unit, University of Aberdeen
1078 *
1079 * @param int value 0 for no 1 for yes
1080
1081 */
1082 function edit_group_issuppressed(value) {
1083 $('#issuppressed_false').removeClass('checked');
1084 $('#issuppressed_true').removeClass('checked');
1085 $('#issuppressed_false').removeClass('unchecked');
1086 $('#issuppressed_true').removeClass('unchecked');
1087 if (value === true) {
1088 $('#issuppressed_true').addClass('checked');
1089 $('#issuppressed_false').addClass('unchecked');
1090 jsGlobal.eg_isSuppressed = 1;
1091 }
1092 if (value === false) {
1093 $('#issuppressed_false').addClass('checked');
1094 $('#issuppressed_true').addClass('unchecked');
1095 jsGlobal.eg_isSuppressed = 0;
1096 }
1097 }
1098
1099 /*
1100 * Changes the value of the isWardTeaching Var
1101 * javascript
1102 *
1103 * based on the current group.
1104 * @author James Boag <j.boag@abdn.ac.uk>
1105 * @version 27-January-2014
1106 * @copyright Medi-CAL Unit, University of Aberdeen
1107 *
1108 * @param int value 0 for no 1 for yes
1109
1110 */
1111 function edit_group_isward(value) {
1112 $('#isward_true').removeClass('checked');
1113 $('#isward_false').removeClass('checked');
1114 $('#isward_true').removeClass('unchecked');
1115 $('#isward_false').removeClass('unchecked');
1116 if (value === true) {
1117 $('#isward_true').addClass('checked');
1118 $('#isward_false').addClass('unchecked');
1119 jsGlobal.eg_isWardTeaching = 1;
1120 }
1121 if (value === false) {
1122 $('#isward_true').addClass('unchecked');
1123 $('#isward_false').addClass('checked');
1124 jsGlobal.eg_isWardTeaching = 0;
1125 }
1126 }
1127
1128 /*
1129 * Changes the value of the isYearList Var
1130 * javascript
1131 *
1132 * based on the current group.
1133 * @author James Boag <j.boag@abdn.ac.uk>
1134 * @version 27-January-2014
1135 * @copyright Medi-CAL Unit, University of Aberdeen
1136 *
1137 * @param int value 0 for no 1 for yes
1138
1139 */
1140
1141 function edit_group_yearlist(value) {
1142 $('#isyearlist_true').removeClass('unchecked');
1143 $('#isyearlist_false').removeClass('unchecked');
1144 $('#isyearlist_true').removeClass('checked');
1145 $('#isyearlist_false').removeClass('checked');
1146 if (value === true) {
1147 $('#isyearlist_false').addClass('unchecked');
1148 $('#isyearlist_true').addClass('checked');
1149 jsGlobal.eg_isYearList = 1;
1150 }
1151 if (value === false) {
1152 $('#isyearlist_true').addClass('unchecked');
1153 $('#isyearlist_false').addClass('checked');
1154 jsGlobal.eg_isYearList = 0;
1155 }
1156 }
1157
1158
1159 /**
1160 * checkEditGroupbuttons
1161 *
1162 * set up the buttons for the edit group dialog
1163 *
1164 *
1165 * @author James Boag <j.boag@abdn.ac.uk>
1166 * @version march-2014
1167 * @copyright Medi-CAL Unit, University of Aberdeen
1168 *
1169 **/
1170 function checkEditGroupbuttons() {
1171 if ($('#isyearlist_false').hasClass('checked')) {
1172 jsGlobal.eg_isYearList = 0;
1173 }
1174 if ($('#isyearlist_true').hasClass('checked')) {
1175 jsGlobal.eg_isYearList = 1;
1176 }
1177 if ($('#isward_false').hasClass('checked')) {
1178 jsGlobal.eg_isWardTeaching = 0;
1179 }
1180 if ($('#isward_true').hasClass('checked')) {
1181 jsGlobal.eg_isWardTeaching = 1;
1182 }
1183 if ($('#issuppressed_true').hasClass('checked')) {
1184 jsGlobal.eg_isSuppressed = 1;
1185 }
1186 if ($('#issuppressed_false').hasClass('checked')) {
1187 jsGlobal.eg_isSuppressed = 0;
1188 }
1189 if ($('#dpyr_1').hasClass('checked')) {
1190 jsGlobal.eg_dypy = 1;
1191 }
1192 if ($('#dpyr_2').hasClass('checked')) {
1193 jsGlobal.eg_dypy = 2;
1194 }
1195 if ($('#dpyr_3').hasClass('checked')) {
1196 jsGlobal.eg_dypy = 3;
1197 }
1198 if ($('#dpyr_4').hasClass('checked')) {
1199 jsGlobal.eg_dypy = 4;
1200 }
1201 if ($('#dpyr_5').hasClass('checked')) {
1202 jsGlobal.eg_dypy = 5;
1203 }
1204
1205 }
1206
1207
1208
1209 /**
1210 * refreshcurrentusersdata
1211 *
1212 * Check for changes
1213 *
1214 * @author James Boag <j.boag@abdn.ac.uk>
1215 * @version march-2014
1216 * @copyright Medi-CAL Unit, University of Aberdeen
1217 *
1218 * Get the user list on load
1219 * check for new users that have been added
1220 * check for deleted users that have been removed.
1221 * */
1222 function refreshcurrentusersdata() {
1223 pulluserlistasitcurentlyis();
1224 checkfornewusers();
1225 checkfordeletedusers();
1226
1227 }
1228 /**
1229 * pulluserlistasitcurentlyis
1230 *
1231 * Pull the userlist as it was prior to edit
1232 *
1233 * @author James Boag <j.boag@abdn.ac.uk>
1234 * @version march-2014
1235 * @copyright Medi-CAL Unit, University of Aberdeen
1236 *
1237 * */
1238 function pulluserlistasitcurentlyis() {
1239 jsGlobal.addedusers = Array();
1240 $('#usercontent').each(function(i, row) {
1241 $(this).find('tr').each(function(j, innerrow) {
1242 jsGlobal.addedusers.push(innerrow.getAttribute('id'));
1243 });
1244
1245 });
1246 }
1247
1248
1249
1250
1251 function createdirectentry(){
1252 $('#busy').show();
1253 // create the group
1254 $direct_entry_id = createdirectentrygroup();
1255 $('#busy').hide();
1256 $('#direct_entry_groups_popup').modal('hide');
1257 reloaddata();
1258 }
1259
1260 /**
1261 * processeditusers
1262 *
1263 * Process the changes made by the user
1264 *
1265 * @author James Boag <j.boag@abdn.ac.uk>
1266 * @version march-2014
1267 * @copyright Medi-CAL Unit, University of Aberdeen
1268 *
1269 * Refesh the globals that hole the changes
1270 *
1271 * save shanges to the DB
1272 * hide the dialog
1273 *
1274 * */
1275
1276 function processeditusers() {
1277
1278
1279 // do ajax!
1280
1281 refreshcurrentusersdata();
1282 var groupid = jsGlobal.currentGroup;
1283 var addusers = jsGlobal.addedusers;
1284 var delusers = jsGlobal.deletedusers;
1285 var menustring = buildmenustring();
1286
1287 $.ajax({
1288 type: "GET",
1289 async: false,
1290 cache: false,
1291 url: window.location + "/ajax_updategroupusers",
1292 data: {groupid: groupid,
1293 delusers: delusers,
1294 menustring: menustring,
1295 addusers: addusers
1296 }, dataType: "json"
1297 });
1298
1299 $('#edit_group_user_popup').modal('hide');
1300 jsGlobal.userslistatload.splice(0, jsGlobal.userslistatload);
1301 reloaddata();
1302 //------------------------------------------------------------------------------
1303 //
1304 var data = '';
1305 $("#Processingusers").hide().html(data).fadeOut('fast');
1306 }
1307
1308 /**
1309 * posteditusers
1310 *
1311 * Process the changes made by the user header function
1312 *
1313 * @author James Boag <j.boag@abdn.ac.uk>
1314 * @version march-2014
1315 * @copyright Medi-CAL Unit, University of Aberdeen
1316 *
1317 * show the busy text
1318 * call the processeditusers
1319 *
1320 *
1321 **/
1322 function posteditusers() {
1323 //------------------------------------------------------------------------------
1324 $("#Processingusers").hide();
1325 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Saving Changes...</b>';
1326 $("#Processingusers").show().html(data).fadeIn('fast');
1327 setTimeout(function() {
1328 // showspinner('user');
1329 processeditusers();
1330 }, 1000);
1331 }
1332
1333 function checkgroupnamejs(groupname) {
1334 var fail = false;
1335 var n = jsData.grouplist.custom.length;
1336 for (var i = 0; i < n; i++) {
1337 var data = jsData.grouplist.custom[i];
1338 if (data.name === groupname) {
1339 fail = true;
1340 }
1341 }
1342 return fail;
1343 }
1344 /**
1345 * setupuserlist
1346 *
1347 * set up the chosen component (drop down)
1348 * for the user list
1349 *
1350 * @author James Boag <j.boag@abdn.ac.uk>
1351 * @version march-2014
1352 * @copyright Medi-CAL Unit, University of Aberdeen
1353 *
1354 **/
1355 function setupuserlist() {
1356 $('#selAttendees_Chosen').html('<select name="users" data-placeholder="Find" class="chzn-container chzn-container-single chzn-with-drop chzn-container-active input-xxlarge" multiple style="width:250px;" tabindex ="-1" id="selAttendees_Chosen" name ="users">' + loaduserlist() + '</select>');
1357 $('#selAttendees_Chosen').chosen({width: "450px"});
1358 $('#selAttendees_Chosen').trigger('chosen:updated');
1359 }
1360
1361
1362 function directentrygroupdialog(){
1363 $('#direct_entry_groups_popup').modal('show');
1364 $('#Processing-di').hide();
1365 /* var direct_entry_id = createdirectentrygroup();
1366
1367 reloaddata();
1368 alert('directentrygroupdialog ::' + direct_entry_id);
1369 this.editusers(direct_entry_id);
1370 */
1371 }
1372
1373
1374
1375
1376 /*
1377 * create a direct entry group
1378 * javascript
1379 *
1380 * create an emtpy group to fill with a list of direct entry students.
1381 * @author James Boag <j.boag@abdn.ac.uk>
1382 * @version 27-April-2015
1383 * @copyright Medi-CAL Unit, University of Aberdeen
1384 *
1385 */
1386 function createdirectentrygroup(){
1387 $("#Processing-di").hide();
1388 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Creating Group</b>';
1389 $("#Processing-di").show().html(data).fadeIn('fast');
1390 setTimeout(function() {
1391 // showspinner('user');
1392 }, 1000);
1393
1394 var group_name = "DIRECT ENTRY GROUP FOR "+jsGlobal.audience.toUpperCase()+" "+jsGlobal.acyr+" Year "+jsGlobal.dpyr;
1395 if (checkgroupnamejs(group_name) === false) {
1396 $.ajax({
1397 type: "GET",
1398 async: false,
1399 cache: true,
1400 url: window.location + "/ajax_creategroup",
1401 data: {
1402 audience: jsGlobal.audience,
1403 degprogyr: jsGlobal.dpyr,
1404 acyr: jsGlobal.acyr,
1405 suppressed: jsGlobal.suppressedflag,
1406 ward: jsGlobal.wardflag,
1407 groupname: group_name ,
1408 userlist: "NONE"
1409 }, dataType: "json"
1410 });
1411 var response = this.dodirectentrygroups(group_name);
1412 return response;
1413
1414 } else {
1415 //tell user that group already exists !!!
1416 alert("Group already exists !");
1417 }
1418 }
1419
1420
1421 function dodirectentrygroups(group_name) {
1422
1423 var callajax = directentryajax(group_name);
1424 var retval = processdirectentry(callajax);
1425 return retval;
1426 }
1427
1428
1429 function directentryajax(group_name){
1430 return $.ajax({
1431 type: "GET",
1432 async: false,
1433 cache: true,
1434 url: window.location + "/ajax_directentrygroup",
1435 data: {
1436 groupname : group_name ,
1437 acyr: jsGlobal.acyr
1438 },
1439 dataType: 'json'
1440 });
1441
1442 }
1443
1444 function processdirectentry(x){
1445 x.success(function(resultarray) {
1446 return x;
1447 });
1448
1449 }
1450
1451 // keep the numberic inputs as numeric only !
1452 $('#group_number').keypress(function(event) {
1453 // Backspace, tab, enter, end, home, left, right
1454 // We don't support the del key in Opera because del == . == 46.
1455 var controlKeys = [8, 9, 13, 35, 36, 37, 39];
1456 // IE doesn't support indexOf
1457 var isControlKey = controlKeys.join(",").match(new RegExp(event.which));
1458 // Some browsers just don't raise events for control keys. Easy.
1459 // e.g. Safari backspace.
1460 if (!event.which || // Control keys in most browsers. e.g. Firefox tab is 0
1461 (49 <= event.which && event.which <= 57) || // Always 1 through 9
1462 (48 == event.which && $(this).attr("value")) || // No 0 first digit
1463 isControlKey) { // Opera assigns values for control keys.
1464 return;
1465 } else {
1466 event.preventDefault();
1467 }
1468 });
1469
1470
1471
1472 // trying to control the size of the screen
1473 function getbrowsersize() {
1474 jsGlobal.height = $(window).height();
1475 jsGlobal.width = $(window).width();
1476 resize();
1477 }
1478
1479 function resize() {
1480 var height = ((parseInt($(window).height())/100)*97);
1481 $('#body').css('height',height+"px");
1482 console.log("New Height is "+height+" px");
1483
1484 $('#group-centre-pane').css(" style='height:75%'");
1485 $('#group-panel').css(" style='height:60%'");
1486
1487 }
1488 /*
1489 * header function to produce a pdf report
1490 * based on the current group.
1491 * @author James Boag <j.boag@abdn.ac.uk>
1492 * @version 27-January-2014
1493 * @copyright Medi-CAL Unit, University of Aberdeen
1494 */
1495 function producereport() {
1496 $('#Processingrpt').hide();
1497 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Preparing Report..</b>';
1498 $('#Processingrpt').show().html(data).fadeIn('fast');
1499 setTimeout(function() {
1500 //---------------------------------------------------------------------------------:)
1501 if (parseInt(jsGlobal.pr_filter_photo) === 1) {
1502 var photo = "1";
1503 } else {
1504 var photo = "0"
1505 }
1506 if (parseInt(jsGlobal.pr_filter_username) === 1) {
1507 var username = "1";
1508 } else {
1509 var username = "0";
1510 }
1511 if (parseInt(jsGlobal.pr_filter_tickbox) === 1) {
1512 var tickbox = "1";
1513 } else {
1514 var tickbox = "0";
1515 }
1516 if (parseInt(jsGlobal.pr_filter_signature) === 1) {
1517 var signaturebox = "1";
1518 } else {
1519 var signaturebox = "0";
1520 }
1521 var fields = username + "|" + tickbox + "|" + signaturebox + "|" + photo;
1522 var ms = buildmenustring();
1523 doreport(fields, ms);
1524 }, 1000);
1525 }
1526
1527
1528 function processreport(x) {
1529 x.success(function(resultarray) {
1530 var len = resultarray.length;
1531 var path = "";
1532 for (var i = 0; i < len; i++) {
1533 path = path + resultarray[i];
1534 }
1535 showreport(path);
1536 });
1537 }
1538
1539 function showreport(path) {
1540 var data = '';
1541 $("#Processingrpt").hide().html(data).fadeOut('fast');
1542 // l.stop();
1543 $('#print_popup').modal('hide');
1544 window.open(path, '_blank', "menubar=no,status=no");
1545 }
1546
1547
1548 function doreport(fields, ms) {
1549
1550 var callajax = call_ajax(fields, ms);
1551 var retval = processreport(callajax);
1552 }
1553
1554 function call_ajax(fields, ms) {
1555 return $.ajax({
1556 type: "GET",
1557 async: false,
1558 cache: true,
1559 url: window.location + "/ajax_pdf",
1560 data: {
1561 id: jsGlobal.currentGroup,
1562 menustring: ms,
1563 options: fields
1564 }, dataType: "json"
1565 });
1566 }
1567
1568 /*
1569 * Call buttonset on all buttons used in the
1570 * print report dilaog.
1571 * @author James Boag <j.boag@abdn.ac.uk>
1572 * @version 27-January-2014
1573 * @copyright Medi-CAL Unit, University of Aberdeen
1574 */
1575 function setupprintfilterdialogbox() {
1576 $('#printusernamebtnset').buttonset();
1577 $('#div_popup_Print_Tickbox').buttonset();
1578 $('#div_popup_Print_Sigbox').buttonset();
1579 $('#div_popup_Print_Photobox').buttonset();
1580 $('#div_popup_Print_Badge_Photobox').buttonset();
1581 printdialogbuttons();
1582 }
1583
1584 //apply the buttonset to the auto create dialog.
1585 function setupacgroupsdialogbox() {
1586 $('#div_popup_ac_type').buttonset();
1587 acdialogbuttons();
1588
1589 }
1590
1591 /**
1592 *
1593 * @author James Boag <j.boag@abdn.ac.uk>
1594 * @version Feb-2014
1595 * @copyright Medi-CAL Unit, University of Aberdeen
1596 *
1597 * set up the buttonsets for the group edit dialog
1598 */
1599 function setupeditgroupdialog() {
1600 $('#popup_group_dpyr').buttonset();
1601 $('#isyearlistbtnset').buttonset();
1602 $('#iswardbtnset').buttonset();
1603 $('#issuppressedbtnset').buttonset();
1604
1605
1606 }
1607 //set auto create dialog vbuttons to the correct value
1608 function acdialogbuttons() {
1609 setacgroupappend(jsGlobal.ac_groups_append);
1610 }
1611 /*
1612 * set the default values for the buttons
1613 * on the print dilaog
1614 *
1615 * @author James Boag <j.boag@abdn.ac.uk>
1616 * @version 27-January-2014
1617 * @copyright Medi-CAL Unit, University of Aberdeen
1618 */
1619 function printdialogbuttons() {
1620 setprintdialogusername(jsGlobal.pr_filter_username);
1621 setprintdilalogtickbox(jsGlobal.pr_filter_tickbox);
1622 setprintdialogsignature(jsGlobal.pr_filter_signature);
1623 setprintdilaogphoto(jsGlobal.pr_filter_photo);
1624 setprintbadgephoto(jsGlobal.pr_badge_photo);
1625 }
1626
1627 /*
1628 * Call buttonset on all buttons used in the
1629 * print badges dilaog.
1630 * @author James Boag <j.boag@abdn.ac.uk>
1631 * @version 27-January-2014
1632 * @copyright Medi-CAL Unit, University of Aberdeen
1633 */
1634 function setprintbadgephoto(value) {
1635 $('#popupprintbadgephotobox_true').removeClass('checked');
1636 $('#popupprintbadgephotobox_false').removeClass('checked');
1637 $('#popupprintbadgephotobox_true').removeClass('unchecked');
1638 $('#popupprintbadgephotobox_false').removeClass('unchecked');
1639 if (parseInt(value) === 1) {
1640 $('#popupprintbadgephotobox_true').addClass('checked');
1641 $('#popupprintbadgephotobox_false').addClass('unchecked');
1642 jsGlobal.pr_badge_photo = 1;
1643 } else {
1644 $('#popupprintbadgephotobox_false').addClass('checked');
1645 $('#popupprintbadgephotobox_true').addClass('unchecked');
1646 jsGlobal.pr_badge_photo = 0;
1647 }
1648 }
1649
1650 /*
1651 * Call buttonset on all buttons used in the
1652 * auto create group dilaog.
1653 * @author James Boag <j.boag@abdn.ac.uk>
1654 * @version 27-January-2014
1655 * @copyright Medi-CAL Unit, University of Aberdeen
1656 */
1657 function setacgroupappend(value) {
1658 $('#popup_ac_type_true').removeClass("checked");
1659 $('#popup_ac_type_false').removeClass("checked");
1660 $('#popup_ac_type_true').removeClass("unchecked");
1661 $('#popup_ac_type_false').removeClass("unchecked");
1662 if (parseInt(value) === 1) {
1663 $('#popup_ac_type_false').addClass("unchecked");
1664 $('#popup_ac_type_true').addClass("checked");
1665 jsGlobal.ac_groups_append = 1;
1666 } else {
1667 $('#popup_ac_type_true').addClass("unchecked");
1668 $('#popup_ac_type_false').addClass("checked");
1669 jsGlobal.ac_groups_append = 0;
1670 }
1671 }
1672
1673 /*
1674 * set the print dilaog photo button
1675 *
1676 * based on the value
1677 * .
1678 * @author James Boag <j.boag@abdn.ac.uk>
1679 * @version 27-January-2014
1680 * @copyright Medi-CAL Unit, University of Aberdeen
1681 * @param value int 1 for on 0 for off
1682 *
1683 */
1684 function setprintdilaogphoto(value) {
1685 $('#popupprintphotobox_true').removeClass("checked");
1686 $('#popupprintphotobox_false').removeClass("checked");
1687 $('#popupprintphotobox_true').removeClass("unchecked");
1688 $('#popupprintphotobox_false').removeClass("unchecked");
1689 if (parseInt(value) === 1) {
1690 $('#popupprintphotobox_true').addClass("checked");
1691 $('#popupprintphotobox_false').addClass("unchecked");
1692 jsGlobal.pr_filter_photo = 1;
1693 } else {
1694 $('#popupprintphotobox_false').addClass("checked");
1695 $('#popupprintphotobox_true').addClass("unchecked");
1696 jsGlobal.pr_filter_photo = 0;
1697 }
1698 }
1699
1700 /*
1701 * set the Print dialog Signatue option
1702 *
1703 * based on the current group.
1704 * @author James Boag <j.boag@abdn.ac.uk>
1705 * @version 27-January-2014
1706 * @copyright Medi-CAL Unit, University of Aberdeen
1707 *
1708 * @param value int 1 for on 0 for off
1709 */
1710 function setprintdialogsignature(value) {
1711 $('#popupprintsigbox_true').removeClass("checked");
1712 $('#popupprintsigbox_false').removeClass("checked");
1713 $('#popupprintsigbox_true').removeClass("unchecked");
1714 $('#popupprintsigbox_false').removeClass("unchecked");
1715 if (parseInt(value) === 1) {
1716 $('#popupprintsigbox_true').addClass("checked");
1717 $('#popupprintsigbox_false').addClass("unchecked");
1718 jsGlobal.pr_filter_signature = 1;
1719 } else {
1720 $('#popupprintsigbox_true').addClass("unchecked");
1721 $('#popupprintsigbox_false').addClass("checked");
1722 jsGlobal.pr_filter_signature = 0;
1723 }
1724 }
1725
1726 /*
1727 * set the Print dialog tick box option
1728 *
1729 * based on the current group.
1730 * @author James Boag <j.boag@abdn.ac.uk>
1731 * @version 27-January-2014
1732 * @copyright Medi-CAL Unit, University of Aberdeen
1733 *
1734 * @param value int 1 for on 0 for off
1735 */
1736 function setprintdilalogtickbox(value) {
1737 $('#popupprinttickbox_true').removeClass("checked");
1738 $('#popupprinttickbox_false').removeClass("checked");
1739 $('#popupprinttickbox_true').removeClass("unchecked");
1740 $('#popupprinttickbox_false').removeClass("unchecked");
1741 if (parseInt(value) === 1) {
1742 $('#popupprinttickbox_false').addClass("unchecked");
1743 $('#popupprinttickbox_true').addClass("checked");
1744 jsGlobal.pr_filter_tickbox = 1;
1745 } else {
1746 $('#popupprinttickbox_true').addClass("unchecked");
1747 $('#popupprinttickbox_false').addClass("checked");
1748 jsGlobal.pr_filter_tickbox = 0;
1749 }
1750 }
1751
1752 /*
1753 * set the Print dialog username option
1754 *
1755 * based on the current group.
1756 * @author James Boag <j.boag@abdn.ac.uk>
1757 * @version 27-January-2014
1758 * @copyright Medi-CAL Unit, University of Aberdeen
1759 *
1760 * @param value int 1 for on 0 for off
1761 */
1762 function setprintdialogusername(value) {
1763 $('#popupprintusername_true').removeClass("checked");
1764 $('#popupprintusername_false').removeClass("checked");
1765 $('#popupprintusername_true').removeClass("unchecked");
1766 $('#popupprintusername_false').removeClass("unchecked");
1767 if (parseInt(value) === 1) {
1768 $('#popupprintusername_false').addClass("unchecked");
1769 $('#popupprintusername_true').addClass("checked");
1770 jsGlobal.pr_filter_username = 1;
1771 } else {
1772 $('#popupprintusername_true').addClass("unchecked");
1773 $('#popupprintusername_false').addClass("checked");
1774 jsGlobal.pr_filter_username = 0;
1775 }
1776 }
1777
1778 /*
1779 * produce the html for the report based on
1780 * the print dialog settings
1781 *
1782 * based on the current group.
1783 * @author James Boag <j.boag@abdn.ac.uk>
1784 * @version 27-January-2014
1785 * @copyright Medi-CAL Unit, University of Aberdeen
1786 *
1787 * @return reportHTML String holding the html used in the report.
1788 */
1789 function produceprintdata() {
1790 var groupid = jsGlobal.currentGroup;
1791 //alert(jsGlobal.currentGroup);
1792 getuserimages(jsGlobal.currentGroup);
1793 var data = getgrouplistforgroup(groupid);
1794 var len = data.length;
1795 var record = "";
1796
1797 var reportHTML = reportbuildheader();
1798 reportHTML = reportHTML + reportbuilddatahdr();
1799 for (var i = 0; i < len; i++) {
1800 record = data[i];
1801 reportHTML = reportHTML + reportbuilddatarow(record);
1802 }
1803
1804 reportHTML = reportHTML + reportbuilddatafooter();
1805 jsGlobal.report = reportHTML;
1806 return reportHTML;
1807 }
1808
1809 /*
1810 * Get the url for the image of a user from the
1811 * javascript
1812 *
1813 * based on the current group.
1814 * @author James Boag <j.boag@abdn.ac.uk>
1815 * @version 27-January-2014
1816 * @copyright Medi-CAL Unit, University of Aberdeen
1817 *
1818 * @param userid int
1819 * @return string the url for the image
1820 */
1821 function getimageurls(userid) {
1822 var len = jsGlobal.images.length;
1823 var record = "";
1824 for (var i = 0; i < len; i++) {
1825 record = jsGlobal.images[i];
1826 if (parseInt(record.userid) === parseInt(userid)) {
1827 return record.url;
1828 }
1829 }
1830
1831 }
1832
1833 /*
1834 * get a group name based on it's id
1835 * javascript
1836 *
1837 * based on the current group.
1838 * @author James Boag <j.boag@abdn.ac.uk>
1839 * @version 27-January-2014
1840 * @copyright Medi-CAL Unit, University of Aberdeen
1841 *
1842 * @param int groupid
1843 * @return string the groups name
1844 */
1845
1846 function getgroupname(groupid) {
1847 var len = jsData.grouplist.custom.length;
1848 var record = "";
1849 for (var i = 0; i < len; i++) {
1850 record = jsData.grouplist.custom[i];
1851 if (parseInt(record.id) === parseInt(groupid)) {
1852 return record.name;
1853 }
1854 }
1855 }
1856
1857 /*
1858 * get a list of users that belong to the group
1859 * javascript
1860 *
1861 * based on the current group.
1862 * @author James Boag <j.boag@abdn.ac.uk>
1863 * @version 27-January-2014
1864 * @copyright Medi-CAL Unit, University of Aberdeen
1865 *
1866 * @param int groupid
1867 * @return array the groups user list */
1868 function getgrouplistforgroup(groupid) {
1869 var len = jsData.grouplist['custom'].length;
1870 var item = "";
1871 for (var i = 0; i < len; i++) {
1872 item = jsData.grouplist['custom'][i];
1873 if (parseInt(item.id) === parseInt(groupid)) {
1874 return item.user;
1875
1876 }
1877 }
1878 }
1879
1880
1881 /*
1882 * get the html for the report header
1883 *
1884 * based on the current group.
1885 * @author James Boag <j.boag@abdn.ac.uk>
1886 * @version 27-January-2014
1887 * @copyright Medi-CAL Unit, University of Aberdeen
1888 *
1889 * @return string the groups name as html
1890 */
1891 function reportbuildheader() {
1892 var name = getgroupname(jsGlobal.currentGroup);
1893
1894 var header = "<table ><thead><tr><td>" + name + "</td></tr></thead></table>";
1895 return header;
1896 }
1897
1898 /*
1899 * get the table header for the report based on the settings
1900 * javascript
1901 *
1902 * based on the current group.
1903 * @author James Boag <j.boag@abdn.ac.uk>
1904 * @version 27-January-2014
1905 * @copyright Medi-CAL Unit, University of Aberdeen
1906 *
1907 * @return string the html for the table header for the group list
1908 */
1909 function reportbuilddatahdr() {
1910 var header = "<table border ='1'><thead><tr>";
1911 if (parseInt(jsGlobal.pr_filter_photo) === 1) {
1912 header = header + "<td width='10%'>Photo</td>";
1913
1914 }
1915 if (parseInt(jsGlobal.pr_filter_username) === 1) {
1916 header = header + "<td width ='20%'>Username</td>";
1917 }
1918 header = header + "<td width ='40%'>Student</td>";
1919 if (parseInt(jsGlobal.pr_filter_tickbox) === 1) {
1920 header = header + "<td width = '10%'>Tick</td>";
1921 }
1922 if (parseInt(jsGlobal.pr_filter_signature) === 1) {
1923 header = header + "<td width = '30%'>Signature</td>";
1924 }
1925 header = header + "</tr></thead><tbody>";
1926 return header;
1927
1928 }
1929
1930 /*
1931 * get the table data for the report based on the settings
1932 * javascript
1933 *
1934 * based on the current group.
1935 * @author James Boag <j.boag@abdn.ac.uk>
1936 * @version 27-January-2014
1937 * @copyright Medi-CAL Unit, University of Aberdeen
1938 *
1939 * @return string the html for the table data for the group list
1940 */
1941 function reportbuilddatarow(row) {
1942 var newrow = "<tr>";
1943 if (parseInt(jsGlobal.pr_filter_photo) === 1) {
1944 var url = getimageurls(row.id);
1945 newrow = newrow + "<td width='10%'><img src=" + url + "></td>";
1946 }
1947 if (parseInt(jsGlobal.pr_filter_username) === 1) {
1948 newrow = newrow + "<td width='20%'>" + row.username + "</td>";
1949 }
1950 var beef = row.lastname.toUpperCase() + " " + row.firstname.charAt(0).toUpperCase() + row.firstname.slice(1);
1951 newrow = newrow + "<td width='40%'>" + beef + "</td>";
1952 if (parseInt(jsGlobal.pr_filter_tickbox) === 1) {
1953 newrow = newrow + "<td width = '10%'></td>";
1954 }
1955 if (parseInt(jsGlobal.pr_filter_signature) === 1) {
1956 newrow = newrow + "<td width = '30%'></td>";
1957 }
1958 newrow = newrow + "</tr>";
1959 return newrow;
1960 }
1961
1962 /*
1963 * get the table footer
1964 *
1965 * javascript
1966 *
1967 * based on the current group.
1968 * @author James Boag <j.boag@abdn.ac.uk>
1969 * @version 27-January-2014
1970 * @copyright Medi-CAL Unit, University of Aberdeen
1971 *
1972 * @return string the html to end the report.
1973 */
1974 function reportbuilddatafooter() {
1975 var footer = "</tbody></table>";
1976 return footer;
1977 }
1978
1979
1980 /*
1981 * get a group record by it's key
1982 * javascript
1983 *
1984 * based on the current group.
1985 * @author James Boag <j.boag@abdn.ac.uk>
1986 * @version 27-January-2014
1987 * @copyright Medi-CAL Unit, University of Aberdeen
1988 *
1989 * @param int key
1990 * @return object group recoed including it's users.
1991 */
1992 function findagrouprecordbykey(key) {
1993 jsGlobal.userslistatload.splice(0, jsGlobal.userslistatload);
1994 var list = jsData.grouplist['custom'];
1995 var n = list.length;
1996 for (var i = 0; i < n; i++) {
1997 var item = list[i];
1998 if (parseInt(item.id) === parseInt(key)) {
1999 return item;
2000 }
2001 }
2002 return "not found";
2003 }
2004
2005 /*
2006 * create the main table in the groups tabs
2007 * javascript
2008 *
2009 * based on the current group.
2010 * @author James Boag <j.boag@abdn.ac.uk>
2011 * @version 27-January-2014
2012 * @copyright Medi-CAL Unit, University of Aberdeen
2013 *
2014 * @param onject list
2015 */
2016 function populategrouplist(list) {
2017 $('#stage').show();
2018 setTimeout(function() {
2019 $('#grouplistbody').html('<table id="grouplist" class="group-centre-pane table-body navbar-inner" width="100%" cellpadding="1px" name="grouplist" style="background-color:#75838C;"><tbody></tbody></table>');
2020
2021
2022 var n = list.length;
2023 var id = -1;
2024 jsGlobal.currentGroups.splice(0, jsGlobal.currentGroups);
2025 jsGlobal.currentGroups.length = 0;
2026 for (var i = 0; i < n; i++) {
2027 id = -1;
2028 var item = list[i];
2029 id = jsGlobal.currentGroups.indexOf(item.id);
2030 if (id === -1) {
2031 var groupname = item.name;
2032 var members = item.user.length;
2033
2034 var key = item.id;
2035 jsGlobal.currentGroup = item.id;
2036 jsGlobal.currentGroups.push(item.id);
2037 if (parseInt(item.isyearlist) === 1) {
2038 builditemyl(key, groupname, members);
2039 } else {
2040 builditem(key, groupname, members);
2041 }
2042 }
2043 }
2044 }, 1000);
2045 setTimeout(function() {
2046 $('#stage').hide();
2047 document.getElementById('stage').style.display = 'none !important';
2048
2049 }, 1000);
2050 }
2051
2052 /*
2053 * add users to the groups list
2054 * javascript
2055 *
2056 * based on the current group.
2057 * @author James Boag <j.boag@abdn.ac.uk>
2058 * @version 27-January-2014
2059 * @copyright Medi-CAL Unit, University of Aberdeen
2060 *
2061 * @param int key
2062 * @return object user;
2063 */
2064 function populateuserlistfromgroup(list) {
2065 var n = list.length;
2066
2067 if (n === 0) {
2068 var user = "No Data";
2069 } else {
2070 var user = Array();
2071 }
2072 for (var i = 0; i < n; i++) {
2073 user.push = list[i];
2074 }
2075 return user;
2076 }
2077
2078
2079 /*
2080 * Add a row to the main table (Groupname,members tools)
2081 * javascript
2082 *
2083 * based on the current group.
2084 * @author James Boag <j.boag@abdn.ac.uk>
2085 * @version 27-January-2014
2086 * @copyright Medi-CAL Unit, University of Aberdeen
2087 *
2088 * @param int key Key to the group record,
2089 * @param string name Group name as a string
2090 * @param int members the number of memebers in the group.
2091 * @return object group recoed including it's users.
2092 */
2093 function builditemyl(key, name, members) {
2094
2095 var menu = buildmenu(key);
2096 var line = "<tr ><td id='" + key + "' width='5%' align='middle' ><input type='checkbox' value='" + key + "' id='sel_" + key + "'></td><td width='2%'><i class='icon-calendar' rel='popover' title='This is a Year List'></i> </td><td width = '60%'>" + name + "</td><td width='15%'>" + members + "</td><td width='20%'>" + menu + "</td></tr>";
2097 $('#grouplistbody > tbody').append(line);
2098 var line = "<tr class='bb'><td class='ylbb' colspan ='5'></td></tr>";
2099 $('#grouplistbody > tbody').append(line);
2100 }
2101
2102 /*
2103 * Add a row to the main table (Groupname,members tools)
2104 * javascript
2105 *
2106 * based on the current group.
2107 * @author James Boag <j.boag@abdn.ac.uk>
2108 * @version 27-January-2014
2109 * @copyright Medi-CAL Unit, University of Aberdeen
2110 *
2111 * @param int key Key to the group record,
2112 * @param string name Group name as a string
2113 * @param int members the number of memebers in the group.
2114 * @return object group recoed including it's users.
2115 */
2116 function builditem(key, name, members) {
2117
2118 var menu = buildmenu(key);
2119 var line = "<tr ><td id='" + key + "' width='5%' align='middle' ><input type='checkbox' value='" + key + "' id='sel_" + key + "'></td><td width='2%'> </td><td width = '60%'>" + name + "</td><td width='15%'>" + members + "</td><td width='20%'>" + menu + "</td></tr>";
2120 $('#grouplistbody > tbody').append(line);
2121 var line = "<tr class='bb'><td class='bb' colspan ='5'></td></tr>";
2122 $('#grouplistbody > tbody').append(line);
2123 }
2124
2125 /*
2126 * Build the menu based on the group id / key
2127 * javascript
2128 *
2129 * based on the current group.
2130 * @author James Boag <j.boag@abdn.ac.uk>
2131 * @version 27-January-2014
2132 * @copyright Medi-CAL Unit, University of Aberdeen
2133 *
2134 * @param int key Key to the group record,
2135
2136 * @return string html for the menu for the group record
2137 */
2138 function buildmenu(key) {
2139 var edit = buildmenuedit(key);
2140 var deleteitem = buildmenudelete(key);
2141 var usermenu = buildmenuusers(key);
2142 var printmenu = buildmenuprint(key);
2143 var badgesmenu = buildmenubadges(key);
2144 var exportmenu = buildmenucsv(key);
2145 var menu = "<table id ='menutable' class='menutable table-body' name ='menutable' cellpadding ='5px' border ='0px'><tr class='bo' border='0px'>" + edit + usermenu + printmenu + badgesmenu + exportmenu + deleteitem + "</tr></table>";
2146 return menu;
2147
2148 }
2149
2150 /*
2151 * create the html of the edit button
2152 * javascript
2153 *
2154 * based on the current group.
2155 * @author James Boag <j.boag@abdn.ac.uk>
2156 * @version 27-January-2014
2157 * @copyright Medi-CAL Unit, University of Aberdeen
2158 *
2159 * @param int key Key to the group record,
2160
2161 * @return string html for the edit button for the item
2162 */
2163 function buildmenuedit(key) {
2164 var editjs = "javascript:editrow(" + key + ")";
2165 var edit = "<td border ='0px'><a href='javascript: void(0)' onclick='" + editjs + ";'><i class='icon-edit'></i></a></td>";
2166 return edit;
2167 }
2168
2169 /*
2170 * create the html of the delete button
2171 * javascript
2172 *
2173 * based on the current group.
2174 * @author James Boag <j.boag@abdn.ac.uk>
2175 * @version 27-January-2014
2176 * @copyright Medi-CAL Unit, University of Aberdeen
2177 *
2178 * @param int key Key to the group record,
2179
2180 * @return string html for the delete button for the item
2181 */
2182 function buildmenudelete(key) {
2183 var deleterow = "javascript:deleterow(" + key + ")";
2184 var deleteitem = "<td border ='0px' ><a href='javascript: void(0)' onclick='" + deleterow + ";'><i class='icon-trash'></i></a></td>";
2185 return deleteitem;
2186 }
2187
2188 /*
2189 * create the html of the edit users button
2190 * javascript
2191 *
2192 * based on the current group.
2193 * @author James Boag <j.boag@abdn.ac.uk>
2194 * @version 27-January-2014
2195 * @copyright Medi-CAL Unit, University of Aberdeen
2196 *
2197 * @param int key Key to the group record,
2198
2199 * @return string html for the edit users button for the item
2200 */
2201 function buildmenuusers(key) {
2202 var editusers = "javascript:editusers(" + key + ")";
2203 var usermenu = "<td border ='0px'> <a href='javascript: void(0)' onclick='" + editusers + ";'><i class='icon-user'></i></a></td>";
2204 return usermenu;
2205 }
2206 /*
2207 * create the html of the print report button
2208 *
2209 * based on the current group.
2210 * @author James Boag <j.boag@abdn.ac.uk>
2211 * @version 27-January-2014
2212 * @copyright Medi-CAL Unit, University of Aberdeen
2213 *
2214 * @param int key Key to the group record,
2215
2216 * @return string html for the print report button for the item
2217 */
2218 function buildmenuprint(key) {
2219 var printgroup = "javascript:printgroup(" + key + ")";
2220 var printmenu = "<td border ='0px'><a href='javascript: void(0)' onclick='" + printgroup + ";'><i class='icon-print'></i></a></td>";
2221 return printmenu;
2222 }
2223 /*
2224 * create the html of the pint badges button
2225 * javascript
2226 *
2227 * based on the current group.
2228 * @author James Boag <j.boag@abdn.ac.uk>
2229 * @version 27-January-2014
2230 * @copyright Medi-CAL Unit, University of Aberdeen
2231 *
2232 * @param int key Key to the group record,
2233
2234 * @return string html for the print badges button for the item
2235 */
2236 function buildmenubadges(key) {
2237 var printbadges = "javascript:printbadges(" + key + ")";
2238 var badgesmenu = "<td border ='0px'><a href='javascript: void(0)' onclick='" + printbadges + ";'><i class='icon-picture'></i></a></td>";
2239 return badgesmenu;
2240 }
2241 /*
2242 * create the html of the export as csv button
2243 * javascript
2244 *
2245 * based on the current group.
2246 * @author James Boag <j.boag@abdn.ac.uk>
2247 * @version 27-January-2014
2248 * @copyright Medi-CAL Unit, University of Aberdeen
2249 *
2250 * @param int key Key to the group record,
2251
2252 * @return string html for the export as csv button for the item
2253 */
2254 function buildmenucsv(key) {
2255 // var exportcsv = "javascript:getcsvhdr(" + key + ")";
2256 // var exportmenu = "<td border ='0px'><a href='javascript: void(0)' onclick='" + exportcsv + ";'><i class='icon-download-alt'></i></a></td>";
2257 var exportcsv = window.location + "/ajax_exportgrouplist?groupid=" + key;
2258 var exportmenu = "<td border ='0px'><a href='" + exportcsv + "'><i class='icon-download-alt'></i></a></td>";
2259 return exportmenu;
2260 }
2261
2262 /*
2263 * create the html of the users row and remove user button
2264 * javascript
2265 *
2266 * based on the current group.
2267 * @author James Boag <j.boag@abdn.ac.uk>
2268 * @version 27-January-2014
2269 * @copyright Medi-CAL Unit, University of Aberdeen
2270 *
2271 * @param object User
2272
2273
2274 */
2275 function builduserrow(user) {
2276 var id = "";
2277 id = jsGlobal.currentUsers.indexOf(user.id);
2278 if (id === -1) {
2279 var rowhtml = "<tr class='bb' id='" + user.id + "' ><td class='bb'>" + user.display + "</td><td class='bb' ><a href='javascript:removerow(" + user.id + ")'><i class='icon-trash'></i></a></td></tr>";
2280 $('#usercontent > tbody').append(rowhtml);
2281 jsGlobal.currentUsers.push(user.id);
2282 }
2283 }
2284
2285 /*
2286 * delete a group
2287 * javascript
2288 *
2289 * based on the current group.
2290 * @author James Boag <j.boag@abdn.ac.uk>
2291 * @version 27-January-2014
2292 * @copyright Medi-CAL Unit, University of Aberdeen
2293 *
2294 * @param id Group id
2295
2296 */
2297 function deleterow(id) {
2298 var record = findagrouprecordbykey(id);
2299 jsGlobal.currentGroup = id;
2300 $('#delete_label').empty();
2301 $('#delete_label').text("Group : '" + record.name + "' ?");
2302 $('#delete_popup').modal('show');
2303
2304 }
2305
2306
2307 /*
2308 * delete a group
2309 * javascript
2310 *
2311
2312 * @author James Boag <j.boag@abdn.ac.uk>
2313 * @version 27-January-2014
2314 * @copyright Medi-CAL Unit, University of Aberdeen
2315 *
2316 * open the dialog !
2317 */
2318
2319 function deletegroup() {
2320 deletegroupsandreload(jsGlobal.currentGroup);
2321 $('#delete_popup').modal('hide')
2322 }
2323 /*
2324 * edit a group record
2325 * javascript
2326 *
2327 * based on the current group.
2328 * @author James Boag <j.boag@abdn.ac.uk>
2329 * @version 27-January-2014
2330 * @copyright Medi-CAL Unit, University of Aberdeen
2331 *
2332 * @param int key Key to the group record,
2333
2334
2335 */
2336 function editrow(id) {
2337 $('#Processing').hide();
2338 if (parseInt(id) === -1) {
2339 $('#editgrouptitle').text("Create New Group");
2340 jsGlobal.newGroup = true;
2341 $('#group_name').val();
2342 var record = new Object;
2343 record.degreeprogyr = 1;
2344 record.isyearlist = 0;
2345 record.iswardteaching = 0;
2346 record.issupressed = 0;
2347 } else {
2348 $('#editgrouptitle').text("Edit Group");
2349 jsGlobal.newGroup = false;
2350 jsGlobal.eg_id = id;
2351 var record = findagrouprecordbykey(id);
2352
2353 }
2354 // load correct record from key (id)
2355
2356
2357 // populate fields on form
2358 if (jsGlobal.newGroup === false) {
2359 $('#group_name').val(record.name);
2360 } else {
2361 $('#group_name').val("");
2362
2363
2364 }
2365
2366 switch (parseInt(record.degreeprogyr)) {
2367 case 1:
2368 $("#dpyr_1").removeClass('checked');
2369 $("#dpyr_2").removeClass('checked');
2370 $("#dpyr_3").removeClass('checked');
2371 $("#dpyr_4").removeClass('checked');
2372 $("#dpyr_5").removeClass('checked');
2373 $("#dpyr_1").removeClass('unchecked');
2374 $("#dpyr_2").removeClass('unchecked');
2375 $("#dpyr_3").removeClass('unchecked');
2376 $("#dpyr_4").removeClass('unchecked');
2377 $("#dpyr_5").removeClass('unchecked');
2378 $("#dpyr_2").addClass('unchecked');
2379 $("#dpyr_3").addClass('unchecked');
2380 $("#dpyr_4").addClass('unchecked');
2381 $("#dpyr_5").addClass('unchecked');
2382 $("#dpyr_1").addClass('checked');
2383 $("direct_entry_button").addClass('disabled');
2384 break;
2385 case 2:
2386 $("#dpyr_1").removeClass('checked');
2387 $("#dpyr_2").removeClass('checked');
2388 $("#dpyr_3").removeClass('checked');
2389 $("#dpyr_4").removeClass('checked');
2390 $("#dpyr_5").removeClass('checked');
2391 $("#dpyr_1").removeClass('unchecked');
2392 $("#dpyr_2").removeClass('unchecked');
2393 $("#dpyr_3").removeClass('unchecked');
2394 $("#dpyr_4").removeClass('unchecked');
2395 $("#dpyr_5").removeClass('unchecked');
2396 $("#dpyr_1").addClass('unchecked');
2397 $("#dpyr_3").addClass('unchecked');
2398 $("#dpyr_4").addClass('unchecked');
2399 $("#dpyr_5").addClass('unchecked');
2400 $("#dpyr_2").addClass('checked');
2401 $("direct_entry_button").addClass('disabled');
2402 break;
2403 case 3:
2404 $("label[for='dpyr_1" + "']").removeClass('checked');
2405 $("label[for='dpyr_2" + "']").removeClass('checked');
2406 $("label[for='dpyr_3" + "']").removeClass('checked');
2407 $("label[for='dpyr_4" + "']").removeClass('checked');
2408 $("label[for='dpyr_5" + "']").removeClass('checked');
2409 $("label[for='dpyr_1" + "']").removeClass('unchecked');
2410 $("label[for='dpyr_2" + "']").removeClass('unchecked');
2411 $("label[for='dpyr_3" + "']").removeClass('unchecked');
2412 $("label[for='dpyr_4" + "']").removeClass('unchecked');
2413 $("label[for='dpyr_5" + "']").removeClass('unchecked');
2414 $("label[for='dpyr_1" + "']").addClass('unchecked');
2415 $("label[for='dpyr_2" + "']").addClass('unchecked');
2416 $("label[for='dpyr_4" + "']").addClass('unchecked');
2417 $("label[for='dpyr_5" + "']").addClass('unchecked');
2418 $("label[for='dpyr_3" + "']").addClass('checked');
2419 $("direct_entry_button").addClass('enabled');
2420 break;
2421 case 4:
2422 $("label[for='dpyr_1" + "']").removeClass('checked');
2423 $("label[for='dpyr_2" + "']").removeClass('checked');
2424 $("label[for='dpyr_3" + "']").removeClass('checked');
2425 $("label[for='dpyr_4" + "']").removeClass('checked');
2426 $("label[for='dpyr_5" + "']").removeClass('checked');
2427 $("label[for='dpyr_1" + "']").removeClass('unchecked');
2428 $("label[for='dpyr_2" + "']").removeClass('unchecked');
2429 $("label[for='dpyr_3" + "']").removeClass('unchecked');
2430 $("label[for='dpyr_4" + "']").removeClass('unchecked');
2431 $("label[for='dpyr_5" + "']").removeClass('unchecked');
2432 $("label[for='dpyr_1" + "']").addClass('unchecked');
2433 $("label[for='dpyr_2" + "']").addClass('unchecked');
2434 $("label[for='dpyr_3" + "']").addClass('unchecked');
2435 $("label[for='dpyr_5" + "']").addClass('unchecked');
2436 $("label[for='dpyr_4" + "']").addClass('checked');
2437 $("direct_entry_button").addClass('disabled');
2438 break;
2439 case 5:
2440 $("label[for='dpyr_1" + "']").removeClass('checked');
2441 $("label[for='dpyr_2" + "']").removeClass('checked');
2442 $("label[for='dpyr_3" + "']").removeClass('checked');
2443 $("label[for='dpyr_4" + "']").removeClass('checked');
2444 $("label[for='dpyr_5" + "']").removeClass('checked');
2445 $("label[for='dpyr_1" + "']").removeClass('unchecked');
2446 $("label[for='dpyr_2" + "']").removeClass('unchecked');
2447 $("label[for='dpyr_3" + "']").removeClass('unchecked');
2448 $("label[for='dpyr_4" + "']").removeClass('unchecked');
2449 $("label[for='dpyr_5" + "']").removeClass('unchecked');
2450 $("label[for='dpyr_1" + "']").addClass('unchecked');
2451 $("label[for='dpyr_2" + "']").addClass('unchecked');
2452 $("label[for='dpyr_3" + "']").addClass('unchecked');
2453 $("label[for='dpyr_4" + "']").addClass('unchecked');
2454 $("label[for='dpyr_5" + "']").addClass('checked');
2455 $("direct_entry_button").addClass('disabled');
2456 break;
2457 }
2458
2459 $("label[for='isyearlist_true" + "']").removeClass('checked');
2460 $("label[for='isyearlist_false" + "']").removeClass('checked');
2461 $("label[for='isyearlist_true" + "']").removeClass('unchecked');
2462 $("label[for='isyearlist_false" + "']").removeClass('unchecked');
2463 if (parseInt(record.isyearlist) === 1) {
2464 $("label[for='isyearlist_false" + "']").addClass('unchecked');
2465 $("label[for='isyearlist_true" + "']").addClass('checked');
2466 } else {
2467 $("label[for='isyearlist_true" + "']").addClass('unchecked');
2468 $("label[for='isyearlist_false" + "']").addClass('checked');
2469 }
2470
2471 $("label[for='isward_true" + "']").removeClass('checked');
2472 $("label[for='isward_false" + "']").removeClass('checked');
2473 $("label[for='isward_true" + "']").removeClass('unchecked');
2474 $("label[for='isward_false" + "']").removeClass('unchecked');
2475 if (parseInt(record.iswardteaching) === 1) {
2476 $("label[for='isward_false" + "']").addClass('unchecked');
2477 $("label[for='isward_true" + "']").addClass('checked');
2478 } else {
2479 $("label[for='isward_true" + "']").addClass('unchecked');
2480 $("label[for='isward_false" + "']").addClass('checked');
2481 }
2482
2483
2484 $("label[for='issuppressed_true" + "']").removeClass('checked');
2485 $("label[for='issuppressed_false" + "']").removeClass('checked');
2486 $("label[for='issuppressed_true" + "']").removeClass('unchecked');
2487 $("label[for='issuppressed_false" + "']").removeClass('unchecked');
2488 if (parseInt(record.issupressed) === 1) {
2489 $("label[for='issuppressed_true" + "']").addClass('checked');
2490 $("label[for='issuppressed_false" + "']").addClass('unchecked');
2491 } else {
2492 $("label[for='issuppressed_true" + "']").addClass('unchecked');
2493 $("label[for='issuppressed_false" + "']").addClass('checked');
2494 }
2495
2496 $('#popup_group_acyr').buttonset();
2497 $('#popup_group_dpyr').buttonset();
2498 $('#isyearlistbtnset').buttonset();
2499 $('#iswardbtnset').buttonset();
2500 $('#issuppressedbtnset').buttonset();
2501
2502 //show form
2503
2504 //$('#Processing').text('');
2505 $('#edit_group_popup').css('display', 'block');
2506 $('#edit_group_popup').modal('show');
2507
2508 }
2509
2510 /*
2511 * edit a user
2512 * javascript
2513 *
2514 * based on the current group.
2515 * @author James Boag <j.boag@abdn.ac.uk>
2516 * @version 27-January-2014
2517 * @copyright Medi-CAL Unit, University of Aberdeen
2518 *
2519 * @param int id a users id
2520
2521
2522 */
2523
2524 function editusers(id) {
2525 jsGlobal.currentUsers = Array();
2526 jsGlobal.currentUsers.splice(0, jsGlobal.currentUsers.length);
2527 jsGlobal.userslistatload.splice(0, jsGlobal.userslistatload.length);
2528 jsGlobal.currentGroup = id;
2529 jsGlobal.addedusers = "";
2530 jsGlobal.deletedusers = "";
2531 var record = findagrouprecordbykey(id);
2532 getkeysfromuserlist(record.user);
2533 var n = record.user.length;
2534 var user;
2535
2536 $('#selAttendees_Chosen').html(loaduserlist());
2537 $('#selAttendees_Chosen').val($("#selAttendees_Chosen option:first").val());
2538 // $('#selAttendees_Chosen').chosen('chosen:updated');
2539 //$('#selAttendees_Chosen').chosen('width:400px');
2540 $("#usercontent").html('<tbody></tbody>')
2541 for (var i = 0; i < n; i++) {
2542 user = record.user[i];
2543 if (parseInt(user.gu_deleted) === 0) {
2544 builduserrow(user);
2545 }
2546 }
2547 jsGlobal.currentGroupName = record.name;
2548 // var advMenu = "<a href='javascript: void(0)' onclick='javascript:addusersadvance();'>Advanced Search</a>";
2549 $('#popup_group_users_name').html("<table width='100%'><tr><td align='left'>Group :" + record.name + "</td><td align='right'></td></tr></table>");
2550
2551 $('#groupid').val(jsGlobal.currentGroup);
2552 $("select#selcontext").find("option#0").attr("selected", true);
2553 $('#searchfor').val("");
2554 $('#edit_group_user_popup').modal('show');
2555
2556 }
2557
2558 /*
2559 * Show the print dialog with all it options
2560 * javascript
2561 *
2562 * based on the current group.
2563 * @author James Boag <j.boag@abdn.ac.uk>
2564 * @version 27-January-2014
2565 * @copyright Medi-CAL Unit, University of Aberdeen
2566 *
2567 * @param id the group id to be printed
2568
2569 */
2570 function printgroup(id) {
2571 jsGlobal.currentGroup = id;
2572 $('#print_popup').modal('show');
2573 }
2574 /*
2575 * Shell for the create badges function
2576 * javascript
2577 *
2578 * based on the current group.
2579 * @author James Boag <j.boag@abdn.ac.uk>
2580 * @version 27-January-2014
2581 * @copyright Medi-CAL Unit, University of Aberdeen
2582 *
2583 * @param int id the groups id
2584
2585
2586 */
2587 function printbadges(id) {
2588 jsGlobal.currentGroup = id;
2589 $('#print_badge_popup').modal('show');
2590
2591// return $.ajax({
2592// type: "GET",
2593// async: false,
2594// url: window.location + "/ajax_badges_pdf",
2595// data: {groupid: id,
2596// picture: 1
2597// }, dataType: "json"
2598// });
2599
2600 }
2601
2602 /*
2603 * open the create csv export dialog
2604 * javascript
2605 *
2606 * based on the current group.
2607 * @author James Boag <j.boag@abdn.ac.uk>
2608 * @version 27-January-2014
2609 * @copyright Medi-CAL Unit, University of Aberdeen
2610 *
2611 * @param int id the group id to be exported
2612 */
2613 function exportcsv(id) {
2614 getcsvhdr(id);
2615 //$('#excel_popup').hide();
2616 }
2617
2618
2619
2620 /*
2621 * Process the Ajax retrun holding the csv data
2622 * javascript
2623 *
2624 * based on the current group.
2625 * @author James Boag <j.boag@abdn.ac.uk>
2626 * @version 27-January-2014
2627 * @copyright Medi-CAL Unit, University of Aberdeen
2628 *
2629 * @param x ajax return data
2630 */
2631 function processscv(x) {
2632 x.success(function(exporttable) {
2633
2634 //alert(exporttable);
2635 // $('#hiddenexportdiv').html("<table id='hiddenexport'><tr><td>Sorry this group has no users</td></tr></table>");
2636
2637 // $('#hiddenexportdiv').html(exporttable);
2638 // $('#excel_popup').modal('show');
2639
2640 });
2641 }
2642
2643 /*
2644 * populate the global var holding the list of Users images for a group
2645 * javascript
2646 *
2647 * based on the current group.
2648 * @author James Boag <j.boag@abdn.ac.uk>
2649 * @version 27-January-2014
2650 * @copyright Medi-CAL Unit, University of Aberdeen
2651 *
2652 * @param x an ajax return holding an array of images for all the users in a group
2653 */
2654 function processimages(x) {
2655 x.success(function(imagearray) {
2656 jsGlobal.images = imagearray;
2657 });
2658 }
2659
2660 /*
2661 * Call the ajax code to retrive an entrre goroup
2662 * of images for the users of a group in one call
2663 * javascript
2664 *
2665 * based on the current group.
2666 * @author James Boag <j.boag@abdn.ac.uk>
2667 * @version 27-January-2014
2668 * @copyright Medi-CAL Unit, University of Aberdeen
2669 *
2670 * @param int id the group to return the images for
2671 */
2672 function getuserimages(id) {
2673 var callajax = getimages(id);
2674 var retval = processimages(callajax);
2675 return retval;
2676 }
2677
2678 /*
2679 * Actual ajax call to get the images for a group.
2680 *
2681 * based on the current group.
2682 * @author James Boag <j.boag@abdn.ac.uk>
2683 * @version 27-January-2014
2684 * @copyright Medi-CAL Unit, University of Aberdeen
2685 *
2686 * @param int id the group to return the images for
2687 */
2688 function getimages(id) {
2689 return $.ajax({
2690 type: "GET",
2691 async: false,
2692 cache: true,
2693 url: window.location + "/ajax_groupimages",
2694 data: {groupid: id
2695 }, dataType: "json"
2696 });
2697 }
2698
2699 /*
2700 * Call the ajax code to retrive the group
2701 *so that it can be sent out as a csv file,
2702 * javascript
2703 *
2704 * based on the current group.
2705 * @author James Boag <j.boag@abdn.ac.uk>
2706 * @version 27-January-2014
2707 * @copyright Medi-CAL Unit, University of Aberdeen
2708 *
2709 * @param int id the group to return the images for
2710 */
2711
2712 function getcsvhdr(id) {
2713 var callajax = getcsv(id);
2714 var retval = processscv(callajax);
2715
2716 return retval;
2717 }
2718
2719 /*
2720 * Actual ajax call to retrive the data
2721 *so that it can be sent out as a csv file,
2722 * javascript
2723 *
2724 * based on the current group.
2725 * @author James Boag <j.boag@abdn.ac.uk>
2726 * @version 27-January-2014
2727 * @copyright Medi-CAL Unit, University of Aberdeen
2728 *
2729 * @param int id the group to return the images for
2730 */
2731
2732 function getcsv(id) {
2733 var x = $.ajax({
2734 type: "GET",
2735 async: false,
2736 cache: true,
2737 url: window.location + "/ajax_exportgrouplist",
2738 data: {groupid: id
2739 }, dataType: "json"
2740 });
2741 // $('#excel_popup').hide();
2742 return x;
2743 }
2744
2745
2746 /*
2747 * Select all checkbox
2748 * pressing this will set all the check boxes
2749 * to on of off
2750 * javascript
2751 *
2752 * based on the current group.
2753 * @author James Boag <j.boag@abdn.ac.uk>
2754 * @version 27-January-2014
2755 * @copyright Medi-CAL Unit, University of Aberdeen
2756 *
2757 */
2758
2759 function selectall() {
2760
2761 if ($('#selectall').is(':checked')) {
2762
2763 $('input[id^="sel_"]').prop('checked', true);
2764 } else {
2765
2766 $('input[id^="sel_"]').prop('checked', false);
2767 }
2768 }
2769 /*
2770 * get that master list of all possible users
2771 * javascript
2772 *
2773 * based on the current group.
2774 * @author James Boag <j.boag@abdn.ac.uk>
2775 * @version 27-January-2014
2776 * @copyright Medi-CAL Unit, University of Aberdeen
2777 *
2778 * @return string formated as the inner html of a dropdown combo box witjh all users in it
2779 */
2780
2781 function loaduserlist() {
2782 var data = jsData.grouplist['static'];
2783
2784 var n = data.length;
2785 var item = "";
2786 var innerhtml = "";
2787 var id = -1;
2788 for (var i = 0; i < n; i++) {
2789 item = data[i];
2790
2791 //<option value='" + item.id + "' selected=''>" + item.name + "</option>";
2792 innerhtml = innerhtml + "<option value='" + item.id + "' >" + item.title + " " + item.firstname + " " + item.lastname + " (" + item.email + ")" + "</option>";
2793
2794 }
2795 return innerhtml;
2796 }
2797
2798 /*
2799 * Load the yearlist from the javascript var
2800 * and insert them into the correct format for
2801 * a html select statement
2802 *
2803 * based on the current group.
2804 * @author James Boag <j.boag@abdn.ac.uk>
2805 * @version 27-January-2014
2806 * @copyright Medi-CAL Unit, University of Aberdeen
2807 *
2808 * @return string formated as the inner html of a dropdown combo box witjh all users in it
2809 */
2810 function loadyearlist() {
2811 var data = jsData.grouplist['custom'];
2812
2813 var n = data.length;
2814 var item = "";
2815 var innerhtml = "";
2816 var id = -1;
2817 for (var i = 0; i < n; i++) {
2818 item = data[i];
2819 if (parseInt(item.isyearlist) === 1) {
2820 //<option value='" + item.id + "' selected=''>" + item.name + "</option>";
2821 innerhtml = innerhtml + "<option value='" + item.id + "' >" + item.name + "</option>";
2822 }
2823 }
2824 return innerhtml;
2825 }
2826
2827 /**
2828 *
2829 * @returns string (HTML FORMATTED) inner code for a select statement holding all the users.
2830 */
2831 function addusershtml() {
2832 var newuser = $('#selAttendees_Chosen').val();
2833 var data = jsData.grouplist['static'];
2834 var item = "";
2835 var newstring = "";
2836 var n = data.length;
2837 var id = -1;
2838 for (var i = 0; i < n; i++) {
2839 item = data[i];
2840 if (parseInt(item.id) === parseInt(newuser)) {
2841 id = jsGlobal.currentUsers.indexOf(item.id);
2842 if (parseInt(id) === parseInt(-1)) {
2843 var newstring = "<tr class='bb' id='" + item.id + "'><td>" + item.title + " " + item.firstname + " " + item.lastname + " (" + item.email + ") </td><td><a href='javascript: void(0)' onclick='javascript:removerow(" + item.id + ");'><i class='icon-trash'></i></a></td></tr>";
2844 $("#usercontent > tbody").append(newstring);
2845 jsGlobal.currentUsers.push(item.id);
2846 }
2847 }
2848 }
2849 checkfornewusers();
2850 }
2851
2852
2853 function advaddusers(i) {
2854 var newuser = i;
2855 var data = jsData.grouplist.static[i];
2856 var item = "";
2857 var newstring = "";
2858 var idx = -1;
2859 item = data;
2860 idx = jsGlobal.currentUsers.indexOf(item.id);
2861 if (idx === -1) {
2862 var newstring = "<tr class='bb' id='" + item.id + "'><td>" + item.title + " " + item.firstname + " " + item.lastname + " (" + item.email + ") </td><td><a href='javascript: void(0)' onclick ='javascript:removerow(" + item.id + ");'><i class='icon-trash'></i></a></td></tr>";
2863 $("#usercontent > tbody").append(newstring);
2864 jsGlobal.currentUsers.push(item.id);
2865 }
2866 checkfornewusers();
2867 }
2868
2869 function removerow(id) {
2870 if (confirm("Are you sure you want to delete this item ?")) {
2871 $('#' + id).remove();
2872
2873 var index = jsGlobal.currentUsers.indexOf(String(id));
2874 if (parseInt(index) > -1) {
2875
2876 jsGlobal.currentUsers[index] = "DELETED";
2877 }
2878
2879 }
2880 checkfordeletedusers();
2881 }
2882
2883
2884 function setaudience(value, initial) {
2885 if (value !== jsGlobal.audience.toUpperCase()) {
2886 audience_off();
2887 if (value === 'MYMBCHB') {
2888 $('#menu_mymbchb').addClass('active');
2889 jsGlobal.audience = 'mymbchb';
2890
2891 }
2892 if (value === 'MYBDS') {
2893 $('#menu_mybds').addClass('active');
2894 jsGlobal.audience = 'mybds';
2895
2896 }
2897 if (value === 'MYPA') {
2898 $('#menu_mypa').addClass('active');
2899 jsGlobal.audience = 'mypa';
2900
2901 }
2902 if (value === 'MYMEDSCI') {
2903 $('#menu_mymedsci').addClass('active');
2904 jsGlobal.audience = 'mymedsci';
2905
2906 }
2907 if (initial !== true) {
2908 reloaddata();
2909 }
2910 }
2911
2912 }
2913
2914 function audience_off() {
2915 $('#menu_mymbchb').removeClass('active');
2916 $('#menu_mybds').removeClass('active');
2917 $('#menu_mypa').removeClass('active');
2918 $('#menu_mymedsci').removeClass('active');
2919 }
2920
2921
2922
2923
2924
2925 function setacyr(value, initial) {
2926 if (value !== jsGlobal.acyr) {
2927 acyr_off();
2928 var d = new Date();
2929 var y = d.getFullYear();
2930 var m = d.getMonth();
2931 if (value === 1) {
2932 $('#menu_acyr_1').addClass('active');
2933 if (m < 7) {
2934 jsGlobal.acyr = (y - 3);
2935 } else {
2936 jsGlobal.acyr = (y - 2);
2937 }
2938
2939 }
2940 if (value === 2) {
2941 $('#menu_acyr_2').addClass('active');
2942 if (m < 7) {
2943 jsGlobal.acyr = (y - 2);
2944 } else {
2945 jsGlobal.acyr = (y - 1);
2946 }
2947
2948 }
2949 if (value === 3) {
2950 $('#menu_acyr_3').addClass('active');
2951 if (m < 7) {
2952 jsGlobal.acyr = (y - 1);
2953 } else {
2954 jsGlobal.acyr = (y);
2955 }
2956
2957 }
2958 if (value === 4) {
2959 $('#menu_acyr_4').addClass('active');
2960 if (m < 7) {
2961 jsGlobal.acyr = (y);
2962 } else {
2963 jsGlobal.acyr = (y + 1);
2964 }
2965
2966 }
2967 if (value === 5) {
2968 $('#menu_acyr_5').addClass('active');
2969 if (m < 7) {
2970 jsGlobal.acyr = (y + 1);
2971 } else {
2972 jsGlobal.acyr = (y + 2);
2973 }
2974
2975 }
2976 if (initial !== true) {
2977 reloaddata();
2978 }
2979 }
2980
2981 }
2982
2983 function acyr_off() {
2984 $('#menu_acyr_1').removeClass('active');
2985 $('#menu_acyr_2').removeClass('active');
2986 $('#menu_acyr_3').removeClass('active');
2987 $('#menu_acyr_4').removeClass('active');
2988 $('#menu_acyr_5').removeClass('active');
2989 }
2990
2991 function setdpyr(value, initial) {
2992 if (value !== jsGlobal.dpyr) {
2993 dpyr_off();
2994 if (value === 1) {
2995 $('#menu_dpyr_1').addClass('active');
2996 jsGlobal.dpyr = 1;
2997
2998 }
2999 if (value === 2) {
3000 $('#menu_dpyr_2').addClass('active');
3001 jsGlobal.dpyr = 2;
3002
3003 }
3004 if (value === 3) {
3005 $('#menu_dpyr_3').addClass('active');
3006 jsGlobal.dpyr = 3;
3007
3008 }
3009 if (value === 4) {
3010 $('#menu_dpyr_4').addClass('active');
3011 jsGlobal.dpyr = 4;
3012
3013 }
3014 if (value === 5) {
3015 $('#menu_dpyr_5').addClass('active');
3016 jsGlobal.dpyr = 5;
3017
3018 }
3019 if (initial !== true) {
3020 reloaddata();
3021 }
3022 }
3023
3024 }
3025
3026 function dpyr_off() {
3027 $('#menu_dpyr_1').removeClass('active');
3028 $('#menu_dpyr_2').removeClass('active');
3029 $('#menu_dpyr_3').removeClass('active');
3030 $('#menu_dpyr_4').removeClass('active');
3031 $('#menu_dpyr_5').removeClass('active');
3032
3033 }
3034
3035 function setsuppressedflag(value, initial) {
3036 var tmp = 0;
3037 if (jsGlobal.suppressedflag === 1) {
3038 tmp = 'true';
3039
3040 } else {
3041 tmp = 'false';
3042 }
3043 if (value !== tmp) {
3044 if (value === 'true') {
3045 jsGlobal.suppressedflag = 1;
3046 $('#suppressed_yes').removeClass('active');
3047 $('#suppressed_no').removeClass('active');
3048 $('#suppressed_yes').addClass('active');
3049 // reloaddata();
3050
3051 } else {
3052 jsGlobal.suppressedflag = 0;
3053 $('#suppressed_yes').removeClass('active');
3054 $('#suppressed_no').removeClass('active');
3055 $('#suppressed_no').addClass('active');
3056 //
3057 }
3058 if (initial !== true) {
3059 reloaddata();
3060 }
3061 }
3062
3063 }
3064
3065 function setwardteachingflag(value, initial) {
3066 var tmp = 0;
3067 if (jsGlobal.wardflag === 1) {
3068 tmp = 'true';
3069
3070 } else {
3071 tmp = 'false';
3072 }
3073 if (value !== tmp) {
3074 if (value === 'true') {
3075 jsGlobal.wardflag = 1;
3076 $('#ward_yes').removeClass('active');
3077 $('#ward_no').removeClass('active');
3078 $('#ward_yes').addClass('active');
3079
3080
3081 } else {
3082 jsGlobal.wardflag = 0;
3083 $('#ward_yes').removeClass('active');
3084 $('#ward_no').removeClass('active');
3085 $('#ward_no').addClass('active');
3086
3087 }
3088 reloaddata();
3089 }
3090
3091 }
3092
3093
3094 function reloaddata() {
3095 reloadgroups();
3096 $('#selectall').attr('checked', false);
3097
3098 }
3099
3100
3101 function process(x) {
3102 x.success(function(groupslist) {
3103 jsData.grouplist = groupslist;
3104 populategrouplist(jsData.grouplist['custom']);
3105 jsData.AjaxRunning = false;
3106 });
3107 }
3108
3109
3110 function reloadgroups() {
3111 var callajax = getupdate();
3112 var retval = process(callajax);
3113 return retval;
3114 }
3115
3116
3117 function removegroupandreload(id) {
3118 var callajax = getupdate(id);
3119 var retval = process(callajax);
3120 return retval;
3121 }
3122
3123
3124 function deletegroupsandreload(id) {
3125 var callajax = softdeletegroup(id);
3126 var retval = reloaddata();
3127 return retval;
3128 }
3129
3130 function softdeletegroup(id) {
3131 $.ajax({
3132 type: "GET",
3133 async: false,
3134 cache: true,
3135 url: window.location + "/ajax_deletegroups",
3136 data: {
3137 id: id,
3138 audience: jsGlobal.audience,
3139 degprogyr: jsGlobal.dpyr,
3140 acyr: jsGlobal.acyr,
3141 suppressed: jsGlobal.suppressedflag,
3142 ward: jsGlobal.wardflag
3143 }, dataType: "json"
3144
3145 });
3146 // reloaddata();
3147 return true;
3148 }
3149
3150
3151
3152
3153 function getupdate() {
3154 buildmenustring();
3155 return $.ajax({
3156 type: "GET",
3157 async: false,
3158 cache: true,
3159 url: window.location + "/ajax_getgroups",
3160 data: {
3161 audience: jsGlobal.audience,
3162 degprogyr: jsGlobal.dpyr,
3163 acyr: jsGlobal.acyr,
3164 suppressed: jsGlobal.suppressedflag,
3165 ward: jsGlobal.wardflag
3166 }, dataType: "json"
3167
3168 });
3169 }
3170
3171
3172 function getkeysfromuserlist(userlist) {
3173 jsGlobal.userslistatload.splice(0, jsGlobal.userslistatload);
3174
3175 if (Object.prototype.toString.call(userlist) === '[object Array]') {
3176 var len = userlist.length;
3177 for (var i = 0; i < len; i++) {
3178 var item = userlist[i];
3179 if (jsGlobal.userslistatload.indexOf(item.id) === -1) {
3180 jsGlobal.userslistatload.push(item.id);
3181 }
3182 }
3183 }
3184 }
3185
3186
3187 function saveuser() {
3188 checkfornewusers();
3189 checkfordeletedusers();
3190
3191 if (jsGlobal.addedusers.length > 0) {
3192 alert('We have [' + jsGlobal.addedusers.length + '] to add');
3193 }
3194 if (jsGlobal.deletedusers.length > 0) {
3195 alert('We have [' + jsGlobal.deletedusers.length + '] to remove');
3196 }
3197 if ((jsGlobal.addedusers.length + jsGlobal.deletedusers.length) === 0) {
3198 alert("Nothing to Change ");
3199 } else {
3200 $('#groupid').val(jsGlobal.currentGroup);
3201 $('#addusers').val(jsGlobal.addedusers);
3202 $('#delusers').val(jsGlobal.deletedusers);
3203 $('#addgroupusers').submit(function(event) {
3204 $("#addgroupusers").submit();
3205 event.preventDefault();
3206 });
3207
3208 }
3209 }
3210
3211 function checkfornewusers() {
3212 jsGlobal.addedusers = [];
3213 // jsGlobal.addedusers = jsGlobal.addedusers.splice(0,jsGlobal.addedusers.length);
3214 var origusers = jsGlobal.userslistatload;
3215 var newusers = jsGlobal.currentUsers;
3216 var len = newusers.length;
3217 var len2 = origusers.length;
3218
3219 for (var i = 0; i < len; i++) {
3220 var newitem = newusers[i];
3221 var found = false;
3222 for (var j = 0; j < len2; j++) {
3223 var origitem = origusers[j];
3224 if (parseInt(newitem) === parseInt(origitem)) {
3225 found = true;
3226 }
3227 }
3228 if (found === false) {
3229 if (newitem !== 'DELETED') {
3230 jsGlobal.addedusers.push(newitem);
3231 }
3232 }
3233 }
3234 $("input[id=menustring]").val(buildmenustring());
3235 $("input[id=groupid]").val(jsGlobal.currentGroup);
3236 $("input[id=addusers]").val(jsGlobal.addedusers);
3237
3238 }
3239
3240 function checkfordeletedusers() {
3241 jsGlobal.deletedusers = Array();
3242 var origusers = jsGlobal.userslistatload;
3243 var newusers = jsGlobal.currentUsers;
3244 var len = origusers.length;
3245
3246 for (var i = 0; i < len; i++) {
3247 var origitem = origusers[i];
3248 if (newusers.indexOf(String(origitem)) === -1) {
3249 jsGlobal.deletedusers.push(origitem);
3250 } else {
3251 }
3252 }
3253 $("input[id=menustring]").val(buildmenustring());
3254 $("input[id=groupid]").val(jsGlobal.currentGroup);
3255 $("input[id=delusers]").val(jsGlobal.deletedusers);
3256
3257
3258 }
3259
3260 /*
3261 * Create a string based on the values of the global var set by the menu positions .
3262 *
3263 * based on the current group.
3264 * @author James Boag <j.boag@abdn.ac.uk>
3265 * @version 27-January-2014
3266 * @copyright Medi-CAL Unit, University of Aberdeen
3267 *
3268 * @return string a pipe delimeted list of the main menu options....
3269 */
3270
3271 function buildmenustring() {
3272 var menustring = "";
3273 checkandsetmenuitems();
3274 menustring = jsGlobal.audience + "|" + jsGlobal.acyr + "|" + jsGlobal.dpyr + "|" + jsGlobal.suppressedflag + "|" + jsGlobal.wardflag;
3275
3276 return menustring;
3277 }
3278
3279 /*
3280 * check alll the flags at the top menu and set the global vars based on their value.
3281 * if the initial flag is set this will only set the var without redrawing menus
3282 * untill it reaches the last menu to stop multiple ajax calls based on changes !
3283 * javascript
3284 *
3285 * based on the current group.
3286 * @author James Boag <j.boag@abdn.ac.uk>
3287 * @version 27-January-2014
3288 * @copyright Medi-CAL Unit, University of Aberdeen
3289 *
3290 * @param int initial
3291 */
3292
3293
3294 function checkandsetmenuitems(initial) {
3295
3296 var change = false;
3297 var defaultAudience = "MYMBCHB";
3298 var defaultacyr = 3; // current year
3299 var defaultdpyr = 1;
3300 var defaultsuppressed = 0;
3301 var defaultward = 0;
3302 if (typeof(initial) === 'undefined') {
3303 initial = false;
3304 }
3305 if (initial === null) {
3306 initial = false;
3307 }
3308 if (initial === "") {
3309 initial === false;
3310 }
3311 if (typeof(jsGlobal.audience) === "undefined") {
3312 setaudience(defaultAudience, initial);
3313 change = true;
3314 }
3315 if (typeof(jsGlobal.audience) === null) {
3316 setaudience(defaultAudience, initial);
3317 change = true;
3318 }
3319 if (jsGlobal.audience === "") {
3320 setaudience(defaultAudience, initial);
3321 change = true;
3322 }
3323 if (typeof(jsGlobal.acyr) === "undefined") {
3324 setacyr(defaultacyr, initial);
3325 change = true;
3326 }
3327 if (typeof(jsGlobal.acyr) === null) {
3328 setacyr(defaultacyr, initial);
3329 change = true;
3330 }
3331 if (jsGlobal.acyr === "") {
3332 setacyr(defaultacyr, initial);
3333 change = true;
3334 }
3335 if (typeof(jsGlobal.dpyr) === "undefined") {
3336 setdpyr(defaultdpyr, initial);
3337 change = true;
3338 }
3339 if (typeof(jsGlobal.dpyr) === null) {
3340 setdpyr(defaultdpyr, initial);
3341 change = true;
3342 }
3343 if (jsGlobal.dpyr === "") {
3344 setdpyr(defaultdpyr, initial);
3345 change = true;
3346 }
3347
3348 if (typeof(jsGlobal.suppressedflag) === "undefined") {
3349 setsuppressedflag(defaultsuppressed, initial);
3350 change = true;
3351 }
3352 if (typeof(jsGlobal.suppressedflag) === null) {
3353 setsuppressedflag(defaultsuppressed, initial);
3354 change = true;
3355 }
3356 if (jsGlobal.suppressedflag === "") {
3357 setsuppressedflag(defaultsuppressed, initial);
3358 change = true;
3359 }
3360 if (typeof(jsGlobal.wardflag) === "undefined") {
3361 setwardteachingflag(defaultward, initial);
3362 change = true;
3363 }
3364 if (typeof(jsGlobal.wardflag) === null) {
3365 setwardteachingflag(defaultward, initial);
3366 change = true;
3367 }
3368 if (jsGlobal.wardflag === "") {
3369 setwardteachingflag(defaultward, initial);
3370 change = true;
3371 }
3372 if (change === true) {
3373 if (initial === false) {
3374 reloaddata();
3375 }
3376 }
3377 }
3378
3379
3380
3381 /*
3382 * combined group dialog
3383 *
3384 * @author James Boag <j.boag@abdn.ac.uk>
3385 * @version 31-March-2014
3386 * @copyright Medi-CAL Unit, University of Aberdeen
3387 *
3388 * @returns {undefined} call the combineselectedgroups code
3389 */
3390 function opencombinedgroupsdialog() {
3391 $('#new_group_label').empty();
3392 $('#new_group_label').append('New Group Name');
3393 $('#create-combi').attr('disabled', 'disabled');
3394 $("#Processing-combi").hide();
3395 var groups = getlistofselectedgroups();
3396 var userlist = getusersfromgroups(getlistofselectedgroups());
3397 if($('input[type=checkbox]:checked').length == 0) {
3398 $('#div_popup_combined_group_name').hide();
3399 var combined_string = "Please select some groups with the check boxes to the left !";
3400 }
3401 if(parseInt(groups.length) + parseInt(userlist.length) > 0) {
3402 $('#create-combi').removeAttr('disabled');
3403 var combined_string = "You have selected " + groups.length + " Groups, to be combined, this new group will contain " + userlist.length + " Users";
3404 } else {
3405 $('#div_popup_combined_group_name').hide();
3406 var combined_string = "Please select some groups with the check boxes to the left !";
3407 }
3408
3409
3410
3411
3412 $('#combine-text').text(combined_string);
3413 $('#popup_title').text("Combined group");
3414 $('#combined_groups').modal('show');
3415
3416
3417 }
3418
3419
3420 /*
3421 * combined group dialog
3422 *
3423 * @author James Boag <j.boag@abdn.ac.uk>
3424 * @version 21-April-2015
3425 * @copyright Medi-CAL Unit, University of Aberdeen
3426 *
3427 * @returns {undefined} call the copy the selected group code
3428 */
3429 function opencopygroupsdialog() {
3430 $('#popup_title').empty();
3431 $('#popup_title').append("Copy a group");
3432 $('#create-combi').text("Copy Group");
3433 $('#new_group_label').empty();
3434 $('#new_group_label').append('New Group Name');
3435
3436 $('#create-combi').attr('disabled', 'disabled');
3437 $("#Processing-combi").hide();
3438 var groups = getlistofselectedgroups();
3439 var userlist = getusersfromgroups(getlistofselectedgroups());
3440 if(parseInt(groups.length) == 0) {
3441 $('#div_popup_combined_group_name').hide();
3442 var combined_string = "Please select One group with the check boxes to the left !";
3443 }
3444 if (parseInt(groups.length) == 1) {
3445 $('#create-combi').removeAttr('disabled');
3446 $('#div_popup_combined_group_name').show();
3447 var combined_string = "You have selected " + groups.length + " Group, to be Copied, this new group will contain " + userlist.length + " Users";
3448 } else {
3449 $('#div_popup_combined_group_name').hide();
3450 var combined_string = "Please select One group with the check boxes to the left !";
3451 }
3452
3453 function directentrygroupdialog(){
3454
3455 $('#combine-text').text(combined_string);
3456
3457 $('#combined_groups').modal('show');
3458
3459 $('#direct_entry_groups_popup').modal('show');
3460
3461 }
3462 /*
3463 * Create a list based on the contents of all the
3464 * groups that have been selected
3465 * javascript
3466 *
3467 * based on the current group.
3468 * @author James Boag <j.boag@abdn.ac.uk>
3469 * @version 27-January-2014
3470 * @copyright Medi-CAL Unit, University of Aberdeen
3471 *
3472 */
3473
3474 function combineselectedgroups() {
3475 $("#Processing-combi").hide();
3476 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Creating new group..</b>';
3477 $("#Processing-combi").show().html(data).fadeIn('fast');
3478
3479 var userlist = Array();
3480 if ($('#combined_group_name').val().length > 1) {
3481 if (checkgroupnamejs($('#combined_group_name').val()) === false) {
3482 var groups = getlistofselectedgroups();
3483 if (groups.length > 0) {
3484 userlist = getusersfromgroups(getlistofselectedgroups());
3485 setTimeout(function() {
3486 $.ajax({
3487 type: "GET",
3488 async: false,
3489 cache: true,
3490 url: window.location + "/ajax_creategroup",
3491 data: {
3492 audience: jsGlobal.audience,
3493 degprogyr: jsGlobal.dpyr,
3494 acyr: jsGlobal.acyr,
3495 suppressed: jsGlobal.suppressedflag,
3496 ward: jsGlobal.wardflag,
3497 groupname: $('#combined_group_name').val(),
3498 userlist: userlist
3499 }, dataType: "json"
3500
3501 });
3502 }, 1000);
3503 reloaddata();
3504 } else {
3505 alert('Please Select at least 1 group to combine ');
3506 }
3507 } else {
3508 alert("Group name is already in use !");
3509 }
3510 } else {
3511 alert("Please enter a Group Name!")
3512 $("#Processing-combi").hide();
3513 return false;
3514 }
3515 $('#combined_groups').modal('hide');
3516 }
3517
3518
3519 /**
3520 * Get a list of all the groups that have been checked
3521 * as selected (used to build a Combined group)
3522 * @returns {getlistofselectedgroups.selectedgroups}
3523 */
3524 function getlistofselectedgroups() {
3525 var selectedgroups = Array();
3526 $('input[id^="sel_"]').each(function() {
3527 if ($(this).is(":checked")) {
3528 selectedgroups.push($(this).val());
3529 }
3530 });
3531 return selectedgroups;
3532 }
3533
3534
3535 /**
3536 * create a distinct list of users
3537 * from all the selected groups.
3538 *
3539 * @param {array} listofgroups
3540 * @returns {getusersfromgroups.masteruserlist}
3541 */
3542
3543 function getusersfromgroups(listofgroups) {
3544 var masteruserlist = Array();
3545 var userlistforcurrentgroup = Array();
3546 var currentgroup = 0;
3547 var outerlen = listofgroups.length;
3548 for (var i = 0; i < outerlen; i++) {
3549 currentgroup = listofgroups[i];
3550 userlistforcurrentgroup = getusersfromgroup(currentgroup);
3551 var innerlen = userlistforcurrentgroup.length;
3552 var user = 0;
3553 for (var x = 0; x < innerlen; x++) {
3554 user = userlistforcurrentgroup[x];
3555 if (masteruserlist.indexOf(user.id) === -1) {
3556 if (user.id > 0) {
3557 masteruserlist.push(user.id);
3558 }
3559 }
3560
3561 }
3562
3563 }
3564 return masteruserlist;
3565 }
3566
3567
3568 function getusersfromgroup(group) {
3569 var userlist = Array();
3570 var len = jsData.grouplist.custom.length;
3571 for (var i = 0; i < len; i++) {
3572 var item = jsData.grouplist.custom[i];
3573 if (parseInt(item.id) === parseInt(group)) {
3574 userlist = item.user;
3575 }
3576 }
3577 return userlist;
3578
3579 }
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590 /*
3591 * create a group based on the contents of the new group text box
3592 * javascript
3593 *
3594 * based on the current group.
3595 * @author James Boag <j.boag@abdn.ac.uk>
3596 * @version 27-January-2014
3597 * @copyright Medi-CAL Unit, University of Aberdeen
3598 *
3599 */
3600 function createnewgroup() {
3601 if ($('#new_group_name').val() !== "") {
3602 $.ajax({
3603 type: "GET",
3604 async: false,
3605 cache: true,
3606 url: window.location + "/ajax_creategroup",
3607 data: {
3608 audience: jsGlobal.audience,
3609 degprogyr: jsGlobal.dpyr,
3610 acyr: jsGlobal.acyr,
3611 suppressed: jsGlobal.suppressedflag,
3612 ward: jsGlobal.wardflag,
3613 groupname: $('#new_group_name').val(),
3614 userlist: "NONE"
3615 }, dataType: "json"
3616
3617 });
3618 jsGlobal.currentGroup = 0;
3619 reloaddata();
3620 } else {
3621 alert("Group name box is empty, Please enter a group name and try agian !");
3622 }
3623 }
3624
3625
3626 function createrangeofnewgroups() {
3627 clearautocreatevalues();
3628 $('#ac_yearlist').html(loadyearlist());
3629 $('#ac_yearlist').width(($('#ac_group_name').width() - 5));
3630 $('#ac_groups_popup').modal('show');
3631 }
3632
3633 function clearautocreatevalues() {
3634 $("#ac_group_name").val("");
3635 $("#ac_group_number").val("");
3636
3637 }
3638
3639 function autocreategroups() {
3640 var yearlist = $('#ac_yearlist').val();
3641 var numberofgroups = $('#ac_group_number').val();
3642 var groupbasename = $('#ac_group_name').val();
3643 var ac_type = jsGlobal.ac_groups_append;
3644 var valid = validateacgroupcall(yearlist, numberofgroups, groupbasename);
3645 if (valid === true) {
3646 splitgroups(groupbasename, numberofgroups, yearlist);
3647 }
3648 }
3649
3650 function validateacgroupcall(yearlist, numberofgroups, groupname) {
3651 var globalvalid = true;
3652 var countvalid = checkthatwehaveatleastauserforeachgroup(yearlist, numberofgroups);
3653 var namevalid = checkthatgroupnameisvalid(groupname);
3654 if (countvalid === false) {
3655 var max = countusersforyeargroup(yearlist);
3656 alert("you need at least 1 member per group ! maximum number of groups is " + max + ".");
3657 $('#ac_group_number').val(''); // Should we set this to the max or blank !
3658 globalvalid = false;
3659 }
3660 if (namevalid === false) {
3661 alert("The Group name is invalid as a group with that name already exists, please enter another name !");
3662 $('#ac_group_name').val('');
3663 globalvalid = false;
3664 }
3665 return globalvalid;
3666 }
3667
3668 function checkthatwehaveatleastauserforeachgroup(yearlistid, numberofgroups) {
3669 if (parseInt(numberofgroups) === 0) {
3670 return false;
3671 ;
3672 }
3673 var data = jsData.grouplist['custom'];
3674 var n = data.length;
3675 var item = "";
3676 var memberscount;
3677 var id = -1;
3678 for (var i = 0; i < n; i++) {
3679 item = data[i];
3680 if (parseInt(item.id) === parseInt(yearlistid)) {
3681 memberscount = item.user.length;
3682 }
3683 }
3684 if (parseInt(memberscount) >= parseInt(numberofgroups)) {
3685 return true;
3686 } else {
3687 return false;
3688 ;
3689 }
3690 }
3691
3692
3693 function checkthatgroupnameisvalid(groupname) {
3694 if (groupname.length < 2) {
3695 return false;
3696 ;
3697 }
3698 var data = jsData.grouplist['custom'];
3699 var n = data.length;
3700 var item = "";
3701 var match = false;
3702 var id = -1;
3703 if (jsGlobal.ac_groups_append === 1) {
3704 groupname = groupname + "1";
3705 } else {
3706 groupname = groupname + "A";
3707 }
3708 for (var i = 0; i < n; i++) {
3709 item = data[i];
3710 if (item.name.search(groupname.trim()))
3711 if (item.name.trim() === groupname.trim()) {
3712 match = true;
3713 }
3714 }
3715 if (match === true) {
3716 return false;
3717 ;
3718 } else {
3719 return true;
3720 }
3721 }
3722
3723
3724 function getusersforyeargroup(yearlistid) {
3725 var data = jsData.grouplist['custom'];
3726 var n = data.length;
3727 var item = "";
3728 var members = Array();
3729 var id = -1;
3730 for (var i = 0; i < n; i++) {
3731 item = data[i];
3732 if (parseInt(item.id) === parseInt(yearlistid)) {
3733 members = item.user;
3734 }
3735 }
3736 return shuffle(members);
3737 }
3738
3739 function countusersforyeargroup(yearlistid) {
3740 var users = getusersforyeargroup(yearlistid);
3741 $('#progressbar').progressbar({max: users.length});
3742 return users.length;
3743 }
3744
3745 function splitgroups(basename, numberofgroups, yearlistid) {
3746 $('#section_progressbar').show();
3747 var key = "ABCDEFGHIJKLMNOPQURSTUVWXYZ";
3748 if (jsGlobal.ac_groups_append === 0) {
3749 if (parseInt(numberofgroups) > 26) {
3750 complexsplitgroups(basename, numberofgroups, yearlistid);
3751 $('#section_progressbar').hide();
3752 $('#ac_groups_popup').modal('hide');
3753 reloaddata();
3754 return true;
3755 }
3756 }
3757 var lv = 0;
3758 var newname = "";
3759 var users = getusersforyeargroup(yearlistid);
3760 users = shuffle(users);
3761 var sliced = split(users, parseInt(numberofgroups));
3762 var percentage = ((100 / parseInt(numberofgroups)));
3763 if (jsGlobal.ac_groups_append === 0) {
3764 // letter based
3765 var endpos = 0;
3766 for (var i = 0; i < parseInt(numberofgroups); i++) {
3767 newname = basename + key.substring(i, (i + 1));
3768
3769 var temp = Array();
3770 var len = sliced[i].length;
3771 for (var xx = 0; xx < len; xx++) {
3772 temp.push(sliced[i][xx].id);
3773 }
3774
3775 $.ajax({
3776 type: "GET",
3777 async: false,
3778 cache: true,
3779 url: window.location + "/ajax_creategroup",
3780 data: {
3781 audience: jsGlobal.audience,
3782 degprogyr: jsGlobal.dpyr,
3783 acyr: jsGlobal.acyr,
3784 suppressed: jsGlobal.suppressedflag,
3785 ward: jsGlobal.wardflag,
3786 groupname: newname,
3787 userlist: temp
3788 }, dataType: "json"
3789
3790 });
3791 lv = (lv + percentage);
3792 setTimeout(function() {
3793 updateprogressbar(lv);
3794 }, 1000);
3795
3796
3797 }
3798
3799 } else {
3800 //numeric based
3801 for (var i = 0; i < parseInt(numberofgroups); i++) {
3802 newname = basename + (i + 1);
3803 var temp = Array();
3804 var len = sliced[i].length;
3805 for (var xx = 0; xx < len; xx++) {
3806 temp.push(sliced[i][xx].id);
3807 }
3808 $.ajax({
3809 type: "GET",
3810 async: false,
3811 cache: true,
3812 url: window.location + "/ajax_creategroup",
3813 data: {
3814 audience: jsGlobal.audience,
3815 degprogyr: jsGlobal.dpyr,
3816 acyr: jsGlobal.acyr,
3817 suppressed: jsGlobal.suppressedflag,
3818 ward: jsGlobal.wardflag,
3819 groupname: newname,
3820 userlist: temp
3821 }, dataType: "json"
3822
3823 });
3824 lv = (lv + percentage);
3825 setTimeout(function() {
3826 updateprogressbar(lv);
3827 }, 1000);
3828
3829 }
3830
3831 }
3832 $('#section_progressbar').hide();
3833 $('#ac_groups_popup').modal('hide');
3834 reloaddata();
3835 }
3836 // letters with groups > 26 !
3837 function complexsplitgroups(basename, numberofgroups, yearlistid) {
3838
3839 var OrigBaseName = basename;
3840 var key = "ABCDEFGHIJKLMNOPQURSTUVWXYZ";
3841 var lv = 0;
3842 var newname = "";
3843 var overflow = 25;
3844 var offset = 0;
3845 var users = getusersforyeargroup(yearlistid);
3846 users = shuffle(users);
3847 var sliced = split(users, parseInt(numberofgroups));
3848 var percentage = ((100 / parseInt(numberofgroups)));
3849 if (jsGlobal.ac_groups_append === 0) {
3850 // letter based
3851 var endpos = 0;
3852 for (var i = 0; i < parseInt(numberofgroups); i++) {
3853 if (parseInt(i) > overflow) {
3854 overflow = overflow + 25;
3855 basename = OrigBaseName + key.substring(offset, (offset + 1));
3856 offset = offset + 1;
3857 }
3858 var pos = offset;
3859 newname = basename + key.substring(endpos, (endpos + 1));
3860 endpos++;
3861 if (endpos > 25) {
3862 endpos = 0;
3863 }
3864 var temp = Array();
3865 var len = sliced[i].length;
3866 for (var xx = 0; xx < len; xx++) {
3867 temp.push(sliced[i][xx].id);
3868 }
3869 $.ajax({
3870 type: "GET",
3871 async: false,
3872 cache: true,
3873 url: window.location + "/ajax_creategroup",
3874 data: {
3875 audience: jsGlobal.audience,
3876 degprogyr: jsGlobal.dpyr,
3877 acyr: jsGlobal.acyr,
3878 suppressed: jsGlobal.suppressedflag,
3879 ward: jsGlobal.wardflag,
3880 groupname: newname,
3881 userlist: temp
3882 }, dataType: "json"
3883
3884 });
3885 lv = (lv + percentage);
3886 setTimeout(function() {
3887 updateprogressbar(lv);
3888 }, 1000);
3889 }
3890 }
3891 return true;
3892 }
3893
3894
3895 function split(a, n) {
3896 var len = a.length, out = [], i = 0;
3897 while (i < len) {
3898 var size = Math.ceil((len - i) / n--);
3899 out.push(a.slice(i, i + size));
3900 i += size;
3901 }
3902 return out;
3903 }
3904
3905
3906 /**
3907 * Updates the proggress bar in the
3908 * auto create groups dialog
3909 * as this can take some time to
3910 * create 50 groups the progress bar
3911 * provides the user with some
3912 * feedback that something is
3913 * happening.
3914 *
3915 * @param {integer} currentval
3916 *
3917 */
3918 function updateprogressbar(currentval) {
3919 setTimeout(function() {
3920 $("#progressbar").progressbar({
3921 value: currentval
3922 });
3923 }, 1000);
3924 }
3925
3926 function processbadges(x) {
3927
3928 x.success(function(resultarray) {
3929 var len = resultarray.length;
3930 var path = "";
3931 for (var i = 0; i < len; i++) {
3932 path = path + resultarray[i];
3933 }
3934 showbadges(path);
3935
3936 });
3937
3938 }
3939
3940
3941 function dobadges() {
3942
3943 $("#Processingbadge").hide();
3944 var data = '<i class="icon-spinner icon-spin icon-large"></i> <b>Preparing Badges...</b>';
3945 $("#Processingbadge").show().html(data).fadeIn('fast');
3946 //---------------------------------------------------------------------------------------------------------------------------------------------
3947 setTimeout(function() {
3948 var callajax = producebadges();
3949 var retval = processbadges(callajax);
3950 }, 1000);
3951 }
3952
3953 /**
3954 * this produces the badges based
3955 * on selection made in the print badges dialog
3956 * @returns void
3957 */
3958 function producebadges() {
3959 var ms = buildmenustring();
3960 var groupname = getgroupname(jsGlobal.currentGroup);
3961 return $.ajax({
3962 type: "GET",
3963 async: false,
3964 cache: true,
3965 url: window.location + "/ajax_badges_pdf",
3966 data: {groupid: jsGlobal.currentGroup,
3967 details: groupname,
3968 menustring: ms,
3969 picture: jsGlobal.pr_badge_photo
3970 }, dataType: "json"
3971 });
3972
3973
3974 //$('#print_badge_popup').modal('hide');
3975 }
3976
3977
3978 function showbadges(path) {
3979 var data = "";
3980 $("#Processingbadge").hide().html(data).fadeIn('fast');
3981 $('#print_badge_popup').modal('hide');
3982 window.open(path, '_blank', "menubar=no,status=no");
3983 }
3984
3985
3986 function closegroupchanges() {
3987 $(this).dialog('destroy');
3988 }
3989
3990 //Fisher–Yates shuffle
3991
3992 function shuffle(array) {
3993 var m = array.length, t, i;
3994 // While there remain elements to shuffle…
3995 while (m) {
3996 // Pick a remaining element…
3997 i = Math.floor(Math.random() * m--);
3998 // And swap it with the current element.
3999 t = array[m];
4000 array[m] = array[i];
4001 array[i] = t;
4002 }
4003 return array;
4004 }
4005
4006
4007 /**
4008 * open the advance search options
4009 *
4010 * @author James Boag <j.boag@abdn.ac.uk>
4011 * @version march-2014
4012 * @copyright Medi-CAL Unit, University of Aberdeen
4013 * @returns {undefined}
4014 */
4015 function addusersadvance() {
4016 //alert("Outch !");
4017 $('#edit_group_user_popup').height('650px');
4018
4019 // $('#modal-body').animate({"top":"-=150px"},"slow");
4020
4021
4022 $('#Advanced-search').slideDown("slow");
4023 $('#std-search').hide();
4024 var advMenu = "<a href='javascript: void(0)' onclick='javascript:removeusersadvance();'>Simple Search</a>";
4025 $('#popup_group_users_name').html("<table width='100%'><tr class='bb'><td align='left'>Group :" + jsGlobal.currentGroupName + "</td><td align='right'>" + advMenu + "</td></tr></table>");
4026 }
4027
4028 /**
4029 * close the advance search options
4030 *
4031 * @author James Boag <j.boag@abdn.ac.uk>
4032 * @version march-2014
4033 * @copyright Medi-CAL Unit, University of Aberdeen
4034 **/
4035 function removeusersadvance() {
4036 //alert("Outch !");
4037 $('#edit_group_user_popup').height('500px');
4038 var advMenu = "<a href='javascript: void(0)' onclick='javascript:addusersadvance();'>Advanced Search</a>";
4039 $('#popup_group_users_name').html("<table width='100%'><tr><td align='left'>Group :" + jsGlobal.currentGroupName + "</td><td align='right'>" + advMenu + "</td></tr></table>");
4040 $('#Advanced-search').hide();
4041 $('#std-search').show();
4042 }
4043
4044
4045
4046 function advancesearch() {
4047 var searchfor = $('#searchfor').val();
4048 var results = advsearch(searchfor);
4049 if (results.length > 0) {
4050
4051 }
4052 }
4053
4054 /**
4055 * open the advance search options
4056 *
4057 * @author James Boag <j.boag@abdn.ac.uk>
4058 * @version march-2014
4059 * @copyright Medi-CAL Unit, University of Aberdeen
4060 *
4061 * @param vlaue the text to search for
4062 **/
4063 function advsearch(value) {
4064 clearadvancedsearch();
4065
4066 var results = Array();
4067 var stringtosearch = "";
4068 var searcharray = Array();
4069 var user = "";
4070 var context = jsGlobal.advsearchcontext;
4071 var len = jsData.grouplist.static.length;
4072 for (var i = 0; i < len; i++) {
4073 user = jsData.grouplist.static[i];
4074 if (String(context) === "0") {
4075 stringtosearch = user.firstname + " " + user.lastname + " " + user.email;
4076 }
4077 if (String(context) === "1") {
4078 stringtosearch = user.firstname;
4079 }
4080 if (String(context) === "2") {
4081 stringtosearch = user.lastname;
4082 }
4083 if (String(context) === "3") {
4084 stringtosearch = user.email;
4085 }
4086 searcharray[i] = jsData.grouplist.static[i].id + "|" + stringtosearch.toLowerCase();
4087 stringtosearch = "";
4088 }
4089 var tosearch = "";
4090 for (var i = 0; i < len; i++) {
4091 tosearch = i + "|" + searcharray[i];
4092 var n = tosearch.search(value.toLowerCase());
4093 if (n !== -1) {
4094 var tmp = tosearch.split('|');
4095 results.push(parseInt(tmp[1]));
4096 addadvancesearchrow(parseInt(tmp[1]));
4097 }
4098 }
4099
4100 return results;
4101
4102 }
4103
4104
4105 function findidfromitem(item_id) {
4106 var len = jsData.grouplist.static.length;
4107 for (var i = 0; i < len; i++) {
4108 var scan = jsData.grouplist.static[i];
4109 if (String(scan.id) === String(item_id)) {
4110 return i;
4111 }
4112 }
4113 return -1;
4114 }
4115
4116 function addadvancesearchrow(id) {
4117 var i = findidfromitem(id);
4118 var html = "<tr class='bb'><td>" + jsData.grouplist.static[i].title + " " + jsData.grouplist.static[i].firstname + " " + jsData.grouplist.static[i].lastname + " " + jsData.grouplist.static[i].email + "</td><td><a href='javascript: void(0)' onclick='javascript:addadvanceditem(" + i + ");'><i class='icon-plus'></i></a></td></tr>";
4119 $('#advsearchcontents > tbody').append(html);
4120 }
4121
4122 function clearadvancedsearch() {
4123
4124 $('#advsearchcontents').html(' <tbody></tbody>');
4125 }
4126
4127 function addadvanceditem(id) {
4128 // var i = findidfromitem(id);
4129 advaddusers(id);
4130 }
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147 /**
4148 * TOOLS add a print_r function to javascript
4149 * *
4150 * @author James Boag <j.boag@abdn.ac.uk>
4151 * @version march-2014
4152 * @copyright Medi-CAL Unit, University of Aberdeen
4153 *
4154 * @param o the array to view.
4155 **/
4156
4157 function print_r(o) {
4158 return JSON.stringify(o, null, '\t').replace(/\n/g, '<br>').replace(/\t/g, ' ');
4159 }
4160 }
4161
4162
4163
4164
4165
4166</script>