madai - Version 1.0.2

Version Notes

Initial release

Download this release

Release Info

Developer Madai
Extension madai
Version 1.0.2
Comparing to
See all releases


Version 1.0.2

app/code/local/Sevenlike/Madai/Block/Product/View.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sevenlike_Madai_Block_Product_View extends Mage_Core_Block_Template {
4
+
5
+ public function getMadaiId(){
6
+ $current_product = Mage::registry('current_product');
7
+ return $current_product->getMadaiId();
8
+ }
9
+ }
app/code/local/Sevenlike/Madai/Block/Trackorder.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Sevenlike_Madai_Block_Trackorder extends Mage_Core_Block_Text
3
+ {
4
+ protected function _getOrdersTrackingCode()
5
+ {
6
+ $result=null;
7
+ $orderIds = $this->getOrderIds();
8
+ if (empty($orderIds) || !is_array($orderIds)) {
9
+ return;
10
+ }
11
+ $collection = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('entity_id', array('in' => $orderIds));
12
+ foreach ($collection as $order) {
13
+ $order_id=Mage::getSingleton('checkout/session')->getQuote()->getMadaiOrderId();
14
+ $params = Mage::helper('madai')->getCloseTransactionParams($order->getIncrementId());
15
+ $url= Mage::helper('madai')->getMadaiUrl().'/wa/ui/magento/orders/'.$order_id.'/payment';
16
+ $fields_string='';
17
+ //url-ify the data for the POST
18
+ foreach($params as $key=>$value) {
19
+ //FIXME gestirlo meglio..
20
+ if ($key!="signature")
21
+ $fields_string .= $key.'='.$value.'&';
22
+ else
23
+ // $fields_string .= $key.'='.rawurlencode($value).'&';
24
+ $fields_string .= $key.'='.urlencode($value).'&';
25
+ }
26
+ rtrim($fields_string, '&');
27
+ $fields_string=substr($fields_string,0,-1);
28
+
29
+ $ch = curl_init();
30
+ curl_setopt($ch,CURLOPT_URL, $url);
31
+ curl_setopt($ch,CURLOPT_POST, count($params));
32
+ curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
33
+ //execute post
34
+ $result = curl_exec($ch);
35
+ Mage::log($result);
36
+ //echo "<hr><hr>";
37
+ //var_dump($result);
38
+ curl_close($ch);
39
+ }
40
+ return true;
41
+ }
42
+
43
+ protected function _toHtml()
44
+ {
45
+ return $this->_getOrdersTrackingCode();
46
+ }
47
+
48
+ }
app/code/local/Sevenlike/Madai/Helper/Data.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sevenlike_Madai_Helper_Data extends Mage_Core_Helper_Data{
4
+
5
+ protected $_cartProductIds;
6
+
7
+ public function __construct() {
8
+ $product_ids = array();
9
+ $products = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
10
+ foreach ($products as $_products){
11
+ $product_ids [$_products->getProductId()] = $_products->getQty();
12
+ }
13
+ $this->_cartProductIds = $product_ids;
14
+ }
15
+
16
+ /* Controllo se un singolo ID prodotto � nel carrello */
17
+ public function isInCart($product) {
18
+ return array_key_exists($product->getId(), $this->_cartProductIds);
19
+ }
20
+
21
+ /* Torna la quantita di un prodotto presente nel carrello */
22
+ public function getQty($product) {
23
+ return $this->_cartProductIds [$product->getId()];
24
+ }
25
+
26
+
27
+ /* Dati di connessione per il singolo store */
28
+ public function getSignerId(){
29
+ if (Mage::getStoreConfig('madai/madai/testmode')=="1")
30
+ return "30e77ae5-5803-472b-8f19-403f407aa440";
31
+ else
32
+ return Mage::getStoreConfig('madai/madai/signerid');
33
+ }
34
+
35
+ public function getSignatureKey(){
36
+ if (Mage::getStoreConfig('madai/madai/testmode')=="1")
37
+ return "4707a110ad567f65f7771693c51822bf80949c803608b1550f8cbca908163c845ca6e607744c547e8f7fa586f1ab1806cc0853e33f1953d1cb9d40828f3a56c2";
38
+ else
39
+ return Mage::getStoreConfig('madai/madai/signaturekey');
40
+ }
41
+
42
+ public function getFormHeight(){
43
+ return "500";
44
+ }
45
+
46
+ public function getIsCatalogHidden(){
47
+ return "true";
48
+ }
49
+
50
+ public function getMadaiUrl(){
51
+ if (Mage::getStoreConfig('madai/madai/testmode')=="1")
52
+ return "https://test.madai.com";
53
+ else
54
+ return "https://www.madai.com";
55
+ }
56
+
57
+ public function getMadaiModaJsUrl(){
58
+ if (Mage::getStoreConfig('madai/madai/testmode')=="1")
59
+ return "https://test.madai.com/wa/static/modal/modal.js";
60
+ else
61
+ return "http://cdn-madai-com.s3.amazonaws.com/pub/modal.js";
62
+ }
63
+
64
+
65
+ /* Formattazione della data in ISO8601 */
66
+ public function getActualIsoTime(){
67
+ //@todo gestione spartana..
68
+ $the_date = strtotime(date('Y-m-d H:i:s'));
69
+ date_default_timezone_get();
70
+ date("Y-d-mTG:i:sz",$the_date);
71
+ date_default_timezone_set("UTC");
72
+ $timestamp = date("Y-m-d", $the_date);
73
+ $timestamp.="T".date("H:i", $the_date)."Z";
74
+ return $timestamp;
75
+ }
76
+
77
+ public function hextobin($hexstr)
78
+ {
79
+ $n = strlen($hexstr);
80
+ $sbin="";
81
+ $i=0;
82
+ while($i<$n)
83
+ {
84
+ $a =substr($hexstr,$i,2);
85
+ $c = pack("H*",$a);
86
+ if ($i==0){$sbin=$c;}
87
+ else {$sbin.=$c;}
88
+ $i+=2;
89
+ }
90
+ return $sbin;
91
+ }
92
+
93
+ public function getCloseTransactionParams($order_id){
94
+ $signerId = Mage::helper('madai')->getSignerId();
95
+ $signerKey = Mage::helper('madai')->getSignatureKey();
96
+ $timestamp = Mage::helper('madai')->getActualIsoTime();
97
+ $message = "{orderId:\"{$order_id}\"}";
98
+ $hmac = hash_init("sha512", HASH_HMAC, Mage::helper('madai')->hextobin($signerKey));
99
+ hash_update($hmac, utf8_decode($signerId));
100
+ hash_update($hmac, utf8_decode($timestamp));
101
+ hash_update($hmac, utf8_decode($message));
102
+ $hmac = hash_final($hmac, true);
103
+ $hmac = bin2hex($hmac);
104
+ $params = array(
105
+ "message" => $message,
106
+ "signerId" => $signerId,
107
+ "timestamp" => $timestamp,
108
+ "signature" => $hmac,
109
+ );
110
+ return $params;
111
+ }
112
+ }
app/code/local/Sevenlike/Madai/Model/Observer.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sevenlike_Madai_Model_Observer {
4
+
5
+ public function applyDiscount(Varien_Event_Observer $observer)
6
+ {
7
+ /* @var $item Mage_Sales_Model_Quote_Item */
8
+ $item = $observer->getQuoteItem();
9
+ if ($item->getParentItem()) {
10
+ $item = $item->getParentItem();
11
+ }
12
+ $madai_discount = Mage::getSingleton('checkout/session')->getQuote()->getMadaiDiscount();
13
+ $madai_order_id = Mage::getSingleton('checkout/session')->getQuote()->getMadaiOrderId();
14
+ // ho il prodotto Madai nel carrello
15
+ if ($madai_discount){
16
+ $actual_qty = floatval(Mage::helper('madai')->getQty($item->getProduct()));
17
+ if ($actual_qty==1){
18
+ $specialPrice = $item->getProduct()->getPrice()-$madai_discount;
19
+ $item->setMadaiDiscount($madai_discount);
20
+ $item->setMadaiOrderId($madai_order_id);
21
+ }
22
+ else{
23
+ $specialPrice = (($item->getProduct()->getPrice()*$actual_qty)-$madai_discount)/$actual_qty;
24
+ }
25
+ $item->setCustomPrice($specialPrice);
26
+ $item->setOriginalCustomPrice($specialPrice);
27
+ $item->getProduct()->setIsSuperMode(true);
28
+ }
29
+
30
+ }
31
+
32
+ /**
33
+ * @param Varien_Event_Observer $observer
34
+ */
35
+ public function applyDiscounts(Varien_Event_Observer $observer)
36
+ {
37
+
38
+ foreach ($observer->getCart()->getQuote()->getAllVisibleItems() as $item /* @var $item Mage_Sales_Model_Quote_Item */) {
39
+ if ($item->getParentItem()) {
40
+ $item = $item->getParentItem();
41
+ }
42
+ if ($item->getMadaiDiscount() > 0) {
43
+ $specialPrice = (($item->getProduct()->getPrice()*$item->getQty())-$item->getMadaiDiscount())/$item->getQty();
44
+ $item->setCustomPrice($specialPrice);
45
+ $item->setOriginalCustomPrice($specialPrice);
46
+ $item->getProduct()->setIsSuperMode(true);
47
+ }
48
+ }
49
+ }
50
+ /*
51
+ public function setCustomDataOnQuoteItem(Varien_Event_Observer $observer)
52
+ {
53
+
54
+ $quote = Mage::getModel('checkout/cart')->getQuote();
55
+ $orderItem = $observer->getOrderItem();
56
+ foreach ( $quote->getAllVisibleItems() as $_item )
57
+ {
58
+ if ($_item->getSku() == $orderItem->getSku())
59
+ {
60
+ $orderItem->setMadaiDiscount($_item->getMadaiDiscount());
61
+ }
62
+ }
63
+ }
64
+ */
65
+
66
+ public function sendOrderConfirmation(Varien_Event_Observer $observer)
67
+ {
68
+ $orderIds = $observer->getEvent()->getOrderIds();
69
+ if (empty($orderIds) || !is_array($orderIds)) {
70
+ return;
71
+ }
72
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('madai_trackorder');
73
+ if ($block) {
74
+ $block->setOrderIds($orderIds);
75
+ }
76
+ }
77
+
78
+ }
79
+
app/code/local/Sevenlike/Madai/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sevenlike_Madai_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ /*
6
+ * Azione che intercetta i parametri in ritorno
7
+ * dalla pagina della scheda prodotto di Madai,
8
+ * Dopo che l'utente ha ridotto il prezzo verso questa
9
+ * rotta vengono passati i paramentri come da specifiche
10
+ */
11
+ public function returnAction()
12
+ {
13
+ Mage::log($this->getRequest()->getParams(),"madai.log");
14
+ if (($this->getRequest()->getParam('signerId')) && ($this->getRequest()->getParam('signerId'))){
15
+ //raccolgo tutti i paramentri passati dalla piattaforma
16
+ $submit_x=$this->getRequest()->getParam('submit_x');
17
+ $submit_y=$this->getRequest()->getParam('submit_y');
18
+ $signerId=$this->getRequest()->getParam('signerId');
19
+ $timestamp=$this->getRequest()->getParam('timestamp');
20
+ $order=urldecode($this->getRequest()->getParam('order'));
21
+ $signature=$this->getRequest()->getParam('signature');
22
+ $json = json_decode($order);
23
+ $madai_price =$json->price->amount;
24
+ $madai_id =$json->productId;
25
+ $order_id = $json->orderId;
26
+ try {
27
+ //Faccio un Load 2 volte! Con LoadByAttribute non ho infatti i dati di stock.
28
+ $product = Mage::getModel('catalog/product')->loadByAttribute("madai_id",$madai_id);
29
+ $product= Mage::getModel('catalog/product')->load($product->getEntityId());
30
+ //Setto i dati sulla sessione cosi' da riprenderli nell'observer e settarli sul singolo item
31
+ Mage::getSingleton('checkout/session')->getQuote()->setMadaiDiscount($product->getFinalPrice()-$madai_price);
32
+ Mage::getSingleton('checkout/session')->getQuote()->setMadaiOrderId($order_id);
33
+ //aggiungo il prodotto al carrello
34
+ $cart = Mage::getSingleton('checkout/cart');
35
+ $cart->addProduct($product, array('qty' => 1));
36
+ $cart->save();
37
+ }
38
+ catch (Exception $ex) {
39
+ echo $ex->getMessage();
40
+ }
41
+ $this->_redirectUrl("/checkout/cart");
42
+ }
43
+ else{
44
+ Mage::getSingleton('customer/session')->addError('There was an error processing your request');
45
+ }
46
+ }
47
+ }
app/code/local/Sevenlike/Madai/etc/config.xml ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Sevenlike_Madai>
5
+ <version>1.0.2</version>
6
+ </Sevenlike_Madai>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <madai>
11
+ <class>Sevenlike_Madai_Block</class>
12
+ </madai>
13
+ </blocks>
14
+ <models>
15
+ <madai>
16
+ <class>Sevenlike_Madai_Model</class>
17
+ </madai>
18
+ </models>
19
+ <helpers>
20
+ <madai>
21
+ <class>Sevenlike_Madai_Helper</class>
22
+ </madai>
23
+ </helpers>
24
+ <resources>
25
+ <madai_setup>
26
+ <setup>
27
+ <module>Sevenlike_Madai</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </madai_setup>
33
+ </resources>
34
+
35
+ <fieldsets>
36
+ <sales_convert_quote_item>
37
+ <madai_discount>
38
+ <to_order_item>*</to_order_item>
39
+ </madai_discount>
40
+ <madai_order_id>
41
+ <to_order_item>*</to_order_item>
42
+ </madai_order_id>
43
+ </sales_convert_quote_item>
44
+
45
+ <sales_convert_order_item>
46
+ <madai_discount>
47
+ <to_quote_item>*</to_quote_item>
48
+ </madai_discount>
49
+ <madai_order_id>
50
+ <to_quote_item>*</to_quote_item>
51
+ </madai_order_id>
52
+
53
+ </sales_convert_order_item>
54
+ </fieldsets>
55
+
56
+ </global>
57
+ <frontend>
58
+ <events>
59
+ <checkout_cart_product_add_after>
60
+ <observers>
61
+ <madai_priceupdate_observer>
62
+ <type>singleton</type>
63
+ <class>madai/observer</class>
64
+ <method>applyDiscount</method>
65
+ </madai_priceupdate_observer>
66
+ </observers>
67
+ </checkout_cart_product_add_after>
68
+ <checkout_cart_update_items_after>
69
+ <observers>
70
+ <madai_priceupdate_observer>
71
+ <type>singleton</type>
72
+ <class>madai/observer</class>
73
+ <method>applyDiscounts</method>
74
+ </madai_priceupdate_observer>
75
+ </observers>
76
+ </checkout_cart_update_items_after>
77
+ <!-- <sales_convert_quote_item_to_order_item>
78
+ <observers>
79
+ <quoteitem_set_custom_data>
80
+ <class>madai/observer</class>
81
+ <method>setCustomDataOnQuoteItem</method>
82
+ </quoteitem_set_custom_data>
83
+ </observers>
84
+ </sales_convert_quote_item_to_order_item> -->
85
+ <checkout_onepage_controller_success_action>
86
+ <observers>
87
+ <madai_order_success>
88
+ <class>madai/observer</class>
89
+ <method>sendOrderConfirmation</method>
90
+ </madai_order_success>
91
+ </observers>
92
+ </checkout_onepage_controller_success_action>
93
+ <checkout_multishipping_controller_success_action>
94
+ <observers>
95
+ <madai_order_success>
96
+ <class>madai/observer</class>
97
+ <method>sendOrderConfirmation</method>
98
+ </madai_order_success>
99
+ </observers>
100
+ </checkout_multishipping_controller_success_action>
101
+
102
+ </events>
103
+
104
+ <layout>
105
+ <updates>
106
+ <madai>
107
+ <file>madai.xml</file>
108
+ </madai>
109
+ </updates>
110
+ </layout>
111
+ <translate>
112
+ <modules>
113
+ <Sevenlike_Madai>
114
+ <files>
115
+ <default>Sevenlike_Madai.csv</default>
116
+ </files>
117
+ </Sevenlike_Madai>
118
+ </modules>
119
+ </translate>
120
+ <routers>
121
+ <madai>
122
+ <use>standard</use>
123
+ <args>
124
+ <module>Sevenlike_Madai</module>
125
+ <frontName>madai</frontName>
126
+ </args>
127
+ </madai>
128
+ </routers>
129
+ </frontend>
130
+
131
+ <adminhtml>
132
+ <acl>
133
+ <resources>
134
+ <admin>
135
+ <children>
136
+ <system>
137
+ <children>
138
+ <config>
139
+ <children>
140
+ <madai>
141
+ <title>Madai section</title>
142
+ </madai>
143
+ </children>
144
+ </config>
145
+ </children>
146
+ </system>
147
+ </children>
148
+ </admin>
149
+ </resources>
150
+ </acl>
151
+ </adminhtml>
152
+
153
+ </config>
app/code/local/Sevenlike/Madai/etc/system.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <madai>
5
+ <label>Madai Integration</label>
6
+ <tab>sales</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>345</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <madai translate="madai" module="madai">
14
+ <label>Madai Integration</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>200</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <signerid>
22
+ <label>Signer Id</label>
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
+ </signerid>
29
+ <signerkey>
30
+ <label>Signer Key</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>20</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </signerkey>
37
+ <testmode translate="label">
38
+ <label>Test Mode</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>5</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </testmode>
46
+ </fields>
47
+ </madai>
48
+ </groups>
49
+ </madai>
50
+ </sections>
51
+ </config>
app/code/local/Sevenlike/Madai/sql/madai_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
7
+
8
+ $setup->addAttribute('catalog_product', 'madai_id', array(
9
+
10
+ 'group' => 'General',
11
+ 'input' => 'text',
12
+ 'type' => 'text',
13
+ 'label' => 'Madai Product ID',
14
+ 'backend' => '',
15
+ 'frontend' => '',
16
+ 'visible' => true,
17
+ 'required' => false,
18
+ 'user_defined' => true,
19
+ 'searchable' => false,
20
+ 'filterable' => false,
21
+ 'comparable' => false,
22
+ 'visible_on_front' => true,
23
+ 'visible_in_advanced_search' => false,
24
+ 'is_html_allowed_on_front' => false,
25
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
26
+ 'note' => 'Madai Product ID'
27
+ ));
28
+
29
+
30
+ $conn = $installer->getConnection();
31
+ $theTable = $this->getTable('sales_flat_quote_item');
32
+
33
+ if($conn->tableColumnExists($theTable, 'madai_discount'))
34
+ Mage::log('Column madai_discount already exists in quote item');
35
+ else
36
+ $conn->addColumn($theTable, 'madai_discount', 'DECIMAL(12,4)');
37
+
38
+
39
+ if($conn->tableColumnExists($theTable, 'madai_order_id'))
40
+ Mage::log('Column madai_product_id already exists in quote item');
41
+ else
42
+ $conn->addColumn($theTable, 'madai_order_id', 'VARHCAR(100)');
43
+
44
+
45
+ $theTable = $this->getTable('sales_flat_order_item');
46
+
47
+ if($conn->tableColumnExists($theTable, 'madai_discount'))
48
+ Mage::log('Column madai_discount already exists in order_item');
49
+ else
50
+ $conn->addColumn($theTable, 'madai_discount', 'DECIMAL(12,4)');
51
+
52
+
53
+ if($conn->tableColumnExists($theTable, 'madai_order_id'))
54
+ Mage::log('Column madai_product_id already exists in order_item');
55
+ else
56
+ $conn->addColumn($theTable, 'madai_order_id', 'VARHCAR(100)');
57
+
58
+
59
+ $installer->endSetup();
app/design/frontend/default/default/layout/madai.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="product.info">
5
+ <block type="madai/product_view" name="madai" template="madai/product/view/reduceprice.phtml" />
6
+ </reference>
7
+ </catalog_product_view>
8
+ <checkout_onepage_success>
9
+ <reference name="after_body_start">
10
+ <block type="madai/trackorder" name="madai_trackorder" as="madai_trackorder" />
11
+ </reference>
12
+ </checkout_onepage_success>
13
+ </layout>
app/design/frontend/default/default/template/madai/product/view/reduceprice.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
2
+ <script type="text/javascript" src="<?php echo Mage::helper('madai')->getMadaiModaJsUrl(); ?>"></script>
3
+ <script type="text/javascript">
4
+ madai.web.modal.config = {
5
+ "<?php echo Mage::helper('madai')->getSignerId() ?>": { // id della campagna
6
+ products: [
7
+ "<?php echo $this->getMadaiId();?>", // id del prodotto
8
+ ],
9
+ height: <?php echo Mage::helper('madai')->getFormHeight() ?>,
10
+ is_catalog_hidden: <?php echo Mage::helper('madai')->getIsCatalogHidden() ?>
11
+ }
12
+ };
13
+ </script>
14
+ <br/>
15
+ <button onclick="javascript:madai.web.modal.open_product('<?php echo $this->getMadaiId();?>');" class="button btn-cart" title="Riduci il prezzo" type="button"><span><span>Riduci il prezzo</span></span></button>
app/etc/modules/Sevenlike_Madai.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Sevenlike_Madai>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Sevenlike_Madai>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>madai</name><version>1.0.2</version><stability>stable</stability><license>OSL</license><channel>community</channel><extends></extends><summary>madai is a cloud-based engagement, conversion and rewarding platform based on a unique crowdrebating model.</summary><description>madai is a cloud-based engagement, conversion and rewarding platform based on a unique crowdrebating model.</description><notes>Initial release</notes><authors><author><name>Madai</name><user>madai</user><email>info@madai.com</email></author></authors><date>2013-08-08</date><time>7:01:18</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="design"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="madai"><dir name="product"><dir name="view"><file name="reduceprice.phtml" hash="c82fcce7a13ede474dbf655e60dc81c8"/></dir></dir></dir></dir><dir name="layout"><file name="madai.xml" hash="e5d3832683a432aff103f2f7b68e667b"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Sevenlike_Madai.xml" hash="6dfa9950f4fad5af858fffabffb6ea04"/></dir></dir><dir name="code"><dir name="local"><dir name="Sevenlike"><dir name="Madai"><dir name="Helper"><file name="Data.php" hash="b2f2d699b9ff5cc101aad1c4b8e999b1"/></dir><dir name="etc"><file name="config.xml" hash="d025b3efa0290a46eca0e72881d5c2c5"/><file name="system.xml" hash="bebd588b51a83d97eb8ce309add31c0f"/></dir><dir name="Block"><file name="Trackorder.php" hash="7dc4847f09bddea8cb6bcead9a6cfb0b"/><dir name="Product"><file name="View.php" hash="18672f2c51e56002f39d1164cd803832"/></dir></dir><dir name="Model"><file name="Observer.php" hash="7fec7f6fa09282e6947349f6dac0d486"/></dir><dir name="sql"><dir name="madai_setup"><file name="mysql4-install-1.0.0.php" hash="ddd2d03ea087613a03175172c098f6f6"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="4b7017aefd3e201a347b6a0063213ee5"/></dir></dir></dir></dir></dir></dir></target></contents></package>