bbmb 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/LICENSE.txt +339 -0
- data/Manifest.txt +91 -0
- data/README.txt +25 -0
- data/Rakefile +28 -0
- data/bin/admin +71 -0
- data/bin/bbmbd +61 -0
- data/lib/bbmb.rb +9 -0
- data/lib/bbmb/config.rb +106 -0
- data/lib/bbmb/html/state/change_password.rb +50 -0
- data/lib/bbmb/html/state/current_order.rb +81 -0
- data/lib/bbmb/html/state/customer.rb +109 -0
- data/lib/bbmb/html/state/customers.rb +52 -0
- data/lib/bbmb/html/state/favorites.rb +19 -0
- data/lib/bbmb/html/state/favorites_result.rb +21 -0
- data/lib/bbmb/html/state/global.rb +62 -0
- data/lib/bbmb/html/state/history.rb +95 -0
- data/lib/bbmb/html/state/info.rb +23 -0
- data/lib/bbmb/html/state/json.rb +16 -0
- data/lib/bbmb/html/state/login.rb +76 -0
- data/lib/bbmb/html/state/order.rb +21 -0
- data/lib/bbmb/html/state/orders.rb +19 -0
- data/lib/bbmb/html/state/result.rb +64 -0
- data/lib/bbmb/html/state/show_pass.rb +16 -0
- data/lib/bbmb/html/state/viral/admin.rb +41 -0
- data/lib/bbmb/html/state/viral/customer.rb +143 -0
- data/lib/bbmb/html/util/known_user.rb +51 -0
- data/lib/bbmb/html/util/multilingual.rb +18 -0
- data/lib/bbmb/html/util/session.rb +52 -0
- data/lib/bbmb/html/util/validator.rb +55 -0
- data/lib/bbmb/html/view/backorder.rb +24 -0
- data/lib/bbmb/html/view/change_password.rb +42 -0
- data/lib/bbmb/html/view/copyleft.rb +41 -0
- data/lib/bbmb/html/view/current_order.rb +482 -0
- data/lib/bbmb/html/view/customer.rb +152 -0
- data/lib/bbmb/html/view/customers.rb +145 -0
- data/lib/bbmb/html/view/favorites.rb +162 -0
- data/lib/bbmb/html/view/favorites_result.rb +26 -0
- data/lib/bbmb/html/view/foot.rb +21 -0
- data/lib/bbmb/html/view/head.rb +32 -0
- data/lib/bbmb/html/view/history.rb +60 -0
- data/lib/bbmb/html/view/info.rb +33 -0
- data/lib/bbmb/html/view/json.rb +20 -0
- data/lib/bbmb/html/view/list_prices.rb +51 -0
- data/lib/bbmb/html/view/login.rb +46 -0
- data/lib/bbmb/html/view/multilingual.rb +17 -0
- data/lib/bbmb/html/view/navigation.rb +30 -0
- data/lib/bbmb/html/view/order.rb +123 -0
- data/lib/bbmb/html/view/orders.rb +50 -0
- data/lib/bbmb/html/view/result.rb +107 -0
- data/lib/bbmb/html/view/search.rb +28 -0
- data/lib/bbmb/html/view/show_pass.rb +60 -0
- data/lib/bbmb/html/view/template.rb +61 -0
- data/lib/bbmb/model/customer.rb +96 -0
- data/lib/bbmb/model/order.rb +255 -0
- data/lib/bbmb/model/product.rb +99 -0
- data/lib/bbmb/model/promotion.rb +52 -0
- data/lib/bbmb/model/quota.rb +27 -0
- data/lib/bbmb/model/subject.rb +46 -0
- data/lib/bbmb/persistence/none.rb +6 -0
- data/lib/bbmb/persistence/odba.rb +42 -0
- data/lib/bbmb/persistence/odba/model/customer.rb +47 -0
- data/lib/bbmb/persistence/odba/model/order.rb +50 -0
- data/lib/bbmb/persistence/odba/model/product.rb +26 -0
- data/lib/bbmb/persistence/odba/model/quota.rb +12 -0
- data/lib/bbmb/util/invoicer.rb +126 -0
- data/lib/bbmb/util/mail.rb +140 -0
- data/lib/bbmb/util/multilingual.rb +57 -0
- data/lib/bbmb/util/numbers.rb +67 -0
- data/lib/bbmb/util/password_generator.rb +44 -0
- data/lib/bbmb/util/polling_manager.rb +135 -0
- data/lib/bbmb/util/server.rb +159 -0
- data/lib/bbmb/util/target_dir.rb +36 -0
- data/lib/bbmb/util/transfer_dat.rb +34 -0
- data/lib/bbmb/util/updater.rb +27 -0
- data/test/data/ydim.yml +2 -0
- data/test/model/test_customer.rb +75 -0
- data/test/model/test_order.rb +426 -0
- data/test/model/test_product.rb +238 -0
- data/test/model/test_promotion.rb +40 -0
- data/test/stub/persistence.rb +57 -0
- data/test/suite.rb +12 -0
- data/test/test_bbmb.rb +18 -0
- data/test/util/test_invoicer.rb +189 -0
- data/test/util/test_mail.rb +359 -0
- data/test/util/test_money.rb +71 -0
- data/test/util/test_password_generator.rb +27 -0
- data/test/util/test_polling_manager.rb +312 -0
- data/test/util/test_server.rb +189 -0
- data/test/util/test_target_dir.rb +82 -0
- data/test/util/test_transfer_dat.rb +45 -0
- metadata +190 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::View::CopyLeft -- bbmb.ch -- 15.09.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/divcomposite'
|
5
|
+
require 'htmlgrid/link'
|
6
|
+
|
7
|
+
module BBMB
|
8
|
+
module Html
|
9
|
+
module View
|
10
|
+
class CopyLeft < HtmlGrid::DivComposite
|
11
|
+
def CopyLeft.external_link(key, url)
|
12
|
+
define_method(key) { |model|
|
13
|
+
link = HtmlGrid::Link.new(key, model, @session, self)
|
14
|
+
link.href = url
|
15
|
+
link
|
16
|
+
}
|
17
|
+
end
|
18
|
+
COMPONENTS = {
|
19
|
+
[0,0] => :lgpl,
|
20
|
+
[1,0] => ', ',
|
21
|
+
[2,0] => :current_year,
|
22
|
+
[3,0] => ' ',
|
23
|
+
[4,0] => :ywesee,
|
24
|
+
[5,0] => ' ',
|
25
|
+
[6,0] => :bbmb_version,
|
26
|
+
}
|
27
|
+
external_link :lgpl, 'http://www.gnu.org/copyleft/lesser.html'
|
28
|
+
external_link :ywesee, 'http://www.ywesee.com'
|
29
|
+
external_link :version, BBMB.config.scm_link
|
30
|
+
def current_year(model)
|
31
|
+
Time.now.year.to_s
|
32
|
+
end
|
33
|
+
def bbmb_version(model)
|
34
|
+
link = version(model)
|
35
|
+
link.set_attribute('title', VERSION)
|
36
|
+
link
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,482 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::View::CurrentOrder -- bbmb.ch -- 20.09.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'bbmb/html/view/backorder'
|
5
|
+
require 'bbmb/html/view/list_prices'
|
6
|
+
require 'bbmb/html/view/order'
|
7
|
+
require 'bbmb/html/view/search'
|
8
|
+
require 'bbmb/html/view/template'
|
9
|
+
require 'htmlgrid/divform'
|
10
|
+
require 'htmlgrid/dojotoolkit'
|
11
|
+
require 'htmlgrid/errormessage'
|
12
|
+
require 'htmlgrid/inputcheckbox'
|
13
|
+
require 'htmlgrid/inputfile'
|
14
|
+
require 'htmlgrid/inputradio'
|
15
|
+
require 'htmlgrid/inputtext'
|
16
|
+
require 'htmlgrid/javascript'
|
17
|
+
require 'htmlgrid/span'
|
18
|
+
require 'htmlgrid/spancomposite'
|
19
|
+
require 'htmlgrid/textarea'
|
20
|
+
|
21
|
+
module BBMB
|
22
|
+
module Html
|
23
|
+
module View
|
24
|
+
module ActiveX
|
25
|
+
def other_html_headers(context)
|
26
|
+
html = ''
|
27
|
+
if(@session.client_activex? && !@lookandfeel.disabled?(:barcode_reader))
|
28
|
+
cab = 'BbmbBarcodeReader.CAB#version=1,3,0,0'
|
29
|
+
cid = "CLSID:1311F1ED-198B-11D6-8FF9-000103484A9A"
|
30
|
+
if(@session.client_nt5?)
|
31
|
+
cab = 'BbmbBarcodeReader2.CAB#version=2,1,0,0'
|
32
|
+
end
|
33
|
+
props = {
|
34
|
+
"id" => "BCReader",
|
35
|
+
"classid" => cid,
|
36
|
+
"codebase"=> @lookandfeel.resource_global(:activex, cab),
|
37
|
+
}
|
38
|
+
html << context.object(props)
|
39
|
+
end
|
40
|
+
html << super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
module UnavailableMethods
|
44
|
+
def unavailables(model)
|
45
|
+
unavailable = model.unavailable
|
46
|
+
unless unavailable.empty?
|
47
|
+
Unavailables.new(unavailable, @session, self)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
class BarcodeReader < HtmlGrid::SpanComposite
|
52
|
+
include HtmlGrid::FormMethods
|
53
|
+
COMPONENTS = {
|
54
|
+
[0,0] => :barcode_usb,
|
55
|
+
[1,0] => :barcode_reader,
|
56
|
+
[2,0] => :barcode_comport,
|
57
|
+
}
|
58
|
+
EVENT = 'scan'
|
59
|
+
FORM_ID = 'bcread'
|
60
|
+
FORM_NAME = 'bcread'
|
61
|
+
def barcode_usb(model)
|
62
|
+
if(!@session.client_nt5?)
|
63
|
+
link = HtmlGrid::Link.new(:barcode_usb, model, @session, self)
|
64
|
+
link.href = "http://www.ionetworks.com/support/epdrivers.jsp#E95"
|
65
|
+
link.target = "_blank"
|
66
|
+
link
|
67
|
+
end
|
68
|
+
end
|
69
|
+
def barcode_reader(model)
|
70
|
+
button = HtmlGrid::Button.new(:barcode_button, model, @session, self)
|
71
|
+
args = [
|
72
|
+
@lookandfeel.lookup(:barcode_none),
|
73
|
+
@lookandfeel.lookup(:barcode_empty),
|
74
|
+
]
|
75
|
+
com = 'this.form.barcode_comport'
|
76
|
+
argstr = args.join("', '")
|
77
|
+
button.set_attribute('onclick', "bc_read(#{com}, '#{argstr}')")
|
78
|
+
button
|
79
|
+
end
|
80
|
+
def barcode_comport(model)
|
81
|
+
input = HtmlGrid::Input.new(:barcode_comport, model, @session, self)
|
82
|
+
input.set_attribute('type', 'hidden')
|
83
|
+
val = @session.get_cookie_input(:comport)
|
84
|
+
if(!/[0-9]+/.match(val))
|
85
|
+
val = "-1"
|
86
|
+
end
|
87
|
+
input.value = val
|
88
|
+
input
|
89
|
+
end
|
90
|
+
end
|
91
|
+
class ClearOrder < HtmlGrid::SpanComposite
|
92
|
+
include HtmlGrid::FormMethods
|
93
|
+
FORM_ID = 'clear'
|
94
|
+
EVENT = :clear_order
|
95
|
+
COMPONENTS = {
|
96
|
+
[0,0] => :clear,
|
97
|
+
}
|
98
|
+
def clear(model)
|
99
|
+
button = HtmlGrid::Button.new(event, model, @session, self)
|
100
|
+
condition = "if(confirm('#{@lookandfeel.lookup(event.to_s << "_confirm")}'))"
|
101
|
+
condition << "this.form.submit();"
|
102
|
+
button.set_attribute('onclick', condition)
|
103
|
+
button
|
104
|
+
end
|
105
|
+
end
|
106
|
+
class CurrentAdditionalInformation < HtmlGrid::Composite
|
107
|
+
COMPONENTS = {
|
108
|
+
[0,0] => :reference,
|
109
|
+
[0,2] => :comment,
|
110
|
+
}
|
111
|
+
LABELS = true
|
112
|
+
VERTICAL = true
|
113
|
+
def comment(model)
|
114
|
+
input = HtmlGrid::Textarea.new(:comment, model, @session, self)
|
115
|
+
input.set_attribute('onKeyUp',
|
116
|
+
'if(this.value.length > 60) this.value=this.value.substring(0,60);')
|
117
|
+
input.value = model.comment
|
118
|
+
input.label = true
|
119
|
+
url = @lookandfeel._event_url(:ajax)
|
120
|
+
input.set_attribute('onchange', "update_order('#{url}', this.form)")
|
121
|
+
input.set_attribute('id', :comment)
|
122
|
+
input
|
123
|
+
end
|
124
|
+
def reference(model)
|
125
|
+
_input_value(:reference, model)
|
126
|
+
end
|
127
|
+
def _input_value(key, model)
|
128
|
+
input = HtmlGrid::InputText.new(key, model, @session, self)
|
129
|
+
url = @lookandfeel._event_url(:ajax)
|
130
|
+
input.set_attribute('onchange', "update_order('#{url}', this.form)")
|
131
|
+
input.set_attribute('id', key)
|
132
|
+
input
|
133
|
+
end
|
134
|
+
end
|
135
|
+
class CurrentPriorities < HtmlGrid::Composite
|
136
|
+
COMPONENTS = {
|
137
|
+
[0,0] => :priority,
|
138
|
+
[0,1,0] => :priority_0,
|
139
|
+
[0,1,1] => 'priority_0',
|
140
|
+
[0,2,0] => :priority_1,
|
141
|
+
[0,2,1] => 'priority_1',
|
142
|
+
[1,2] => 'priority_explain_1',
|
143
|
+
[0,3,0] => :priority_13,
|
144
|
+
[0,3,1] => 'priority_13',
|
145
|
+
[1,3] => 'priority_explain_13',
|
146
|
+
[0,4,0] => :priority_16,
|
147
|
+
[0,4,1] => 'priority_16',
|
148
|
+
[1,4] => 'priority_explain_16',
|
149
|
+
[0,5,0] => :priority_21,
|
150
|
+
[0,5,1] => 'priority_21',
|
151
|
+
[1,5] => 'priority_explain_21',
|
152
|
+
[0,6,0] => :priority_40,
|
153
|
+
[0,6,1] => 'priority_40',
|
154
|
+
[1,6] => 'priority_explain_40',
|
155
|
+
[0,7,0] => :priority_41,
|
156
|
+
[0,7,1] => 'priority_41',
|
157
|
+
[1,7] => 'priority_explain_41',
|
158
|
+
}
|
159
|
+
SYMBOL_MAP = {
|
160
|
+
:priority => HtmlGrid::LabelText,
|
161
|
+
}
|
162
|
+
def priority_input(model, num)
|
163
|
+
radio = HtmlGrid::InputRadio.new(:priority,
|
164
|
+
model, @session, self)
|
165
|
+
num = num.to_i
|
166
|
+
radio.value = num
|
167
|
+
radio.label = false
|
168
|
+
test = model.priority || @session.user_input(:priority)
|
169
|
+
if(test == num)
|
170
|
+
radio.set_attribute('checked', true)
|
171
|
+
end
|
172
|
+
url = @lookandfeel._event_url(:ajax)
|
173
|
+
script = "update_order('#{url}', this.form)"
|
174
|
+
radio.set_attribute('onclick', script)
|
175
|
+
radio
|
176
|
+
end
|
177
|
+
def priority_0(model)
|
178
|
+
priority_input(model, '')
|
179
|
+
end
|
180
|
+
def priority_1(model)
|
181
|
+
priority_input(model, 1)
|
182
|
+
end
|
183
|
+
def priority_13(model)
|
184
|
+
priority_input(model, 13)
|
185
|
+
end
|
186
|
+
def priority_16(model)
|
187
|
+
priority_input(model, 16)
|
188
|
+
end
|
189
|
+
def priority_21(model)
|
190
|
+
priority_input(model, 21)
|
191
|
+
end
|
192
|
+
def priority_40(model)
|
193
|
+
priority_input(model, 40)
|
194
|
+
end
|
195
|
+
def priority_41(model)
|
196
|
+
priority_input(model, 41)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
class CurrentToggleable < HtmlGrid::Composite
|
200
|
+
COMPONENTS = {
|
201
|
+
[0,0] => CurrentAdditionalInformation,
|
202
|
+
[1,0] => CurrentPriorities,
|
203
|
+
}
|
204
|
+
end
|
205
|
+
class TransferDat < HtmlGrid::SpanComposite
|
206
|
+
include HtmlGrid::FormMethods
|
207
|
+
COMPONENTS = {
|
208
|
+
[0,0] => :file_chooser,
|
209
|
+
[1,0] => :submit,
|
210
|
+
}
|
211
|
+
EVENT = :transfer
|
212
|
+
FORM_ID = 'transfer-dat'
|
213
|
+
FORM_NAME = 'transfer_dat'
|
214
|
+
SYMBOL_MAP = {
|
215
|
+
:file_chooser => HtmlGrid::InputFile,
|
216
|
+
}
|
217
|
+
TAG_METHOD = :multipart_form
|
218
|
+
def initialize(event, *args)
|
219
|
+
@event = event
|
220
|
+
super(*args)
|
221
|
+
end
|
222
|
+
def event
|
223
|
+
@event || super
|
224
|
+
end
|
225
|
+
end
|
226
|
+
class CurrentPositions < HtmlGrid::List
|
227
|
+
include Backorder
|
228
|
+
include ListPrices
|
229
|
+
include PositionMethods
|
230
|
+
CSS_CLASS = 'list'
|
231
|
+
if BBMB.config.enable_price_levels
|
232
|
+
COMPONENTS = {
|
233
|
+
[0,0] => :delete_position,
|
234
|
+
[1,0] => :quantity,
|
235
|
+
[2,0] => :description,
|
236
|
+
[3,0] => :backorder,
|
237
|
+
[4,0] => :price_base,
|
238
|
+
[5,0] => :price_levels,
|
239
|
+
[6,0] => :price2,
|
240
|
+
[7,0] => :price3,
|
241
|
+
[5,1] => :price4,
|
242
|
+
[6,1] => :price5,
|
243
|
+
[7,1] => :price6,
|
244
|
+
[8,0] => :total,
|
245
|
+
}
|
246
|
+
CSS_MAP = {
|
247
|
+
[0,0] => 'delete',
|
248
|
+
[1,0] => 'tiny right',
|
249
|
+
[2,0] => 'description',
|
250
|
+
[4,0,4,2] => 'right',
|
251
|
+
[8,0] => 'total',
|
252
|
+
}
|
253
|
+
CSS_HEAD_MAP = {
|
254
|
+
[1,0] => 'right',
|
255
|
+
[4,0] => 'right',
|
256
|
+
[5,0] => 'right',
|
257
|
+
[8,0] => 'right',
|
258
|
+
}
|
259
|
+
else
|
260
|
+
COMPONENTS = {
|
261
|
+
[0,0] => :delete_position,
|
262
|
+
[1,0] => :quantity,
|
263
|
+
[2,0] => :description,
|
264
|
+
[3,0] => :backorder,
|
265
|
+
[4,0] => :price_base,
|
266
|
+
[5,0] => :total,
|
267
|
+
}
|
268
|
+
CSS_MAP = {
|
269
|
+
[0,0] => 'delete',
|
270
|
+
[1,0] => 'tiny right',
|
271
|
+
[2,0] => 'description',
|
272
|
+
[4,0] => 'right',
|
273
|
+
[5,0] => 'total',
|
274
|
+
}
|
275
|
+
CSS_HEAD_MAP = {
|
276
|
+
[1,0] => 'right',
|
277
|
+
[4,0] => 'right',
|
278
|
+
[5,0] => 'right',
|
279
|
+
}
|
280
|
+
end
|
281
|
+
SORT_DEFAULT = :description
|
282
|
+
def delete_position(model)
|
283
|
+
super(model, :order_product)
|
284
|
+
end
|
285
|
+
def description(model)
|
286
|
+
position_modifier(model, :description, :search)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
class TermsOfService < HtmlGrid::Composite
|
290
|
+
COMPONENTS = {
|
291
|
+
[0,0] => :accept_terms,
|
292
|
+
[1,0] => "terms_of_service",
|
293
|
+
}
|
294
|
+
SYMBOL_MAP = {
|
295
|
+
:accept_terms => HtmlGrid::InputCheckbox,
|
296
|
+
}
|
297
|
+
def accept_terms(model)
|
298
|
+
model = @session.state._customer
|
299
|
+
check = HtmlGrid::InputCheckbox.new(:accept_terms, model, @session, self)
|
300
|
+
check.attributes['checked'] = !model.terms_last_accepted.nil?
|
301
|
+
check
|
302
|
+
end
|
303
|
+
end
|
304
|
+
class OrderConfirmation < HtmlGrid::Composite
|
305
|
+
COMPONENTS = {
|
306
|
+
[0,0] => :order_confirmation,
|
307
|
+
[1,0] => "order_confirmation_text",
|
308
|
+
}
|
309
|
+
SYMBOL_MAP = {
|
310
|
+
:order_confirmation => HtmlGrid::InputCheckbox,
|
311
|
+
}
|
312
|
+
end
|
313
|
+
class CurrentOrderForm < HtmlGrid::DivForm
|
314
|
+
include HtmlGrid::ErrorMessage
|
315
|
+
COMPONENTS = {
|
316
|
+
[0,0] => :toggle,
|
317
|
+
[0,1] => CurrentToggleable,
|
318
|
+
[0,2] => :order_total,
|
319
|
+
[1,2] => :total,
|
320
|
+
}
|
321
|
+
CSS_ID_MAP = { 1 => 'info', 2 => 'order-total' }
|
322
|
+
EVENT = :commit
|
323
|
+
FORM_ID = 'additional_info'
|
324
|
+
SORT_DEFAULT = :description
|
325
|
+
SYMBOL_MAP = {
|
326
|
+
:order_total => HtmlGrid::LabelText,
|
327
|
+
}
|
328
|
+
def init
|
329
|
+
submit = 3
|
330
|
+
if @lookandfeel.enabled?(:terms_of_service, false)
|
331
|
+
components.update [0,submit] => :toggle_terms,
|
332
|
+
[0,submit + 1] => TermsOfService
|
333
|
+
css_id_map.update submit + 1 => 'terms-of-service'
|
334
|
+
submit += 2
|
335
|
+
end
|
336
|
+
if BBMB.config.mail_confirm_reply_to && !@model.empty?
|
337
|
+
components.store [0,submit], :order_confirmation
|
338
|
+
css_id_map.update submit => 'order-confirmation'
|
339
|
+
submit += 1
|
340
|
+
end
|
341
|
+
components.store [0,submit], :submit
|
342
|
+
super
|
343
|
+
error_message
|
344
|
+
end
|
345
|
+
def order_confirmation(model)
|
346
|
+
OrderConfirmation.new(@session.state._customer, @session, self)
|
347
|
+
end
|
348
|
+
def toggle(model)
|
349
|
+
ms_open = " + #{@lookandfeel.lookup(:additional_info)}"
|
350
|
+
ms_close = " − #{@lookandfeel.lookup(:additional_info)}"
|
351
|
+
attrs = {
|
352
|
+
'css_class' => 'toggler',
|
353
|
+
'message_open' => ms_open,
|
354
|
+
'message_close' => ms_close,
|
355
|
+
'status' => toggle_status(model),
|
356
|
+
'togglee' => 'info',
|
357
|
+
}
|
358
|
+
dojo_tag('contenttoggler', attrs)
|
359
|
+
end
|
360
|
+
def toggle_status(model)
|
361
|
+
model.additional_info.empty? ? 'closed' : 'open'
|
362
|
+
end
|
363
|
+
def toggle_terms(model)
|
364
|
+
ms_open = " + #{@lookandfeel.lookup(:terms)}"
|
365
|
+
ms_close = " − #{@lookandfeel.lookup(:terms)}"
|
366
|
+
attrs = {
|
367
|
+
'css_class' => 'toggler',
|
368
|
+
'message_open' => ms_open,
|
369
|
+
'message_close' => ms_close,
|
370
|
+
'status' => toggle_terms_status,
|
371
|
+
'togglee' => 'terms-of-service',
|
372
|
+
}
|
373
|
+
dojo_tag('contenttoggler', attrs)
|
374
|
+
end
|
375
|
+
def toggle_terms_status
|
376
|
+
@session.state._customer.terms_last_accepted ? 'closed' : 'open'
|
377
|
+
end
|
378
|
+
def total(model)
|
379
|
+
span = HtmlGrid::Span.new(model, @session, self)
|
380
|
+
span.css_id = 'total'
|
381
|
+
span.value = model.total
|
382
|
+
span
|
383
|
+
end
|
384
|
+
def submit(model)
|
385
|
+
super unless(model.empty?)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
class Unavailables < HtmlGrid::List
|
389
|
+
BACKGROUND_ROW = 'bg'
|
390
|
+
BACKGROUND_SUFFIX = ''
|
391
|
+
CSS_CLASS = 'list'
|
392
|
+
COMPONENTS = {
|
393
|
+
[0,0] => :delete_position,
|
394
|
+
[1,0] => :quantity,
|
395
|
+
[2,0] => :description,
|
396
|
+
}
|
397
|
+
CSS_MAP = {
|
398
|
+
[0,0] => 'delete',
|
399
|
+
[1,0] => 'tiny right',
|
400
|
+
[2,0] => 'description',
|
401
|
+
[3,0] => 'right',
|
402
|
+
}
|
403
|
+
SORT_DEFAULT = nil
|
404
|
+
OMIT_HEADER = true
|
405
|
+
def delete_position(model)
|
406
|
+
link = HtmlGrid::Link.new(:delete, model, @session, self)
|
407
|
+
url = @lookandfeel.base_url
|
408
|
+
id = @list_index
|
409
|
+
event = 'delete_unavailable'
|
410
|
+
link.href = "javascript:delete_position('#{url}', '#{event}', '#{id}');"
|
411
|
+
link
|
412
|
+
end
|
413
|
+
def description(model)
|
414
|
+
span = HtmlGrid::Span.new(model, @session, self)
|
415
|
+
parts = [model.description].compact
|
416
|
+
[:ean13, :pcode].each { |key|
|
417
|
+
if(value = model.send(key))
|
418
|
+
parts.push(sprintf("%s: %s", @lookandfeel.lookup(key), value))
|
419
|
+
end
|
420
|
+
}
|
421
|
+
span.value = @lookandfeel.lookup(:unavailable, parts.join(', '))
|
422
|
+
span
|
423
|
+
end
|
424
|
+
end
|
425
|
+
class CurrentOrderComposite < HtmlGrid::DivComposite
|
426
|
+
include UnavailableMethods
|
427
|
+
COMPONENTS = {
|
428
|
+
[0,0] => Search,
|
429
|
+
[1,0] => :position_count,
|
430
|
+
[2,0] => :barcode_reader,
|
431
|
+
[3,0] => :order_transfer,
|
432
|
+
[4,0] => :clear_order,
|
433
|
+
[0,1] => CurrentPositions,
|
434
|
+
[0,2] => :unavailables,
|
435
|
+
}
|
436
|
+
CSS_ID_MAP = [ 'toolbar' ]
|
437
|
+
def init
|
438
|
+
if(!@model.empty? || @lookandfeel.enabled?(:additional_info_first))
|
439
|
+
components.store([1,2], CurrentOrderForm)
|
440
|
+
end
|
441
|
+
super
|
442
|
+
end
|
443
|
+
def barcode_reader(model)
|
444
|
+
if(@session.client_activex? && !@lookandfeel.disabled?(:barcode_reader))
|
445
|
+
BarcodeReader.new(model, @session, self)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
def clear_order(model)
|
449
|
+
unless(model.empty?)
|
450
|
+
ClearOrder.new(model, @session, self)
|
451
|
+
end
|
452
|
+
end
|
453
|
+
def order_transfer(model)
|
454
|
+
unless(@lookandfeel.disabled?(:transfer_dat))
|
455
|
+
TransferDat.new(:order_transfer, model, @session, self)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
def position_count(model)
|
459
|
+
span = HtmlGrid::Span.new(model, @session, self)
|
460
|
+
span.value = @lookandfeel.lookup(:positions, model.size)
|
461
|
+
span.css_class = 'guide'
|
462
|
+
span
|
463
|
+
end
|
464
|
+
end
|
465
|
+
class CurrentOrder < Template
|
466
|
+
include HtmlGrid::DojoToolkit::DojoTemplate
|
467
|
+
include ActiveX
|
468
|
+
CONTENT = CurrentOrderComposite
|
469
|
+
DOJO_DEBUG = BBMB.config.debug
|
470
|
+
DOJO_PREFIX = {
|
471
|
+
'ywesee' => '../javascript',
|
472
|
+
}
|
473
|
+
DOJO_REQUIRE = [ 'dojo.widget.*', 'ywesee.widget.*',
|
474
|
+
'ywesee.widget.ContentToggler' ] #, 'dojo.widget.Tooltip' ]
|
475
|
+
JAVASCRIPTS = [
|
476
|
+
"bcreader",
|
477
|
+
"order",
|
478
|
+
]
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|
482
|
+
end
|