2017-05-12 15:47:05 +02:00
|
|
|
|
class ProcedureOverview
|
2017-06-27 18:00:05 +02:00
|
|
|
|
attr_accessor :procedure,
|
|
|
|
|
:created_dossiers_count,
|
|
|
|
|
:dossiers_en_instruction_count,
|
|
|
|
|
:old_dossiers_en_instruction,
|
|
|
|
|
:dossiers_en_construction_count,
|
|
|
|
|
:old_dossiers_en_construction
|
2017-05-12 15:47:05 +02:00
|
|
|
|
|
2020-01-15 14:57:40 +01:00
|
|
|
|
def initialize(procedure, start_date, groups)
|
2017-06-27 18:00:05 +02:00
|
|
|
|
@start_date = start_date
|
|
|
|
|
@procedure = procedure
|
2017-05-12 15:47:05 +02:00
|
|
|
|
|
2020-01-20 14:23:01 +01:00
|
|
|
|
dossiers = procedure.dossiers.where(groupe_instructeur: groups)
|
2020-01-15 14:57:40 +01:00
|
|
|
|
|
|
|
|
|
@dossiers_en_instruction_count = dossiers.state_en_instruction.count
|
|
|
|
|
@old_dossiers_en_instruction = dossiers
|
2017-06-27 18:00:05 +02:00
|
|
|
|
.state_en_instruction
|
2017-12-14 15:53:02 +01:00
|
|
|
|
.where('en_instruction_at < ?', 1.week.ago)
|
2017-06-27 18:00:05 +02:00
|
|
|
|
|
2020-01-15 14:57:40 +01:00
|
|
|
|
@dossiers_en_construction_count = dossiers.state_en_construction.count
|
|
|
|
|
@old_dossiers_en_construction = dossiers
|
2017-06-27 18:00:05 +02:00
|
|
|
|
.state_en_construction
|
2017-12-14 15:51:45 +01:00
|
|
|
|
.where('en_construction_at < ?', 1.week.ago)
|
2017-06-27 18:00:05 +02:00
|
|
|
|
|
2020-01-15 14:57:40 +01:00
|
|
|
|
@created_dossiers_count = dossiers
|
2018-10-25 15:07:15 +02:00
|
|
|
|
.where(created_at: start_date..Time.zone.now)
|
2017-06-27 18:00:05 +02:00
|
|
|
|
.state_not_brouillon
|
2017-05-12 15:47:05 +02:00
|
|
|
|
.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def had_some_activities?
|
2018-01-15 14:42:48 +01:00
|
|
|
|
[
|
|
|
|
|
@dossiers_en_instruction_count,
|
|
|
|
|
@dossiers_en_construction_count,
|
|
|
|
|
@created_dossiers_count
|
|
|
|
|
].reduce(:+) > 0
|
2017-05-12 15:47:05 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-06-27 18:00:05 +02:00
|
|
|
|
def dossiers_en_construction_description
|
|
|
|
|
case @dossiers_en_construction_count
|
2017-05-12 15:47:05 +02:00
|
|
|
|
when 0
|
|
|
|
|
nil
|
|
|
|
|
when 1
|
2017-06-27 18:00:05 +02:00
|
|
|
|
'dossier suivi en construction'
|
2017-05-12 15:47:05 +02:00
|
|
|
|
else
|
2017-06-27 18:00:05 +02:00
|
|
|
|
'dossiers suivis en construction'
|
2017-05-12 15:47:05 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-06-27 18:00:05 +02:00
|
|
|
|
def dossiers_en_instruction_description
|
|
|
|
|
case @dossiers_en_instruction_count
|
2017-05-12 15:47:05 +02:00
|
|
|
|
when 0
|
|
|
|
|
nil
|
|
|
|
|
when 1
|
2021-05-26 15:16:30 +02:00
|
|
|
|
"dossier est en cours d’instruction"
|
2017-05-12 15:47:05 +02:00
|
|
|
|
else
|
2021-05-26 15:16:30 +02:00
|
|
|
|
"dossiers sont en cours d’instruction"
|
2017-05-12 15:47:05 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-06-27 18:00:05 +02:00
|
|
|
|
def created_dossier_description
|
|
|
|
|
formated_date = I18n.l(@start_date, format: '%d %B %Y')
|
2017-05-12 15:47:05 +02:00
|
|
|
|
|
2017-06-27 18:00:05 +02:00
|
|
|
|
case @created_dossiers_count
|
2017-05-12 15:47:05 +02:00
|
|
|
|
when 0
|
|
|
|
|
nil
|
|
|
|
|
when 1
|
2017-06-27 18:00:05 +02:00
|
|
|
|
"nouveau dossier a été déposé depuis le #{formated_date}"
|
2017-05-12 15:47:05 +02:00
|
|
|
|
else
|
2017-06-27 18:00:05 +02:00
|
|
|
|
"nouveaux dossiers ont été déposés depuis le #{formated_date}"
|
2017-05-12 15:47:05 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|