sandoz.bbmb.ch 1.0.0

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +26 -0
  4. data/Gemfile +12 -0
  5. data/History.txt +6 -0
  6. data/LICENSE +339 -0
  7. data/Rakefile +21 -0
  8. data/doc/index.rbx +14 -0
  9. data/doc/resources/activex/BbmbBarcodeReader.CAB +0 -0
  10. data/doc/resources/activex/BbmbBarcodeReader2.CAB +0 -0
  11. data/doc/resources/bbmb.css +301 -0
  12. data/doc/resources/errors/appdown.html +14 -0
  13. data/doc/resources/javascript/bcreader.js +131 -0
  14. data/doc/resources/javascript/order.js +65 -0
  15. data/doc/resources/javascript/widget/ContentToggler.js +60 -0
  16. data/doc/resources/javascript/widget/__package__.js +2 -0
  17. data/doc/resources/javascript/widget/templates/ContentToggler.html +4 -0
  18. data/doc/resources/logo.png +0 -0
  19. data/lib/bbmb/html/util/lookandfeel.rb +202 -0
  20. data/lib/bbmb/sandoz.rb +4 -0
  21. data/lib/bbmb/sandoz/html/state/viral/customer.rb +25 -0
  22. data/lib/bbmb/sandoz/version.rb +5 -0
  23. data/lib/bbmb/util/csv_importer.rb +123 -0
  24. data/readme.md +28 -0
  25. data/sandoz.bbmb.ch.gemspec +45 -0
  26. data/test/rcov +2 -0
  27. data/test/selenium.rb +1687 -0
  28. data/test/selenium/selenium-server.jar +0 -0
  29. data/test/selenium/test_current_order.rb +336 -0
  30. data/test/selenium/test_customer.rb +363 -0
  31. data/test/selenium/test_customers.rb +92 -0
  32. data/test/selenium/test_favorites.rb +257 -0
  33. data/test/selenium/test_favorites_result.rb +81 -0
  34. data/test/selenium/test_history.rb +112 -0
  35. data/test/selenium/test_login.rb +112 -0
  36. data/test/selenium/test_orders.rb +111 -0
  37. data/test/selenium/test_result.rb +157 -0
  38. data/test/selenium/unit.rb +146 -0
  39. data/test/stub/http_server.rb +140 -0
  40. data/test/stub/persistence.rb +58 -0
  41. data/test/suite.rb +15 -0
  42. data/test/util/data/Artikel.TXT +50 -0
  43. data/test/util/data/Kunden.TXT +14 -0
  44. data/test/util/test_csv_importer.rb +136 -0
  45. metadata +414 -0
