Class: Ig3tool::ProtjesGlade

Inherits:
GladeHelper show all
Defined in:
lib/ui/protjes.rb

Constant Summary collapse

["Producten", "Producten"]
ICON =
"doos_xsmall.png"

Constants inherited from GladeHelper

GladeHelper::GLADE_DIR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GladeHelper

#_get_widget, #add_window_colorer, #load_sounds, #make_debugger_combo, #make_eval_widget, #make_status_combo, #number_eval_widget, #play, #present, #show

Constructor Details

#initializeProtjesGlade

Returns a new instance of ProtjesGlade.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/ui/protjes.rb', line 21

def initialize
	super("protjes.glade")
@tabs = @glade.get_widget("tabs")

# MANAGE TAB
@manage_debuggers = @glade.get_widget("add_debuggers")
@manage_plebs = @glade.get_widget("add_plebs")
@manage_members = @glade.get_widget("add_members")
@manage_edit = @glade.get_widget("add_edit")
@add_notification = @glade.get_widget("add_notification")
@add_barcode = @glade.get_widget("add_barcode")
@add_name = @glade.get_widget("add_name")
@add_stock = @glade.get_widget("add_stock")
@add_prodcat = @glade.get_widget("add_prodcat")
@add_categories = @glade.get_widget("add_categories")
@continuous_stock = @glade.get_widget("continuous_stock_check")

@categories = $client.product_categories.collect {|x| x.name}.sort


@add_products = @glade.get_widget("add_products")
@add_products.model = @add_products_store = Gtk::ListStore.new(Object, String)
l = Gtk::CellRendererText.new
@add_products.insert_column(-1, "product", l, :text => 1)
@add_products.enable_search = true



# PURCHASE TAB
@purchase_debuggers_orig = @glade.get_widget("purchase_debuggers_orig")
@purchase_plebs_orig = @glade.get_widget("purchase_plebs_orig")
@purchase_members_orig = @glade.get_widget("purchase_members_orig")
@purchase_last = @glade.get_widget("purchase_last")
@purchase_debugger = @glade.get_widget("purchase_debugger")
@purchase_debuggers = @glade.get_widget("purchase_debuggers")
@purchase_plebs = @glade.get_widget("purchase_plebs")
@purchase_members = @glade.get_widget("purchase_members")
@purchase_barcode = @glade.get_widget("purchase_barcode")
@purchase_name = @glade.get_widget("purchase_name")
@purchase_stock = @glade.get_widget("purchase_stock")
@purchase_category = @glade.get_widget("purchase_category")
@purchase_categories = @glade.get_widget("purchase_categories")
@purchase_notification = @glade.get_widget("purchase_notification")
@purchase_amount = @glade.get_widget("purchase_amount")
@purchase_price = @glade.get_widget("purchase_price")
@purchase_date = @glade.get_widget("purchase_date")
@purchase_accept = @glade.get_widget("purchase_accept")
  
@purchase_products = @glade.get_widget("purchase_products")
@purchase_products.model = @purchase_products_store = Gtk::ListStore.new(Object, String)
l = Gtk::CellRendererText.new
@purchase_products.insert_column(-1, "product", l, :text => 1)
@purchase_products.enable_search = true

# STOCK TAB
@stock_notification = @glade.get_widget("stock_notification")
@stock_categories = @glade.get_widget("stock_categories")
@stock_barcode = @glade.get_widget("stock_barcode")
@stock_stock = @glade.get_widget("stock_stock")
@stock_category = @glade.get_widget("stock_category")
@stock_name = @glade.get_widget("stock_name")
@stock_debugger = @glade.get_widget("stock_debugger")
@stock_stock_new = @glade.get_widget("stock_stock_new")
@stock_apply = @glade.get_widget("stock_apply")

@stock_products = @glade.get_widget("stock_products")
@stock_products.model = @stock_products_store = Gtk::ListStore.new(Object, String)
l = Gtk::CellRendererText.new
@stock_products.insert_column(-1, "product", l, :text => 1)
@stock_products.enable_search = true

# LOG TAB
@log_notification = @glade.get_widget("log_notification")
@log_categories = @glade.get_widget("log_categories")
@log_barcode = @glade.get_widget("log_barcode")
@log_name = @glade.get_widget("log_name")
@log_products = @glade.get_widget("log_products")
@log_products.model = @log_products_store = Gtk::ListStore.new(Object, String)
l = Gtk::CellRendererText.new
@log_products.insert_column(-1, "product", l, :text => 1)
@log_products.enable_search = true


