Commit 8ec112b0 authored by Mateus Ravedutti's avatar Mateus Ravedutti

Fix professionals report search form

parent 92d962e0
......@@ -63,6 +63,24 @@ load_service_places = (app_root_url, field, city_hall_id) ->
.html('<option value="">Nenhum local de atendimento cadastrado nesta prefeitura!</option>')
)
load_occupations = (app_root_url, city_hall_id) ->
$('select#q_occupation_id_eq').attr('disabled', 'disabled').html('<option value="">Carregando cargos...</option>')
select = ['<option value="">Todos</option>']
$.getJSON(app_root_url + 'city_halls/' + parseInt(city_hall_id) + '/occupations.json')
.done((dados) ->
$.each(dados, (i, item) ->
select.push('<option value="' + item['id'] + '">' + item['name'] + '</option>')
)
if select.length > 1
$('select#q_occupation_id_eq').html(select)
.removeAttr('disabled')
else
$('select#q_occupation_id_eq').attr('disabled', 'disabled')
.html('<option value="">Nenhum cargo cadastrado nesta prefeitura!</option>')
)
$(document).ready ->
$('#reset_button_report').click((e) ->
e.preventDefault()
......@@ -984,8 +1002,6 @@ $(document).ready ->
current_report = window.location.pathname.split('/').pop()
service_place_field = 'select#q_service_places_id_eq'
if(current_report == 'schedules_report')
professional_field = 'select#report_shift_professional_performer_id_eq'
service_place_field = 'select#report_service_place_id_eq'
......@@ -994,6 +1010,8 @@ $(document).ready ->
professional_field = 'select#services_shift_professional_performer_id_eq'
service_place_field = 'select#services_service_place_id_eq'
service_type_field = 'select#services_shift_service_type_id_eq'
else if(current_report == 'professionals_report')
service_place_field = 'select#q_service_places_id_eq'
else
professional_field = 'select#report_professional_performer_id_eq'
service_place_field = 'select#report_service_place_id_eq'
......@@ -1016,11 +1034,13 @@ $(document).ready ->
load_service_places(app_root_url, service_place_field, city_id)
load_professionals(app_root_url, professional_field, '',city_id)
load_service_types(app_root_url, service_type_field,'',city_id)
load_occupations(app_root_url, city_id)
$('select#city_hall_id').on('change', () ->
city_id = $('select#city_hall_id').val()
load_service_places(app_root_url,service_place_field,city_id)
load_professionals(app_root_url,professional_field,'',city_id)
load_service_types(app_root_url,service_type_field,'',city_id)
load_occupations(app_root_url, city_id)
)
$(service_place_field).on('change', () ->
service_place_id = $(service_place_field).val()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment