e9_crm 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +105 -0
  4. data/README.md +31 -0
  5. data/Rakefile +2 -0
  6. data/app/controllers/e9_crm/advertising_campaigns_controller.rb +3 -0
  7. data/app/controllers/e9_crm/affiliate_campaigns_controller.rb +3 -0
  8. data/app/controllers/e9_crm/base_controller.rb +5 -0
  9. data/app/controllers/e9_crm/campaign_groups_controller.rb +3 -0
  10. data/app/controllers/e9_crm/campaigns_controller.rb +4 -0
  11. data/app/controllers/e9_crm/companies_controller.rb +3 -0
  12. data/app/controllers/e9_crm/contact_emails_controller.rb +38 -0
  13. data/app/controllers/e9_crm/contact_merges_controller.rb +26 -0
  14. data/app/controllers/e9_crm/contacts_controller.rb +46 -0
  15. data/app/controllers/e9_crm/dated_costs_controller.rb +4 -0
  16. data/app/controllers/e9_crm/deals_controller.rb +19 -0
  17. data/app/controllers/e9_crm/email_campaigns_controller.rb +3 -0
  18. data/app/controllers/e9_crm/email_templates.controller.rb +3 -0
  19. data/app/controllers/e9_crm/menu_options_controller.rb +26 -0
  20. data/app/controllers/e9_crm/offers_controller.rb +3 -0
  21. data/app/controllers/e9_crm/page_views_controller.rb +20 -0
  22. data/app/controllers/e9_crm/record_attributes_controller.rb +3 -0
  23. data/app/controllers/e9_crm/reports_controller.rb +2 -0
  24. data/app/controllers/e9_crm/resources_controller.rb +43 -0
  25. data/app/controllers/e9_crm/sales_campaigns_controller.rb +3 -0
  26. data/app/helpers/e9_crm/base_helper.rb +77 -0
  27. data/app/helpers/e9_crm/campaigns_helper.rb +14 -0
  28. data/app/helpers/e9_crm/contact_merges_helper.rb +17 -0
  29. data/app/helpers/e9_crm/contacts_helper.rb +27 -0
  30. data/app/helpers/e9_crm/deals_helper.rb +15 -0
  31. data/app/helpers/e9_crm/menu_options_helper.rb +11 -0
  32. data/app/helpers/e9_crm/page_views_helper.rb +2 -0
  33. data/app/models/address_attribute.rb +4 -0
  34. data/app/models/advertising_campaign.rb +15 -0
  35. data/app/models/affiliate.rb +4 -0
  36. data/app/models/affiliate_campaign.rb +15 -0
  37. data/app/models/campaign.rb +34 -0
  38. data/app/models/campaign_group.rb +5 -0
  39. data/app/models/company.rb +4 -0
  40. data/app/models/contact.rb +258 -0
  41. data/app/models/contact_email.rb +49 -0
  42. data/app/models/dated_cost.rb +9 -0
  43. data/app/models/deal.rb +83 -0
  44. data/app/models/email_campaign.rb +13 -0
  45. data/app/models/email_template.rb +7 -0
  46. data/app/models/instant_messaging_handle_attribute.rb +4 -0
  47. data/app/models/menu_option.rb +33 -0
  48. data/app/models/offer.rb +50 -0
  49. data/app/models/page_view.rb +80 -0
  50. data/app/models/phone_number_attribute.rb +4 -0
  51. data/app/models/record_attribute.rb +41 -0
  52. data/app/models/sales_campaign.rb +15 -0
  53. data/app/models/sales_person.rb +4 -0
  54. data/app/models/tracking_cookie.rb +61 -0
  55. data/app/models/website_attribute.rb +4 -0
  56. data/app/observers/deal_observer.rb +11 -0
  57. data/app/uploaders/file_uploader.rb +34 -0
  58. data/app/views/e9_crm/campaigns/_form_inner.html.haml +5 -0
  59. data/app/views/e9_crm/contact_emails/_form.html.haml +7 -0
  60. data/app/views/e9_crm/contact_emails/_form_inner.html.haml +11 -0
  61. data/app/views/e9_crm/contact_emails/destroy.js.erb +3 -0
  62. data/app/views/e9_crm/contact_emails/send_email.js.erb +1 -0
  63. data/app/views/e9_crm/contact_merges/_field.html.haml +10 -0
  64. data/app/views/e9_crm/contact_merges/_form.html.haml +10 -0
  65. data/app/views/e9_crm/contact_merges/new.html.haml +2 -0
  66. data/app/views/e9_crm/contacts/_details.html.haml +22 -0
  67. data/app/views/e9_crm/contacts/_form_inner.html.haml +51 -0
  68. data/app/views/e9_crm/contacts/_header.html.haml +19 -0
  69. data/app/views/e9_crm/contacts/_tag_table.html.haml +15 -0
  70. data/app/views/e9_crm/contacts/index.html.haml +13 -0
  71. data/app/views/e9_crm/contacts/index.js.erb +5 -0
  72. data/app/views/e9_crm/contacts/merge.html.haml +1 -0
  73. data/app/views/e9_crm/contacts/templates.js.erb +1 -0
  74. data/app/views/e9_crm/deals/_form_inner.html.haml +5 -0
  75. data/app/views/e9_crm/deals/_header.html.haml +0 -0
  76. data/app/views/e9_crm/deals/leads.html.haml +13 -0
  77. data/app/views/e9_crm/email_templates/_form_inner.html.haml +9 -0
  78. data/app/views/e9_crm/menu_options/_form_inner.html.haml +6 -0
  79. data/app/views/e9_crm/menu_options/_header.html.haml +8 -0
  80. data/app/views/e9_crm/offers/_form.html.haml +7 -0
  81. data/app/views/e9_crm/offers/_form_inner.html.haml +42 -0
  82. data/app/views/e9_crm/offers/_form_inner.html.haml.bak +43 -0
  83. data/app/views/e9_crm/page_views/_table.html.haml +25 -0
  84. data/app/views/e9_crm/record_attributes/_address_attribute.html.haml +5 -0
  85. data/app/views/e9_crm/record_attributes/_instant_messaging_handle_attribute.html.haml +5 -0
  86. data/app/views/e9_crm/record_attributes/_phone_number_attribute.html.haml +5 -0
  87. data/app/views/e9_crm/record_attributes/_record_attribute.html.haml +10 -0
  88. data/app/views/e9_crm/record_attributes/_templates.js.erb +12 -0
  89. data/app/views/e9_crm/record_attributes/_user.html.haml +23 -0
  90. data/app/views/e9_crm/record_attributes/_website_attribute.html.haml +5 -0
  91. data/app/views/e9_crm/resources/_footer.html.haml +1 -0
  92. data/app/views/e9_crm/resources/_form.html.haml +7 -0
  93. data/app/views/e9_crm/resources/_form_inner.html.haml +5 -0
  94. data/app/views/e9_crm/resources/_header.html.haml +0 -0
  95. data/app/views/e9_crm/resources/_table.html.haml +21 -0
  96. data/app/views/e9_crm/resources/create.js.erb +6 -0
  97. data/app/views/e9_crm/resources/destroy.js.erb +3 -0
  98. data/app/views/e9_crm/resources/edit.html.haml +2 -0
  99. data/app/views/e9_crm/resources/index.html.haml +13 -0
  100. data/app/views/e9_crm/resources/index.js.erb +1 -0
  101. data/app/views/e9_crm/resources/new.html.haml +2 -0
  102. data/app/views/e9_crm/resources/show.html.haml +2 -0
  103. data/app/views/e9_crm/resources/update.js.erb +5 -0
  104. data/config/initializers/inflections.rb +3 -0
  105. data/config/locales/e9.en.yml +28 -0
  106. data/config/locales/en.yml +63 -0
  107. data/config/routes.rb +61 -0
  108. data/e9_crm.gemspec +29 -0
  109. data/lib/e9_crm/model.rb +63 -0
  110. data/lib/e9_crm/rails_extensions.rb +98 -0
  111. data/lib/e9_crm/tracking_controller.rb +78 -0
  112. data/lib/e9_crm/version.rb +3 -0
  113. data/lib/e9_crm.rb +59 -0
  114. data/lib/generators/e9_crm/install_generator.rb +32 -0
  115. data/lib/generators/e9_crm/templates/create_e9_crm_tables.rb +107 -0
  116. data/lib/generators/e9_crm/templates/initializer.rb +4 -0
  117. data/lib/generators/e9_crm/templates/javascript.js +187 -0
  118. data/test/functional/e9_crm/campaign_types_controller_test.rb +49 -0
  119. data/test/functional/home_controller_test.rb +8 -0
  120. metadata +283 -0
