2017-06-29 15:31:29 +02:00
|
|
|
|
module NewGestionnaire
|
|
|
|
|
class DossiersController < ProceduresController
|
|
|
|
|
def attestation
|
|
|
|
|
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
|
|
|
|
end
|
|
|
|
|
|
2017-07-06 16:33:36 +02:00
|
|
|
|
def show
|
|
|
|
|
@dossier = dossier
|
2017-08-30 15:31:36 +02:00
|
|
|
|
dossier.notifications.demande.mark_as_read
|
2017-10-24 11:41:22 +02:00
|
|
|
|
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
|
2017-07-06 16:33:36 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-07-19 11:08:53 +02:00
|
|
|
|
def messagerie
|
|
|
|
|
@dossier = dossier
|
2017-08-30 15:31:36 +02:00
|
|
|
|
dossier.notifications.messagerie.mark_as_read
|
2017-10-24 11:41:22 +02:00
|
|
|
|
current_gestionnaire.mark_tab_as_seen(dossier, :messagerie)
|
2017-07-19 11:08:53 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-27 12:08:47 +02:00
|
|
|
|
def annotations_privees
|
2017-07-19 16:53:31 +02:00
|
|
|
|
@dossier = dossier
|
2017-09-27 15:08:34 +02:00
|
|
|
|
dossier.notifications.annotations_privees.mark_as_read
|
2017-10-24 11:41:22 +02:00
|
|
|
|
current_gestionnaire.mark_tab_as_seen(dossier, :annotations_privees)
|
2017-07-19 16:53:31 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-26 14:38:16 +02:00
|
|
|
|
def avis
|
|
|
|
|
@dossier = dossier
|
2017-09-27 11:55:56 +02:00
|
|
|
|
dossier.notifications.avis.mark_as_read
|
2017-10-24 11:41:22 +02:00
|
|
|
|
current_gestionnaire.mark_tab_as_seen(dossier, :avis)
|
2017-09-26 14:38:16 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-07-11 15:45:20 +02:00
|
|
|
|
def follow
|
2017-07-17 12:11:33 +02:00
|
|
|
|
current_gestionnaire.follow(dossier)
|
2017-07-17 15:14:19 +02:00
|
|
|
|
dossier.next_step!('gestionnaire', 'follow')
|
2017-07-17 12:28:09 +02:00
|
|
|
|
flash.notice = 'Dossier suivi'
|
2017-07-11 15:45:20 +02:00
|
|
|
|
redirect_back(fallback_location: procedures_url)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def unfollow
|
2017-10-05 14:10:49 +02:00
|
|
|
|
current_gestionnaire.unfollow(dossier)
|
2017-07-17 12:28:09 +02:00
|
|
|
|
flash.notice = "Vous ne suivez plus le dossier nº #{dossier.id}"
|
|
|
|
|
|
2017-07-11 15:45:20 +02:00
|
|
|
|
redirect_back(fallback_location: procedures_url)
|
|
|
|
|
end
|
|
|
|
|
|
2017-07-11 15:56:23 +02:00
|
|
|
|
def archive
|
|
|
|
|
dossier.update_attributes(archived: true)
|
2017-09-25 18:13:10 +02:00
|
|
|
|
current_gestionnaire.unfollow(dossier)
|
2017-07-11 15:56:23 +02:00
|
|
|
|
redirect_back(fallback_location: procedures_url)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def unarchive
|
|
|
|
|
dossier.update_attributes(archived: false)
|
|
|
|
|
redirect_back(fallback_location: procedures_url)
|
|
|
|
|
end
|
|
|
|
|
|
2017-07-19 14:04:49 +02:00
|
|
|
|
def create_commentaire
|
|
|
|
|
Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier))
|
2017-09-25 18:06:20 +02:00
|
|
|
|
current_gestionnaire.follow(dossier)
|
2017-09-08 17:17:19 +02:00
|
|
|
|
flash.notice = "Message envoyé"
|
2017-07-19 14:04:49 +02:00
|
|
|
|
redirect_to messagerie_dossier_path(dossier.procedure, dossier)
|
|
|
|
|
end
|
|
|
|
|
|
2017-07-24 20:04:41 +02:00
|
|
|
|
def position
|
|
|
|
|
etablissement = dossier.etablissement
|
|
|
|
|
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
|
|
|
|
|
|
|
|
|
|
lon = "2.428462"
|
|
|
|
|
lat = "46.538192"
|
|
|
|
|
zoom = "13"
|
|
|
|
|
|
|
|
|
|
unless point.nil?
|
|
|
|
|
lon = point.x.to_s
|
|
|
|
|
lat = point.y.to_s
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] }
|
|
|
|
|
end
|
|
|
|
|
|
2017-08-28 14:16:13 +02:00
|
|
|
|
def create_avis
|
|
|
|
|
Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
2017-09-26 14:38:16 +02:00
|
|
|
|
redirect_to avis_dossier_path(dossier.procedure, dossier)
|
2017-08-28 14:16:13 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-08-02 15:33:23 +02:00
|
|
|
|
def update_annotations
|
|
|
|
|
dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
|
|
|
|
|
dossier.update_attributes(champs_private_params)
|
2017-09-27 12:08:47 +02:00
|
|
|
|
redirect_to annotations_privees_dossier_path(dossier.procedure, dossier)
|
2017-08-02 15:33:23 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-10-05 23:27:02 +02:00
|
|
|
|
def print
|
|
|
|
|
@dossier = dossier
|
|
|
|
|
render layout: "print"
|
|
|
|
|
end
|
|
|
|
|
|
2017-06-29 15:31:29 +02:00
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def dossier
|
2017-07-06 16:33:36 +02:00
|
|
|
|
current_gestionnaire.dossiers.find(params[:dossier_id])
|
2017-06-29 15:31:29 +02:00
|
|
|
|
end
|
2017-07-19 14:04:49 +02:00
|
|
|
|
|
|
|
|
|
def commentaire_params
|
2017-10-30 16:16:20 +01:00
|
|
|
|
params.require(:commentaire).permit(:body, :file)
|
2017-07-19 14:04:49 +02:00
|
|
|
|
end
|
2017-08-28 14:16:13 +02:00
|
|
|
|
|
|
|
|
|
def avis_params
|
2017-09-20 10:42:16 +02:00
|
|
|
|
params.require(:avis).permit(:email, :introduction, :confidentiel)
|
2017-08-28 14:16:13 +02:00
|
|
|
|
end
|
2017-08-02 15:33:23 +02:00
|
|
|
|
|
|
|
|
|
def champs_private_params
|
|
|
|
|
params.require(:dossier).permit(champs_private_attributes: [:id, :value, value: []])
|
|
|
|
|
end
|
2017-06-29 15:31:29 +02:00
|
|
|
|
end
|
|
|
|
|
end
|