1/* Civi stuff */ 2 3CRM.$(function($) { 4 5 6 $("#views-exposed-form-lecturers-directory-page select").select2(); 7 8 9 // Date in YYYY-MM-DD format 10 var d = new Date(); 11 var today = d.getFullYear() + "-" + (d.getMonth() + 1 ) + "-" + d.getDate(); 12 13 var yestrDate = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + (d.getDate() - 1); 14 15 // Datatable stuff 16 17 $('#activities_table').DataTable({ 18 retrieve: true, 19 "order": [[ 3, 'desc' ]], 20 }); 21 22 23 $('#related_waiting_members_table').DataTable({ 24 retrieve: true, 25 stateSave: true, 26 dom: 'frtBip', 27 buttons: [ 28 'copy', 'csv', 'excel', 'pdf', 'print' 29 ], 30 'columns': [ 31 null, 32 null, 33 null, 34 //null, 35 {className: "nowrap"} 36 ], 37 "order": [[ 1, 'asc' ], [ 0, 'asc' ]], 38 "drawCallback": function( settings ) { 39 40 if (CRM.vars) { 41 $.each(CRM.vars.relChange.relChange, function (key, value) { 42 // Convert to member 43 44 $("#addmember-" + value.rcontA + "-" + value.relID).on('click', function (e) { 45 e.preventDefault(); 46 CRM.confirm({ 47 width: 400, 48 title: ts('Are you sure?'), 49 message: ts('You are about to move a contact from Waiting List to Member. Please click' + 50 ' "Continue" to proceed.') 51 }) 52 .on('crmConfirm:yes', function () { 53 // Removing current Waiting Member relationship 54 CRM.api3('Relationship', 'create', { 55 "id": value.relID, 56 "contact_id_a": value.rcontA, 57 "contact_id_b": value.rcontB, 58 "relationship_type_id": value.rtypeID, 59 "end_date": yestrDate, 60 "is_permission_b_a": 0, 61 "is_permission_a_b": 0, 62 "is_active": 0 63 }), 64 // Add new Relationship 65 CRM.api3('Relationship', 'create', { 66 // "id": value.relID, 67 "contact_id_a": value.rcontA, 68 "contact_id_b": value.rcontB, 69 "relationship_type_id": 4, 70 "start_date": today, 71 "is_permission_b_a": 1, 72 "is_permission_a_b": 0, 73 "is_active": 1 74 }).done(function (result) { 75 //console.log(result); 76 var rid = result['id']; 77 if (result['is_error'] == 0) { 78 CRM.status(result.values[rid]['display_name'] + ' was successfully added as a Member!\n Refreshing page .. ', 'Success', 'success'); 79 //CRM.refreshParent; 80 location.reload(); 81 } 82 if (result['is_error'] == 1) { 83 CRM.status(result['error_message'], 'error', 'error'); 84 // console.log(result); 85 } 86 }); 87 }) 88 .on('crmConfirm:no', function () { 89 CRM.status('Cancelled', 'info'); 90 }) 91 // e.off(); 92 }); 93 94 95 // Remove from a Waiting List 96 97 $("#removefromwaiting-" + value.rcontA + "-" + value.relID).on('click', function (e) { 98 e.preventDefault(); 99 CRM.confirm({ 100 width: 400, 101 title: ts('Are you sure?'),
102 message: ts('You are about to remove a contact from Waiting List. Please click "Continue"' + 103 ' to proceed.') 104 }) 105 .on('crmConfirm:yes', function () { 106 // Removing current Waiting Member relationship 107 CRM.api3('Relationship', 'create', { 108 "id": value.relID, 109 "contact_id_a": value.rcontA, 110 "contact_id_b": value.rcontB, 111 "relationship_type_id": value.rtypeID, 112 "end_date": yestrDate, 113 "is_permission_b_a": 0, 114 "is_permission_a_b": 0, 115 "is_active": 0 116 }).done(function (result) { 117 //console.log(result); 118 //return; 119 var rid = result['id']; 120 if (result['is_error'] == 0) { 121 CRM.status(result.values[rid]['display_name'] + ' was successfully removed from a Waiting List.\n Refreshing page .. ', 'Success', 'success'); 122 //CRM.refreshParent; 123 location.reload(); 124 } 125 if (result['is_error'] == 1) { 126 CRM.status(result['error_message'], 'error', 'error'); 127 // console.log(result); 128 } 129 }); 130 }) 131 .on('crmConfirm:no', function () { 132 CRM.status('Cancelled', 'info'); 133 }) 134 e.off(); 135 }); 136 137 }); 138 } 139 //}); 140 } 141 }); 142 143 if ($('.page-civicrm-report-instance .crm-report-form-block table.display').length) { 144 $('.page-civicrm-report-instance .crm-report-form-block table.display').removeClass('display'); 145 } 146 $('table.civi-societyadmin-datatable').DataTable({ 147 retrieve: true, 148 stateSave: true, 149 'columns': [ 150 null, 151 null, 152 null, 153 {className: "nowrap"} 154 ], 155 156 "drawCallback": function( settings ) { 157 158// Check if variables came from php module aren't empty 159 if (CRM.vars) { 160 $.each(CRM.vars.relChange.relChange, function (key, value) { 161 $("#resign-" + value.rcontA + "-" + value.relID).on('click', function (e) { 162 e.preventDefault(); 163 CRM.api3('Relationship', 'getcount', { 164 "contact_id_a": value.rcontA, 165 "is_active": 1, 166 }).done(function (result) { 167 if (result.result > 1) { 168 rc1 = 1; 169 } 170 171 if (result.result <= 1) { 172 rc1 = 0; 173 } 174 }); 175 176 177 CRM.api3('Contact', 'getoptions', { 178 "field": "custom_1141" 179 }).done(function (result) { 180 str = ''; 181 $.each (result['values'], function (key, value) { 182 str = str + '<input type="radio" id="' + value.replace(/\s/g, '-') + '" name="' + value.replace(/\s/g, '-') + '" value="' 183 + key + '">' + '<label for="' + value.replace(/\s/g, '-') + '">'+ value 184 + '</label><br>' 185 }); 186 resReason(str); 187 }); 188 189 function resReason(d) { 190 CRM.confirm({ 191 width: 400, 192 title: ts('Are you sure?'), 193 message: ts('You are about to remove a ' 194 + value.rname + ' relation between ' 195 + value.iname + ' member and ' + value.oname + '.' 196 + '<br><br><u>Please select a reason below:</u>' 197 + '<form id="resReason" style="margin: 1rem 2rem;">' 198 + d 199 + '</form>' 200 + 'and click "OK" to proceed.'), 201 }) 202 .on('crmConfirm:yes', function () { 203 CRM.api3('Contact', 'create', { 204 "contact_type": "Individual", 205 "id": value.rcontA, 206 "custom_197": rc1, 207 "custom_1141": $("#resReason input[type='radio']:checked").val(), 208 // Relationships part 209 'api.Relationship.create': { 210 "id": value.relID, 211 "contact_id_a": value.rcontA, 212 "contact_id_b": value.rcontB, 213 "relationship_type_id": value.rtypeID, 214 "end_date": today,
215 "is_permission_b_a": 0, 216 "is_permission_a_b": 0, 217 "is_active": 0 218 }, 219 }).done(function (result) { 220 //console.log(result); 221 var rid = result['id']; 222 if (result['is_error'] == 0) { 223 CRM.status(result.values[rid]['display_name'] + ' was successfully resigned!<br>Refreshing page..', 'Success', 'success'); 224 //CRM.refreshParent; 225 location.reload(); 226 } 227 if (result['is_error'] == 1) { 228 CRM.status(result['error_message'], 'error', 'error'); 229 } 230 } 231 ); 232 }) 233 .on('crmConfirm:no', function () { 234 CRM.status('Cancelled', 'info'); 235 // location.reload(); 236 }); 237 //e.off(); 238 } 239 }); 240// Decease 241 $("#decease-" + value.rcontA + "-" + value.relID).on('click', function (e) { 242 e.preventDefault(); 243 CRM.confirm({ 244 width: 400, 245 title: ts('Are you sure?'), 246 message: ts('You are about to remove a member from your list who has died. ' + 247 'Please click "Continue" to proceed.') 248 }) 249 .on('crmConfirm:yes', function () { 250 CRM.api3('Contact', 'create', { 251 "contact_type": "Individual", 252 "id": value.rcontA, 253 "is_deceased": 1, 254 "deceased_date": yestrDate, 255 "custom_197": 0, 256 // Relationships part 257 'api.Relationship.create': { 258 "id": value.relID, 259 "contact_id_a": value.rcontA, 260 "contact_id_b": value.rcontB, 261 "relationship_type_id": value.rtypeID, 262 "end_date": yestrDate, 263 "is_permission_b_a": 0, 264 "is_permission_a_b": 0, 265 "is_active": 0 266 }, 267 }).done(function (result) { 268 //console.log(result); 269 var rid = result['id']; 270 if (result['is_error'] == 0) { 271 CRM.status(result.values[rid]['display_name'] + ' was sucessfully deceised!\n Refreshing page .. ', 'Success', 'success' ); 272 //CRM.refreshParent; 273 location.reload(); 274 } 275 if (result['is_error'] == 1) { 276 CRM.status(result['error_message'], 'error', 'error'); 277 } 278 }); 279 }) 280 .on('crmConfirm:no', function () { 281 CRM.status('Cancelled', 'info'); 282 }) 283 // e.off(); 284 }); 285 286 287 // the end 288 }) 289 } 290 291 292 } 293 }); 294 295 296 $('.page-user-sad #block-system-main').on('click', 'a.societymemberedit', CRM.popup); 297 $('.page-user-sad #block-system-main').on('click', 'a.waitinglist-member-edit', CRM.popup); 298 $('.page-user-sad #block-system-main').on('click', 'a.viewmember', CRM.popup); 299 $('.page-user-sad #block-system-main').on('click', 'a.viewwaiting', CRM.popup); 300 //$('.page-user-sad #block-system-main').on('crmPopupOpen', 'a.societymemberedit', function() {}); 301 $('.page-user-sad #block-system-main').on('crmPopupFormSuccess', 'a.societymemberedit', function() { 302 // var msg = CRM.status(); 303 // msg.resolve(); 304 // console.log(msg); 305 // CRM.refreshParent = function() {}; 306 // societymemberedit 307 }); 308 309 310 $('.page-user-sad #block-system-main') 311 .on('click', 'a.add_new_member', CRM.popup) 312 .on('crmPopupFormSuccess', 'a.add_new_member', function() { 313 CRM.alert= function() {}; 314 /* 315 $('#related_members_table').crmSnippet(); 316 $('#related_members_table').crmSnippet('refresh'); 317 */ 318 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'info' ); 319 location.reload(true); 320 321 }); 322 323 $('.page-user-sad #block-system-main') 324 .on('click', 'a.add_waiting_member', CRM.popup) 325 .on('crmPopupFormSuccess', 'a.add_waiting_member', function() { 326 CRM.alert= function() {}; 327 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'success' ); 328 location.reload(true); 329 }); 330 331 $('.page-user-sad #block-system-main') 332 .on('click', 'a.addcommiteemember', CRM.popup) 333 .on('crmPopupFormSuccess', 'a.addcommiteemember', function() { 334 CRM.alert= function() {}; 335 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'success' ); 336 location.reload(true); 337 }); 338 339 340 // Try to add select2 to lecturers search 341 342 $('#views-exposed-form-online-directory-for-lecturers-page select').select2({ 343 placeholder: 'Please click here to see a list of avail. options', 344 }); 345 346 $('#views-exposed-form-online-directory-for-lecturers-page-1 select').select2({ 347 placeholder: 'Please click here to see a list of avail. options', 348 }); 349 350// Hide Submit button at http://www.nadfas.org.uk/grants-pre-screening-application-page 351 352 $('#edit-submitted-please-tick-all-that-apply-9,' + 353 '#edit-submitted-please-tick-all-that-apply-10,' + 354 '#edit-submitted-please-tick-all-that-apply-11') 355 .click(function() { 356 if( $(this).is(':checked')) { 357 $(".form-actions").hide(); 358 } else { 359 $(".form-actions").show(); 360 } 361 }); 362 363 364 365});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.