Commit 3c5b9fe0 authored by Alan Peterson Carvalho Silva's avatar Alan Peterson Carvalho Silva
Browse files

Merge branch 'Issue#3303' into 'materializecss'

Issue#3303



See merge request !191
parents a363b674 6f2c15ac
Pipeline #4778 skipped
......@@ -1734,4 +1734,23 @@ td.service_table_icon {
}
.right.hide-on-med-and-down.large-menu {
height: 56px;
}
\ No newline at end of file
}
.spreadsheet-img{
width: 32px;
height: 32px;
}
ul.collapsible.import-collapsible {
box-shadow: none;
}
.download-button{
display: inline-block;
}
.first-collapsible-upload{
border-bottom: 1px solid white;
}
.spreadsheet-img{
width: 32px;
height: 32px;
}
......@@ -14,7 +14,7 @@ class Professionals::UsersController < ApplicationController
return redirect_to root_path, alert: "Você não possui permissão para visualizar esta página."
end
@link = "Cadastro de cidadãos"
@current_place = @currentProfessionalServicePlace.service_place
if @currentProfessionalServicePlace.role != "adm_c3sl"
......@@ -86,7 +86,7 @@ class Professionals::UsersController < ApplicationController
end
end
end
def edit
@link = "Cadastro de cidadãos"
@link2 = "Alterar Cidadão"
......@@ -199,7 +199,7 @@ class Professionals::UsersController < ApplicationController
@current_place = @currentProfessionalServicePlace.service_place
@places = ServicePlace.where(city_id: @citizen.city_id)
if params[:pcd_radio] == 'true'
if params[:citizen][:pcd].empty?
return redirect_to new_professionals_user_path(params), alert: "Você deve especificar o tipo de deficiência."
......@@ -252,9 +252,9 @@ class Professionals::UsersController < ApplicationController
def set_citizen
@citizen = Citizen.find(params[:id])
@current_place = @currentProfessionalServicePlace.service_place
@selected = @citizen.service_places.where(active: true).pluck(:id)
if @currentProfessionalServicePlace.role == "adm_prefeitura"
@places = ServicePlace.where(city_id: @citizen.city_id)
......@@ -262,8 +262,8 @@ class Professionals::UsersController < ApplicationController
@places = ServicePlace.all
else
@places = ServicePlace.where(id: @currentProfessionalServicePlace.service_place.id)
end
end
if !can_edit?(@citizen)
return redirect_to root_path, alert: "Você não possui permissão para editar este cidadão."
end
......@@ -275,20 +275,20 @@ class Professionals::UsersController < ApplicationController
# retorna array de roles inferiores em relação ao profissional atual
def inferior_roles
roles = ProfessionalServicePlace::ROLES
for i in 0..3
if roles[i] == @currentProfessionalServicePlace.role
return roles[0...i]
roles_array = ProfessionalServicePlace::ROLES
for i in 0..roles_array.length
if roles_array[i] == self.role
return roles_array[0..i]
end
end
end
# retorna array de roles superiores em relação ao profissional atual
def superior_eq_roles
roles = ProfessionalServicePlace::ROLES
for i in 0..3
if roles[i] == @currentProfessionalServicePlace.role
return roles[i..3]
roles_array = ProfessionalServicePlace::ROLES
for i in 0..roles_array
if roles_array[i] == @currentProfessionalServicePlace.role
return roles_array[i..roles_array.length]
end
end
end
......@@ -308,20 +308,20 @@ class Professionals::UsersController < ApplicationController
end
elsif @currentProfessionalServicePlace.role == "responsavel_atendimento"
return false
elsif @currentProfessionalServicePlace.role == "atendente_local" && (citizen.professional != nil &&
elsif @currentProfessionalServicePlace.role == "atendente_local" && (citizen.professional != nil &&
( !((citizen.professional.roles - inferior_roles).empty?) ||
citizen.professional.administradorc3sl? || ( !citizen.professional.professionals_service_places.empty? &&
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!local_citizen?(citizen)
return false
elsif @currentProfessionalServicePlace.role == "adm_prefeitura" &&
(citizen.professional != nil && !((citizen.professional.roles - inferior_roles).empty?)) ||
elsif @currentProfessionalServicePlace.role == "adm_prefeitura" &&
(citizen.professional != nil && !((citizen.professional.roles - inferior_roles).empty?)) ||
!local_citizen?(citizen)
return false
elsif @currentProfessionalServicePlace.role == "adm_local" && (citizen.professional != nil &&
elsif @currentProfessionalServicePlace.role == "adm_local" && (citizen.professional != nil &&
( !((citizen.professional.roles - inferior_roles).empty?) ||
citizen.professional.administradorc3sl? || ( !citizen.professional.professionals_service_places.empty? &&
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!local_citizen?(citizen)
return false
elsif citizen.professional != nil && citizen.professional.administradorc3sl?
......@@ -338,17 +338,17 @@ class Professionals::UsersController < ApplicationController
return true
elsif @currentProfessionalServicePlace.role == "responsavel_atendimento"
return false
elsif @currentProfessionalServicePlace.role == "atendente_local" && (citizen.professional != nil &&
elsif @currentProfessionalServicePlace.role == "atendente_local" && (citizen.professional != nil &&
(citizen.professional.administradorc3sl? || ( !citizen.professional.professionals_service_places.empty? &&
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!local_citizen?(citizen)
return false
elsif @currentProfessionalServicePlace.role == "adm_prefeitura" &&
elsif @currentProfessionalServicePlace.role == "adm_prefeitura" &&
(citizen.professional != nil && citizen.professional.administradorc3sl?) || !local_citizen?(citizen)
return false
elsif @currentProfessionalServicePlace.role == "adm_local" && (citizen.professional != nil &&
elsif @currentProfessionalServicePlace.role == "adm_local" && (citizen.professional != nil &&
(citizen.professional.administradorc3sl? || ( !citizen.professional.professionals_service_places.empty? &&
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!(citizen.professional.professionals_service_places.any? {|u| u.service_place_id == @current_place.id})))) ||
!local_citizen?(citizen)
return false
elsif citizen.professional != nil && citizen.professional.administradorc3sl?
......
......@@ -49,14 +49,13 @@ class ReportsController < ApplicationController
end
end
def schedule_select_professionals_report
@link = "Relatórios"
@link2 = "Profissionais"
@search = Professional.search(params[:q])
@professionals = @search.result
if !current_citizen.professional.administradorc3sl?
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id)
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id)
else
@serviceplaces = ServicePlace.all
end
......@@ -113,11 +112,16 @@ class ReportsController < ApplicationController
# Se foi escolhido um local de atendimento
unless params["q"]["service_places_id_eq"].nil? or params["q"]["service_places_id_eq"].empty?
@p_service_place = ServicePlace.find(params["q"]["service_places_id_eq"])
end
end
# Se foi escolhido uma permissão
unless params["q"]["professionals_service_places_role_eq"].nil? or params["q"]["professionals_service_places_role_eq"].empty?
@p_permissao = params["q"]["professionals_service_places_role_eq"]
@p_permissao_possiveis = []
@p_permissao_possiveis << params["q"]["professionals_service_places_role_eq"]
else
@p_permissao_possiveis = @currentProfessionalServicePlace.inferior_roles
end
# Se foi escolhido uma situação
......@@ -133,7 +137,9 @@ class ReportsController < ApplicationController
end
end
report = ProfessionalsReport.new(:page_size => "A4", :top_margin => 0, :page_layout => :portrait).to_pdf( @city_hall, @service_place, @professionals, @p_ocupacao, @p_service_place, @p_permissao, @p_situacao)
report = ProfessionalsReport.new(:page_size => "A4", :top_margin => 0, :page_layout => :portrait).to_pdf( @city_hall, @service_place, @professionals, @p_ocupacao, @p_service_place, @p_permissao, @p_situacao,@p_permissao_possiveis)
send_data report, filename: "professionals.pdf",
type: "application/pdf"
end
......@@ -341,7 +347,7 @@ class ReportsController < ApplicationController
@search.build_sort
if !current_citizen.professional.administradorc3sl?
@serviceplaces = ServicePlace.where(:city_hall_id => @currentCityHall.id)
@serviceplaces = ServicePlace.all.active.where(:city_hall_id => @currentCityHall.id, :id => @currentProfessionalServicePlace.service_place_id)
@professionals = Professional.active.hide_c3sl_user.where(service_places: {city_hall_id: @currentCityHall.id}).includes(:service_places)
else
@serviceplaces = ServicePlace.all
......@@ -617,7 +623,7 @@ class ReportsController < ApplicationController
end
if @currentProfessionalServicePlace.role == "adm_local"
@service_places = [@currentProfessionalServicePlace.service_places]
@service_places = [@currentProfessionalServicePlace.service_place]
else
@service_places = @city_hall.service_places.active
end
......
......@@ -97,7 +97,7 @@ class ServiceTypesController < ApplicationController
end
#instância variáveis para setores e prefeituras
#instancia variáveis para setores e prefeituras
def fetch_dependencies
if current_citizen.professional.administradorc3sl?
@setores = Sector.all
......@@ -110,9 +110,15 @@ class ServiceTypesController < ApplicationController
# Retorna os tipos de atendimento dado
# setor no formato JSON
def sector_service_types
@service_types = ServiceType.where(:sector_id => params[:sector_id]).pluck(:id,:description)
respond_to do |format|
format.json { render json: @service_types }
if params[:sector_id].present?
@service_types = ServiceType.where(:sector_id => params[:sector_id]).pluck(:id,:description)
respond_to do |format|
format.json { render json: @service_types }
end
else
respond_to do |format|
format.json { head :no_content }
end
end
end
......
......@@ -336,7 +336,7 @@ class ShiftsController < ApplicationController
@add_shifts ||= []
end
else
conflict_shift = conflicting_shifts?(@current_shift)
conflict_shift = nil
end
end
end
......
......@@ -251,9 +251,9 @@ def upload_csv(file)
:remove_zero_values =>false, :col_sep => ';',
:convert_values_to_numeric => false})
rescue EOFError
return redirect_to :back, alert: "Arquivo .csv vazio!"
return redirect_to :upload_instructions, alert: "Arquivo .csv vazio!"
rescue CSV::MalformedCSVError
return redirect_to :back, alert: "Arquivo .csv não formatado."
return redirect_to :upload_instructions, alert: "Arquivo .csv não formatado."
end
if csv_comma[0].size == 16
......@@ -261,11 +261,11 @@ def upload_csv(file)
elsif csv_semicolon[0].size == 16
csv = csv_semicolon
else
return redirect_to :back, alert: "Arquivo .csv não formatado."
return redirect_to :upload_instructions, alert: "Arquivo .csv não formatado."
end
if csv.empty?
return redirect_to :back, alert: "Arquivo .csv vazio!"
return redirect_to :upload_instructions, alert: "Arquivo .csv vazio!"
end
size = csv.length
......@@ -304,7 +304,7 @@ def upload_csv(file)
@transposed = @values.transpose
@lines = Array (0..@values.count-1)
if @transposed.size != 16
return redirect_to :back, alert: "Arquivo .csv não formatado corretamente."
return redirect_to :upload_instructions, alert: "Arquivo .csv não formatado corretamente."
end
#############################################
......@@ -411,10 +411,10 @@ def upload_csv(file)
if not(file.nil?)
@fileType = file.original_filename.to_s.split(".").last # Get the file format (csv)
else
return redirect_to :back, alert: "Por favor, selecione um arquivo para o upload"
return redirect_to :upload_instructions, alert: "Por favor, selecione um arquivo para o upload"
end
if @fileType != 'csv'
return redirect_to :back, alert: "Somente arquivos do tipo .csv são suportados"
return redirect_to :upload_instructions, alert: "Somente arquivos do tipo .csv são suportados"
end
tinicio = Time.now
upload_csv(file)
......
......@@ -42,7 +42,7 @@ class ProfessionalServicePlace < ActiveRecord::Base
# Níveis de permissões dos profissionais, ver {ProfissionalAbility}.
ROLES = %w[responsavel_atendimento atendente_local adm_local adm_prefeitura adm_c3sl]
# Verifica se professional possui a permissão fornecida.
# @param base_role [String] a permissão a verificar se o professional
# possui.
......@@ -66,38 +66,48 @@ class ProfessionalServicePlace < ActiveRecord::Base
##############################
# Checks if the current permission role is adm_c3sl
# @return [true, false] returns 'true' if the current permission role is
# @return [true, false] returns 'true' if the current permission role is
# 'adm_c3sl' or 'false' istead.
def adm_c3sl?
self.role == "adm_c3sl"
end
# Checks if the current permission role is adm_c3sl
# @return [true, false] returns 'true' if the current permission role is
# @return [true, false] returns 'true' if the current permission role is
# 'adm_c3sl' or 'false' istead.
def adm_prefeitura?
self.role == "adm_prefeitura"
end
# Checks if the current permission role is adm_c3sl
# @return [true, false] returns 'true' if the current permission role is
# @return [true, false] returns 'true' if the current permission role is
# 'adm_c3sl' or 'false' istead.
def adm_local?
self.role == "adm_local"
end
# Checks if the current permission role is adm_c3sl
# @return [true, false] returns 'true' if the current permission role is
# @return [true, false] returns 'true' if the current permission role is
# 'adm_c3sl' or 'false' istead.
def atendente_local?
self.role == "atendente_local"
end
# Checks if the current permission role is adm_c3sl
# @return [true, false] returns 'true' if the current permission role is
# @return [true, false] returns 'true' if the current permission role is
# 'adm_c3sl' or 'false' istead.
def responsavel_atendimento?
self.role == "responsavel_atendimento"
end
#checks all with permission below the current permission
def inferior_roles
roles_array = ProfessionalServicePlace::ROLES
for i in 0..roles_array.length
if roles_array[i] == self.role
return roles_array[0..i]
end
end
end
end
# coding: utf-8
class ProfessionalsReport < Prawn::Document
def to_pdf( table_prefeitura, table_service_placeatendimento, table_profissionais, p_ocupacao, p_service_placeatendimento, p_permissao, p_situacao)
def to_pdf( table_prefeitura, table_service_placeatendimento, table_profissionais, p_ocupacao, p_service_placeatendimento, p_permissao, p_situacao,p_permissao_possiveis)
define_grid(:columns =>15, :rows => 68, :gutter => 0)
@city_hall = table_prefeitura
@service_place = table_service_placeatendimento
......@@ -8,6 +8,9 @@ class ProfessionalsReport < Prawn::Document
@p_service_placeatendimento = p_service_placeatendimento
@p_permissao = p_permissao
@p_situacao = p_situacao
@p_permissao_possiveis = p_permissao_possiveis
header_report
@gridControl = 0
if @p_service_placeatendimento.present?
......@@ -23,9 +26,10 @@ class ProfessionalsReport < Prawn::Document
@gridControl+=1
end
grid([6,0],[6+(@gridControl),14]).bounding_box do
header_report
end
end
@professionals = table_profissionais
@atributos = [ "Nome", "CPF", "Ocupação", "Matricula", "Local de Atendimento", "Permissão", "Situação"]
......@@ -59,8 +63,8 @@ class ProfessionalsReport < Prawn::Document
grid([4,1],[5,12]).bounding_box do
text "RELATÓRIO DE PROFISSIONAIS", :color => "FFFFFF", :size => 7, :valign => :center, :style => :bold
end
end
grid([67,0],[67,9]).bounding_box do
optionsDate = {
......@@ -101,7 +105,7 @@ class ProfessionalsReport < Prawn::Document
if @p_service_placeatendimento.present?
@dataSend = @dataSend + "Local de Atendimento: #{@p_service_placeatendimento.name}\n"
end
if @p_permissao.present?
@dataSend = @dataSend+ "Permissão: #{I18n.t(@p_permissao)}\n"
end
......@@ -134,8 +138,8 @@ class ProfessionalsReport < Prawn::Document
# por causa da grande quantidade de dados geradas abaixo no data_table
l_ocupacao = @p_ocupacao
# Verifica se a ocupação é um filtro
table line_table_rows, :cell_style => {:borders => [], :size => 9, :align => :center, :vposition => :center} do
table line_table_rows, :cell_style => {:borders => [], :size => 9, :align => :center, :vposition => :center} do
self.width = 525
row(0).background_color = "92bf23"
row(0).font_style = :bold
......@@ -148,7 +152,7 @@ class ProfessionalsReport < Prawn::Document
self.row_colors = [ "F2F2F2", "FFFFFF"]
self.header = true
end
end
def line_table_rows
......@@ -164,8 +168,8 @@ class ProfessionalsReport < Prawn::Document
@professionals.map do |professional|
@data_cell_table = [] # apaga array temporaria para a próxima iteração
if !professional.c3sl_user?
if !professional.c3sl_user? && !((professional.roles & @p_permissao_possiveis).empty?)
@data_cell_table.push(professional.name)
@data_cell_table.push(professional.cpf)
......@@ -202,4 +206,22 @@ class ProfessionalsReport < Prawn::Document
@data_cell_table # coloca array temporaria na tabela do relatório
end
end
def footer
number_pages "Gerado em: #{DateTime.now.strftime("%H:%M %d/%m/%y")}",
:at => [bounds.left, 0],
:align => :left,
:size => 10
number_pages "<page>/<total>", {
:start_count_at => 0,
:at => [bounds.right - 50, 0],
:align => :right,
:size => 10
}
end
end
......@@ -12,24 +12,34 @@
<div class="field-h col s12 m6 l3">
<%= f.label :occupation_id, "Ocupação" %><br />
<%= f.collection_select :occupation_id_eq, Occupation.active.all, :id, :description,
<%= f.collection_select :occupation_id_eq, Occupation.active.all, :id, :name,
{ :include_blank => "Todos" }, { :class => "search-field" } %>
</div>
<div class="field-h col s12 m6 l3">
<%= 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>
<% if @currentProfessionalServicePlace.role != "adm_c3sl"%>
<div class="field-h col s12 m6 l3">
<%= f.label :service_places_id, t('service_place') + ":" %><br />
<%= f.text_field :service_places_id_eq, { :class => 'search-field', :value => @serviceplaces[0].name, :disabled => true} %>
<%= f.hidden_field :service_places_id_eq, { :class => 'search-field', :value => @serviceplaces[0].id, :readonly => true} %>
<!-- <%= f.hidden_field :service_places_id_eq, :value => @serviceplaces %> -->
<!-- <%= f.collection_select :service_places_id_eq, @serviceplaces, :id, :name,{ :class => "search-field"}, {:readonly => "readonly"} %> -->
</div>
<% else %>
<div class="field-h col s12 m6 l3">
<%= 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>
<% end %>
<div class="field-h col s12 m6 l3">
<%= f.label :professionals_service_places_role, "Permissão: " %><br />
<% #.zip transformer the two arrays selected into one %>
<%= f.select :professionals_service_places_role_eq,
options_for_select(t(ProfessionalServicePlace::ROLES).zip(ProfessionalServicePlace::ROLES)),
options_for_select(t(@currentProfessionalServicePlace.inferior_roles).zip(@currentProfessionalServicePlace.inferior_roles)),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
......
......@@ -2,7 +2,7 @@
<%= search_form_for(@search, :as => :services, :method => :post,
:url => { :action => :generate_services_report, :format => :pdf, :search => @search }) do |f|%>
<div class = "card-content"id="search-form">
<h2 class="card-title">Atendimentos</h2>
<h2 class="card-title">Atendimentos</h2>
<% if current_citizen.professional.administradorc3sl? %>
<div class="field-h col s12 m4 l4">
......@@ -13,12 +13,20 @@
<% end %>
<br>
<div class="field-h col s12 m4 l4">
<%= f.label :orgao_id, "Local de Atendimento: " %><br />
<%= f.select :service_place_id_eq,
options_from_collection_for_select(@serviceplaces, "id","name",@search.service_place_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<% if @currentProfessionalServicePlace.role != "adm_c3sl"%>
<div class="field-h col s12 m6 l3">
<%= f.label :service_places_id, t('service_place') + ":" %><br />
<%= f.text_field :service_places_id_eq, { :class => 'search-field', :value => @serviceplaces[0].name, :disabled => true} %>
<%= f.hidden_field :service_places_id_eq, { :class => 'search-field', :value => @serviceplaces[0].id, :readonly => true} %>
</div>
<% else %>
<div class="field-h col s12 m6 l3">
<%= 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>
<% end %>
<div class="field-h col s12 m4 l4">
<%= f.label :escala_data_execucao, "Data de início: " %><br />
......@@ -70,7 +78,7 @@
<div class="card-action clear actions-margin">
<%= f.button "Gerar relatório", :class => "waves-effect btn right" %>
<%= button_tag("Limpar Campos", { :name => 'reset', :id => 'reset_button_report', :type => "button", :class => 'back-bt waves-effect btn-flat' }) %>
<%= link_to 'Voltar', :back , {:class => 'back-bt waves-effect btn-flat left'}%>
</div>
<% end %>
<%= link_to 'Voltar', :back , {:class => 'back-bt waves-effect btn-flat left'}%>
</div>
<% end %>
</div>
......@@ -93,7 +93,9 @@
<% @service_place.professionals.each do |pro| %>
<li><%= link_to "#{pro.citizen.name}:", pro %>
<% pro.professionals_service_places.each do |p|%>
<%= "(#{t(p.role)}, #{situation(p)})" %>
<% if p.service_place_id == @service_place.id %>
<%= "(#{t(p.role)}, #{situation(p)})" %>
<% end %>
<% end %>
</li>
<% end %>
......
......@@ -32,7 +32,7 @@ development:
pool: 5
host: localhost
username: postgres
password: 123
password: 123456
# test:
# adapter: postgresql
......
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