office_clerk 0.8 → 0.9
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 +4 -4
- data/Gemfile +6 -2
- data/Gemfile.lock +159 -100
- data/Guardfile +3 -0
- data/README.md +7 -2
- data/Rakefile +9 -0
- data/app/assets/images/missing_list.png +0 -0
- data/app/assets/images/missing_product.png +0 -0
- data/app/assets/images/missing_thumb.png +0 -0
- data/app/assets/javascripts/office_clerk.js +7 -5
- data/app/assets/stylesheets/office_clerk.css.scss +89 -14
- data/app/controllers/baskets_controller.rb +37 -26
- data/app/controllers/orders_controller.rb +44 -29
- data/app/controllers/products_controller.rb +6 -6
- data/app/controllers/purchases_controller.rb +18 -8
- data/app/helpers/admin_helper.rb +16 -21
- data/app/helpers/baskets_helper.rb +31 -0
- data/app/helpers/categories_helper.rb +3 -0
- data/app/helpers/office_helper.rb +34 -7
- data/app/helpers/orders_helper.rb +2 -3
- data/app/models/basket.rb +46 -20
- data/app/models/clerk.rb +6 -1
- data/app/models/item.rb +7 -0
- data/app/models/order.rb +18 -6
- data/app/models/product.rb +23 -8
- data/app/views/addresses/show.html.haml +2 -2
- data/app/views/baskets/_small.html.haml +2 -2
- data/app/views/baskets/edit.html.haml +19 -16
- data/app/views/baskets/index.html.haml +13 -5
- data/app/views/baskets/show.html.haml +3 -3
- data/app/views/categories/_treeview.html.haml +1 -2
- data/app/views/categories/edit.html.haml +4 -5
- data/app/views/categories/index.html.haml +7 -7
- data/app/views/categories/show.html.haml +3 -4
- data/app/views/clerks/edit.html.haml +4 -3
- data/app/views/clerks/index.html.haml +6 -6
- data/app/views/clerks/show.html.haml +3 -3
- data/app/views/layouts/_admin_menu.html.haml +8 -8
- data/app/views/layouts/_messages.html.haml +2 -2
- data/app/views/layouts/office_clerk.haml +10 -27
- data/app/views/order_mailer/confirm.text.erb +1 -2
- data/app/views/order_mailer/shipped.text.erb +2 -1
- data/app/views/orders/index.csv.erb +6 -6
- data/app/views/orders/index.html.haml +25 -20
- data/app/views/orders/shipment.haml +57 -0
- data/app/views/orders/show.html.haml +106 -39
- data/app/views/products/_head.haml +1 -2
- data/app/views/products/_line.html.haml +1 -1
- data/app/views/products/_preview_box.haml +14 -10
- data/app/views/products/_triple.html.haml +1 -1
- data/app/views/products/edit.html.haml +4 -4
- data/app/views/products/index.html.haml +24 -13
- data/app/views/products/show.html.haml +15 -12
- data/app/views/purchases/index.html.haml +11 -7
- data/app/views/purchases/show.html.haml +42 -25
- data/app/views/sessions/sign_up.haml +10 -10
- data/app/views/suppliers/edit.html.haml +2 -2
- data/app/views/suppliers/index.html.haml +6 -7
- data/app/views/suppliers/show.html.haml +2 -3
- data/config/i18n-tasks.yml +97 -0
- data/config/initializers/migrate.rb +11 -1
- data/config/initializers/paperclip.rb +17 -0
- data/config/locales/config.yml +0 -1
- data/config/locales/en.yml +99 -116
- data/config/locales/fi.yml +101 -117
- data/config/routes.rb +18 -15
- data/db/migrate/20131226143612_categories.rb +2 -2
- data/db/migrate/20131226151332_products.rb +3 -3
- data/lib/office_clerk/engine.rb +5 -8
- data/lib/office_clerk/shipping_method.rb +12 -1
- data/lib/office_clerk/version.rb +1 -1
- data/office_clerk.gemspec +5 -5
- data/spec/controllers/baskets_controller_spec.rb +2 -2
- data/spec/controllers/orders_controller_spec.rb +0 -29
- data/spec/controllers/products_controller_spec.rb +4 -3
- data/spec/controllers/purchases_controller_spec.rb +3 -4
- data/spec/factories/orders.rb +6 -1
- data/spec/factories/products.rb +3 -0
- data/spec/features/baskets/edit_spec.rb +6 -1
- data/spec/features/baskets/index_spec.rb +1 -0
- data/spec/features/baskets/search_spec.rb +1 -1
- data/spec/features/orders/filter_spec.rb +19 -0
- data/spec/features/orders/inventory_spec.rb +19 -0
- data/spec/features/orders/ordering_spec.rb +84 -0
- data/spec/features/paginate_spec.rb +11 -0
- data/spec/features/sessions_spec.rb +2 -1
- data/spec/{models/locale_spec.rb → i18n_spec.rb} +19 -1
- data/spec/mailers/order_mailer_spec.rb +2 -1
- data/spec/models/baskets/inventory_spec.rb +9 -2
- data/spec/models/baskets/items_spec.rb +6 -1
- data/spec/models/order_spec.rb +20 -1
- data/spec/routing/baskets_routing_spec.rb +5 -1
- data/spec/routing/orders_routing_spec.rb +0 -12
- data/spec/spec_helper.rb +16 -3
- data/test_app/bin/setup +29 -0
- data/test_app/config/application.rb +3 -0
- data/test_app/config/boot.rb +1 -2
- data/test_app/config/environment.rb +1 -1
- data/test_app/config/environments/development.rb +1 -1
- data/test_app/config/environments/production.rb +20 -21
- data/test_app/config/environments/test.rb +7 -4
- data/test_app/config/initializers/assets.rb +11 -0
- data/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/test_app/config/initializers/mime_types.rb +0 -1
- data/test_app/config/initializers/session_store.rb +1 -1
- data/test_app/config/routes.rb +1 -2
- data/test_app/config/secrets.yml +22 -0
- data/test_app/db/migrate/20141114205526_suppliers.office.rb +1 -1
- data/test_app/db/migrate/20141114205527_categories.office.rb +3 -3
- data/test_app/db/migrate/20141114205528_items.office.rb +1 -1
- data/test_app/db/migrate/20141114205529_orders.office.rb +1 -1
- data/test_app/db/migrate/20141114205530_baskets.office.rb +1 -1
- data/test_app/db/migrate/20141114205531_purchases.office.rb +1 -1
- data/test_app/db/migrate/20141114205532_products.office.rb +4 -4
- data/test_app/db/schema.rb +26 -26
- metadata +35 -28
- data/app/views/orders/edit.html.haml +0 -25
- data/app/views/orders/ship.haml +0 -91
- data/app/views/purchases/edit.html.haml +0 -9
- data/spec/features/orders_spec.rb +0 -37
data/Guardfile
CHANGED
@@ -25,5 +25,8 @@ guard :rspec , :cmd => command do
|
|
25
25
|
# Turnip features and steps
|
26
26
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
27
27
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
28
|
+
|
29
|
+
# locales
|
30
|
+
watch(%r{^config/locales/.*yml}) { |m| "spec/i18n_spec.rb" }
|
28
31
|
end
|
29
32
|
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
## Office Clerk
|
2
|
+
|
3
|
+
[](https://gitter.im/rubyclerks/office_clerk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2
4
|
[](https://travis-ci.org/rubyclerks/office_clerk)
|
3
5
|
[](http://badge.fury.io/rb/office_clerk)
|
4
6
|
[](https://codeclimate.com/github/rubyclerks/office_clerk)
|
5
|
-
[](https://codeclimate.com/github/rubyclerks/office_clerk)
|
7
|
+
[ 300+](https://codeclimate.com/github/rubyclerks/office_clerk)
|
6
8
|
|
7
9
|
Office Clerk is the back office helper, your accountant, storage manager, secretary and more. It is the heart of the [RubyClerks team](http://rubyclerks.org) , the manager as it were.
|
8
10
|
|
@@ -45,7 +47,10 @@ The longer route, adding to existing project
|
|
45
47
|
|
46
48
|
If you got this far and still have question , mail me, or mail the [list](https://groups.google.com/forum/#!forum/rubyclerks)
|
47
49
|
|
48
|
-
|
50
|
+
Check the [User Guide](http://rubyclerks.org/user_guide/01_index.html),
|
51
|
+
then the [Developer Guide](http://rubyclerks.org/developer_guide/01_index.html).
|
52
|
+
|
53
|
+
Fill issues if you find, or discuss with me for ideas.
|
49
54
|
|
50
55
|
### Similar Projects
|
51
56
|
|
data/Rakefile
CHANGED
@@ -3,4 +3,13 @@
|
|
3
3
|
|
4
4
|
require File.expand_path('../test_app/config/application', __FILE__)
|
5
5
|
|
6
|
+
require 'bundler/gem_tasks'
|
7
|
+
|
6
8
|
TestApp::Application.load_tasks
|
9
|
+
|
10
|
+
desc 'Rebuild test and run specs'
|
11
|
+
task :full_test do
|
12
|
+
system("rake db:drop db:migrate RAILS_ENV=test && rspec")
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => 'full_test'
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,11 +1,12 @@
|
|
1
|
-
//= require jquery
|
1
|
+
//= require jquery.min
|
2
|
+
//= require jquery_ujs
|
2
3
|
//= require best_in_place
|
3
4
|
|
4
|
-
//= require jquery-ui
|
5
|
+
//= require jquery-ui/datepicker
|
5
6
|
//= require jquery-ui/datepicker-fi
|
6
7
|
//= require best_in_place.jquery-ui
|
7
8
|
|
8
|
-
//= require bootstrap
|
9
|
+
//= require bootstrap.min
|
9
10
|
//= require_self
|
10
11
|
|
11
12
|
$.datepicker.setDefaults( $.datepicker.regional[ 'fi' ] );
|
@@ -13,14 +14,13 @@ $.datepicker.setDefaults( $.datepicker.regional[ 'fi' ] );
|
|
13
14
|
$(function() {
|
14
15
|
$( ".datepicker" ).datepicker( );
|
15
16
|
});
|
16
|
-
|
17
|
+
|
17
18
|
function initPage(){
|
18
19
|
// Add Error Form style with bootstrap
|
19
20
|
$("div.form-group>div.field_with_errors").parent().addClass("error");
|
20
21
|
$("#error_explanation").addClass("text-error");
|
21
22
|
|
22
23
|
}
|
23
|
-
|
24
24
|
$(window).bind('page:change', function() {
|
25
25
|
initPage();
|
26
26
|
});
|
@@ -28,4 +28,6 @@ $(window).bind('page:change', function() {
|
|
28
28
|
$(document).ready(function() {
|
29
29
|
/* Activating Best In Place */
|
30
30
|
jQuery(".best_in_place").best_in_place();
|
31
|
+
/* and fading alerts */
|
32
|
+
jQuery(".alert").delay(5000).fadeOut("slow");
|
31
33
|
});
|
@@ -38,14 +38,17 @@ a.online{
|
|
38
38
|
color: green;
|
39
39
|
}
|
40
40
|
|
41
|
-
.alert
|
42
|
-
background-color: #00FFEB;
|
41
|
+
.alert {
|
43
42
|
padding: 8px;
|
44
43
|
radius: $global-radius;
|
45
44
|
}
|
46
45
|
|
47
|
-
.alert-
|
48
|
-
background-color:
|
46
|
+
.alert-notice {
|
47
|
+
background-color: #00FFEB;
|
48
|
+
}
|
49
|
+
|
50
|
+
.alert-alert {
|
51
|
+
background-color: #ff8080;
|
49
52
|
};
|
50
53
|
|
51
54
|
|
@@ -55,7 +58,7 @@ body {
|
|
55
58
|
|
56
59
|
.new-button {
|
57
60
|
top: 15px;
|
58
|
-
text-align: right;
|
61
|
+
text-align: right;
|
59
62
|
}
|
60
63
|
|
61
64
|
.strip {
|
@@ -80,7 +83,7 @@ ul.pagination li {
|
|
80
83
|
ul.pagination li a{
|
81
84
|
background-color: rgba(255, 255, 255, 0.9);
|
82
85
|
}
|
83
|
-
|
86
|
+
|
84
87
|
.admin-table {
|
85
88
|
font-size: 0.5rem;
|
86
89
|
|
@@ -90,38 +93,110 @@ thead, tbody { vertical-align: top;
|
|
90
93
|
|
91
94
|
}
|
92
95
|
|
93
|
-
.tausta {
|
96
|
+
.tausta {
|
94
97
|
background: $tausta-bg;
|
95
98
|
border-radius: 6px;
|
96
99
|
padding-top: 6px;
|
97
100
|
margin-bottom: 20px;
|
98
101
|
}
|
99
102
|
|
100
|
-
.products{
|
103
|
+
.products{
|
101
104
|
background: image-url('office_clerk/products-2.jpg') no-repeat;
|
102
105
|
}
|
103
106
|
|
104
|
-
.baskets{
|
107
|
+
.baskets{
|
105
108
|
background: image-url('office_clerk/baskets-2.jpg') no-repeat;
|
106
109
|
}
|
107
110
|
|
108
|
-
.orders{
|
111
|
+
.orders{
|
109
112
|
background: image-url('office_clerk/orders-2.jpg') no-repeat;
|
110
113
|
}
|
111
114
|
|
112
|
-
.purchases{
|
115
|
+
.purchases{
|
113
116
|
background: image-url('office_clerk/purchases-2.jpg') no-repeat;
|
114
117
|
height: 161px;
|
115
118
|
}
|
116
119
|
|
117
|
-
.categories{
|
120
|
+
.categories{
|
118
121
|
background: image-url('office_clerk/categories-2.jpg') no-repeat;
|
119
122
|
}
|
120
123
|
|
121
|
-
.suppliers{
|
124
|
+
.suppliers{
|
122
125
|
background: image-url('office_clerk/suppliers-2.jpg') no-repeat;
|
123
126
|
}
|
124
127
|
|
125
|
-
.clerks{
|
128
|
+
.clerks{
|
126
129
|
background: image-url('office_clerk/clerks-2.jpg') no-repeat;
|
127
130
|
}
|
131
|
+
|
132
|
+
.admin {
|
133
|
+
.product-container {
|
134
|
+
margin-bottom: 31px;
|
135
|
+
position: relative;
|
136
|
+
border: 1px solid #5BE7E2;
|
137
|
+
box-shadow: 2px 2px 5px #E8EDF0;
|
138
|
+
overflow: hidden;
|
139
|
+
width: 260px;
|
140
|
+
}
|
141
|
+
|
142
|
+
.product-container h4 {
|
143
|
+
position: absolute;
|
144
|
+
left: 0;
|
145
|
+
padding: 10px;
|
146
|
+
color: #000000;
|
147
|
+
font-size: 1.5rem;
|
148
|
+
background: #94cef6;
|
149
|
+
margin: 0px;
|
150
|
+
width: 100%;
|
151
|
+
z-index: 1;
|
152
|
+
}
|
153
|
+
|
154
|
+
.square-image {
|
155
|
+
height: 200px;
|
156
|
+
}
|
157
|
+
|
158
|
+
.square-image img {
|
159
|
+
position: absolute;
|
160
|
+
bottom: 4px;
|
161
|
+
}
|
162
|
+
|
163
|
+
.bottom {
|
164
|
+
position: absolute;
|
165
|
+
bottom: 0;
|
166
|
+
right: 0;
|
167
|
+
}
|
168
|
+
|
169
|
+
.product-fact {
|
170
|
+
border-top: 1px solid #0078ff;
|
171
|
+
background: rgba(255, 255, 255, 0.7);
|
172
|
+
padding: 5px 10px 0 5px;
|
173
|
+
position: relative;
|
174
|
+
top: 75px;
|
175
|
+
}
|
176
|
+
|
177
|
+
.product-fact p {
|
178
|
+
font-size: 1.2rem;
|
179
|
+
font-weight: 500;
|
180
|
+
color: #000000;
|
181
|
+
line-height: 110%;
|
182
|
+
margin-bottom: 3px;
|
183
|
+
}
|
184
|
+
|
185
|
+
.product-list-price {
|
186
|
+
color: #04617A;
|
187
|
+
font-weight: 400;
|
188
|
+
font-size: 2.6rem;
|
189
|
+
text-align: right;
|
190
|
+
position: absolute;
|
191
|
+
bottom: 2px;
|
192
|
+
right: 22px; }
|
193
|
+
|
194
|
+
}
|
195
|
+
|
196
|
+
.no-bg {
|
197
|
+
background: none;
|
198
|
+
}
|
199
|
+
|
200
|
+
.no-border td {
|
201
|
+
border: none;
|
202
|
+
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BasketsController < AdminController
|
3
|
+
include BasketsHelper
|
3
4
|
|
4
|
-
before_filter :load_basket, :only => [:show, :edit, :change , :update, :destroy , :order ,
|
5
|
-
:checkout, :purchase , :discount , :ean]
|
5
|
+
before_filter :load_basket, :only => [:show, :edit, :change , :update, :destroy , :order ,
|
6
|
+
:checkout, :purchase , :discount , :ean , :zero]
|
6
7
|
|
7
8
|
def index
|
8
|
-
@q = Basket.
|
9
|
+
@q = Basket.ransack( params[:q] )
|
9
10
|
@basket_scope = @q.result( :distinct => true )
|
10
11
|
@baskets = @basket_scope.includes({:items => :product} , :kori).paginate( :page => params[:page], :per_page => 20 )
|
11
12
|
end
|
@@ -18,8 +19,7 @@ class BasketsController < AdminController
|
|
18
19
|
order = @basket.kori || Order.new( :basket => @basket )
|
19
20
|
order.pos_checkout( current_clerk.email )
|
20
21
|
order.save!
|
21
|
-
|
22
|
-
if(styles && styles.split.include?("receipt"))
|
22
|
+
if has_receipt?
|
23
23
|
redirect_to receipt_order_path(order)
|
24
24
|
else
|
25
25
|
redirect_to order_path(order)
|
@@ -30,14 +30,18 @@ class BasketsController < AdminController
|
|
30
30
|
gon.basket_id = @basket.id
|
31
31
|
end
|
32
32
|
|
33
|
+
def zero
|
34
|
+
@basket.zero_prices!
|
35
|
+
render :edit
|
36
|
+
end
|
37
|
+
|
33
38
|
#as an action this order is meant as a verb, ie order this basket
|
34
39
|
def order
|
35
40
|
if @basket.empty?
|
36
|
-
render :edit , :notice => t(:basket_empty)
|
37
|
-
return
|
41
|
+
return render :edit , :notice => t(:basket_empty)
|
38
42
|
end
|
39
43
|
order = Order.create! :basket => @basket , :email => current_clerk.email , :ordered_on => Date.today
|
40
|
-
redirect_to
|
44
|
+
redirect_to order_path(order)
|
41
45
|
end
|
42
46
|
|
43
47
|
def purchase
|
@@ -50,7 +54,7 @@ class BasketsController < AdminController
|
|
50
54
|
return
|
51
55
|
end
|
52
56
|
purchase = Purchase.create! :basket => @basket
|
53
|
-
redirect_to
|
57
|
+
redirect_to office.purchase_path(purchase)
|
54
58
|
end
|
55
59
|
|
56
60
|
def new
|
@@ -62,23 +66,23 @@ class BasketsController < AdminController
|
|
62
66
|
def discount
|
63
67
|
if discount = params[:discount]
|
64
68
|
if i_id = params[:item]
|
65
|
-
item = @basket.items.find { |
|
69
|
+
item = @basket.items.find { |it| it.id.to_s == i_id }
|
66
70
|
item_discount( item , discount )
|
67
71
|
else
|
68
|
-
@basket.items.each do |
|
69
|
-
item_discount(
|
72
|
+
@basket.items.each do |it|
|
73
|
+
item_discount( it , discount )
|
70
74
|
end
|
71
75
|
end
|
72
76
|
@basket.save!
|
73
77
|
else
|
74
78
|
flash[:error] = "No discount given"
|
75
79
|
end
|
76
|
-
redirect_to
|
80
|
+
redirect_to office.edit_basket_path(@basket)
|
77
81
|
end
|
78
82
|
|
79
83
|
# ean search at the top of basket edit
|
80
84
|
def ean
|
81
|
-
return if
|
85
|
+
return if redirect_if_locked
|
82
86
|
ean = params[:ean]
|
83
87
|
ean.sub!("P+" , "P-") if ean[0,2] == "P+"
|
84
88
|
prod = Product.find_by_ean ean
|
@@ -90,16 +94,15 @@ class BasketsController < AdminController
|
|
90
94
|
@basket.add_product prod
|
91
95
|
else
|
92
96
|
# stor the basket in the session ( or the url ???)
|
93
|
-
redirect_to :
|
94
|
-
:q => {"name_or_product_name_cont"=> ean},:basket => @basket.id
|
97
|
+
redirect_to office.products_path(:q => {"name_or_product_name_cont"=> ean},:basket => @basket.id)
|
95
98
|
return
|
96
99
|
end
|
97
100
|
end
|
98
|
-
redirect_to
|
101
|
+
redirect_to office.basket_path(@basket)
|
99
102
|
end
|
100
103
|
|
101
104
|
def edit
|
102
|
-
return if
|
105
|
+
return if redirect_if_locked
|
103
106
|
if p_id = (params[:add] || params[:delete])
|
104
107
|
add = params[:add].blank? ? -1 : 1
|
105
108
|
@basket.add_product Product.find(p_id) , add
|
@@ -118,7 +121,7 @@ class BasketsController < AdminController
|
|
118
121
|
end
|
119
122
|
|
120
123
|
def update
|
121
|
-
return if
|
124
|
+
return if redirect_if_locked
|
122
125
|
@basket.update_attributes(params_for_basket)
|
123
126
|
flash.notice = t(:update_success, :model => "basket")
|
124
127
|
redirect_to edit_basket_path(@basket)
|
@@ -126,18 +129,27 @@ class BasketsController < AdminController
|
|
126
129
|
|
127
130
|
def destroy
|
128
131
|
# the idea is that you can't delete a basket once something has been "done" with it (order..)
|
129
|
-
|
130
|
-
|
132
|
+
if @basket.locked?
|
133
|
+
flash.notice = t('basket_locked')
|
134
|
+
else
|
135
|
+
flash.notice = t('basket') + " " + t(:deleted)
|
136
|
+
@basket.destroy
|
137
|
+
end
|
138
|
+
redirect_to baskets_path
|
131
139
|
end
|
132
140
|
|
133
141
|
private
|
134
142
|
|
135
143
|
# check if the @basket is locked (no edits allowed)
|
136
144
|
# and if so redirect to show
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
145
|
+
# return if redirect happened
|
146
|
+
def redirect_if_locked
|
147
|
+
if @basket.locked?
|
148
|
+
flash.notice = t('basket_locked')
|
149
|
+
redirect_to :action => :show
|
150
|
+
return true
|
151
|
+
end
|
152
|
+
return false
|
141
153
|
end
|
142
154
|
|
143
155
|
def item_discount item , discount
|
@@ -155,4 +167,3 @@ class BasketsController < AdminController
|
|
155
167
|
params.require(:basket).permit( :items_attributes => [:quantity , :price , :id] )
|
156
168
|
end
|
157
169
|
end
|
158
|
-
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class OrdersController < AdminController
|
3
3
|
|
4
|
-
before_filter :load_order, :only => [:show, :edit, :
|
4
|
+
before_filter :load_order, :only => [ :show, :edit, :destroy, :update , :cancel,
|
5
|
+
:ship, :shipment , :pay , :mail]
|
5
6
|
|
6
7
|
def index
|
7
8
|
@q = Order.search(params[:q])
|
8
|
-
@order_scope = @q.result( :distinct => true)
|
9
|
-
@orders = @order_scope.
|
9
|
+
@order_scope = @q.result( :distinct => true).includes(:basket => :items )
|
10
|
+
@orders = @order_scope.paginate(:page => params[:page],:per_page => 20)
|
10
11
|
end
|
11
12
|
|
12
13
|
def show
|
@@ -14,51 +15,56 @@ class OrdersController < AdminController
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def new
|
17
|
-
|
18
|
-
@order.
|
19
|
-
|
18
|
+
basket = Basket.create!
|
19
|
+
@order = Order.new :email => current_clerk.email , :basket => basket , :ordered_on => Date.today
|
20
|
+
if( copy = params[:address])
|
21
|
+
order = Order.find copy
|
22
|
+
@order.email = order.email
|
23
|
+
@order.address = order.address
|
24
|
+
end
|
25
|
+
@order.save!
|
26
|
+
redirect_to edit_basket_path basket
|
20
27
|
end
|
21
28
|
|
22
29
|
def mail
|
23
30
|
action = params[:act]
|
24
|
-
puts "MAIL #{action}"
|
25
31
|
mail = eval("OrderMailer.#{action}(@order)")
|
26
32
|
mail.deliver
|
27
33
|
flash.notice = "Sent #{action}"
|
28
34
|
redirect_to :action => :show
|
29
35
|
end
|
30
36
|
def pay
|
31
|
-
@order.pay_now
|
32
|
-
|
37
|
+
@order.pay_now
|
38
|
+
@order.save
|
39
|
+
return redirect_to orders_path , :notice => t(:update_success) + ":#{@order.number}"
|
33
40
|
end
|
41
|
+
|
34
42
|
def ship
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
redirect_to order_path(@order), :notice => t(:OK)
|
40
|
-
return
|
41
|
-
end
|
43
|
+
@order.ship_now
|
44
|
+
@order.basket.deduct!
|
45
|
+
@order.save!
|
46
|
+
return redirect_to order_path(@order), :notice => t(:update_success)
|
42
47
|
end
|
43
|
-
|
44
|
-
|
48
|
+
|
49
|
+
# after many user mistakes we now let the user undo those, cancel to go back to edit
|
50
|
+
def cancel
|
51
|
+
@order.cancel!
|
52
|
+
return redirect_to order_path(@order), :notice => t(:update_success)
|
45
53
|
end
|
46
54
|
|
47
|
-
def
|
48
|
-
|
49
|
-
@order
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
render :edit
|
54
|
-
end
|
55
|
+
def shipment
|
56
|
+
return if request.get?
|
57
|
+
return redirect_to order_path(@order), :notice => t(:update_success) if @order.update_attributes(params_for_order)
|
58
|
+
end
|
59
|
+
|
60
|
+
def edit
|
55
61
|
end
|
56
62
|
|
57
63
|
def update
|
58
64
|
@order.build_basket unless @order.basket
|
59
65
|
respond_to do |format|
|
60
66
|
if @order.update_attributes(params_for_order)
|
61
|
-
format.html { redirect_to(@order, :notice => t(:update_success, :model =>
|
67
|
+
format.html { redirect_to(@order, :notice => t(:update_success, :model => :order)) }
|
62
68
|
format.json { respond_with_bip(@order) }
|
63
69
|
else
|
64
70
|
format.html { render :action => :edit }
|
@@ -67,6 +73,16 @@ class OrdersController < AdminController
|
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
76
|
+
def destroy
|
77
|
+
if @order.basket.locked?
|
78
|
+
flash.notice = t(:basket_locked)
|
79
|
+
else
|
80
|
+
@order.destroy
|
81
|
+
flash.notice = t(:order) + " " + t(:deleted)
|
82
|
+
end
|
83
|
+
redirect_to orders_url
|
84
|
+
end
|
85
|
+
|
70
86
|
private
|
71
87
|
|
72
88
|
def load_order
|
@@ -74,7 +90,6 @@ class OrdersController < AdminController
|
|
74
90
|
end
|
75
91
|
|
76
92
|
def params_for_order
|
77
|
-
params.require(:order).permit(:shipment_price,:shipment_tax,:shipment_type, :note)
|
93
|
+
params.require(:order).permit(:payment_info,:shipment_info,:shipment_price,:shipment_tax,:shipment_type, :note , :name ,:street, :city , :phone , :email)
|
78
94
|
end
|
79
95
|
end
|
80
|
-
|