@@ -0,0 +1,60 @@
1
+ dojo.provide("ywesee.widget.ContentToggler");
2
+ dojo.require("dojo.widget.*");
3
+ dojo.require("dojo.lfx.html");
4
+
5
+ ywesee.widget.ContentToggler = function() {
6
+ dojo.widget.HtmlWidget.call(this);
7
+
8
+ this.widgetType = "ContentToggler";
9
+ this.templatePath = dojo.uri.dojoUri("../javascript/widget/templates/ContentToggler.html");
10
+
11
+ this.css_class = 'toggler';
12
+ this.togglee = '';
13
+ this.message_open = '';
14
+ this.message_close = '';
15
+ this.status = '';
16
+ this.duration = 1;
17
+
18
+ this.toggleContent = function() {
19
+ var tmp = this.status;
20
+ if(tmp == 'change') return;
21
+ this.status = 'change';
22
+ if(tmp == 'open') {
23
+ this.implode();
24
+ } else {
25
+ this.explode();
26
+ }
27
+ }
28
+ this.implode = function() {
29
+ var _this = this;
30
+ var callback = function() {
31
+ _this.toggler.innerHTML = _this.message_open;
32
+ _this.status = 'closed';
33
+ };
34
+ dojo.lfx.html.wipeOut(this.togglee, this.duration,
35
+ dojo.lfx.easeOut, callback).play();
36
+ }
37
+ this.explode = function(){
38
+ var _this = this;
39
+ var callback = function() {
40
+ _this.toggler.innerHTML = _this.message_close;
41
+ _this.status = 'open';
42
+ };
43
+ dojo.lfx.html.wipeIn(this.togglee, this.duration,
44
+ dojo.lfx.easeOut, callback).play();
45
+ }
46
+ this.fillInTemplate = function() {
47
+ if(this.status == 'closed') {
48
+ this.implode();
49
+ } else {
50
+ this.toggler.innerHTML = this.message_close;
51
+ }
52
+ this.duration = 500;
53
+ this.toggler.className = this.css_class;
54
+ }
55
+ }
56
+
57
+
58
+ dojo.inherits(ywesee.widget.ContentToggler, dojo.widget.HtmlWidget);
59
+ dojo.widget.tags.addParseTreeHandler("dojo:contenttoggler");
60
+
@@ -0,0 +1,2 @@
1
+ dojo.provide("ywesee.widget");
2
+ dojo.widget.manager.registerWidgetPackage("ywesee.widget");
@@ -0,0 +1,4 @@
1
+ <div
2
+ dojoAttachPoint="toggler"
3
+ dojoAttachEvent="onClick: toggleContent;">
4
+ </div>
Binary file
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env ruby
2
+ # Html::Util::Lookandfeel -- bbmb.ch -- 15.09.2006 -- hwyss@ywesee.com
3
+
4
+ require 'sbsm/lookandfeel'
5
+
6
+ module BBMB
7
+ module Html
8
+ module Util
9
+ class Lookandfeel < SBSM::Lookandfeel
10
+ DICTIONARIES = {
11
+ "de" => {
12
+ :additional_info => "Zusatzinformationen",
13
+ :address1 => "Adresse",
14
+ :backorder => "im Rückstand",
15
+ :barcode_button => "Barcode-Leser",
16
+ :barcode_empty => "Es sind keine Barcodes im Leser.",
17
+ :barcode_none => "Es konnte keine Verbindung zum Barcode-Leser hergestellt werden.",
18
+ :barcode_usb => "Download USB-Treiber",
19
+ :barcode_wait => "Einen Moment, bitte...",
20
+ :canton => "Kanton",
21
+ :change_pass => "Passwort ändern",
22
+ :clear_favorites => "Schnellb. löschen",
23
+ :clear_favorites_confirm => "Wollen Sie wirklich die gesamte Schnellbestellung löschen?",
24
+ :clear_order => "Bestellung löschen",
25
+ :clear_order_confirm => "Wollen Sie wirklich die gesamte Bestellung löschen?",
26
+ :cleartext => "Passwort",
27
+ :city => "Ort",
28
+ :comment => "Bemerkungen (max. 60 Zeichen)",
29
+ :commit => "Bestellung auslösen",
30
+ :confirm_pass => "Bestätigung",
31
+ :contact => "Kontaktperson",
32
+ :currency => "Sfr.",
33
+ :currency_format => "Sfr. %.2f",
34
+ :current_order => "Home",
35
+ :customer => "Kunde",
36
+ :customers => "Kunden",
37
+ :customer_id => "Kundennr",
38
+ :delete => "Löschen",
39
+ :default_values => "Voreinstellungen",
40
+ :drtitle => "Titel",
41
+ :ean13 => "EAN-Code",
42
+ :email => "Email",
43
+ :error => "Ihre Eingaben konnten nicht gespeichert werden da Angaben fehlen oder nicht korrekt sind.\nBitte ergänzen Sie die rot gekennzeichneten Felder.",
44
+ :e_duplicate_email => "Es gibt bereits ein Benutzerprofil für diese Email-Adresse",
45
+ :e_email_required => "Bitte speichern Sie zuerst eine gültige Email-Adresse",
46
+ :e_empty_pass => "Das Passwort war leer.",
47
+ :e_invalid_ean13 => "Der EAN-Code war ungültig.",
48
+ :e_invalid_quantity0 => "'",
49
+ :e_invalid_quantity1 => "' ist keine gültige Zahl.",
50
+ :e_non_matching_pass => "Das Passwort und die Bestätigung waren nicht identisch.",
51
+ :e_pass_not_set => "Das Passwort konnte nicht gespeichert werden",
52
+ :e_terms_of_service => "Bitte akzeptieren Sie die Allgemeinen Geschäftsbedingungen (\"AGB\") der Sandoz Pharmaceuticals AG, vgl. unten.",
53
+ :e_user_unsaved => "Das Benutzerprofil wurde nicht gespeichert!",
54
+ :false => "Nein",
55
+ :favorites => "Schnellbestellung",
56
+ :favorite_positions0 => "Aktuelle Schnellbest.: ",
57
+ :favorite_positions1 => " Positionen",
58
+ :favorite_product => "Zu Schnellbest. hinzufügen",
59
+ :favorite_transfer => "Datei zu Schnellb.",
60
+ :fax => "Fax",
61
+ :filter_button => "Filter",
62
+ :firstname => "Vorname",
63
+ :generate_pass => "Passwort Generieren",
64
+ :history => "Umsatz",
65
+ :history_turnover0 => "Totalumsatz: ",
66
+ :history_turnover1 => "",
67
+ :html_title => "BBMB",
68
+ :increment_order => "Zu Best. hinzufügen",
69
+ :lastname => "Name",
70
+ :lgpl => "LGPL",
71
+ :list_price0 => '',
72
+ :list_price1 => ' Stk. à ',
73
+ :list_price2 => '',
74
+ :logged_in_as0 => "Sie sind angemeldet als ",
75
+ :logged_in_as1 => "",
76
+ :login => "Anmelden",
77
+ :login_data_saved => "Ihre Anmelde-Daten wurden geändert.",
78
+ :logout => "Abmelden",
79
+ :logo => "Sandoz",
80
+ :new_customer => "Neuer Kunde",
81
+ :new_customer_mail => "mailto:info.switzerland@sandoz.com?subject=Neukunde BBMB - bitte Passwort generieren",
82
+ :new_customer_invite => "Bestellen Sie jetzt online. Wir richten für Sie den spezifisch auf Ihre Praxis zugeschnittenen, benutzerfreundlichen E-Shop ein!\nUnser Kundenservice oder unsere Aussendienstmitarbeiter beraten Sie gerne!",
83
+ :next => ">>",
84
+ :nullify => "Alles auf 0 setzen",
85
+ :order => "Archiv - Bestellung",
86
+ :orders => "Archiv",
87
+ :order_confirmation => "Bestellbestätigung",
88
+ :order_confirmation_text => <<-EOS,
89
+ Wenn Sie eine Bestellbestätigung wünschen, bitten wir Sie dieses Feld zu markieren.
90
+
91
+ Se voule ricevere una confirmazione del Suo ordine, voglia attivare il servizio cliccando qui.
92
+
93
+ Si vous aimeriez recevoire une confirmation de votre commande veuillez activer le service ici.
94
+ EOS
95
+ :order_problem => <<-EOS,
96
+ Beim Versand Ihrer Bestellung ist ein Problem aufgetreten.
97
+ Ein Administrator wurde automatisch darüber informiert und wird mit Ihnen Kontakt aufnehmen.
98
+ EOS
99
+ :order_product => "Zu Bestellung hinzufügen",
100
+ :order_sent => "Ihre Bestellung wurde an die Sandoz AG versandt.",
101
+ :order_total => "Total Sfr. ",
102
+ :order_transfer => "Datei zu Best.",
103
+ :organisation => "Kunde",
104
+ :pass => "Passwort",
105
+ :pager_index0 => " ",
106
+ :pager_index1 => " bis ",
107
+ :pager_index2 => " ",
108
+ :pager_total0 => " von ",
109
+ :pager_total1 => "",
110
+ :pcode => "Pharmacode",
111
+ :phone_business => "Tel. Geschäft",
112
+ :phone_mobile => "Tel. Mobile",
113
+ :phone_private => "Tel. Privat",
114
+ :plz => "PLZ",
115
+ :positions0 => "Aktuelle Bestellung: ",
116
+ :positions1 => " Positionen",
117
+ :previous => "<<",
118
+ :price_range0 => "",
119
+ :price_range1 => " bis ",
120
+ :price_range2 => "",
121
+ :priority => "Versandart",
122
+ :priority_0 => "Nichts Ausw&auml;hlen",
123
+ :priority_1 => "Post",
124
+ :priority_13 => "Express Mond",
125
+ :priority_16 => "Express Freitag",
126
+ :priority_21 => "Kurier",
127
+ :priority_40 => "Terminfracht",
128
+ :priority_41 => "Terminfracht",
129
+ :priority_explain_1 => "Lieferung n&auml;chster Tag (gem. Konditionenliste)",
130
+ :priority_explain_13 => "Lieferung Vormittag n&auml;chster Tag (z.L. Kunde)",
131
+ :priority_explain_16 => "Lieferung am Samstag (z.L. Kunde)",
132
+ :priority_explain_21 => "Lieferung am gleichen Tag (z.L. Kunde)",
133
+ :priority_explain_40 => "bis 09:00 Uhr / 80 Sfr. (z.L. Kunde)",
134
+ :priority_explain_41 => "bis 10:00 Uhr / 50 Sfr. (z.L. Kunde)",
135
+ :product_found => "Suchresultat: 1 Produkt gefunden",
136
+ :products_found0 => "Suchresultat: ",
137
+ :products_found1 => " Produkte gefunden",
138
+ :reference => "Interne Bestellnummer",
139
+ :reset => "Zurücksetzen",
140
+ :save => "Speichern",
141
+ :search => "Suchen",
142
+ :search_favorites => "Suchen",
143
+ :show_pass => "Passwort Anzeigen",
144
+ :terms => "Allgemeine Geschäftsbedingungen",
145
+ :terms_last_accepted => "Bitte akzeptieren Sie die Allgemeinen Geschäftsbedingungen (\"AGB\") der Sandoz Pharmaceuticals AG, vgl. unten.",
146
+ :terms_of_service => <<-EOS,
147
+ Hiermit akzeptiere ich die Allgemeinen Geschäftsbedingungen (AGB) der Sandoz Pharmaceuticals AG.
148
+ Die aktuelle Version unserer AGB kann auf unserer Website <a href='http://www.generika.ch' target='_blank'>www.generika.ch</a> eingesehen und <a href='http://www.generika.ch/pdf/AGB_D.pdf' target='_blank'>heruntergeladen</a> werden.
149
+
150
+ J'accepte les Conditions Générales de Vente (CGV) de la société Sandoz Pharmaceuticals SA.
151
+ La version actuelle de nos CGV peut être consultée et <a href='http://www.generika.ch/pdf/AGB_F.pdf' target='_blank'>téléchargée</a> sur notre site Internet <a href='http://www.generiques.ch' target='_blank'>www.generiques.ch</a>.
152
+
153
+ Accetto le Condizioni Generali di Contratto (CGC) di Sandoz Pharmaceuticals S.A.
154
+ La versione aggiornata delle nostre CGC può essere visionata e <a href='http://www.generika.ch/pdf/AGB_I.pdf' target='_blank'>scaricata</a> al nostro sito web <a href='http://www.generici.ch' target='_blank'>www.generici.ch</a>.
155
+ EOS
156
+ :th_city => "Ort",
157
+ :th_commit_time => "Bestellung vom",
158
+ :th_customer_id => "Kundennr",
159
+ :th_description => "Artikelbezeichnung",
160
+ :th_email => "Email",
161
+ :th_item_count => "Packungen",
162
+ :th_last_login => "Letztes Login",
163
+ :th_order_count => "Best.",
164
+ :th_price => "Preis",
165
+ :th_price_base => "Preis",
166
+ :th_price_levels => 'Staffelpreise',
167
+ :th_quantity => 'Menge',
168
+ :th_order_total => "Endpreis",
169
+ :th_organisation => "Kunde",
170
+ :th_plz => "PLZ",
171
+ :th_size => "Positionen",
172
+ :th_total => "Total",
173
+ :th_valid => "Aktiviert",
174
+ :title => "Anrede",
175
+ :title_f => "Frau",
176
+ :title_m => "Herr",
177
+ :true => "Ja",
178
+ :turnover => "Umsatz",
179
+ :unavailable0 => "Unidentifiziertes Produkt (",
180
+ :unavailable1 => ")",
181
+ :version => "Commit-ID",
182
+ :welcome => "Willkommen bei Sandoz&nbsp;Pharmaceuticals&nbsp;AG\nBei Fragen wenden Sie sich bitte an den Customer&nbsp;Service (<a href='mailto:Customer.Service_ch@sandoz.com'>Customer.Service_ch@sandoz.com</a>) Tel.&nbsp;0800&nbsp;858&nbsp;885",
183
+ :ywesee => "ywesee.com",
184
+ }
185
+ }
186
+ ENABLED = {
187
+ :terms_of_service => true,
188
+ }
189
+ RESOURCES = {
190
+ :activex => 'activex',
191
+ :css => 'bbmb.css',
192
+ :dojo_js => 'dojo/dojo.js',
193
+ :javascript => 'javascript',
194
+ :logo => 'logo.png',
195
+ }
196
+ def navigation
197
+ zone_navigation + super
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # Sandoz-Extensions -- sandoz.bbmb.ch -- 20.11.2007 -- hwyss@ywesee.com
3
+
4
+ require 'bbmb/sandoz/html/state/viral/customer'
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # Html::State::Viral::Customer -- sandoz.bbmb.ch -- 20.11.2007 -- hwyss@ywesee.com
3
+
4
+ require 'bbmb/html/state/viral/customer'
5
+ require 'bbmb/html/state/change_password'
6
+
7
+ module BBMB
8
+ module Html
9
+ module State
10
+ module Viral
11
+ module Customer
12
+ def change_pass
13
+ ChangePassword.new(@session, _customer)
14
+ end
15
+ unless(instance_methods.include?("__extension_zone_navigation__"))
16
+ alias :__extension_zone_navigation__ :zone_navigation
17
+ end
18
+ def zone_navigation
19
+ __extension_zone_navigation__.push(:change_pass)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module BBMB
2
+ module SANDOZ
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Util::CsvImporter -- sandoz.bbmb.ch -- 19.11.2007 -- hwyss@ywesee.com
4
+
5
+ require 'bbmb/model/customer'
6
+ require 'bbmb/util/mail'
7
+ require 'yus/entity'
8
+
9
+ module BBMB
10
+ module Util
11
+ class CsvImporter
12
+ def import(io, persistence=BBMB.persistence)
13
+ count = 0
14
+ if io.respond_to?(:path)
15
+ get_encoding = `file --brief "#{io.path}"`
16
+ io.set_encoding('ISO-8859-1', 'UTF-8') if /^ISO-8859/.match(get_encoding)
17
+ end
18
+
19
+ io.each { |line|
20
+ next if line.size < 5
21
+ record = line.split("\t")
22
+ if(object = import_record(record))
23
+ persistence.save(object)
24
+ end
25
+ count += 1
26
+ }
27
+ postprocess(persistence)
28
+ count
29
+ end
30
+ def postprocess(persistence=BBMB.persistence)
31
+ end
32
+ def string(str)
33
+ str = str.to_s.strip
34
+ str.gsub(/\s+/, ' ') unless str.empty?
35
+ end
36
+ end
37
+ class CustomerImporter < CsvImporter
38
+ CUSTOMER_MAP = {
39
+ 1 => :ean13,
40
+ 3 => :title,
41
+ 4 => :firstname,
42
+ 5 => :lastname,
43
+ 6 => :organisation,
44
+ 8 => :address1,
45
+ 9 => :plz,
46
+ 10 => :city,
47
+ 11 => :phone_business,
48
+ 12 => :fax,
49
+ }
50
+ def import_record(record)
51
+ customer_id = string(record[0])
52
+ ean13 = string(record[1])
53
+ return unless(/^\d+$/.match(customer_id))
54
+ customer = Model::Customer.find_by_customer_id(customer_id)
55
+ if customer.nil? && !ean13.to_s.empty? \
56
+ && (customer = Model::Customer.find_by_ean13(ean13) \
57
+ || Model::Customer.find_by_customer_id(ean13))
58
+ customer.customer_id = customer_id
59
+ end
60
+ customer ||= Model::Customer.new(customer_id)
61
+ CUSTOMER_MAP.each { |idx, name|
62
+ unless customer.protects? name
63
+ customer.send("#{name}=", string(record[idx]))
64
+ end
65
+ }
66
+ customer
67
+ rescue Yus::DuplicateNameError => err
68
+ @duplicates.push(err)
69
+ nil
70
+ end
71
+ end
72
+ class ProductImporter < CsvImporter
73
+ PRODUCT_MAP = {
74
+ 1 => :description_de,
75
+ 2 => :description_fr,
76
+ 3 => :ean13,
77
+ 4 => :pcode,
78
+ 5 => :price,
79
+ }
80
+ def initialize
81
+ super
82
+ @active_products = {}
83
+ end
84
+ def import_record(record)
85
+ article_number = string(record[0])
86
+ return unless(/^\d+$/.match(article_number))
87
+ @active_products.store article_number, true
88
+ product = Model::Product.find_by_article_number(article_number) \
89
+ || Model::Product.new(article_number)
90
+ PRODUCT_MAP.each { |idx, name|
91
+ value = string(record[idx])
92
+ writer = "#{name}="
93
+ case name
94
+ when :description_de
95
+ product.description.de = value
96
+ when :description_fr
97
+ product.description.fr = value
98
+ else
99
+ product.send(writer, value)
100
+ end
101
+ }
102
+ product
103
+ end
104
+ def postprocess(persistence)
105
+ return if(@active_products.empty?)
106
+ deletables = []
107
+ persistence.all(BBMB::Model::Product) { |product|
108
+ unless(@active_products.include?(product.article_number))
109
+ deletables.push product
110
+ end
111
+ }
112
+ persistence.all(BBMB::Model::Customer) { |customer|
113
+ [customer.current_order, customer.favorites].each { |order|
114
+ deletables.each { |product|
115
+ order.add(0, product)
116
+ }
117
+ }
118
+ }
119
+ persistence.delete(*deletables) unless(deletables.empty?)
120
+ end
121
+ end
122
+ end
123
+ end
data/readme.md ADDED
@@ -0,0 +1,28 @@
1
+ # sandoz.bbmb.ch
2
+
3
+ * https://github.com/zdavatz/sandoz.bbmb.ch.git
4
+
5
+ ## DESCRIPTION:
6
+
7
+ Sandoz skin for BBMB
8
+
9
+
10
+ ## INSTALL:
11
+
12
+ * bundle install
13
+
14
+ ## TEST:
15
+
16
+ Only unit tests for csv-importer.
17
+
18
+ The specs have not yet been ported from selenium to watir.
19
+
20
+ ## DEVELOPERS:
21
+
22
+ * Zeno R.R. Davatz
23
+ * Hannes Wyss (up to Version 1.0)
24
+ * Niklaus Giger (ported to Ruby 2.3.0)
25
+
26
+ ## LICENSE:
27
+
28
+ * GPLv2