Commit 2d85873e authored by Pedro Henrique's avatar Pedro Henrique

fix merge conflicts

Signed-off-by: Pedro Henrique's avatarPedro Henrique! <pha14@inf.ufpr.br>
parents 35448a99 770d0c1b
......@@ -78,9 +78,50 @@ carrega_cep = ->
$("select#citizen_city_id").val("")
)
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 + '/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['id'] + '">' + service_place['name'] + '</option>')
)
$('select#q_service_places_id_eq').html(select)
else
$('select#q_service_places_id_eq').html('<option value="">Todos </option>')
)
$.getJSON(app_root_url + 'city_halls/' + city_hall_id + '/occupations.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, occupation) ->
select.push('<option value="' + occupation['id'] + '">' + occupation['name'] + '</option>')
)
$('select#q_occupation_id_eq').html(select)
else
$('select#q_occupation_id_eq').html('<option value="">Todos </option>')
)
desabilita_selects_from_city_hall = () ->
$('select#q_service_places_id_eq').html('<option value="">Todos </option>')
$('select#q_occupation_id_eq').html('<option value="">Todos </option>')
$(document).ready(->
$('#service_places__id').material_select();
$('select#q_service_places_city_hall_id_eq').on('change', () ->
city_hall_id = $("select#q_service_places_city_hall_id_eq").val()
update_city_hall_child_selects(city_hall_id)
desabilita_selects_from_city_hall()
)
$('.multiple-select-dropdown li').hide ->
id = $(".multiple-select-dropdown").attr("id")
$('#service_places__id').material_select();
......@@ -89,6 +130,8 @@ $(document).ready(->
);
$(document).ready(->
$('#reset_button').click ->
$('.search-field').val('')
$('.cpf').val('')
......
......@@ -163,13 +163,15 @@ class CityHallsController < ApplicationController
def sectors
begin
p = CityHall.find(params[:city_hall_id])
sectors = p.sectors.active.pluck(:id, :name)
sectors = sectors.sort_by { |s| s[1] }
respond_to do |format|
format.json { render json: p.sectors.pluck(:id, :name) }
end
rescue
respond_to do |format|
format.json { head :no_content }
format.json { render json: sectors }
end
#rescue
# respond_to do |format|
# format.json { head :no_content }
#end
end
end
......@@ -184,13 +186,15 @@ class CityHallsController < ApplicationController
c = CityHall.find(params[:city_hall_id])
end
professionals = []
c.service_places.each do |s|
c.service_places.active.each do |s|
s.professionals.joins(:citizen).pluck(:id,:name).each do |p|
professionals.push({:id => p[0], :name => p[1]})
end
end
professionals = professionals.uniq
professionals = professionals.sort_by { |professional| professional[:name] }
respond_to do |format|
format.json { render json: professionals }
end
......@@ -209,11 +213,13 @@ class CityHallsController < ApplicationController
end
service_types_vector = ServiceType.active.joins(:sector).where(:sectors => {:city_hall_id => c})
service_types = []
service_types_vector.pluck(:id,:description).each do |s|
service_types_vector.active.pluck(:id,:description).each do |s|
service_types.push({:id => s[0], :description => s[1]})
end
service_types = service_types.uniq
service_types = service_types.sort_by { |service_type| service_type[:description] }
respond_to do |format|
format.json { render json: service_types }
end
......@@ -225,12 +231,31 @@ class CityHallsController < ApplicationController
def service_places
c = CityHall.find(params[:city_hall_id])
service_places = []
c.service_places.pluck(:id,:name).each do |s|
c.service_places.active.pluck(:id,:name).each do |s|
service_places.push({:id => s[0], :name => s[1]})
end
service_places = service_places.sort_by { |service_place| service_place[:name] }
respond_to do |format|
format.json { render json: service_places }
end
end
def occupations
c = CityHall.find(params[:city_hall_id])
occupations = []
c.occupations.pluck(:id,:name).each do |s|
occupations.push({:id => s[0], :name => s[1]})
end
occupations = occupations.sort_by { |occupation| occupation[:name] }
respond_to do |format|
format.json { render json: occupations }
end
end
end
......@@ -211,9 +211,9 @@ class ProfessionalsController < ApplicationController
load_places places_a
if params[:citizen][:cep]
if !valida_cep(params[:citizen][:cep])
return redirect_to :back, alert: "CEP inválido."
end
if !valida_cep(params[:citizen][:cep])
return redirect_to :back, alert: "CEP inválido."
end
end
#if params[:role][:name].empty?
......@@ -358,10 +358,16 @@ class ProfessionalsController < ApplicationController
# GET /professionals/minhas_escalas
def shifts
#TODO Tem que fazer [by Fabricio]
@service_places_professionals = ServiceType.all.order(:description)
if @currentProfessionalServicePlace.role == "adm_c3sl"
@service_places_professionals = ServiceType.all.order('description ASC')
else
ids = ServiceTypeServicePlace.where(service_place_id: @currentProfessionalServicePlace.service_place.id).pluck(:service_type_id)
@service_places_professionals = ServiceType.where(id: ids).order('description ASC')
end
if session[:carrega_pagina]
@carrega_pagina = true
session[:carrega_pagina] = false
@carrega_pagina = true
session[:carrega_pagina] = false
end
@link = "Minhas Escalas"
......@@ -831,6 +837,14 @@ end
@places_add[session[:new_city_hall_service_place_id].to_i] = 'adm_prefeitura'
end
if params[:citizen][:cep]
if !valida_cep(params[:citizen][:cep])
return redirect_to :back, alert: "CEP inválido."
end
else
return redirect_to :back, alert: "CEP inválido."
end
@citizen = Citizen.new(citizen_params)
@professional = Professional.new(professional_params)
@citizen.professional = @professional
......@@ -991,8 +1005,10 @@ end
def service_places
begin
p = Professional.find(params[:id])
service_places = p.service_places.active.pluck(:id, :name)
service_places = service_places.sort_by { |s| s[1] }
respond_to do |format|
format.json { render json: p.service_places.active.pluck(:id, :name) }
format.json { render json: service_places }
end
rescue
respond_to do |format|
......
......@@ -467,13 +467,15 @@ class ReportsController < ApplicationController
@professionals = Professional.active.hide_c3sl_user
end
@tipos_atendimento = ServiceType.active
if !current_citizen.professional.administradorsistema?
if !current_citizen.professional.administradorc3sl?
@professionals_service_places = current_citizen.professional.professionals_service_places
@tipos_atendimento = @tipos_atendimento.joins(:service_places => :schedules).where(:schedules => {:citizen_id => current_citizen})
@tipos_atendimento_ativos = ServiceTypeServicePlace.where(service_place_id: @currentProfessionalServicePlace.service_place_id, active: true)
@tipos_atendimento = []
@tipos_atendimento_ativos.each { |x| @tipos_atendimento.push(ServiceType.find(x.service_type_id))}
end
if !@tipos_atendimento.nil?
@tipos_atendimento = @tipos_atendimento.sort_by{|t| t.description}
end
@tipos_atendimento = @tipos_atendimento.order('description ASC')
if not @professionals.nil?
@professionals = @professionals.order('citizens.name ASC').includes(:citizen)
end
......@@ -668,8 +670,8 @@ class ReportsController < ApplicationController
@link = "Relatórios"
@link2 = "Atendimentos"
if !current_citizen.professional.administradorsistema?
@serviceplaces = ServicePlace.where(:city_hall_id => @currentCityHall.id)
if !current_citizen.professional.administradorc3sl?
@serviceplaces = ServicePlace.all.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
......
......@@ -110,7 +110,12 @@ class SchedulesController < ApplicationController
if @currentProfessionalServicePlace.role == "adm_c3sl"
# As adm_c3sl
# Get all active sectors
@sectors = Sector.active.order('name ASC')
if(@citizen != nil)
@city_hall_id = CityHall.active.where(city_id: @citizen.city.id).first.id
@sectors = Sector.active.where(city_hall_id: @city_hall_id)
else
@sectors = Sector.active
end
# Get all active service places
@city_service_places = ServicePlace.active
# Get all active service types
......@@ -120,7 +125,12 @@ class SchedulesController < ApplicationController
elsif @currentProfessionalServicePlace.role == "adm_prefeitura"
# As adm_prefeitura
# Get all active sectors of its city hall
@sectors = @currentCityHall.sectors.active.order('name ASC')
if(@citizen != nil)
@city_hall_id = CityHall.active.where(city_id: @citizen.city.id).first.id
@sectors = Sector.active.where(city_hall_id: @city_hall_id)
else
@sectors = Sector.active
end
# 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
......
......@@ -88,8 +88,10 @@ class SectorsController < ApplicationController
def service_types
begin
p = Sector.find(params[:sector_id])
service_types = p.service_types.active.pluck(:id, :description)
service_types = service_types.sort_by { |s| s[1] }
respond_to do |format|
format.json { render json: p.service_types.active.pluck(:id, :description) }
format.json { render json: service_types }
end
rescue
respond_to do |format|
......
......@@ -166,6 +166,8 @@ class ServicePlacesController < ApplicationController
@orgao_profissionais = ActiveRecord::Base.connection.select_all(@orgao_profissionais)
@orgao_profissionais = @orgao_profissionais.sort_by { |p| p['name'] }
respond_to do |format|
format.json { render json: @orgao_profissionais }
end
......@@ -188,6 +190,8 @@ class ServicePlacesController < ApplicationController
.select([ :id, :description ])
@service_type_service_place = ActiveRecord::Base.connection.select_all(@service_type_service_place)
@service_type_service_place = @service_type_service_place.sort_by { |s| s['description'] }
respond_to do |format|
format.json { render json: @service_type_service_place }
end
......
......@@ -347,8 +347,10 @@ class ServiceTypesController < ApplicationController
def service_places
begin
p = ServiceType.find(params[:id])
service_places = p.service_places.active.pluck(:id, :name)
service_places = service_places.sort_by { |s| s[1] }
respond_to do |format|
format.json { render json: p.service_places.active.pluck(:id, :name) }
format.json { render json: service_places }
end
rescue
respond_to do |format|
......
......@@ -681,7 +681,7 @@ class ShiftsController < ApplicationController
def load_professionals_and_service_types
@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
@city_halls = CityHall.where(id: @currentCityHall.id).order('name ASC');
else
# mostrar apenas profissionais ativos
......
......@@ -55,7 +55,7 @@ class CitizenAbility
can [:professionals, :service_types], ServicePlace
can :manage, [Professional, Report]
can [:schedule_select_escalas_report, :generate_escalas_report], Report
can [:service_types, :professionals], CityHall
can [:service_types, :professionals, :occupations, :service_places], CityHall
end
if ['adm_prefeitura',
'adm_c3sl'].include?(profServPlace.role)
......
......@@ -14,11 +14,42 @@
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :occupation_id, t(:Occupation)+": " %>
<%= f.collection_select :occupation_id_eq, Occupation.all.order(:name), :id, :name, {
:include_blank => "Todos"}, { :class => "search-field" } %>
<%= 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" } %>
<% else %>
<%= f.collection_select :service_places_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 :occupation_id, t(:Occupation)+": " %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.select :occupation_id_eq,
options_from_collection_for_select([],"id","name"),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% else %>
<%= f.select :occupation_id_eq,
options_from_collection_for_select(Occupation.where(city_hall_id: @currentCityHall.id),"id","name"),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_places_id, t(:service_places)+": " %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.select :service_places_id_eq,
options_from_collection_for_select([],"id","name"),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% else %>
<%= f.select :service_places_id_eq,
options_from_collection_for_select(ServicePlace.where(city_hall_id: @currentCityHall.id),"id","name"),
{:include_blank => "Todos"}, {:class => "search-field"} %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :active, t(:Situation)+":" %>
<%= f.select :active_eq,
......@@ -26,22 +57,6 @@
{:include_blank => "Todos"},{:class => "search-field"} %>
</div>
<% if @currentProfessionalServicePlace.role != "adm_local" %>
<div class="field-h col s12 m6 l3 truncate">
<%= f.label :service_places_id, t(:service_place) + ":" %>
<br />
<%= f.collection_select :service_places_id_eq, @serviceplaces, :id, :name,
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<% else %>
<div class="field-h col s12 m6 l3 truncate">
<%= f.label :service_places_id, t(:service_place) + ":" %>
<br />
<%= f.text_field :service_places_id_eq, :class => 'search-field', :value => @current_place.name, :disabled => true %>
</div>
<% end %>
<div class="field-h col s12 m6 l3">
<%= f.label :name, t(:Name)+": " %>
<%= f.text_field :citizen_name_cont, :class => "search-field" %>
......
......@@ -192,6 +192,7 @@ Agendador::Application.routes.draw do
get "/city_halls/:city_hall_id/service_types" => "city_halls#service_types", :format => :json
get "/city_halls/:city_hall_id/service_places" => "city_halls#service_places", :format => :json
get "/city_halls/:city_hall_id/sectors", :to => "city_halls#sectors", :format => :json
get "/city_halls/:city_hall_id/occupations" => "city_halls#occupations", :format => :json
# Sectors
get "/sectors/:sector_id/service_types", :to => "sectors#service_types", :format => :json
......
......@@ -2,13 +2,23 @@
namespace :agendador do
task :setup_c3sl_user => :environment do
Occupation.new do |o|
o.name = "Cargo a"
o.description = "Descricao cargo a"
o.city_hall = CityHall.first
o.active = true
o.save!
end
Professional.new do |p|
Citizen.new do |c|
c.name = "Administrador CTrêsSL"
c.cep = "81530-110"
c.cpf = "987.654.321-00"
c.rg = "111111111"
c.birth_date = "2013-01-01"
c.city = City.first
c.phone1 = "(12)1212-1212"
c.password = "C3$1@dm"
c.password_confirmation = "C3$1@dm"
c.address_number = 23
......
......@@ -21,16 +21,11 @@ namespace :agendador do
p.address_street = "Endereço"
p.address_number = 1
p.phone1 = "(41)0000-0000"
p.state = State.where(abbrevation: "PR").first
p.city = City.where(name: "Curitiba").first
p.cancel_limit = 48
p.max_schedules = 3
p.blocking_days = 30
p.absence_max = 1
p.schedule_period = 90
p.previous_notice = 48
p.description = "<p>O aplicativo Agendador foi desenvolvido para viabilizar a automatização do schedule dos atendimentos com hora marcada em órgãos públicos, permitindo que uma city_hall crie, por exemplo, horários de atendimento para médicos em postos de saúde.</p>"
p.textoBloqueio = "<p>Para realizar seu schedule, entre em contato com a city_hall.</p>"
p.description = "O aplicativo Agendador foi desenvolvido para viabilizar a automatização do schedule dos atendimentos com hora marcada em órgãos públicos, permitindo que uma city_hall crie, por exemplo, horários de atendimento para médicos em postos de saúde."
p.block_text = "Para realizar seu schedule, entre em contato com a city_hall."
p.url = ""
p.save!
......@@ -40,12 +35,11 @@ namespace :agendador do
printf "Inserindo Local de Atendimento..."
ServicePlace.new do |o|
o.name = "Local de Atendimento"
o.cep = "80035-010"
o.cep = "81530-110"
o.neighborhood = "Centro"
o.address_street = "Rua XV de Novembro"
o.address_number = 1
o.active = true
o.state = State.where(abbrevation: "PR").first
o.city = City.where(name: "Curitiba").first
o.city_hall = CityHall.first
o.save!
......@@ -54,8 +48,6 @@ namespace :agendador do
print "Inserindo usuário administrador do C3SL..."
Rake::Task['agendador:setup_c3sl_user'].invoke
print "Inserindo usuário administrador do Ministério das Comunicações..."
Rake::Task['agendador:setup_minicom_user'].invoke
print "OK!\n"
end
end
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