diff --git a/Gemfile.lock b/Gemfile.lock index f6c7066..0541d29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -224,7 +224,7 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) - mimemagic (0.3.3) + mimemagic (0.3.10) mini_magick (4.10.1) mini_mime (1.0.2) mini_portile2 (2.4.0) diff --git a/app/views/admin/m_odrs/_form.html.haml b/app/views/admin/m_odrs/_form.html.haml index 842c51f..76066c1 100644 --- a/app/views/admin/m_odrs/_form.html.haml +++ b/app/views/admin/m_odrs/_form.html.haml @@ -13,13 +13,16 @@ = f.input :landing_text, :label => "Texte lancement :" .row.qi_cancel_margins - .col-sm-4 + .col-sm-3 = f.input :start_at, :label => "Date de début :" , :as => :date - .col-sm-4 + .col-sm-3 = f.input :end_at, :label => "Date de fin :" , :as => :date - .col-sm-4 + .col-sm-3 = f.input :public_end, :label => "Date de fin des envois :" , :as => :date - + + .col-sm-3 + = f.input :ins_limit, :label => "Nbr max de participations :" + .row.qi_cancel_margins diff --git a/app/views/public/m_odrs/show.html.haml b/app/views/public/m_odrs/show.html.haml index c1ffa03..29d2a88 100644 --- a/app/views/public/m_odrs/show.html.haml +++ b/app/views/public/m_odrs/show.html.haml @@ -7,6 +7,17 @@ %br %br %br + +-elsif @m_odr.ins_limit? and @m_odr.m_odr_reps.count >= @m_odr.ins_limit.to_i + %div{:style => "margin-top:30px;font-weight:bold;font-weight:800;font-size:2em;text-transform:uppercase;font-family: 'Open Sans','Helvetica Neue', Helvetica, sans-serif;text-align:center;"} + %br + Cette opération est maintenant terminée, nous vous remercions pour votre confiance ! + + %br + %br + %br + + -elsif @m_odr.start_at > Date.today and params[:force].to_s == "" %div{:style => "margin-top:30px;font-weight:bold;font-weight:800;font-size:2em;text-transform:uppercase;font-family: 'Open Sans','Helvetica Neue', Helvetica, sans-serif;text-align:center;"} -count = ((@m_odr.start_at) - (Date.today)) @@ -67,7 +78,23 @@ =hidden_field_tag :force, params[:force] =f.hidden_field :t + + -if @m_odr.ins_limit? + %center + %p + -nbr = @m_odr.ins_limit - @m_odr.m_odr_reps.count + + =nbr + + -if nbr > 1 + participations restantes + + -else + participation restante + + .form_pannel + %h3 Vous =f.inputs do diff --git a/db/migrate/20210913081136_add_ins_limit_to_m_odrs.rb b/db/migrate/20210913081136_add_ins_limit_to_m_odrs.rb new file mode 100644 index 0000000..b4f3afc --- /dev/null +++ b/db/migrate/20210913081136_add_ins_limit_to_m_odrs.rb @@ -0,0 +1,5 @@ +class AddInsLimitToMOdrs < ActiveRecord::Migration[6.0] + def change + add_column :m_odrs, :ins_limit, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index bbb21f0..aa86ecd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_10_06_115533) do +ActiveRecord::Schema.define(version: 2021_09_13_081136) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -967,6 +967,7 @@ ActiveRecord::Schema.define(version: 2020_10_06_115533) do t.integer "ba_number_place_x" t.integer "ba_remise_place_y" t.integer "ba_remise_place_x" + t.integer "ins_limit" t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id" end