Smilla_Sobuintegration - Version 1.0.0

Version Notes

sobu Integration 1.0.0

Download this release

Release Info

Developer smilla AG
Extension Smilla_Sobuintegration
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (27) hide show
  1. app/code/local/Smilla/PostChShippingLabel/Block/Sales/Order/Grid.php +17 -0
  2. app/code/local/Smilla/PostChShippingLabel/Block/View/Postchshippinglabel.php +15 -0
  3. app/code/local/Smilla/PostChShippingLabel/Helper/Data.php +6 -0
  4. app/code/local/Smilla/PostChShippingLabel/Model/Source/Codeoptions.php +13 -0
  5. app/code/local/Smilla/PostChShippingLabel/Model/Source/Formatoptions.php +13 -0
  6. app/code/local/Smilla/PostChShippingLabel/controllers/PostchshippinglabelController.php +170 -0
  7. app/code/local/Smilla/PostChShippingLabel/etc/config.xml +86 -0
  8. app/code/local/Smilla/PostChShippingLabel/etc/system.xml +136 -0
  9. app/code/local/Smilla/Sobuintegration/Block/Generatebutton.php +19 -0
  10. app/code/local/Smilla/Sobuintegration/Block/Share.php +27 -0
  11. app/code/local/Smilla/Sobuintegration/Helper/Data.php +100 -0
  12. app/code/local/Smilla/Sobuintegration/Model/Condition/Benefit.php +65 -0
  13. app/code/local/Smilla/Sobuintegration/Model/Observer.php +73 -0
  14. app/code/local/Smilla/Sobuintegration/controllers/AdminController.php +39 -0
  15. app/code/local/Smilla/Sobuintegration/controllers/ShareController.php +68 -0
  16. app/code/local/Smilla/Sobuintegration/etc/config.xml +136 -0
  17. app/code/local/Smilla/Sobuintegration/etc/system.xml +144 -0
  18. app/design/frontend/base/default/layout/sobuintegration.xml +49 -0
  19. app/design/frontend/base/default/template/sobu/checkout/share.phtml +16 -0
  20. app/design/frontend/base/default/template/sobu/order/share.phtml +18 -0
  21. app/design/frontend/base/default/template/sobu/sales/order/share.phtml +16 -0
  22. app/design/frontend/base/default/template/sobu/sales/order/totals.phtml +62 -0
  23. app/etc/modules/Smilla_Sobuintegration.xml +9 -0
  24. app/locale/de_CH/Smilla_Sobuintegration.csv +21 -0
  25. app/locale/de_DE/Smilla_Sobuintegration.csv +21 -0
  26. package.xml +19 -0
  27. skin/frontend/base/default/images/sobu/sobulogo.png +0 -0