@@ -0,0 +1,15 @@
1
+ # An sales campaign
2
+ #
3
+ # Carries an affiliate fee
4
+ #
5
+ class SalesCampaign < Campaign
6
+ money_columns :sales_fee
7
+ belongs_to :sales_person
8
+
9
+ ##
10
+ # The sum cost of this campaign
11
+ #
12
+ def cost
13
+ sales_fee
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # A contact subtype for sales people, who drive sales campaigns
2
+ #
3
+ class SalesPerson < Contact
4
+ end
@@ -0,0 +1,61 @@
1
+ require 'digest/md5'
2
+
3
+ # Mirrors a browser cookie installed on the client
4
+ #
5
+ # == Purpose
6
+ #
7
+ # A +User+ may have many cookies, and it is through these cookies that associated
8
+ # +PageView+ records are tracked.
9
+ #
10
+ # == Behavior
11
+ #
12
+ # The cookie is tracked through it's hashed id (hid), and maintains the most
13
+ # recent campaign code passed from the associated client.
14
+ #
15
+ # Immediately after the cookie is loaded or created, a +PageView+ is generated.
16
+ # It is given the current +code+ of the cookie, if it exists, and if either the
17
+ # cookie itself is new, or the code on it is new (has changed), that +PageView+
18
+ # is marked as a new visit.
19
+ #
20
+ # In this way, a +PageView+ will be credited to a campaign code even if it a
21
+ # code is not passed in its actual request. The timeline might look like this:
22
+ #
23
+ # 1. A client visits the site normally with no campaign code.
24
+ # - A cookie is created/installed
25
+ # - A new visit, uncoded page view is created
26
+ #
27
+ # 2. The client visits another page.
28
+ # - The installed cookie is loaded
29
+ # - An uncoded page view is created.
30
+ #
31
+ # 3. The same client (pre-existing cookie) visits the site with code ABC.
32
+ # - The installed cookie is loaded, its code updated to ABC.
33
+ # - A new visit, ABC coded page view is created
34
+ #
35
+ # 4. The client visits another page.
36
+ # - The installed cookie is loaded
37
+ # - An ABC coded page view is created
38
+ #
39
+ # In this manner, page views are always credited to the most recently loaded
40
+ # code, with the assumption that it was the most recently seen code that
41
+ # prompted the client to (re)visit the site.
42
+ #
43
+ class TrackingCookie < ActiveRecord::Base
44
+ belongs_to :user, :inverse_of => :tracking_cookies
45
+ has_many :page_views
46
+ after_save :generate_hid, :on => :create
47
+
48
+ attr_accessor :new_visit
49
+
50
+ def new_visit?
51
+ @new_visit.present?
52
+ end
53
+
54
+ protected
55
+
56
+ def generate_hid
57
+ unless hid.present?
58
+ update_attribute :hid, Digest::MD5.hexdigest("#{id}//#{DateTime.now}")
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,4 @@
1
+ # Attribute for related websites, e.g. Facebook Page, Personal Website
2
+ #
3
+ class WebsiteAttribute < RecordAttribute
4
+ end
@@ -0,0 +1,11 @@
1
+ class DealObserver < ActiveRecord::Observer
2
+ def before_revert(record)
3
+ end
4
+
5
+ def before_convert(record)
6
+ if email = record.offer && record.offer.conversion_alert_email.presence
7
+ Rails.logger.debug("Sending Offer Conversion Alert to [#{email}]")
8
+ Offer.conversion_email.try(:send!, email)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ class FileUploader < CarrierWave::Uploader::Base
4
+
5
+ # Override the directory where uploaded files will be stored.
6
+ # This is a sensible default for uploaders that are meant to be mounted:
7
+ def store_dir
8
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
9
+ end
10
+
11
+ #Add a white list of extensions which are allowed to be uploaded.
12
+ #For images you might use something like this:
13
+ def extension_white_list
14
+ %w(*)
15
+ end
16
+
17
+ # A string of file extensions acceptable for the uploader.
18
+ # (passed to uploadify)
19
+ #
20
+ def file_ext(delimiter= ';')
21
+ extension_white_list.map {|ext| "*.#{ext}" }.join(delimiter)
22
+ end
23
+
24
+ # Description of file types acceptable for the uploader
25
+ # (passed to uploadify)
26
+ #
27
+ def file_desc
28
+ "All Files (#{file_ext(',')})"
29
+ end
30
+
31
+ def filename
32
+ super.presence || path.present? && path.split('/').last
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ - resource.attributes.each_pair do |field, value|
2
+ - next if ['id', 'created_at', 'updated_at'].include?(field)
3
+ .field
4
+ = f.label field
5
+ = f.text_field field
@@ -0,0 +1,7 @@
1
+ = form_for resource, :url => polymorphic_path(resource), :remote => request.xhr? do |f|
2
+ .errors= resource_error_messages!
3
+
4
+ = render 'form_inner', :f => f
5
+
6
+ .actions
7
+ = f.submit
@@ -0,0 +1,11 @@
1
+ = f.hidden_field :name
2
+ = f.hidden_field :user_ids
3
+ .field
4
+ = f.label :from_email, nil, :class => :req
5
+ = f.text_field :from_email
6
+ .field
7
+ = f.label :subject, nil, :class => :req
8
+ = f.text_field :subject
9
+ .field
10
+ = f.label :text_body, nil, :class => :req
11
+ = f.text_area :text_body
@@ -0,0 +1,3 @@
1
+ <% if !resource.errors.any? %>
2
+ $("#ids_<%= resource.id %>").fadeOut();
3
+ <% end %>
@@ -0,0 +1 @@
1
+ // send email
@@ -0,0 +1,10 @@
1
+ .field
2
+ = f.label column
3
+ .contact-a-value
4
+ %label{:for => "contact_a_#{column}"}
5
+ = contact_a(column).presence || e9_t(:no_value)
6
+ = f.radio_button column, contact_a(column), :checked => (f.object.send(column) == contact_a(column) || f.object.send(column).blank?), :id => "contact_a_#{column}"
7
+ .contact-b-value
8
+ %label{:for => "contact_b_#{column}"}
9
+ = contact_b(column).presence || e9_t(:no_value)
10
+ = f.radio_button column, contact_b(column), :id => "contact_b_#{column}"
@@ -0,0 +1,10 @@
1
+ = form_for @contact, :url => contact_merges_path do |f|
2
+ = hidden_field_tag :contact_a_id, @contact_a.id
3
+ = hidden_field_tag :contact_b_id, @contact_b.id
4
+
5
+ = render 'field', :column => :first_name, :f => f
6
+ = render 'field', :column => :last_name, :f => f
7
+ = render 'field', :column => :company_name, :f => f
8
+ = render 'field', :column => :title, :f => f
9
+ .actions
10
+ = f.submit
@@ -0,0 +1,2 @@
1
+ = title e9_t(:new_title)
2
+ = render 'form'
@@ -0,0 +1,22 @@
1
+ .contact-who
2
+ %span.contact-name= record.name
3
+ - if record.company_id? || record.title?
4
+ = " - "
5
+ = link_to_contact_search(:by_title, record.title) if record.title?
6
+ = " at " if record.company_id? && record.title?
7
+ = link_to_contact_search(:by_company, record.company_id, record.company_name) if record.company_id?
8
+
9
+ - if record.phone_number_attributes.any?
10
+ .contact-phone-numbers
11
+ - record.phone_number_attributes.each do |phone_number_attribute|
12
+ .contact-phone-number= phone_number_attribute
13
+
14
+ - if record.instant_messaging_handle_attributes.any?
15
+ .contact-im-handles
16
+ - record.instant_messaging_handle_attributes.each do |instant_messaging_handle_attribute|
17
+ .contact-im-handle= instant_messaging_handle_attribute
18
+
19
+ - if record.website_attributes.any?
20
+ .contact-websites
21
+ - record.website_attributes.each do |website_attribute|
22
+ .contact-website= website_attribute
@@ -0,0 +1,51 @@
1
+ %fieldset.contact-standard-fields
2
+ %legend= e9_t(:form_legend_standard)
3
+ .field
4
+ = f.label :first_name
5
+ = f.text_field :first_name
6
+ .field
7
+ = f.label :last_name
8
+ = f.text_field :last_name
9
+ .field
10
+ = f.label :company_name
11
+ = f.text_field :company_name
12
+ .field
13
+ = f.label :title
14
+ = f.text_field :title
15
+
16
+ = render 'e9_tags/form', :f => f, :context => [:users, true]
17
+
18
+ %fieldset.contact-contact-fields
19
+ %legend= e9_t(:form_legend_contact)
20
+
21
+ %fieldset.nested-associations
22
+ %legend
23
+ %span= f.label(:users)
24
+ = link_to_add_record_attribute(:users)
25
+ = render_record_attribute_association(:users, f)
26
+
27
+ %fieldset.nested-associations
28
+ %legend
29
+ %span= f.label(:phone_number_attributes)
30
+ = link_to_add_record_attribute(:phone_number_attributes)
31
+ = render_record_attribute_association(:phone_number_attributes, f)
32
+
33
+ %fieldset.nested-associations
34
+ %legend
35
+ %span= f.label(:instant_messaging_handle_attributes)
36
+ = link_to_add_record_attribute(:instant_messaging_handle_attributes)
37
+ = render_record_attribute_association(:instant_messaging_handle_attributes, f)
38
+
39
+ %fieldset.nested-associations
40
+ %legend
41
+ %span= f.label(:website_attributes)
42
+ = link_to_add_record_attribute(:website_attributes)
43
+ = render_record_attribute_association(:website_attributes, f)
44
+
45
+ %fieldset.nested-associations
46
+ %legend
47
+ %span= f.label(:address_attributes)
48
+ = link_to_add_record_attribute(:address_attributes)
49
+ = render_record_attribute_association(:address_attributes, f)
50
+
51
+ = javascript_include_tag templates_contacts_path
@@ -0,0 +1,19 @@
1
+ .toolbar
2
+ .toolbar-left
3
+ = form_tag(resource_class, :method => :get, :id => 'contact_search_form') do
4
+ = label_tag 'contact_search_field', t(:search)
5
+ = text_field_tag 'search', params[:search], :id => 'contact_search_field'
6
+ = submit_tag t(:go), :name => nil
7
+ = submit_tag t(:clear), :name => nil, :id => 'contact_search_clear'
8
+ .toolbar-middle
9
+ = form_tag new_contact_email_path, :method => :get, :id => 'contact_email_form', 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @user_ids.length do
10
+ = select_tag 'etid', contact_email_template_select_options
11
+ = hidden_field_tag 'uids', @user_ids.join(','), :id => 'contact_email_uids'
12
+ = submit_tag e9_t(:send_email_template), :name => nil
13
+ = form_tag send_email_admin_user_email_path('__ID__'), :method => :put, :id => 'contact_newsletter_form', 'data-confirm' => e9_t(:contact_newsletter_confirmation, :count => collection.length), 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @user_ids.length do
14
+ = select_tag 'eid', contact_newsletter_select_options
15
+ = hidden_field_tag 'uids', @user_ids.join(','), :id => 'contact_newsletter_uids'
16
+ = submit_tag e9_t(:send_email_newsletter), :name => nil
17
+ .toolbar-right
18
+ = link_to_new_resource(Contact)
19
+ = link_to_new_resource(Company)
@@ -0,0 +1,15 @@
1
+ - tagged_params = Array.wrap(params[:tagged])
2
+ %table.tag-table
3
+ %thead
4
+ %th{:colspan => 2}
5
+ = t(:tags_name, :scope => :e9_tags)
6
+ %tbody
7
+ - Tagging.where(:context => E9Tags.escape_context('users*')).joins(:tag).all.group_by {|t| t.name[0].upcase }.sort.each do |letter, tags|
8
+ %tr
9
+ %td.tag-starts-with= letter
10
+ %td.tags
11
+ %ul.tags
12
+ - tags.sort_by(&:name).each do |tag|; tag_id = "tagged-#{tag.name.dasherize}"
13
+ %li.tag
14
+ = label_tag(tag_id, tag.name)
15
+ = check_box_tag('tagged[]', tag.name, tagged_params.member?(tag.name), :id => tag_id)
@@ -0,0 +1,13 @@
1
+ = title (@index_title || e9_t(:index_title))
2
+
3
+
4
+ #index_header
5
+ = render 'header'
6
+
7
+ #records_table
8
+ = render 'table', :resources => collection
9
+
10
+ #contact-tag-list
11
+ = render 'tag_table'
12
+
13
+ = render 'footer'
@@ -0,0 +1,5 @@
1
+ <% new_title = @index_title || e9_t(:index_title) %>
2
+ $('#index_header').html("<%= escape_javascript(render('header')) %>");
3
+ $('#records_table').html("<%= escape_javascript(render('table', :resources => collection)) %>");
4
+ document.title = "<%= escape_javascript(meta_title(new_title)) %>";
5
+ $("h1.title, ul.breadcrumbs li.last").html("<%= escape_javascript(new_title) %>");
@@ -0,0 +1 @@
1
+ <%= render 'e9_crm/record_attributes/templates' %>
@@ -0,0 +1,5 @@
1
+ - resource.attributes.each_pair do |field, value|
2
+ - next if ['id', 'created_at', 'updated_at'].include?(field)
3
+ .field
4
+ = f.label field
5
+ = f.text_field field
File without changes
@@ -0,0 +1,13 @@
1
+ = title (@index_title || e9_t(:index_title))
2
+
3
+ = render 'header'
4
+
5
+ - if sortable_controller?
6
+ = form_tag polymorphic_path([:update_order, resource_class]) do
7
+ %div#records_table
8
+ = render 'table', :resources => collection, :field_map => {}
9
+ - else
10
+ %div#records_table
11
+ = render 'table', :resources => collection
12
+
13
+ = render 'footer'
@@ -0,0 +1,9 @@
1
+ .field
2
+ = f.label :name, nil, :class => :req
3
+ = f.text_field :name
4
+ .field
5
+ = f.label :subject, nil, :class => :req
6
+ = f.text_field :subject
7
+ .field
8
+ = f.label :text_body, nil, :class => :req
9
+ = f.text_area :text_body
@@ -0,0 +1,6 @@
1
+ .field
2
+ = f.label :key
3
+ = f.select :key, MenuOption::KEYS.sort
4
+ .field
5
+ = f.label :value
6
+ = f.text_field :value
@@ -0,0 +1,8 @@
1
+ .toolbar
2
+ .toolbar-left
3
+ %form{:action => menu_options_path, :method => :get, :id => 'menu_option_key_select_form'}
4
+ = label_tag 'menu_option_key_select', t(:view)
5
+ = select_tag 'key', options_for_select(MenuOption::KEYS.sort, params[:key]), :id => 'menu_option_key_select'
6
+ = submit_tag t(:go), :name => nil
7
+ .toolbar-right
8
+ = link_to_new_resource(MenuOption, :menu_option => {:key => params[:key]})
@@ -0,0 +1,7 @@
1
+ = form_for resource, :url => polymorphic_path([parent, resource]), :remote => request.xhr?, :html => { :multipart => true } do |f|
2
+ .errors= resource_error_messages!
3
+
4
+ = render 'form_inner', :f => f
5
+
6
+ .actions
7
+ = f.submit
@@ -0,0 +1,42 @@
1
+ .field
2
+ = f.label :name, nil, :class => :req
3
+ = f.text_field :name
4
+
5
+ .field{:class => request.xhr? ? 'tinymcexhr' : 'tinymce'}
6
+ = f.label :template, nil, :class => :req
7
+ = f.text_area :template
8
+
9
+ - if request.xhr?
10
+ - resource.region_type_ids.each_with_index do |id, i|
11
+ = hidden_field_tag 'offer[region_type_ids][]', id, :id => "offer_region_type_ids_#{i}"
12
+ - if resource.new_record?
13
+ - resource.node_ids.each_with_index do |id, i|
14
+ = hidden_field_tag 'offer[node_ids][]', id, :id => "offer_node_ids_#{i}"
15
+ - else
16
+ = render 'shared/admin/region_type_select', :f => f
17
+
18
+ %fieldset.upload
19
+ = render 'shared/form_partials/carrierwave_upload_field', :field => :file, :f => f
20
+ .field
21
+ = f.label :download_link_text
22
+ = f.text_field :download_link_text
23
+
24
+ .field
25
+ = f.label :success_alert_text
26
+ = f.text_field :success_alert_text
27
+
28
+ .field
29
+ = f.label :success_page_text
30
+ = f.text_area :success_page_text
31
+
32
+ .field
33
+ = f.label :success_alert_text
34
+ = f.text_field :success_alert_text
35
+
36
+ .field
37
+ = f.label :conversion_alert_email
38
+ = f.text_field :conversion_alert_email
39
+
40
+ .field
41
+ = f.label :custom_form_html
42
+ = f.text_area :custom_form_html
@@ -0,0 +1,43 @@
1
+ = f.fields_for resource.options do |ff|
2
+ .field
3
+ = f.label :name, nil, :class => :req
4
+ = f.text_field :name
5
+
6
+ .field{:class => request.xhr? ? 'tinymcexhr' : 'tinymce'}
7
+ = f.label :template, nil, :class => :req
8
+ = f.text_area :template
9
+
10
+ - if request.xhr?
11
+ - resource.region_type_ids.each_with_index do |id, i|
12
+ = hidden_field_tag 'offer[region_type_ids][]', id, :id => "offer_region_type_ids_#{i}"
13
+ - if resource.new_record?
14
+ - resource.node_ids.each_with_index do |id, i|
15
+ = hidden_field_tag 'offer[node_ids][]', id, :id => "offer_node_ids_#{i}"
16
+ - else
17
+ = render 'shared/admin/region_type_select', :f => f
18
+
19
+ %fieldset.upload
20
+ = render 'shared/form_partials/carrierwave_upload_field', :field => :file, :f => f
21
+ .field
22
+ = ff.label :download_link_text
23
+ = ff.text_field :download_link_text
24
+
25
+ .field
26
+ = ff.label :success_alert_text
27
+ = ff.text_field :success_alert_text
28
+
29
+ .field
30
+ = ff.label :success_page_text
31
+ = ff.text_area :success_page_text
32
+
33
+ .field
34
+ = ff.label :success_alert_text
35
+ = ff.text_field :success_alert_text
36
+
37
+ .field
38
+ = ff.label :conversion_alert_email
39
+ = ff.text_field :conversion_alert_email
40
+
41
+ .field
42
+ = ff.label :custom_form_html
43
+ = ff.text_area :custom_form_html
@@ -0,0 +1,25 @@
1
+ %table.records
2
+ %thead
3
+ %tr
4
+ %th= orderable_column_link('campaign.name', :campaign)
5
+ %th= orderable_column_link(:created_at)
6
+ %th= orderable_column_link(:request_path)
7
+ %th= orderable_column_link(:referer)
8
+ %th= orderable_column_link(:remote_ip)
9
+ %tbody
10
+ - if collection.empty?
11
+ %tr
12
+ %td{:colspan => 5}= e9_t(:no_records_text)
13
+ - else
14
+ - collection.each do |record|
15
+ %tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
16
+ %td.contact-campaign-name
17
+ = record.campaign_name || 'n/a'
18
+ %td.contact-created-at
19
+ = I18n.l(record.created_at)
20
+ %td.contact-request-path
21
+ = record.request_path
22
+ %td.contact-referer
23
+ = record.referer
24
+ %td.contact-remote-ip
25
+ = record.remote_ip
@@ -0,0 +1,5 @@
1
+ = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f, :value_field_type => :text_area } do
2
+ - if (types = AddressAttribute.types).present?
3
+ = f.fields_for f.object.options do |ff|
4
+ .field
5
+ = ff.select :type, types
@@ -0,0 +1,5 @@
1
+ = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
+ - if (types = InstantMessagingHandleAttribute.types).present?
3
+ = f.fields_for f.object.options do |ff|
4
+ .field
5
+ = ff.select :type, types
@@ -0,0 +1,5 @@
1
+ = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
+ - if (types = PhoneNumberAttribute.types).present?
3
+ = f.fields_for f.object.options do |ff|
4
+ .field
5
+ = ff.select :type, types
@@ -0,0 +1,10 @@
1
+ .record-attribute.nested-association
2
+ - if f.object.persisted?
3
+ = f.hidden_field :id
4
+ = f.hidden_field :_destroy, :value => 0
5
+ .field
6
+ = f.send local_assigns[:value_field_type] || :text_field, :value
7
+
8
+ = yield
9
+
10
+ = link_to_destroy_record_attribute
@@ -0,0 +1,12 @@
1
+ E9CRM = window.E9CRM || {};
2
+ E9CRM.js_templates = {};
3
+ E9CRM.js_templates.start_child_index =
4
+ E9CRM.js_templates.current_child_index = <%= child_index = 100000 %>;
5
+ <%= fields_for(resource) do |f| %>
6
+ <% resource_class::RECORD_ATTRIBUTES.each do |association_name| %>
7
+ <% build_associated_resource(association_name) %>
8
+ <%= f.fields_for(association_name, :child_index => child_index) do |association_form_builder| %>
9
+ E9CRM.js_templates.<%= association_name %> = "<%= escape_javascript(record_attribute_template(association_name, association_form_builder)) %>";
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,23 @@
1
+ .record-attribute.nested-association
2
+ = f.hidden_field :status
3
+
4
+ - if f.object.persisted?
5
+ = f.hidden_field :id
6
+ = f.hidden_field :_destroy, :value => 0
7
+ .field
8
+ = f.object.email
9
+ - else
10
+ .field
11
+ = f.email_field :email
12
+
13
+ = f.fields_for f.object.options do |ff|
14
+ - if (types = User.email_types).present?
15
+ .field
16
+ = ff.select :type, types
17
+ .field.radio
18
+ = ff.hidden_field :primary, :value => false
19
+ = ff.label :primary_true, ff.object.class.human_attribute_name(:primary)
20
+ = ff.radio_button :primary, true
21
+
22
+ - if f.object.prospect?
23
+ = link_to_destroy_record_attribute
@@ -0,0 +1,5 @@
1
+ = render :layout => 'e9_crm/record_attributes/record_attribute', :locals => { :f => f } do
2
+ - if (types = WebsiteAttribute.types).present?
3
+ = f.fields_for f.object.options do |ff|
4
+ .field
5
+ = ff.select :type, types
@@ -0,0 +1 @@
1
+ = will_paginate collection
@@ -0,0 +1,7 @@
1
+ = form_for resource, :url => polymorphic_path([parent, resource]), :remote => request.xhr? do |f|
2
+ .errors= resource_error_messages!
3
+
4
+ = render 'form_inner', :f => f
5
+
6
+ .actions
7
+ = f.submit
@@ -0,0 +1,5 @@
1
+ - resource.attributes.each_pair do |field, value|
2
+ - next if ['id', 'created_at', 'updated_at'].include?(field)
3
+ .field
4
+ = f.label field
5
+ = f.text_field field
File without changes
@@ -0,0 +1,21 @@
1
+ - field_map = local_assigns[:field_map] || records_table_field_map
2
+
3
+ %table.records{:class => sortable_controller? ? 'sortable' : nil }
4
+ %thead
5
+ %tr
6
+ - field_map[:fields].keys.each do |field|
7
+ %th= resource_class.human_attribute_name(field)
8
+ %th= e9_t(:actions)
9
+ %tbody
10
+ - if collection.empty?
11
+ %tr
12
+ %td{:colspan => field_map[:fields].length + 1}= e9_t(:no_records_text)
13
+ - else
14
+ - collection.each do |record|
15
+ %tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
16
+ - field_map[:fields].each do |key, value|
17
+ %td{:class => "contact-#{key}"}
18
+ = value.respond_to?(:call) ? value.call(record) : record.send(key)
19
+ %td.links
20
+ - field_map[:links][record].each do |link|
21
+ = link
@@ -0,0 +1,6 @@
1
+ <% if resource.errors.any? %>
2
+ $('form .errors').html("<%= escape_javascript(resource_error_messages!) %>");
3
+ $.fn.colorbox.resize();
4
+ <% else %>
5
+ window.location.reload(true);
6
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% if !resource.errors.any? %>
2
+ $("#ids_<%= resource.id %>").fadeOut();
3
+ <% end %>