caboose-cms 0.7.49 → 0.7.50

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05df2133ce69c265c58154aae2612ddd8c018412
4
- data.tar.gz: 65b19cc81afe0af3f2d617dd8c1cbdd33bf41f8b
3
+ metadata.gz: 9b58501d798ee6dd520475669eceb99c09f13e9c
4
+ data.tar.gz: 32fba4ffcbaabe2177813d854c5a08739f1d1f84
5
5
  SHA512:
6
- metadata.gz: b386a475e9c3592bc02be0e4252cc2c2de1e40af93ba6c8371a08f1bfdbb5cf2669b173ad2bb0fcebb5fcfabb79a082a82138c8d2cf7c1b672d39771ba233696
7
- data.tar.gz: 8e66d3a6e7b8a638b4fd4aa668302f0c1c090d4e74dde92f82675c1f91a6425718435587d063cb5db82f42bcda9f24efb8bf3446bff321a9776709af97754839
6
+ metadata.gz: 40f9f0f70d178446b26b74f0679ee9185b85afec6e2b71c215a0732ce750126791a1c11970d7d2535d3c6a0b05f58daca6e6893356c0504397c75b3b6012bc61
7
+ data.tar.gz: a6b9faefa91b639810c4f43215be8762d20d2c854a99b07ae3e0c0d80fcadea9dc424f9dbc38fb23addda78ba4e3703cd4f40ccf072b495dce207ab1c00f0888
@@ -222,6 +222,17 @@ module Caboose
222
222
  render :json => { :success => true }
223
223
  end
224
224
 
225
+ # GET /admin/orders/city-report
226
+ def admin_city_report
227
+ return if !user_is_allowed('orders', 'view')
228
+
229
+ @d1 = params[:d1] ? DateTime.strptime("#{params[:d1]} 00:00:00", '%Y-%m-%d %H:%M:%S') : DateTime.strptime(DateTime.now.strftime("%Y-%m-01 00:00:00"), '%Y-%m-%d %H:%M:%S')
230
+ @d2 = params[:d2] ? DateTime.strptime("#{params[:d2]} 00:00:00", '%Y-%m-%d %H:%M:%S') : @d1 + 1.month
231
+ @rows = OrderReporter.city_report(@site.id, @d1, @d2)
232
+
233
+ render :layout => 'caboose/admin'
234
+ end
235
+
225
236
  # GET /admin/orders/summary-report
226
237
  def admin_summary_report
227
238
  return if !user_is_allowed('orders', 'view')
@@ -62,5 +62,45 @@ module Caboose
62
62
  return days2
63
63
  end
64
64
 
65
+ def OrderReporter.city_report(site_id, d1, d2)
66
+ q = ["select
67
+ count(*),
68
+ sum(O.subtotal),
69
+ sum(O.tax),
70
+ sum(O.shipping),
71
+ sum(O.handling),
72
+ sum(O.discount),
73
+ sum(O.total),
74
+ SA.city,
75
+ SA.state
76
+ from store_orders O
77
+ left join store_addresses SA on O.shipping_address_id = SA.id
78
+ where O.site_id = ?
79
+ and (O.financial_status = ? or O.financial_status = ?)
80
+ and O.date_authorized >= ?
81
+ and O.date_authorized < ?
82
+ group by concat(SA.city, ', ', SA.state), SA.state, SA.city
83
+ order by SA.state, SA.city",
84
+ site_id, 'authorized', 'captured', d1, d2]
85
+ rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
86
+
87
+ arr = []
88
+ rows.each do |row|
89
+ arr << Caboose::StdClass.new(
90
+ :count => row[0].to_i,
91
+ :subtotal => row[1].to_f,
92
+ :tax => row[2].to_f,
93
+ :shipping => row[3].to_f,
94
+ :handling => row[4].to_f,
95
+ :discount => row[5].to_f,
96
+ :total => row[6].to_f,
97
+ :city => row[7],
98
+ :state => row[8]
99
+ )
100
+ end
101
+
102
+ return arr
103
+ end
104
+
65
105
  end
66
106
  end