@purchase_log = @glade.get_widget("purchase_log")
@purchase_log.model = @purchase_log_store = Gtk::ListStore.new(Object, String, String, String, String, String)
l = Gtk::CellRendererText.new
@purchase_log.insert_column(-1, "time", l) do |tvc, cell, m, iter|
	cell.text = Time.parse(iter[0].time).strftime("%d/%m/%y")
end
@purchase_log.insert_column(-1, "barcode", l) do |tvc, cell, m, iter|
	cell.text = iter[0].product
end
@purchase_log.insert_column(-1, "debugger", l) do |tvc, cell, m, iter|
	cell.text = iter[0].debugger
end
@purchase_log.insert_column(-1, "amount", l) do |tvc, cell, m, iter|
	cell.text = iter[0].count
end
@purchase_log.insert_column(-1, "price", l) do |tvc, cell, m, iter|
	cell.text = iter[0].cost
end

# sales LOG TAB
@slog_notification = @glade.get_widget("slog_notification")
@slog_categories = @glade.get_widget("slog_categories")
@slog_barcode = @glade.get_widget("slog_barcode")
@slog_name = @glade.get_widget("slog_name")
@slog_products = @glade.get_widget("slog_products")
@slog_products.model = @slog_products_store = Gtk::ListStore.new(Object, String)
l = Gtk::CellRendererText.new
@slog_products.insert_column(-1, "product", l, :text => 1)
@slog_products.enable_search = true


@spurchase_log = @glade.get_widget("spurchase_log")
@spurchase_log.model = @spurchase_log_store = Gtk::ListStore.new(Object, String, String, String, String, String, String)
l = Gtk::CellRendererText.new
@spurchase_log.insert_column(-1, "time", l) do |tvc, cell, m, iter|
	cell.text = Time.parse(iter[0].time).strftime("%d/%m/%y")
end
@spurchase_log.insert_column(-1, "barcode", l) do |tvc, cell, m, iter|
	cell.text = iter[0].product
end
@spurchase_log.insert_column(-1, "debugger", l) do |tvc, cell, m, iter|
	cell.text = iter[0].debugger
end
@spurchase_log.insert_column(-1, "status", l) do |tvc, cell, m, iter|
	cell.text = iter[0].status
end
@spurchase_log.insert_column(-1, "amount", l) do |tvc, cell, m, iter|
	cell.text = iter[0].count
end
@spurchase_log.insert_column(-1, "price", l) do |tvc, cell, m, iter|
	cell.text = iter[0].price
end





# ALL 

cat_model = Gtk::ListStore.new(String)
cat2_model = Gtk::ListStore.new(String)
cat3_model = Gtk::ListStore.new(String)
cat4_model = Gtk::ListStore.new(String)
cat5_model = Gtk::ListStore.new(String)
cat6_model = Gtk::ListStore.new(String)
cat_model.prepend[0] = "all products"
cat3_model.prepend[0] = "all products"
cat4_model.prepend[0] = "all products"
cat5_model.prepend[0] = "all products"
cat6_model.prepend[0] = "all products"
@categories.each do |cat|
	r    = cat_model.append
	r[0] = cat
	r2    = cat2_model.append
	r2[0] = cat
	r3    = cat3_model.append
	r3[0] = cat
	r4    = cat4_model.append
	r4[0] = cat
	r5    = cat5_model.append
	r5[0] = cat
	r6    = cat6_model.append
	r6[0] = cat
end
@add_categories.model  = cat_model
@add_categories.active = 0
@add_prodcat.model  = cat2_model
@add_prodcat.active = -1
@purchase_categories.model  = cat3_model
@purchase_categories.active = 0
@stock_categories.model  = cat4_model
@stock_categories.active = 0
@log_categories.model  = cat5_model
@log_categories.active = 0
@slog_categories.model  = cat6_model
@slog_categories.active = 0

@continuous_stock.active = false

toggle_purchase_fields(false)
	_add_clear
	_purchase_clear

#signal handlers
@handler1 = @add_barcode.signal_connect("changed"){ barcode_changed }
@handler2 = @purchase_barcode.signal_connect("changed"){ barcode_changed }
@handler3 = @stock_barcode.signal_connect("changed"){ barcode_changed }
@handler6 = @log_barcode.signal_connect("changed"){ barcode_changed }
@handler7 = @log_barcode.signal_connect("activate"){ _log_show(@log_barcode.text.strip) ; _update_log(@log_barcode.text.strip) }

