e9_crm 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/e9_crm/advertising_campaigns_controller.rb +1 -0
- data/app/controllers/e9_crm/affiliate_campaigns_controller.rb +1 -0
- data/app/controllers/e9_crm/campaign_groups_controller.rb +8 -0
- data/app/controllers/e9_crm/campaigns_controller.rb +38 -1
- data/app/controllers/e9_crm/companies_controller.rb +1 -0
- data/app/controllers/e9_crm/contact_emails_controller.rb +3 -7
- data/app/controllers/e9_crm/contacts_controller.rb +6 -4
- data/app/controllers/e9_crm/dated_costs_controller.rb +1 -0
- data/app/controllers/e9_crm/deals_controller.rb +66 -2
- data/app/controllers/e9_crm/email_campaigns_controller.rb +1 -0
- data/app/controllers/e9_crm/email_templates.controller.rb +1 -0
- data/app/controllers/e9_crm/offers_controller.rb +1 -0
- data/app/controllers/e9_crm/page_views_controller.rb +1 -0
- data/app/controllers/e9_crm/resources_controller.rb +2 -1
- data/app/controllers/e9_crm/sales_campaigns_controller.rb +1 -0
- data/app/helpers/e9_crm/campaign_groups_helper.rb +8 -0
- data/app/helpers/e9_crm/campaigns_helper.rb +42 -11
- data/app/helpers/e9_crm/contacts_helper.rb +1 -1
- data/app/helpers/e9_crm/deals_helper.rb +25 -0
- data/app/models/advertising_campaign.rb +0 -1
- data/app/models/campaign.rb +40 -8
- data/app/models/campaign_group.rb +6 -0
- data/app/models/contact.rb +22 -0
- data/app/models/contact_email.rb +29 -18
- data/app/models/deal.rb +93 -14
- data/app/models/no_campaign.rb +5 -0
- data/app/models/page_view.rb +13 -44
- data/app/models/tracking_cookie.rb +0 -6
- data/app/observers/deal_observer.rb +3 -0
- data/app/views/e9_crm/advertising_campaigns/_form_inner.html.haml +1 -0
- data/app/views/e9_crm/affiliate_campaigns/_form_inner.html.haml +10 -0
- data/app/views/e9_crm/campaign_groups/_footer.html.haml +0 -0
- data/app/views/e9_crm/campaign_groups/_header.html.haml +3 -0
- data/app/views/e9_crm/campaigns/_footer.html.haml +0 -0
- data/app/views/e9_crm/campaigns/_form_inner.html.haml +20 -4
- data/app/views/e9_crm/campaigns/_header.html.haml +16 -0
- data/app/views/e9_crm/campaigns/_reports_table.html.haml +31 -0
- data/app/views/e9_crm/campaigns/_table.html.haml +31 -0
- data/app/views/e9_crm/campaigns/reports.html.haml +13 -0
- data/app/views/e9_crm/contact_emails/_form_inner.html.haml +1 -1
- data/app/views/e9_crm/contacts/_header.html.haml +5 -4
- data/app/views/e9_crm/deals/_reports_table.html.haml +86 -0
- data/app/views/e9_crm/deals/reports.html.haml +19 -0
- data/app/views/e9_crm/deals/reports.js.erb +1 -0
- data/app/views/e9_crm/email_campaigns/_form_inner.html.haml +1 -0
- data/app/views/e9_crm/page_views/_table.html.haml +7 -7
- data/app/views/e9_crm/resources/_table.html.haml +1 -1
- data/app/views/e9_crm/sales_campaigns/_form_inner.html.haml +11 -0
- data/config/locales/e9.en.yml +11 -1
- data/config/locales/en.yml +16 -5
- data/config/routes.rb +15 -12
- data/e9_crm.gemspec +1 -1
- data/lib/e9_crm/rails_extensions.rb +7 -0
- data/lib/e9_crm/tracking_controller.rb +69 -52
- data/lib/e9_crm/version.rb +1 -1
- data/lib/generators/e9_crm/install_generator.rb +1 -1
- data/lib/generators/e9_crm/templates/{create_e9_crm_tables.rb → migration.rb} +6 -7
- metadata +20 -6
- data/app/controllers/e9_crm/record_attributes_controller.rb +0 -3
- data/app/controllers/e9_crm/reports_controller.rb +0 -2
@@ -0,0 +1,31 @@
|
|
1
|
+
%table.records
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th= orderable_column_link(:type)
|
5
|
+
%th= orderable_column_link(:name)
|
6
|
+
%th= orderable_column_link('campaign_group.name', :campaign_group)
|
7
|
+
%th= orderable_column_link(:new_visits)
|
8
|
+
%th= orderable_column_link(:repeat_visits)
|
9
|
+
%th= orderable_column_link(:deals_count)
|
10
|
+
%th= orderable_column_link(:won_deals_count)
|
11
|
+
%tbody
|
12
|
+
- if collection.empty?
|
13
|
+
%tr
|
14
|
+
%td{:colspan => 5}= e9_t(:no_records_text)
|
15
|
+
- else
|
16
|
+
- collection.each do |record|
|
17
|
+
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
18
|
+
%td.record-type
|
19
|
+
= record.type[/(.*)Campaign/, 1]
|
20
|
+
%td.record-name
|
21
|
+
= record.name
|
22
|
+
%td.record-campaign-group
|
23
|
+
= record.campaign_group || e9_t(:no_group, :scope => 'e9_crm.campaigns')
|
24
|
+
%td.record-new-visits
|
25
|
+
= record.new_visits
|
26
|
+
%td.record-repeat-visits
|
27
|
+
= record.repeat_visits
|
28
|
+
%td.record-deals-count
|
29
|
+
= record.deals_count
|
30
|
+
%td.record-won-deals-count
|
31
|
+
= record.won_deals_count
|
@@ -0,0 +1,31 @@
|
|
1
|
+
%table.records
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th= orderable_column_link(:type)
|
5
|
+
%th= orderable_column_link(:name)
|
6
|
+
%th= orderable_column_link('campaign_group.name', :campaign_group)
|
7
|
+
%th= orderable_column_link(:code)
|
8
|
+
%th= orderable_column_link(:affiliate_fee)
|
9
|
+
%th= orderable_column_link(:sales_fee)
|
10
|
+
%th= e9_t(:actions)
|
11
|
+
%tbody
|
12
|
+
- if collection.empty?
|
13
|
+
%tr
|
14
|
+
%td{:colspan => 7}= e9_t(:no_records_text)
|
15
|
+
- else
|
16
|
+
- collection.each do |record|
|
17
|
+
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
18
|
+
%td.record-type
|
19
|
+
= record.type[/(.*)Campaign/, 1]
|
20
|
+
%td.record-name
|
21
|
+
= record.name
|
22
|
+
%td.record-campaign-group
|
23
|
+
= record.campaign_group || e9_t(:no_group, :scope => 'e9_crm.campaigns')
|
24
|
+
%td.record-code
|
25
|
+
= display_campaign_code(record.code)
|
26
|
+
%td.record-affiliate-fee
|
27
|
+
= display_campaign_fee(record.affiliate_fee)
|
28
|
+
%td.record-sales-fee
|
29
|
+
= display_campaign_fee(record.sales_fee)
|
30
|
+
%td.links
|
31
|
+
= link_to_edit_campaign(record)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
= title (@index_title || e9_t(:reports_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
|
9
|
+
- else
|
10
|
+
%div#records_table
|
11
|
+
= render 'table', :resources => collection
|
12
|
+
|
13
|
+
= render 'footer'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
- contact_ids = collection.map(&:id)
|
1
2
|
.toolbar
|
2
3
|
.toolbar-left
|
3
4
|
= form_tag(resource_class, :method => :get, :id => 'contact_search_form') do
|
@@ -6,13 +7,13 @@
|
|
6
7
|
= submit_tag t(:go), :name => nil
|
7
8
|
= submit_tag t(:clear), :name => nil, :id => 'contact_search_clear'
|
8
9
|
.toolbar-middle
|
9
|
-
= form_tag new_contact_email_path, :method => :get, :id => 'contact_email_form', 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @
|
10
|
+
= form_tag new_contact_email_path, :method => :get, :id => 'contact_email_form', 'data-empty' => e9_t(:no_contacts_notification), 'data-count' => @contact_ids.length do
|
10
11
|
= select_tag 'etid', contact_email_template_select_options
|
11
|
-
= hidden_field_tag 'uids', @
|
12
|
+
= hidden_field_tag 'uids', @contact_ids.join(','), :id => 'contact_email_uids'
|
12
13
|
= 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' => @
|
14
|
+
= 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' => @contact_ids.length do
|
14
15
|
= select_tag 'eid', contact_newsletter_select_options
|
15
|
-
= hidden_field_tag 'uids', @
|
16
|
+
= hidden_field_tag 'uids', @contact_ids.join(','), :id => 'contact_newsletter_uids'
|
16
17
|
= submit_tag e9_t(:send_email_newsletter), :name => nil
|
17
18
|
.toolbar-right
|
18
19
|
= link_to_new_resource(Contact)
|
@@ -0,0 +1,86 @@
|
|
1
|
+
%table.records
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th= orderable_column_link(:campaign_type)
|
5
|
+
%th= orderable_column_link(:campaign_name)
|
6
|
+
%th= orderable_column_link(:campaign_group)
|
7
|
+
%th= orderable_column_link(:new_visits)
|
8
|
+
%th= orderable_column_link(:repeat_visits)
|
9
|
+
%th= orderable_column_link(:lead_count)
|
10
|
+
%th= orderable_column_link(:deal_count)
|
11
|
+
%th= orderable_column_link(:won_deal_count)
|
12
|
+
%th= orderable_column_link(:total_value)
|
13
|
+
%th= orderable_column_link(:average_value)
|
14
|
+
%th= orderable_column_link(:total_cost)
|
15
|
+
%th= orderable_column_link(:average_cost)
|
16
|
+
%th= orderable_column_link(:average_elapsed)
|
17
|
+
%tbody
|
18
|
+
-# prepare a hash to store the accumulated row data for calculations
|
19
|
+
- dat = Hash.new {|k,v| k[v] = [] }
|
20
|
+
|
21
|
+
- if collection.empty?
|
22
|
+
%tr
|
23
|
+
%td{:colspan => 13}= e9_t(:no_records_text, :scope => 'e9_crm.reports')
|
24
|
+
- else
|
25
|
+
- collection.each do |record|
|
26
|
+
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
27
|
+
%td.record-campaign-type
|
28
|
+
= record.campaign_type[/(.*)Campaign/, 1]
|
29
|
+
%td.record-campaign-name
|
30
|
+
= record.campaign_name
|
31
|
+
%td.record-campaign-group
|
32
|
+
= record.campaign_group
|
33
|
+
%td.record-new-visits
|
34
|
+
- dat[:new_visits] << record.new_visits
|
35
|
+
= record.new_visits
|
36
|
+
%td.record-repeat-visits
|
37
|
+
- dat[:repeat_visits] << record.repeat_visits
|
38
|
+
= record.repeat_visits
|
39
|
+
%td.record-lead-count
|
40
|
+
- dat[:lead_count] << record.lead_count
|
41
|
+
= record.lead_count.to_i
|
42
|
+
%td.record-deal-count
|
43
|
+
- dat[:deal_count] << record.deal_count
|
44
|
+
= record.deal_count.to_i
|
45
|
+
%td.record-won-deal-count
|
46
|
+
- dat[:won_deal_count] << record.won_deal_count
|
47
|
+
= record.won_deal_count.to_i
|
48
|
+
%td.record-total-value
|
49
|
+
- dat[:total_value] << record.total_value
|
50
|
+
= record.total_value
|
51
|
+
%td.record-averate-value
|
52
|
+
- dat[:average_value] << record.average_value
|
53
|
+
= record.average_value
|
54
|
+
%td.record-total-cost
|
55
|
+
- dat[:total_cost] << record.total_cost
|
56
|
+
= record.total_cost
|
57
|
+
%td.record-average-cost
|
58
|
+
- dat[:average_cost] << record.average_cost
|
59
|
+
= record.average_cost
|
60
|
+
%td.record-average-elapsed
|
61
|
+
- dat[:average_elapsed] << record.average_elapsed
|
62
|
+
= record.average_elapsed && "%s days" % record.average_elapsed || 'n/a'
|
63
|
+
%tfooter
|
64
|
+
%tr{:class => 'record-totals'}
|
65
|
+
%td.record-totals-label{:colspan => 3}
|
66
|
+
#{t(:totals)}:
|
67
|
+
%td.record-new-visits
|
68
|
+
= dat[:new_visits].sum
|
69
|
+
%td.record-repeat-visits
|
70
|
+
= dat[:repeat_visits].sum
|
71
|
+
%td.record-lead-count
|
72
|
+
= dat[:lead_count].sum
|
73
|
+
%td.record-deal-count
|
74
|
+
= dat[:deal_count].sum.to_i
|
75
|
+
%td.record-won-deal-count
|
76
|
+
= dat[:won_deal_count].sum.to_i
|
77
|
+
%td.record-total-value
|
78
|
+
= dat[:total_value].average
|
79
|
+
%td.record-averate-value
|
80
|
+
= dat[:average_value].average
|
81
|
+
%td.record-total-cost
|
82
|
+
= dat[:total_cost].compact.sum
|
83
|
+
%td.record-average-cost
|
84
|
+
= dat[:average_cost].compact.average
|
85
|
+
%td.record-average-elapsed
|
86
|
+
= "%s days" % dat[:average_elapsed].compact.average
|
@@ -0,0 +1,19 @@
|
|
1
|
+
= title (@index_title || e9_t(:index_title, :scope => 'e9_crm.reports'))
|
2
|
+
|
3
|
+
.toolbar
|
4
|
+
.toolbar-left
|
5
|
+
= form_tag(resource_class, :method => :get, :id => 'campaign_search_form') do
|
6
|
+
%select{:name => 'type'}
|
7
|
+
= campaign_type_select_options
|
8
|
+
%select{:name => 'group'}
|
9
|
+
= campaign_group_select_options
|
10
|
+
%select{:name => 'from'}
|
11
|
+
= deal_date_select_options
|
12
|
+
%select{:name => 'until'}
|
13
|
+
= deal_date_select_options(true)
|
14
|
+
|
15
|
+
.toolbar-right
|
16
|
+
= link_to_collection(Campaign)
|
17
|
+
|
18
|
+
%div#records_table
|
19
|
+
= render 'reports_table'
|
@@ -0,0 +1 @@
|
|
1
|
+
$("table.records").replaceWith("<%= escape_javascript(render('reports_table', :collection => collection)) %>");
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'e9_crm/campaigns/form_inner', :f => f
|
@@ -1,8 +1,8 @@
|
|
1
1
|
%table.records
|
2
2
|
%thead
|
3
3
|
%tr
|
4
|
-
%th= orderable_column_link('campaign.name', :campaign)
|
5
4
|
%th= orderable_column_link(:created_at)
|
5
|
+
%th= orderable_column_link('campaign.name', :campaign)
|
6
6
|
%th= orderable_column_link(:request_path)
|
7
7
|
%th= orderable_column_link(:referer)
|
8
8
|
%th= orderable_column_link(:remote_ip)
|
@@ -13,13 +13,13 @@
|
|
13
13
|
- else
|
14
14
|
- collection.each do |record|
|
15
15
|
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
16
|
-
%td.
|
17
|
-
= record.campaign_name || 'n/a'
|
18
|
-
%td.contact-created-at
|
16
|
+
%td.record-created-at
|
19
17
|
= I18n.l(record.created_at)
|
20
|
-
%td.
|
18
|
+
%td.record-campaign-name
|
19
|
+
= record.campaign_name || e9_t(:no_campaign)
|
20
|
+
%td.record-request-path
|
21
21
|
= record.request_path
|
22
|
-
%td.
|
22
|
+
%td.record-referer
|
23
23
|
= record.referer
|
24
|
-
%td.
|
24
|
+
%td.record-remote-ip
|
25
25
|
= record.remote_ip
|
@@ -14,7 +14,7 @@
|
|
14
14
|
- collection.each do |record|
|
15
15
|
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
16
16
|
- field_map[:fields].each do |key, value|
|
17
|
-
%td{:class => "
|
17
|
+
%td{:class => "record-#{key.to_s.dasherize}"}
|
18
18
|
= value.respond_to?(:call) ? value.call(record) : record.send(key)
|
19
19
|
%td.links
|
20
20
|
- field_map[:links][record].each do |link|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
= render 'e9_crm/campaigns/form_inner', :f => f
|
2
|
+
|
3
|
+
%fieldset
|
4
|
+
%legend= e9_t(:salesperson_information_legend, :scope => 'e9_crm.campaigns')
|
5
|
+
.field
|
6
|
+
= f.label :sales_person_id
|
7
|
+
= f.collection_select :sales_person_id, Contact.sales_persons.all, :id, :name, :prompt => true
|
8
|
+
.field
|
9
|
+
= f.label :sales_fee
|
10
|
+
= f.text_field :sales_fee
|
11
|
+
|
data/config/locales/e9.en.yml
CHANGED
@@ -17,7 +17,7 @@ en:
|
|
17
17
|
send_email_template: Send Email
|
18
18
|
send_email_newsletter: Send Newsletter
|
19
19
|
contact_newsletter_confirmation: "The system will send the newsletter to all of the selected contacts (%{count}) if they are subscribed to receieve email. Are you sure you want to proceed?"
|
20
|
-
no_contacts_notification: "
|
20
|
+
no_contacts_notification: "You cannot send an email with no recipients!"
|
21
21
|
contact_merges:
|
22
22
|
new_title: Merge Contacts
|
23
23
|
no_value: (No Value)
|
@@ -26,3 +26,13 @@ en:
|
|
26
26
|
send_email: Send Email
|
27
27
|
leads:
|
28
28
|
index_title: Leads
|
29
|
+
reports:
|
30
|
+
index_title: Marketing Report
|
31
|
+
no_records_text: No data exists for those query parameters.
|
32
|
+
campaigns:
|
33
|
+
no_campaign: No Campaign
|
34
|
+
no_group: No Group
|
35
|
+
campaign_information_legend: Campaign Information
|
36
|
+
salesperson_information_legend: Salesperson Information
|
37
|
+
affiliate_information_legend: Affiliate Information
|
38
|
+
code_help: "Be careful when creating tracking codes. They are NOT EDITABLE after you save them. To track the success of this campaign, you can append ?%{code}={Your Code} to the end of any and all URLs on your website. It might look something like this: http://www.example.com/about-us?%{code}=alpha, where \"alpha\" represents the code you created. You can provide this tracking URL to a salesperson or an affiliate or it can be placed at the end of a link in any of your advertisements."
|
data/config/locales/en.yml
CHANGED
@@ -3,6 +3,9 @@ en:
|
|
3
3
|
go: Go
|
4
4
|
search: Search
|
5
5
|
view: View
|
6
|
+
none: None
|
7
|
+
totals: Totals
|
8
|
+
inline_help_link: '[?]'
|
6
9
|
|
7
10
|
e9_crm:
|
8
11
|
add_record_attribute: Add
|
@@ -10,10 +13,13 @@ en:
|
|
10
13
|
|
11
14
|
activerecord:
|
12
15
|
links:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
edit: "Edit"
|
17
|
+
destroy: "Delete"
|
18
|
+
show: "View"
|
19
|
+
index: "Manage %{models}"
|
20
|
+
|
21
|
+
campaign_group:
|
22
|
+
confirm_destroy: Are you sure? This cannot be undone. Any campaigns which are associated with this group will become groupless.
|
17
23
|
|
18
24
|
errors:
|
19
25
|
messages:
|
@@ -27,8 +33,10 @@ en:
|
|
27
33
|
invalid: "One or more of the emails you entered is invalid."
|
28
34
|
contact_email:
|
29
35
|
attributes:
|
36
|
+
contact_ids:
|
37
|
+
blank: "You cannot send an emailwith no recipients!"
|
30
38
|
user_ids:
|
31
|
-
blank: "
|
39
|
+
blank: "None of the contacts selected are configured with primary emails. Please correct this and try again."
|
32
40
|
deal:
|
33
41
|
attributes:
|
34
42
|
status:
|
@@ -53,6 +61,9 @@ en:
|
|
53
61
|
attributes:
|
54
62
|
campaign:
|
55
63
|
name: Name
|
64
|
+
code_hint: Append to URL
|
65
|
+
no_campaign:
|
66
|
+
name: No Campaign
|
56
67
|
offer:
|
57
68
|
alert_email_instructions: (Enter an email if you want to be notified of conversions)
|
58
69
|
submit_button_text: Submit Button Text
|
data/config/routes.rb
CHANGED
@@ -4,7 +4,7 @@ Rails.application.routes.draw do
|
|
4
4
|
scope :path => crm_path, :module => :e9_crm do
|
5
5
|
resources :companies, :except => :show
|
6
6
|
resources :contacts, :except => :show do
|
7
|
-
resources :page_views, :path => 'activity', :only => :index
|
7
|
+
#resources :page_views, :path => 'activity', :only => :index
|
8
8
|
collection { get :templates }
|
9
9
|
end
|
10
10
|
resources :deals, :except => :show
|
@@ -18,26 +18,28 @@ Rails.application.routes.draw do
|
|
18
18
|
collection { post :update_order }
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
resources :campaigns, :only => :index do
|
24
|
-
resources :page_views, :path => 'activity', :only => :index
|
21
|
+
resources :campaigns, :only => [:index, :destroy] do
|
22
|
+
#resources :page_views, :path => 'activity', :only => :index
|
25
23
|
end
|
26
24
|
scope :path => :campaigns do
|
27
|
-
get '/activity', :to => redirect("/#{crm_path}/campaigns/all/activity")
|
28
|
-
|
25
|
+
#get '/activity', :to => redirect("/#{crm_path}/campaigns/all/activity")
|
29
26
|
resources :campaign_groups, :path => 'groups', :except => [:show]
|
30
|
-
|
31
|
-
resources :
|
27
|
+
|
28
|
+
resources :sales_campaigns, :path => 'sales', :except => [:show, :index]
|
29
|
+
resources :affiliate_campaigns, :path => 'affiliate', :except => [:show, :index]
|
30
|
+
resources :email_campaigns, :path => 'email', :except => [:show, :index]
|
31
|
+
resources :advertising_campaigns, :path => 'advertising', :except => [:show, :index] do
|
32
32
|
resources :dated_costs, :path => 'costs'
|
33
33
|
end
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
%w( advertising affiliate email sales ).each do |path|
|
36
|
+
get "/#{path}", :to => redirect("/#{crm_path}/campaigns?type=#{path}")
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
# leads are simply a scoped view of offers (only index)
|
39
41
|
get :leads, :as => :leads, :to => 'deals#leads'
|
40
|
-
get :marketing_report, :to => '
|
42
|
+
get :marketing_report, :to => 'deals#reports', :only => :index
|
41
43
|
|
42
44
|
get '/merge_contacts/:contact_a_id/and/:contact_b_id', :as => :new_contact_merge, :to => 'contact_merges#new'
|
43
45
|
post '/merge_contacts', :as => :contact_merges, :to => 'contact_merges#create'
|
@@ -57,5 +59,6 @@ Rails.application.routes.draw do
|
|
57
59
|
).each do |path|
|
58
60
|
get "/#{path}/:id", :to => redirect("/#{crm_path}/#{path}/%{id}/edit"), :constraints => { :id => /\d+/ }
|
59
61
|
end
|
62
|
+
|
60
63
|
end
|
61
64
|
end
|
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.13")
|
27
27
|
s.add_dependency("e9_tags", "~> 0.0.11")
|
28
28
|
s.add_dependency("will_paginate")
|
29
29
|
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'active_record/base'
|
2
2
|
require 'action_view/base'
|
3
3
|
|
4
|
+
class Array
|
5
|
+
def average
|
6
|
+
return 0 unless length > 0 && all? {|n| n && n.respond_to?(:to_f) }
|
7
|
+
sum / length
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
class ActiveRecord::Base
|
5
12
|
#
|
6
13
|
# Basic conversion for "money" columns using the Money class and Rails composed_of
|
@@ -2,77 +2,94 @@ module E9Crm
|
|
2
2
|
module TrackingController
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
included
|
5
|
+
included do
|
6
|
+
before_filter :check_for_new_session
|
7
|
+
after_filter :track_page_view
|
8
|
+
end
|
6
9
|
|
7
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
|
8
17
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def track_page_view
|
19
|
+
@_page_view ||= tracking_cookie.page_views.create({
|
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
|
+
})
|
29
|
+
end
|
20
30
|
|
21
|
-
|
22
|
-
|
23
|
-
|
31
|
+
def tracking_cookie
|
32
|
+
@_tracking_cookie ||= begin
|
33
|
+
E9Crm.log "Begin load or install cookie: cookie_name[#{E9Crm.cookie_name}] query_param[#{E9Crm.query_param}]"
|
24
34
|
|
25
|
-
|
35
|
+
code = params.delete(E9Crm.query_param)
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
if hid = cookies[E9Crm.cookie_name]
|
38
|
+
E9Crm.log("Installed cookie found: hid(#{hid})")
|
39
|
+
@_tracking_cookie = TrackingCookie.find_by_hid(hid)
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
35
46
|
end
|
36
|
-
end
|
37
47
|
|
38
|
-
|
48
|
+
E9Crm.log(@_tracking_cookie ? "Cookie loaded: (#{E9Crm.cookie_name} : #{@_tracking_cookie.hid})" : "Cookie not found")
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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 = {}
|
46
56
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
55
65
|
|
56
|
-
|
57
|
-
|
58
|
-
|
66
|
+
E9Crm.log "Cookie marked as new"
|
67
|
+
session[:new_visit] = true
|
68
|
+
end
|
59
69
|
|
60
|
-
|
61
|
-
|
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
|
62
73
|
end
|
63
|
-
end
|
64
74
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
69
82
|
end
|
70
|
-
end
|
71
83
|
|
72
|
-
|
84
|
+
E9Crm.log("Final Cookie : #{@_tracking_cookie.inspect}")
|
73
85
|
|
74
|
-
|
86
|
+
@_tracking_cookie
|
87
|
+
end
|
75
88
|
end
|
76
|
-
|
89
|
+
|
90
|
+
def tracking_campaign
|
91
|
+
@_tracking_campaign ||= tracking_cookie.code.presence && Campaign.find_by_code(tracking_cookie.code) || Campaign.default
|
92
|
+
end
|
93
|
+
|
77
94
|
end
|
78
95
|
end
|