2015-09-22 15:00:59 +02:00
|
|
|
class Backoffice::DossiersController < ApplicationController
|
2015-09-22 10:15:12 +02:00
|
|
|
before_action :authenticate_gestionnaire!
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
|
|
def show
|
2015-11-02 16:36:52 +01:00
|
|
|
initialize_instance_params params[:id]
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2015-11-13 15:23:21 +01:00
|
|
|
def a_traiter
|
2015-12-02 14:05:56 +01:00
|
|
|
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
|
|
|
|
.paginate(:page => params[:page]).decorate
|
2015-11-26 15:47:31 +01:00
|
|
|
|
2015-12-02 14:05:56 +01:00
|
|
|
@page = 'a_traiter'
|
2015-11-13 15:23:21 +01:00
|
|
|
total_dossiers_per_state
|
|
|
|
end
|
|
|
|
|
|
|
|
def en_attente
|
2015-12-02 14:05:56 +01:00
|
|
|
@dossiers = current_gestionnaire.dossiers.waiting_for_user()
|
|
|
|
.paginate(:page => params[:page]).decorate
|
|
|
|
|
|
|
|
@page = 'en_attente'
|
2015-11-13 15:23:21 +01:00
|
|
|
total_dossiers_per_state
|
|
|
|
end
|
|
|
|
|
|
|
|
def termine
|
2015-12-02 14:05:56 +01:00
|
|
|
@dossiers = current_gestionnaire.dossiers.termine()
|
|
|
|
.paginate(:page => params[:page]).decorate
|
|
|
|
|
|
|
|
@page = 'termine'
|
2015-11-13 15:23:21 +01:00
|
|
|
total_dossiers_per_state
|
|
|
|
end
|
|
|
|
|
2015-11-17 18:21:03 +01:00
|
|
|
def search
|
2015-11-26 15:47:31 +01:00
|
|
|
@search_terms = params[:q]
|
2015-11-17 18:21:03 +01:00
|
|
|
|
|
|
|
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
|
2015-11-26 15:47:31 +01:00
|
|
|
|
|
|
|
unless @dossiers_search.empty?
|
2015-11-30 17:03:36 +01:00
|
|
|
@dossiers_search = @dossiers_search.paginate(:page => params[:page]).decorate
|
2015-11-26 15:47:31 +01:00
|
|
|
end
|
|
|
|
|
2015-11-17 18:21:03 +01:00
|
|
|
@dossier = @dossier.decorate unless @dossier.nil?
|
|
|
|
|
|
|
|
total_dossiers_per_state
|
|
|
|
rescue RuntimeError
|
|
|
|
@dossiers_search = []
|
|
|
|
end
|
|
|
|
|
2015-11-02 11:45:52 +01:00
|
|
|
def valid
|
2015-11-02 16:36:52 +01:00
|
|
|
initialize_instance_params params[:dossier_id]
|
2015-09-24 16:51:14 +02:00
|
|
|
|
2015-11-02 11:45:52 +01:00
|
|
|
@dossier.next_step! 'gestionnaire', 'valid'
|
2015-09-24 16:51:14 +02:00
|
|
|
flash.notice = 'Dossier confirmé avec succès.'
|
|
|
|
|
|
|
|
render 'show'
|
|
|
|
end
|
2015-10-09 12:05:07 +02:00
|
|
|
|
2015-11-02 15:00:28 +01:00
|
|
|
def close
|
2015-11-02 16:36:52 +01:00
|
|
|
initialize_instance_params params[:dossier_id]
|
2015-10-09 12:05:07 +02:00
|
|
|
|
2015-11-02 15:00:28 +01:00
|
|
|
@dossier.next_step! 'gestionnaire', 'close'
|
2015-10-09 12:05:07 +02:00
|
|
|
flash.notice = 'Dossier traité avec succès.'
|
|
|
|
|
|
|
|
render 'show'
|
|
|
|
end
|
2015-11-02 16:36:52 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-11-13 15:23:21 +01:00
|
|
|
def total_dossiers_per_state
|
2015-12-02 14:05:56 +01:00
|
|
|
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_gestionnaire.dossiers.waiting_for_gestionnaire.size
|
|
|
|
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_gestionnaire.dossiers.waiting_for_user.size
|
|
|
|
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_gestionnaire.dossiers.termine.size
|
2015-11-13 15:23:21 +01:00
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
def initialize_instance_params dossier_id
|
2015-11-27 15:09:16 +01:00
|
|
|
@dossier = Dossier.where(archived: false).find(dossier_id)
|
2015-11-02 16:36:52 +01:00
|
|
|
@entreprise = @dossier.entreprise.decorate
|
|
|
|
@etablissement = @dossier.etablissement
|
|
|
|
@pieces_justificatives = @dossier.pieces_justificatives
|
2015-11-04 11:14:07 +01:00
|
|
|
@commentaires = @dossier.ordered_commentaires
|
2015-11-02 16:36:52 +01:00
|
|
|
@commentaires = @commentaires.all.decorate
|
|
|
|
@commentaire_email = current_gestionnaire.email
|
|
|
|
|
|
|
|
@procedure = @dossier.procedure
|
|
|
|
|
|
|
|
@dossier = @dossier.decorate
|
2015-11-04 11:14:07 +01:00
|
|
|
@champs = @dossier.ordered_champs
|
2015-11-02 16:36:52 +01:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
flash.alert = t('errors.messages.dossier_not_found')
|
|
|
|
redirect_to url_for(controller: '/backoffice')
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|