@handler4 = @purchase_price.signal_connect("changed"){ price_amount_changed }
@handler5 = @purchase_amount.signal_connect("changed"){ price_amount_changed }

%w(focus-out-event activate).each do |s|
	@purchase_amount.signal_connect s do
		number_eval_widget(@purchase_amount, "0.0")
		if @purchase_price.text.strip.to_c == 0
			@purchase_price.text = (@purchase_amount.text.strip.to_i * @purchase_debuggers_orig.text.to_f).to_s
		end
		false
	end
end
#@handler8 = @add_categories.signal_connect("changed"){ refresh }
@handler9 = @purchase_categories.signal_connect("changed"){ refresh }
@handler10 = @stock_categories.signal_connect("changed"){ refresh }
@handler11 = @log_categories.signal_connect("changed"){ refresh }
@handler12 = @slog_categories.signal_connect("changed"){ refresh }

@handler15 = @slog_barcode.signal_connect("changed"){ barcode_changed }
@handler16 = @slog_barcode.signal_connect("activate"){ _slog_show(@log_barcode.text.strip) ; _update_slog(@log_barcode.text.strip) }

make_debugger_combo(@purchase_debugger)
make_debugger_combo(@stock_debugger)

[@purchase_amount, @purchase_price, @purchase_plebs, @purchase_debuggers,
 @purchase_members, @manage_debuggers, @manage_plebs, @manage_members,
 @stock_stock_new].each do |w|
	make_eval_widget w
end

  @handler69 = @purchase_debugger.signal_connect("changed"){ purchase_debugger_changed }
  @debugger_stamp = nil

end

Instance Attribute Details

#gladeObject (readonly)

Returns the value of attribute glade.



19
20
21
# File 'lib/ui/protjes.rb', line 19

def glade
  @glade
end

Instance Method Details

#accept_toogled(widget) ⇒ Object



521
522
# File 'lib/ui/protjes.rb', line 521

def accept_toogled(widget)
end

#add_apply(widget) ⇒ Object



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/ui/protjes.rb', line 557

def add_apply(widget)
	begin
		@add_notification.text = "saving product..."
		toggle_price_fields(true, false)
     barcode = @add_barcode.text.strip
		raise Needed, "please scan a barcode" if @add_barcode.text.strip.empty?
		raise Needed, "please enter a descriptive name" if @add_name.text.strip.empty?
		raise Needed, "please select a category" if @add_prodcat.active == -1
		if @continuous_stock.active?
			cs = 1
		else
			cs = 0
		end
		$client.product_save!("barcode" => @add_barcode.text.strip, "name" => @add_name.text.strip, "continuous_stock" => cs, "dprice" => @manage_debuggers.text.strip.to_c, "mprice" => @manage_members.text.strip.to_c, "nmprice" => @manage_plebs.text.strip.to_c, "category" => @categories[@add_prodcat.active])
		_update_add_products(false)
		@add_notification.text = "the imps saved the product!"
		_add_clear(false)
     _add_show(barcode)
     _purchase_show(barcode)
	rescue Exception => e
		@add_notification.text = e.message
	end
end

#add_cancel(widget) ⇒ Object



434
435
436
437
# File 'lib/ui/protjes.rb', line 434

def add_cancel(widget)
toggle_price_fields(true, false)
_add_clear
end

#add_delete(w) ⇒ Object



492
493
494
495
496
497
498
499
500
501
# File 'lib/ui/protjes.rb', line 492

def add_delete(w)
	begin
	barcode = @add_barcode.text.strip
	$client.product_remove!("barcode" => barcode)
	_add_clear
  _update_add_products(false)
	rescue Exception => e
		@add_notification.text = e.message
	end
end

#add_edit(widget) ⇒ Object



405
406
407
# File 'lib/ui/protjes.rb', line 405

def add_edit(widget)
toggle_price_fields(false)
end

#afronden(i) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/ui/protjes.rb', line 294

def afronden(i)
	m = i % 5
	case m
	when 0
		i
	when 1
		i - 1
	when 2
		i - 2
	when 3
		i + 2
	when 4
		i + 1
	end
end

