300 savePersons($(this).closest('.live-table-card')); 301 }); 302 303 $('.table-status-select').change(function(){ 304 var c = $(this).closest('.live-table-card'); 305 306 $.post('/modules/live-tables/' + c.data('table-id') + '/status', { 307 _token: $('meta[name="csrf-token"]').attr('content'), 308 table_status: $(this).val() 309 }, function(r){ 310 if(r.success){ 311 location.reload(); 312 } 313 }); 314 }); 315 316 // ===================================================== 317 // OCCUPIED TABLE SEARCH 318 // Empty search = all tables 319 // Typed search = occupied tables only 320 // Searches: table, floor, invoice, customer, mobile, waiter 321 // ===================================================== 322 function filterOccupiedTables(){ 323 var search = $.trim($('#occupied_table_search').val()).toLowerCase(); 324 var found = 0; 325 326 $('.live-table-wrapper').each(function(){ 327 var wrapper = $(this); 328 329 if(search === ''){ 330 wrapper.show(); 331 return; 332 } 333 334 if(wrapper.attr('data-status') !== 'occupied'){ 335 wrapper.hide(); 336 return; 337 } 338 339 var searchableText = (wrapper.attr('data-search') || '').toLowerCase(); 340 341 if(searchableText.indexOf(search) !== -1){ 342 wrapper.show(); 343 found++; 344 } else { 345 wrapper.hide(); 346 } 347 }); 348 349 if(search !== '' && found === 0){ 350 $('#occupied_search_no_result').show(); 351 } else { 352 $('#occupied_search_no_result').hide(); 353 } 354 } 355 356 $('#occupied_table_search').on('keyup input', filterOccupiedTables); 357 358 $('#clear_occupied_search').click(function(){ 359 $('#occupied_table_search').val(''); 360 filterOccupiedTables(); 361 $('#occupied_table_search').focus(); 362 }); 363 364 // Keep existing auto refresh, but don't destroy an active search. 365 setTimeout(function(){ 366 if($.trim($('#occupied_table_search').val()) === ''){ 367 location.reload(); 368 } 369 }, 30000); 370 371 }); 372 373 @endsection