e9_crm 0.1.7 → 0.1.8
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.
- data/.gitignore +1 -0
- data/app/controllers/e9_crm/campaigns_controller.rb +3 -0
- data/app/controllers/e9_crm/contact_emails_controller.rb +5 -1
- data/app/controllers/e9_crm/contact_offers_controller.rb +3 -0
- data/app/controllers/e9_crm/deals_controller.rb +41 -13
- data/app/controllers/e9_crm/file_download_offers_controller.rb +3 -0
- data/app/controllers/e9_crm/leads_controller.rb +74 -0
- data/app/controllers/e9_crm/new_content_subscription_offers_controller.rb +3 -0
- data/app/controllers/e9_crm/newsletter_subscription_offers_controller.rb +3 -0
- data/app/controllers/e9_crm/offer_subclass_controller.rb +11 -0
- data/app/controllers/e9_crm/offers_controller.rb +37 -0
- data/app/controllers/e9_crm/resources_controller.rb +8 -0
- data/app/controllers/e9_crm/video_offers_controller.rb +3 -0
- data/app/helpers/e9_crm/deals_helper.rb +32 -0
- data/app/helpers/e9_crm/leads_helper.rb +63 -0
- data/app/helpers/e9_crm/offers_helper.rb +16 -0
- data/app/models/campaign.rb +1 -0
- data/app/models/contact.rb +2 -0
- data/app/models/contact_offer.rb +2 -0
- data/app/models/deal.rb +110 -8
- data/app/models/file_download_offer.rb +2 -0
- data/app/models/new_content_subscription_offer.rb +5 -0
- data/app/models/newsletter_subscription_offer.rb +5 -0
- data/app/models/no_campaign.rb +5 -1
- data/app/models/offer.rb +30 -19
- data/app/models/subscription_offer.rb +3 -0
- data/app/models/video_offer.rb +2 -0
- data/app/views/e9_crm/campaigns/_header.html.haml +2 -2
- data/app/views/e9_crm/contact_offers/_form_inner.html.haml +5 -0
- data/app/views/e9_crm/contacts/_form_inner.html.haml +2 -1
- data/app/views/e9_crm/contacts/_index_sidebar.html.haml +30 -0
- data/app/views/e9_crm/contacts/index.html.haml +1 -30
- data/app/views/e9_crm/contacts/index.js.erb +1 -1
- data/app/views/e9_crm/deals/_form_inner.html.haml +16 -8
- data/app/views/e9_crm/deals/_header.html.haml +13 -0
- data/app/views/e9_crm/deals/_leads_header.html.haml +12 -0
- data/app/views/e9_crm/deals/_leads_table.html.haml +34 -0
- data/app/views/e9_crm/deals/leads.html.haml +4 -9
- data/app/views/e9_crm/deals/leads.js.erb +1 -0
- data/app/views/e9_crm/deals/offer_form.html.haml +6 -0
- data/app/views/e9_crm/deals/reports.html.haml +1 -1
- data/app/views/e9_crm/{offers → file_download_offers}/_form.html.haml +0 -0
- data/app/views/e9_crm/file_download_offers/_form_inner.html.haml +11 -0
- data/app/views/e9_crm/leads/_form.html.haml +26 -0
- data/app/views/e9_crm/leads/create.js.erb +11 -0
- data/app/views/e9_crm/leads/new.html.haml +6 -0
- data/app/views/e9_crm/menu_options/_header.html.haml +3 -4
- data/app/views/e9_crm/new_content_subscription_offers/_form_inner.html.haml +1 -0
- data/app/views/e9_crm/newsletter_subscription_offers/_form_inner.html.haml +1 -0
- data/app/views/e9_crm/offers/_footer.html.haml +0 -0
- data/app/views/e9_crm/offers/_form_inner.html.haml +8 -22
- data/app/views/e9_crm/offers/_header.html.haml +12 -0
- data/app/views/e9_crm/offers/_offer.html.haml +4 -0
- data/app/views/e9_crm/offers/_public_offer.html.haml +6 -0
- data/app/views/e9_crm/offers/show.html.haml +2 -0
- data/app/views/e9_crm/resources/_form_inner.html.haml +0 -5
- data/app/views/e9_crm/resources/create.js.erb +3 -2
- data/app/views/e9_crm/resources/edit.html.haml +1 -1
- data/app/views/e9_crm/resources/new.html.haml +1 -1
- data/app/views/e9_crm/resources/show.html.haml +1 -1
- data/app/views/e9_crm/resources/update.js.erb +3 -1
- data/app/views/e9_crm/subscription_offers/_form_inner.html.haml +5 -0
- data/app/views/e9_crm/video_offers/_form_inner.html.haml +5 -0
- data/config/locales/e9.en.yml +3 -2
- data/config/locales/en.yml +30 -13
- data/config/routes.rb +31 -8
- data/e9_crm.gemspec +1 -1
- data/lib/e9_crm/controller.rb +94 -0
- data/lib/e9_crm/model.rb +9 -9
- data/lib/e9_crm/rails_extensions.rb +9 -0
- data/lib/e9_crm/tracking_controller.rb +48 -80
- data/lib/e9_crm/version.rb +1 -1
- data/lib/e9_crm.rb +8 -1
- data/lib/generators/e9_crm/templates/migration.rb +3 -9
- metadata +39 -9
- data/Gemfile.lock +0 -98
- data/app/models/affiliate.rb +0 -4
- data/app/models/sales_person.rb +0 -4
- data/app/views/e9_crm/contact_emails/send_email.js.erb +0 -1
- data/app/views/e9_crm/offers/_form_inner.html.haml.bak +0 -43
data/config/locales/en.yml
CHANGED
@@ -23,9 +23,9 @@ en:
|
|
23
23
|
show: '%{model}'
|
24
24
|
|
25
25
|
links:
|
26
|
-
edit: "Edit"
|
27
|
-
destroy: "Delete"
|
28
|
-
show: "View"
|
26
|
+
edit: "Edit %{model}"
|
27
|
+
destroy: "Delete %{model}"
|
28
|
+
show: "View %{model}"
|
29
29
|
index: "Manage %{models}"
|
30
30
|
|
31
31
|
campaign_group:
|
@@ -55,22 +55,32 @@ en:
|
|
55
55
|
invalid: "Status must be one of (%{options})"
|
56
56
|
|
57
57
|
models:
|
58
|
-
|
59
|
-
email_campaign: Email Campaign
|
60
|
-
email_template: Email Template
|
61
|
-
affiliate_campaign: Affiliate Campaign
|
58
|
+
address_attribute: Address
|
62
59
|
advertising_campaign: Advertising Campaign
|
60
|
+
affiliate_campaign: Affiliate Campaign
|
63
61
|
campaign: Campaign
|
64
|
-
|
62
|
+
campaign_group: Campaign Group
|
65
63
|
company: Company
|
66
64
|
contact: Contact
|
65
|
+
contact_email: Contact Email
|
66
|
+
contact_offer: Contact Offer
|
67
67
|
dated_cost: Advertising Cost
|
68
68
|
deal: Deal
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
email_campaign: Email Campaign
|
70
|
+
email_template: Email Template
|
71
|
+
file_download_offer: File Download Offer
|
72
72
|
instant_messaging_handle_attribute: IM Handle
|
73
|
+
menu_options: Menu Option
|
74
|
+
new_content_subscription_offer: New Content Subscription Offer
|
75
|
+
newsletter_subscription_offer: Newsletter Subscription Offer
|
76
|
+
no_campaign: '(No Campaign)'
|
77
|
+
offer: Offer
|
78
|
+
page_view: Page View
|
73
79
|
phone_number_attrubute: Phone
|
80
|
+
record_attribute: Attribute
|
81
|
+
sales_campaign: Sales Campaign
|
82
|
+
tracking_cookie: Tracking Cookie
|
83
|
+
video_offer: Video Offer
|
74
84
|
website_attribute: Website
|
75
85
|
attributes:
|
76
86
|
campaign:
|
@@ -86,9 +96,16 @@ en:
|
|
86
96
|
info: Background Information
|
87
97
|
company:
|
88
98
|
info: Background Information
|
89
|
-
|
90
|
-
|
99
|
+
deal:
|
100
|
+
info: Details
|
101
|
+
custom_info: Lead Information
|
102
|
+
lead_email: Email
|
103
|
+
lead_name: First Name
|
104
|
+
campaign_code: Code
|
105
|
+
offer_name: Offer
|
106
|
+
created_at: Date
|
91
107
|
offer:
|
108
|
+
template: Teaser Text
|
92
109
|
alert_email_instructions: (Enter an email if you want to be notified of conversions)
|
93
110
|
submit_button_text: Submit Button Text
|
94
111
|
success_alert_text: Success Alert Text
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
crm_path = 'admin/crm'
|
3
3
|
|
4
|
+
scope :module => :e9_crm do
|
5
|
+
resources :offers, :as => :public_offer, :only => :show do
|
6
|
+
resources :leads, :as => :deals, :only => [:new, :create], :path => ''
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
scope :path => crm_path, :module => :e9_crm do
|
5
11
|
resources :companies, :except => :show
|
6
12
|
resources :contacts do
|
@@ -13,8 +19,8 @@ Rails.application.routes.draw do
|
|
13
19
|
delete :reset_avatar
|
14
20
|
end
|
15
21
|
end
|
22
|
+
|
16
23
|
resources :deals, :except => :show
|
17
|
-
resources :offers, :except => :show
|
18
24
|
|
19
25
|
# contact_emails are generated by email templates, and end up in the sent emails list
|
20
26
|
resources :contact_emails, :except => [:index, :show]
|
@@ -38,11 +44,11 @@ Rails.application.routes.draw do
|
|
38
44
|
#get '/activity', :to => redirect("/#{crm_path}/campaigns/all/activity")
|
39
45
|
resources :campaign_groups, :path => 'groups', :except => [:show]
|
40
46
|
|
41
|
-
resources :sales_campaigns,
|
42
|
-
resources :affiliate_campaigns,
|
43
|
-
resources :email_campaigns,
|
47
|
+
resources :sales_campaigns, :path => 'sales', :except => [:show, :index]
|
48
|
+
resources :affiliate_campaigns, :path => 'affiliate', :except => [:show, :index]
|
49
|
+
resources :email_campaigns, :path => 'email', :except => [:show, :index]
|
44
50
|
resources :advertising_campaigns, :path => 'advertising', :except => [:show, :index] do
|
45
|
-
resources :dated_costs,
|
51
|
+
resources :dated_costs, :path => 'costs'
|
46
52
|
end
|
47
53
|
|
48
54
|
%w( advertising affiliate email sales ).each do |path|
|
@@ -50,9 +56,26 @@ Rails.application.routes.draw do
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
resources :offers, :only => [:index, :destroy]
|
60
|
+
scope :path => :offers do
|
61
|
+
resources :contact_offers, :path => 'contact', :except => [:show, :index]
|
62
|
+
resources :file_download_offers, :path => 'file_download', :except => [:show, :index]
|
63
|
+
resources :new_content_subscription_offers, :path => 'new_content_subscription', :except => [:show, :index]
|
64
|
+
resources :newsletter_subscription_offers, :path => 'newsletter_subscription', :except => [:show, :index]
|
65
|
+
resources :video_offers, :path => 'video', :except => [:show, :index]
|
66
|
+
|
67
|
+
%w( contact file_download new_content_subscription newsletter_subscription video ).each do |path|
|
68
|
+
get "/#{path}", :as => "#{path}_offers_redirect", :to => redirect("/#{crm_path}/offers?type=#{path}")
|
69
|
+
get "/#{path}/:id", :as => "#{path}_offers_edit_redirect", :to => redirect("/#{crm_path}/#{path}/%{id}/edit"), :constraints => { :id => /\d+/ }
|
70
|
+
end
|
71
|
+
|
72
|
+
%w( contact file_download new_content_subscription newsletter_subscription video ).each do |path|
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# leads are simply a scoped view of deals (only index)
|
77
|
+
get :leads, :as => :leads, :to => 'deals#leads'
|
78
|
+
get :marketing_report, :to => 'deals#reports'
|
56
79
|
|
57
80
|
get '/merge_contacts/:contact_a_id/and/:contact_b_id', :as => :new_contact_merge, :to => 'contact_merges#new'
|
58
81
|
post '/merge_contacts', :as => :contact_merges, :to => 'contact_merges#create'
|
data/e9_crm.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency("inherited_resources", "~> 1.1.2")
|
24
24
|
s.add_dependency("has_scope")
|
25
25
|
s.add_dependency("money")
|
26
|
-
s.add_dependency("e9_rails", "~> 0.0.
|
26
|
+
s.add_dependency("e9_rails", "~> 0.0.15")
|
27
27
|
s.add_dependency("e9_tags", "~> 0.0.11")
|
28
28
|
s.add_dependency("will_paginate")
|
29
29
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module E9Crm
|
2
|
+
#
|
3
|
+
# This module is included into all controllers and makes available the current +tracking_cookie+
|
4
|
+
# and +tracking_campaign+ as controller and helper methods
|
5
|
+
#
|
6
|
+
module Controller
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
helper_method :tracking_cookie, :tracking_campaign
|
11
|
+
|
12
|
+
prepend_before_filter do
|
13
|
+
E9Crm.log("E9Crm controller request")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
#
|
20
|
+
# Attempts to get the Campaign associated with the loaded tracking cookie, and will
|
21
|
+
# install a tracking cookie first if one is not found.
|
22
|
+
#
|
23
|
+
# Falls back the the default campaign (typically No Campaign) if the tracking cookie
|
24
|
+
# is not associated with a campaign.
|
25
|
+
#
|
26
|
+
def tracking_campaign
|
27
|
+
@_tracking_campaign ||= begin
|
28
|
+
tracking_cookie.code.present? && Campaign.find_by_code(tracking_cookie.code) || Campaign.default
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Loads or installs the tracking cookie
|
34
|
+
#
|
35
|
+
def tracking_cookie
|
36
|
+
@_tracking_cookie ||= begin
|
37
|
+
E9Crm.log "Begin load or install cookie: cookie_name[#{E9Crm.cookie_name}] query_param[#{E9Crm.query_param}]"
|
38
|
+
|
39
|
+
code = params.delete(E9Crm.query_param)
|
40
|
+
|
41
|
+
if hid = cookies[E9Crm.cookie_name]
|
42
|
+
E9Crm.log("Installed cookie found: hid(#{hid})")
|
43
|
+
@_tracking_cookie = TrackingCookie.find_by_hid(hid)
|
44
|
+
|
45
|
+
unless @_tracking_cookie
|
46
|
+
# This should only happen in developemnt, as it means the cookie has been
|
47
|
+
# installed then removed from the database.
|
48
|
+
E9Crm.log("Installed cookie's hash id does not match any stored cookies!")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
E9Crm.log(@_tracking_cookie ? "Cookie loaded: (#{E9Crm.cookie_name} : #{@_tracking_cookie.hid})" : "Cookie not found")
|
53
|
+
|
54
|
+
if @_tracking_cookie
|
55
|
+
if current_user && @_tracking_cookie.user_id? && @_tracking_cookie.user_id != current_user.id
|
56
|
+
E9Crm.log "Tracking user_id not matched: found(#{@_tracking_cookie.user_id}), current(#{current_user.id}"
|
57
|
+
@_tracking_cookie = nil
|
58
|
+
else
|
59
|
+
attrs = {}
|
60
|
+
|
61
|
+
if current_user && !@_tracking_cookie.user_id?
|
62
|
+
E9Crm.log("Cookie user (#{@_tracking_cookie.user_id}) not current_user (#{current_user.id}), changing...")
|
63
|
+
attrs[:user] = current_user
|
64
|
+
end
|
65
|
+
|
66
|
+
if code.present? && code != @_tracking_cookie.code && Campaign.find_by_code(code)
|
67
|
+
E9Crm.log "Code present and cookie code(#{@_tracking_cookie.code}) does not match (#{code}), changing..."
|
68
|
+
attrs[:code] = code
|
69
|
+
|
70
|
+
E9Crm.log "Cookie marked as new"
|
71
|
+
session[:new_visit] = true
|
72
|
+
end
|
73
|
+
|
74
|
+
E9Crm.log(attrs.blank? ? "Cookie unchanged, no update" : "Cookie changed, new attrs: #{attrs.inspect}")
|
75
|
+
@_tracking_cookie.update_attributes(attrs) unless attrs.blank?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
@_tracking_cookie ||= begin
|
80
|
+
session[:new_visit] = true
|
81
|
+
|
82
|
+
TrackingCookie.create(:code => code, :user => current_user).tap do |cookie|
|
83
|
+
E9Crm.log "Installing new cookie (#{E9Crm.cookie_name} : #{cookie.hid})"
|
84
|
+
cookies.permanent[E9Crm.cookie_name] = cookie.hid
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
E9Crm.log("Final Cookie : #{@_tracking_cookie.inspect}")
|
89
|
+
|
90
|
+
@_tracking_cookie
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/e9_crm/model.rb
CHANGED
@@ -23,7 +23,7 @@ module E9Crm
|
|
23
23
|
|
24
24
|
scope :primary, lambda { where(%Q{#{table_name}.options REGEXP "primary: [\\"']?true"}) }
|
25
25
|
|
26
|
-
|
26
|
+
before_save :create_contact_if_missing!
|
27
27
|
after_destroy :cleanup_contact
|
28
28
|
end
|
29
29
|
|
@@ -34,20 +34,20 @@ module E9Crm
|
|
34
34
|
["true", true].member? options.primary
|
35
35
|
end
|
36
36
|
|
37
|
+
def create_contact_if_missing!
|
38
|
+
if contact.blank?
|
39
|
+
# when creating a contact we should assume we're primary
|
40
|
+
self.options.primary = true
|
41
|
+
create_contact(create_contact_parameters)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
37
45
|
protected
|
38
46
|
|
39
47
|
def create_contact_parameters
|
40
48
|
{ :first_name => self.first_name, :last_name => self.last_name }
|
41
49
|
end
|
42
50
|
|
43
|
-
def create_contact_if_missing
|
44
|
-
if contact.blank?
|
45
|
-
# when creating a contact we should assume we're primary
|
46
|
-
self.options.primary = true
|
47
|
-
create_contact(create_contact_parameters)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
51
|
def cleanup_contact
|
52
52
|
# NOTE this is called after_delete, reload the contact to clear the deleted
|
53
53
|
# user from the contact's #users
|
@@ -2,6 +2,14 @@ require 'active_record/base'
|
|
2
2
|
require 'action_view/base'
|
3
3
|
|
4
4
|
class Array
|
5
|
+
#
|
6
|
+
# Simple helper for array calculating averages
|
7
|
+
#
|
8
|
+
# Returns 0 if all array elements do not exist and respond to to_f
|
9
|
+
#
|
10
|
+
# NOTE nil responds to to_f but not to +, which would throw an
|
11
|
+
# exception on sum if nil was allowed in the array
|
12
|
+
#
|
5
13
|
def average
|
6
14
|
return 0 unless length > 0 && all? {|n| n && n.respond_to?(:to_f) }
|
7
15
|
sum / length
|
@@ -81,6 +89,7 @@ module E9Crm
|
|
81
89
|
# This would be worth looking into further but inherited templates are a feature coming
|
82
90
|
# up in Rails anyway.
|
83
91
|
#
|
92
|
+
|
84
93
|
module ActionView
|
85
94
|
extend ActiveSupport::Concern
|
86
95
|
|
@@ -5,91 +5,59 @@ module E9Crm
|
|
5
5
|
included do
|
6
6
|
before_filter :check_for_new_session
|
7
7
|
after_filter :track_page_view
|
8
|
-
end
|
9
|
-
|
10
|
-
protected
|
11
|
-
def check_for_new_session
|
12
|
-
if request.session_options[:id].blank?
|
13
|
-
E9Crm.log("No session found, page view will increment campaign counter cache")
|
14
|
-
@_should_cache = true
|
15
|
-
end
|
16
|
-
end
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
:request_path => request.fullpath,
|
21
|
-
:user_agent => request.user_agent,
|
22
|
-
:referer => request.referer,
|
23
|
-
:remote_ip => request.remote_ip,
|
24
|
-
:session => request.session_options[:id],
|
25
|
-
:campaign => tracking_campaign,
|
26
|
-
:new_visit => session[:new_visit].present?,
|
27
|
-
:should_cache => !!@_should_cache
|
28
|
-
})
|
9
|
+
prepend_before_filter do
|
10
|
+
E9Crm.log("E9Crm tracking controller request")
|
29
11
|
end
|
12
|
+
end
|
30
13
|
|
31
|
-
|
32
|
-
@_tracking_cookie ||= begin
|
33
|
-
E9Crm.log "Begin load or install cookie: cookie_name[#{E9Crm.cookie_name}] query_param[#{E9Crm.query_param}]"
|
34
|
-
|
35
|
-
code = params.delete(E9Crm.query_param)
|
36
|
-
|
37
|
-
if hid = cookies[E9Crm.cookie_name]
|
38
|
-
E9Crm.log("Installed cookie found: hid(#{hid})")
|
39
|
-
@_tracking_cookie = TrackingCookie.find_by_hid(hid)
|
40
|
-
|
41
|
-
unless @_tracking_cookie
|
42
|
-
# This should only happen in developemnt, as it means the cookie has been
|
43
|
-
# installed then removed from the database.
|
44
|
-
E9Crm.log("Installed cookie's hash id does not match any stored cookies!")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
E9Crm.log(@_tracking_cookie ? "Cookie loaded: (#{E9Crm.cookie_name} : #{@_tracking_cookie.hid})" : "Cookie not found")
|
49
|
-
|
50
|
-
if @_tracking_cookie
|
51
|
-
if current_user && @_tracking_cookie.user_id? && @_tracking_cookie.user_id != current_user.id
|
52
|
-
E9Crm.log "Tracking user_id not matched: found(#{@_tracking_cookie.user_id}), current(#{current_user.id}"
|
53
|
-
@_tracking_cookie = nil
|
54
|
-
else
|
55
|
-
attrs = {}
|
56
|
-
|
57
|
-
if current_user && !@_tracking_cookie.user_id?
|
58
|
-
E9Crm.log("Cookie user (#{@_tracking_cookie.user_id}) not current_user (#{current_user.id}), changing...")
|
59
|
-
attrs[:user] = current_user
|
60
|
-
end
|
61
|
-
|
62
|
-
if code.present? && code != @_tracking_cookie.code && Campaign.find_by_code(code)
|
63
|
-
E9Crm.log "Code present and cookie code(#{@_tracking_cookie.code}) does not match (#{code}), changing..."
|
64
|
-
attrs[:code] = code
|
65
|
-
|
66
|
-
E9Crm.log "Cookie marked as new"
|
67
|
-
session[:new_visit] = true
|
68
|
-
end
|
69
|
-
|
70
|
-
E9Crm.log(attrs.blank? ? "Cookie unchanged, no update" : "Cookie changed, new attrs: #{attrs.inspect}")
|
71
|
-
@_tracking_cookie.update_attributes(attrs) unless attrs.blank?
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
@_tracking_cookie ||= begin
|
76
|
-
session[:new_visit] = true
|
77
|
-
|
78
|
-
TrackingCookie.create(:code => code, :user => current_user).tap do |cookie|
|
79
|
-
E9Crm.log "Installing new cookie (#{E9Crm.cookie_name} : #{cookie.hid})"
|
80
|
-
cookies.permanent[E9Crm.cookie_name] = cookie.hid
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
E9Crm.log("Final Cookie : #{@_tracking_cookie.inspect}")
|
85
|
-
|
86
|
-
@_tracking_cookie
|
87
|
-
end
|
88
|
-
end
|
14
|
+
protected
|
89
15
|
|
90
|
-
|
91
|
-
|
16
|
+
#
|
17
|
+
# Checks to see if our session is new (a first request). During such a call
|
18
|
+
# the session id has not been set yet.
|
19
|
+
#
|
20
|
+
# This is useful when determining whether or not the page view (created afterwards)
|
21
|
+
# should increment the counter cache for its associated Campaign, as this should
|
22
|
+
# only happen once per session.
|
23
|
+
#
|
24
|
+
def check_for_new_session
|
25
|
+
if request.session_options[:id].blank?
|
26
|
+
E9Crm.log("No session found, page view will increment campaign counter cache")
|
27
|
+
@_should_cache = true
|
92
28
|
end
|
29
|
+
end
|
93
30
|
|
31
|
+
#
|
32
|
+
# Track a page view and associate it with the loaded cookie.
|
33
|
+
#
|
34
|
+
# === Notable paramters
|
35
|
+
#
|
36
|
+
# [:new_visit] This is stored in the session during tracking cookie creation
|
37
|
+
# if the tracking cookie is either new, or changing campaigns
|
38
|
+
# because a user is visiting on a different code.
|
39
|
+
#
|
40
|
+
# [:campaign] The campaign associated with the tracking cookie or the default
|
41
|
+
# campaign (typically the NoCampaign record)
|
42
|
+
#
|
43
|
+
# [:should_cache] Whether or not this page view should increment the page view
|
44
|
+
# count for it's associated page. This should only happen once
|
45
|
+
# per session and for this reason, is only true on sessionless
|
46
|
+
# (new) requests. This is determined by looking for a session id
|
47
|
+
# during the before filter, as in the after filter the session id
|
48
|
+
# has been assigned.
|
49
|
+
#
|
50
|
+
def track_page_view
|
51
|
+
@_page_view ||= tracking_cookie.page_views.create({
|
52
|
+
:request_path => request.fullpath,
|
53
|
+
:user_agent => request.user_agent,
|
54
|
+
:referer => request.referer,
|
55
|
+
:remote_ip => request.remote_ip,
|
56
|
+
:session => request.session_options[:id],
|
57
|
+
:campaign => tracking_campaign,
|
58
|
+
:new_visit => session[:new_visit].present?,
|
59
|
+
:should_cache => !!@_should_cache
|
60
|
+
})
|
61
|
+
end
|
94
62
|
end
|
95
63
|
end
|
data/lib/e9_crm/version.rb
CHANGED
data/lib/e9_crm.rb
CHANGED
@@ -10,8 +10,9 @@ require 'e9_crm/rails_extensions'
|
|
10
10
|
|
11
11
|
module E9Crm
|
12
12
|
autoload :VERSION, 'e9_crm/version'
|
13
|
-
autoload :
|
13
|
+
autoload :Controller, 'e9_crm/controller'
|
14
14
|
autoload :Model, 'e9_crm/model'
|
15
|
+
autoload :TrackingController, 'e9_crm/tracking_controller'
|
15
16
|
|
16
17
|
mattr_accessor :cookie_name
|
17
18
|
@@cookie_name = '_e9_tc'
|
@@ -35,6 +36,10 @@ module E9Crm
|
|
35
36
|
Rails.logger.send(@@log_level, "e9Crm: #{message}") if @@logging
|
36
37
|
end
|
37
38
|
|
39
|
+
def E9Crm.configure
|
40
|
+
yield self
|
41
|
+
end
|
42
|
+
|
38
43
|
def E9Crm.init!
|
39
44
|
user_model = case @@user_model
|
40
45
|
when Class; @@user_model
|
@@ -45,6 +50,8 @@ module E9Crm
|
|
45
50
|
user_model.send(:include, E9Crm::Model)
|
46
51
|
end
|
47
52
|
|
53
|
+
ActionController::Base.send(:include, E9Crm::Controller)
|
54
|
+
|
48
55
|
E9Crm.tracking_controllers.each do |controller|
|
49
56
|
controller.send(:include, E9Crm::TrackingController)
|
50
57
|
end
|
@@ -75,9 +75,10 @@ class CreateE9CrmStructure < ActiveRecord::Migration
|
|
75
75
|
create_table :deals, :force => true do |t|
|
76
76
|
t.string :type
|
77
77
|
t.string :name
|
78
|
-
t.string :
|
78
|
+
t.string :lead_name, :lead_email
|
79
|
+
t.string :category, :offer_name, :campaign_code
|
79
80
|
t.text :info
|
80
|
-
t.references :offer, :campaign, :
|
81
|
+
t.references :offer, :campaign, :contact, :user
|
81
82
|
t.timestamp :created_at, :updated_at, :converted_at, :closed_at
|
82
83
|
t.string :status, :limit => 32
|
83
84
|
t.integer :value, :default => 0
|
@@ -87,13 +88,6 @@ class CreateE9CrmStructure < ActiveRecord::Migration
|
|
87
88
|
add_index 'deals', 'tracking_cookie_id'
|
88
89
|
add_index 'deals', 'status'
|
89
90
|
|
90
|
-
create_table :offers, :force => true do |t|
|
91
|
-
t.string :type
|
92
|
-
t.references :offer, :campaign, :tracking_cookie
|
93
|
-
t.timestamp :created_at, :updated_at, :converted_at, :closed_at
|
94
|
-
t.string :status, :limit => 32
|
95
|
-
end
|
96
|
-
|
97
91
|
add_column :users, :contact_id, :integer rescue nil
|
98
92
|
add_column :users, :options, :text, :limit => 1.kilobyte rescue nil
|
99
93
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: e9_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Cox
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-25 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
68
|
+
version: 0.0.15
|
69
69
|
type: :runtime
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
@@ -133,7 +133,6 @@ extra_rdoc_files: []
|
|
133
133
|
files:
|
134
134
|
- .gitignore
|
135
135
|
- Gemfile
|
136
|
-
- Gemfile.lock
|
137
136
|
- README.md
|
138
137
|
- Rakefile
|
139
138
|
- app/controllers/e9_crm/advertising_campaigns_controller.rb
|
@@ -145,16 +144,23 @@ files:
|
|
145
144
|
- app/controllers/e9_crm/companies_controller.rb
|
146
145
|
- app/controllers/e9_crm/contact_emails_controller.rb
|
147
146
|
- app/controllers/e9_crm/contact_merges_controller.rb
|
147
|
+
- app/controllers/e9_crm/contact_offers_controller.rb
|
148
148
|
- app/controllers/e9_crm/contacts_controller.rb
|
149
149
|
- app/controllers/e9_crm/dated_costs_controller.rb
|
150
150
|
- app/controllers/e9_crm/deals_controller.rb
|
151
151
|
- app/controllers/e9_crm/email_campaigns_controller.rb
|
152
152
|
- app/controllers/e9_crm/email_templates.controller.rb
|
153
|
+
- app/controllers/e9_crm/file_download_offers_controller.rb
|
154
|
+
- app/controllers/e9_crm/leads_controller.rb
|
153
155
|
- app/controllers/e9_crm/menu_options_controller.rb
|
156
|
+
- app/controllers/e9_crm/new_content_subscription_offers_controller.rb
|
157
|
+
- app/controllers/e9_crm/newsletter_subscription_offers_controller.rb
|
158
|
+
- app/controllers/e9_crm/offer_subclass_controller.rb
|
154
159
|
- app/controllers/e9_crm/offers_controller.rb
|
155
160
|
- app/controllers/e9_crm/page_views_controller.rb
|
156
161
|
- app/controllers/e9_crm/resources_controller.rb
|
157
162
|
- app/controllers/e9_crm/sales_campaigns_controller.rb
|
163
|
+
- app/controllers/e9_crm/video_offers_controller.rb
|
158
164
|
- app/helpers/e9_crm/base_helper.rb
|
159
165
|
- app/helpers/e9_crm/campaign_groups_helper.rb
|
160
166
|
- app/helpers/e9_crm/campaigns_helper.rb
|
@@ -163,31 +169,37 @@ files:
|
|
163
169
|
- app/helpers/e9_crm/contacts_helper.rb
|
164
170
|
- app/helpers/e9_crm/deals_helper.rb
|
165
171
|
- app/helpers/e9_crm/email_templates_helper.rb
|
172
|
+
- app/helpers/e9_crm/leads_helper.rb
|
166
173
|
- app/helpers/e9_crm/menu_options_helper.rb
|
174
|
+
- app/helpers/e9_crm/offers_helper.rb
|
167
175
|
- app/helpers/e9_crm/page_views_helper.rb
|
168
176
|
- app/models/address_attribute.rb
|
169
177
|
- app/models/advertising_campaign.rb
|
170
|
-
- app/models/affiliate.rb
|
171
178
|
- app/models/affiliate_campaign.rb
|
172
179
|
- app/models/campaign.rb
|
173
180
|
- app/models/campaign_group.rb
|
174
181
|
- app/models/company.rb
|
175
182
|
- app/models/contact.rb
|
176
183
|
- app/models/contact_email.rb
|
184
|
+
- app/models/contact_offer.rb
|
177
185
|
- app/models/dated_cost.rb
|
178
186
|
- app/models/deal.rb
|
179
187
|
- app/models/email_campaign.rb
|
180
188
|
- app/models/email_template.rb
|
189
|
+
- app/models/file_download_offer.rb
|
181
190
|
- app/models/instant_messaging_handle_attribute.rb
|
182
191
|
- app/models/menu_option.rb
|
192
|
+
- app/models/new_content_subscription_offer.rb
|
193
|
+
- app/models/newsletter_subscription_offer.rb
|
183
194
|
- app/models/no_campaign.rb
|
184
195
|
- app/models/offer.rb
|
185
196
|
- app/models/page_view.rb
|
186
197
|
- app/models/phone_number_attribute.rb
|
187
198
|
- app/models/record_attribute.rb
|
188
199
|
- app/models/sales_campaign.rb
|
189
|
-
- app/models/
|
200
|
+
- app/models/subscription_offer.rb
|
190
201
|
- app/models/tracking_cookie.rb
|
202
|
+
- app/models/video_offer.rb
|
191
203
|
- app/models/website_attribute.rb
|
192
204
|
- app/observers/deal_observer.rb
|
193
205
|
- app/uploaders/file_uploader.rb
|
@@ -206,14 +218,15 @@ files:
|
|
206
218
|
- app/views/e9_crm/contact_emails/_form.html.haml
|
207
219
|
- app/views/e9_crm/contact_emails/_form_inner.html.haml
|
208
220
|
- app/views/e9_crm/contact_emails/destroy.js.erb
|
209
|
-
- app/views/e9_crm/contact_emails/send_email.js.erb
|
210
221
|
- app/views/e9_crm/contact_merges/_field.html.haml
|
211
222
|
- app/views/e9_crm/contact_merges/_form.html.haml
|
212
223
|
- app/views/e9_crm/contact_merges/new.html.haml
|
224
|
+
- app/views/e9_crm/contact_offers/_form_inner.html.haml
|
213
225
|
- app/views/e9_crm/contacts/_contact.html.haml
|
214
226
|
- app/views/e9_crm/contacts/_details.html.haml
|
215
227
|
- app/views/e9_crm/contacts/_form_inner.html.haml
|
216
228
|
- app/views/e9_crm/contacts/_header.html.haml
|
229
|
+
- app/views/e9_crm/contacts/_index_sidebar.html.haml
|
217
230
|
- app/views/e9_crm/contacts/_sidebar.html.haml
|
218
231
|
- app/views/e9_crm/contacts/_table.html.haml
|
219
232
|
- app/views/e9_crm/contacts/_tag_table.html.haml
|
@@ -237,20 +250,34 @@ files:
|
|
237
250
|
- app/views/e9_crm/deals/_footer.html.haml
|
238
251
|
- app/views/e9_crm/deals/_form_inner.html.haml
|
239
252
|
- app/views/e9_crm/deals/_header.html.haml
|
253
|
+
- app/views/e9_crm/deals/_leads_header.html.haml
|
254
|
+
- app/views/e9_crm/deals/_leads_table.html.haml
|
240
255
|
- app/views/e9_crm/deals/_reports_table.html.haml
|
241
256
|
- app/views/e9_crm/deals/_table.html.haml
|
242
257
|
- app/views/e9_crm/deals/leads.html.haml
|
258
|
+
- app/views/e9_crm/deals/leads.js.erb
|
259
|
+
- app/views/e9_crm/deals/offer_form.html.haml
|
243
260
|
- app/views/e9_crm/deals/reports.html.haml
|
244
261
|
- app/views/e9_crm/deals/reports.js.erb
|
245
262
|
- app/views/e9_crm/email_campaigns/_form_inner.html.haml
|
246
263
|
- app/views/e9_crm/email_templates/_footer.html.haml
|
247
264
|
- app/views/e9_crm/email_templates/_form_inner.html.haml
|
248
265
|
- app/views/e9_crm/email_templates/_header.html.haml
|
266
|
+
- app/views/e9_crm/file_download_offers/_form.html.haml
|
267
|
+
- app/views/e9_crm/file_download_offers/_form_inner.html.haml
|
268
|
+
- app/views/e9_crm/leads/_form.html.haml
|
269
|
+
- app/views/e9_crm/leads/create.js.erb
|
270
|
+
- app/views/e9_crm/leads/new.html.haml
|
249
271
|
- app/views/e9_crm/menu_options/_form_inner.html.haml
|
250
272
|
- app/views/e9_crm/menu_options/_header.html.haml
|
251
|
-
- app/views/e9_crm/
|
273
|
+
- app/views/e9_crm/new_content_subscription_offers/_form_inner.html.haml
|
274
|
+
- app/views/e9_crm/newsletter_subscription_offers/_form_inner.html.haml
|
275
|
+
- app/views/e9_crm/offers/_footer.html.haml
|
252
276
|
- app/views/e9_crm/offers/_form_inner.html.haml
|
253
|
-
- app/views/e9_crm/offers/
|
277
|
+
- app/views/e9_crm/offers/_header.html.haml
|
278
|
+
- app/views/e9_crm/offers/_offer.html.haml
|
279
|
+
- app/views/e9_crm/offers/_public_offer.html.haml
|
280
|
+
- app/views/e9_crm/offers/show.html.haml
|
254
281
|
- app/views/e9_crm/page_views/_table.html.haml
|
255
282
|
- app/views/e9_crm/record_attributes/_address_attribute.html.haml
|
256
283
|
- app/views/e9_crm/record_attributes/_form_partial.html.haml
|
@@ -274,12 +301,15 @@ files:
|
|
274
301
|
- app/views/e9_crm/resources/show.html.haml
|
275
302
|
- app/views/e9_crm/resources/update.js.erb
|
276
303
|
- app/views/e9_crm/sales_campaigns/_form_inner.html.haml
|
304
|
+
- app/views/e9_crm/subscription_offers/_form_inner.html.haml
|
305
|
+
- app/views/e9_crm/video_offers/_form_inner.html.haml
|
277
306
|
- config/initializers/inflections.rb
|
278
307
|
- config/locales/e9.en.yml
|
279
308
|
- config/locales/en.yml
|
280
309
|
- config/routes.rb
|
281
310
|
- e9_crm.gemspec
|
282
311
|
- lib/e9_crm.rb
|
312
|
+
- lib/e9_crm/controller.rb
|
283
313
|
- lib/e9_crm/model.rb
|
284
314
|
- lib/e9_crm/rails_extensions.rb
|
285
315
|
- lib/e9_crm/tracking_controller.rb
|