Commit df590d97 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Merge branch 'hotfix_issue_109' into 'master'

Hotfix issue 109

See merge request !226
parents 02293fd6 6412a9bc
......@@ -33,7 +33,7 @@ class ProfessionalsController < ApplicationController
.includes(:service_places)
else
@serviceplaces = ServicePlace.where(:id => @currentCityHall.service_places).order(:name)
@serviceplaces = ServicePlace.where(:id => @currentCityHall.service_places).order('name ASC')
@professionals = @search.result.where.not(id: @currentProfessionalServicePlace.professional.id)
.where.not(professionals_service_places: {role: "adm_c3sl"})
.includes(:professionals_service_places)
......@@ -42,7 +42,7 @@ class ProfessionalsController < ApplicationController
end
else
@serviceplaces = ServicePlace.all.order(:name)
@serviceplaces = ServicePlace.all.order('name ASC')
@professionals = @search.result.where.not(professionals_service_places: {role: "adm_c3sl"})
.includes(:professionals_service_places)
end
......@@ -56,6 +56,7 @@ class ProfessionalsController < ApplicationController
@roles.pop
end
end
@roles.sort!
@professionals = @professionals.paginate(page: params[:page], per_page: 25)
......@@ -115,10 +116,13 @@ class ProfessionalsController < ApplicationController
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.active.where(:city_hall => @currentCityHall)
@places = ServicePlace.active.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.active
@places = ServicePlace.active.order('name ASC')
end
@roles.sort!
places_professional = @professional.professionals_service_places.active.pluck(:service_place_id,:role)
places_a = []
places_professional.each do |place, role|
......@@ -183,10 +187,12 @@ class ProfessionalsController < ApplicationController
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.where(:city_hall => @currentCityHall)
@places = ServicePlace.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.all
@places = ServicePlace.all.order('name ASC')
end
@roles.sort!
if @currentProfessionalServicePlace.role == "adm_local"
if !params[:role][:name].empty?
params[:add_places] = @currentProfessionalServicePlace.service_place.id.to_s+','+params[:role][:name].to_s
......@@ -768,10 +774,11 @@ end
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.active.where(:city_hall => @currentCityHall)
@places = ServicePlace.active.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.active
@places = ServicePlace.active.order('name ASC')
end
@roles.sort!
if params[:citizen]
if !params[:citizen][:cpf]
......@@ -801,10 +808,12 @@ end
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.active.where(:city_hall => @currentCityHall)
@places = ServicePlace.active.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.active
@places = ServicePlace.active.order('name ASC')
end
@roles.sort!
if @currentProfessionalServicePlace.role == "adm_local"
if !params[:role][:name].empty?
params[:add_places] = @currentProfessionalServicePlace.service_place.id.to_s+','+params[:role][:name].to_s
......@@ -887,10 +896,12 @@ end
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.where(:city_hall => @currentCityHall)
@places = ServicePlace.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.all
@places = ServicePlace.all.order('name ASC')
end
@roles.sort!
@citizen = Citizen.find(params[:citizen_id])
if @citizen.professional
redirect_to search_professional_path, alert: "Este cidadão já é um profissional."
......@@ -910,10 +921,12 @@ end
@roles.pop
@current_place = @currentProfessionalServicePlace.service_place.name
end
@places = ServicePlace.where(:city_hall => @currentCityHall)
@places = ServicePlace.where(:city_hall => @currentCityHall).order('name ASC')
else
@places = ServicePlace.all
@places = ServicePlace.all.order('name ASC')
end
@roles.sort!
if @currentProfessionalServicePlace.role == "adm_local"
if !params[:role][:name].empty?
params[:add_places] = @currentProfessionalServicePlace.service_place.id.to_s+','+params[:role][:name].to_s
......
......@@ -56,12 +56,15 @@ class ReportsController < ApplicationController
@professionals = @search.result
if @currentProfessionalServicePlace.role != "adm_c3sl" && @currentProfessionalServicePlace.role != "adm_prefeitura"
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id)
@occupation = Occupation.where(city_hall_id: @currentCityHall.id).all.order('name ASC')
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id).order('name ASC')
else
if @currentProfessionalServicePlace.role != "adm_c3sl"
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id)
@occupation = Occupation.where(city_hall_id: @currentCityHall.id).all.order('name ASC')
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id).order('name ASC')
else
@serviceplaces = ServicePlace.all
@occupation = Occupation.active.all.order('name ASC')
@serviceplaces = ServicePlace.all.order('name ASC')
end
end
......@@ -321,32 +324,29 @@ class ReportsController < ApplicationController
end
def schedule_select_shifts_report
@link = "Relatórios"
@link2 = "Escalas"
@search = Shift.search(params[:report])
if @currentProfessionalServicePlace.role == "adm_prefeitura"
@serviceplaces = ServicePlace.where(:city_hall_id => @currentCityHall.id)
@professionals = []
@serviceplaces = ServicePlace.where(:city_hall_id => @currentCityHall.id).order('name ASC')
@professionals = Professional.active.hide_c3sl_user.where(service_places: {city_hall_id: @currentCityHall.id}).includes(:service_places)
elsif @currentProfessionalServicePlace.role == "adm_c3sl"
@serviceplaces = ServicePlace.all
@serviceplaces = ServicePlace.all.order('name ASC')
@professionals = Professional.active.hide_c3sl_user
else
@professionals = Professional.joins(:professionals_service_places)
.where(:professionals_service_places => {
:active => true
})
.where(:professionals_service_places => {
:service_place_id => @currentProfessionalServicePlace.service_place.id
})
.uniq
@professionals = Professional.where(:professionals_service_places => { :active => true })
.where(:professionals_service_places => { :service_place_id => @currentProfessionalServicePlace.service_place.id })
.includes(:professionals_service_places)
end
@shifts = @search.result
@search.build_sort
if not @professionals.nil?
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
end
respond_to do |format|
format.html
end
......@@ -460,10 +460,10 @@ class ReportsController < ApplicationController
@search.build_sort
if !current_citizen.professional.administradorc3sl?
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id)
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id).order('name ASC')
@professionals = Professional.active.hide_c3sl_user.where(service_places: {city_hall_id: @currentCityHall.id}).includes(:service_places)
else
@serviceplaces = ServicePlace.all
@serviceplaces = ServicePlace.all.order('name ASC')
@professionals = Professional.active.hide_c3sl_user
end
......@@ -473,6 +473,11 @@ class ReportsController < ApplicationController
@tipos_atendimento = @tipos_atendimento.joins(:service_places => :schedules).where(:schedules => {:citizen_id => current_citizen})
end
@tipos_atendimento = @tipos_atendimento.order('description ASC')
if not @professionals.nil?
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
end
respond_to do |format|
format.html
end
......@@ -680,8 +685,8 @@ class ReportsController < ApplicationController
@search = Schedule.search(params[:services])
@search.build_sort
@tipos_atendimento = ServiceType.active
@tipos_situacoes = Situation.select("id, description")
@tipos_atendimento = ServiceType.active.order('description ASC')
@tipos_situacoes = Situation.select("id, description").order('description ASC')
@atendimentos = @search.result
.joins(:shift => :service_place)
.where('shifts.data_execucao >= ?', Date.today)
......@@ -692,6 +697,11 @@ class ReportsController < ApplicationController
.where(:service_places => { :id => current_citizen.professional.service_places, :active => true })
end
@serviceplaces = @serviceplaces.order('name ASC')
if not @professionals.nil?
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
end
respond_to do |format|
format.html
end
......
......@@ -110,7 +110,7 @@ class SchedulesController < ApplicationController
if @currentProfessionalServicePlace.role == "adm_c3sl"
# As adm_c3sl
# Get all active sectors
@sectors = Sector.active
@sectors = Sector.active.order('name ASC')
# Get all active service places
@city_service_places = ServicePlace.active
# Get all active service types
......@@ -120,7 +120,7 @@ class SchedulesController < ApplicationController
elsif @currentProfessionalServicePlace.role == "adm_prefeitura"
# As adm_prefeitura
# Get all active sectors of its city hall
@sectors = @currentCityHall.sectors.active
@sectors = @currentCityHall.sectors.active.order('name ASC')
# Get all active service places of its city hall
@city_service_places = @currentCityHall.service_places.active
# Get all active service types of its city hall
......@@ -136,7 +136,7 @@ class SchedulesController < ApplicationController
.uniq
.where(:service_places => {
:id => @currentProfessionalServicePlace.service_place
})
}).order('name ASC')
# Get its service place
@city_service_places = @currentProfessionalServicePlace.service_place
# Get the active service types of this service place
......@@ -277,28 +277,28 @@ class SchedulesController < ApplicationController
redirect_to :controller => "reports",
:action => "schedule_select_services_report"
else
@search = Schedule.search(params[:q])
@schedules = @search.result
if @currentProfessionalServicePlace.role == "adm_c3sl"
# As adm_c3sl
# Get all active sectors
@sectors = Sector.active
@sectors = Sector.active.order('name ASC')
# Get all active service places
@city_service_places = ServicePlace.active
@city_service_places = ServicePlace.active.order('name ASC')
# Get all active service types
@city_service_types = ServiceType.active
# Get all active available schedules
@schedules = @schedules.where.not(:situation => Situation.disponivel)
# Get all active professionals
@professionals = Professional.active
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
elsif @currentProfessionalServicePlace.role == "adm_prefeitura"
# As adm_prefeitura
# Get all active sectors of its city hall
@sectors = @currentCityHall.sectors.active
@sectors = @currentCityHall.sectors.active.order('name ASC')
# Get all active service places of its city hall
@city_service_places = @currentCityHall.service_places.active
@city_service_places = @currentCityHall.service_places.active.order('name ASC')
# Get all active service types of its city hall
@city_service_types = ServiceType.active.joins(:sector)
.where(:sectors => {:city_hall_id => @currentCityHall})
......@@ -307,8 +307,10 @@ class SchedulesController < ApplicationController
.joins(:service_place)
.where(:service_places => {:city_hall_id => @currentCityHall})
# Get all active professionals of its city hall's service places
@professionals = Professional.active.joins(:service_places)
@professionals = Professional.active
.where(:service_places => {:city_hall_id => @currentCityHall})
.includes(:service_places)
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
elsif ["adm_local","atendente_local"].include?(@currentProfessionalServicePlace.role)
# As adm_local
# Get all active sectors of its service_place
......@@ -316,9 +318,10 @@ class SchedulesController < ApplicationController
.uniq
.where(:service_places => {
:id => @currentProfessionalServicePlace.service_place
})
}).order('name ASC')
# Get its service place
@city_service_places = [@currentProfessionalServicePlace.service_place]
@city_service_places.sort!
# Get the active service types of this service place
@city_service_types = @city_service_places.first.service_types.active
# Get the available schedules from this service place
......@@ -326,15 +329,17 @@ class SchedulesController < ApplicationController
.where.not(:situation => Situation.disponivel)
# Get all active professionals of its service_place
@professionals = @city_service_places.first.professionals
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
elsif @currentProfessionalServicePlace.role == "responsavel_atendimento"
# Get all active sectors of its service_place
@sectors = @sectors = Sector.active.joins(:service_types => :service_places)
.uniq
.where(:service_places => {
:id => @currentProfessionalServicePlace.service_place
})
}).order('name ASC')
# Get its service place
@city_service_places = [@currentProfessionalServicePlace.service_place]
@city_service_places.sort!
# Get the active service types of this service place
@city_service_types = @city_service_places.first.service_types.active
# Get the available schedules from this service place
......@@ -342,8 +347,11 @@ class SchedulesController < ApplicationController
.where.not(:situation => Situation.disponivel)
# Get all active professionals of its service_place
@professionals = [@currentProfessionalServicePlace.professional]
@professionals.sort!
end
@city_service_types = @city_service_types.order('description ASC')
# Default values to service start and end time
treshold = @currentCityHall.schedule_period.days
# @limite_inicio = (Time.now - treshold).beginning_of_day #Dia atual - limite da prefeitura
......@@ -367,7 +375,7 @@ class SchedulesController < ApplicationController
@schedules = @schedules.paginate(page: params[:page], per_page: 25)
@situations = Situation.where.not(description: "Disponível")
.select("id, description")
.select("id, description").order('description ASC')
respond_to do |format|
format.html # atendimento.html.erb
format.js # atendimento.js.erb
......
......@@ -107,7 +107,7 @@ class SectorsController < ApplicationController
# Get city_halls to fill colletion input in new and edit
def fetch_dependencies
@city_halls = CityHall.all.order(:name)
@city_halls = CityHall.all.order('name ASC')
end
# Only allow a trusted parameter "white list" through.
......
......@@ -56,7 +56,7 @@ class ServiceTypesController < ApplicationController
@service_type = ServiceType.find(params[:id])
@service_type_city_hall = @service_type.sector.city_hall
@setores = Sector.where(:city_hall => @service_type_city_hall)
@setores = Sector.where(:city_hall => @service_type_city_hall).order('name ASC')
if current_citizen.professional.administradorc3sl?
......
......@@ -56,10 +56,19 @@ class ShiftsController < ApplicationController
# Escalas para o local de atendimento do profissional
# que está logado no sistema.
start_date = Date.today
if not params[:q].nil?
if not params[:q][:execution_start_time_gteq].nil?
start_date = Date.strptime(params[:q][:execution_start_time_gteq], '%d/%m/%Y')
end
end
@shifts = @search.result
.where(:next_shift => nil)
.where("execution_start_time >= ?", start_date)
.order(execution_start_time: :asc)
# .where("execution_start_time >= ?", Date.today)
if non_specified
@shifts = @shifts.where(:professional_performer_id => nil)
......@@ -96,6 +105,9 @@ class ShiftsController < ApplicationController
@professional_places = @professional_places.where(id: @currentProfessionalServicePlace.service_place_id)
@shifts = @shifts.where(service_place_id: @currentProfessionalServicePlace.service_place_id)
end
@professional_places = @professional_places.order('name ASC')
# Adiciona o campo situation para cada escala, com o número de agendamentos que não foram cancelados. Se todos estão cancelados, então não devemos permitir a alteração
@canceled_situation_id = Situation.where(description: "Cancelado").first.id
......@@ -667,12 +679,12 @@ class ShiftsController < ApplicationController
end
def load_professionals_and_service_types
@place_service_types = ServiceType.active.order('description ASC')
@place_service_types = ServiceType.active
if @currentProfessionalServicePlace.role != "adm_c3sl"
@service_places_professionals = Professional.where(service_places: {city_hall_id: @currentCityHall.id}).includes(:service_places).hide_c3sl_user.order('name ASC')
@service_places_professionals = Professional.where(service_places: {city_hall_id: @currentCityHall.id}).includes(:service_places).hide_c3sl_user
else
# mostrar apenas profissionais ativos
@service_places_professionals = Professional.all.order('name ASC')
@service_places_professionals = Professional.all
end
if @currentProfessionalServicePlace.role != "adm_prefeitura" && @currentProfessionalServicePlace.role != "adm_c3sl"
......@@ -693,7 +705,7 @@ class ShiftsController < ApplicationController
end
@place_service_types = @place_service_types.order('description ASC')
@service_places_professionals = @service_places_professionals.order('name ASC')
@service_places_professionals = @service_places_professionals.order('citizens.name ASC').includes(:citizen)
end
......
......@@ -12,7 +12,7 @@
<div class="field-h col s12 m6 l3">
<%= f.label :occupation_id, t(:Occupation)+":" %><br />
<%= f.collection_select :occupation_id_eq, Occupation.active.all, :id, :name,
<%= f.collection_select :occupation_id_eq, @occupation, :id, :name,
{ :include_blank => "Todos" }, { :class => "search-field" } %>
</div>
......@@ -33,11 +33,9 @@
<div class="field-h col s12 m6 l3">
<%= f.label :professionals_service_places_role, t(:role)+": " %><br />
<% #.zip transformer the two arrays selected into one %>
<%= f.select :professionals_service_places_role_eq,
options_for_select(t(@currentProfessionalServicePlace.inferior_roles).zip(@currentProfessionalServicePlace.inferior_roles)),
<%= f.select :professionals_service_places_role_eq, options_for_select(t(@currentProfessionalServicePlace.inferior_roles.sort)
.zip(@currentProfessionalServicePlace.inferior_roles.sort)),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
......
......@@ -58,7 +58,7 @@
<div class="field-h col s12 m4 l4">
<%= f.label :situation_id, t(:Situation)+": " %><br />
<%= f.collection_select :situation_id_eq,
Situation.all, :id, :description,
Situation.all.order('description ASC'), :id, :description,
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
......
......@@ -15,13 +15,13 @@
<br>
<% if @currentProfessionalServicePlace.role != "adm_c3sl"%>
<div class="field-h col s12 m6 l3">
<div class="field-h col s12 m4 l4">
<%= f.label :service_place_id, t(:service_place) + ":" %><br />
<%= f.text_field :service_place_id_eq, { :class => 'search-field', :value => @serviceplaces[0].name, :disabled => true} %>
<%= f.hidden_field :service_place_id_eq, { :class => 'search-field', :value => @serviceplaces[0].id, :readonly => true} %>
</div>
<% else %>
<div class="field-h col s12 m6 l3">
<div class="field-h col s12 m4 l4">
<%= f.label :service_place_id, t(:service_place) + ":" %><br />
<%= f.collection_select :service_place_id_eq, @serviceplaces, :id, :name,
{ :include_blank => "Todos"}, { :class => "search-field" } %>
......
......@@ -31,15 +31,12 @@
<div class="field-h col s12 m6 l3">
<%= f.label :service_type_id, t(:service_type)+": " %><br />
<% if @currentProfessionalServicePlace.role != "adm_local" %>
<%= f.select :service_type_id_eq,
options_from_collection_for_select([],
"id","description",@search.service_type_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<%= f.select :service_type_id_eq, options_from_collection_for_select([], "id", "description", @search.service_type_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% else %>
<%= f.select :service_type_id_eq,
options_from_collection_for_select(@currentProfessionalServicePlace.service_place.service_types,
"id","description",@search.service_type_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<%= f.select :service_type_id_eq, options_from_collection_for_select(@currentProfessionalServicePlace.service_place.service_types,
"id","description",@search.service_type_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% end %>
</div>
......
......@@ -19,17 +19,15 @@
<%= hidden_field_tag :app_url, root_url %>
<div class="col s12 m6 l6">
<div class="col s12 m12 l6">
<% if current_citizen.professional.administradorc3sl? %>
<%= f.label :city_hall_id, t(:city_hall)+"*:" %><br />
<div class="field-required">
<%= f.label :city_hall_id, t(:city_hall)+"*:" %><br />
<%= f.collection_select(:city_hall_id, @city_halls, :id, :name,
{ :include_blank => "Selecione uma prefeitura" }, { :class => "search-field" }) %>
</div>
<% end %>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :active, t(:Situation)+"*:" %><br />
<% if @sector.new_record? %>
......@@ -38,57 +36,44 @@
<%= f.select :active, [["Ativo",true],["Inativo",false]] %>
<% end %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :name, t(:Name)+"*:" %><br />
<%= f.text_field :name %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :schedules_by_sector, t(:number_schedules_by_sector)+"*:" %><br />
<%= f.text_field :schedules_by_sector, :type => 'number' %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :blocking_days, "Número de dias de impedimento de novos agendamentos*: " %><br />
<%= f.number_field :blocking_days%>
</div>
</div>
<div class="col s12 m6 l6">
<div class="col s12 m12 l6">
<div class="field-required">
<%= f.label :cancel_limit, t(:cancel_limit)+"*: " %><br />
<%= f.number_field :cancel_limit %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :prior_cancel_hours, "Horas de antecedência para poder cancelar um atendimento*: " %><br />
<%= f.number_field :prior_cancel_hours %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :absence_max, "Número de faltas que gera impedimento de
novos agendamentos*: " %><br />
<%= f.label :absence_max, "Número de faltas que gera impedimento de novos agendamentos*: " %><br />
<%= f.number_field :absence_max %>
</div>
</div>
<div class="field-required">
<%= f.label :description, t(:Description)+"*:" %><br />
<%= f.text_area :description, {:class => "materialize-textarea"} %>
</div>
</div>
</div>
<div class="card-action">
......
......@@ -36,7 +36,7 @@
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :cep, "CEP: " %><br />
<%= f.label :cep, "CEP*: " %><br />
<%= f.text_field :cep, :class => "cep", :type => "tel", :placeholder => "Digite o CEP" %>
</div>
</div>
......@@ -44,10 +44,10 @@
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :neighborhood, t(:neighborhood)+"*: " %><br />
<%= f.text_field :neighborhood, { :disabled => "disabled" } %>
<%= f.text_field :neighborhood, { :disabled => "disabled", value: "Digite um CEP válido" }%>
</div>
</div>
<div class="col s12 m6 l6">
<div class="col s12 m6 l6">
<div class="field-required">
<%= label_tag :state_id, t(:state)+"*:" %><br />