#barcode_changedObject



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/ui/protjes.rb', line 337

def barcode_changed()
	case @tabs.page
	when 0
		_purchase_clear(false)
		toggle_purchase_fields(false)
	when 1
		_purchase_clear(false)
		toggle_purchase_fields(false)
	when 2
		_stock_clear(false)
		toggle_stock_field(false)
	when 3
		_log_clear(false)
	when 4
		_slog_clear(false)
	end
end

#barcode_del(widget, arg0, arg1) ⇒ Object



334
335
# File 'lib/ui/protjes.rb', line 334

def barcode_del(widget, arg0, arg1)
end

#barcode_ins(widget, arg0, arg1, arg2) ⇒ Object



331
332
# File 'lib/ui/protjes.rb', line 331

def barcode_ins(widget, arg0, arg1, arg2)
end

#changed(widget) ⇒ Object



468
469
470
# File 'lib/ui/protjes.rb', line 468

def changed(widget)
  #puts "changed() is not implemented yet."
end

#check_purchase_debugger_resetObject



254
255
256
257
258
# File 'lib/ui/protjes.rb', line 254

def check_purchase_debugger_reset
  if @debugger_stamp.nil? or ((Time.now - @debugger_stamp).to_i > 300) 
    @purchase_debugger.active = -1
  end
end

#debuggers_act(widget) ⇒ Object



518
519
# File 'lib/ui/protjes.rb', line 518

def debuggers_act(widget)
end

#get_debugger(widget) ⇒ Object



260
261
262
# File 'lib/ui/protjes.rb', line 260

def get_debugger(widget)
	widget.active_iter[0]
end

#log_cancel(w) ⇒ Object



438
439
440
441
# File 'lib/ui/protjes.rb', line 438

def log_cancel(w)
	_log_clear
   _update_log
end

#log_select(widget, path, column) ⇒ Object



595
596
597
598
599
600
# File 'lib/ui/protjes.rb', line 595

def log_select(widget, path, column)
prodentry = widget.model.get_iter(path)
barcode = prodentry[0].barcode
_log_show(barcode)
_update_log(barcode)
end

#members_act(widget) ⇒ Object



328
329
# File 'lib/ui/protjes.rb', line 328

def members_act(widget)
end

#notification_focus_in_event_cb(widget, arg0) ⇒ Object



550
551
# File 'lib/ui/protjes.rb', line 550

def notification_focus_in_event_cb(widget, arg0)
end

#plebs_act(widget) ⇒ Object



431
432
# File 'lib/ui/protjes.rb', line 431

def plebs_act(widget)
end

#price_amount_changedObject



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/ui/protjes.rb', line 264

def price_amount_changed
	amount = @purchase_amount.text.strip.to_i
	price = @purchase_price.text.strip.to_c
	amount = @purchase_amount.text.strip.to_i
	@purchase_notification.text = "please enter a valid amount" if amount == 0
	@purchase_notification.text = "please enter a valid price (in euro's)" if price == 0
	if amount != 0  and price != 0
		begin
			@purchase_notification.text = "" 
			old = @purchase_debuggers_orig.text
			oldm = @purchase_members_orig.text
			oldp = @purchase_plebs_orig.text
			new = price.to_f / amount.to_f
			memb_ratio = (oldm.to_f / old.to_f)
			plebs_ratio = (oldp.to_f / old.to_f)
			newp = (new.to_f * plebs_ratio).to_i
			newm = (new.to_f * memb_ratio).to_i
			@purchase_debuggers.text = new.to_i.from_c.to_s
			@purchase_members.text = afronden(newm).from_c.to_s
			@purchase_plebs.text = afronden(newp).from_c.to_s
			#@purchase_accept.active = true
		rescue Exception => e
			@purchase_debuggers.text = new.to_i.from_c.to_s
			@purchase_members.text = afronden(new.to_i).from_c.to_s
			@purchase_plebs.text = afronden(new.to_i).from_c.to_s
			@purchase_notification.text = "no (smart) price suggestions could be made"
		end
	end
end

#price_del(widget, arg0, arg1) ⇒ Object



476
477
# File 'lib/ui/protjes.rb', line 476

def price_del(widget, arg0, arg1)
end

#price_ins(widget, arg0, arg1, arg2) ⇒ Object



529
530
# File 'lib/ui/protjes.rb', line 529

def price_ins(widget, arg0, arg1, arg2)
end