@@ -0,0 +1,49 @@
1
+
2
+ <h1>City Report</h1>
3
+
4
+ <form action='/admin/orders/city-report' method='get' id='search_form'>
5
+ <p>
6
+ <input type='text' id='d1' name='d1' value='<%= @d1.strftime('%Y-%m-%d') %>' /> -
7
+ <input type='text' id='d2' name='d2' value='<%= @d2.strftime('%Y-%m-%d') %>' />
8
+ <input type='submit' value='Change Date Range' />
9
+ </p>
10
+ </form>
11
+
12
+ <table class='data'>
13
+ <tr>
14
+ <th>City </th>
15
+ <th>State </th>
16
+ <th>Count </th>
17
+ <th>Subtotal </th>
18
+ <th>Tax </th>
19
+ <th>Shipping </th>
20
+ <th>Handling </th>
21
+ <th>Discount </th>
22
+ <th>Total </th>
23
+ </tr>
24
+ <% @rows.each do |row| %>
25
+ <tr>
26
+ <td><%= row.city %></td>
27
+ <td><%= row.state %></td>
28
+ <td align='right'><%= row.count %></td>
29
+ <td align='right'>$<%= sprintf('%.2f', row.subtotal ) %></td>
30
+ <td align='right'>$<%= sprintf('%.2f', row.tax ) %></td>
31
+ <td align='right'>$<%= sprintf('%.2f', row.shipping ) %></td>
32
+ <td align='right'>$<%= sprintf('%.2f', row.handling ) %></td>
33
+ <td align='right'>$<%= sprintf('%.2f', row.discount ) %></td>
34
+ <td align='right'>$<%= sprintf('%.2f', row.total ) %></td>
35
+ </tr>
36
+ <% end %>
37
+ </table>
38
+
39
+ <% content_for :caboose_js do %>
40
+ <%= javascript_include_tag 'caboose/model/all' %>
41
+ <script type='text/javascript'>
42
+
43
+ $(document).ready(function() {
44
+ $('#d1').datepicker({ dateFormat: 'yy-mm-dd' });
45
+ $('#d2').datepicker({ dateFormat: 'yy-mm-dd' });
46
+ });
47
+
48
+ </script>
49
+ <% end %>
@@ -9,6 +9,7 @@
9
9
  <a class="caboose-btn" href='/admin/orders/new'>New Manual Order</a>
10
10
  <a class="caboose-btn" href='/admin/orders/print-pending' target='_blank'>Print Pending Orders</a>
11
11
  <a class="caboose-btn" href='/admin/orders/summary-report' target='_blank'>Summary Report</a>
12
+ <a class="caboose-btn" href='/admin/orders/city-report' target='_blank'>City Report</a>
12
13
  </p>
13
14
  <form action='/admin/orders' method='get' id='search_form' style='display: none;'>
14
15
  <p><input type='text' name='id' placeholder='Order ID' value="<%= @pager.params['id'] %>" style='width: 100px;' /></p>
data/config/routes.rb CHANGED
@@ -661,6 +661,7 @@ Caboose::Engine.routes.draw do
661
661
  # Orders
662
662
  #=============================================================================
663
663
 
664
+ get "/admin/orders/city-report" => "orders#admin_city_report"
664
665
  get "/admin/orders/summary-report" => "orders#admin_summary_report"
665
666
  get "/admin/orders/weird-test" => "orders#admin_weird_test"
666
667
  get "/admin/orders" => "orders#admin_index"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.49'
2
+ VERSION = '0.7.50'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.49
4
+ version: 0.7.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -1009,6 +1009,7 @@ files:
1009
1009
  - app/views/caboose/orders/_admin_footer.html.erb
1010
1010
  - app/views/caboose/orders/_admin_header.html.erb
1011
1011
  - app/views/caboose/orders/_quickbooks_order.html.erb
1012
+ - app/views/caboose/orders/admin_city_report.html.erb
1012
1013
  - app/views/caboose/orders/admin_delete_form.html.erb
1013
1014
  - app/views/caboose/orders/admin_edit.html.erb
1014
1015
  - app/views/caboose/orders/admin_index.html.erb