Commit e51a6a07 authored by Mateus Ravedutti's avatar Mateus Ravedutti

Merge branch 'Issue_112' into 'master'

Issue 112

See merge request !247
parents acb96ef3 e0a3a7c3
load_professionals = (app_root_url, service_place_id = '', city_hall_id = 0) ->
$('select#report_professional_performer_id_eq').attr('disabled', 'disabled').html('<option value="">Carregando profissionais...</option>')
load_professionals = (app_root_url, field, service_place_id = '', city_hall_id = 0) ->
$(field).attr('disabled', 'disabled').html('<option value="">Carregando profissionais...</option>')
# get service_place's professionals
select = ['<option value="">Todos</option>']
if service_place_id == ''
......@@ -15,15 +15,15 @@ load_professionals = (app_root_url, service_place_id = '', city_hall_id = 0) ->
select.push('<option value="' + item.id + '">' + item.name + '</option>')
)
if select.length > 1
$('select#report_professional_performer_id_eq').html(select)
$(field).html(select)
.removeAttr('disabled')
else
$('select#report_professional_performer_id_eq').attr('disabled', 'disabled')
$(field).attr('disabled', 'disabled')
.html('<option value="">Nenhum profissional cadastrado neste local!</option>')
)
load_service_types = (app_root_url, service_place_id = '', city_hall_id = 0) ->
$('select#report_service_type_id_eq').attr('disabled', 'disabled').html('<option value="">Carregando tipos de atendimento...</option>')
load_service_types = (app_root_url, field, service_place_id = '', city_hall_id = 0) ->
$(field).attr('disabled', 'disabled').html('<option value="">Carregando tipos de atendimento...</option>')
# get service_place's service_types
select = ['<option value="">Todos</option>']
if service_place_id == ''
......@@ -39,16 +39,16 @@ load_service_types = (app_root_url, service_place_id = '', city_hall_id = 0) ->
select.push('<option value="' + item.id + '">' + item.description + '</option>')
)
if select.length > 1
$('select#report_service_type_id_eq').html(select)
$(field).html(select)
.removeAttr('disabled')
else
$('select#report_service_type_id_eq').attr('disabled', 'disabled')
$(field).attr('disabled', 'disabled')
.html('<option value="">Nenhum tipo de atendimento cadastrado neste local!</option>')
)
load_service_places = (app_root_url, city_hall_id) ->
$('select#report_service_place_id_eq').attr('disabled', 'disabled').html('<option value="">Carregando locais de atendimento...</option>')
# get city_hall's service_palces
load_service_places = (app_root_url, field, city_hall_id) ->
$(field).attr('disabled', 'disabled').html('<option value="">Carregando locais de atendimento...</option>')
# get city_hall's service_places
select = ['<option value="">Todos</option>']
$.getJSON(app_root_url + 'city_halls/' + parseInt(city_hall_id) + '/service_places')
.done((dados) ->
......@@ -56,13 +56,31 @@ load_service_places = (app_root_url, city_hall_id) ->
select.push('<option value="' + item.id + '">' + item.name + '</option>')
)
if select.length > 1
$('select#report_service_place_id_eq').html(select)
$(field).html(select)
.removeAttr('disabled')
else
$('select#report_service_place_id_eq').attr('disabled', 'disabled')
$(field).attr('disabled', 'disabled')
.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()
......@@ -981,32 +999,53 @@ $(document).ready ->
app_root_url = $("input#app_root_url").val()
city_hall_id = $("select#city_hall_id").val()
current_report = window.location.pathname.split('/').pop()
if(current_report == 'schedules_report')
professional_field = 'select#report_shift_professional_performer_id_eq'
service_place_field = 'select#report_service_place_id_eq'
service_type_field = 'select#report_shift_service_type_id_eq'
else if(current_report == 'services_report')
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'
service_type_field = 'select#report_service_type_id_eq'
if city_hall_id == undefined
if $('select#report_service_place_id_eq').val() != undefined
if $(service_place_field).val() != undefined
# adm_prefeitura
load_professionals(app_root_url)
load_service_types(app_root_url)
$('select#report_service_place_id_eq').on('change', () ->
service_place_id = $("select#report_service_place_id_eq").val()
load_professionals(app_root_url, service_place_id)
load_service_types(app_root_url, service_place_id)
load_professionals(app_root_url, professional_field)
load_service_types(app_root_url, service_type_field)
$(service_place_field).on('change', () ->
service_place_id = $(service_place_field).val()
load_professionals(app_root_url, professional_field, service_place_id)
load_service_types(app_root_url, service_type_field, service_place_id)
)
else
# adm_c3sl
city_id = $('select#city_hall_id').val()
load_service_places(app_root_url, city_id)
load_professionals(app_root_url,'',city_id)
load_service_types(app_root_url,'',city_id)
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, city_id)
load_professionals(app_root_url,'',city_id)
load_service_types(app_root_url,'',city_id)
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#report_service_place_id_eq').on('change', () ->
service_place_id = $("select#report_service_place_id_eq").val()
load_professionals(app_root_url, service_place_id)
load_service_types(app_root_url, service_place_id)
$(service_place_field).on('change', () ->
service_place_id = $(service_place_field).val()
load_professionals(app_root_url, professional_field, service_place_id)
load_service_types(app_root_url, service_type_field, service_place_id)
)
translate_weekday = (div, index) ->
switch index%7
......@@ -1026,4 +1065,4 @@ translate_weekday = (div, index) ->
day = 'SAB'
# error
$(div).html day
return
\ No newline at end of file
return
......@@ -20,10 +20,90 @@ get_date_object = (string, separator) ->
date_object
update_city_hall_child_selects = (city_hall_id) ->
if city_hall_id || city_hall_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'city_halls/' + city_hall_id + '/professionals.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, professional) ->
select.push('<option value="' + professional['id'] + '">' + professional['name'] + '</option>')
)
$('select#q_shift_professional_performer_id_eq').html(select)
else
$('select#q_shift_professional_performer_id_eq').html('<option value="">Todos </option>')
)
update_professional_child_selects = (professional_id) ->
if professional_id or professional_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'professionals/' + professional_id + '/service_places.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, service_place) ->
select.push('<option value="' + service_place[0] + '">' + service_place[1] + '</option>')
)
$('select#q_service_place_id_eq').html(select)
else
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
)
update_service_place_child_selects = (service_place_id) ->
if service_place_id or service_place_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'service_places/' + service_type_id + '/service_types.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, service_type) ->
select.push('<option value="' + service_type['id'] + '">' + service_type['description'] + '</option>')
)
$('select#q_shift_service_type_id_eq').html(select)
else
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
)
desabilita_selects_from_city_hall = () ->
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
$('select#q_shift_professional_performer_id_eq').html('<option value="">Todos </option>')
desabilita_select_service_place = () ->
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
desabilita_select_service_type = () ->
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
$(document).ready(->
# Parâmetros da URL
params = get_url_params()
$('select#q_service_place_city_hall_id_eq').on('change', () ->
city_hall_id = $("select#q_service_place_city_hall_id_eq").val()
update_city_hall_child_selects(city_hall_id)
desabilita_selects_from_city_hall()
)
$('select#q_shift_professional_performer_id_eq').on('change', () ->
professional_id = $("select#q_shift_professional_performer_id_eq").val()
update_professional_child_selects(professional_id)
desabilita_select_service_place()
desabilita_select_service_type()
)
$('select#q_service_place_id_eq').on('change', () ->
service_place_id = $("select#q_service_place_id_eq").val()
update_service_place_child_selects(service_place_id)
desabilita_select_service_type()
)
$('#reset_btn').click ->
$('.search-field').val('')
$('.ordenacao').val('Decrescente')
......
......@@ -4,7 +4,19 @@
<div id="search-form">
<%= search_form_for(@search) do |f| %>
<div class="field-h col s12 m6 l3">
<div class="field-h col s12 m6 l3">
<%= f.label :city_hall_id, t(:city_hall) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :city_hall_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos" }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :city_hall_id_eq, CityHall.where(id: @currentCityHall.id),
:id, :name, { disabled: true }, { :class => "search-field" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :name, t(:Name)+": " %><br />
<%= f.text_field :name_cont, :class => "search-field"%>
</div>
......
......@@ -17,7 +17,7 @@
<%= f.label :service_places_city_hall_id, t(:city_hall) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :service_places_city_hall_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos" }, { :class => "search-field" } %>
:id, :name, { :include_blank => "Todos", selected: 0 }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :service_places_city_hall_id_eq, CityHall.where(id: @currentCityHall.id),
:id, :name, { disabled: true }, { :class => "search-field" } %>
......
......@@ -4,6 +4,15 @@
<div id="search-form">
<%= search_form_for(@search, :url => { :controller => "users", :action => 'index'}) do |f| %>
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<div class="field-h col s12 m6 l3">
<%= f.label :city_hall, t(:city_hall)+": " %><br />
<%= f.collection_select :city_city_halls_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos" }, { :class => "search-field" } %>
</div>
<% end %>
<div class="field-h col s12 m6 l3">
<%= f.label :name, t(:Name)+": " %><br />
<%= f.text_field :name_cont, :class => "search-field" %>
......
......@@ -31,32 +31,45 @@
{ :value => @limite_fim.strftime("%d/%m/%Y"), :class => "date agendamentos_atend_calendario", :readonly => "true" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_city_hall_id, t(:city_hall) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :service_place_city_hall_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos", selected: 0 }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :service_place_city_hall_id_eq, CityHall.where(id: @currentCityHall.id),
:id, :name, { disabled: true }, { :class => "search-field" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :shift_professional_performer_id, t(:Professional)+": " %><br />
<%= f.collection_select :shift_professional_performer_id_eq, @professionals,
<%= f.collection_select :shift_professional_performer_id_eq, [],
:id, :name, {:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id_eq, t(:service_place) %><br />
<%= f.collection_select :service_place_id_eq, [], :id,
:name,{ :include_blank => "Todos" },
{ :class => "search-field" } %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :escala_tipo_atendimento_id, t(:service_type)+": " %><br />
<%= f.collection_select :shift_service_type_id_eq, @city_service_types,
<%= f.collection_select :shift_service_type_id_eq, [],
:id, :description, {:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :situation_id, t(:Situation)+": " %><br />
<%= f.collection_select :situation_id_eq, @situations, :id,
:description, {:include_blank => "Todos"},
{:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id_eq, t(:service_place) %><br />
<%= f.collection_select :service_place_id_eq, @city_service_places, :id,
:name,{ :include_blank => "Todos" },
{ :class => "search-field" } %>
</div>
</div>
<div class="actions">
......
......@@ -25,10 +25,16 @@
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :city, t(:city)+": " %><br />
<%= f.text_field :city_name_cont, :class => "search-field" %>
<%= f.label :city_hall_id, t(:city_hall) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :city_hall_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos" }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :city_hall_id_eq, CityHall.where(id: @currentCityHall.id),
:id, :name, { disabled: true }, { :class => "search-field" } %>
<% end %>
</div>
<% end %>
<% end %>
<div class="field-h col s12 m6 l3">
<%= f.label :active, t(:Situation)+": " %><br />
......
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