#purchaseObject



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/ui/protjes.rb', line 312

def purchase
	begin
		if @purchase_accept.active?
			barcode = @purchase_barcode.text.strip
			$client.product_save!("barcode" => barcode, "dprice" => @purchase_debuggers.text.strip.to_c, "mprice" => @purchase_members.text.strip.to_c, "nmprice" => @purchase_plebs.text.strip.to_c)
		end

		raise "Refusing to update stock: price == 0 !" if @purchase_price.text.strip.to_c == 0
		$client.product_purchase!("debugger" => get_debugger(@purchase_debugger).username, "date" => @purchase_date.text.strip, "barcode" => @purchase_barcode.text.strip, "amount" => @purchase_amount.text.strip.to_i,  "price" => @purchase_price.text.strip.to_c)
		_purchase_clear
		@purchase_notification.text = "the imps noted this purchase..."	
	rescue Exception => e
		@purchase_notification.text = e.message
	end
end

#purchase_cancel(widget) ⇒ Object



524
525
526
527
# File 'lib/ui/protjes.rb', line 524

def purchase_cancel(widget)
_purchase_clear
  check_purchase_debugger_reset
end

#purchase_debugger_changedObject



249
250
251
252
# File 'lib/ui/protjes.rb', line 249

def purchase_debugger_changed
  puts "debugger changed"
  @debugger_stamp = Time.now
end

#purchase_select(widget, path, column) ⇒ Object



586
587
588
589
590
# File 'lib/ui/protjes.rb', line 586

def purchase_select(widget, path, column)
prodentry = widget.model.get_iter(path)
_add_show(prodentry[0].barcode)
_purchase_show(prodentry[0].barcode)
end

#refresh(widget = nil) ⇒ Object



503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/ui/protjes.rb', line 503

def refresh(widget=nil)
case @tabs.page
when 0
_update_add_products(false)
when 1
_update_purchase_products(false)
when 2
_update_stock_products(false)
when 3
_update_log_products(false)
when 4
_update_slog_products(false)
end
end

#refresh_slog(w) ⇒ Object



458
459
460
461
462
463
464
465
466
# File 'lib/ui/protjes.rb', line 458

def refresh_slog(w)
	barcode = @slog_barcode.text.strip
	begin
		p = $client.product_lookup(barcode)
		_update_slog(barcode)
	rescue Needed => e
		_update_slog
	end
end

#refreshlog(w) ⇒ Object



449
450
451
452
453
454
455
456
457
# File 'lib/ui/protjes.rb', line 449

def refreshlog(w)
	barcode = @log_barcode.text.strip
	begin
		p = $client.product_lookup(barcode)
		_update_log(barcode)
	rescue Needed => e
		_update_log
	end
end

#select(widget, path, column) ⇒ Object



581
582
583
584
585
# File 'lib/ui/protjes.rb', line 581

def select(widget, path, column)
prodentry = widget.model.get_iter(path)
_add_show(prodentry[0].barcode)
_purchase_show(prodentry[0].barcode)
end

#select_from_log(widget, path, column) ⇒ Object



601
602
603
604
605
606
# File 'lib/ui/protjes.rb', line 601

def select_from_log(widget, path, column)
prodentry = widget.model.get_iter(path)
barcode = prodentry[0].product
_log_show(barcode)
_update_log(barcode)
end

#select_from_slog(widget, path, column) ⇒ Object



613
614
615
616
617
618
# File 'lib/ui/protjes.rb', line 613

def select_from_slog(widget, path, column)
prodentry = widget.model.get_iter(path)
barcode = prodentry[0].product
_slog_show(barcode)
_update_slog(barcode)
end

#slog_cancel(w) ⇒ Object



442
443
444
445
# File 'lib/ui/protjes.rb', line 442

def slog_cancel(w)
	_slog_clear
   _update_slog
end

#slog_select(widget, path, column) ⇒ Object



607
608
609
610
611
612
# File 'lib/ui/protjes.rb', line 607

def slog_select(widget, path, column)
prodentry = widget.model.get_iter(path)
barcode = prodentry[0].barcode
_slog_show(barcode)
_update_slog(barcode)
end

#smart_search(widget) ⇒ Object



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/ui/protjes.rb', line 409

def smart_search(widget)
case @tabs.page
when 0
	barcode = @add_barcode.text.strip
	_add_show(barcode)
	_purchase_show(barcode)
