<commit_before>= render partial: "/admin/order_cycles/order_cycle_top_buttons"

- content_for :page_title do
  = t :edit_order_cycle

- shared_payment_methods = order_cycle_shared_payment_methods(@order_cycle)
- shared_shipping_methods = order_cycle_shared_shipping_methods(@order_cycle)

= form_for [main_app, :admin, @order_cycle], html: { class: "order_cycle" } do |f|

  = render 'wizard_progress'

  %fieldset.no-border-bottom
    %legend{ align: 'center'}= t('.checkout_options')

  = hidden_field_tag "order_cycle[selected_shipping_method_ids][]", ""

  %table.checkout-options
    %thead
      %tr
        %th= t('.distributor')
        %th= t('.shipping_methods')
        %th= t('.payment_methods')
      - @order_cycle.distributors.each do |distributor|
        - payment_methods = @order_cycle.attachable_payment_methods.where("distributor_id = ?", distributor.id) -  shared_payment_methods
        - shipping_methods = @order_cycle.attachable_shipping_methods.where("distributor_id = ?", distributor.id) - shared_shipping_methods
        %tr
          %td= distributor.name
          %td
            - shipping_methods.each do |shipping_method|
              %p
                %label
                  = check_box_tag "order_cycle[selected_shipping_method_ids][]",
                      shipping_method.id, @order_cycle.shipping_methods.include?(shipping_method),
                      id: "order_cycle_selected_shipping_method_ids_#{shipping_method.id}"
                  = shipping_method.name
            - distributor.shipping_methods.backend.each do |shipping_method|
              %label.disabled
                = check_box_tag nil, nil, false, disabled: true
                = shipping_method.name
                = "(#{t('.back_end')})"
            - if shipping_methods.none? && distributor.shipping_methods.backend.none?
              %p.text-center
                = t('.no_shipping_methods')
          %td
            - if payment_methods.any?
              %ul
                - payment_methods.each do |payment_method|
                  %li= payment_method.name
            - else
              %p.text-center
                = t('.no_payment_methods')
      - if shared_payment_methods.any? || shared_shipping_methods.any?
        %tr
          %td= t('.shared')
          %td
            - if shared_shipping_methods.any?
              = f.collection_check_boxes :shipping_method_ids, shared_shipping_methods, :id, :name do |input|
                - shared_shipping_method = input.object
                %p
                  = input.check_box
                  = input.label
                %p
                  &mdash;
                  %em>
                    = shared_shipping_method.distributors.where(id: @order_cycle.distributor_ids).map(&:name).join(", ")
          %td
            - if shared_payment_methods.any?
              %ul
                - shared_payment_methods.each do |shared_payment_method|
                  %li
                    = shared_payment_method.name
                    %p
                      &mdash;
                      %em
                        = shared_payment_method.distributors.where(id: @order_cycle.distributor_ids).map(&:name).join(", ")

  %div#save-bar
    %div.container
      %div.seven.columns.alpha
        - if @order_cycle.errors.any?
          %h5#status-message.error
            = @order_cycle.errors.to_a.to_sentence
      %div.nine.columns.omega.text-right
        = hidden_field_tag :context, :checkout_options
        = f.submit t('.save'), class: "red", name: :save
        = f.submit t('.save_and_back_to_list'), class: "red", name: :save_and_back_to_list
        %a.button.cancel{ href: main_app.admin_order_cycles_path }
          = t('.cancel')
<commit_msg>Fix :selected_shipping_method_ids param for shared shipping methods.<commit_after>= render partial: "/admin/order_cycles/order_cycle_top_buttons"

- content_for :page_title do
  = t :edit_order_cycle

- shared_payment_methods = order_cycle_shared_payment_methods(@order_cycle)
- shared_shipping_methods = order_cycle_shared_shipping_methods(@order_cycle)

= form_for [main_app, :admin, @order_cycle], html: { class: "order_cycle" } do |f|

  = render 'wizard_progress'

  %fieldset.no-border-bottom
    %legend{ align: 'center'}= t('.checkout_options')

  = hidden_field_tag "order_cycle[selected_shipping_method_ids][]", ""

  %table.checkout-options
    %thead
      %tr
        %th= t('.distributor')
        %th= t('.shipping_methods')
        %th= t('.payment_methods')
      - @order_cycle.distributors.each do |distributor|
        - payment_methods = @order_cycle.attachable_payment_methods.where("distributor_id = ?", distributor.id) -  shared_payment_methods
        - shipping_methods = @order_cycle.attachable_shipping_methods.where("distributor_id = ?", distributor.id) - shared_shipping_methods
        %tr
          %td= distributor.name
          %td
            - shipping_methods.each do |shipping_method|
              %p
                %label
                  = check_box_tag "order_cycle[selected_shipping_method_ids][]",
                      shipping_method.id, @order_cycle.shipping_methods.include?(shipping_method),
                      id: "order_cycle_selected_shipping_method_ids_#{shipping_method.id}"
                  = shipping_method.name
            - distributor.shipping_methods.backend.each do |shipping_method|
              %label.disabled
                = check_box_tag nil, nil, false, disabled: true
                = shipping_method.name
                = "(#{t('.back_end')})"
            - if shipping_methods.none? && distributor.shipping_methods.backend.none?
              %p.text-center
                = t('.no_shipping_methods')
          %td
            - if payment_methods.any?
              %ul
                - payment_methods.each do |payment_method|
                  %li= payment_method.name
            - else
              %p.text-center
                = t('.no_payment_methods')
      - if shared_payment_methods.any? || shared_shipping_methods.any?
        %tr
          %td= t('.shared')
          %td
            - if shared_shipping_methods.any?
              = f.collection_check_boxes :selected_shipping_method_ids, shared_shipping_methods, :id, :name do |input|
                - shared_shipping_method = input.object
                %p
                  = input.check_box
                  = input.label
                %p
                  &mdash;
                  %em>
                    = shared_shipping_method.distributors.where(id: @order_cycle.distributor_ids).map(&:name).join(", ")
          %td
            - if shared_payment_methods.any?
              %ul
                - shared_payment_methods.each do |shared_payment_method|
                  %li
                    = shared_payment_method.name
                    %p
                      &mdash;
                      %em
                        = shared_payment_method.distributors.where(id: @order_cycle.distributor_ids).map(&:name).join(", ")

  %div#save-bar
    %div.container
      %div.seven.columns.alpha
        - if @order_cycle.errors.any?
          %h5#status-message.error
            = @order_cycle.errors.to_a.to_sentence
      %div.nine.columns.omega.text-right
        = hidden_field_tag :context, :checkout_options
        = f.submit t('.save'), class: "red", name: :save
        = f.submit t('.save_and_back_to_list'), class: "red", name: :save_and_back_to_list
        %a.button.cancel{ href: main_app.admin_order_cycles_path }
          = t('.cancel')

{'fraction_non_alphanumeric': 0.10688836104513064, 'fraction_numerical': 0.0002639218791237794, 'mean_word_length': 2.000395882818686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1787392', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2184, 'n_words': 332}