app/code/local/Smilla/PostChShippingLabel/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_PostChShippingLabel_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
4
+ {
5
+
6
+ protected function _prepareMassaction()
7
+ {
8
+ parent::_prepareMassaction();
9
+ $this->getMassactionBlock()->addItem('postch_shippinglabel', array(
10
+ 'label'=> Mage::helper('sales')->__('Post.CH Labels drucken'),
11
+ 'url' => $this->getUrl('smillaadmin/postchshippinglabel/multipleShippingLabel'),
12
+ ));
13
+
14
+
15
+ return $this;
16
+ }
17
+ }
app/code/local/Smilla/PostChShippingLabel/Block/View/Postchshippinglabel.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_PostChShippingLabel_Block_View_Postchshippinglabel extends Mage_Adminhtml_Block_Sales_Order_View
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->_addButton('postch_shippinglabel', array(
10
+ 'label' => Mage::helper('sales')->__('Post.CH Label drucken'),
11
+ 'onclick' => 'setLocation(\'' . $this->getUrl('smillaadmin/postchshippinglabel/singleShippingLabel') . '\')',
12
+ ));
13
+ }
14
+
15
+ }
app/code/local/Smilla/PostChShippingLabel/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_PostChShippingLabel_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Smilla/PostChShippingLabel/Model/Source/Codeoptions.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_PostChShippingLabel_Model_Source_Codeoptions
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'ECO', 'label' =>'PostPac Economy'),
9
+ array('value' => 'PRI', 'label' =>'PostPac Priority'),
10
+ array('value' => 'A7', 'label' =>'A7'),
11
+ );
12
+ }
13
+ }
app/code/local/Smilla/PostChShippingLabel/Model/Source/Formatoptions.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_PostChShippingLabel_Model_Source_Formatoptions
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'A5', 'label' =>'A5'),
9
+ array('value' => 'A6', 'label' =>'A6'),
10
+ array('value' => 'A7', 'label' =>'A7'),
11
+ );
12
+ }
13
+ }
app/code/local/Smilla/PostChShippingLabel/controllers/PostchshippinglabelController.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once("Mage/Adminhtml/controllers/Sales/ShipmentController.php");
3
+ class Smilla_PostChShippingLabel_PostchshippinglabelController extends Mage_Adminhtml_Controller_Sales_Shipment
4
+ {
5
+
6
+ public function singleShippingLabelAction()
7
+ {
8
+ $request = $this->getRequest();
9
+
10
+ $ids = $request->getParam('order_id');
11
+ $order = Mage::getModel('sales/order')->load($ids);
12
+
13
+ $labelBinaryData = $this->generateLabel($order);
14
+ $pdf = Zend_Pdf::parse($labelBinaryData);
15
+
16
+ $this->_prepareDownloadResponse('ShippingLabel-'.$ids.'.pdf', $pdf->render(), 'application/pdf');
17
+
18
+ }
19
+
20
+ public function multipleShippingLabelAction()
21
+ {
22
+ $request = $this->getRequest();
23
+
24
+ $ids = $request->getParam('order_ids');
25
+
26
+ if(!$ids){
27
+ $ids = array($request->getParam('order_id'));
28
+ }
29
+
30
+ $pdf = new Zend_Pdf(); // Initializing the merged PDF
31
+
32
+ for($i=0;$i<count($ids);$i++){
33
+
34
+ $order = Mage::getModel('sales/order')->load($ids[$i]);
35
+
36
+ // Generate Label
37
+ $labelBinaryData = $this->generateLabel($order);
38
+
39
+ // Copy Page to multipage PDF
40
+ $tmp_pdf = Zend_Pdf::parse($labelBinaryData);
41
+ $tmp_page = clone $tmp_pdf->pages[0];
42
+ $pdf->pages[] = $tmp_page;
43
+
44
+ }
45
+
46
+ $this->_prepareDownloadResponse('ShippingLabels-'.implode('-', $ids).'.pdf', $pdf->render(), 'application/pdf');
47
+
48
+ }
49
+
50
+
51
+ /**
52
+ * Get PDF Label From Post.CH Webservice
53
+ */
54
+ protected function generateLabel($order){
55
+ $tarif = 'ECO';
56
+
57
+ // SOAP Config
58
+ /* TODO: Datei auslesen */
59
+ $SOAP_wsdl_file_path = 'post/barcode_v2_1.wsdl';
60
+ $SOAP_config = array(
61
+
62
+ // Webservice Endpoint URL
63
+ 'location' => Mage::getStoreConfig('postchshippinglabel/settings/endpointurl'),
64
+
65
+ // Webservice Barcode Login
66
+ 'login' => Mage::getStoreConfig('postchshippinglabel/settings/username'),
67
+ //'password' => Mage::getStoreConfig('postchshippinglabel/settings/password'),
68
+ 'password' => 'SktNuAM2u8'
69
+ );
70
+
71
+ $SOAP_Client = new SoapClient($SOAP_wsdl_file_path, $SOAP_config);
72
+
73
+ // Franking License Configuration
74
+ $generateLabelRequest = array(
75
+ 'Language' => 'de',
76
+ 'Envelope' => array(
77
+ 'LabelDefinition' => array(
78
+ 'LabelLayout' => Mage::getStoreConfig('postchshippinglabel/advanced_settings/format'),
79
+ 'PrintAddresses' => 'RecipientAndCustomer',
80
+ 'ImageFileType' => 'PDF',
81
+ 'ImageResolution' => 300,
82
+ 'PrintPreview' => false
83
+ ),
84
+ 'FileInfos' => array(
85
+ 'FrankingLicense' => Mage::getStoreConfig('postchshippinglabel/settings/licenseno'),
86
+ 'PpFranking' => false,
87
+ 'Customer' => array(
88
+ 'Name1' => Mage::getStoreConfig('postchshippinglabel/customer/company'),
89
+ 'Street' => Mage::getStoreConfig('postchshippinglabel/customer/street'),
90
+ 'ZIP' => Mage::getStoreConfig('postchshippinglabel/customer/postcode'),
91
+ 'City' => Mage::getStoreConfig('postchshippinglabel/customer/city'),
92
+ ),
93
+ 'CustomerSystem' => 'Magento Labeling Extension by Smilla AG'
94
+ ),
95
+ 'Data' => array(
96
+ 'Provider' => array(
97
+ 'Sending' => array(
98
+ 'Item' => array(
99
+ array(
100
+ 'ItemID' => $order->getRealOrderId(),
101
+ 'Recipient' => array(
102
+ 'Title' => $order->getShippingAddress()->getTitle(),
103
+ 'Name1' => $order->getShippingAddress()->getFirstname().' '.$order->getShippingAddress()->getLastname(),
104
+ 'Name2' => $order->getShippingAddress()->getCompany(),
105
+ 'Street' => implode(", ", $order->getShippingAddress()->getStreet()),
106
+ 'ZIP' => substr($order->getShippingAddress()->getPostcode(), 0, 4),
107
+ 'City' => $order->getShippingAddress()->getCity(),
108
+ 'EMail' => $order->getShippingAddress()->getEmail()
109
+ ),
110
+ 'Attributes' => array(
111
+ 'PRZL' => array(
112
+ Mage::getStoreConfig('postchshippinglabel/advanced_settings/code')
113
+ ),
114
+ 'ProClima' => (Mage::getStoreConfig('postchshippinglabel/advanced_settings/proclima') == 1)
115
+ )
116
+ )
117
+ )
118
+ )
119
+ )
120
+ )
121
+ )
122
+ );
123
+
124
+
125
+ // Web service call
126
+ $response = null;
127
+ $response = $SOAP_Client->GenerateLabel($generateLabelRequest);
128
+
129
+ $item = $response->Envelope->Data->Provider->Sending->Item;
130
+ if (isset($item->Errors)) {
131
+ $errorMessages = "";
132
+ $delimiter="";
133
+ foreach ($item->Errors as $error) {
134
+ $errorMessages .= $delimiter.$error->Message;
135
+ $delimiter=",";
136
+ }
137
+ echo '<p>ERROR for item with itemID='.$item->ItemID.": ".$errorMessages.'.<br/></p>';
138
+ die();
139
+
140
+ }
141
+
142
+ // Save Tracking Code (Swiss Post)
143
+ $identCode = $item->IdentCode;
144
+ $shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
145
+ $shipment_collection->addAttributeToFilter('order_id', $order->getId());
146
+
147
+ foreach($shipment_collection as $sc) {
148
+ $shipment = Mage::getModel('sales/order_shipment');
149
+ $shipment->load($sc->getId());
150
+
151
+ if($shipment->getId() != '') {
152
+ $track = Mage::getModel('sales/order_shipment_track')
153
+ ->setShipment($shipment)
154
+ ->setData('title', 'Bestellung '.$order->getRealOrderId())
155
+ ->setData('number', $identCode)
156
+ ->setData('carrier_code', 'swisspost')
157
+ ->setData('order_id', $shipment->getData('order_id'))
158
+ ->save();
159
+ }
160
+ }
161
+
162
+ // Get successfully generated label as binary data:
163
+ return $item->Label;
164
+
165
+
166
+ }
167
+
168
+
169
+
170
+ }
app/code/local/Smilla/PostChShippingLabel/etc/config.xml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Smilla_PostChShippingLabel>
5
+ <version>0.1.0</version>
6
+ </Smilla_PostChShippingLabel>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <postchshippinglabel>
11
+ <class>Smilla_PostChShippingLabel_Model</class>
12
+ </postchshippinglabel>
13
+ </models>
14
+ <blocks>
15
+ <adminhtml>
16
+ <rewrite>
17
+ <sales_order_grid>Smilla_PostChShippingLabel_Block_Sales_Order_Grid</sales_order_grid>
18
+ </rewrite>
19
+ <rewrite>
20
+ <sales_order_view>Smilla_PostChShippingLabel_Block_View_Postchshippinglabel</sales_order_view>
21
+ </rewrite>
22
+ </adminhtml>
23
+ </blocks>
24
+ <helpers>
25
+ <postchshippinglabel>
26
+ <class>Smilla_PostChShippingLabel_Helper</class>
27
+ </postchshippinglabel>
28
+ </helpers>
29
+ </global>
30
+ <admin>
31
+ <routers>
32
+ <smilla_postchshippinglabel>
33
+ <use>admin</use>
34
+ <args>
35
+ <module>Smilla_PostChShippingLabel</module>
36
+ <frontName>smillaadmin</frontName>
37
+ </args>
38
+ </smilla_postchshippinglabel>
39
+
40
+ </routers>
41
+ </admin>
42
+
43
+
44
+ <adminhtml>
45
+ <acl>
46
+ <resources>
47
+ <all>
48
+ <title>Allow Everything</title>
49
+ </all>
50
+ <admin>
51
+ <children>
52
+ <smilla_postchshippinglabel>
53
+ <title>Post.CH Shippinglabel 1</title>
54
+ </smilla_postchshippinglabel>
55
+ <Smilla_PostChShippingLabel>
56
+ <title>Post.CH Shippinglabel 2</title>
57
+ </Smilla_PostChShippingLabel>
58
+ <smillaadmin>
59
+ <title>Post.CH Shippinglabel 2</title>
60
+ </smillaadmin>
61
+ <system>
62
+ <children>
63
+ <config>
64
+ <children>
65
+ <postchshippinglabel>
66
+ <title>Post.CH Shippinglabel Settings</title>
67
+ </postchshippinglabel>
68
+ </children>
69
+ </config>
70
+ </children>
71
+ </system>
72
+ </children>
73
+ </admin>
74
+ </resources>
75
+ </acl>
76
+ </adminhtml>
77
+
78
+
79
+ <default>
80
+ <postchshippinglabel>
81
+ <settings>
82
+ <endpointurl>https://int.mypostbusiness.ch/wsbc/barcode/v2_1</endpointurl>
83
+ </settings>
84
+ </postchshippinglabel>
85
+ </default>
86
+ </config>
app/code/local/Smilla/PostChShippingLabel/etc/system.xml ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <sections>
3
+ <postchshippinglabel module="postchshippinglabel">
4
+ <label>Post.CH Labeling</label>
5
+ <tab>sales</tab>
6
+ <frontend_type>text</frontend_type>
7
+ <show_in_default>1</show_in_default>
8
+ <show_in_website>1</show_in_website>
9
+ <show_in_store>1</show_in_store>
10
+ <sort_order>100</sort_order>
11
+ <groups>
12
+ <settings translate="label">
13
+ <label>Webservice Zugangsdaten</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>10</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <endpointurl translate="label">
21
+ <label>Endpoint-URL</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ </endpointurl>
28
+ <username translate="label">
29
+ <label>Webservice-Benutzername</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>20</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </username>
36
+ <password translate="label">
37
+ <label>Webservice-Passwort</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>30</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </password>
44
+ <licenseno translate="label">
45
+ <label>Frankierlizenz-Nr. (8-stellig)</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>40</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </licenseno>
52
+ </fields>
53
+ </settings>
54
+ <advanced_settings translate="label">
55
+ <label>Einstellungen</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>10</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <fields>
62
+ <format translate="label">
63
+ <label>Label-Format</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>postchshippinglabel/source_formatoptions</source_model>
66
+ <sort_order>10</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </format>
71
+ <code translate="label">
72
+ <label>Dienstleistungscode</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>postchshippinglabel/source_codeoptions</source_model>
75
+ <sort_order>30</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </code>
80
+ <proclima translate="label">
81
+ <label>ProClima</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>adminhtml/system_config_source_yesno</source_model>
84
+ <sort_order>40</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </proclima>
89
+ </fields>
90
+ </advanced_settings>
91
+ <customer translate="label">
92
+ <label>Absenderadresse</label>
93
+ <frontend_type>text</frontend_type>
94
+ <sort_order>20</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ <fields>
99
+ <company translate="label">
100
+ <label>Firma/Name</label>
101
+ <frontend_type>text</frontend_type>
102
+ <sort_order>10</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </company>
107
+ <street translate="label">
108
+ <label>Straße / Hausnummer</label>
109
+ <frontend_type>text</frontend_type>
110
+ <sort_order>20</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ </street>
115
+ <postcode translate="label">
116
+ <label>PLZ</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>30</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </postcode>
123
+ <city translate="label">
124
+ <label>Ort</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>40</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </city>
131
+ </fields>
132
+ </customer>
133
+ </groups>
134
+ </postchshippinglabel>
135
+ </sections>
136
+ </config>
app/code/local/Smilla/Sobuintegration/Block/Generatebutton.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Smilla_Sobuintegration_Block_Generatebutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ $url = $this->getUrl('sobuadmin/admin/generatersa');
9
+
10
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
11
+ ->setType('button')
12
+ ->setClass('scalable')
13
+ ->setLabel(Mage::helper('sobuintegration')->__('Generate RSA Key'))
14
+ ->setOnClick("if(confirm('Neuen RSA Schlüssel jetzt generieren? (Der vorhandene wird ggf. überschrieben)')){ setLocation('$url')}")
15
+ ->toHtml();
16
+
17
+ return $html;
18
+ }
19
+ }
app/code/local/Smilla/Sobuintegration/Block/Share.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Smilla_Sobuintegration_Block_Share extends Mage_Core_Block_Template
5
+ {
6
+
7
+ public function __construct() {
8
+
9
+ $this->setOrder(Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id')));
10
+ }
11
+
12
+ public function getApiKey(){
13
+ return Mage::helper('sobuintegration/data')->getApiKey();
14
+
15
+ }
16
+
17
+ public function getOrderData(){
18
+ $result = Mage::helper('sobuintegration/data')->getOrderData($this->getOrder());
19
+
20
+ return json_encode($result);
21
+ }
22
+
23
+ public function getSignatureData($orderdata){
24
+ return Mage::helper('sobuintegration/data')->getDigitalSignature($orderdata);
25
+ }
26
+
27
+ }
app/code/local/Smilla/Sobuintegration/Helper/Data.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_Sobuintegration_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getOrderData($order){
6
+
7
+ $storeViews = Mage::getModel('core/store')
8
+ ->getCollection()
9
+ ->setLoadDefault(true);
10
+
11
+ $result = array(
12
+ "id" => $order->getRealOrderId(),
13
+ "items" => array()
14
+ );
15
+
16
+ // Items
17
+ foreach($order->getItemsCollection() as $item){
18
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
19
+
20
+ $itemarray = array(
21
+ "quantity" => (int) $item->getQtyOrdered(),
22
+ "product" => array(
23
+ "id" => $product->getSku(),
24
+ "editable" => true,
25
+ "languageVersions" => array( ),
26
+ "image" => $product->getImageUrl()
27
+ )
28
+ );
29
+
30
+ // Get all Labels from Store views
31
+ foreach($storeViews as $storeId => $store) {
32
+ $locale = substr(Mage::getStoreConfig('general/locale/code', $storeId), 0, 2);
33
+ Mage::app()->setCurrentStore($storeId);
34
+
35
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
36
+ $itemarray["product"]["languageVersions"][$locale] = array(
37
+ "name" => $product->getName(),
38
+ "message" => 'Ich habe gerade das Produkt "'.$product->getName().'" gekauft.'
39
+ );
40
+
41
+ }
42
+
43
+ $result['items'][] = $itemarray;
44
+
45
+ }
46
+
47
+ return $result;
48
+ }
49
+
50
+ public function getApiKey(){
51
+ if(Mage::getStoreConfig('sobuintegration/settings/testmode') == 1){
52
+ return Mage::getStoreConfig('sobuintegration/settings/testapikey');
53
+ } else {
54
+ return Mage::getStoreConfig('sobuintegration/settings/apikey');
55
+ }
56
+
57
+ }
58
+
59
+ public function getTotal($order){
60
+ $currency = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getShortName();
61
+ return number_format($order->getGrandTotal(), 2).$currency;
62
+ }
63
+
64
+ /**
65
+ * Returns the digital signature for the passed string
66
+ * @param string $sData
67
+ * @return string hexadezimal coded RSA signature of the SHA1 hash of the string
68
+ */
69
+ public function getDigitalSignature($sData)
70
+ {
71
+
72
+ Mage::getStoreConfig('sobuintegration/settings/privatekey');
73
+ $sPKeyID = openssl_get_privatekey(Mage::getStoreConfig('sobuintegration/settings/privatekey'));
74
+ // calculate the signature
75
+ openssl_sign($sData, $sSignature, $sPKeyID, OPENSSL_ALGO_SHA1);
76
+ // remove key from memory
77
+ openssl_free_key($sPKeyID);
78
+
79
+ return $this->getHEXConvertedSignature($sSignature);
80
+ }
81
+
82
+ /**
83
+ * Returns a hex encoded string
84
+ * @param string $sSignature
85
+ * @return string
86
+ */
87
+ private function getHEXConvertedSignature($sSignature)
88
+ {
89
+ $sFinalSingature = '';
90
+ for($i=0,$ii=strlen($sSignature); $i<$ii; $i++)
91
+ {
92
+ $sChar = $sSignature[$i];
93
+ $sFinalSingature .= str_pad(dechex(ord($sChar)), 2, 0, STR_PAD_LEFT);
94
+ }
95
+
96
+
97
+ return $sFinalSingature;
98
+ }
99
+
100
+ }
app/code/local/Smilla/Sobuintegration/Model/Condition/Benefit.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Smilla_Sobuintegration_Model_Condition_Benefit extends Mage_Rule_Model_Condition_Abstract
3
+ {
4
+
5
+ /**
6
+ *
7
+ * @return Smilla_Sobuintegration_Model_Condition_Benefit
8
+ */
9
+ public function loadAttributeOptions()
10
+ {
11
+ $attributes = array(
12
+ 'sobu_code' => Mage::helper('sobuintegration')->__('Sobu Benefit Code')
13
+ );
14
+
15
+ $this->setAttributeOption($attributes);
16
+
17
+ return $this;
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @return mixed
23
+ */
24
+ public function getAttributeElement()
25
+ {
26
+ $element = parent::getAttributeElement();
27
+ $element->setShowAsText(true);
28
+ return $element;
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @return string
34
+ */
35
+ public function getInputType()
36
+ {
37
+
38
+ return 'string';
39
+ }
40
+
41
+ /**
42
+ * @return string
43
+ */
44
+ public function getValueElementType()
45
+ {
46
+ return 'text';
47
+ }
48
+
49
+ /**
50
+ * Validate Rule Condition
51
+ *
52
+ * @param Varien_Object $object
53
+ *
54
+ * @return bool
55
+ */
56
+ public function validate(Varien_Object $object)
57
+ {
58
+ if($this->getAttribute() == 'sobu_code' && $this->getValue() == Mage::getSingleton("checkout/session")->getData("sobu_vouchercode")){
59
+ return true;
60
+ } else {
61
+ return false;
62
+ }
63
+
64
+ }
65
+ }
app/code/local/Smilla/Sobuintegration/Model/Observer.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Smilla_Sobuintegration_Model_Observer
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+
8
+ }
9
+
10
+ /**
11
+ * Event: salesrule_rule_condition_combine
12
+ *
13
+ * @param $observer
14
+ */
15
+ public function addConditionToSalesRule($observer)
16
+ {
17
+
18
+ $additional = $observer->getAdditional();
19
+ $conditions = (array)$additional->getConditions();
20
+
21
+ $conditions = array_merge_recursive($conditions, array(
22
+ array('label' => Mage::helper('sobuintegration')->__('Sobu Benefit'), 'value' => 'sobuintegration/condition_benefit'),
23
+ ));
24
+
25
+ $additional->setConditions($conditions);
26
+ $observer->setAdditional($additional);
27
+
28
+ return $observer;
29
+ }
30
+
31
+ /**
32
+ * Register Sale to Sobu
33
+ *
34
+ * @param $observer
35
+ * @return boolean
36
+ */
37
+ public function registerSobuSale(Varien_Event_Observer $observer)
38
+ {
39
+ $order = $observer->getEvent()->getOrder();
40
+ $clickId = (int)Mage::getSingleton("checkout/session")->getData("sobu_clickid");
41
+
42
+ // Sobu ClickId exists?
43
+ if ($clickId > 0) {
44
+ // Register Sale (Server-2-Server=
45
+ $api_url = 'https://www.sobu.ch/register';
46
+ $postdata = array(
47
+ 'apiKey' => Mage::helper('sobuintegration/data')->getApiKey(),
48
+ 'orderId' => $order->getRealOrderId(),
49
+ 'total' => Mage::helper('sobuintegration/data')->getTotal($order),
50
+ 'signature' => Mage::helper('sobuintegration/data')->getDigitalSignature($order->getRealOrderId().'#'.Mage::helper('sobuintegration/data')->getTotal($order)),
51
+ 'clickId' => $clickId,
52
+ );
53
+
54
+ $ch = curl_init($api_url);
55
+ curl_setopt($ch, CURLOPT_POST, true);
56
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postdata));
57
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
58
+ $result = json_decode(curl_exec($ch));
59
+ curl_close($ch);
60
+
61
+ if($result->isError){
62
+ // Error sending Request
63
+ }
64
+
65
+ // Remove Session Data
66
+ Mage::getSingleton("checkout/session")->unsetData("sobu_vouchercode");
67
+ Mage::getSingleton("checkout/session")->unsetData("sobu_clickid");
68
+
69
+ }
70
+
71
+ return true;
72
+ }
73
+ }
app/code/local/Smilla/Sobuintegration/controllers/AdminController.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Smilla_Sobuintegration_AdminController extends Mage_Adminhtml_Controller_Sales_Shipment
4
+ {
5
+
6
+ public function generatersaAction()
7
+ {
8
+ // generate 2048-bit RSA key
9
+ $pkGenerate = openssl_pkey_new(array(
10
+ 'private_key_bits' => 2048,
11
+ 'private_key_type' => OPENSSL_KEYTYPE_RSA
12
+ ));
13
+
14
+ // get the private key
15
+ openssl_pkey_export($pkGenerate,$pkGeneratePrivate); // NOTE: second argument is passed by reference
16
+
17
+ // get the public key
18
+ $pkGenerateDetails = openssl_pkey_get_details($pkGenerate);
19
+ $pkGeneratePublic = $pkGenerateDetails['key'];
20
+
21
+ // free resources
22
+ openssl_pkey_free($pkGenerate);
23
+
24
+ // Save keys to Config
25
+ $config = new Mage_Core_Model_Config();
26
+ $config->saveConfig('sobuintegration/settings/publickey', $pkGeneratePublic, 'default', 0);
27
+ $config->saveConfig('sobuintegration/settings/privatekey', $pkGeneratePrivate, 'default', 0);
28
+ #echo Mage::getStoreConfig('sobuintegration/settings/privatekey');
29
+
30
+ // Redirect
31
+ $this->_redirect('adminhtml/system_config/edit/section/sobuintegration');
32
+
33
+
34
+ }
35
+
36
+
37
+
38
+
39
+ }
app/code/local/Smilla/Sobuintegration/controllers/ShareController.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Smilla_Sobuintegration_ShareController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ public function orderAction()
6
+ {
7
+
8
+ $loginUrl = Mage::helper('customer')->getLoginUrl();
9
+ if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
10
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
11
+ }
12
+
13
+ $this->loadLayout();
14
+ $this->order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
15
+
16
+ if (!$this->_canViewOrder($this->order)) {
17
+ // Not authorized for this order
18
+ $this->_redirect('customer/account');
19
+ }
20
+
21
+
22
+ $this->renderLayout();
23
+
24
+ }
25
+
26
+ public function linkAction()
27
+ {
28
+ $voucherCode = trim($this->getRequest()->getParam('code'));
29
+ $this->session = Mage::getSingleton('checkout/session');
30
+
31
+ if(strlen($voucherCode) > 0) {
32
+
33
+ // Save Vouchercode to Session
34
+ Mage::getSingleton("checkout/session")->setData("sobu_vouchercode", $voucherCode);
35
+ // Save ClickId to Session
36
+ Mage::getSingleton("checkout/session")->setData("sobu_clickid", $this->getRequest()->getParam('sobuClickId'));
37
+
38
+ $this->session->addSuccess(
39
+ Mage::helper('sobuintegration')->__('Sobu Benefit was successfully applied')
40
+ );
41
+
42
+ } else {
43
+ $this->session->addError(
44
+ Mage::helper('sobuintegration')->__('Link not valid')
45
+ );
46
+ }
47
+ $this->_redirect("/");
48
+
49
+ }
50
+
51
+ /**
52
+ * Check order view availability
53
+ *
54
+ * @param Mage_Sales_Model_Order $order
55
+ * @return bool
56
+ */
57
+ protected function _canViewOrder($order)
58
+ {
59
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
60
+ $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
61
+ if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
62
+ && in_array($order->getState(), $availableStates, $strict = true)
63
+ ) {
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+ }
app/code/local/Smilla/Sobuintegration/etc/config.xml ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Smilla_Sobuintegration>
5
+ <version>0.1.0</version>
6
+ </Smilla_Sobuintegration>
7
+ </modules>
8
+
9
+
10
+ <admin>
11
+ <routers>
12
+ <sobuadmin>
13
+ <use>admin</use>
14
+ <args>
15
+ <module>Smilla_Sobuintegration</module>
16
+ <frontName>sobuadmin</frontName>
17
+ </args>
18
+ </sobuadmin>
19
+
20
+ </routers>
21
+ </admin>
22
+ <frontend>
23
+ <routers>
24
+ <sobu>
25
+ <use>standard</use>
26
+ <args>
27
+ <module>Smilla_Sobuintegration</module>
28
+ <frontName>sobu</frontName>
29
+ </args>
30
+ </sobu>
31
+ </routers>
32
+
33
+ <layout>
34
+ <updates>
35
+ <sobu>
36
+ <file>sobuintegration.xml</file>
37
+ </sobu>
38
+ </updates>
39
+ </layout>
40
+
41
+ <translate>
42
+ <modules>
43
+ <sobuintegration>
44
+ <files>
45
+ <default>Smilla_Sobuintegration.csv</default>
46
+ </files>
47
+ </sobuintegration>
48
+ </modules>
49
+ </translate>
50
+ </frontend>
51
+ <global>
52
+ <blocks>
53
+ <sobuintegration>
54
+ <class>Smilla_Sobuintegration_Block</class>
55
+ </sobuintegration>
56
+ <sobuintegration_adminhtml>
57
+ <class>Smilla_Sobuintegration_Block_Adminhtml</class>
58
+ </sobuintegration_adminhtml>
59
+ </blocks>
60
+ <models>
61
+ <sobuintegration>
62
+ <class>Smilla_Sobuintegration_Model</class>
63
+ </sobuintegration>
64
+ </models>
65
+ <helpers>
66
+ <sobuintegration>
67
+ <class>Smilla_Sobuintegration_Helper</class>
68
+ </sobuintegration>
69
+ </helpers>
70
+ <events>
71
+ <salesrule_rule_condition_combine>
72
+ <observers>
73
+ <add_condition_to_sales_rule>
74
+ <class>Smilla_Sobuintegration_Model_Observer</class>
75
+ <method>addConditionToSalesRule</method>
76
+ </add_condition_to_sales_rule>
77
+ </observers>
78
+ </salesrule_rule_condition_combine>
79
+ <sales_order_place_after>
80
+ <observers>
81
+ <sobu_register_sale>
82
+ <class>Smilla_Sobuintegration_Model_Observer</class>
83
+ <method>registerSobuSale</method>
84
+ </sobu_register_sale>
85
+ </observers>
86
+ </sales_order_place_after>
87
+ </events>
88
+ </global>
89
+
90
+ <adminhtml>
91
+ <acl>
92
+ <resources>
93
+ <all>
94
+ <title>Allow Everything</title>
95
+ </all>
96
+ <admin>
97
+ <children>
98
+ <sobuintegration>
99
+ <title>sobu.ch Integration</title>
100
+ </sobuintegration>
101
+ <system>
102
+ <children>
103
+ <config>
104
+ <children>
105
+ <sobuintegration>
106
+ <title>sobu.ch Integration Settings</title>
107
+ </sobuintegration>
108
+ </children>
109
+ </config>
110
+ </children>
111
+ </system>
112
+ </children>
113
+ </admin>
114
+ </resources>
115
+ </acl>
116
+ <translate>
117
+ <modules>
118
+ <sobuintegration>
119
+ <files>
120
+ <default>Smilla_Sobuintegration.csv</default>
121
+ </files>
122
+ </sobuintegration>
123
+ </modules>
124
+ </translate>
125
+ </adminhtml>
126
+
127
+
128
+ <default>
129
+ <sobuintegration>
130
+ <settings>
131
+ <testmode>1</testmode>
132
+ </settings>
133
+ </sobuintegration>
134
+ </default>
135
+
136
+ </config>
app/code/local/Smilla/Sobuintegration/etc/system.xml ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <sections>
3
+ <sobuintegration module="sobuintegration">
4
+ <label>sobu.ch</label>
5
+ <tab>sales</tab>
6
+ <frontend_type>text</frontend_type>
7
+ <show_in_default>1</show_in_default>
8
+ <show_in_website>1</show_in_website>
9
+ <show_in_store>1</show_in_store>
10
+ <sort_order>100</sort_order>
11
+ <groups>
12
+ <settings translate="label">
13
+ <label>Settings</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>10</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <apikey translate="label">
21
+ <label>API Key</label>
22
+ <comment>Sobu API Key</comment>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ </apikey>
29
+ <testapikey translate="label">
30
+ <label>Test API Key</label>
31
+ <comment>Sobu Test API Key</comment>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </testapikey>
38
+ <testmode translate="label">
39
+ <label>Testmode?</label>
40
+ <comment>Run in Testmode?</comment>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>adminhtml/system_config_source_yesno</source_model>
43
+ <sort_order>30</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </testmode>
48
+ <generatekey translate="label">
49
+ <label>Generate Key</label>
50
+ <frontend_type>button</frontend_type>
51
+ <frontend_model>sobuintegration/generatebutton</frontend_model>
52
+ <sort_order>40</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </generatekey>
57
+ <publickey translate="label">
58
+ <label>Public Key</label>
59
+ <comment>Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal</comment>
60
+ <frontend_type>textarea</frontend_type>
61
+ <sort_order>50</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </publickey>
66
+ <privatekey translate="label">
67
+ <label></label>
68
+ <frontend_type>hidden</frontend_type>
69
+ <sort_order>60</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </privatekey>
74
+
75
+ </fields>
76
+ </settings>
77
+ <settings translate="label">
78
+ <label>Settings</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>10</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <fields>
85
+ <apikey translate="label">
86
+ <label>API key </label>
87
+ <comment>sobu API Key</comment>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>10</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </apikey>
94
+ <testapikey translate="label">
95
+ <label>Test API key</label>
96
+ <comment>sobu Test API Key</comment>
97
+ <frontend_type>text</frontend_type>
98
+ <sort_order>20</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>1</show_in_store>
102
+ </testapikey>
103
+ <testmode translate="label">
104
+ <label>Testmode?</label>
105
+ <comment>Run in Testmode?</comment>
106
+ <frontend_type>select</frontend_type>
107
+ <source_model>adminhtml/system_config_source_yesno</source_model>
108
+ <sort_order>30</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ </testmode>
113
+ <generatekey translate="label">
114
+ <label>Generate Key</label>
115
+ <frontend_type>button</frontend_type>
116
+ <frontend_model>sobuintegration/generatebutton</frontend_model>
117
+ <sort_order>40</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ </generatekey>
122
+ <publickey translate="label">
123
+ <label>Public Key</label>
124
+ <comment>Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal</comment>
125
+ <frontend_type>textarea</frontend_type>
126
+ <sort_order>50</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </publickey>
131
+ <privatekey translate="label">
132
+ <label></label>
133
+ <frontend_type>hidden</frontend_type>
134
+ <sort_order>60</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </privatekey>
139
+ </fields>
140
+ </settings>
141
+ </groups>
142
+ </sobuintegration>
143
+ </sections>
144
+ </config>
app/design/frontend/base/default/layout/sobuintegration.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <sobu_share_order>
4
+ <reference name="root">
5
+ <action method="setTemplate">
6
+ <template>page/1column.phtml</template>
7
+ </action>
8
+ </reference>
9
+ <reference name="content">
10
+ <block type="sobuintegration/share" name="sobu_share_order" template="sobu/order/share.phtml"></block>
11
+ </reference>
12
+ </sobu_share_order>
13
+
14
+ <!-- Order View -->
15
+ <sales_order_view>
16
+ <reference name="my.account.wrapper">
17
+ <block type="sales/order_view" name="sobu_share" after="sales.order.view" template="sobu/sales/order/share.phtml" />
18
+ </reference>
19
+ </sales_order_view>
20
+
21
+
22
+ <!-- Multi Checkout Success Page -->
23
+ <checkout_multishipping_success translate="label">
24
+ <reference name="content">
25
+ <block type="checkout/multishipping_success" after="checkout_success" name="sobu_share"
26
+ template="sobu/checkout/share.phtml"/>
27
+ </reference>
28
+ </checkout_multishipping_success>
29
+
30
+ <!-- Checkout Success Page -->
31
+ <checkout_onepage_success translate="label">
32
+ <reference name="content">
33
+ <block type="checkout/onepage_success" after="checkout.success" name="sobu_share"
34
+ template="sobu/checkout/share.phtml"/>
35
+ </reference>
36
+ </checkout_onepage_success>
37
+
38
+
39
+ <!-- E-Mail -->
40
+ <sales_email_order_items>
41
+ <reference name="items">
42
+ <reference name="order_totals" template="sobu/sales/order/totals.phtml">
43
+ <action method="setTemplate">
44
+ <template>sobu/sales/order/totals.phtml</template>
45
+ </action>
46
+ </reference>
47
+ </reference>
48
+ </sales_email_order_items>
49
+ </layout>
app/design/frontend/base/default/template/sobu/checkout/share.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <br>
2
+ <br>
3
+ <div class="block block-sobu">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('Mit sobu publizieren und profitieren') ?></span></strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <div>
9
+ <p class="empty"> <img src="<?php echo $this->getSkinUrl('images/sobu/sobulogo.png') ?>" align="left" /><?php echo $this->__('Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung.') ?></p>
10
+ <div class="clearer"></div>
11
+ </div>
12
+ <div class="actions">
13
+ <button class="button" onclick="setLocation('<?php echo $this->getUrl('sobu/share/order', array('order_id' => Mage::getSingleton('checkout/session')->getLastOrderId()))?>')" title="<?php echo $this->__('Einkauf publizieren!') ?>" type="button"><span><span><?php echo $this->__('Einkauf publizieren!') ?></span></span></button>
14
+ </div>
15
+ </div>
16
+ </div>
app/design/frontend/base/default/template/sobu/order/share.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1><?php echo $this->__('Sie werden nun zur Sobu Plattform weitergeleitet...') ?></h1>
3
+ </div>
4
+ <p>
5
+ <?php echo $this->__('Wenn diese Seite länger als fünf Sekunden angezeigt wird,') ?> <a href="javascript:document.forms.publish.submit();"><?php echo $this->__('hier klicken') ?></a>.
6
+ </p>
7
+
8
+ <form name="publish" method="POST" action="https://www.sobu.ch/publish">
9
+ <input type="hidden" name="apiKey" value="<?=$this->getApiKey() ?>"/>
10
+ <input type="hidden" name="order" value='<?=$orderdata = $this->getOrderData() ?>'/>
11
+ <input type="hidden" name="signature" value="<?=$this->getSignatureData($orderdata) ?>"/>
12
+ </form>
13
+
14
+ <script type="text/javascript">
15
+ window.onload = function () {
16
+ document.forms.publish.submit();
17
+ }
18
+ </script>
app/design/frontend/base/default/template/sobu/sales/order/share.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <br>
2
+ <br>
3
+ <div class="block block-sobu">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('Mit sobu publizieren und profitieren') ?></span></strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <div>
9
+ <p class="empty"> <img src="<?php echo $this->getSkinUrl('images/sobu/sobulogo.png') ?>" align="left" /><?php echo $this->__('Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung.') ?></p>
10
+ <div class="clearer"></div>
11
+ </div>
12
+ <div class="actions">
13
+ <button class="button" onclick="setLocation('<?php echo $this->getUrl('sobu/share/order', array('order_id' => $this->getOrder()->getId()))?>')" title="<?php echo $this->__('Einkauf publizieren!') ?>" type="button"><span><span><?php echo $this->__('Einkauf publizieren!') ?></span></span></button>
14
+ </div>
15
+ </div>
16
+ </div>
app/design/frontend/base/default/template/sobu/sales/order/totals.phtml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /**
27
+ * @var $this Mage_Sales_Block_Order_Totals
28
+ * @see Mage_Sales_Block_Order_Totals
29
+ */
30
+ ?>
31
+ <?php foreach ($this->getTotals() as $_code => $_total): ?>
32
+ <?php if ($_total->getBlockName()): ?>
33
+ <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
34
+ <?php else:?>
35
+ <tr class="<?php echo $_code?>">
36
+ <td <?php echo $this->getLabelProperties()?>>
37
+ <?php if ($_total->getStrong()):?>
38
+ <strong><?php echo $this->escapeHtml($_total->getLabel());?></strong>
39
+ <?php else:?>
40
+ <?php echo $this->escapeHtml($_total->getLabel());?>
41
+ <?php endif?>
42
+ </td>
43
+ <td <?php echo $this->getValueProperties()?>>
44
+ <?php if ($_total->getStrong()):?>
45
+ <strong><?php echo $this->formatValue($_total) ?></strong>
46
+ <?php else:?>
47
+ <?php echo $this->formatValue($_total) ?>
48
+ <?php endif?>
49
+ </td>
50
+ </tr>
51
+ <?php endif?>
52
+ <?php endforeach?>
53
+ <tr>
54
+ <td colspan="4">
55
+ <br>
56
+ <div style="padding: 0 10px">
57
+ <p><strong><?php echo $this->__('Mit sobu publizieren und profitieren') ?></strong><br>
58
+ <?php echo $this->__('Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung.') ?>
59
+ <a target="_blank" href="<?php echo $this->getUrl('sobu/share/order', array('order_id' => $this->getOrder()->getId()))?>"><?php echo $this->__('Einkauf publizieren!') ?></a></p>
60
+ </div>
61
+ </td>
62
+ </tr>
app/etc/modules/Smilla_Sobuintegration.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Smilla_Sobuintegration>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Smilla_Sobuintegration>
8
+ </modules>
9
+ </config>
app/locale/de_CH/Smilla_Sobuintegration.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "API Key","API Key"
2
+ "sobu API Key","sobu API Key"
3
+ "Test API Key","Test API Key"
4
+ "sobu Test API Key","sobu Test API Key"
5
+ "Settings","Einstellungen"
6
+ "Testmode?","Testmodus?"
7
+ "Public Key","Public Key"
8
+ "Run in Testmode?","Soll die Anbindung im Testmodus laufen?"
9
+ "Generate Key","Key generieren"
10
+ "Generate RSA Key","RSA Key generieren"
11
+ "Sobu Benefit Code","Sobu Gutschrift Code"
12
+ "Sobu Benefit","Sobu Gutschrift"
13
+ "Sobu Benefit was successfully applied","Sobu Gutschrift erfolgreich angewendet"
14
+ "Link not valid","Link ungültig"
15
+ "Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal","Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal"
16
+ "Mit sobu publizieren und profitieren","Mit sobu publizieren und profitieren"
17
+ "Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung.","Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung."
18
+ "Einkauf publizieren!","Einkauf publizieren!"
19
+ "Sie werden nun zur Sobu Plattform weitergeleitet...","Sie werden nun zur Sobu Plattform weitergeleitet..."
20
+ "Wenn diese Seite länger als fünf Sekunden angezeigt wird,","Wenn diese Seite länger als fünf Sekunden angezeigt wird,"
21
+ "hier klicken","hier klicken"
app/locale/de_DE/Smilla_Sobuintegration.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "API Key","API Key"
2
+ "sobu API Key","sobu API Key"
3
+ "Test API Key","Test API Key"
4
+ "sobu Test API Key","sobu Test API Key"
5
+ "Settings","Einstellungen"
6
+ "Testmode?","Testmodus?"
7
+ "Public Key","Public Key"
8
+ "Run in Testmode?","Soll die Anbindung im Testmodus laufen?"
9
+ "Generate Key","Key generieren"
10
+ "Generate RSA Key","RSA Key generieren"
11
+ "Sobu Benefit Code","Sobu Gutschrift Code"
12
+ "Sobu Benefit","Sobu Gutschrift"
13
+ "Sobu Benefit was successfully applied","Sobu Gutschrift erfolgreich angewendet"
14
+ "Link not valid","Link ungültig"
15
+ "Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal","Bitte kopieren Sie diesen Link nach der Generierung in Ihr Sobu-Portal"
16
+ "Mit sobu publizieren und profitieren","Mit sobu publizieren und profitieren"
17
+ "Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung.","Publizieren Sie jetzt Ihren Einkauf gratis mit Sobu und ihren sozialen Netzwerken und verdienen Sie Geld mit Freundschaftswerbung."
18
+ "Einkauf publizieren!","Einkauf publizieren!"
19
+ "Sie werden nun zur Sobu Plattform weitergeleitet...","Sie werden nun zur Sobu Plattform weitergeleitet..."
20
+ "Wenn diese Seite länger als fünf Sekunden angezeigt wird,","Wenn diese Seite länger als fünf Sekunden angezeigt wird,"
21
+ "hier klicken","hier klicken"
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Smilla_Sobuintegration</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrieren Sie Ihren Shop in das sobu Netzwerk. K&#xE4;ufe Teilen, Sobu Rabatte uvm. </summary>
10
+ <description>Durch die sobu Magento Extension ist es m&#xF6;glich einen Magento-Shop in das sobu Netzwerk zu integrieren.&#xD;
11
+ Vorraussetzung ist eine Magento Installation sowie ein g&#xFC;ltiger Vertrag mit der sobu-Plattform. Weitere Informationen dazu finden Sie unter: https://www.sobu.ch/de/partner</description>
12
+ <notes>sobu Integration 1.0.0</notes>
13
+ <authors><author><name>smilla AG</name><user>smilla</user><email>hendrik.unkenholz@smilla.com</email></author></authors>
14
+ <date>2013-11-20</date>
15
+ <time>17:01:17</time>
16
+ <contents><target name="magelocal"><dir name="Smilla"><dir name="PostChShippingLabel"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="b28a6d60ecebf1df36a323717630f852"/></dir></dir><dir name="View"><file name="Postchshippinglabel.php" hash="2ba040c5f973d8f5287dbe64e29e3950"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e821c705ee985f2fd6606b724dd999e0"/></dir><dir name="Model"><dir name="Source"><file name="Codeoptions.php" hash="4f73854bde626b90fcfcb568f2931857"/><file name="Formatoptions.php" hash="0dbe915bd42b21f17abbcbfb758dc741"/></dir></dir><dir name="controllers"><file name="PostchshippinglabelController.php" hash="9b83ae915a3cf3b7e5cea5cdde88f085"/></dir><dir name="etc"><file name="config.xml" hash="e8d9455d7111a3bea63ee942f48170b4"/><file name="system.xml" hash="b7f321041ca485bfeea6059da3690b19"/></dir></dir><dir name="Sobuintegration"><dir name="Block"><file name="Generatebutton.php" hash="74084f97064fa5806d715ead2ffef14d"/><file name="Share.php" hash="266f41ed10e3e7aca0281ca130e534c1"/></dir><dir name="Helper"><file name="Data.php" hash="0ea96dbfd04cf76b90e1e20401fef201"/></dir><dir name="Model"><dir name="Condition"><file name="Benefit.php" hash="b1bd857449aab759db38173c477eb26f"/></dir><file name="Observer.php" hash="822d1b975533db9b1d19cbd683c55ab1"/></dir><dir name="controllers"><file name="AdminController.php" hash="d3848d4ed2e3cbb5fa6ff0f78518c43e"/><file name="ShareController.php" hash="8e6e804fcfdbba00f8ed9e36da108cc6"/></dir><dir name="etc"><file name="config.xml" hash="3c778cedc46f383fdd1cf5534d016b1c"/><file name="system.xml" hash="fe668e67e730b31fd9d0f730662b34d3"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="sobu"><dir name="checkout"><file name="share.phtml" hash="4a3e7434d2949924e058deb31eb69c9a"/></dir><dir name="order"><file name="share.phtml" hash="dc6ef65cf5250539d583fd6ce3262bf8"/></dir><dir name="sales"><dir name="order"><file name="share.phtml" hash="3bcb445e1c9b3030b368644732fb45fc"/><file name="totals.phtml" hash="3558c7f0f40f15d9aa10212544f9bdc6"/></dir></dir></dir></dir><dir name="layout"><file name="sobuintegration.xml" hash="d61dc98b7476568cbc265cbe49dbfad1"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="sobu"><file name="sobulogo.png" hash="04e44b757c5b0e20c5277a556eb7fb71"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="de_CH"><file name="Smilla_Sobuintegration.csv" hash="16b02b9e10356fec03aee3a67a20a9dd"/></dir><dir name="de_DE"><file name="Smilla_Sobuintegration.csv" hash="16b02b9e10356fec03aee3a67a20a9dd"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Smilla_Sobuintegration.xml" hash="fee68335def2e0a2e3974f457ce34b90"/></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>
skin/frontend/base/default/images/sobu/sobulogo.png ADDED
Binary file