when 1
	barcode = @purchase_barcode.text.strip
	_add_show(barcode)
	_purchase_show(barcode)
when 2
	barcode = @stock_barcode.text.strip
	_stock_show(barcode)
when 3
	barcode = @stock_barcode.text.strip
	_log_show(barcode)
when 4
	barcode = @stock_barcode.text.strip
	_slog_show(barcode)
end
end

#stock_apply(widget) ⇒ Object



479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/ui/protjes.rb', line 479

def stock_apply(widget)
begin
	raise IG3Error, "select a debugger please!" if @stock_debugger.active == -1
	bar = @stock_barcode.text.strip
$client.product_adjust_stock!("barcode" => bar, "stock" => @stock_stock_new.text.strip.to_i, "debugger" => get_debugger(@stock_debugger).username)
_stock_clear
@stock_notification.text = "stock update saved!"
_stock_show(bar)
rescue Exception => e
@stock_notification.text = e.message
end
end

#stock_cancel(widget) ⇒ Object



472
473
474
# File 'lib/ui/protjes.rb', line 472

def stock_cancel(widget)
_stock_clear
end

#stock_select(widget, path, column) ⇒ Object



591
592
593
594
# File 'lib/ui/protjes.rb', line 591

def stock_select(widget, path, column)
prodentry = widget.model.get_iter(path)
_stock_show(prodentry[0].barcode)
end

#stock_to_apply(widget) ⇒ Object



553
554
555
# File 'lib/ui/protjes.rb', line 553

def stock_to_apply(widget)
@stock_apply.grab_focus
end

#tabfocus(widget, a, b) ⇒ Object



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/ui/protjes.rb', line 532

def tabfocus(widget, a, b)
case b
when 0
	_update_add_products
when 1
	_update_purchase_products
    check_purchase_debugger_reset
when 2
	_update_stock_products
when 3
	_update_log_products
	_update_log
when 4
	_update_slog_products
	_update_slog
end
end

#to_purchase(w) ⇒ Object



446
447
448
# File 'lib/ui/protjes.rb', line 446

def to_purchase(w)
	@tabs.page = 1
end

#toggle_price_fields(from_save, bool = nil) ⇒ Object



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/ui/protjes.rb', line 355

def toggle_price_fields(from_save, bool=nil)
   # if from_save  = true the saving of prices gets skipped
	bool = (not @manage_debuggers.sensitive?) if bool.nil?
	@manage_debuggers.sensitive = bool
	@manage_debuggers.editable = bool
	@manage_plebs.sensitive = bool
	@manage_plebs.editable = bool
	@manage_members.sensitive = bool
	@manage_members.editable = bool
	if bool
		@manage_edit.image = Gtk::Image.new(Gtk::Stock::SAVE, Gtk::IconSize::BUTTON)
		@manage_edit.label = Gtk::Stock::SAVE
	else
		unless from_save
			begin
				barcode = @add_barcode.text.strip
				$client.product_save!("barcode" => barcode, "dprice" => @manage_debuggers.text.strip.to_c, "mprice" => @manage_members.text.strip.to_c, "nmprice" => @manage_plebs.text.strip.to_c)

				@add_notification.text = "prices saved!"
				_add_show(barcode)
			rescue Exception => e
				puts e.backtrace
				@add_notification.text = e.message
			end
		end
		@manage_edit.image = Gtk::Image.new(Gtk::Stock::EDIT, Gtk::IconSize::BUTTON)
		@manage_edit.label = Gtk::Stock::EDIT
	end
end

#toggle_purchase_fields(bool) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/ui/protjes.rb', line 385

def toggle_purchase_fields(bool)
	@purchase_debuggers.sensitive = bool
	@purchase_debuggers.editable = bool
	@purchase_plebs.sensitive = bool
	@purchase_plebs.editable = bool
	@purchase_members.sensitive = bool
	@purchase_members.editable = bool
	#@purchase_date.sensitive = bool
	#@purchase_date.editable = bool
	@purchase_amount.sensitive = bool
	@purchase_amount.editable = bool
	@purchase_price.sensitive = bool
	@purchase_price.editable = bool
end

#toggle_stock_field(bool) ⇒ Object



400
401
402
403
# File 'lib/ui/protjes.rb', line 400

def toggle_stock_field(bool)
	@stock_stock_new.sensitive = bool
	@stock_stock_new.editable = bool
end