Sha256: bed35b26e5324bcc68059568c4ebe3a2aee2ad30d6f7b3122fe79f7fcee464c6

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module Admin::ClientRepresentativesHelper
  include Admin::HasCredentialColumnHelper

  alias :client_representative_password_form_column :password_form_column
  alias :client_representative_login_enabled_form_column :login_enabled_form_column

  def client_representative_clients_form_column(record, options)
    list_i = nil

    # Keeps our queries down by 'caching' it here:
    client_ids = record.client_ids
    
    Client.find(:all, :order => 'company_name ASC').in_groups_of((Client.count(:all).to_f/3).ceil, false).collect{ |group|
      '<ul class="checkbox-list">'+
        group.collect{ |client|
          list_i = (list_i) ? list_i+1 : 0
          chk_name = "%s[%d][id]" % [options[:name], client.id]
          chk_id = "%s_client_%d" % [options[:id], client.id]

          '<li>%s<label for="%s">%s</label></li>' % [ 
            check_box_tag(chk_name, client.id, client_ids.include?(client.id), :id => chk_id ), 
            chk_id,
            h(client.company_name)
          ]
        }.join+
      '</ul>'
    }.join
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 app/helpers/admin/client_representatives_helper.rb
brisk-bills-0.8.1 app/helpers/admin/client_representatives_helper.rb