2016-09-27 17:26:49 +02:00
|
|
|
class Backoffice::DossiersController < Backoffice::DossiersListController
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
def index
|
2016-09-27 17:26:49 +02:00
|
|
|
super
|
2016-09-26 13:58:54 +02:00
|
|
|
|
2016-09-27 17:26:49 +02:00
|
|
|
dossiers_list_facade.service.filter_procedure_reset!
|
2015-11-13 15:23:21 +01:00
|
|
|
end
|
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
def show
|
2015-12-24 15:10:20 +01:00
|
|
|
create_dossier_facade params[:id]
|
2016-08-08 12:52:30 +02:00
|
|
|
@champs = @facade.champs_private unless @facade.nil?
|
2015-12-02 18:03:52 +01:00
|
|
|
end
|
|
|
|
|
2016-10-04 19:19:03 +02:00
|
|
|
def filter
|
|
|
|
super
|
|
|
|
|
|
|
|
redirect_to backoffice_dossiers_path(liste: param_liste)
|
|
|
|
end
|
|
|
|
|
2016-08-25 12:30:15 +02:00
|
|
|
def download_dossiers_tps
|
|
|
|
dossiers = current_gestionnaire.dossiers.where.not(state: :draft)
|
|
|
|
|
|
|
|
response.headers['Content-Type'] = 'text/csv'
|
|
|
|
|
|
|
|
render csv: dossiers, status: 200
|
|
|
|
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
|
|
|
|
2016-09-27 17:26:49 +02:00
|
|
|
dossiers_list_facade
|
2016-08-11 15:27:35 +02:00
|
|
|
|
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?
|
|
|
|
|
|
|
|
rescue RuntimeError
|
|
|
|
@dossiers_search = []
|
|
|
|
end
|
|
|
|
|
2015-11-02 11:45:52 +01:00
|
|
|
def valid
|
2015-12-24 15:10:20 +01:00
|
|
|
create_dossier_facade params[:dossier_id]
|
2015-09-24 16:51:14 +02:00
|
|
|
|
2015-12-24 15:10:20 +01:00
|
|
|
@facade.dossier.next_step! 'gestionnaire', 'valid'
|
2015-09-24 16:51:14 +02:00
|
|
|
flash.notice = 'Dossier confirmé avec succès.'
|
|
|
|
|
2015-12-24 15:10:20 +01:00
|
|
|
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
|
2015-12-15 15:37:46 +01:00
|
|
|
|
2015-09-24 16:51:14 +02:00
|
|
|
render 'show'
|
|
|
|
end
|
2015-10-09 12:05:07 +02:00
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
def receive
|
|
|
|
create_dossier_facade params[:dossier_id]
|
|
|
|
|
|
|
|
@facade.dossier.next_step! 'gestionnaire', 'receive'
|
|
|
|
flash.notice = 'Dossier considéré comme reçu.'
|
|
|
|
|
2016-09-01 10:27:22 +02:00
|
|
|
NotificationMailer.dossier_received(@facade.dossier).deliver_now!
|
|
|
|
|
2016-08-25 15:21:25 +02:00
|
|
|
render 'show'
|
|
|
|
end
|
|
|
|
|
2016-08-25 17:46:26 +02:00
|
|
|
def refuse
|
|
|
|
create_dossier_facade params[:dossier_id]
|
|
|
|
|
|
|
|
@facade.dossier.next_step! 'gestionnaire', 'refuse'
|
|
|
|
flash.notice = 'Dossier considéré comme refusé.'
|
|
|
|
|
2016-08-25 18:02:56 +02:00
|
|
|
NotificationMailer.dossier_refused(@facade.dossier).deliver_now!
|
|
|
|
|
2016-08-25 17:46:26 +02:00
|
|
|
render 'show'
|
|
|
|
end
|
|
|
|
|
|
|
|
def without_continuation
|
|
|
|
create_dossier_facade params[:dossier_id]
|
|
|
|
|
|
|
|
@facade.dossier.next_step! 'gestionnaire', 'without_continuation'
|
|
|
|
flash.notice = 'Dossier considéré comme sans suite.'
|
|
|
|
|
2016-08-25 18:02:56 +02:00
|
|
|
NotificationMailer.dossier_without_continuation(@facade.dossier).deliver_now!
|
|
|
|
|
2016-08-25 17:46:26 +02:00
|
|
|
render 'show'
|
|
|
|
end
|
|
|
|
|
2015-11-02 15:00:28 +01:00
|
|
|
def close
|
2015-12-24 15:10:20 +01:00
|
|
|
create_dossier_facade params[:dossier_id]
|
2015-10-09 12:05:07 +02:00
|
|
|
|
2015-12-24 15:10:20 +01:00
|
|
|
@facade.dossier.next_step! 'gestionnaire', 'close'
|
2015-10-09 12:05:07 +02:00
|
|
|
flash.notice = 'Dossier traité avec succès.'
|
|
|
|
|
2016-08-25 18:02:56 +02:00
|
|
|
NotificationMailer.dossier_closed(@facade.dossier).deliver_now!
|
|
|
|
|
2015-10-09 12:05:07 +02:00
|
|
|
render 'show'
|
|
|
|
end
|
2015-11-02 16:36:52 +01:00
|
|
|
|
2016-07-18 18:24:29 +02:00
|
|
|
def follow
|
|
|
|
follow = current_gestionnaire.toggle_follow_dossier params[:dossier_id]
|
|
|
|
|
2016-09-09 15:55:03 +02:00
|
|
|
current_gestionnaire.dossiers.find(params[:dossier_id]).next_step! 'gestionnaire', 'follow'
|
|
|
|
|
2016-07-18 18:24:29 +02:00
|
|
|
flash.notice = (follow.class == Follow ? 'Dossier suivi' : 'Dossier relaché')
|
|
|
|
redirect_to request.referer
|
|
|
|
end
|
|
|
|
|
2016-08-01 18:10:32 +02:00
|
|
|
def reload_smartlisting
|
|
|
|
begin
|
|
|
|
@liste = URI(request.referer).query.split('=').second
|
|
|
|
rescue NoMethodError
|
2016-09-27 17:26:49 +02:00
|
|
|
@liste = cookies[:liste] || 'a_traiter'
|
2016-08-01 18:10:32 +02:00
|
|
|
end
|
2016-08-11 15:27:35 +02:00
|
|
|
|
2016-09-27 17:26:49 +02:00
|
|
|
dossiers_list_facade @liste
|
|
|
|
smartlisting_dossier
|
2016-08-01 18:10:32 +02:00
|
|
|
|
|
|
|
render 'backoffice/dossiers/index', formats: :js
|
|
|
|
end
|
|
|
|
|
2015-11-02 16:36:52 +01:00
|
|
|
private
|
|
|
|
|
2015-12-24 15:10:20 +01:00
|
|
|
def create_dossier_facade dossier_id
|
|
|
|
@facade = DossierFacades.new dossier_id, current_gestionnaire.email
|
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
|
2016-09-08 16:21:54 +02:00
|
|
|
|
|
|
|
def retrieve_procedure
|
|
|
|
return if params[:procedure_id].blank?
|
|
|
|
current_gestionnaire.procedures.find params[:procedure_id]
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|