PayRandom - Version 1.0.0

Version Notes

First version of PayRandom Extension

Download this release

Release Info

Developer PayRandom
Extension PayRandom
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (115) hide show
  1. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Choose.php +37 -0
  2. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Choose/Grid.php +103 -0
  3. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Current.php +22 -0
  4. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Current/Grid.php +99 -0
  5. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit.php +28 -0
  6. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Form.php +18 -0
  7. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Tab/Form.php +72 -0
  8. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Tabs.php +22 -0
  9. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Predefined.php +22 -0
  10. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Predefined/Grid.php +102 -0
  11. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Sold.php +22 -0
  12. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Sold/Grid.php +115 -0
  13. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Amount.php +10 -0
  14. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Attraction.php +33 -0
  15. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Balance.php +20 -0
  16. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Discount.php +41 -0
  17. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Fixed/Value.php +15 -0
  18. app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Option.php +13 -0
  19. app/code/community/PayRandom/PRPayment/Block/Catalog/Product/Grid.php +17 -0
  20. app/code/community/PayRandom/PRPayment/Block/Catalog/Product/Renderer.php +26 -0
  21. app/code/community/PayRandom/PRPayment/Block/Checkout/Cart.php +22 -0
  22. app/code/community/PayRandom/PRPayment/Block/Checkout/Cart/Item/Renderer.php +33 -0
  23. app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Link.php +22 -0
  24. app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Payment.php +23 -0
  25. app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Review/Info.php +23 -0
  26. app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Shipping/Method.php +23 -0
  27. app/code/community/PayRandom/PRPayment/Block/Form/Prpayment.php +9 -0
  28. app/code/community/PayRandom/PRPayment/Block/Product/Price.php +22 -0
  29. app/code/community/PayRandom/PRPayment/Block/Product/View.php +24 -0
  30. app/code/community/PayRandom/PRPayment/Block/Tax/Checkout/Grandtotal.php +23 -0
  31. app/code/community/PayRandom/PRPayment/Block/Tax/Checkout/Subtotal.php +23 -0
  32. app/code/community/PayRandom/PRPayment/Helper/Data.php +286 -0
  33. app/code/community/PayRandom/PRPayment/Helper/Data/Api.php +267 -0
  34. app/code/community/PayRandom/PRPayment/Helper/Data/Data.php +6 -0
  35. app/code/community/PayRandom/PRPayment/Model/Deal.php +36 -0
  36. app/code/community/PayRandom/PRPayment/Model/Dealproduct.php +19 -0
  37. app/code/community/PayRandom/PRPayment/Model/Observer.php +48 -0
  38. app/code/community/PayRandom/PRPayment/Model/Predefineddeal.php +14 -0
  39. app/code/community/PayRandom/PRPayment/Model/Productstatistics.php +14 -0
  40. app/code/community/PayRandom/PRPayment/Model/Resource/Deal.php +6 -0
  41. app/code/community/PayRandom/PRPayment/Model/Resource/Deal/Collection.php +10 -0
  42. app/code/community/PayRandom/PRPayment/Model/Resource/Dealproduct.php +6 -0
  43. app/code/community/PayRandom/PRPayment/Model/Resource/Dealproduct/Collection.php +10 -0
  44. app/code/community/PayRandom/PRPayment/Model/Resource/Predefineddeal.php +6 -0
  45. app/code/community/PayRandom/PRPayment/Model/Resource/Predefineddeal/Collection.php +10 -0
  46. app/code/community/PayRandom/PRPayment/Model/Resource/Productstatistics.php +6 -0
  47. app/code/community/PayRandom/PRPayment/Model/Resource/Productstatistics/Collection.php +10 -0
  48. app/code/community/PayRandom/PRPayment/Model/Resource/Setup.php +3 -0
  49. app/code/community/PayRandom/PRPayment/Model/Standard.php +22 -0
  50. app/code/community/PayRandom/PRPayment/controllers/DealsController.php +243 -0
  51. app/code/community/PayRandom/PRPayment/controllers/InfoController.php +50 -0
  52. app/code/community/PayRandom/PRPayment/controllers/PaymentController.php +135 -0
  53. app/code/community/PayRandom/PRPayment/etc/adminhtml.xml +57 -0
  54. app/code/community/PayRandom/PRPayment/etc/config.xml +209 -0
  55. app/code/community/PayRandom/PRPayment/etc/system.xml +97 -0
  56. app/code/community/PayRandom/PRPayment/sql/prpayment_setup/mysql4-install-0.1.0.php +132 -0
  57. app/design/adminhtml/base/default/template/prpayment/deal/design.phtml +258 -0
  58. app/design/adminhtml/base/default/template/prpayment/info.phtml +10 -0
  59. app/design/adminhtml/base/default/template/prpayment/predefinedgrid.phtml +214 -0
  60. app/design/adminhtml/default/default/layout/prpayment.xml +15 -0
  61. app/design/frontend/base/default/layout/prpayment.xml +121 -0
  62. app/design/frontend/base/default/template/prpayment/addtocart_pr.phtml +12 -0
  63. app/design/frontend/base/default/template/prpayment/catalog/product/list.phtml +200 -0
  64. app/design/frontend/base/default/template/prpayment/catalog/product/view/addtocart.phtml +28 -0
  65. app/design/frontend/base/default/template/prpayment/catalog/product/view/type/default.phtml +24 -0
  66. app/design/frontend/base/default/template/prpayment/checkout/cart.phtml +180 -0
  67. app/design/frontend/base/default/template/prpayment/checkout/cart/item/default.phtml +268 -0
  68. app/design/frontend/base/default/template/prpayment/checkout/onepage/link.phtml +7 -0
  69. app/design/frontend/base/default/template/prpayment/checkout/onepage/payment.phtml +54 -0
  70. app/design/frontend/base/default/template/prpayment/checkout/onepage/review/button.phtml +7 -0
  71. app/design/frontend/base/default/template/prpayment/checkout/onepage/review/item.phtml +221 -0
  72. app/design/frontend/base/default/template/prpayment/checkout/onepage/shipping_method.phtml +27 -0
  73. app/design/frontend/base/default/template/prpayment/form/prpayment.phtml +37 -0
  74. app/design/frontend/base/default/template/prpayment/onestepcheckout/checkout.phtml +1310 -0
  75. app/design/frontend/base/default/template/prpayment/onestepcheckout/summary.phtml +185 -0
  76. app/design/frontend/base/default/template/prpayment/price.phtml +90 -0
  77. app/design/frontend/base/default/template/prpayment/price_full.phtml +93 -0
  78. app/design/frontend/base/default/template/prpayment/redirect.phtml +8 -0
  79. app/design/frontend/base/default/template/prpayment/review.phtml +63 -0
  80. app/design/frontend/base/default/template/prpayment/tax/checkout/grandtotal.phtml +39 -0
  81. app/design/frontend/base/default/template/prpayment/tax/checkout/subtotal.phtml +36 -0
  82. app/etc/modules/PayRandom_PRPayment.xml +16 -0
  83. app/locale/en_US/PayRandom_PRPayment.csv +90 -0
  84. app/locale/es_ES/PayRandom_PRPayment.csv +90 -0
  85. package.xml +26 -0
  86. skin/adminhtml/base/default/css/prpayment/adminprpayment.css +98 -0
  87. skin/adminhtml/base/default/js/prpayment/adminprpayment.js +288 -0
  88. skin/adminhtml/default/default/images/prpayment/add.png +0 -0
  89. skin/adminhtml/default/default/images/prpayment/attraction_high.png +0 -0
  90. skin/adminhtml/default/default/images/prpayment/attraction_medium.png +0 -0
  91. skin/adminhtml/default/default/images/prpayment/attraction_very_high.png +0 -0
  92. skin/adminhtml/default/default/images/prpayment/delete.png +0 -0
  93. skin/adminhtml/default/default/images/prpayment/edit.png +0 -0
  94. skin/adminhtml/default/default/images/prpayment/payrandom.png +0 -0
  95. skin/adminhtml/default/default/images/prpayment/slider-attraction.png +0 -0
  96. skin/adminhtml/default/default/images/prpayment/slider-handler-shadow.png +0 -0
  97. skin/adminhtml/default/default/images/prpayment/slider-handler.png +0 -0
  98. skin/adminhtml/default/default/images/prpayment/slider.png +0 -0
  99. skin/frontend/base/default/css/prpayment/prpayment.css +107 -0
  100. skin/frontend/base/default/images/prpayment/help.png +0 -0
  101. skin/frontend/base/default/images/prpayment/information_excl.png +0 -0
  102. skin/frontend/base/default/images/prpayment/information_question.png +0 -0
  103. skin/frontend/base/default/images/prpayment/lens.png +0 -0
  104. skin/frontend/base/default/images/prpayment/logo_pr.png +0 -0
  105. skin/frontend/base/default/images/prpayment/logo_pr_150.png +0 -0
  106. skin/frontend/base/default/images/prpayment/logo_pr_min.png +0 -0
  107. skin/frontend/base/default/images/prpayment/logo_pr_small.png +0 -0
  108. skin/frontend/base/default/images/prpayment/logo_pr_white.png +0 -0
  109. skin/frontend/base/default/images/prpayment/logo_pr_white_small.png +0 -0
  110. skin/frontend/base/default/images/prpayment/modalbox/close.png +0 -0
  111. skin/frontend/base/default/images/prpayment/modalbox/roulette.png +0 -0
  112. skin/frontend/base/default/images/prpayment/modalbox/video.png +0 -0
  113. skin/frontend/base/default/images/prpayment/roulette.png +0 -0
  114. skin/frontend/base/default/images/prpayment/roulette_2.png +0 -0
  115. skin/frontend/base/default/js/prpayment/prpayment.js +35 -0
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Choose.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Choose extends Mage_Adminhtml_Block_Widget_Grid_Container{
3
+
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'prpayment';
7
+ $this->_controller = 'adminhtml_deals_choose';
8
+
9
+ $this->_headerText = Mage::helper('prpayment')->__('Asignar ruleta PayRandom');
10
+
11
+
12
+ $this->_addButton('back', array(
13
+ 'label' => Mage::helper('adminhtml')->__('Back'),
14
+ 'onclick' => 'javascript: history.go(-1)',
15
+ 'class' => 'back',
16
+ ));
17
+
18
+ $this->_addButton('assign', array(
19
+ 'label' => Mage::helper('prpayment')->__('Asignar ruleta'),
20
+ 'onclick' => 'prPaymentAssignPredefined()',
21
+ 'class' => 'assign',
22
+ ));
23
+
24
+ $this->_addButton('add', array(
25
+ 'label' => Mage::helper('prpayment')->__('Nueva ruleta'),
26
+ 'onclick' => 'setLocation(\'' . $this->getCreateUrl() .'\')',
27
+ 'class' => 'add',
28
+ ));
29
+
30
+ parent::__construct();
31
+ }
32
+
33
+ public function getCreateUrl(){
34
+ $productId = $this->getRequest()->getParam('product_id');
35
+ return Mage::helper("adminhtml")->getUrl('*/deals/new', array('product_id' => $productId));
36
+ }
37
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Choose/Grid.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Choose_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('predefinedDealsGrid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+
12
+ $this->setTemplate('prpayment/predefinedgrid.phtml');
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('prpayment/predefineddeal')->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+ $avgPrice = 20;
25
+ $product = Mage::getModel('catalog/product')->load($this->getRequest()->getParam('product_id'));
26
+ if($product->getPrice()){
27
+ $avgPrice = $product->getPrice();
28
+ }
29
+
30
+ if($this->getRequest()->getParam('avg_price')){
31
+ $avgPrice = $this->getRequest()->getParam('avg_price');
32
+ }
33
+ $this->setAvgPrice($avgPrice);
34
+ $this->addColumn('id',
35
+ array(
36
+ 'align' =>'right',
37
+ 'width' => '50px',
38
+ 'index' => 'id',
39
+ 'sortable' => false,
40
+ 'filter' => false,
41
+ 'renderer' => new PayRandom_PRPayment_Block_Adminhtml_Renderer_Option(),
42
+ ));
43
+ $this->addColumn('name',
44
+ array(
45
+ 'header' => Mage::helper('prpayment')->__('Nombre'),
46
+ 'align' =>'left',
47
+ 'filter' => false,
48
+ 'index' => 'name',
49
+ ));
50
+
51
+ for($i = 0; $i < 8; $i++){
52
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Discount($i);
53
+ $renderer->setAvgPrice($avgPrice);
54
+ $this->addColumn('discounts' . $i,
55
+ array(
56
+ 'align' =>'right',
57
+ 'index' => 'discounts',
58
+ 'renderer' => $renderer,
59
+ 'filter' => false,
60
+ 'sortable' => false,
61
+ ));
62
+ }
63
+
64
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Fixed_Value($avgPrice);
65
+ $this->addColumn('priceavg',
66
+ array(
67
+ 'header' => Mage::helper('prpayment')->__('Precio medio'),
68
+ 'align' =>'right',
69
+ 'renderer' => $renderer,
70
+ 'filter' => false,
71
+ 'sortable' => false,
72
+ ));
73
+
74
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Balance($avgPrice);
75
+ $this->addColumn('balance',
76
+ array(
77
+ 'header' => Mage::helper('prpayment')->__('Equilibrio'),
78
+ 'align' =>'right',
79
+ 'renderer' => $renderer,
80
+ 'index' => 'discounts',
81
+ 'filter' => false,
82
+ 'sortable' => false,
83
+ ));
84
+
85
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Attraction($avgPrice);
86
+ $this->addColumn('attraction',
87
+ array(
88
+ 'header' => Mage::helper('prpayment')->__('Atracción'),
89
+ 'align' =>'left',
90
+ 'renderer' => $renderer,
91
+ 'index' => 'discounts',
92
+ 'filter' => false,
93
+ 'sortable' => false,
94
+ 'width' => '100px',
95
+ ));
96
+
97
+ return parent::_prepareColumns();
98
+ }
99
+ public function getRowUrl($row)
100
+ {
101
+ return false;
102
+ }
103
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Current.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Current extends Mage_Adminhtml_Block_Widget_Grid_Container{
3
+
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'prpayment';
7
+ $this->_controller = 'adminhtml_deals_current';
8
+
9
+ $this->_headerText = Mage::helper('prpayment')->__('Productos PR en juego');
10
+
11
+
12
+ $this->_addButton('back', array(
13
+ 'label' => Mage::helper('adminhtml')->__('Back'),
14
+ 'onclick' => 'javascript: history.go(-1)',
15
+ 'class' => 'back',
16
+ ));
17
+
18
+ parent::__construct();
19
+ $this->removeButton('add');
20
+
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Current/Grid.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Current_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('productStatisticsGrid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getModel('prpayment/productstatistics')->getCollection()
16
+ ->addFieldToFilter('active', array('=' => 1));
17
+
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+ $this->addColumn('product_name',
25
+ array(
26
+ 'header' => Mage::helper('prpayment')->__('Nombre'),
27
+ 'align' =>'left',
28
+ 'filter' => false,
29
+ 'index' => 'name',
30
+ ));
31
+ $this->addColumn('deal_name',
32
+ array(
33
+ 'header' => Mage::helper('prpayment')->__('Ruleta'),
34
+ 'align' =>'left',
35
+ 'filter' => false,
36
+ 'index' => 'deal_name',
37
+ ));
38
+ $this->addColumn('min_price',
39
+ array(
40
+ 'header' => Mage::helper('prpayment')->__('Precio mínimo'),
41
+ 'align' =>'left',
42
+ 'filter' => false,
43
+ 'index' => 'min_price',
44
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
45
+ ));
46
+ $this->addColumn('max_price',
47
+ array(
48
+ 'header' => Mage::helper('prpayment')->__('Precio máximo'),
49
+ 'align' =>'left',
50
+ 'filter' => false,
51
+ 'index' => 'max_price',
52
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
53
+ ));
54
+ $this->addColumn('total_amount',
55
+ array(
56
+ 'header' => Mage::helper('prpayment')->__('Total en ventas'),
57
+ 'align' =>'left',
58
+ 'filter' => false,
59
+ 'index' => 'total_amount',
60
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
61
+ ));
62
+ $this->addColumn('units',
63
+ array(
64
+ 'header' => Mage::helper('prpayment')->__('Unidades'),
65
+ 'align' =>'left',
66
+ 'filter' => false,
67
+ 'index' => 'units',
68
+ ));
69
+ $this->addColumn('times_purchased',
70
+ array(
71
+ 'header' => Mage::helper('prpayment')->__('Transacciones'),
72
+ 'align' =>'left',
73
+ 'filter' => false,
74
+ 'index' => 'times_purchased',
75
+ ));
76
+ $this->addColumn('expected_average_price',
77
+ array(
78
+ 'header' => Mage::helper('prpayment')->__('Precio medio esperado'),
79
+ 'align' =>'left',
80
+ 'filter' => false,
81
+ 'index' => 'expected_average_price',
82
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
83
+ ));
84
+ $this->addColumn('average_price',
85
+ array(
86
+ 'header' => Mage::helper('prpayment')->__('Precio medio'),
87
+ 'align' =>'left',
88
+ 'filter' => false,
89
+ 'index' => 'average_price',
90
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
91
+ ));
92
+
93
+ return parent::_prepareColumns();
94
+ }
95
+ public function getRowUrl($row)
96
+ {
97
+ return false;
98
+ }
99
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Edit extends Mage_Adminhtml_Block_Widget_Container{
3
+ protected function _prepareLayout()
4
+ {
5
+ $this->setTemplate('prpayment/deal/design.phtml');
6
+
7
+ $productId = $this->getRequest()->getParam('product_id');
8
+
9
+ $product = Mage::getModel('catalog/product')->load($productId);
10
+
11
+ if ( Mage::registry('deals_data') && Mage::registry('deals_data')->getId() )
12
+ {
13
+ $dealData = Mage::registry('deals_data');
14
+ $this->setDeal($dealData);
15
+ } else {
16
+ $this->setDeal(Mage::getModel('prpayment/deal'));
17
+ }
18
+
19
+
20
+ $this->setProduct($product);
21
+ $this->setAvgPrice($product->getPrice());
22
+
23
+ if($this->getRequest()->getParam('avg_price')){
24
+ $this->setAvgPrice($this->getRequest()->getParam('avg_price'));
25
+ }
26
+ return parent::_prepareLayout();
27
+ }
28
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Form.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(
7
+ array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))
10
+ ),
11
+ 'method' => 'post',
12
+ )
13
+ );
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Tab/Form.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ $fieldset = $form->addFieldset('deals_form',
9
+ array('legend'=> Mage::helper('prpayment')->__('Roulette discounts')));
10
+
11
+ $dealData = false;
12
+
13
+ if ( Mage::registry('deals_data') && Mage::registry('deals_data')->getId() )
14
+ {
15
+ $dealData = Mage::registry('deals_data');
16
+ }
17
+
18
+ $fieldset->addField('name', 'text',
19
+ array(
20
+ 'label' => Mage::helper('prpayment')->__('Name'),
21
+ 'class' => 'required-entry',
22
+ 'required' => true,
23
+ 'name' => 'name',
24
+ 'value' => ($dealData?$dealData->getName():''),
25
+ )
26
+ );
27
+
28
+ for($i = 0; $i < 8; $i++){
29
+ $fieldset->addField('discount' . $i, 'text',
30
+ array(
31
+ 'label' => Mage::helper('prpayment')->__('Discount') . ' ' . ($i + 1),
32
+ 'class' => 'required-entry validate-percents',
33
+ 'required' => true,
34
+ 'name' => 'discount' . $i,
35
+ 'value' => ($dealData?$dealData->getDiscount($i):''),
36
+ )
37
+ );
38
+ }
39
+
40
+ $options = array(
41
+ array(
42
+ 'value' => 'percentages',
43
+ 'label' => Mage::helper('prpayment')->__('Percentages')
44
+ ),
45
+ array(
46
+ 'value' => 'prices',
47
+ 'label' => Mage::helper('prpayment')->__('Prices')
48
+ )
49
+ );
50
+
51
+ $fieldset->addField('deals_product_id', 'hidden', array(
52
+ 'class' => 'required-entry',
53
+ 'required' => true,
54
+ 'name' => 'deals_product_id',
55
+ 'value' => Mage::registry('deals_product_id')
56
+ )
57
+ );
58
+
59
+ $fieldset2 = $form->addFieldset('deals_form2',
60
+ array('legend'=> Mage::helper('prpayment')->__('Options')));
61
+
62
+ $fieldset2->addField('view_format', 'select', array(
63
+ 'name' => 'view_format',
64
+ 'label' => Mage::helper('prpayment')->__('View format'),
65
+ 'title' => Mage::helper('prpayment')->__('View format'),
66
+ 'values' => $options,
67
+ 'value' => ($dealData?$dealData->getViewFormat():''),
68
+ ));
69
+
70
+ return parent::_prepareForm();
71
+ }
72
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Edit/Tabs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('deals_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('prpayment')->__('Deal'));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab('form_section', array(
14
+ 'label' => Mage::helper('prpayment')->__('Deal discounts'),
15
+ 'title' => Mage::helper('prpayment')->__('Deal discounts'),
16
+ 'content' => $this->getLayout()
17
+ ->createBlock('prpayment/adminhtml_deals_edit_tab_form')
18
+ ->toHtml()
19
+ ));
20
+ return parent::_beforeToHtml();
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Predefined.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Predefined extends Mage_Adminhtml_Block_Widget_Grid_Container{
3
+
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'prpayment';
7
+ $this->_controller = 'adminhtml_deals_predefined';
8
+
9
+ $this->_headerText = Mage::helper('prpayment')->__('Ruletas predefinidas');
10
+
11
+
12
+ $this->_addButton('back', array(
13
+ 'label' => Mage::helper('adminhtml')->__('Back'),
14
+ 'onclick' => 'javascript: history.go(-1)',
15
+ 'class' => 'back',
16
+ ));
17
+
18
+ parent::__construct();
19
+ $this->removeButton('add');
20
+
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Predefined/Grid.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Predefined_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('predefinedDealsGridInfo');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getModel('prpayment/predefineddeal')->getCollection();
16
+
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $avgPrice = 20;
24
+ $product = Mage::getModel('catalog/product')->load($this->getRequest()->getParam('product_id'));
25
+ if($product->getPrice()){
26
+ $avgPrice = $product->getPrice();
27
+ }
28
+
29
+ if($this->getRequest()->getParam('avg_price')){
30
+ $avgPrice = $this->getRequest()->getParam('avg_price');
31
+ }
32
+ $this->setAvgPrice($avgPrice);
33
+ $this->addColumn('id',
34
+ array(
35
+ 'align' =>'right',
36
+ 'width' => '50px',
37
+ 'index' => 'id',
38
+ 'sortable' => false,
39
+ 'filter' => false,
40
+ 'renderer' => new PayRandom_PRPayment_Block_Adminhtml_Renderer_Option(),
41
+ ));
42
+ $this->addColumn('name',
43
+ array(
44
+ 'header' => Mage::helper('prpayment')->__('Nombre'),
45
+ 'align' =>'left',
46
+ 'filter' => false,
47
+ 'index' => 'name',
48
+ ));
49
+
50
+ for($i = 0; $i < 8; $i++){
51
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Discount($i);
52
+ $renderer->setAvgPrice($avgPrice);
53
+ $this->addColumn('discounts' . $i,
54
+ array(
55
+ 'align' =>'right',
56
+ 'index' => 'discounts',
57
+ 'renderer' => $renderer,
58
+ 'filter' => false,
59
+ 'sortable' => false,
60
+ ));
61
+ }
62
+
63
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Fixed_Value($avgPrice);
64
+ $this->addColumn('priceavg',
65
+ array(
66
+ 'header' => Mage::helper('prpayment')->__('Precio medio'),
67
+ 'align' =>'right',
68
+ 'renderer' => $renderer,
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ ));
72
+
73
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Balance($avgPrice);
74
+ $this->addColumn('balance',
75
+ array(
76
+ 'header' => Mage::helper('prpayment')->__('Equilibrio'),
77
+ 'align' =>'right',
78
+ 'renderer' => $renderer,
79
+ 'index' => 'discounts',
80
+ 'filter' => false,
81
+ 'sortable' => false,
82
+ ));
83
+
84
+ $renderer = new PayRandom_PRPayment_Block_Adminhtml_Renderer_Attraction($avgPrice);
85
+ $this->addColumn('attraction',
86
+ array(
87
+ 'header' => Mage::helper('prpayment')->__('Atracción'),
88
+ 'align' =>'left',
89
+ 'renderer' => $renderer,
90
+ 'index' => 'discounts',
91
+ 'filter' => false,
92
+ 'sortable' => false,
93
+ 'width' => '100px',
94
+ ));
95
+
96
+ return parent::_prepareColumns();
97
+ }
98
+ public function getRowUrl($row)
99
+ {
100
+ return false;
101
+ }
102
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Sold.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Sold extends Mage_Adminhtml_Block_Widget_Grid_Container{
3
+
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'prpayment';
7
+ $this->_controller = 'adminhtml_deals_sold';
8
+
9
+ $this->_headerText = Mage::helper('prpayment')->__('Productos PR vendidos');
10
+
11
+
12
+ $this->_addButton('back', array(
13
+ 'label' => Mage::helper('adminhtml')->__('Back'),
14
+ 'onclick' => 'javascript: history.go(-1)',
15
+ 'class' => 'back',
16
+ ));
17
+
18
+ parent::__construct();
19
+ $this->removeButton('add');
20
+
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Deals/Sold/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Adminhtml_Deals_Sold_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('productStatisticsGrid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('ASC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getModel('prpayment/productstatistics')->getCollection()
16
+ ->addFieldToFilter('active', array('=' => 0));
17
+
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+ $this->addColumn('product_name',
25
+ array(
26
+ 'header' => Mage::helper('prpayment')->__('Nombre'),
27
+ 'align' =>'left',
28
+ 'filter' => false,
29
+ 'index' => 'name',
30
+ ));
31
+ $this->addColumn('deal_name',
32
+ array(
33
+ 'header' => Mage::helper('prpayment')->__('Ruleta'),
34
+ 'align' =>'left',
35
+ 'filter' => false,
36
+ 'index' => 'deal_name',
37
+ ));
38
+ $this->addColumn('min_price',
39
+ array(
40
+ 'header' => Mage::helper('prpayment')->__('Precio mínimo'),
41
+ 'align' =>'left',
42
+ 'filter' => false,
43
+ 'index' => 'min_price',
44
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
45
+ ));
46
+ $this->addColumn('max_price',
47
+ array(
48
+ 'header' => Mage::helper('prpayment')->__('Precio máximo'),
49
+ 'align' =>'left',
50
+ 'filter' => false,
51
+ 'index' => 'max_price',
52
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
53
+ ));
54
+
55
+ $this->addColumn('total_amount',
56
+ array(
57
+ 'header' => Mage::helper('prpayment')->__('Total en ventas'),
58
+ 'align' =>'left',
59
+ 'filter' => false,
60
+ 'index' => 'total_amount',
61
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
62
+ ));
63
+ $this->addColumn('units',
64
+ array(
65
+ 'header' => Mage::helper('prpayment')->__('Unidades'),
66
+ 'align' =>'left',
67
+ 'filter' => false,
68
+ 'index' => 'units',
69
+ ));
70
+ $this->addColumn('times_purchased',
71
+ array(
72
+ 'header' => Mage::helper('prpayment')->__('Transacciones'),
73
+ 'align' =>'left',
74
+ 'filter' => false,
75
+ 'index' => 'times_purchased',
76
+ ));
77
+ $this->addColumn('expected_average_price',
78
+ array(
79
+ 'header' => Mage::helper('prpayment')->__('Precio medio esperado'),
80
+ 'align' =>'left',
81
+ 'filter' => false,
82
+ 'index' => 'expected_average_price',
83
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
84
+ ));
85
+
86
+ $this->addColumn('average_price',
87
+ array(
88
+ 'header' => Mage::helper('prpayment')->__('Precio medio'),
89
+ 'align' =>'left',
90
+ 'filter' => false,
91
+ 'index' => 'average_price',
92
+ 'renderer' => 'PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount'
93
+ ));
94
+ $this->addColumn('start_date',
95
+ array(
96
+ 'header' => Mage::helper('prpayment')->__('Fecha inicio'),
97
+ 'align' =>'left',
98
+ 'filter' => false,
99
+ 'index' => 'start_date',
100
+ ));
101
+ $this->addColumn('end_date',
102
+ array(
103
+ 'header' => Mage::helper('prpayment')->__('Fecha final'),
104
+ 'align' =>'left',
105
+ 'filter' => false,
106
+ 'index' => 'end_date',
107
+ ));
108
+
109
+ return parent::_prepareColumns();
110
+ }
111
+ public function getRowUrl($row)
112
+ {
113
+ return false;
114
+ }
115
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Amount.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Amount extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function render(Varien_Object $row)
6
+ {
7
+ $value = $row->getData($this->getColumn()->getIndex());
8
+ return $this->helper('checkout')->formatPrice($value);
9
+ }
10
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Attraction.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Attraction extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function __construct($avgPrice)
6
+ {
7
+ parent::__construct();
8
+ $this->setAvgPrice($avgPrice);
9
+ }
10
+ public function render(Varien_Object $row)
11
+ {
12
+ $data = $row->getData($this->getColumn()->getIndex());
13
+
14
+ $jsonData = json_decode($data, true);
15
+ $avgPrice = $this->getAvgPrice();
16
+ $attraction = PayRandom_PRPayment_Helper_Data::calcAttraction($jsonData, $avgPrice);
17
+
18
+ if($attraction < 10){
19
+ $numberOfImg = 1;
20
+ $imgAttraction = $this->getSkinUrl('images/prpayment/attraction_medium.png');
21
+ $altText = Mage::helper('prpayment')->__('Atracción Media');
22
+ }elseif($attraction < 150){
23
+ $numberOfImg = 2;
24
+ $imgAttraction = $this->getSkinUrl('images/prpayment/attraction_high.png');
25
+ $altText = Mage::helper('prpayment')->__('Atracción Alta');
26
+ }else{
27
+ $numberOfImg = 3;
28
+ $imgAttraction = $this->getSkinUrl('images/prpayment/attraction_very_high.png');
29
+ $altText = Mage::helper('prpayment')->__('Atracción Muy Alta');
30
+ }
31
+ return str_repeat('<img src="' . $imgAttraction . '" alt="' . $altText . '" /> ', $numberOfImg);
32
+ }
33
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Balance.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Balance extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function __construct($avgPrice)
6
+ {
7
+ parent::__construct();
8
+ $this->setAvgPrice($avgPrice);
9
+ }
10
+
11
+ public function render(Varien_Object $row)
12
+ {
13
+ $data = $row->getData($this->getColumn()->getIndex());
14
+
15
+ $jsonData = json_decode($data, true);
16
+ $avgPrice = $this->getAvgPrice();
17
+
18
+ return number_format(PayRandom_PRPayment_Helper_Data::calcBalance($jsonData, $avgPrice));
19
+ }
20
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Discount.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Discount extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function __construct($discountPos = 0)
6
+ {
7
+ parent::__construct();
8
+ $this->setDiscountPos($discountPos);
9
+ }
10
+
11
+ public function render(Varien_Object $row)
12
+ {
13
+ $data = $row->getData($this->getColumn()->getIndex());
14
+
15
+ $jsonData = json_decode($data, true);
16
+
17
+ if($this->getAvgPrice()){
18
+ $diffOverAvg = $jsonData[$this->getDiscountPos()];
19
+
20
+ $price = PayRandom_PRPayment_Helper_Data::applyDiscount($diffOverAvg, $this->getAvgPrice());
21
+
22
+ $style = '';
23
+
24
+ $diffOverAvg = -$diffOverAvg;
25
+
26
+ if($diffOverAvg > 0){
27
+ $style = 'background-color: #ffe5e6;';
28
+ }elseif($diffOverAvg < 0){
29
+ $style = 'background-color: #e8f3e5;';
30
+ }
31
+
32
+ $return = '<span style="font-size: 0.8em;">' . ($diffOverAvg >= 0?'+':'') . (number_format($diffOverAvg * 100, 2)) . '%' . '</span>';
33
+ $return .= '<br/>';
34
+ $return .= $this->helper('checkout')->formatPrice($price);
35
+
36
+ return '<div style="' . $style . 'width:100%">' . $return . '</div>';
37
+ }else{
38
+ return $jsonData[$this->getDiscountPos()] * 100 . '%';
39
+ }
40
+ }
41
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Fixed/Value.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Fixed_Value extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function __construct($fixedValue = 0)
6
+ {
7
+ parent::__construct();
8
+ $this->setFixedValue($fixedValue);
9
+ }
10
+
11
+ public function render(Varien_Object $row)
12
+ {
13
+ return $this->helper('checkout')->formatPrice($this->getFixedValue());
14
+ }
15
+ }
app/code/community/PayRandom/PRPayment/Block/Adminhtml/Renderer/Option.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Adminhtml_Renderer_Option extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function render(Varien_Object $row)
6
+ {
7
+ $data = $row->getData($this->getColumn()->getIndex());
8
+ $productId = $this->getRequest()->getParam('product_id');
9
+
10
+ $assignUrl = Mage::helper("adminhtml")->getUrl('*/deals/assign', array('product_id' => $productId, 'predefined_deal_id' => $data));
11
+ return '<input type="radio" name="' . $this->getColumn()->getIndex() . '" value="' . $data . '" title="' . $assignUrl . '" />';
12
+ }
13
+ }
app/code/community/PayRandom/PRPayment/Block/Catalog/Product/Grid.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid {
4
+ protected function _prepareColumns() {
5
+ parent::_prepareColumns();
6
+ $this->addColumn('addPayRandom',
7
+ array(
8
+ 'header' => Mage::helper('prpayment')->__('PayRandom'),
9
+ 'width' => '50px',
10
+ 'filter' => false,
11
+ 'sortable' => false,
12
+ 'renderer' => 'PayRandom_PRPayment_Block_Catalog_Product_Renderer',
13
+ ));
14
+ return $this;
15
+ }
16
+
17
+ }
app/code/community/PayRandom/PRPayment/Block/Catalog/Product/Renderer.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Catalog_Product_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
3
+ public function render(Varien_Object $row) {
4
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
5
+ $product = Mage::getModel('catalog/product')->load($row->getId());
6
+
7
+ if (in_array( $row->getId(), $productsCanApply)) {
8
+ $value = $this->htmlEscape($this->__('Edit PayRandom Roulette')) ;
9
+ $img = '<img src="' . $this->getSkinUrl('images/prpayment/edit.png') . '" alt="' . $value . '" />';
10
+ $return = '<a href="' . Mage::helper("adminhtml")->getUrl('*/deals/edit', array('product_id' => $row->getId())) .'">' . $img . '</a>';
11
+
12
+ $value = $this->htmlEscape($this->__('Delete PayRandom Roulette')) ;
13
+ $img = '<img src="' . $this->getSkinUrl('images/prpayment/delete.png') . '" alt="' . $value . '" />';
14
+ $return .= '<a href="' . Mage::helper("adminhtml")->getUrl('*/deals/remove', array('product_id' => $row->getId())) .'" onclick="return confirm(\'' . $this->__('¿Estás seguro de que quieres eliminar la oferta PayRandom?') . '\');">' . $img . '</a>';
15
+
16
+ return $return;
17
+ }else{
18
+ if ($row->getTypeId() == "simple" && !$product->getSpecialPrice()) {
19
+ $value = $this->htmlEscape($this->__('Add PayRandom Roulette')) ;
20
+ $img = '<img src="' . $this->getSkinUrl('images/prpayment/add.png') . '" alt="' . $value . '" />';
21
+ return '<a href="' . Mage::helper("adminhtml")->getUrl('*/deals/choose', array('product_id' => $row->getId())) .'">' . $img . '</a>';
22
+ }
23
+ }
24
+ }
25
+
26
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Cart.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setTemplate('prpayment/checkout/cart.phtml');
16
+ }
17
+
18
+ $html = $this->renderView();
19
+ return $html;
20
+ }
21
+
22
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Cart/Item/Renderer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
14
+ $productId = $this->getItem()->getProduct()->getId();
15
+
16
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($productId);
17
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
18
+
19
+ $this->setMinimumDiscount($deal->getMinimumDiscount());
20
+ $this->setMaximumDiscount($deal->getMaximumDiscount());
21
+
22
+ if($this->getTemplate() == 'checkout/cart/item/default.phtml'){
23
+ $this->setTemplate('prpayment/checkout/cart/item/default.phtml');
24
+ }elseif($this->getTemplate() == 'checkout/onepage/review/item.phtml'){
25
+ $this->setTemplate('prpayment/checkout/onepage/review/item.phtml');
26
+ }
27
+ }
28
+
29
+ $html = $this->renderView();
30
+ return $html;
31
+ }
32
+
33
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Link.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_Onepage_Link
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setTemplate('prpayment/checkout/onepage/link.phtml');
16
+ }
17
+
18
+ $html = $this->renderView();
19
+ return $html;
20
+ }
21
+
22
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Payment.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Onepage_Payment extends Mage_Checkout_Block_Onepage_Payment
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setTemplate('prpayment/checkout/onepage/payment.phtml');
16
+ }
17
+
18
+ $html = $this->renderView();
19
+ return $html;
20
+ }
21
+
22
+
23
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Review/Info.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Onepage_Review_Info extends Mage_Checkout_Block_Onepage_Review_Info
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setTemplate('prpayment/review.phtml');
16
+ }
17
+
18
+ $html = $this->renderView();
19
+ return $html;
20
+ }
21
+
22
+
23
+ }
app/code/community/PayRandom/PRPayment/Block/Checkout/Onepage/Shipping/Method.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Checkout_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setTemplate('prpayment/checkout/onepage/shipping_method.phtml');
16
+ }
17
+
18
+ $html = $this->renderView();
19
+ return $html;
20
+ }
21
+
22
+
23
+ }
app/code/community/PayRandom/PRPayment/Block/Form/Prpayment.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Form_Prpayment extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('prpayment/form/prpayment.phtml');
8
+ }
9
+ }
app/code/community/PayRandom/PRPayment/Block/Product/Price.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Product_Price extends Mage_Catalog_Block_Product_Price
2
+ {
3
+ // and Override _toHtml Function to be
4
+ protected function _toHtml()
5
+ {
6
+ $productId = null;
7
+ if($this->getProduct()){
8
+ $productId = $this->getProduct()->getId();
9
+ }
10
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
11
+ if(in_array($productId, $productsCanApply)){
12
+ $productDeal = PayRandom_PRPayment_Helper_Data::getProductDeal($productId);
13
+ $this->setProductDeal($productDeal);
14
+ $this->setTemplate('prpayment/price.phtml');
15
+ }
16
+
17
+ if (!$this->getProduct() || $this->getProduct()->getCanShowPrice() === false) {
18
+ return '';
19
+ }
20
+ return parent::_toHtml();
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/Block/Product/View.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Block_Product_View extends Mage_Catalog_Block_Product_View {
3
+ public function getTierPriceHtml($product = null)
4
+ {
5
+ $productId = null;
6
+ if (is_null($product)) {
7
+ if($product = $this->getProduct()){
8
+ $productId = $product->getId();
9
+ }
10
+ }
11
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
12
+ if(in_array($productId, $productsCanApply)){
13
+ return '';
14
+ }
15
+
16
+ return $this->_getPriceBlock($product->getTypeId())
17
+ ->setTemplate($this->getTierPriceTemplate())
18
+ ->setProduct($product)
19
+ ->setInGrouped($this->getProduct()->isGrouped())
20
+ ->toHtml();
21
+ }
22
+
23
+ }
24
+
app/code/community/PayRandom/PRPayment/Block/Tax/Checkout/Grandtotal.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Tax_Checkout_Grandtotal extends Mage_Tax_Block_Checkout_Grandtotal
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setCartDeal(PayRandom_PRPayment_Helper_Data::getCartDeal());
16
+ $this->setTemplate('prpayment/tax/checkout/grandtotal.phtml');
17
+ }
18
+
19
+ $html = $this->renderView();
20
+ return $html;
21
+ }
22
+
23
+ }
app/code/community/PayRandom/PRPayment/Block/Tax/Checkout/Subtotal.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php class PayRandom_PRPayment_Block_Tax_Checkout_Subtotal extends Mage_Tax_Block_Checkout_Subtotal
2
+ {
3
+ /**
4
+ * Render block HTML
5
+ *
6
+ * @return string
7
+ */
8
+ protected function _toHtml()
9
+ {
10
+ if (!$this->getTemplate()) {
11
+ return '';
12
+ }
13
+
14
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
15
+ $this->setCartDeal(PayRandom_PRPayment_Helper_Data::getCartDeal());
16
+ $this->setTemplate('prpayment/tax/checkout/subtotal.phtml');
17
+ }
18
+
19
+ $html = $this->renderView();
20
+ return $html;
21
+ }
22
+
23
+ }
app/code/community/PayRandom/PRPayment/Helper/Data.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Helper_Data extends Mage_Payment_Helper_Data {
3
+
4
+ const MARGIN_ERROR = 10;
5
+ public static function checkSignature($parameters = null) {
6
+ if (!is_array($parameters)) {
7
+ return false;
8
+ }
9
+
10
+ if (!isset($parameters['request_code'])) {
11
+ return false;
12
+ }
13
+
14
+ if (!isset($parameters['merchant_code'])) {
15
+ return false;
16
+ }
17
+
18
+ if (!isset($parameters['date'])) {
19
+ return false;
20
+ }
21
+
22
+ if (!isset($parameters['signature'])) {
23
+ return false;
24
+ }
25
+
26
+ $_parameters = $parameters;
27
+ unset($_parameters['signature']);
28
+
29
+ $calcSignature = self::calcSignature($_parameters);
30
+
31
+ return $calcSignature === $parameters['signature'];
32
+ }
33
+
34
+ public static function calcSignature($parameters = null) {
35
+ if (!is_array($parameters))
36
+ return null;
37
+
38
+ ksort($parameters);
39
+
40
+ return sha1(implode('', $parameters) . Mage::getStoreConfig('payment/prpayment/secret_key'));
41
+ }
42
+
43
+ public function getStoreMethods($store = null, $quote = null) {
44
+ $methods = parent::getStoreMethods($store, $quote);
45
+
46
+ $canApplyOffer = PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer();
47
+
48
+ foreach ($methods as $k => $method) {
49
+ if ($method -> getCode() == 'prpayment') {
50
+ if (!$canApplyOffer) {
51
+ unset($methods[$k]);
52
+ }
53
+ } else {
54
+ if ($canApplyOffer) {
55
+ unset($methods[$k]);
56
+ }
57
+ }
58
+ }
59
+
60
+ return $methods;
61
+ }
62
+
63
+ public static function idProductsDeal() {
64
+ return Mage::getModel('prpayment/dealproduct')->getCollection()->getColumnValues('product_id');
65
+ }
66
+
67
+ public static function checkCartCanApplyOffer(){
68
+ $canApplyOffer = true;
69
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
70
+
71
+ //get a list of product in cart
72
+ $cart = Mage::getSingleton('checkout/session');
73
+
74
+ $cartProductIds = array();
75
+ foreach ($cart->getQuote()->getAllItems() as $item) {
76
+ $cartProductIds[] = $item -> getProductId();
77
+ if (!in_array($item -> getProductId(), $productsCanApply)) {
78
+ $canApplyOffer = false;
79
+ }
80
+ }
81
+ if(count(array_unique($cartProductIds)) != 1) $canApplyOffer = false;
82
+ return $canApplyOffer;
83
+ }
84
+
85
+ public static function getCartDeal(){
86
+ $return = false;
87
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
88
+
89
+ //get a list of product in cart
90
+ $cart = Mage::getSingleton('checkout/session');
91
+
92
+ $cartProductIds = array();
93
+ foreach ($cart->getQuote()->getAllItems() as $item) {
94
+ if (in_array($item -> getProductId(), $productsCanApply)) {
95
+ $cartProductIds[] = $item -> getProductId();
96
+ }
97
+ }
98
+ if(count(array_unique($cartProductIds)) == 1){
99
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId(current($cartProductIds));
100
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
101
+
102
+ $return = $deal;
103
+ }
104
+ return $return;
105
+ }
106
+
107
+ public static function getCartProductDeal(){
108
+ $return = false;
109
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
110
+
111
+ //get a list of product in cart
112
+ $cart = Mage::getSingleton('checkout/session');
113
+
114
+ $cartProductIds = array();
115
+ foreach ($cart->getQuote()->getAllItems() as $item) {
116
+ if (in_array($item -> getProductId(), $productsCanApply)) {
117
+ $cartProductIds[] = $item -> getProductId();
118
+ }
119
+ }
120
+ if(count(array_unique($cartProductIds)) == 1){
121
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId(current($cartProductIds));
122
+ $return = $dealProduct;
123
+ }
124
+ return $return;
125
+ }
126
+
127
+ public static function getProductDeal($productId){
128
+ $return = false;
129
+
130
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($productId);
131
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
132
+ if ($deal->getId()) {
133
+ $return = $deal;
134
+ }
135
+ return $return;
136
+ }
137
+
138
+ public static function updatePredefinedDeals(){
139
+ $return = false;
140
+ $predefinedDeals = Mage::helper('prpayment/api')->predefinedDeals();
141
+
142
+ if($predefinedDeals !== false){
143
+ $tblName = Mage::getSingleton('core/resource')->getTableName('prpayment/predefineddeal');
144
+
145
+ $truncate = Mage::getSingleton('core/resource')->getConnection('core_read');
146
+ $truncate->query("TRUNCATE {$tblName}");
147
+
148
+
149
+ $i = 0;
150
+ foreach($predefinedDeals as $predefinedDeal){
151
+ $predModel = Mage::getModel('prpayment/predefineddeal');
152
+
153
+ $predModel->setName($predefinedDeal['name']);
154
+
155
+ $predModel->setDiscounts(json_encode($predefinedDeal['discounts']));
156
+ $predModel->save();
157
+ }
158
+
159
+ $return = true;
160
+ }
161
+ return $return;
162
+ }
163
+
164
+ public static function updateStatistics(){
165
+ $return = false;
166
+
167
+ $statistics = Mage::helper('prpayment/api')->productsStatistics();
168
+
169
+ if($statistics !== false){
170
+ $tblName = Mage::getSingleton('core/resource')->getTableName('prpayment/productstatistics');
171
+
172
+ $truncate = Mage::getSingleton('core/resource')->getConnection('core_read');
173
+ $truncate->query("TRUNCATE {$tblName}");
174
+
175
+ foreach($statistics as $statistic){
176
+ $statModel = Mage::getModel('prpayment/productstatistics');
177
+
178
+ $statModel->name = $statistic['name'];
179
+ $statModel->deal_name = $statistic['deal_name'];
180
+ $statModel->product_id = $statistic['code'];
181
+ $statModel->total_amount = $statistic['total_amount'];
182
+ $statModel->times_purchased = $statistic['times_purchased'];
183
+ $statModel->units = $statistic['units'];
184
+ $statModel->min_price = $statistic['min_price'];
185
+ $statModel->max_price = $statistic['max_price'];
186
+ $statModel->expected_average_price = $statistic['expected_average_price'];
187
+ $statModel->average_price = $statistic['average_price'];
188
+ $statModel->start_date = $statistic['start_date'];
189
+ $statModel->end_date = $statistic['end_date'];
190
+ $statModel->active = $statistic['active'];
191
+
192
+ $statModel->save();
193
+ }
194
+
195
+ $return = true;
196
+ }
197
+ return $return;
198
+ }
199
+
200
+ public static function getDiscountsAvg($discounts){
201
+ if(!is_array($discounts) || count($discounts) < 1)
202
+ return false;
203
+
204
+ return array_sum($discounts)/count($discounts);
205
+ }
206
+
207
+ public static function getArrDiscountsAvg($discounts){
208
+ $return = array();
209
+ $discountAvg = self::getDiscountsAvg($discounts);
210
+
211
+ foreach($discounts as $discount){
212
+ $return[] = 1 - $discount / $discountAvg;
213
+ }
214
+
215
+ return $return;
216
+ }
217
+
218
+ public static function converToPercent($arrData){
219
+ return array_map(array('PayRandom_PRPayment_Helper_Data', 'toPercent'), $arrData);
220
+ }
221
+
222
+ public static function toPercent($val){
223
+ return $val * 100;
224
+ }
225
+
226
+ public static function toPow2($val){
227
+ return $val * $val;
228
+ }
229
+
230
+ public static function calcBalance($arrData, $avgPrice){
231
+ return 2 * self::calcVariance(self::applyDiscountArray($arrData, $avgPrice)) / self::MARGIN_ERROR;
232
+ }
233
+
234
+ public static function calcVariance($data){
235
+ $avg = self::getDiscountsAvg($data);
236
+
237
+ $dataPow2 = array_map(array('PayRandom_PRPayment_Helper_Data', 'toPow2'), $data);
238
+ return array_sum($dataPow2) / count($data) - $avg * $avg;
239
+ }
240
+
241
+ public static function calcAttraction($arrData, $avgPrice){
242
+ $discountsPerCent = self::converToPercent($arrData);
243
+
244
+ $num100 = 0;
245
+ foreach($discountsPerCent as $discount){
246
+ if($discount == 100) $num100++;
247
+ }
248
+
249
+ $correction = 0;
250
+ switch($num100){
251
+ case 0:
252
+ $correction = 0;
253
+ break;
254
+ case 1:
255
+ $correction = 10;
256
+ break;
257
+ case 2:
258
+ $correction = 30;
259
+ break;
260
+ case 3:
261
+ $correction = 50;
262
+ break;
263
+ default:
264
+ $correction = 100;
265
+ break;
266
+ }
267
+ return self::calcVariance(self::applyDiscountArray($arrData, $avgPrice)) + $correction;
268
+ }
269
+
270
+ public static function deserializeDiscounts($discounts){
271
+ return json_decode($discounts, true);
272
+ }
273
+
274
+ public static function applyDiscountArray($discountArray, $price){
275
+ $return = array();
276
+ foreach($discountArray as $discount){
277
+ $return[] = self::applyDiscount($discount, $price);
278
+ }
279
+ return $return;
280
+ }
281
+
282
+ public static function applyDiscount($discount, $price){
283
+ $discount = (float) $discount;
284
+ return $price - $price * $discount;
285
+ }
286
+ }
app/code/community/PayRandom/PRPayment/Helper/Data/Api.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Helper_Data_Api extends Mage_Core_Helper_Abstract {
3
+ const API_URL = 'http://payrandom.zlworks.com/api';
4
+ const API_VERSION = '/v1';
5
+
6
+ public static function createProduct($values){
7
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
8
+ $values['date'] = date('Y-m-d_H_i_s');
9
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
10
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
11
+
12
+ $curl = curl_init();
13
+ curl_setopt_array($curl, array(
14
+ CURLOPT_RETURNTRANSFER => 1,
15
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/products',
16
+ CURLOPT_POST => true,
17
+ CURLOPT_POSTFIELDS => $values,
18
+ ));
19
+
20
+ $resp = curl_exec($curl);
21
+ curl_close($curl);
22
+
23
+ $return = json_decode($resp, true);
24
+ if($return['code'] != 1){
25
+ Mage::log('createProduct:: ' . var_export($resp, true), null, 'payrandom.log');
26
+ }
27
+ return $return['code'] == 1;
28
+ }
29
+
30
+ public static function updateProduct($productId, $values){
31
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
32
+ $values['date'] = date('Y-m-d_H_i_s');
33
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
34
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
35
+
36
+ $curl = curl_init();
37
+ curl_setopt_array($curl, array(
38
+ CURLOPT_RETURNTRANSFER => 1,
39
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/products' . '/' . urlencode($productId),
40
+ CURLOPT_CUSTOMREQUEST => 'PUT',
41
+ CURLOPT_POST => true,
42
+ CURLOPT_POSTFIELDS => $values,
43
+ ));
44
+
45
+ $resp = curl_exec($curl);
46
+ curl_close($curl);
47
+
48
+ $return = json_decode($resp, true);
49
+ if($return['code'] != 1){
50
+ Mage::log('updateProduct:: ' . var_export($resp, true), null, 'payrandom.log');
51
+ }
52
+ return $return['code'] == 1;
53
+ }
54
+
55
+ public static function updateDealFromModel($deal, $productId){
56
+ $values = array();
57
+ $values['product_code'] = $productId;
58
+
59
+ $values['name'] = $deal->getName();
60
+ $values['discounts'] = $deal->getDiscounts();
61
+ $values['kind'] = $deal->getKind();
62
+ $values['view_format'] = $deal->getViewFormat();
63
+
64
+ if($deal->getId()){
65
+ return self::updateDeal($deal->getId(), $values);
66
+ }else{
67
+ return self::createDeal($values);
68
+ }
69
+ }
70
+
71
+ public static function removeProduct($productId){
72
+ $values = array();
73
+ $values['code'] = $productId;
74
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
75
+ $values['date'] = date('Y-m-d_H_i_s');
76
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
77
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
78
+
79
+ $curl = curl_init();
80
+ curl_setopt_array($curl, array(
81
+ CURLOPT_RETURNTRANSFER => 1,
82
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/products' . '/' . urlencode($productId),
83
+ CURLOPT_CUSTOMREQUEST => 'DELETE',
84
+ CURLOPT_POST => true,
85
+ CURLOPT_POSTFIELDS => $values,
86
+ ));
87
+
88
+ $resp = curl_exec($curl);
89
+ curl_close($curl);
90
+
91
+ $return = json_decode($resp, true);
92
+ if($return['code'] != 1){
93
+ Mage::log('removeProduct:: ' . var_export($resp, true), null, 'payrandom.log');
94
+ }
95
+ return $return['code'] == 1;
96
+ }
97
+
98
+ public static function createDeal($values){
99
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
100
+ $values['date'] = date('Y-m-d_H_i_s');
101
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
102
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
103
+
104
+ $curl = curl_init();
105
+ curl_setopt_array($curl, array(
106
+ CURLOPT_RETURNTRANSFER => 1,
107
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/deals',
108
+ CURLOPT_POST => true,
109
+ CURLOPT_POSTFIELDS => $values,
110
+ ));
111
+
112
+ $resp = curl_exec($curl);
113
+ curl_close($curl);
114
+
115
+ $return = json_decode($resp, true);
116
+ if($return['code'] != 1){
117
+ Mage::log('createDeal:: ' . var_export($resp, true), null, 'payrandom.log');
118
+ }
119
+ return $return['code'] == 1;
120
+ }
121
+
122
+ public static function updateDeal($dealId, $values){
123
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
124
+ $values['date'] = date('Y-m-d_H_i_s');
125
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
126
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
127
+
128
+ $curl = curl_init();
129
+ curl_setopt_array($curl, array(
130
+ CURLOPT_RETURNTRANSFER => 1,
131
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/deals' . '/' . urlencode($dealId),
132
+ CURLOPT_CUSTOMREQUEST => 'PUT',
133
+ CURLOPT_POST => true,
134
+ CURLOPT_POSTFIELDS => $values,
135
+ ));
136
+
137
+ $resp = curl_exec($curl);
138
+ curl_close($curl);
139
+
140
+ $return = json_decode($resp, true);
141
+ if($return['code'] != 1){
142
+ Mage::log('updateDeal:: ' . var_export($resp, true), null, 'payrandom.log');
143
+ }
144
+ return $return['code'] == 1;
145
+ }
146
+
147
+ public static function installSubscription(){
148
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
149
+ $values['date'] = date('Y-m-d_H_i_s');
150
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
151
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
152
+
153
+ $curl = curl_init();
154
+ curl_setopt_array($curl, array(
155
+ CURLOPT_RETURNTRANSFER => 1,
156
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/merchants/' . Mage::getStoreConfig('payment/prpayment/merchant_code') . '/install_subscription',
157
+ CURLOPT_CUSTOMREQUEST => 'POST',
158
+ CURLOPT_POST => true,
159
+ CURLOPT_POSTFIELDS => $values,
160
+ ));
161
+
162
+ $resp = curl_exec($curl);
163
+ curl_close($curl);
164
+
165
+ $return = json_decode($resp, true);
166
+ if($return['code'] != 1){
167
+ Mage::log('installSubscription:: ' . var_export($resp, true), null, 'payrandom.log');
168
+ }
169
+ return $return['code'] == 1;
170
+ }
171
+
172
+ public static function predefinedDeals(){
173
+ $values = array();
174
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
175
+ $values['date'] = date('Y-m-d_H_i_s');
176
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
177
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
178
+
179
+ $curl = curl_init();
180
+ curl_setopt_array($curl, array(
181
+ CURLOPT_RETURNTRANSFER => 1,
182
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/predefined_deals?'. http_build_query($values),
183
+ ));
184
+
185
+ $resp = curl_exec($curl);
186
+ curl_close($curl);
187
+
188
+ $return = json_decode($resp, true);
189
+ if($return['code'] != 1){
190
+ Mage::log('predefinedDeals:: ' . var_export($resp, true), null, 'payrandom.log');
191
+ return false;
192
+ }else{
193
+ return $return['predefined_deals'];
194
+ }
195
+ }
196
+
197
+ public static function productsStatistics(){
198
+ $values = array();
199
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
200
+ $values['date'] = date('Y-m-d_H_i_s');
201
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
202
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
203
+
204
+ $curl = curl_init();
205
+ curl_setopt_array($curl, array(
206
+ CURLOPT_RETURNTRANSFER => 1,
207
+ CURLOPT_URL => self::API_URL . self::API_VERSION . '/merchants/' . Mage::getStoreConfig('payment/prpayment/merchant_code') . '/products?'. http_build_query($values),
208
+ ));
209
+
210
+ $resp = curl_exec($curl);
211
+ curl_close($curl);
212
+
213
+ $return = json_decode($resp, true);
214
+ if($return['code'] != 1){
215
+ Mage::log('productsStatistics:: ' . var_export($resp, true), null, 'payrandom.log');
216
+ return false;
217
+ }else{
218
+ return $return['products'];
219
+ }
220
+ }
221
+
222
+ public static function getOrdersUrl(){
223
+ return self::API_URL . self::API_VERSION . '/orders';
224
+ }
225
+
226
+ public static function getDashBoardUrl(){
227
+ $values = array();
228
+ $values['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
229
+ $values['date'] = date('Y-m-d_H_i_s');
230
+ $values['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
231
+ $values['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($values);
232
+
233
+ if ($values['merchant_code']) {
234
+ return self::API_URL . self::API_VERSION . '/merchants/' . Mage::getStoreConfig('payment/prpayment/merchant_code') . '/statistics?' . http_build_query($values);
235
+ }
236
+ else {
237
+ return self::API_URL . self::API_VERSION . '/merchants/no_merchant_code';
238
+ }
239
+ }
240
+
241
+
242
+ public static function getRouletteImg($discounts, $productPrice, $freeText, $width, $height){
243
+ $params = array();
244
+
245
+ $disc = array();
246
+ foreach($discounts as $discount){
247
+ $disc[] = (1 - $discount) * $productPrice;
248
+ }
249
+ $disc = json_encode($disc);
250
+
251
+ $params['sizes'] = $width . 'x'. $height;
252
+ $params['prices'] = $disc;
253
+ $params['free_text'] = $freeText;
254
+
255
+ return self::API_URL . self::API_VERSION . '/roulette?' . http_build_query($params);
256
+ }
257
+
258
+ public static function getWatermarkImg($upperText, $offerText, $width, $height){
259
+ $params = array();
260
+
261
+ $params['sizes'] = $width . 'x'. $height;
262
+ $params['upper_text'] = $upperText;
263
+ $params['offer_text'] = $offerText;
264
+
265
+ return self::API_URL . self::API_VERSION . '/watermark?' . http_build_query($params);
266
+ }
267
+ }
app/code/community/PayRandom/PRPayment/Helper/Data/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Helper_Data_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/PayRandom/PRPayment/Model/Deal.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Deal extends Mage_Core_Model_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/deal');
5
+ }
6
+
7
+ protected function _beforeSave(){
8
+ if (!$this->getCreatedAt()) {
9
+ $this->setCreatedAt(now());
10
+ }
11
+ $this->setUpdatedAt(now());
12
+ return parent::_beforeSave();
13
+ }
14
+
15
+ public function getMinimumDiscount(){
16
+ return min($this->getDiscountsArray());
17
+ }
18
+
19
+ public function getMaximumDiscount(){
20
+ return max($this->getDiscountsArray());
21
+ }
22
+
23
+ public function getDiscount($i){
24
+ $discountsArray = $this->getDiscountsArray();
25
+ if(isset($discountsArray[$i]))
26
+ {
27
+ return $discountsArray[$i];
28
+ }
29
+ return false;
30
+ }
31
+
32
+ public function getDiscountsArray(){
33
+ return json_decode($this->getDiscounts());
34
+ }
35
+
36
+ }
app/code/community/PayRandom/PRPayment/Model/Dealproduct.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Dealproduct extends Mage_Core_Model_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/dealproduct');
5
+ }
6
+
7
+ public function loadByProductId($productId){
8
+ return $this->load($productId, 'product_id');
9
+ }
10
+
11
+ protected function _beforeSave(){
12
+ if (!$this->getCreatedAt()) {
13
+ $this->setCreatedAt(now());
14
+ }
15
+ $this->setUpdatedAt(now());
16
+ return parent::_beforeSave();
17
+ }
18
+
19
+ }
app/code/community/PayRandom/PRPayment/Model/Observer.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Observer
3
+ {
4
+ public function onUpdate($obj)
5
+ {
6
+ $event = $obj->getEvent();
7
+ $product = $event->getProduct();
8
+
9
+ $dealProductModel = Mage::getModel('prpayment/dealproduct')->loadByProductId($product->getId());
10
+ if ($dealProductModel->getId()) {
11
+ $values = array();
12
+ $values['code'] = $product->getId();
13
+ $values['name'] = $product->getName();
14
+ $values['description'] = $product->getName();
15
+ $values['price'] = $product->getPrice();
16
+
17
+ /* HACK Disable special price */
18
+ if ($product->getSpecialPrice()) {
19
+ $product->setSpecialPrice(null);
20
+ $product->save();
21
+ if (Mage::getSingleton('core/session')) {
22
+ Mage::getSingleton('core/session')->addNotice(__('No es posible guardar precio especial en productos PayRandom'));
23
+ }
24
+ }
25
+
26
+ if(!Mage::helper('prpayment/api')->updateProduct($product->getId(), $values)){
27
+ if(!Mage::helper('prpayment/api')->createProduct($values)){
28
+ throw new Exception(Mage::helper('prpayment')->__('The product cannot be saved to PayRandom'));
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ public function onUpdateConfig($obj){
35
+ Mage::log('Update config callback', null, 'payrandom.log');
36
+ if (Mage::getStoreConfig('payment/prpayment/merchant_code')) {
37
+ Mage::helper('prpayment/api')->installSubscription();
38
+ PayRandom_PRPayment_Helper_Data::updatePredefinedDeals();
39
+ Mage::log('Installed subscription and updated predefined deals', null, 'payrandom.log');
40
+ }
41
+ }
42
+
43
+ public function cronTask() {
44
+ PayRandom_PRPayment_Helper_Data::updatePredefinedDeals();
45
+ PayRandom_PRPayment_Helper_Data::updateStatistics();
46
+ }
47
+
48
+ }
app/code/community/PayRandom/PRPayment/Model/Predefineddeal.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Predefineddeal extends Mage_Core_Model_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/predefineddeal');
5
+ }
6
+
7
+ protected function _beforeSave(){
8
+ if (!$this->getCreatedAt()) {
9
+ $this->setCreatedAt(now());
10
+ }
11
+ $this->setUpdatedAt(now());
12
+ return parent::_beforeSave();
13
+ }
14
+ }
app/code/community/PayRandom/PRPayment/Model/Productstatistics.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Productstatistics extends Mage_Core_Model_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/productstatistics');
5
+ }
6
+
7
+ protected function _beforeSave(){
8
+ if (!$this->getCreatedAt()) {
9
+ $this->setCreatedAt(now());
10
+ }
11
+ $this->setUpdatedAt(now());
12
+ return parent::_beforeSave();
13
+ }
14
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Deal.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Resource_Deal extends Mage_Core_Model_Resource_Db_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/deal', 'id');
5
+ }
6
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Deal/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Model_Resource_Deal_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('prpayment/deal');
9
+ }
10
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Dealproduct.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Resource_Dealproduct extends Mage_Core_Model_Resource_Db_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/dealproduct', 'id');
5
+ }
6
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Dealproduct/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Model_Resource_Dealproduct_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('prpayment/dealproduct');
9
+ }
10
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Predefineddeal.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Resource_Predefineddeal extends Mage_Core_Model_Resource_Db_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/predefineddeal', 'id');
5
+ }
6
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Predefineddeal/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Model_Resource_Predefineddeal_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('prpayment/predefineddeal');
9
+ }
10
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Productstatistics.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Resource_Productstatistics extends Mage_Core_Model_Resource_Db_Abstract {
3
+ protected function _construct() {
4
+ $this -> _init('prpayment/productstatistics', 'id');
5
+ }
6
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Productstatistics/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayRandom_PRPayment_Model_Resource_Productstatistics_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('prpayment/productstatistics');
9
+ }
10
+ }
app/code/community/PayRandom/PRPayment/Model/Resource/Setup.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
3
+ }
app/code/community/PayRandom/PRPayment/Model/Standard.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PayRandom_PRPayment_Model_Standard extends Mage_Payment_Model_Method_Abstract {
3
+ protected $_code = 'prpayment';
4
+
5
+ protected $_isInitializeNeeded = true;
6
+ protected $_canUseInternal = true;
7
+ protected $_canUseForMultishipping = false;
8
+ protected $_formBlockType = 'prpayment/form_prpayment';
9
+
10
+ public function assignData($data)
11
+ {
12
+ if (!($data instanceof Varien_Object)) {
13
+ $data = new Varien_Object($data);
14
+ }
15
+ Mage::GetSingleton("core/session")->setFixedPrice($data->getRadioFixedPrice());
16
+ return $this;
17
+ }
18
+
19
+ public function getOrderPlaceRedirectUrl() {
20
+ return Mage::getUrl('prpayment/payment/redirect', array('_secure' => true));
21
+ }
22
+ }
app/code/community/PayRandom/PRPayment/controllers/DealsController.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category PayRandom
4
+ * @package PayRandom_PRPayment
5
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
6
+ */
7
+
8
+
9
+ class PayRandom_PRPayment_DealsController extends Mage_Adminhtml_Controller_Action {
10
+ public function indexAction()
11
+ {
12
+ $this->loadLayout();
13
+ $this->renderLayout();
14
+ }
15
+
16
+ public function chooseAction()
17
+ {
18
+ $this->loadLayout();
19
+ $this->_setActiveMenu('prpayment_menu');
20
+ $this->_addBreadcrumb('Pay Random Deal', 'Pay Random Deal');
21
+ $this->_addContent($this->getLayout()->createBlock('prpayment/adminhtml_deals_choose'));
22
+ $this->renderLayout();
23
+ }
24
+
25
+ public function chooseredirAction()
26
+ {
27
+ $productId = $this->getRequest()->getParam('product_id');
28
+ $avgPrice = $this->getRequest()->getParam('avg_price');
29
+ $this->_redirect('*/deals/choose', array('product_id' => $productId, 'avg_price' => $avgPrice));
30
+ }
31
+
32
+ public function editAction()
33
+ {
34
+ $dealModel = Mage::getModel('prpayment/deal');
35
+ $dealProductModel = Mage::getModel('prpayment/dealproduct');
36
+
37
+ $productId = $this->getRequest()->getParam('product_id');
38
+
39
+ $dealProductModel->loadByProductId($productId);
40
+ $dealModel->load($dealProductModel->getDealId());
41
+
42
+ if ($productId != 0)
43
+ {
44
+ Mage::register('deals_data', $dealModel);
45
+ Mage::register('deals_product_id', $productId);
46
+
47
+ $this->loadLayout();
48
+ $this->_setActiveMenu('prpayment_menu');
49
+ $this->_addBreadcrumb('Pay Random Deal', 'Pay Random Deal');
50
+
51
+ $this->getLayout()->getBlock('head')
52
+ ->setCanLoadExtJs(true);
53
+ $this->_addContent($this->getLayout()
54
+ ->createBlock('prpayment/adminhtml_deals_edit')
55
+ );
56
+
57
+ $this->renderLayout();
58
+
59
+ }
60
+ else
61
+ {
62
+ Mage::getSingleton('adminhtml/session')
63
+ ->addError('No editable');
64
+ $this->_redirect('*/*/');
65
+ }
66
+ }
67
+
68
+ public function newAction()
69
+ {
70
+ $productId = $this->getRequest()->getParam('product_id');
71
+ $this->_redirect('*/deals/edit', array('product_id' => $productId));
72
+ }
73
+
74
+ public function assignAction(){
75
+ $productId = $this->getRequest()->getParam('product_id');
76
+ $predefinedDealId = $this->getRequest()->getParam('predefined_deal_id');
77
+ $avgPrice = $this->getRequest()->getParam('avg_price');
78
+ $hasFixedPrice = $this->getRequest()->getParam('radioFixedPrice');
79
+ $fixedPrice = $this->getRequest()->getParam('fixed_price');
80
+
81
+ $predefinedDeal = Mage::getModel('prpayment/predefineddeal');
82
+ $predefinedDeal->load($predefinedDealId);
83
+
84
+ $avgDiscounts = PayRandom_PRPayment_Helper_Data::deserializeDiscounts($predefinedDeal->getDiscounts());
85
+
86
+ $finalPrices = PayRandom_PRPayment_Helper_Data::applyDiscountArray($avgDiscounts, $avgPrice);
87
+
88
+
89
+ $product = Mage::getModel('catalog/product')->load($productId);
90
+
91
+ $realDiscounts = array();
92
+ foreach($finalPrices as $finalPrice){
93
+ $realDiscounts[] = 1 - ($finalPrice / $product->getPrice());
94
+ }
95
+
96
+ if ($hasFixedPrice == 1) {
97
+ $fixedDiscount = 1 - ($fixedPrice / $product->getPrice());
98
+ return $this->_saveAction($productId, $realDiscounts, $fixedDiscount, $predefinedDeal->getName(), 'prices');
99
+ }
100
+ else {
101
+ return $this->_saveAction($productId, $realDiscounts, null, $predefinedDeal->getName(), 'prices');
102
+ }
103
+
104
+ }
105
+
106
+ public function saveAction(){
107
+ $productId = $this->getRequest()->getParam('deals_product_id');
108
+ $dealName = $this->getRequest()->getParam('deal_name');
109
+ $viewFormat = $this->getRequest()->getParam('view_format');
110
+ $discounts = $this->getRequest()->getParam('discounts');
111
+ $hasFixedPrice = $this->getRequest()->getParam('radioFixedPrice');
112
+
113
+ if ($hasFixedPrice == 1) {
114
+ $product = Mage::getModel('catalog/product')->load($productId);
115
+ $fixedPrice = $this->getRequest()->getParam('fixed_price');
116
+ $fixedDiscount = 1 - ($fixedPrice / $product->getPrice());
117
+ }
118
+
119
+ return $this->_saveAction($productId, $discounts, $fixedDiscount, $dealName, $viewFormat);
120
+ }
121
+
122
+ private function discountsToFloat($val){
123
+ return (float) $val;
124
+ }
125
+
126
+ private function _saveAction($productId, $discounts, $fixedDiscount, $dealName, $viewFormat){
127
+ $discounts = array_map(array('PayRandom_PRPayment_DealsController', 'discountsToFloat'), $discounts);
128
+ $dealModel = Mage::getModel('prpayment/deal');
129
+ $dealProductModel = Mage::getModel('prpayment/dealproduct');
130
+
131
+ $dealProductModel->loadByProductId($productId);
132
+ $dealModel->load($dealProductModel->getDealId());
133
+
134
+ if ($productId != 0)
135
+ {
136
+ try {
137
+ $product = Mage::getModel('catalog/product')->load($productId);
138
+ if($dealName == ''){
139
+ $dealName = $product->getName();
140
+ }
141
+
142
+
143
+ $values = array();
144
+ $values['code'] = $productId;
145
+ $values['name'] = $product->getName();
146
+ $values['description'] = $product->getName();
147
+ $values['price'] = $product->getPrice();
148
+
149
+ if($dealProductModel->getId() == 0){
150
+ if(!Mage::helper('prpayment/api')->createProduct($values)){
151
+ if(!Mage::helper('prpayment/api')->updateProduct($productId, $values)){
152
+ throw new Exception(Mage::helper('prpayment')->__('The product cannot be saved to PayRandom'));
153
+ }
154
+ }
155
+ }else{
156
+ if(!Mage::helper('prpayment/api')->updateProduct($productId, $values)){
157
+ if(!Mage::helper('prpayment/api')->createProduct($values)){
158
+ throw new Exception(Mage::helper('prpayment')->__('The product cannot be saved to PayRandom'));
159
+ }
160
+ }
161
+ }
162
+
163
+ $dealModel->setName($dealName);
164
+ $dealModel->setDiscounts(json_encode($discounts));
165
+ $dealModel->setKind('custom');
166
+ $dealModel->setViewFormat($viewFormat);
167
+
168
+ $dealModel->setFixedDiscount($fixedDiscount);
169
+
170
+ $values = array();
171
+ $values['product_code'] = $productId;
172
+
173
+ $values['code'] = $dealModel->getId();
174
+ $values['name'] = $dealModel->getName();
175
+ $values['discounts'] = $dealModel->getDiscounts();
176
+ $values['kind'] = $dealModel->getKind();
177
+
178
+ if (!is_null($dealModel->getFixedDiscount())) {
179
+ $values['fixed_discount'] = $dealModel->getFixedDiscount();
180
+ }
181
+
182
+ /* var_dump($values);
183
+ die();*/
184
+ if($dealModel->getId() == 0){
185
+ $dealModel->save();
186
+ $values['code'] = $dealModel->getId();
187
+ if(!Mage::helper('prpayment/api')->createDeal($values)){
188
+ $dealModel->delete();
189
+ throw new Exception(Mage::helper('prpayment')->__('The deal cannot be saved to PayRandom'));
190
+ }
191
+ }else{
192
+ if(!Mage::helper('prpayment/api')->updateDeal($dealModel->getId(), $values)){
193
+ throw new Exception(Mage::helper('prpayment')->__('The deal cannot be saved to PayRandom'));
194
+ }
195
+ $dealModel->save();
196
+ }
197
+
198
+ if($dealProductModel->getId() == 0){
199
+ $dealProductModel->setProductId($productId);
200
+ $dealProductModel->setDealId($dealModel->getId());
201
+ $dealProductModel->save();
202
+ }
203
+
204
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('prpayment')->__('Deal was successfully saved'));
205
+ $this->getResponse()->setRedirect($this->getUrl('*/deals/edit', array('product_id' => $productId)));
206
+ return;
207
+ } catch (Exception $e) {
208
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
209
+ $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('product_id' => $productId)));
210
+ return;
211
+ }
212
+ }
213
+ else
214
+ {
215
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('prpayment')->__('No product id'));
216
+ $this->getResponse()->setRedirect($this->getUrl('*/catalog_product'));
217
+ return;
218
+ }
219
+ }
220
+
221
+ public function removeAction()
222
+ {
223
+ $productId = $this->getRequest()->getParam('product_id');
224
+
225
+ $dealModel = Mage::getModel('prpayment/deal');
226
+ $dealProductModel = Mage::getModel('prpayment/dealproduct');
227
+
228
+ $dealProductModel->loadByProductId($productId);
229
+ $dealModel->load($dealProductModel->getDealId());
230
+
231
+ if(Mage::helper('prpayment/api')->removeProduct($productId)){
232
+ $dealProductModel->delete();
233
+ $dealModel->delete();
234
+ Mage::getSingleton('core/session')->addSuccess($this->__('The deal has been deleted successfully'));
235
+ }else{
236
+ Mage::getSingleton('core/session')->addError($this->__('The deal hasn\'t been deleted'));
237
+ }
238
+
239
+ $this->_redirect('*/catalog_product/index');
240
+ }
241
+
242
+ }
243
+
app/code/community/PayRandom/PRPayment/controllers/InfoController.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category PayRandom
4
+ * @package PayRandom_PRPayment
5
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
6
+ */
7
+
8
+ class PayRandom_PRPayment_InfoController extends Mage_Adminhtml_Controller_Action {
9
+ protected function _initAction()
10
+ {
11
+ $this->loadLayout()->_setActiveMenu('prpayment_menu')
12
+ ->_addBreadcrumb(Mage::helper('prpayment')->__('PayRandom - Account info'), Mage::helper('prpayment')->__('PayRandom - Account info'));
13
+ return $this;
14
+ }
15
+ public function indexAction() {
16
+ $this->_initAction();
17
+ $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','prpayment',array('template' => 'prpayment/info.phtml'));
18
+
19
+ $block->setVersion('Basic');
20
+ $block->setExpirationDate();
21
+
22
+ $this->getLayout()->getBlock('content')->append($block);
23
+ $this->renderLayout();
24
+ }
25
+
26
+ public function currentDealsAction() {
27
+ $this->loadLayout();
28
+ $this->_setActiveMenu('prpayment_menu');
29
+ $this->_addBreadcrumb('Pay Random Deal', 'Pay Random Deal');
30
+ $this->_addContent($this->getLayout()->createBlock('prpayment/adminhtml_deals_current'));
31
+ $this->renderLayout();
32
+ }
33
+
34
+ public function soldDealsAction() {
35
+ $this->loadLayout();
36
+ $this->_setActiveMenu('prpayment_menu');
37
+ $this->_addBreadcrumb('Pay Random Deal', 'Pay Random Deal');
38
+ $this->_addContent($this->getLayout()->createBlock('prpayment/adminhtml_deals_sold'));
39
+ $this->renderLayout();
40
+ }
41
+
42
+ public function predefinedDealsAction() {
43
+ $this->loadLayout();
44
+ $this->_setActiveMenu('prpayment_menu');
45
+ $this->_addBreadcrumb('Pay Random Deal', 'Pay Random Deal');
46
+ $this->_addContent($this->getLayout()->createBlock('prpayment/adminhtml_deals_predefined'));
47
+ $this->renderLayout();
48
+ }
49
+
50
+ }
app/code/community/PayRandom/PRPayment/controllers/PaymentController.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category PayRandom
4
+ * @package PayRandom_PRPayment
5
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
6
+ */
7
+
8
+
9
+ class PayRandom_PRPayment_PaymentController extends Mage_Core_Controller_Front_Action {
10
+ // The redirect action is triggered when someone places an order
11
+ public function redirectAction() {
12
+ $this->loadLayout();
13
+
14
+ $_order = new Mage_Sales_Model_Order();
15
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
16
+ if($orderId){
17
+ $_order->loadByIncrementId($orderId);
18
+
19
+ $parameters = array();
20
+ $parameters['merchant_code'] = Mage::getStoreConfig('payment/prpayment/merchant_code');
21
+ $parameters['request_code'] = date('YmdHis') . str_pad(rand(), 10, "0", STR_PAD_LEFT);
22
+ foreach($_order->getAllItems() as $item){
23
+ $parameters['product_code'] = $item->getProductId();
24
+ $parameters['quantity_ordered'] = $item->getQtyOrdered();
25
+ }
26
+
27
+ $dealProductModel = Mage::getModel('prpayment/dealproduct')->loadByProductId($parameters['product_code']);
28
+ if ($dealProductModel->getId()) {
29
+ $parameters['deal_code'] = $dealProductModel->getDealId();
30
+ }
31
+
32
+ $parameters['date'] = date('Y-m-d_H_i_s');
33
+ $parameters['order_code'] = $orderId;
34
+ $parameters['url_notification'] = Mage::getModel('core/url')->sessionUrlVar(Mage::getUrl('prpayment/payment/notify', array('_secure' => true)));
35
+ $parameters['url_ok'] = Mage::getModel('core/url')->sessionUrlVar(Mage::getUrl('prpayment/payment/resultok', array('_secure' => true)));
36
+ $parameters['url_ko'] = Mage::getModel('core/url')->sessionUrlVar(Mage::getUrl('prpayment/payment/resultko', array('_secure' => true)));
37
+ $parameters['total_amount'] = $_order->getBaseGrandTotal();
38
+ $parameters['total_amount_for_discount'] = $_order->getBaseGrandTotal() - $_order->getShippingAmount();
39
+
40
+ if (Mage::GetSingleton("core/session")->getFixedPrice() == 2) {
41
+ $parameters['apply_fixed_discount'] = 1;
42
+ }
43
+
44
+ $parameters['signature'] = PayRandom_PRPayment_Helper_Data::calcSignature($parameters);
45
+
46
+ Mage::log('redirectAction:: Parameters: ' . var_export($parameters, true), null, 'payrandom.log');
47
+
48
+ $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','prpayment',array('template' => 'prpayment/redirect.phtml'));
49
+ $block->setParameters($parameters);
50
+
51
+ $this->getLayout()->getBlock('content')->append($block);
52
+ $this->renderLayout();
53
+ }else{
54
+ Mage_Core_Controller_Varien_Action::_redirect('');
55
+ }
56
+ }
57
+
58
+ public function notifyAction() {
59
+ $response = array();
60
+ $response['result'] = '0';
61
+ if($this->getRequest()->isPost()) {
62
+ if(PayRandom_PRPayment_Helper_Data :: checkSignature($this->getRequest()->getParams())){
63
+ if($this->checkParams($this->getRequest()->getParams())){
64
+ $orderId = $this->getRequest()->getParam('order_code');
65
+ $order = Mage::getModel('sales/order');
66
+ $order->loadByIncrementId($orderId);
67
+ if($order->getState() == Mage_Sales_Model_Order::STATE_NEW){ // Check current state
68
+ $resultPR = $this->getRequest()->getParam('result');
69
+ if($resultPR == '1'){
70
+ $discountAmount = $this->getRequest()->getParam('discount');
71
+ if($discountAmount){
72
+ $order->setDiscountAmount(-$discountAmount);
73
+ $order->setBaseDiscountAmount(-$discountAmount);
74
+ $order->setDiscountDescription('PayRandom');
75
+ $order->setGrandTotal($order->getGrandTotal()-$discountAmount);
76
+ $order->setBaseGrandTotal($order->getBaseGrandTotal()-$discountAmount);
77
+ $order->setSubtotalWithDiscount($order->getSubtotalWithDiscount()-$discountAmount);
78
+ $order->setBaseSubtotalWithDiscount($order->getBaseSubtotalWithDiscount()-$discountAmount);
79
+ }
80
+
81
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
82
+
83
+ $order->sendNewOrderEmail();
84
+ $order->setEmailSent(true);
85
+
86
+ $order->save();
87
+
88
+ Mage::log('notifyAction::Complete. Parameters: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
89
+ PayRandom_PRPayment_Helper_Data::updateStatistics();
90
+ $response['result'] = '1';
91
+ }else{
92
+ Mage::log('notifyAction::Cancelled (' . $resultPR . '). Parameters: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
93
+ $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
94
+ }
95
+ }else{
96
+ Mage::log('notifyAction::Current state incorrect: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
97
+ $response['result'] = '903';
98
+ }
99
+ }else{
100
+ Mage::log('notifyAction::Missing parameters. Parameters: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
101
+ $response['result'] = '902';
102
+ }
103
+ }else{
104
+ Mage::log('notifyAction::Error validating signature. Parameters: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
105
+ $response['result'] = '901';
106
+ }
107
+ } else {
108
+ Mage::log('notifyAction::Is not a POST request. Parameters: ' . var_export($this->getRequest()->getParams(), true), null, 'payrandom.log');
109
+ $response['result'] = '900';
110
+ }
111
+
112
+ $this->getResponse()->setHeader('Content-type', 'application/json');
113
+ $this->getResponse()->setBody(json_encode($response));
114
+ }
115
+
116
+ public function resultokAction() {
117
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
118
+ }
119
+
120
+ public function resultkoAction() {
121
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
122
+ }
123
+
124
+ private function checkParams($params){
125
+ if(!isset($params['result'])){
126
+ Mage::log('checkParams::No result. Parameters: ' . var_export($params, true), null, 'payrandom.log');
127
+ return false;
128
+ }
129
+ if(!isset($params['order_code'])){
130
+ Mage::log('checkParams::No order_code. Parameters: ' . var_export($params, true), null, 'payrandom.log');
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+ }
app/code/community/PayRandom/PRPayment/etc/adminhtml.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <prpayment_menu translate="title" module="adminhtml">
5
+ <title>PayRandom</title>
6
+ <sort_order>150</sort_order>
7
+ <children>
8
+ <prpayment_menu_dashboard translate="title" module="adminhtml">
9
+ <title>Dashboard</title>
10
+ <action>*/info/index</action>
11
+ </prpayment_menu_dashboard>
12
+ <prpayment_menu_current translate="title" module="adminhtml">
13
+ <title>Productos PR en juego</title>
14
+ <action>*/info/currentDeals</action>
15
+ </prpayment_menu_current>
16
+ <prpayment_menu_sold translate="title" module="adminhtml">
17
+ <title>Productos PR vendidos</title>
18
+ <action>*/info/soldDeals</action>
19
+ </prpayment_menu_sold>
20
+ <prpayment_menu_roulettes translate="title" module="adminhtml">
21
+ <title>Ruletas predefinidas</title>
22
+ <action>*/info/predefinedDeals</action>
23
+ </prpayment_menu_roulettes>
24
+ </children>
25
+ </prpayment_menu>
26
+ </menu>
27
+ <acl>
28
+ <resources>
29
+ <admin>
30
+ <children>
31
+ <prpayment_menu translate="title" module="adminhtml">
32
+ <title>Pay Random</title>
33
+ <sort_order>300</sort_order>
34
+ <children>
35
+ <prpayment_menu_dashboard translate="title" module="adminhtml">
36
+ <title>Dashboard</title>
37
+ <sort_order>100</sort_order>
38
+ </prpayment_menu_dashboard>
39
+ <prpayment_menu_current translate="title" module="adminhtml">
40
+ <title>Productos PR en juego</title>
41
+ <sort_order>100</sort_order>
42
+ </prpayment_menu_current>
43
+ <prpayment_menu_sold translate="title" module="adminhtml">
44
+ <title>Productos PR vendidos</title>
45
+ <sort_order>100</sort_order>
46
+ </prpayment_menu_sold>
47
+ <prpayment_menu_roulettes translate="title" module="adminhtml">
48
+ <title>Ruletas predefinidas</title>
49
+ <sort_order>100</sort_order>
50
+ </prpayment_menu_roulettes>
51
+ </children>
52
+ </prpayment_menu>
53
+ </children>
54
+ </admin>
55
+ </resources>
56
+ </acl>
57
+ </config>
app/code/community/PayRandom/PRPayment/etc/config.xml ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category PayRandom
5
+ * @package PayRandom_PRPayment
6
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <PayRandom_PRPayment>
12
+ <version>0.1.0</version>
13
+ </PayRandom_PRPayment>
14
+ </modules>
15
+ <global>
16
+ <models>
17
+ <prpayment_events>
18
+ <class>PayRandom_PRPayment_Model</class>
19
+ </prpayment_events>
20
+ <prpayment>
21
+ <class>PayRandom_PRPayment_Model</class>
22
+ <resourceModel>prpayment_resource</resourceModel>
23
+ </prpayment>
24
+ <prpayment_resource>
25
+ <class>PayRandom_PRPayment_Model_Resource</class>
26
+ <entities>
27
+ <deal>
28
+ <table>prpayment_deals</table>
29
+ </deal>
30
+ <dealproduct>
31
+ <table>prpayment_deals_products</table>
32
+ </dealproduct>
33
+ <predefineddeal>
34
+ <table>prpayment_predefined_deals</table>
35
+ </predefineddeal>
36
+ <productstatistics>
37
+ <table>prpayment_product_statistics</table>
38
+ </productstatistics>
39
+ </entities>
40
+ </prpayment_resource>
41
+ </models>
42
+ <events>
43
+ <catalog_product_prepare_save>
44
+ <observers>
45
+ <prpayment_events_observer>
46
+ <type>singleton</type>
47
+ <class>PayRandom_PRPayment_Model_Observer</class>
48
+ <method>onUpdate</method>
49
+ </prpayment_events_observer>
50
+ </observers>
51
+ </catalog_product_prepare_save>
52
+ <admin_system_config_changed_section_payment>
53
+ <observers>
54
+ <prpayment_events_observer>
55
+ <type>singleton</type>
56
+ <class>PayRandom_PRPayment_Model_Observer</class>
57
+ <method>onUpdateConfig</method>
58
+ </prpayment_events_observer>
59
+ </observers>
60
+ </admin_system_config_changed_section_payment>
61
+ </events>
62
+ <resources>
63
+ <prpayment_setup>
64
+ <setup>
65
+ <module>PayRandom_PRPayment</module>
66
+ <class>PayRandom_PRPayment_Model_Resource_Setup</class>
67
+ </setup>
68
+ </prpayment_setup>
69
+ </resources>
70
+ <helpers>
71
+ <prpayment>
72
+ <class>PayRandom_PRPayment_Helper_Data</class>
73
+ </prpayment>
74
+ <prpayment_api>
75
+ <class>PayRandom_PRPayment_Helper_API</class>
76
+ </prpayment_api>
77
+ <payment>
78
+ <rewrite>
79
+ <data>PayRandom_PRPayment_Helper_Data</data>
80
+ </rewrite>
81
+ </payment>
82
+ </helpers>
83
+ <blocks>
84
+ <adminhtml>
85
+ <rewrite>
86
+ <catalog_product_grid>PayRandom_PRPayment_Block_Catalog_Product_Grid</catalog_product_grid>
87
+ </rewrite>
88
+ </adminhtml>
89
+ <catalog>
90
+ <rewrite>
91
+ <product_price>PayRandom_PRPayment_Block_Product_Price</product_price>
92
+ <product_view>PayRandom_PRPayment_Block_Product_View</product_view>
93
+ </rewrite>
94
+ </catalog>
95
+ <checkout>
96
+ <rewrite>
97
+ <onepage_review_info>PayRandom_PRPayment_Block_Checkout_Onepage_Review_Info</onepage_review_info>
98
+ <cart_item_renderer>PayRandom_PRPayment_Block_Checkout_Cart_Item_Renderer</cart_item_renderer>
99
+ <cart>PayRandom_PRPayment_Block_Checkout_Cart</cart>
100
+ <onepage_link>PayRandom_PRPayment_Block_Checkout_Onepage_Link</onepage_link>
101
+ <onepage_shipping_method>PayRandom_PRPayment_Block_Checkout_Onepage_Shipping_Method</onepage_shipping_method>
102
+ <onepage_payment>PayRandom_PRPayment_Block_Checkout_Onepage_Payment</onepage_payment>
103
+ </rewrite>
104
+ </checkout>
105
+ <tax>
106
+ <rewrite>
107
+ <checkout_grandtotal>PayRandom_PRPayment_Block_Tax_Checkout_Grandtotal</checkout_grandtotal>
108
+ <checkout_subtotal>PayRandom_PRPayment_Block_Tax_Checkout_Subtotal</checkout_subtotal>
109
+ </rewrite>
110
+ </tax>
111
+ <prpayment>
112
+ <class>PayRandom_PRPayment_Block</class>
113
+ </prpayment>
114
+ </blocks>
115
+ </global>
116
+ <default>
117
+ <payment>
118
+ <prpayment>
119
+ <model>prpayment/standard</model>
120
+ <active>1</active>
121
+ <order_status>pending</order_status>
122
+ <title>Pay Random</title>
123
+ <payment_action>sale</payment_action>
124
+ <allowspecific>0</allowspecific>
125
+ <sort_order>1</sort_order>
126
+ </prpayment>
127
+ </payment>
128
+ </default>
129
+ <frontend>
130
+ <layout>
131
+ <updates>
132
+ <prpayment>
133
+ <file>prpayment.xml</file>
134
+ </prpayment>
135
+ </updates>
136
+ </layout>
137
+
138
+ <routers>
139
+ <prpayment>
140
+ <use>standard</use>
141
+ <args>
142
+ <module>PayRandom_PRPayment</module>
143
+ <frontName>payrandom</frontName>
144
+ </args>
145
+ </prpayment>
146
+ </routers>
147
+ <translate>
148
+ <modules>
149
+ <PayRandom_PRPayment>
150
+ <files>
151
+ <default>PayRandom_PRPayment.csv</default>
152
+ </files>
153
+ </PayRandom_PRPayment>
154
+ </modules>
155
+ </translate>
156
+ </frontend>
157
+ <admin>
158
+ <routers>
159
+ <adminhtml>
160
+ <args>
161
+ <modules>
162
+ <PayRandom_PRPayment after="Mage_Adminhtml">PayRandom_PRPayment</PayRandom_PRPayment>
163
+ </modules>
164
+ </args>
165
+ </adminhtml>
166
+ </routers>
167
+ </admin>
168
+ <adminhtml>
169
+ <layout>
170
+ <updates>
171
+ <prpayment>
172
+ <file>prpayment.xml</file>
173
+ </prpayment>
174
+ </updates>
175
+ </layout>
176
+ <acl>
177
+ <resources>
178
+ <admin>
179
+ <children>
180
+ <prpayment>
181
+ <title>Pay Random</title>
182
+ </prpayment>
183
+ </children>
184
+ </admin>
185
+ </resources>
186
+ </acl>
187
+ <translate>
188
+ <modules>
189
+ <PayRandom_PRPayment>
190
+ <files>
191
+ <default>PayRandom_PRPayment.csv</default>
192
+ </files>
193
+ </PayRandom_PRPayment>
194
+ </modules>
195
+ </translate>
196
+ </adminhtml>
197
+ <crontab>
198
+ <jobs>
199
+ <prpayment_events>
200
+ <schedule>
201
+ <cron_expr>0 3 * * *</cron_expr>
202
+ </schedule>
203
+ <run>
204
+ <model>prpayment_events/observer::cronTask</model>
205
+ </run>
206
+ </prpayment_events>
207
+ </jobs>
208
+ </crontab>
209
+ </config>
app/code/community/PayRandom/PRPayment/etc/system.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category PayRandom
5
+ * @package PayRandom_PRPayment
6
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <payment>
12
+ <groups>
13
+ <prpayment translate="label comment" module="paygate">
14
+ <label>Pay Random</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>0</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
+ <active translate="label">
22
+ <label>Enabled</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ </active>
30
+ <title translate="label">
31
+ <label>Title</label>
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
+ </title>
38
+ <order_status translate="label">
39
+ <label>New Order Status</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_order_status</source_model>
42
+ <sort_order>50</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>0</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </order_status>
47
+ <allowspecific translate="label">
48
+ <label>Payment Applicable From</label>
49
+ <frontend_type>select</frontend_type>
50
+ <sort_order>61</sort_order>
51
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </allowspecific>
56
+ <specificcountry translate="label">
57
+ <label>Countries Payment Applicable From</label>
58
+ <frontend_type>multiselect</frontend_type>
59
+ <sort_order>70</sort_order>
60
+ <source_model>adminhtml/system_config_source_country</source_model>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ <depends>
65
+ <allowspecific>1</allowspecific>
66
+ </depends>
67
+ </specificcountry>
68
+ <sort_order translate="label">
69
+ <label>Sort Order</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>100</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </sort_order>
76
+ <merchant_code translate="label">
77
+ <label>Merchant code</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>200</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>0</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </merchant_code>
84
+ <secret_key translate="label">
85
+ <label>Secret key</label>
86
+ <frontend_type>password</frontend_type>
87
+ <sort_order>201</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>0</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </secret_key>
92
+ </fields>
93
+ </prpayment>
94
+ </groups>
95
+ </payment>
96
+ </sections>
97
+ </config>
app/code/community/PayRandom/PRPayment/sql/prpayment_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $table = $installer->getConnection()->newTable($installer->getTable('prpayment/deal'))
6
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
7
+ 'nullable' => false,
8
+ 'primary' => true,
9
+ 'identity' => true,
10
+ ), 'ID')
11
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
12
+ 'nullable' => false,
13
+ ), 'Name')
14
+ ->addColumn('kind', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
15
+ 'nullable' => false,
16
+ ), 'Kind')
17
+ ->addColumn('discounts', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
18
+ 'nullable' => false,
19
+ ), 'Serialized discounts')
20
+ ->addColumn('view_format', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
21
+ 'nullable' => false,
22
+ ), 'View format')
23
+ ->addColumn('fixed_discount', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => true,
25
+ ), 'View format')
26
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
27
+ 'nullable' => true,
28
+ ), 'Created at')
29
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
30
+ 'nullable' => true,
31
+ ), 'Updated at');
32
+ $installer->getConnection()->createTable($table);
33
+
34
+ $table = $installer->getConnection()->newTable($installer->getTable('prpayment/dealproduct'))
35
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
36
+ 'nullable' => false,
37
+ 'primary' => true,
38
+ 'identity' => true,
39
+ ), 'ID')
40
+ ->addColumn('deal_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
41
+ 'nullable' => false,
42
+ ), 'Deal ID')
43
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
44
+ 'nullable' => false,
45
+ ), 'Product ID')
46
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
47
+ 'nullable' => true,
48
+ ), 'Created at')
49
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
50
+ 'nullable' => true,
51
+ ), 'Updated at');
52
+ $installer->getConnection()->createTable($table);
53
+
54
+ $table = $installer->getConnection()->newTable($installer->getTable('prpayment/predefineddeal'))
55
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
56
+ 'nullable' => false,
57
+ 'primary' => true,
58
+ 'identity' => true,
59
+ ), 'ID')
60
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
61
+ 'nullable' => false,
62
+ ), 'Name')
63
+ ->addColumn('discounts', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
64
+ 'nullable' => false,
65
+ ), 'Serialized discounts')
66
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
67
+ 'nullable' => true,
68
+ ), 'Created at')
69
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
70
+ 'nullable' => true,
71
+ ), 'Updated at');
72
+ $installer->getConnection()->createTable($table);
73
+
74
+ $table = $installer->getConnection()->newTable($installer->getTable('prpayment/productstatistics'))
75
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
76
+ 'nullable' => false,
77
+ 'primary' => true,
78
+ 'identity' => true,
79
+ ), 'ID')
80
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
81
+ 'nullable' => false,
82
+ ), 'Name')
83
+ ->addColumn('deal_name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
84
+ 'nullable' => false,
85
+ ), 'Deal name')
86
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
87
+ 'nullable' => false,
88
+ ), 'Product ID')
89
+ ->addColumn('total_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
90
+ 'nullable' => false,
91
+ 'default' => '0.0000',
92
+ ), 'Total amount')
93
+ ->addColumn('times_purchased', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
94
+ 'nullable' => false,
95
+ ), 'Times purcharsed')
96
+ ->addColumn('units', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
97
+ 'nullable' => false,
98
+ ), 'Units')
99
+ ->addColumn('min_price', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
100
+ 'nullable' => false,
101
+ 'default' => '0.0000',
102
+ ), 'Minimum price')
103
+ ->addColumn('max_price', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
104
+ 'nullable' => false,
105
+ 'default' => '0.0000',
106
+ ), 'Maximum price')
107
+ ->addColumn('expected_average_price', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
108
+ 'nullable' => false,
109
+ 'default' => '0.0000',
110
+ ), 'Expected average price')
111
+ ->addColumn('average_price', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
112
+ 'nullable' => false,
113
+ 'default' => '0.0000',
114
+ ), 'Average price')
115
+ ->addColumn('start_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
116
+ 'nullable' => true,
117
+ ), 'Start date')
118
+ ->addColumn('end_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
119
+ 'nullable' => true,
120
+ ), 'End date')
121
+ ->addColumn('active', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array(
122
+ 'nullable' => true,
123
+ ), 'Active')
124
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
125
+ 'nullable' => true,
126
+ ), 'Created at')
127
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
128
+ 'nullable' => true,
129
+ ), 'Updated at');
130
+ $installer->getConnection()->createTable($table);
131
+
132
+ $installer->endSetup();
app/design/adminhtml/base/default/template/prpayment/deal/design.phtml ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_price = $this->getProduct()->getPrice();
3
+ $_deal = $this->getDeal();
4
+ $_discounts = json_decode($_deal->getDiscounts(), true);
5
+ $_product = $this->getProduct();
6
+ $_productId = $this->getProduct()->getId();
7
+ $_fixed_discount = $_deal->getFixedDiscount();
8
+ ?>
9
+ <div class="content-header">
10
+ <h3 class="icon-head head-system-account">PayRandom - <?php echo ($_deal->getId() == 0?$this->__('Nueva ruleta'):$_deal->getName());?></h3>
11
+ <div style="float: right;">
12
+ <button style="" onclick="window.location='<?php echo Mage::helper('adminhtml')->getUrl("/catalog_product/index");?>'" class="scalable back" type="button" title="<?php echo $this->__('Back');?>"<span><span><span><?php echo $this->__('Back');?></span></span></span></button>
13
+ <button style="" onclick="if(designForm.validate()){ designForm.submit();} " class="scalable save" type="button" title="<?php echo $this->__('Guardar y asignar');?>"><span><span><span><?php echo $this->__('Guardar y asignar');?></span></span></span></button>
14
+ </div>
15
+ </div>
16
+ <div class="entry-edit">
17
+ <p>
18
+ <strong><?php echo $this->__('Producto');?>:</strong> <?php echo $this->getProduct()->getName();?>
19
+ <strong style="margin-left: 40px;"><?php echo $this->__('Precio original');?>:</strong> <?php echo $this->helper('checkout')->formatPrice($_price);?>
20
+ </p>
21
+ <form name="form_design" id="form_design" method="get" action="<?php echo $this->getUrl('*/deals/save');?>">
22
+ <div class="prpayment-design-box">
23
+ <div class="prpayment-design-box-left">
24
+ <div class="prpayment-design-group">
25
+ <div class="prpayment-design-element">
26
+ <strong>1 . <?php echo $this->__('Ponle nombre a la ruleta'); ?></strong>
27
+ <br/>
28
+ <input class="required-entry" type="text" id="name" value="<?php echo htmlspecialchars($_deal->getName());?>" name="deal_name" />
29
+ </div>
30
+ </div>
31
+ <div class="prpayment-design-element">
32
+ <div class="prpayment-design-element">
33
+ <strong>2 . <?php echo $this->__('Configura la ruleta'); ?></strong>
34
+ </div>
35
+ <div class="prpayment-design-element">
36
+ <strong><?php echo $this->__('Precio medio'); ?>:</strong>
37
+ <input class="required-entry validate-greater-than-zero" type="text" id="avg_price" value="<?php echo $this->getAvgPrice();?>" name="avg_price" />
38
+ </div>
39
+ <div class="prpayment-design-element" style="position:relative;">
40
+ <strong><?php echo $this->__('Atracción'); ?>:</strong>
41
+ <br/>
42
+ <div style="width: 350px; background-color: #ccc; height: 4px; margin: 20px 0px 7px 0px;">
43
+
44
+ <div id="sliderAttraction" style="float: left; background-color: red; height: 4px;">
45
+ <div id="trackAttraction" style="width: 350px; height: 20px; position: absolute;">
46
+ <div id="handleAttraction" style="top: -8px; position: absolute;" class="prpayment-slider-handle"></div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ <script type="text/javascript" language="javascript">
52
+ // <![CDATA[
53
+
54
+ var sliderAttraction = new Control.Slider('handleAttraction', 'trackAttraction', {
55
+ range: $R(0,6),
56
+ values: [0,1,2,3,4,5,6],
57
+ sliderValue: 0,
58
+ startSpan: 'sliderAttraction',
59
+ onSlide: function(v) { updateSliderAttraction(v); },
60
+ onChange: function(v) { updateSliderAttraction(v); }
61
+ });
62
+
63
+ function updateSliderAttraction(value) {
64
+ switch(value){
65
+ case 0:
66
+ case 1:
67
+ case 2:
68
+ $('sliderAttraction').setStyle({
69
+ backgroundColor: '#fd4d4e'
70
+ });
71
+ break;
72
+ case 3:
73
+ case 4:
74
+ $('sliderAttraction').setStyle({
75
+ backgroundColor: '#fc9325'
76
+ });
77
+ break;
78
+ case 5:
79
+ case 6:
80
+ $('sliderAttraction').setStyle({
81
+ backgroundColor: '#03b285'
82
+ });
83
+ break;
84
+ }
85
+ setAttraction(value, parseFloat($('avg_price').value));
86
+ }
87
+ // ]]>
88
+ </script>
89
+
90
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/slider-attraction.png');?>" alt="PayRandom" width="100%" style="width: 100%; max-width: 350px;" />
91
+ <div id="visible_recalculate" style="position:absolute; bottom: 15px; right: 0px;">
92
+ <button style="width: 75px;" onclick="recalculate(10); " class="scalable" type="button" title="<?php echo $this->__('Recalcular');?>"><span><span><span><?php echo $this->__('Recalcular');?></span></span></span></button>
93
+ </div>
94
+ </div>
95
+ <div class="prpayment-design-element">
96
+ <table>
97
+ <tr>
98
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 1</th>
99
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 2</th>
100
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 3</th>
101
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 4</th>
102
+ </tr>
103
+ <tr>
104
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal1" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[0], $_price), 2);?>" name="deal1" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
105
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal2" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[1], $_price), 2);?>" name="deal2" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
106
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal3" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[2], $_price), 2);?>" name="deal3" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
107
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal4" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[3], $_price), 2);?>" name="deal4" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
108
+ </tr>
109
+ <tr>
110
+ <td id="result-deal-1" class="prpayment-design-deal-result">&nbsp;</td>
111
+ <td id="result-deal-2" class="prpayment-design-deal-result">&nbsp;</td>
112
+ <td id="result-deal-3" class="prpayment-design-deal-result">&nbsp;</td>
113
+ <td id="result-deal-4" class="prpayment-design-deal-result">&nbsp;</td>
114
+ </tr>
115
+ <tr>
116
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 5</th>
117
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 6</th>
118
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 7</th>
119
+ <th class="prpayment-design-deal-header"><?php echo $this->__('Precio');?> 8</th>
120
+ </tr>
121
+ <tr>
122
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal5" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[4], $_price), 2);?>" name="deal5" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
123
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal6" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[5], $_price), 2);?>" name="deal6" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
124
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal7" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[6], $_price), 2);?>" name="deal7" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
125
+ <td><input class="prpayment-design-deal required-entry validate-zero-or-greater" type="text" id="deal8" value="<?php echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_discounts[7], $_price), 2);?>" name="deal8" onchange="updateDiffDiscountsFromDeals(true);" onkeyup="updateDiffDiscountsFromDeals(true);" /></td>
126
+ </tr>
127
+ <tr>
128
+ <td id="result-deal-5" class="prpayment-design-deal-result">&nbsp;</td>
129
+ <td id="result-deal-6" class="prpayment-design-deal-result">&nbsp;</td>
130
+ <td id="result-deal-7" class="prpayment-design-deal-result">&nbsp;</td>
131
+ <td id="result-deal-8" class="prpayment-design-deal-result">&nbsp;</td>
132
+ </tr>
133
+ </table>
134
+ <span style="font-style: italic;"><?php echo $this->__('Escribe valor 0 si quieres poner el premio GRATIS');?></span>
135
+ </div>
136
+ </div>
137
+ <div class="prpayment-design-element">
138
+ <div class="prpayment-design-element">
139
+ <strong>3 . <?php echo $this->__('Precio fijo'); ?></strong>
140
+ <br/>
141
+ <table style="width: 100%">
142
+ <tr>
143
+ <td style="width: 30%">
144
+ <input type="radio" id="noFixedPrice" name="radioFixedPrice" onchange="updateFixedPrice()" value="0" <?php if (is_null($_fixed_discount)) echo "checked";?> />
145
+ <label for="noFixedPrice"><?php echo $this->__('Sin precio fijo');?></label>
146
+ </td>
147
+ <td style="width: 70%">
148
+ <input type="radio" id="fixedPrice" name="radioFixedPrice" onchange="updateFixedPrice()" value="1" <?php if (!is_null($_fixed_discount)) echo "checked";?> />
149
+ <input class="validate-greater-than-zero" type="text" id="fixed_price" value="<?php if (!is_null($_fixed_discount)) echo round(PayRandom_PRPayment_Helper_Data::applyDiscount($_fixed_discount, $_price), 2);?>" name="fixed_price" style="width: 50%"/>
150
+ <div class="hint" style="padding-left: 20px;"><?php echo $this->__('Fixed price hint');?></span>
151
+ </td>
152
+ </tr>
153
+ </table>
154
+ </div>
155
+ </div>
156
+ <div class="prpayment-design-element">
157
+ <div class="prpayment-design-element">
158
+ <strong>4 . <?php echo $this->__('Icono de la oferta'); ?></strong>
159
+ <br/>
160
+ <table style="width: 100%">
161
+ <tr>
162
+ <td style="width: 30%">
163
+ <select name="view_format" id="dealIcon" onchange="updateExampleIcon()">
164
+ <option <?php if($_deal->view_format == ''){echo ' selected="selected" ';}?>value=""><?php echo $this->__('Ninguno');?></option>
165
+ <option <?php if($_deal->view_format == 'percentages'){echo ' selected="selected" ';}?>value="percentages"><?php echo $this->__('Porcentaje');?></option>
166
+ <option <?php if($_deal->view_format == 'prices'){echo ' selected="selected" ';}?>value="prices"><?php echo $this->__('Importe mínimo');?></option>
167
+ </select>
168
+ </td>
169
+ <td style="width: 70%">
170
+ <?php if (file_exists(Mage::getBaseDir("media") . "/catalog/product" . $_product->getData('small_image'))): ?>
171
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(150); ?>" width="150" height="150" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
172
+ <?php endif ?>
173
+ <img id="iconExample" src="" style="left: -84px; position: relative; top: 8px;" />
174
+ </td>
175
+ </tr>
176
+ </table>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ <div class="prpayment-design-box-right">
181
+ <div id="roulette">
182
+ <div class="prpayment-design-box-bottom">
183
+ <h2><?php echo $this->__('Los números de la ruleta');?>:</h2>
184
+ <table style="width: 100%;">
185
+ <tr>
186
+ <th width="33%"><?php echo $this->__('Precio medio');?></th>
187
+ <th width="33%"><?php echo $this->__('Equilibrio');?></th>
188
+ <th width="33%"><?php echo $this->__('Atracción');?></th>
189
+ </tr>
190
+ <tr>
191
+ <td><span id="lblAvgPrice"><?php echo $this->helper('checkout')->formatPrice($_price);?></span>€</td>
192
+ <td><span id="lblBalance"></span></td>
193
+ <td>
194
+ <span id="lblAttraction"></span>
195
+ <span class="deal-attraction-medium deal-attraction" style="display:none;">
196
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_medium.png');?>" alt="PayRandom" />
197
+ </span>
198
+ <span class="deal-attraction-high deal-attraction" style="display:none;">
199
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_high.png');?>" alt="PayRandom" />
200
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_high.png');?>" alt="PayRandom" />
201
+ </span>
202
+ <span class="deal-attraction-very-high deal-attraction" style="display:none;">
203
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_very_high.png');?>" alt="PayRandom" />
204
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_very_high.png');?>" alt="PayRandom" />
205
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/attraction_very_high.png');?>" alt="PayRandom" />
206
+ </span>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ </div>
211
+ <div class="prpayment-design-box-bigimage">
212
+ <img id="roulette-img" style="width: 60%;" src="<?php echo PayRandom_PRPayment_Helper_Data_Api::getRouletteImg($_discounts, $_price, $this->__('Free'), 600, 600);?>" />
213
+ </div>
214
+ </div>
215
+ <div id="recalculate" style="display: none;" class="prpayment-design-recaluclate">
216
+ <button style="width: 50%; font-size: 4em;" onclick="recalculate(10); " class="scalable" type="button" title="<?php echo $this->__('Recalcular');?>"><span><span><span><?php echo $this->__('Recalcular');?></span></span></span></button>
217
+ </div>
218
+ <div id="prpayment-loading" style="display: none;" class="prpayment-design-loading">
219
+ <h2><?php echo $this->__('Generando la ruleta...');?></h2>
220
+ </div>
221
+ </div>
222
+ <div style="clear: both;"></div>
223
+ </div>
224
+ <input type="hidden" name="real_price" id="real_price" value="<?php echo $_price;?>" />
225
+ <input type="hidden" name="deals_product_id" id="deals_product_id" value="<?php echo $_productId;?>" />
226
+ <input type="hidden" id="real_discount_1" name="discounts[]" value="1" />
227
+ <input type="hidden" id="real_discount_2" name="discounts[]" value="2" />
228
+ <input type="hidden" id="real_discount_3" name="discounts[]" value="3" />
229
+ <input type="hidden" id="real_discount_4" name="discounts[]" value="4" />
230
+ <input type="hidden" id="real_discount_5" name="discounts[]" value="5" />
231
+ <input type="hidden" id="real_discount_6" name="discounts[]" value="6" />
232
+ <input type="hidden" id="real_discount_7" name="discounts[]" value="7" />
233
+ <input type="hidden" id="real_discount_8" name="discounts[]" value="8" />
234
+ </form>
235
+ </div>
236
+ <script type="text/javascript">
237
+ //< ![CDATA[
238
+ var jsTranslate = <?php echo json_encode(
239
+ array(
240
+ 'freeText' => $this->__('Free'),
241
+ 'upToText' => $this->__('Hasta'),
242
+ 'fromText' => $this->__('Desde'),
243
+ 'fromFreeText' => $this->__('Now')
244
+ )
245
+ );?>;
246
+
247
+ Validation.add("validate-fixed-price", "No valid", function (v) {
248
+ return parseFloat(v) >= parseFloat($('avg_price').value);
249
+ });
250
+
251
+ var designForm = new varienForm('form_design');
252
+ <?php if($_deal->getId()) { ?>
253
+ updateDiffDiscountsFromDeals(false);
254
+ <?php } else { ?>
255
+ setAttraction(0, parseFloat($('avg_price').value));
256
+ <?php } ?>
257
+ //]]>
258
+ </script>
app/design/adminhtml/base/default/template/prpayment/info.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <h3 class="icon-head head-system-account">PayRandom - <?php echo $this->__('Account Information');?></h3>
3
+ </div>
4
+ <div class="entry-edit">
5
+ <?php /*<p><a href="<?php echo Mage::helper("adminhtml")->getUrl('adminhtml/system_config/edit', array('section'=>'payment'));?>"><?php echo $this->__('Configure extension');?></a></p>*/ ?>
6
+
7
+ <div class="entry-edit" style="text-align: center;">
8
+ <iframe src="<?php echo Mage::helper('prpayment/api')->getDashBoardUrl();?>" height="600" width="960" style="border: 0px;"></iframe>
9
+ </div>
10
+ </div>
app/design/adminhtml/base/default/template/prpayment/predefinedgrid.phtml ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $numColumns = sizeof($this->getColumns());
3
+ $avgPrice = $this->getAvgPrice();
4
+ $productId = $this->getRequest()->getParam('product_id');
5
+
6
+ $product = Mage::getModel('catalog/product')->load($productId);
7
+ ?>
8
+ <div style="clear: both; margin-bottom: 20px;">
9
+ <strong><?php echo $this->__('Producto');?>:</strong> <?php echo $product->getName();?>
10
+
11
+ <strong><?php echo $this->__('Precio original');?>:</strong> <?php echo $this->helper('checkout')->formatPrice($product->getPrice());?>
12
+ <div style="float: right;">
13
+ <form name="form_avg_price" id="form_avg_price" method="get" action="<?php echo $this->getUrl('*/deals/chooseredir');?>">
14
+ <?php echo $this->__('Precio medio'); ?>: <input class="required-entry validate-zero-or-greater" type="text" id="avgPrice" value="<?php echo $avgPrice;?>" name="avg_price" />
15
+ <input type="submit" value="<?php echo $this->__('Recalcular');?>" class="form-button" />
16
+ <input type="hidden" value="<?php echo $productId;?>" name="product_id" />
17
+ </form>
18
+ </div>
19
+ </div>
20
+ <?php if($this->getCollection()): ?>
21
+ <?php if($this->canDisplayContainer()): ?>
22
+ <?php if($this->getGridHeader()): ?>
23
+ <div class="content-header">
24
+ <table cellspacing="0">
25
+ <tr>
26
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
27
+ </tr>
28
+ </table>
29
+ </div>
30
+ <?php endif ?>
31
+
32
+ <div id="<?php echo $this->getId() ?>">
33
+ <?php else: ?>
34
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
35
+ <?php endif; ?>
36
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
37
+ <?php echo $this->getMassactionBlockHtml() ?>
38
+ <?php endif ?>
39
+ <div class="grid">
40
+ <div class="hor-scroll">
41
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
42
+ <?php foreach ($this->getColumns() as $_column): ?>
43
+ <col <?php echo $_column->getHtmlProperty() ?> />
44
+ <?php endforeach; ?>
45
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
46
+ <thead>
47
+ <?php if ($this->getHeadersVisibility()): ?>
48
+ <tr class="headings">
49
+ <?php foreach ($this->getColumns() as $_column): ?>
50
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
51
+ <?php endforeach; ?>
52
+ </tr>
53
+ <?php endif; ?>
54
+ <?php if ($this->getFilterVisibility()): ?>
55
+ <tr class="filter">
56
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
57
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
58
+ <?php endforeach; ?>
59
+ </tr>
60
+ <?php endif ?>
61
+ </thead>
62
+ <?php endif; ?>
63
+ <?php if ($this->getCountTotals()): ?>
64
+ <tfoot>
65
+ <tr class="totals">
66
+ <?php foreach ($this->getColumns() as $_column): ?>
67
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
68
+ <?php endforeach; ?>
69
+ </tr>
70
+ </tfoot>
71
+ <?php endif; ?>
72
+
73
+ <tbody>
74
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
75
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
76
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
77
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
78
+
79
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
80
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
81
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
82
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
83
+ </td>
84
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
85
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
86
+ <?php endif;?>
87
+ <?php endif;?>
88
+
89
+ <?php endforeach; ?>
90
+ </tr>
91
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
92
+ <?php foreach ($_multipleRows as $_i):?>
93
+ <tr>
94
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
95
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
96
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
97
+ </td>
98
+ <?php endforeach; ?>
99
+ </tr>
100
+ <?php endforeach;?>
101
+ <?php endif;?>
102
+
103
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
104
+ <tr class="subtotals">
105
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
106
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
107
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
108
+ $_column->getRowField($this->getSubTotalItem($_item))
109
+ );
110
+ ?>
111
+ </td>
112
+ <?php endforeach; ?>
113
+ </tr>
114
+ <?php endif; ?>
115
+ <?php endforeach; ?>
116
+ <?php elseif ($this->getEmptyText()): ?>
117
+ <tr>
118
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
119
+ </tr>
120
+ <?php endif; ?>
121
+ </tbody>
122
+
123
+ </table>
124
+ </div>
125
+ </div>
126
+ <?php if($this->canDisplayContainer()): ?>
127
+ </div>
128
+ <script type="text/javascript">
129
+ //<![CDATA[
130
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
131
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
132
+ <?php if($this->getRowClickCallback()): ?>
133
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
134
+ <?php endif; ?>
135
+ <?php if($this->getCheckboxCheckCallback()): ?>
136
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
137
+ <?php endif; ?>
138
+ <?php if($this->getRowInitCallback()): ?>
139
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
140
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
141
+ <?php endif; ?>
142
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
143
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
144
+ <?php endif ?>
145
+ <?php echo $this->getAdditionalJavaScript(); ?>
146
+ //]]>
147
+ </script>
148
+ <?php endif; ?>
149
+ <?php endif ?>
150
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
151
+ <table cellspacing="0" class="actions">
152
+ <tr>
153
+ <?php if($this->getPagerVisibility()): ?>
154
+ <td class="pager">
155
+ <?php echo $this->__('Page') ?>
156
+
157
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
158
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
159
+ <?php if($_curPage>1): ?>
160
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
161
+ <?php else: ?>
162
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
163
+ <?php endif; ?>
164
+
165
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
166
+
167
+ <?php if($_curPage < $_lastPage): ?>
168
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
169
+ <?php else: ?>
170
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
171
+ <?php endif; ?>
172
+
173
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
174
+ <span class="separator">|</span>
175
+ <?php echo $this->__('View') ?>
176
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
177
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
178
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
179
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
180
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
181
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
182
+ </select>
183
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
184
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
185
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
186
+ <?php if($this->getRssLists()): ?>
187
+ <?php foreach ($this->getRssLists() as $_rss): ?>
188
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
189
+ <?php endforeach ?>
190
+ <?php endif; ?>
191
+ </td>
192
+ <?php endif ?>
193
+ <?php if($this->getExportTypes()): ?>
194
+ <td class="export a-right">
195
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
196
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
197
+ <?php foreach ($this->getExportTypes() as $_type): ?>
198
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
199
+ <?php endforeach; ?>
200
+ </select>
201
+ <?php echo $this->getExportButtonHtml() ?>
202
+ </td>
203
+ <?php endif; ?>
204
+ <td class="filter-actions a-right">
205
+ <?php echo $this->getMainButtonsHtml() ?>
206
+ </td>
207
+ </tr>
208
+ </table>
209
+ <?php endif; ?>
210
+ <script type="text/javascript">
211
+ //< ![CDATA[
212
+ var predefinedForm = new varienForm('form_avg_price');
213
+ //]]>
214
+ </script>
app/design/adminhtml/default/default/layout/prpayment.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>js/prpayment/adminprpayment.js</name>
8
+ </action>
9
+ <action method="addItem">
10
+ <type>skin_css</type>
11
+ <name>css/prpayment/adminprpayment.css</name>
12
+ </action>
13
+ </reference>
14
+ </default>
15
+ </layout>
app/design/frontend/base/default/layout/prpayment.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>js/prpayment/prpayment.js</name>
8
+ </action>
9
+ <action method="addItem">
10
+ <type>skin_css</type>
11
+ <name>css/prpayment/prpayment.css</name>
12
+ </action>
13
+ </reference>
14
+ </default>
15
+
16
+ <catalog_category_default>
17
+ <reference name="product_list">
18
+ <action method="setTemplate">
19
+ <template>prpayment/catalog/product/list.phtml</template>
20
+ </action>
21
+ </reference>
22
+ </catalog_category_default>
23
+ <catalog_category_layered>
24
+ <reference name="product_list">
25
+ <action method="setTemplate">
26
+ <template>prpayment/catalog/product/list.phtml</template>
27
+ </action>
28
+ </reference>
29
+ </catalog_category_layered>
30
+ <catalogsearch_result_index>
31
+ <reference name="search_result_list">
32
+ <action method="setTemplate">
33
+ <template>prpayment/catalog/product/list.phtml</template>
34
+ </action>
35
+ </reference>
36
+ </catalogsearch_result_index>
37
+
38
+ <catalogsearch_advanced_result>
39
+ <reference name="search_result_list">
40
+ <action method="setTemplate">
41
+ <template>prpayment/catalog/product/list.phtml</template>
42
+ </action>
43
+ </reference>
44
+ </catalogsearch_advanced_result>
45
+ <PRODUCT_TYPE_simple>
46
+ <reference name="product.info.simple">
47
+ <action method="setTemplate">
48
+ <template>prpayment/catalog/product/view/type/default.phtml</template>
49
+ </action>
50
+ </reference>
51
+ </PRODUCT_TYPE_simple>
52
+ <PRODUCT_TYPE_configurable>
53
+ <reference name="product.info.configurable">
54
+ <action method="setTemplate">
55
+ <template>prpayment/catalog/product/view/type/default.phtml</template>
56
+ </action>
57
+ </reference>
58
+ </PRODUCT_TYPE_configurable>
59
+ <PRODUCT_TYPE_virtual>
60
+ <reference name="product.info.virtual">
61
+ <action method="setTemplate">
62
+ <template>prpayment/catalog/product/view/type/default.phtml</template>
63
+ </action>
64
+ </reference>
65
+ </PRODUCT_TYPE_virtual>
66
+ <catalog_product_view>
67
+ <reference name="product.info.addtocart">
68
+ <action method="setTemplate">
69
+ <template>prpayment/catalog/product/view/addtocart.phtml</template>
70
+ </action>
71
+ </reference>
72
+ </catalog_product_view>
73
+ <checkout_onepage_review>
74
+ <reference name="checkout.onepage.review.button">
75
+ <action method="setTemplate">
76
+ <template>prpayment/checkout/onepage/review/button.phtml</template>
77
+ </action>
78
+ </reference>
79
+ </checkout_onepage_review>
80
+ <!-- OneStepCheckout -->
81
+ <onestepcheckout_index_index>
82
+ <reference name="onestepcheckout.checkout">
83
+ <action method="setTemplate">
84
+ <template>prpayment/onestepcheckout/checkout.phtml</template>
85
+ </action>
86
+ </reference>
87
+ <reference name="onestepcheckout.summary">
88
+ <action method="setTemplate">
89
+ <template>prpayment/onestepcheckout/summary.phtml</template>
90
+ </action>
91
+ </reference>
92
+ </onestepcheckout_index_index>
93
+ <onestepcheckout_ajax_add_extra_product>
94
+ <reference name="checkout.cart.totals">
95
+ <action method="setTemplate">
96
+ <template>prpayment/onestepcheckout/summary.phtml</template>
97
+ </action>
98
+ </reference>
99
+ </onestepcheckout_ajax_add_extra_product>
100
+ <onestepcheckout_ajax_set_methods_separate>
101
+ <reference name="onestepcheckout.summary">
102
+ <action method="setTemplate">
103
+ <template>prpayment/onestepcheckout/summary.phtml</template>
104
+ </action>
105
+ </reference>
106
+ </onestepcheckout_ajax_set_methods_separate>
107
+ <onestepcheckout_ajax_paymentrefresh>
108
+ <reference name="onestepcheckout.summary">
109
+ <action method="setTemplate">
110
+ <template>prpayment/onestepcheckout/summary.phtml</template>
111
+ </action>
112
+ </reference>
113
+ </onestepcheckout_ajax_paymentrefresh>
114
+ <onestepcheckout_ajax_save_billing>
115
+ <reference name="onestepcheckout.summary">
116
+ <action method="setTemplate">
117
+ <template>prpayment/onestepcheckout/summary.phtml</template>
118
+ </action>
119
+ </reference>
120
+ </onestepcheckout_ajax_save_billing>
121
+ </layout>
app/design/frontend/base/default/template/prpayment/addtocart_pr.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_product = $this->getProduct(); ?>
2
+ <?php $buttonTitle = $this->__('Compra y Juega'); ?>
3
+ <?php if($_product->isSaleable()): ?>
4
+ <div class="add-to-cart">
5
+ <?php if(!$_product->isGrouped()): ?>
6
+ <label for="qty"><?php echo $this->__('Qty:') ?></label>
7
+ <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) == null ? 1 : $this->getMinimalQty($_product) ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
8
+ <?php endif; ?>
9
+ <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
10
+ <?php echo $this->getChildHtml('', true, true) ?>
11
+ </div>
12
+ <?php endif; ?>
app/design/frontend/base/default/template/prpayment/catalog/product/list.phtml ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php
35
+ $_productCollection=$this->getLoadedProductCollection();
36
+ $_helper = $this->helper('catalog/output');
37
+ ?>
38
+ <?php if(!$_productCollection->count()): ?>
39
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
40
+ <?php else: ?>
41
+ <div class="category-products">
42
+ <?php echo $this->getToolbarHtml() ?>
43
+ <?php // List mode ?>
44
+ <?php if($this->getMode()!='grid'): ?>
45
+ <?php $_iterator = 0; ?>
46
+ <ol class="products-list" id="products-list">
47
+ <?php foreach ($_productCollection as $_product): ?>
48
+ <?php
49
+ $ImgPRandom = '';
50
+ $txtAddToCart = $this->__('Add to Cart');
51
+ $productId = $_product->getId();
52
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
53
+ if(in_array($productId, $productsCanApply)){
54
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($productId);
55
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
56
+ if($deal->view_format){
57
+ $maxDiscount = $deal->getMaximumDiscount();
58
+
59
+ if($deal->view_format == 'prices'){
60
+ if($maxDiscount == 1){
61
+ $maxDiscountText = $this->__('Free');
62
+ $upperText = $this->__('Now');
63
+ }else{
64
+ $maxDiscountText = PayRandom_PRPayment_Helper_Data::applyDiscount($maxDiscount, $_product->getPrice());
65
+ $maxDiscountText = round($maxDiscountText, 2) . '€';
66
+ $upperText = $this->__('Desde');
67
+ }
68
+ }else{
69
+ if($maxDiscount == 1){
70
+ $maxDiscountText = $this->__('Free');
71
+ $upperText = $this->__('Now');
72
+ }else{
73
+ $maxDiscountText = round($maxDiscount * 100) . '%';
74
+ $upperText = $this->__('Hasta');
75
+ }
76
+ }
77
+
78
+ $imgSrc = PayRandom_PRPayment_Helper_Data_Api::getWatermarkImg($upperText, $maxDiscountText, 70, 70);
79
+ $ImgPRandom = '<img src="' . $imgSrc . '" alt="PayRandom" style="position: relative; top: -60px; left: 75px;" />';
80
+ }
81
+ $txtAddToCart = $this->__('Compra y Juega');
82
+ }
83
+ ?>
84
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
85
+ <?php // Product Image ?>
86
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /><?php echo $ImgPRandom;?></a>
87
+ <?php // Product description ?>
88
+ <div class="product-shop">
89
+ <div class="f-fix">
90
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
91
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
92
+ <?php if($_product->getRatingSummary()): ?>
93
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
94
+ <?php endif; ?>
95
+ <?php echo $this->getPriceHtml($_product, true) ?>
96
+ <?php if($_product->isSaleable()): ?>
97
+ <p><button type="button" title="<?php echo $txtAddToCart ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $txtAddToCart ?></span></span></button></p>
98
+ <?php else: ?>
99
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
100
+ <?php endif; ?>
101
+ <div class="desc std">
102
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
103
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
104
+ </div>
105
+ <ul class="add-to-links">
106
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
107
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
108
+ <?php endif; ?>
109
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
110
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
111
+ <?php endif; ?>
112
+ </ul>
113
+ </div>
114
+ </div>
115
+ </li>
116
+ <?php endforeach; ?>
117
+ </ol>
118
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
119
+
120
+ <?php else: ?>
121
+
122
+ <?php // Grid Mode ?>
123
+
124
+ <?php $_collectionSize = $_productCollection->count() ?>
125
+ <?php $_columnCount = $this->getColumnCount(); ?>
126
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
127
+ <?php
128
+ $ImgPRandom = '';
129
+ $txtAddToCart = $this->__('Add to Cart');
130
+ $productId = $_product->getId();
131
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
132
+ if(in_array($productId, $productsCanApply)){
133
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($productId);
134
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
135
+ if($deal->view_format){
136
+ $maxDiscount = $deal->getMaximumDiscount();
137
+
138
+ if($deal->view_format == 'prices'){
139
+ if($maxDiscount == 1){
140
+ $maxDiscountText = $this->__('Free');
141
+ $upperText = $this->__('Now');
142
+ }else{
143
+ $maxDiscountText = PayRandom_PRPayment_Helper_Data::applyDiscount($maxDiscount, $_product->getPrice());
144
+ $maxDiscountText = round($maxDiscountText, 2) . '€';
145
+ $upperText = $this->__('Desde');
146
+ }
147
+ }else{
148
+ if($maxDiscount == 1){
149
+ $maxDiscountText = $this->__('Free');
150
+ $upperText = $this->__('Now');
151
+ }else{
152
+ $maxDiscountText = round($maxDiscount * 100) . '%';
153
+ $upperText = $this->__('Hasta');
154
+ }
155
+ }
156
+
157
+ $imgSrc = PayRandom_PRPayment_Helper_Data_Api::getWatermarkImg($upperText, $maxDiscountText, 70, 70);
158
+ $ImgPRandom = '<img src="' . $imgSrc . '" alt="PayRandom" style="position: relative; top: -60px; left: 75px;" />';
159
+ }
160
+ $txtAddToCart = $this->__('Compra y Juega');
161
+ }
162
+ ?>
163
+ <?php if ($i++%$_columnCount==0): ?>
164
+ <ul class="products-grid">
165
+ <?php endif ?>
166
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
167
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /><?php echo $ImgPRandom;?></a>
168
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
169
+ <?php if($_product->getRatingSummary()): ?>
170
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
171
+ <?php endif; ?>
172
+ <?php echo $this->getPriceHtml($_product, true) ?>
173
+ <div class="actions">
174
+ <?php if($_product->isSaleable()): ?>
175
+ <button type="button" title="<?php echo $txtAddToCart ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $txtAddToCart ?></span></span></button>
176
+ <?php else: ?>
177
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
178
+ <?php endif; ?>
179
+ <ul class="add-to-links">
180
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
181
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
182
+ <?php endif; ?>
183
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
184
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
185
+ <?php endif; ?>
186
+ </ul>
187
+ </div>
188
+ </li>
189
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
190
+ </ul>
191
+ <?php endif ?>
192
+ <?php endforeach ?>
193
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
194
+ <?php endif; ?>
195
+
196
+ <div class="toolbar-bottom">
197
+ <?php echo $this->getToolbarHtml() ?>
198
+ </div>
199
+ </div>
200
+ <?php endif; ?>
app/design/frontend/base/default/template/prpayment/catalog/product/view/addtocart.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_product = $this->getProduct(); ?>
2
+ <?php
3
+ $productId = $_product->getId();
4
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
5
+ if(in_array($productId, $productsCanApply)){
6
+ $block = $this->getLayout()->createBlock(
7
+ 'Mage_Core_Block_Template',
8
+ 'addtocart_pr',
9
+ array('template' => 'prpayment/addtocart_pr.phtml')
10
+ );
11
+ $block->setProduct($this->getProduct());
12
+ echo $block->toHtml();
13
+ }else{
14
+ ?>
15
+ <?php $buttonTitle = $this->__('Add to Cart'); ?>
16
+ <?php if($_product->isSaleable()): ?>
17
+ <div class="add-to-cart">
18
+ <?php if(!$_product->isGrouped()): ?>
19
+ <label for="qty"><?php echo $this->__('Qty:') ?></label>
20
+ <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
21
+ <?php endif; ?>
22
+ <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
23
+ <?php echo $this->getChildHtml('', true, true) ?>
24
+ </div>
25
+ <?php endif; ?>
26
+ <?php
27
+ }
28
+ ?>
app/design/frontend/base/default/template/prpayment/catalog/product/view/type/default.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
2
+ <?php $_product = $this->getProduct() ?>
3
+
4
+ <?php if ($_product->isAvailable()): ?>
5
+ <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
6
+ <?php else: ?>
7
+ <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
8
+ <?php endif; ?>
9
+ <?php echo $this->getChildHtml('product_type_data_extra') ?>
10
+ <?php
11
+ $productId = $_product->getId();
12
+ $productsCanApply = PayRandom_PRPayment_Helper_Data::idProductsDeal();
13
+ if(in_array($productId, $productsCanApply)){
14
+ $block = $this->getLayout()->createBlock(
15
+ 'Mage_Core_Block_Template',
16
+ 'price_full',
17
+ array('template' => 'prpayment/price_full.phtml')
18
+ );
19
+ $block->setProduct($this->getProduct());
20
+ echo $block->toHtml();
21
+ }else{
22
+ echo $this->getPriceHtml($_product);
23
+ }
24
+ ?>
app/design/frontend/base/default/template/prpayment/checkout/cart.phtml ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $dealProduct = PayRandom_PRPayment_Helper_Data::getCartProductDeal(); ?>
2
+ <?php $_id = $dealProduct->getProductId(); ?>
3
+ <?php $product = Mage::getModel('catalog/product')->load($_id); ?>
4
+ <?php $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId()); ?>
5
+ <?php $_discounts = json_decode($deal->getDiscounts(), true); ?>
6
+ <?php $_taxHelper = $this->helper('tax'); ?>
7
+ <?php $_price = $_taxHelper->getPrice($product, $product->getPrice()); ?>
8
+
9
+ <div class="cart">
10
+ <div class="page-title title-buttons">
11
+ <h1><?php echo $this->__('Shopping Cart') ?></h1>
12
+ <?php if(!$this->hasError()): ?>
13
+ <ul class="checkout-types">
14
+ <?php foreach ($this->getMethods('top_methods') as $method): ?>
15
+ <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
16
+ <li><?php echo $methodHtml; ?></li>
17
+ <?php endif; ?>
18
+ <?php endforeach; ?>
19
+ </ul>
20
+ <?php endif; ?>
21
+ </div>
22
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
23
+ <?php echo $this->getChildHtml('form_before') ?>
24
+ <div class="payrandom-information">
25
+ <div class="payrandom-information-img">
26
+ <div class="payrandom-information-content">
27
+ <div class="payrandom-information-content-right">
28
+ <a href="#" class="payrandom-price-full-left-element" onclick="prPaymentOpenHelp(<?php echo $_id ?>); return false;">
29
+ <?php echo $this->__('Más información');?>
30
+ </a>
31
+ </div>
32
+ <?php echo $this->__('Continua con el proceso de compra y al final jugarás el precio con <strong>PayRandom</strong>');?>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
37
+ <fieldset>
38
+ <table id="shopping-cart-table" class="data-table cart-table">
39
+ <col width="1" />
40
+ <col />
41
+ <col width="1" />
42
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
43
+ <col width="1" />
44
+ <?php endif ?>
45
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
46
+ <col width="1" />
47
+ <?php endif; ?>
48
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
49
+ <col width="1" />
50
+ <?php endif; ?>
51
+ <col width="1" />
52
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
53
+ <col width="1" />
54
+ <?php endif; ?>
55
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
56
+ <col width="1" />
57
+ <?php endif; ?>
58
+ <col width="1" />
59
+
60
+ <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
61
+ <thead>
62
+ <tr>
63
+ <th rowspan="<?php echo $mergedCells; ?>">&nbsp;</th>
64
+ <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
65
+ <th rowspan="<?php echo $mergedCells; ?>"></th>
66
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
67
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
68
+ <?php endif ?>
69
+ <th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span> <br/><img src="<?php echo $this->getSkinUrl('images/prpayment/help.png');?>" alt="PayRandom" /></th>
70
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
71
+ <th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?>
72
+ <br/><img src="<?php echo $this->getSkinUrl('images/prpayment/help.png');?>" alt="PayRandom" /></th>
73
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center">&nbsp;</th>
74
+ </tr>
75
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
76
+ <tr>
77
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
78
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
79
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
80
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
81
+ </tr>
82
+ <?php endif; ?>
83
+ </thead>
84
+ <tfoot>
85
+ <tr>
86
+ <td colspan="50" class="a-right">
87
+ <?php if($this->getContinueShoppingUrl()): ?>
88
+ <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getContinueShoppingUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
89
+ <?php endif; ?>
90
+ <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
91
+ <button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
92
+ <!--[if lt IE 8]>
93
+ <input type="hidden" id="update_cart_action_container" />
94
+ <script type="text/javascript">
95
+ //<![CDATA[
96
+ Event.observe(window, 'load', function()
97
+ {
98
+ // Internet Explorer (lt 8) does not support value attribute in button elements
99
+ $emptyCartButton = $('empty_cart_button');
100
+ $cartActionContainer = $('update_cart_action_container');
101
+ if ($emptyCartButton && $cartActionContainer) {
102
+ Event.observe($emptyCartButton, 'click', function()
103
+ {
104
+ $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
105
+ $cartActionContainer.setAttribute('name', 'update_cart_action');
106
+ $cartActionContainer.setValue('empty_cart');
107
+ });
108
+ }
109
+
110
+ });
111
+ //]]>
112
+ </script>
113
+ <![endif]-->
114
+ </td>
115
+ </tr>
116
+ </tfoot>
117
+ <tbody>
118
+ <?php foreach($this->getItems() as $_item): ?>
119
+ <?php echo $this->getItemHtml($_item) ?>
120
+ <?php endforeach ?>
121
+ </tbody>
122
+ </table>
123
+ <script type="text/javascript">decorateTable('shopping-cart-table')</script>
124
+ </fieldset>
125
+ </form>
126
+ <div class="cart-collaterals">
127
+ <div class="col2-set">
128
+ <div class="col-1">
129
+ <?php echo $this->getChildHtml('crosssell') ?>
130
+ </div>
131
+ <div class="col-2">
132
+ <?php /* Extensions placeholder */ ?>
133
+ <?php echo $this->getChildHtml('checkout.cart.extra') ?>
134
+ <?php echo $this->getChildHtml('coupon') ?>
135
+ <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
136
+ </div>
137
+ </div>
138
+ <div class="totals">
139
+ <?php echo $this->getChildHtml('totals'); ?>
140
+ <?php if(!$this->hasError()): ?>
141
+ <ul class="checkout-types">
142
+ <?php foreach ($this->getMethods('methods') as $method): ?>
143
+ <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
144
+ <li><?php echo $methodHtml; ?></li>
145
+ <?php endif; ?>
146
+ <?php endforeach; ?>
147
+ </ul>
148
+ <?php endif; ?>
149
+ </div>
150
+ </div>
151
+ </div>
152
+ <div id="payrandom-modalbox-info-<?php echo $_id ?>" class="payrandom-modalbox" style="display:none;">
153
+ <div class="payrandom-modalbox-header">
154
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/logo_pr_white_small.png');?>" alt="PayRandom" />
155
+ <a href="#" onclick="prPaymentCloseHelp(<?php echo $_id;?>); return false;" id="payrandom-modalbox-close" class="payrandom-modalbox-close"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/close.png');?>" alt="close" /></a>
156
+ </div>
157
+ <div class="payrandom-modalbox-content">
158
+ <div id="payrandom-maincontent-<?php echo $_id;?>" class="payrandom-modalbox-content-maincontent">
159
+ <div class="payrandom-modalbox-content-divimg">
160
+ <img src="<?php echo PayRandom_PRPayment_Helper_Data_Api::getRouletteImg($_discounts, $_price, $this->__('Free'), 250, 250);?>" alt="Roulette" />
161
+ </div>
162
+
163
+ <h2 class="payrandom-modalbox-h2"><?php echo $this->__('Compra y juega con PayRandom') ?></h2>
164
+ <p><?php echo $this->__('¡Consigue este producto por uno de los precios que vés en la ruleta!') ?></p>
165
+ <p><span class="payrandom-modalbox-howitworks"><?php echo $this->__('Cómo funciona') ?>:</span></p>
166
+ <a href="#" onclick="$('payrandom-maincontent-<?php echo $_id;?>').hide();$('payrandom-video-<?php echo $_id;?>').show(); return false;" target="_blank"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/video.png');?>" alt="help" /></a>
167
+ </div>
168
+ <div id="payrandom-video-<?php echo $_id;?>" class="payrandom-modalbox-content-video" style="display: none;">
169
+ <iframe id="how-it-works" src="//player.vimeo.com/video/91405153" width="465" height="260" frameborder="0" allowfullscreen></iframe>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ <script type="text/javascript">
174
+ document.observe('dom:loaded', function() {
175
+ $("payrandom-modalbox-close").on("click", function (e) {
176
+ $('how-it-works').setAttribute('src','');
177
+ $('how-it-works').setAttribute('src','//player.vimeo.com/video/91405153');
178
+ });
179
+ });
180
+ </script>
app/design/frontend/base/default/template/prpayment/checkout/cart/item/default.phtml ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_item = $this->getItem();
3
+ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
4
+ $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
5
+ ?>
6
+ <tr>
7
+ <td><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
8
+ <td>
9
+ <h2 class="product-name">
10
+ <?php if ($this->hasProductUrl()):?>
11
+ <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->htmlEscape($this->getProductName()) ?></a>
12
+ <?php else: ?>
13
+ <?php echo $this->htmlEscape($this->getProductName()) ?>
14
+ <?php endif; ?>
15
+ </h2>
16
+ <?php if ($_options = $this->getOptionList()):?>
17
+ <dl class="item-options">
18
+ <?php foreach ($_options as $_option) : ?>
19
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
20
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
21
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
22
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
23
+ <div class="truncated_full_value">
24
+ <dl class="item-options">
25
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
26
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
27
+ </dl>
28
+ </div>
29
+ <?php endif; ?>
30
+ </dd>
31
+ <?php endforeach; ?>
32
+ </dl>
33
+ <?php endif;?>
34
+ <?php if ($messages = $this->getMessages()): ?>
35
+ <?php foreach ($messages as $message): ?>
36
+ <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
37
+ <?php endforeach; ?>
38
+ <?php endif; ?>
39
+ <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
40
+ <?php if ($addInfoBlock): ?>
41
+ <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
42
+ <?php endif;?>
43
+ </td>
44
+ <td class="a-center">
45
+ <?php if ($isVisibleProduct): ?>
46
+ <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
47
+ <?php endif ?>
48
+ </td>
49
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
50
+ <td class="a-center">
51
+ <?php if ($isVisibleProduct): ?>
52
+ <a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
53
+ <?php endif ?>
54
+ </td>
55
+ <?php endif ?>
56
+
57
+ <?php if ($canApplyMsrp): ?>
58
+ <td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
59
+ <span class="cart-price">
60
+ <span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
61
+ <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
62
+ <a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
63
+ <script type="text/javascript">
64
+ Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("What's this?") ?>");
65
+ </script>
66
+ </span>
67
+ </td>
68
+ <?php else: ?>
69
+
70
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
71
+ <td class="a-right">
72
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
73
+ <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
74
+ <?php else: ?>
75
+ <span class="cart-price">
76
+ <?php endif; ?>
77
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
78
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition())); ?>
79
+ <?php echo $this->__('a');?>
80
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition())); ?>
81
+ <?php else: ?>
82
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * $_item->getCalculationPrice()) ?>
83
+ <?php echo $this->__('a');?>
84
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * $_item->getCalculationPrice()) ?>
85
+ <?php endif; ?>
86
+
87
+ </span>
88
+
89
+
90
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
91
+
92
+ <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
93
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
94
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
95
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
96
+ <?php endforeach; ?>
97
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
98
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
99
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
100
+ <?php endforeach; ?>
101
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
102
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
103
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
104
+ <?php endforeach; ?>
105
+ <?php endif; ?>
106
+ </div>
107
+
108
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
109
+ <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
110
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
111
+ </div>
112
+ <?php endif; ?>
113
+ <?php endif; ?>
114
+ </td>
115
+ <?php endif; ?>
116
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
117
+ <td>
118
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
119
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
120
+ <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
121
+ <?php else: ?>
122
+ <span class="cart-price">
123
+ <?php endif; ?>
124
+
125
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
126
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_incl+$_item->getWeeeTaxAppliedAmount())); ?>
127
+ <?php echo $this->__('a');?>
128
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_incl+$_item->getWeeeTaxAppliedAmount())); ?>
129
+ <?php else: ?>
130
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_incl-$_item->getWeeeTaxDisposition())) ?>
131
+ <?php echo $this->__('a');?>
132
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_incl-$_item->getWeeeTaxDisposition())) ?>
133
+ <?php endif; ?>
134
+
135
+ </span>
136
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
137
+
138
+ <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
139
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
140
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
141
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
142
+ <?php endforeach; ?>
143
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
144
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
145
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
146
+ <?php endforeach; ?>
147
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
148
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
149
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
150
+ <?php endforeach; ?>
151
+ <?php endif; ?>
152
+ </div>
153
+
154
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
155
+ <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
156
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
157
+ </div>
158
+ <?php endif; ?>
159
+ <?php endif; ?>
160
+ </td>
161
+ <?php endif; ?>
162
+ <?php endif; ?>
163
+ <td class="a-center">
164
+ <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
165
+ </td>
166
+ <?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
167
+ <td class="a-right">
168
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
169
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
170
+ <?php else: ?>
171
+ <span class="cart-price">
172
+ <?php endif; ?>
173
+
174
+ <?php if ($canApplyMsrp): ?>
175
+ <span class="cart-msrp-subtotal">--</span>
176
+ <?php else: ?>
177
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
178
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?>
179
+ <?php echo $this->__('a');?>
180
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?>
181
+ <?php else: ?>
182
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * $_item->getRowTotal()) ?>
183
+ <?php echo $this->__('a');?>
184
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * $_item->getRowTotal()) ?>
185
+ <?php endif; ?>
186
+ <?php endif; ?>
187
+
188
+ </span>
189
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
190
+
191
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
192
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
193
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
194
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
195
+ <?php endforeach; ?>
196
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
197
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
198
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
199
+ <?php endforeach; ?>
200
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
201
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
202
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
203
+ <?php endforeach; ?>
204
+ <?php endif; ?>
205
+ </div>
206
+
207
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
208
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
209
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
210
+ </div>
211
+ <?php endif; ?>
212
+ <?php endif; ?>
213
+ </td>
214
+ <?php endif; ?>
215
+ <?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
216
+ <td>
217
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
218
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
219
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
220
+ <?php else: ?>
221
+ <span class="cart-price">
222
+ <?php endif; ?>
223
+
224
+ <?php if ($canApplyMsrp): ?>
225
+ <span class="cart-msrp-subtotal">--</span>
226
+ <?php else: ?>
227
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
228
+ <?php $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_incl+$_item->getWeeeTaxAppliedRowAmount())); ?>
229
+ -
230
+ <?php $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_incl+$_item->getWeeeTaxAppliedRowAmount())); ?>
231
+ <?php else: ?>
232
+ <?php $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_incl-$_item->getWeeeTaxRowDisposition())) ?>
233
+ -
234
+ <?php $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_incl-$_item->getWeeeTaxRowDisposition())) ?>
235
+ <?php endif; ?>
236
+ <?php endif; ?>
237
+
238
+ </span>
239
+
240
+
241
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
242
+
243
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
244
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
245
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
246
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
247
+ <?php endforeach; ?>
248
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
249
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
250
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
251
+ <?php endforeach; ?>
252
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
253
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
254
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
255
+ <?php endforeach; ?>
256
+ <?php endif; ?>
257
+ </div>
258
+
259
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
260
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
261
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
262
+ </div>
263
+ <?php endif; ?>
264
+ <?php endif; ?>
265
+ </td>
266
+ <?php endif; ?>
267
+ <td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
268
+ </tr>
app/design/frontend/base/default/template/prpayment/checkout/onepage/link.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php if ($this->isPossibleOnepageCheckout()):?>
2
+ <?php if (Mage::helper('core')->isModuleEnabled("Idev_OneStepCheckout")):?>
3
+ <button type="button" title="<?php echo $this->__('Compra y Juega') ?>" onclick="window.location='<?php echo Mage::getUrl("onestepcheckout");?>'" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Compra y Juega') ?></span></span></button>
4
+ <?php else:?>
5
+ <button type="button" title="<?php echo $this->__('Compra y Juega') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Compra y Juega') ?></span></span></button>
6
+ <?php endif?>
7
+ <?php endif?>
app/design/frontend/base/default/template/prpayment/checkout/onepage/payment.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
4
+ var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
5
+ var payment = new Payment('co-payment-form', '<?php echo $this->getUrl('checkout/onepage/savePayment') ?>');
6
+ var lastPrice;
7
+ //]]>
8
+ </script>
9
+ <form action="" id="co-payment-form">
10
+ <fieldset>
11
+ <?php echo $this->getChildHtml('methods') ?>
12
+ </fieldset>
13
+ </form>
14
+ <div class="payrandom-information">
15
+ <div class="payrandom-information-img">
16
+ <div class="payrandom-information-content">
17
+ <?php echo $this->__('Debes saber que para jugar con <strong>PayRandom</strong> primero debes demostrar que puedes pagar el precio que te toque, por eso se hará previamente una reserva del <strong>importe máximo</strong> de la compra a través de PayPal.');?>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
22
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
23
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
24
+ </div>
25
+ <div class="buttons-set" id="payment-buttons-container">
26
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
27
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
28
+ <button type="button" class="button" onclick="payment.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
29
+ <span class="please-wait" id="payment-please-wait" style="display:none;">
30
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
31
+ </span>
32
+ </div>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ function toggleToolTip(event){
36
+ if($('payment-tool-tip')){
37
+ $('payment-tool-tip').setStyle({
38
+ top: (Event.pointerY(event)-560)+'px'//,
39
+ //left: (Event.pointerX(event)+100)+'px'
40
+ })
41
+ $('payment-tool-tip').toggle();
42
+ }
43
+ Event.stop(event);
44
+ }
45
+ if($('payment-tool-tip-close')){
46
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
47
+ }
48
+ //]]>
49
+ </script>
50
+ <script type="text/javascript">
51
+ //<![CDATA[
52
+ payment.currentMethod = "<?php echo $this->getChild('methods')->getSelectedMethodCode() ?>";
53
+ //]]>
54
+ </script>
app/design/frontend/base/default/template/prpayment/checkout/onepage/review/button.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ $buttonText = $this->__('Place Order');
3
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
4
+ $buttonText = $this->__('Compra y Juega');
5
+ }
6
+ ?>
7
+ <button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="review.save();"><span><span><?php echo $buttonText ?></span></span></button>
app/design/frontend/base/default/template/prpayment/checkout/onepage/review/item.phtml ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_item = $this->getItem()?>
2
+ <tr>
3
+ <td><h3 class="product-name"><?php echo $this->htmlEscape($this->getProductName()) ?></h3>
4
+ <?php if ($_options = $this->getOptionList()):?>
5
+ <dl class="item-options">
6
+ <?php foreach ($_options as $_option) : ?>
7
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
8
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
9
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
10
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
11
+ <div class="truncated_full_value">
12
+ <dl class="item-options">
13
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
14
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
15
+ </dl>
16
+ </div>
17
+ <?php endif; ?>
18
+ </dd>
19
+ <?php endforeach; ?>
20
+ </dl>
21
+ <?php endif;?>
22
+ <?php if ($addtInfoBlock = $this->getProductAdditionalInformationBlock()):?>
23
+ <?php echo $addtInfoBlock->setItem($_item)->toHtml() ?>
24
+ <?php endif;?>
25
+ </td>
26
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
27
+ <td class="a-right">
28
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
29
+ <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
30
+ <?php else: ?>
31
+ <span class="cart-price">
32
+ <?php endif; ?>
33
+
34
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
35
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition())); ?>
36
+ <?php echo $this->__('a'); ?>
37
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition())); ?>
38
+ <?php else: ?>
39
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * $_item->getCalculationPrice()) ?>
40
+ <?php echo $this->__('a'); ?>
41
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * $_item->getCalculationPrice()) ?>
42
+ <?php endif; ?>
43
+
44
+ </span>
45
+
46
+
47
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
48
+
49
+ <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
50
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
51
+ <small>
52
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
53
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
54
+ <?php endforeach; ?>
55
+ </small>
56
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
57
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
58
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
59
+ <?php endforeach; ?>
60
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
61
+ <small>
62
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
63
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
64
+ <?php endforeach; ?>
65
+ </small>
66
+ <?php endif; ?>
67
+ </div>
68
+
69
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
70
+ <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
71
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
72
+ </div>
73
+ <?php endif; ?>
74
+ <?php endif; ?>
75
+ </td>
76
+ <?php endif; ?>
77
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
78
+ <td>
79
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
80
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
81
+ <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
82
+ <?php else: ?>
83
+ <span class="cart-price">
84
+ <?php endif; ?>
85
+
86
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
87
+ <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
88
+ <?php else: ?>
89
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
90
+ <?php endif; ?>
91
+
92
+ </span>
93
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
94
+
95
+ <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
96
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
97
+ <small>
98
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
99
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
100
+ <?php endforeach; ?>
101
+ </small>
102
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
103
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
104
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
105
+ <?php endforeach; ?>
106
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
107
+ <small>
108
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
109
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
110
+ <?php endforeach; ?>
111
+ </small>
112
+ <?php endif; ?>
113
+ </div>
114
+
115
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
116
+ <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
117
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
118
+ </div>
119
+ <?php endif; ?>
120
+ <?php endif; ?>
121
+ </td>
122
+ <?php endif; ?>
123
+ <td class="a-center"><?php echo $_item->getQty() ?></td>
124
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
125
+ <td class="a-right">
126
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
127
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
128
+ <?php else: ?>
129
+ <span class="cart-price">
130
+ <?php endif; ?>
131
+
132
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
133
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * ($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?>
134
+ <?php echo $this->__('a'); ?>
135
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * ($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?>
136
+ <?php else: ?>
137
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $this->getMaximumDiscount()) * $_item->getRowTotal()) ?>
138
+ <?php echo $this->__('a'); ?>
139
+ <?php echo $this->helper('checkout')->formatPrice((1 - $this->getMinimumDiscount()) * $_item->getRowTotal()) ?>
140
+ <?php endif; ?>
141
+
142
+ </span>
143
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
144
+
145
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
146
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
147
+ <small>
148
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
149
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span><br />
150
+ <?php endforeach; ?>
151
+ </small>
152
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
153
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
154
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
155
+ <?php endforeach; ?>
156
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
157
+ <small>
158
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
159
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
160
+ <?php endforeach; ?>
161
+ </small>
162
+ <?php endif; ?>
163
+ </div>
164
+
165
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
166
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
167
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
168
+ </div>
169
+ <?php endif; ?>
170
+ <?php endif; ?>
171
+ </td>
172
+ <?php endif; ?>
173
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
174
+ <td>
175
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
176
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
177
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
178
+ <?php else: ?>
179
+ <span class="cart-price">
180
+ <?php endif; ?>
181
+
182
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
183
+ <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
184
+ <?php else: ?>
185
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
186
+ <?php endif; ?>
187
+
188
+ </span>
189
+
190
+
191
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
192
+
193
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
194
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
195
+ <small>
196
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
197
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span><br />
198
+ <?php endforeach; ?>
199
+ </small>
200
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
201
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
202
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
203
+ <?php endforeach; ?>
204
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
205
+ <small>
206
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
207
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
208
+ <?php endforeach; ?>
209
+ </small>
210
+ <?php endif; ?>
211
+ </div>
212
+
213
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
214
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
215
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
216
+ </div>
217
+ <?php endif; ?>
218
+ <?php endif; ?>
219
+ </td>
220
+ <?php endif; ?>
221
+ </tr>
app/design/frontend/base/default/template/prpayment/checkout/onepage/shipping_method.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="payrandom-information">
2
+ <div class="payrandom-information-img">
3
+ <div class="payrandom-information-content">
4
+ <?php echo $this->__('Los precios <strong>PayRandom</strong> no incluyen los gastos de envío.');?>
5
+ </div>
6
+ </div>
7
+ </div>
8
+ <form id="co-shipping-method-form" action="">
9
+ <div id="checkout-shipping-method-load">
10
+ <?php echo $this->getChildHtml('available') ?>
11
+ </div>
12
+ <script type="text/javascript">
13
+ //<![CDATA[
14
+ var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
15
+ //]]>
16
+ </script>
17
+ <div id="onepage-checkout-shipping-method-additional-load">
18
+ <?php echo $this->getChildHtml('additional') ?>
19
+ </div>
20
+ <div class="buttons-set" id="shipping-method-buttons-container">
21
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
22
+ <button type="button" class="button" onclick="shippingMethod.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
23
+ <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
24
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
25
+ </span>
26
+ </div>
27
+ </form>
app/design/frontend/base/default/template/prpayment/form/prpayment.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <?php $cartDeal = PayRandom_PRPayment_Helper_Data::getCartDeal(); ?>
3
+ <?php if (!is_null($cartDeal->getFixedDiscount())): ?>
4
+
5
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
6
+ <li>
7
+ <label for="<?php echo $_code ?>_no_fixed_price" class="required"><em>*</em><?php echo $this->__('Ruleta');?></label>
8
+ <span class="input-box">
9
+ <input type="radio" id="<?php echo $_code ?>_no_fixed_price" name="payment[radio_fixed_price]" value="1" checked onclick="updatePrices();" />
10
+ </span>
11
+ </li>
12
+ <li>
13
+ <label for="<?php echo $_code ?>_fixed_price" class="required"><em>*</em><?php echo $this->__('Con precio fijo');?> <?php echo $this->helper('checkout')->formatPrice((1 - $cartDeal->getFixedDiscount()) * Mage::getSingleton('checkout/session')->getQuote()->getSubtotal()); ?> </label>
14
+ <span class="input-box">
15
+ <input type="radio" id="<?php echo $_code ?>_fixed_price" name="payment[radio_fixed_price]" value="2" onclick="updatePrices();" />
16
+ </span>
17
+ </li>
18
+ </ul>
19
+ <div>
20
+ <?php echo $this->getMethod()->getConfigData('message');?>
21
+ </div>
22
+ <?php else: ?>
23
+ <?php Mage::GetSingleton("core/session")->setFixedPrice(0); ?>
24
+ <?php endif ?>
25
+
26
+ <script type="text/javascript">
27
+ var updatePrices = function () {
28
+ if ($$('input:checked[name="payment[radio_fixed_price]"]')[0].value == "2") {
29
+ $$(".prpayment-fixed-price").each(Element.show);
30
+ $$(".prpayment-interval-price").each(Element.hide);
31
+ }
32
+ else {
33
+ $$(".prpayment-fixed-price").each(Element.hide);
34
+ $$(".prpayment-interval-price").each(Element.show);
35
+ }
36
+ };
37
+ </script>
app/design/frontend/base/default/template/prpayment/onestepcheckout/checkout.phtml ADDED
@@ -0,0 +1,1310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $step_counter = 1;
4
+ $helper = Mage::helper('onestepcheckout/checkout');
5
+
6
+ ?>
7
+ <?php if(!$this->canCheckout() || !$this->validateMinimumAmount()): ?>
8
+ <?php if($this->settings['checkout_title']): ?>
9
+ <h1 class="onestepcheckout-title"><?php echo $this->settings['checkout_title']; ?></h1>
10
+ <?php endif; ?>
11
+
12
+ <?php if($this->canCheckout() && !$this->validateMinimumAmount()): ?>
13
+ <p><?php echo Mage::getStoreConfig('sales/minimum_order/description'); ?></p>
14
+ <p><a href="<?php echo $this->getUrl(''); ?>"><?php echo $this->__('Back to homepage'); ?></a></p>
15
+ <?php else: ?>
16
+ <p><?php echo $this->__('You need to have products in your cart to checkout, and your cart is empty.'); ?></p>
17
+ <p><a href="<?php echo $this->getUrl(''); ?>"><?php echo $this->__('Back to homepage'); ?></a></p>
18
+ <?php endif; ?>
19
+ <?php else: ?>
20
+
21
+ <form id="onestepcheckout-form" method="post" action="<?php echo $this->getUrl('onestepcheckout', array('_secure'=>true)); ?>">
22
+ <fieldset class="group-select" style="margin: 0;">
23
+
24
+ <?php if($this->settings['checkout_title']): ?>
25
+ <h1 class="onestepcheckout-title"><?php echo $this->settings['checkout_title']; ?></h1>
26
+ <?php endif; ?>
27
+
28
+ <?php if($this->settings['checkout_description']): ?>
29
+ <p class="onestepcheckout-description"><?php echo $this->settings['checkout_description']; ?></p>
30
+ <?php endif; ?>
31
+
32
+ <?php if(!$this->isCustomerLoggedIn() && $helper->showLoginLink()): ?>
33
+ <p class="onestepcheckout-login-link">
34
+ <a id="onestepcheckout-login-link" href="javascript:void(0); return: false;"><?php echo $this->__('Already registered? Click here to login.'); ?></a>
35
+ </p>
36
+ <?php endif; ?>
37
+
38
+ <?php if(isset($this->formErrors['unknown_source_error'])): ?>
39
+ <div class="onestepcheckout-error">
40
+ <?php echo $this->formErrors['unknown_source_error']; ?>
41
+ </div>
42
+ <?php endif; ?>
43
+ <div class="onestepcheckout-threecolumns checkoutcontainer onestepcheckout-skin-<?php echo $this->settings['skin']; ?> <?php if(Mage::helper('onestepcheckout')->isEnterprise()): ?>onestepcheckout-enterprise<?php endif; ?>">
44
+ <div class="onestepcheckout-column-left">
45
+ <div id="billing_address">
46
+ <script type="text/javascript">
47
+ var billing = new Billing();
48
+
49
+ </script>
50
+ <ul>
51
+ <li>
52
+ <p class="onestepcheckout-numbers onestepcheckout-numbers-<?php echo $step_counter++; ?>"><?php echo $this->__('Billing address'); ?></p>
53
+ <?php if(isset($this->formErrors['billing_error']) && count($this->formErrors['billing_errors']) > 0): ?>
54
+ <div class="onestepcheckout-error">
55
+ <?php echo $this->__('Please check red fields below and try again.'); ?>
56
+ </div>
57
+ <?php endif; ?>
58
+ </li>
59
+ <?php if ($this->customerHasAddresses()): ?>
60
+ <li>
61
+ <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
62
+ <div class="input-box">
63
+ <?php echo $this->getAddressesHtmlSelect('billing') ?>
64
+ </div>
65
+ </li>
66
+ <?php endif; ?>
67
+ <li>
68
+ <div>
69
+ <ul id="billing_address_list" <?php echo (($this->customerHasAddresses() && !$this->getNewAddressSelectValueOnError('billing')) ? 'style = "display:none"' : false ); ?>>
70
+ <?php echo $this->getChildHtml('billing_address');?>
71
+ <?php $addressAttributes = $this->getChild('customer_form_billing_address_user_defined_attributes');?>
72
+ <?php if ($addressAttributes): ?>
73
+ <?php $addressAttributes->setEntity($this->getQuote()->getBillingAddress())->setEntityType('customer_address');?>
74
+ <?php $addressAttributes->setFieldIdFormat('billing:%1$s')->setFieldNameFormat('billing[%1$s]');?>
75
+ <?php echo $addressAttributes->setExcludeFileAttributes(true)->setShowContainer(false)->toHtml()?>
76
+ <?php endif;?>
77
+ <?php $customerAttributes = $this->getChild('customer_form_customer_user_defined_attributes');?>
78
+ <?php if ($customerAttributes): ?>
79
+ <?php $customerAttributes->setEntityModelClass('customer/customer')->setFieldIdFormat('billing:%1$s');?>
80
+ <?php $customerAttributes->setFieldNameFormat('billing[%1$s]')->setShowContainer(false);?>
81
+ <?php echo $customerAttributes->setExcludeFileAttributes(true)->toHtml()?>
82
+ <?php endif;?>
83
+ </ul>
84
+ </div>
85
+ </li>
86
+ <li>
87
+ <?php $uncheck = (!empty($_POST['billing']) && empty($_POST['billing']['use_for_shipping']));?>
88
+ <?php if($this->differentShippingAvailable()): ?>
89
+ <div class="input-box input-different-shipping">
90
+ <input type="checkbox" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" <?php echo (($this->sameAsBilling() && !$uncheck) ? 'checked="checked" ':'')?>/>
91
+ <label for="billing:use_for_shipping_yes"><?php echo $this->__('Ship to the same address')?></label>
92
+ </div>
93
+ <?php else: ?>
94
+ <input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" />
95
+ <?php endif; ?>
96
+ </li>
97
+ </ul>
98
+ </div>
99
+ <?php if($this->differentShippingAvailable()): ?>
100
+ <div id="shipping_address" <?php echo (($this->sameAsBilling() && !$uncheck) ? 'style="display: none"': false);?>>
101
+ <script type="text/javascript">
102
+ var shipping = new Shipping();
103
+ </script>
104
+ <ul>
105
+ <li class="shipping-address-title">
106
+ <?php echo $this->__('Shipping address'); ?>
107
+ </li>
108
+ <?php if ($this->customerHasAddresses()): ?>
109
+ <li class="form-alt">
110
+ <label for="shipping-address-select"><?php echo $this->__('Select a shipping address from your address book or enter a new address.') ?></label>
111
+ <div class="input-box"><?php echo $this->getAddressesHtmlSelect('shipping') ?></div>
112
+ </li>
113
+ <?php endif ?>
114
+ <li id="shipping_address_list" <?php if($this->customerHasAddresses() && !$this->getNewAddressSelectValueOnError('shipping')) { echo ' style="display: none;" '; } ?>>
115
+ <div id="">
116
+ <ul>
117
+ <?php echo $this->getChildHtml('shipping_address');?>
118
+ <?php $addressAttributes = $this->getChild('customer_form_shipping_address_user_defined_attributes');?>
119
+ <?php if ($addressAttributes): ?>
120
+ <?php $addressAttributes->setEntity($this->getQuote()->getShippingAddress())->setEntityType('customer_address');?>
121
+ <?php $addressAttributes->setFieldIdFormat('shipping:%1$s')->setFieldNameFormat('shipping[%1$s]');?>
122
+ <?php echo $addressAttributes->setExcludeFileAttributes(true)->setShowContainer(false)->toHtml()?>
123
+ <?php endif;?>
124
+ </ul>
125
+ <input type="hidden" name="shipping[address_id]" value="<?php echo $this->getQuote()->getShippingAddress()->getId() ?>" id="shipping:address_id" />
126
+ <!-- END LIST OF SHIPPIING FIELDS -->
127
+ </div>
128
+ </li>
129
+ </ul>
130
+ </div>
131
+ <?php endif; ?>
132
+ </div>
133
+
134
+ <div class="onestepcheckout-column-middle">
135
+
136
+
137
+ <?php if(!$this->isVirtual()): ?>
138
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/hide_shipping_method')):?>
139
+ <?php if(isset($this->formErrors['shipping_method']) && $this->formErrors['shipping_method']): ?>
140
+ <div class="onestepcheckout-error onestepcheckout-shipment-method-error">
141
+ <?php echo $this->__('Please choose a shipping method.'); ?>
142
+ </div>
143
+ <?php endif; ?>
144
+ <?php echo $this->getChildHtml('choose-shipping-method'); ?>
145
+ <?php else:?>
146
+ <div class="onestepcheckout-shipping-method">
147
+ <p class="onestepcheckout-numbers onestepcheckout-numbers-<?php echo $step_counter++; ?>"><?php echo $this->__('Shipping method'); ?></p>
148
+
149
+ <?php if(isset($this->formErrors['shipping_method']) && $this->formErrors['shipping_method']): ?>
150
+ <div class="onestepcheckout-error onestepcheckout-shipment-method-error">
151
+ <?php echo $this->__('Please choose a shipping method.'); ?>
152
+ </div>
153
+ <?php endif; ?>
154
+
155
+ <div class="onestepcheckout-shipping-method-block">
156
+ <?php echo $this->getChildHtml('choose-shipping-method'); ?>
157
+ </div>
158
+ <?php if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){ ?>
159
+ <div class="payrandom-information">
160
+ <div class="payrandom-information-img">
161
+ <div class="payrandom-information-content">
162
+ <?php echo $this->__('Los precios <strong>PayRandom</strong> no incluyen los gastos de envío.');?>
163
+ </div>
164
+ </div>
165
+ </div>
166
+ <?php } ?>
167
+ </div>
168
+ <?php endif; ?>
169
+ <?php endif; ?>
170
+
171
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/hide_payment_method')):?>
172
+ <?php if(!empty($this->formErrors['payment_method'])): ?>
173
+ <div class="onestepcheckout-error onestepcheckout-payment-method-error">
174
+ <?php echo $this->__('Please choose a payment method.'); ?>
175
+ </div>
176
+ <?php endif; ?>
177
+ <?php if(!empty($this->formErrors['payment_method_error'])): ?>
178
+ <div class="onestepcheckout-error onestepcheckout-payment-method-error">
179
+ <?php echo $this->__('Please enter valid details below.'); ?>
180
+ </div>
181
+ <?php endif; ?>
182
+ <?php echo $this->getChildHtml('choose-payment-method'); ?>
183
+ <?php else: ?>
184
+ <p class="onestepcheckout-numbers onestepcheckout-numbers-<?php echo $step_counter++; ?>"><?php echo $this->__('Payment method'); ?></p>
185
+ <?php if(isset($this->formErrors['payment_method']) && $this->formErrors['payment_method']): ?>
186
+ <div class="onestepcheckout-error onestepcheckout-payment-method-error">
187
+ <?php echo $this->__('Please choose a payment method.'); ?>
188
+ </div>
189
+ <?php else: ?>
190
+ <?php if(isset($this->formErrors['payment_method_error'])): ?>
191
+ <div class="onestepcheckout-error onestepcheckout-payment-method-error">
192
+ <?php echo $this->__('Please enter valid details below.'); ?>
193
+ </div>
194
+ <?php endif; ?>
195
+ <?php endif; ?>
196
+
197
+ <?php echo $this->getChildHtml('choose-payment-method'); ?>
198
+
199
+ <?php if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){ ?>
200
+ <div class="payrandom-information">
201
+ <div class="payrandom-information-img">
202
+ <div class="payrandom-information-content">
203
+ <?php echo $this->__('Debes saber que para jugar con <strong>PayRandom</strong> primero debes demostrar que puedes pagar el precio que te toque, por eso se hará previamente una reserva del <strong>importe máximo</strong> de la compra a través de PayPal.');?>
204
+ </div>
205
+ </div>
206
+ </div>
207
+ <?php } ?>
208
+
209
+
210
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
211
+ <div class="btn-close">
212
+ <a href="javascript:void(0);" id="payment-tool-tip-close"><img src="<?php echo $this->getSkinUrl('images/btn_window_close.gif') ?>" alt="<?php echo $this->__('Close') ?>" /></a>
213
+ </div>
214
+ <div class="block-content">
215
+ <img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" />
216
+ </div>
217
+ </div>
218
+ <?php endif; ?>
219
+ </div>
220
+
221
+ <div class="onestepcheckout-column-right">
222
+
223
+ <p class="onestepcheckout-numbers onestepcheckout-numbers-4"><?php echo $this->__('Review your order'); ?></p>
224
+
225
+ <div class="onestepcheckout-summary">
226
+ <?php echo $this->getChildHtml('summary'); ?>
227
+ </div>
228
+
229
+ <?php if($this->settings['enable_discount']): ?>
230
+ <div class="onestepcheckout-coupons">
231
+ <div id="coupon-notice" style="display: none;"></div>
232
+ <?php $_couponcode = $this->getQuote()->getCouponCode(); ?>
233
+ <label for="id_couponcode"><?php echo $this->__('Coupon code:'); ?></label><br/>
234
+ <input class="input-text" type="text" name="onestepcheckout-couponcode" id="id_couponcode" value="<?php echo Mage::helper('core')->escapeHtml($_couponcode); ?>" />
235
+ <br/>
236
+ <button id="onestepcheckout-coupon-add" class="form-button-alt button" type="button"><span><span><?php echo $this->__('Apply Coupon'); ?></span></span></button>
237
+ <button id="onestepcheckout-coupon-remove" class="form-button-alt button" type="button" style="<?php if($_couponcode == '') { echo 'display: none;'; } ?>"><span><span><?php echo $this->__('Cancel Coupon'); ?></span></span></button>
238
+ <script>
239
+ Event.observe(window, 'load', function() {
240
+ $('onestepcheckout-coupon-add').observe('click', function(e) {
241
+
242
+ var coupon = $('id_couponcode').getValue();
243
+ var couponNotice = $('coupon-notice');
244
+
245
+ couponNotice.hide();
246
+
247
+ if(coupon == '') {
248
+ alert('<?php echo $this->__('Please enter a valid coupon code.'); ?>');
249
+ return;
250
+ }
251
+
252
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/add_coupon', array('_secure'=>true)); ?>';
253
+ var parameters = {code: coupon};
254
+ var shipping_methods = $$('dl.shipment-methods').first();
255
+ var payment_methods = $$('div.payment-methods').first();
256
+ var summary = $$('div.onestepcheckout-summary').first();
257
+
258
+ if(shipping_methods){
259
+ shipping_methods.update('<div class="loading-ajax">&nbsp;</div>');
260
+ }
261
+
262
+ if(payment_methods){
263
+ payment_methods.update('<div class="loading-ajax">&nbsp;</div>');
264
+ }
265
+
266
+ summary.update('<div class="loading-ajax">&nbsp;</div>');
267
+
268
+ new Ajax.Request(url, {
269
+ method: 'post',
270
+ parameters: parameters,
271
+ onSuccess: function(transport) {
272
+ if(transport.status == 200) {
273
+
274
+ var response = transport.responseText.evalJSON();
275
+
276
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
277
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
278
+
279
+ if(shipping_methods){
280
+ shipping_methods.hide();
281
+ shipping_methods.update(response.shipping_method);
282
+ shipping_methods.show();
283
+ $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
284
+ $$('dl.shipment-methods input').invoke('observe', 'click', function() {
285
+ $$('div.onestepcheckout-shipment-method-error').each(function(item) {
286
+ new Effect.Fade(item);
287
+ });
288
+ });
289
+ }
290
+
291
+ if(payment_methods){
292
+ payment_methods.hide();
293
+ payment_methods.replace(response.payment_method);
294
+ payment_methods.show();
295
+
296
+ paymentContainer = $('container_payment_method_' + payment.currentMethod)
297
+ paymentForm = $('payment_form_' + payment.currentMethod)
298
+
299
+ if(paymentContainer != null){
300
+ paymentContainer.show();
301
+ }
302
+ if(paymentForm != null){
303
+ paymentForm.show();
304
+ }
305
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', get_separate_save_methods_function(url));
306
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', function() {
307
+ $$('div.onestepcheckout-payment-method-error').each(function(item) {
308
+ new Effect.Fade(item);
309
+ });
310
+ });
311
+ }
312
+
313
+ summary.hide();
314
+ summary.update(response.summary);
315
+ summary.show();
316
+
317
+ if(response.success) {
318
+
319
+ couponNotice.update(response.message);
320
+ couponNotice.removeClassName('error-msg');
321
+ couponNotice.addClassName('success-msg');
322
+ couponNotice.show();
323
+ /* Show remove button */
324
+ $('onestepcheckout-coupon-remove').show();
325
+ }
326
+ else {
327
+
328
+ couponNotice.update(response.message);
329
+ couponNotice.removeClassName('success-msg');
330
+ couponNotice.addClassName('error-msg');
331
+ couponNotice.show();
332
+ /* Hide remove button */
333
+ $('onestepcheckout-coupon-remove').hide();
334
+ }
335
+ }
336
+ }
337
+ });
338
+ });
339
+
340
+ $('onestepcheckout-coupon-remove').observe('click', function(e) {
341
+
342
+ var coupon = $('id_couponcode').getValue();
343
+ var couponNotice = $('coupon-notice');
344
+
345
+ couponNotice.hide();
346
+
347
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/add_coupon', array('_secure'=>true)); ?>';
348
+ var parameters = {code: coupon, remove: '1'};
349
+ var shipping_methods = $$('dl.shipment-methods').first();
350
+ var payment_methods = $$('div.payment-methods').first();
351
+ var summary = $$('div.onestepcheckout-summary').first();
352
+
353
+ if(shipping_methods){
354
+ shipping_methods.update('<div class="loading-ajax">&nbsp;</div>');
355
+ }
356
+
357
+ if(payment_methods){
358
+ payment_methods.update('<div class="loading-ajax">&nbsp;</div>');
359
+ }
360
+ summary.update('<div class="loading-ajax">&nbsp;</div>');
361
+
362
+ new Ajax.Request(url, {
363
+ method: 'post',
364
+ parameters: parameters,
365
+ onSuccess: function(transport) {
366
+ if(transport.status == 200) {
367
+ var response = transport.responseText.evalJSON();
368
+
369
+ if(response.success){
370
+ $('id_couponcode').setValue('')
371
+ $('onestepcheckout-coupon-remove').hide();
372
+ }
373
+
374
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
375
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
376
+
377
+ if(shipping_methods){
378
+ shipping_methods.hide();
379
+ shipping_methods.update(response.shipping_method);
380
+ shipping_methods.show();
381
+ $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
382
+ $$('dl.shipment-methods input').invoke('observe', 'click', function() {
383
+ $$('div.onestepcheckout-shipment-method-error').each(function(item) {
384
+ new Effect.Fade(item);
385
+ });
386
+ });
387
+ }
388
+
389
+ if(payment_methods){
390
+ payment_methods.hide();
391
+ payment_methods.replace(response.payment_method);
392
+ payment_methods.show();
393
+
394
+ paymentContainer = $('container_payment_method_' + payment.currentMethod)
395
+ paymentForm = $('payment_form_' + payment.currentMethod)
396
+
397
+ if(paymentContainer != null){
398
+ paymentContainer.show();
399
+ }
400
+
401
+ if(paymentForm != null){
402
+ paymentForm.show();
403
+ }
404
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', get_separate_save_methods_function(url));
405
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', function() {
406
+ $$('div.onestepcheckout-payment-method-error').each(function(item) {
407
+ new Effect.Fade(item);
408
+ });
409
+ });
410
+ }
411
+
412
+ summary.hide();
413
+ summary.update(response.summary);
414
+ summary.show();
415
+
416
+ couponNotice.hide();
417
+ couponNotice.update(response.message);
418
+ couponNotice.removeClassName('error-msg');
419
+ couponNotice.addClassName('success-msg');
420
+ couponNotice.show();
421
+ }
422
+ }
423
+ });
424
+ });
425
+ });
426
+ </script>
427
+ </div>
428
+ <?php endif; ?>
429
+
430
+ <?php if($this->settings['enable_giftcard']): ?>
431
+ <div class="onestepcheckout-giftcards">
432
+ <div id="giftcard-notice" style="display: none;"></div>
433
+ <?php
434
+ $_hasGiftCards = unserialize($this->getQuote()->getGiftCards());
435
+ $_giftcardcode = $this->getQuote()->getgiftcardCode(); ?>
436
+ <label for="id_giftcardcode"><?php echo $this->__('giftcard code:'); ?></label><br/>
437
+ <input class="input-text" type="text" name="onestepcheckout-giftcardcode" id="id_giftcardcode" value="<?php echo Mage::helper('core')->escapeHtml($_giftcardcode); ?>" />
438
+ <br/>
439
+ <button id="onestepcheckout-giftcard-add" class="form-button-alt button" type="button"><span><span><?php echo $this->__('Apply gift card'); ?></span></span></button>
440
+ <button id="onestepcheckout-giftcard-remove" class="form-button-alt button" type="button" style="<?php if(empty($_hasGiftCards)) { echo 'display: none;'; } ?>"><span><span><?php echo $this->__('Cancel gift card'); ?></span></span></button>
441
+ <script>
442
+ document.observe('dom:loaded', function() {
443
+ $('onestepcheckout-giftcard-add').observe('click', function(e) {
444
+ var giftcard = $('id_giftcardcode').getValue();
445
+ var giftcardNotice = $('giftcard-notice');
446
+ giftcardNotice.hide();
447
+ if(giftcard == '') {
448
+ alert('<?php echo $this->__('Please enter a valid giftcard code.'); ?>');
449
+ return;
450
+ }
451
+
452
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/add_giftcard', array('_secure'=>true)); ?>';
453
+ var parameters = {code: giftcard};
454
+ var shipping_methods = $$('dl.shipment-methods').first();
455
+ var payment_methods = $$('div.payment-methods').first();
456
+ var summary = $$('div.onestepcheckout-summary').first();
457
+
458
+ if(shipping_methods){
459
+ shipping_methods.update('<div class="loading-ajax">&nbsp;</div>');
460
+ }
461
+
462
+ if(payment_methods){
463
+ payment_methods.update('<div class="loading-ajax">&nbsp;</div>');
464
+ }
465
+ summary.update('<div class="loading-ajax">&nbsp;</div>');
466
+
467
+ new Ajax.Request(url+Math.random(1000), {
468
+ method: 'post',
469
+ parameters: parameters,
470
+ onSuccess: function(transport) {
471
+ if(transport.status == 200) {
472
+
473
+ var response = transport.responseText.evalJSON();
474
+
475
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
476
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
477
+
478
+ if(shipping_methods){
479
+ shipping_methods.hide();
480
+ shipping_methods.update(response.shipping_method);
481
+ shipping_methods.show();
482
+ $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
483
+ $$('dl.shipment-methods input').invoke('observe', 'click', function() {
484
+ $$('div.onestepcheckout-shipment-method-error').each(function(item) {
485
+ new Effect.Fade(item);
486
+ });
487
+ });
488
+ }
489
+
490
+ if(payment_methods){
491
+ //payment_methods.hide();
492
+ payment_methods.replace(response.payment_method);
493
+ //payment_methods.show();
494
+
495
+ paymentContainer = $('container_payment_method_' + payment.currentMethod)
496
+ paymentForm = $('payment_form_' + payment.currentMethod)
497
+
498
+ if(paymentContainer != null){
499
+ paymentContainer.show();
500
+ }
501
+ if(paymentForm != null){
502
+ paymentForm.show();
503
+ }
504
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', get_separate_save_methods_function(url));
505
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', function() {
506
+ $$('div.onestepcheckout-payment-method-error').each(function(item) {
507
+ new Effect.Fade(item);
508
+ });
509
+ });
510
+ }
511
+
512
+ if(response.success) {
513
+ summary.update(response.summary);
514
+ giftcardNotice.update(response.message);
515
+ giftcardNotice.removeClassName('error-msg');
516
+ giftcardNotice.addClassName('success-msg');
517
+ giftcardNotice.show();
518
+ /* Show remove button */
519
+ $('onestepcheckout-giftcard-remove').show();
520
+ }
521
+ else {
522
+ summary.update(response.summary);
523
+ giftcardNotice.update(response.message);
524
+ giftcardNotice.removeClassName('success-msg');
525
+ giftcardNotice.addClassName('error-msg');
526
+ giftcardNotice.show();
527
+ /* Hide remove button */
528
+ //$('onestepcheckout-giftcard-remove').hide();
529
+ }
530
+ }
531
+ }
532
+ });
533
+ });
534
+
535
+ $('onestepcheckout-giftcard-remove').observe('click', function(e) {
536
+ var giftcard = $('id_giftcardcode').getValue();
537
+ var giftcardNotice = $('giftcard-notice');
538
+ giftcardNotice.hide();
539
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/add_giftcard', array('_secure'=>true)); ?>';
540
+ var parameters = {code: giftcard, remove: '1'};
541
+ var shipping_methods = $$('dl.shipment-methods').first();
542
+ var payment_methods = $$('div.payment-methods').first();
543
+ var summary = $$('div.onestepcheckout-summary').first();
544
+
545
+ if(shipping_methods){
546
+ shipping_methods.update('<div class="loading-ajax">&nbsp;</div>');
547
+ }
548
+
549
+ if(payment_methods){
550
+ payment_methods.update('<div class="loading-ajax">&nbsp;</div>');
551
+ }
552
+ summary.update('<div class="loading-ajax">&nbsp;</div>');
553
+
554
+ new Ajax.Request(url, {
555
+ method: 'post',
556
+ parameters: parameters,
557
+ onSuccess: function(transport) {
558
+ if(transport.status == 200) {
559
+ var response = transport.responseText.evalJSON();
560
+
561
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
562
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
563
+
564
+ if(shipping_methods){
565
+ shipping_methods.hide();
566
+ shipping_methods.update(response.shipping_method);
567
+ shipping_methods.show();
568
+ $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
569
+ $$('dl.shipment-methods input').invoke('observe', 'click', function() {
570
+ $$('div.onestepcheckout-shipment-method-error').each(function(item) {
571
+ new Effect.Fade(item);
572
+ });
573
+ });
574
+ }
575
+
576
+ if(payment_methods){
577
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', get_separate_save_methods_function(url));
578
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', function() {
579
+ $$('div.onestepcheckout-payment-method-error').each(function(item) {
580
+ new Effect.Fade(item);
581
+ });
582
+ });
583
+ payment_methods.hide();
584
+ payment_methods.replace(response.payment_method);
585
+ payment_methods.show();
586
+
587
+ paymentContainer = $('container_payment_method_' + payment.currentMethod)
588
+ paymentForm = $('payment_form_' + payment.currentMethod)
589
+
590
+ if(paymentContainer != null){
591
+ paymentContainer.show();
592
+ }
593
+ if(paymentForm != null){
594
+ paymentForm.show();
595
+ }
596
+ }
597
+
598
+ if(response.success){
599
+ $('id_giftcardcode').setValue('')
600
+ $('onestepcheckout-giftcard-remove').hide();
601
+ }
602
+ var summary = $$('div.onestepcheckout-summary').first();
603
+
604
+ summary.hide();
605
+ summary.update(response.summary);
606
+ summary.show();
607
+
608
+ giftcardNotice.hide();
609
+ giftcardNotice.update(response.message);
610
+ giftcardNotice.removeClassName('error-msg');
611
+ giftcardNotice.addClassName('success-msg');
612
+ giftcardNotice.show();
613
+ }
614
+ }
615
+ });
616
+ });
617
+ });
618
+ </script>
619
+ </div>
620
+ <?php endif; ?>
621
+
622
+ <?php if($this->settings['enable_comments']): ?>
623
+ <div class="onestepcheckout-comments">
624
+ <label for="id_comments"><?php echo $this->__('Comments'); ?></label><br/>
625
+ <textarea id="id_comments" name="onestepcheckout_comments"><?php if(isset($_POST['onestepcheckout_comments'])) { echo Mage::helper('core')->escapeHtml($_POST['onestepcheckout_comments']); } ?></textarea>
626
+ </div>
627
+ <?php endif; ?>
628
+
629
+ <?php if($this->settings['enable_gift_messages']): ?>
630
+ <div id="onestepcheckout-giftmessages">
631
+ <div class="onestepcheckout-giftmessagecontainer">
632
+ <?php echo $this->helper('onestepcheckout/message')->getInline('onepage_checkout', $this->getQuote(), $this->getDontDisplayContainer()) ?>
633
+ </div>
634
+ </div>
635
+ <?php endif; ?>
636
+
637
+ <?php $customerEmail = (($this->isCustomerLoggedIn())) ? $this->getQuote()->getCustomer()->getEmail() : false ;?>
638
+ <?php if($this->settings['enable_newsletter'] && !$this->isSubScribed($customerEmail)): ?>
639
+ <div class="onestepcheckout-enable-newsletter">
640
+ <input type="checkbox" id="id_subscribe_newsletter" name="subscribe_newsletter" value="1" <?php if($this->settings['newsletter_default_checked']): ?>checked="checked"<?php endif; ?> />
641
+ <label for="id_subscribe_newsletter"><?php echo $this->__('Subscribe to our newsletter'); ?></label>
642
+ </div>
643
+ <?php endif; ?>
644
+
645
+ <?php $_extraProductsHelper = Mage::helper('onestepcheckout/extraproducts'); ?>
646
+ <?php if($_extraProductsHelper->hasExtraProducts()): ?>
647
+ <div class="onestepcheckout-extraproducts">
648
+ <ul>
649
+ <?php foreach($_extraProductsHelper->getExtraProducts() as $product): ?>
650
+ <li><input type="checkbox" class="onestepcheckout-extra-product"
651
+ <?php if($_extraProductsHelper->productInCart($product->getId())): ?>
652
+ checked="checked" <?php endif; ?>
653
+ name="extra_products_<?php echo $product->getId(); ?>"
654
+ id="id_extra_product_<?php echo $product->getId(); ?>" /> &nbsp;
655
+ <label for="id_extra_product_<?php echo $product->getId(); ?>"> <?php echo $product->getName(); ?>
656
+ <span><?php echo Mage::helper('checkout')->formatPrice($product->getPrice()); ?></span>
657
+ </label></li>
658
+ <?php endforeach; ?>
659
+ </ul>
660
+ </div>
661
+
662
+ <script>
663
+ Event.observe(window, 'load', function() {
664
+ $$('input.onestepcheckout-extra-product').invoke('observe', 'click', function(e) {
665
+ var id_temp = e.element().id.split('id_extra_product_');
666
+ if(id_temp.length == 2) {
667
+ var product_id = id_temp[1];
668
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/add_extra_product'); ?>';
669
+ var parameters = {
670
+ product_id: product_id
671
+ }
672
+
673
+ if(!e.element().checked) {
674
+ parameters['remove'] = 1;
675
+ }
676
+
677
+ var summary = $$('div.onestepcheckout-summary').first();
678
+ summary.update('<div class="loading-ajax">&nbsp;</div>');
679
+
680
+ new Ajax.Request(url, {
681
+ method: 'post',
682
+ parameters: parameters,
683
+ onSuccess: function(transport) {
684
+ summary.update(transport.responseText);
685
+ }
686
+ });
687
+ };
688
+ });
689
+ });
690
+ </script>
691
+ <?php endif; ?>
692
+
693
+ <?php
694
+ /**
695
+ * Feedbackdropdown start
696
+ */
697
+ ?>
698
+ <?php if(!empty($this->settings['feedback']['enable_feedback']) && !empty($this->settings['feedback']['feedback_values'])):?>
699
+ <?php
700
+ $selectedFeedBackFields = $this->getRequest()->getPost('onestepcheckout-feedback', false);
701
+ $feedbackValues = unserialize($this->settings['feedback']['feedback_values']);
702
+ ?>
703
+ <div class="onestepcheckout-feedback" id="">
704
+ <label for="id_feedback"><?php echo $this->__('How did you hear about us?'); ?></label><br>
705
+ <select style="" name="onestepcheckout-feedback" id="id_feedback" defaultvalue="">
706
+ <option value=""><?php echo $this->__('Please choose'); ?></option>
707
+ <?php foreach($feedbackValues as $value => $label):
708
+ $selected= (!empty($selectedFeedBackFields) && $selectedFeedBackFields == $value) ? ' selected' : '';
709
+ ?>
710
+ <option value="<?php echo $value?>" <?php echo $selected;?>><?php echo $label['value']?></option>
711
+ <?php endforeach;?>
712
+ <?php if(!empty($this->settings['feedback']['enable_feedback_freetext'])):
713
+ $selected= (empty($feedbackValues[$selectedFeedBackFields]) && $selectedFeedBackFields != '') ? ' selected' : '';
714
+ ?>
715
+ <option value="freetext" <?php echo $selected;?>><?php echo $this->__('Other'); ?></option>
716
+ <?php endif;?>
717
+ </select>
718
+ </div>
719
+ <?php if(!empty($this->settings['feedback']['enable_feedback_freetext'])):?>
720
+ <script type="text/javascript">
721
+ $('id_feedback').observe('change', function (event){
722
+ if(this.getValue() == 'freetext'){
723
+ $('id_feedback_freetext_div').show();
724
+ } else {
725
+ $('id_feedback_freetext_div').hide();
726
+ }
727
+ });
728
+ </script>
729
+ <div id='id_feedback_freetext_div' class="onestepcheckout-feedback-freetext"<?php echo ((!empty($selectedFeedBackFields) && $selectedFeedBackFields == 'freetext') ? '' : ' style="display: none;"'); ?>>
730
+ <label for="id_feedback_freetext"><?php echo $this->__('Please specify:'); ?></label><br/>
731
+ <textarea id="id_feedback_freetext" name="onestepcheckout-feedback-freetext"><?php echo Mage::helper('core')->escapeHtml($this->getRequest()->getPost('onestepcheckout-feedback-freetext', false));?></textarea>
732
+ </div>
733
+ <?php endif; ?>
734
+ <?php endif; ?>
735
+ <?php
736
+ /**
737
+ * Feedbackdropdown end
738
+ */
739
+ ?>
740
+
741
+ <?php if($this->settings['enable_terms']): //deprecated?>
742
+ <div class="onestepcheckout-enable-terms">
743
+ <?php
744
+
745
+ if(isset($this->formErrors['terms_error']) && $this->formErrors['terms_error']) {
746
+ $terms_error = true;
747
+ }
748
+ else {
749
+ if($_SERVER['REQUEST_METHOD'] == 'POST') {
750
+ $terms_error = false;
751
+ }
752
+ else {
753
+ $terms_error = true;
754
+ }
755
+ }
756
+ ?>
757
+
758
+ <input class="required-entry" type="checkbox" id="id_accept_terms" name="accept_terms" value="1" <?php if(!$terms_error) echo "checked=\"checked\""; ?> />
759
+ <label for="id_accept_terms"><?php echo $this->__('I accept the <a id="onestepcheckout-toc-link" target="_blank" href="javascript:void(0);">Terms and Conditions</a>'); ?></label>
760
+
761
+ <?php if(isset($this->formErrors['terms_error']) && $this->formErrors['terms_error']): ?>
762
+ <div class="onestepcheckout-error onestepcheckout-terms-error">
763
+ <?php echo $this->__('You must accept our terms to continue.'); ?>
764
+ </div>
765
+ <?php endif; ?>
766
+
767
+ </div>
768
+ <?php endif; ?>
769
+
770
+ <?php
771
+ /**
772
+ * Default magento agreements
773
+ */
774
+ ?>
775
+ <?php if($this->settings['enable_default_terms']): ?>
776
+ <?php if(!empty($this->formErrors['agreements_error'])):?>
777
+ <div class="onestepcheckout-error onestepcheckout-terms-error">
778
+ <?php echo $this->__('Please agree to all the terms and conditions before placing the order.'); ?>
779
+ </div>
780
+ <?php endif;?>
781
+ <?php echo $this->getChildHtml('agreements') ?>
782
+ <script type="text/javascript">
783
+
784
+ var termsmodals = new Object;
785
+
786
+ document.observe('dom:loaded', function() {
787
+ $$('.checkout-agreements li p input').each(
788
+ function(elem){
789
+ elem.addClassName('required-entry');
790
+ }
791
+ );
792
+ });
793
+
794
+ <?php if($this->settings['enable_textarea']):?>
795
+ document.observe('dom:loaded', function() {
796
+ $$('.checkout-agreements li p label').each(
797
+ function(elem){
798
+ elem.up().insert('<a href="javascript:void(0);" onclick="termsmodals[\'' + elem.htmlFor + '\'].open();">' + elem.innerHTML + '</a>');
799
+ elem.hide();
800
+ }
801
+ );
802
+ $$('div.agreement-content').each(
803
+ function(element){
804
+ element.id = 'agreement-div-' + element.up('li').down('input').id;
805
+ $$('body')[0].insert(element);
806
+ }
807
+ );
808
+ $$('.checkout-agreements li p input').each(
809
+ function(elem){
810
+ window.termsmodals[elem.id] = new Control.Modal($('agreement-div-' + elem.id),{
811
+ overlayOpacity: 0.75,
812
+ className: 'oscmodal',
813
+ fade: true,
814
+ closeOnClick: true,
815
+ height: 400,
816
+ width: 700
817
+ });
818
+ }
819
+ );
820
+ });
821
+ <?php endif;?>
822
+
823
+ </script>
824
+ <?php endif;?>
825
+ <?php
826
+ /**
827
+ * Default magento agreements end
828
+ */
829
+ ?>
830
+
831
+ <div class="onestepcheckout-place-order-wrapper">
832
+ <?php if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){ ?>
833
+ <div class="prpayment-interval-price">
834
+ <button type="button" title="<?php echo $this->__('Compra y Juega'); ?>" id="onestepcheckout-place-order" class="large orange onestepcheckout-button onestepcheckout-place-order" onclick="javascript:void(0);"><span><span><?php echo $this->__('Compra y Juega'); ?></span></span></button>
835
+ </div>
836
+ <div class="prpayment-fixed-price" style="display:none;">
837
+ <button type="button" title="<?php echo $this->__('Place order now'); ?>" id="onestepcheckout-place-order" class="large orange onestepcheckout-button onestepcheckout-place-order" onclick="javascript:void(0);"><span><span><?php echo $this->__('Place order now'); ?></span></span></button>
838
+ </div>
839
+ <?php } else { ?>
840
+ <button type="button" title="<?php echo $this->__('Place order now'); ?>" id="onestepcheckout-place-order" class="large orange onestepcheckout-button onestepcheckout-place-order" onclick="javascript:void(0);"><span><span><?php echo $this->__('Place order now'); ?></span></span></button>
841
+ <?php } ?>
842
+ </div>
843
+ </div>
844
+ <div style="clear: both;">&nbsp;</div>
845
+ </div>
846
+ </fieldset>
847
+ </form>
848
+
849
+ <?php if(!$this->isCustomerLoggedIn() && $helper->showLoginLink()): ?>
850
+ <?php echo $this->getChildHtml('login-popup'); ?>
851
+ <?php endif; ?>
852
+
853
+ <?php if($helper->isValidateEmail()): ?>
854
+ <script>
855
+ $('billing:email').observe('blur', function(e) {
856
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/check_email', array('_secure'=>true)); ?>';
857
+ var email = e.element().getValue();
858
+ var parameters = { email: email };
859
+
860
+ new Ajax.Request(url, {
861
+ parameters: parameters,
862
+ onComplete: function(response) {
863
+ if(response.status == 200) {
864
+ var result = response.responseText.evalJSON().result;
865
+ if(result == 'invalid') {
866
+ $('onestepcheckout-email-error-message').update('<?php echo $this->__('Invalid email address.'); ?>');
867
+ $('onestepcheckout-email-error').show();
868
+ }
869
+ else if(result == 'exists') {
870
+ <?php if($this->settings['registration_order_without_password']): ?>
871
+ // Remove the password fields if the email exists in database
872
+ $('onestepcheckout-li-password').hide();
873
+ <?php endif; ?>
874
+ $('onestepcheckout-email-error-message').update('<?php echo $this->__('Email address already registered. Please <a href="javascript:void(0);" onclick="login_popup.show(); return false;">login now</a> or use a different email address.'); ?>');
875
+ $('onestepcheckout-email-error').show();
876
+ $('id_onestepcheckout_username').value = email;
877
+ }
878
+ else {
879
+ $('onestepcheckout-email-error').hide();
880
+ $('onestepcheckout-li-password').show();
881
+ }
882
+ }
883
+ }
884
+ })
885
+
886
+ });
887
+ Validation.add('validate-email', '<?php echo $this->__('This is a required field.') ?>', function(v) {
888
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/check_email', array('_secure'=>true)); ?>';
889
+ var email = v;
890
+ var parameters = { email: email };
891
+ var value = Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v)
892
+
893
+ new Ajax.Request(url, {
894
+ parameters: parameters,
895
+ asynchronous: false,
896
+ onComplete: function(response) {
897
+ if(response.status == 200) {
898
+ var result = response.responseText.evalJSON().result;
899
+ if(result == 'invalid') {
900
+ value = false;
901
+ } else if(result == 'exists') {
902
+ <?php if($this->settings['registration_order_without_password']): ?>
903
+ $('onestepcheckout-li-password').hide();
904
+ <?php endif; ?>
905
+ $('onestepcheckout-email-error-message').update('<?php echo $this->__('Email address already registered. Please <a href="javascript:void(0);" onclick="login_popup.show(); return false;">login now</a> or use a different email address.'); ?>');
906
+ $('onestepcheckout-email-error').show();
907
+ $('id_onestepcheckout_username').value = email;
908
+ value = false;
909
+ }
910
+ }
911
+ }
912
+ })
913
+ return value;
914
+ });
915
+ </script>
916
+ <?php endif; ?>
917
+
918
+ <?php if($this->settings['enable_terms']): ?>
919
+ <div id="onestepcheckout-toc-popup" style="display: none;">
920
+
921
+ <div class="onestepcheckout-popup-wrapper">
922
+ <div class="onestepcheckout-popup-wrapper-inner">
923
+ <h1><?php echo $this->settings['terms_title']; ?></h1>
924
+
925
+ <div class="onestepcheckout-toc-terms">
926
+ <?php echo $this->settings['terms_contents']; ?>
927
+ </div>
928
+
929
+ <p class="close"><a href="javascript:void(0);"><?php echo $this->__('Close'); ?></a></p>
930
+ </div>
931
+ </div>
932
+ <div class="onestepcheckout-popup-footer">&nbsp;</div>
933
+ </div>
934
+ <script>
935
+ Event.observe(window, 'load', function() {
936
+
937
+ var termsPopup = new Control.Modal($('onestepcheckout-toc-popup'), {
938
+ overlayOpacity: 0.65,
939
+ fade: true,
940
+ fadeDuration: 0.3
941
+ });
942
+
943
+ $('onestepcheckout-toc-link').observe('click', function(e) {
944
+ e.preventDefault();
945
+ termsPopup.open();
946
+ });
947
+
948
+ $$('div#onestepcheckout-toc-popup p.close a').invoke('observe', 'click', function(e) {
949
+ e.preventDefault();
950
+ termsPopup.close();
951
+ });
952
+
953
+ });
954
+
955
+ /*
956
+ var popup;
957
+ Event.observe(window, 'load', function() {
958
+ popup = new OneStepCheckout_Popup('onestepcheckout-toc-popup','onestepcheckout-toc-link', 'div#onestepcheckout-toc-popup p.close a');
959
+ });
960
+ */
961
+ </script>
962
+ <?php endif; ?>
963
+
964
+
965
+
966
+
967
+
968
+ <script>
969
+ <?php if($this->hasFormErrors()): ?>
970
+ if($$('div.input-error').length > 0) {
971
+ var input = $$('div.input-error')[0].select('input');
972
+ if(input.length == 1) {
973
+ input[0].focus();
974
+ }
975
+ }
976
+ <?php endif; ?>
977
+ </script>
978
+
979
+ <?php if(!$this->settings['exclude_region']): ?>
980
+ <script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?></script>
981
+ <script type="text/javascript">
982
+ //<![CDATA[
983
+ var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', countryRegions, undefined, 'billing:postcode');
984
+
985
+ <?php if($this->settings['enable_different_shipping'] && !$this->isVirtual()): ?>
986
+ var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', countryRegions, undefined, 'shipping:postcode');
987
+ <?php endif; ?>
988
+ //]]>
989
+ </script>
990
+ <?php endif; ?>
991
+
992
+
993
+ <script type="text/javascript">
994
+
995
+ Event.observe(window, 'load', function() {
996
+ if ($$('div.shopping-cart-totals').length == 1) {
997
+ }
998
+ else {
999
+
1000
+ already_placing_order = false;
1001
+ review = false;
1002
+ reviewmodal = false;
1003
+
1004
+ /* Handle place order click event */
1005
+ $$('.onestepcheckout-place-order').each(function(elem){
1006
+ elem.observe('click', function(e) {
1007
+ Event.stop(e);
1008
+
1009
+ // First validate the form
1010
+ var form = new VarienForm('onestepcheckout-form');
1011
+
1012
+ if(!form.validator.validate()) {
1013
+ Event.stop(e);
1014
+ } else {
1015
+
1016
+ if(!already_placing_order && $$('.loading-ajax').length <= 0 ) {
1017
+ <?php if(!empty($helper->settings['addressreview']['enable_addressreview'])):?>
1018
+ var addressTemplates = {
1019
+ shipping: '<?php echo str_replace("\r", '', str_replace("\n", '', $helper->settings['addressreview']['shipping_template']));?>',
1020
+ billing: '<?php echo str_replace("\r", '', str_replace("\n", '', $helper->settings['addressreview']['billing_template']));?>'
1021
+ };
1022
+ addressPreview(addressTemplates, 'addressreview');
1023
+ if(!review){
1024
+ review = true;
1025
+ if(!reviewmodal){
1026
+ reviewmodal = new Control.Modal($('addressreview'),{
1027
+ overlayOpacity: 0.75,
1028
+ className: 'oscmodal',
1029
+ fade: true,
1030
+ closeOnClick: false
1031
+ });
1032
+ }
1033
+ reviewmodal.open();
1034
+ reviewmodal.observe('beforeClose',function(){
1035
+ review = false;
1036
+ });
1037
+ return true;
1038
+ Event.stop(e);
1039
+ } else {
1040
+ reviewmodal.close();
1041
+ }
1042
+ <?php endif;?>
1043
+ already_placing_order = true;
1044
+
1045
+ var submitelement = $('onestepcheckout-place-order');
1046
+
1047
+ var loaderelement = new Element('div').
1048
+ addClassName('onestepcheckout-place-order-loading').
1049
+ update('<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif'); ?>" />&nbsp;&nbsp;<?php echo $this->__('Please wait, processing your order...'); ?>');
1050
+
1051
+ submitelement.parentNode.appendChild(loaderelement);
1052
+
1053
+ /* Disable button to avoid multiple clicks */
1054
+ submitelement.removeClassName('orange').addClassName('grey');
1055
+ submitelement.disabled = true;
1056
+
1057
+ /* Submit the form */
1058
+ $('onestepcheckout-form').submit();
1059
+ }
1060
+ }
1061
+ });
1062
+ });
1063
+
1064
+
1065
+ // This is a separate page
1066
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
1067
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
1068
+
1069
+ $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
1070
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', get_separate_save_methods_function(url));
1071
+
1072
+ $$('div.payment-methods input[name="payment\[method\]"]').invoke('observe', 'click', function() {
1073
+ $$('div.onestepcheckout-payment-method-error').each(function(item) {
1074
+ new Effect.Fade(item);
1075
+ });
1076
+ });
1077
+
1078
+ $$('dl.shipment-methods input').invoke('observe', 'click', function() {
1079
+ $$('div.onestepcheckout-shipment-method-error').each(function(item) {
1080
+ new Effect.Fade(item);
1081
+ });
1082
+ });
1083
+
1084
+ var has_hidden_terms = false;
1085
+
1086
+ if($('id_accept_terms') != null) {
1087
+
1088
+ $('id_accept_terms').observe('click', function(e) {
1089
+ var element = e.element();
1090
+
1091
+ if(element.checked) {
1092
+ $$('div.onestepcheckout-terms-error').each(function(item) {
1093
+ new Effect.Fade(item);
1094
+ has_hidden_terms = true;
1095
+ });
1096
+ }
1097
+ else {
1098
+ if(has_hidden_terms) {
1099
+ $$('div.onestepcheckout-terms-error').each(function(item) {
1100
+ new Effect.Appear(item);
1101
+ has_hidden_terms = false;
1102
+ });
1103
+ }
1104
+ }
1105
+ });
1106
+ }
1107
+ }
1108
+
1109
+ var form = $('onestepcheckout-form');
1110
+
1111
+ /* Highlight selected payment method if one set */
1112
+ if($RF(form, 'payment[method]') != null) {
1113
+ try {
1114
+ var payment_method = $RF(form, 'payment[method]');
1115
+ $('container_payment_method_' + payment_method).show();
1116
+ $('payment_form_' + payment_method).show();
1117
+ } catch(err) {
1118
+
1119
+ }
1120
+ }
1121
+
1122
+ /* Set default shipping method if not set */
1123
+ if($RF(form, 'shipping_method') == null) {
1124
+ try {
1125
+ var method = '<?php echo $this->_getDefaultShippingMethod(); ?>';
1126
+ if(method != '') {
1127
+ $('s_method_' + method).checked = true;
1128
+ get_separate_save_methods_function(url);
1129
+ }
1130
+ } catch(err) {
1131
+
1132
+ }
1133
+ }
1134
+ //submit what's available on load
1135
+ get_separate_save_methods_function(url)();
1136
+
1137
+ <?php if($this->differentShippingAvailable()): ?>
1138
+ $('billing:use_for_shipping_yes').observe('click', function(e) {
1139
+ var element = e.element();
1140
+ if(element.checked){
1141
+ $('shipping_address').hide();
1142
+ } else {
1143
+ if($('shipping-address-select') && $('shipping-address-select').value == ''){
1144
+ $('shipping_address_list').show()
1145
+ }
1146
+ $('shipping_address').show();
1147
+ <?php if(!$this->isCustomerLoggedIn()):?>
1148
+ $('shipping_address_list').show()
1149
+ <?php endif;?>
1150
+ <?php if($this->isCustomerLoggedIn()):?>
1151
+ if(!$('shipping-address-select') && $('shipping_address_list').getStyle('display')=='none'){
1152
+ $('shipping_address_list').show()
1153
+ }
1154
+ <?php endif;?>
1155
+ }
1156
+
1157
+ <?php if($this->settings['enable_ajax_save_billing']): ?>
1158
+ get_save_billing_function('<?php echo $this->getUrl('onestepcheckout/ajax/save_billing', array('_secure'=>true)); ?>', '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>', <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>, true)();
1159
+ <?php endif; ?>
1160
+
1161
+ });
1162
+ <?php endif; ?>
1163
+ <?php
1164
+ $triggers = Mage::getStoreConfig('onestepcheckout/ajax_update/ajax_save_billing_fields');
1165
+ if(!empty($triggers)){
1166
+ $triggers = str_replace('country', 'country_id', $triggers);
1167
+ $triggers = str_replace('state/region', 'region_id', $triggers);
1168
+ $triggers = explode(',',$triggers);
1169
+ if(in_array('region_id',$triggers)){
1170
+ $triggers[] = 'region';
1171
+ }
1172
+ }
1173
+ ?>
1174
+
1175
+ <?php if(Mage::getStoreConfig('onestepcheckout/ajax_update/enable_ajax_save_billing') && !empty($triggers)):?>
1176
+
1177
+ var url_save_billing = '<?php echo $this->getUrl('onestepcheckout/ajax/save_billing', array('_secure'=>true)); ?>';
1178
+ var url_set_methods = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)); ?>';
1179
+ var update_payments = <?php echo $this->settings['enable_update_payment_on_shipping'] ? 'true' : 'false'; ?>;
1180
+ var update_on_initial = false;
1181
+
1182
+ var euvat = $('euvat_action_validate_taxvat');
1183
+
1184
+ if(euvat !== null){
1185
+ euvat.observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments, true));
1186
+ }
1187
+
1188
+ var euvatid = $('billing:vat_id');
1189
+
1190
+ if(euvatid !== null){
1191
+ euvatid.observe('click', get_save_billing_function(url_save_billing, url_set_methods, update_payments, true));
1192
+ }
1193
+
1194
+ triggers = ['<?php echo implode ('\',\'',$triggers)?>'];
1195
+ btriggered = [];
1196
+ striggered = [];
1197
+
1198
+ <?php
1199
+ foreach($triggers as $value){
1200
+ echo (($this->getQuote()->getBillingAddress()->getData($value)) ? 'btriggered.push(\'billing:'.$value.'\');' : '');
1201
+ echo (($this->getQuote()->getShippingAddress()->getData($value)) ? 'striggered.push(\'shipping:'.$value.'\');' : '');
1202
+ }
1203
+ ?>
1204
+
1205
+
1206
+ bcountry_id = $('billing:country_id');
1207
+ if(bcountry_id){
1208
+ if(bcountry_id.getValue()){
1209
+ if(!btriggered.include('billing:country_id')){
1210
+ btriggered.push('billing:country_id');
1211
+ }
1212
+ }
1213
+ }
1214
+ scountry_id = $('shipping:country_id');
1215
+ if(scountry_id){
1216
+ if(scountry_id.getValue()){
1217
+ if(!striggered.include('shipping:country_id')){
1218
+ striggered.push('shipping:country_id');
1219
+ }
1220
+ }
1221
+ }
1222
+
1223
+ batriggered = false;
1224
+ satriggered = false;
1225
+
1226
+ changeTimer = false;
1227
+ changeInterval = 1000;
1228
+
1229
+ triggers.each(function(item){
1230
+ var belement = $('billing:'+item);
1231
+ if(belement){
1232
+ belement.observe('change', function(e){
1233
+ var element = e.element();
1234
+ var id = element.id;
1235
+ var tagname = element.tagName;
1236
+ if(tagname === 'SELECT'){
1237
+ clearTimeout(changeTimer);
1238
+ changeTimer = setTimeout(bcallbackEvent, changeInterval, id);
1239
+ } else {
1240
+ bcallbackEvent(id);
1241
+ }
1242
+ });
1243
+ }
1244
+
1245
+ var selement = $('shipping:'+item);
1246
+ if(selement){
1247
+ selement.observe('change', function(e){
1248
+ var element = e.element();
1249
+ var id = element.id;
1250
+ var tagname = element.tagName;
1251
+ if(tagname === 'SELECT'){
1252
+ clearTimeout(changeTimer);
1253
+ changeTimer = setTimeout(scallbackEvent, changeInterval, id);
1254
+ } else {
1255
+ scallbackEvent(id);
1256
+ }
1257
+ });
1258
+ }
1259
+ });
1260
+
1261
+ function scallbackEvent (id){
1262
+ if(!striggered.include(id)){
1263
+ striggered.push(id);
1264
+ }
1265
+ if(striggered.length >= triggers.length-1){
1266
+ satriggered = true;
1267
+ }
1268
+ get_save_billing_function(url_save_billing, url_set_methods, update_payments, satriggered)();
1269
+ }
1270
+
1271
+
1272
+ function bcallbackEvent (id){
1273
+ if(!btriggered.include(id)){
1274
+ btriggered.push(id);
1275
+ }
1276
+ if(btriggered.length >= triggers.length-1){
1277
+ batriggered = true;
1278
+ }
1279
+ get_save_billing_function(url_save_billing, url_set_methods, update_payments, batriggered)();
1280
+ }
1281
+
1282
+
1283
+ <?php if($this->isCustomerLoggedIn()):?>
1284
+ var bselect = $('billing-address-select');
1285
+ var sselect = $('shipping-address-select');
1286
+ if(bselect){
1287
+ bselect.observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments, true));
1288
+ }
1289
+ if(sselect){
1290
+ sselect.observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments, true));
1291
+ }
1292
+ <?php endif;?>
1293
+
1294
+ <?php endif; ?>
1295
+
1296
+ });
1297
+
1298
+ if($('payment-tool-tip-close')){
1299
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
1300
+ }
1301
+
1302
+ </script>
1303
+
1304
+
1305
+ <?php endif; ?>
1306
+
1307
+ <div id="onestepcheckout_popup_overlay" style="display: none;">&nbsp;</div>
1308
+
1309
+
1310
+ <div id="loading-process" style="display: none;"></div>
app/design/frontend/base/default/template/prpayment/onestepcheckout/summary.phtml ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_coreHelper = $this->helper('core');
3
+ $checkoutHelper = Mage::helper('onestepcheckout/checkout');
4
+ $minimumDiscount = false;
5
+ $maximumDiscount = false;
6
+ $fixedDiscount = false;
7
+
8
+ if(PayRandom_PRPayment_Helper_Data::checkCartCanApplyOffer()){
9
+ $item = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
10
+ $item = $item[0];
11
+ $productId = $item->getProduct()->getId();//getProductId();
12
+
13
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($productId);
14
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
15
+
16
+ $minimumDiscount = $deal->getMinimumDiscount();
17
+ $maximumDiscount = $deal->getMaximumDiscount();
18
+ $fixedDiscount = $deal->getFixedDiscount();
19
+ }
20
+ ?>
21
+
22
+ <table class="onestepcheckout-summary">
23
+ <thead>
24
+ <tr>
25
+ <th class="name"><?php echo $this->__('Product'); ?></th>
26
+ <th class="qty"><?php echo $this->__('Qty'); ?></th>
27
+ <th class="total"><?php echo $this->__('Subtotal'); ?></th>
28
+ </tr>
29
+ </thead>
30
+ <?php foreach($this->getItems() as $item): ?>
31
+ <tr>
32
+ <td class="name">
33
+ <?php echo $item->getName(); ?>
34
+ <?php if($checkoutHelper->settings['show_custom_options']): ?>
35
+ <?php $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()); ?>
36
+ <?php if(isset($options['options']) && count($options['options']) > 0): ?>
37
+ <ul class="onestepcheckout-custom-options">
38
+ <?php foreach($options['options'] as $option): ?>
39
+ <li><b><?php echo $option['label'] . ':</b> ' . $option['value']; ?></li>
40
+ <?php endforeach; ?>
41
+ </ul>
42
+ <?php endif; ?>
43
+
44
+ <?php if($item->getProduct()->isConfigurable()): ?>
45
+
46
+ <?php
47
+ $configurable_options = $item->getProduct()->getTypeInstance(true)->getSelectedAttributesInfo($item->getProduct());
48
+ ?>
49
+
50
+ <?php if(is_array($configurable_options) && count($configurable_options) > 0): ?>
51
+ <ul class="onestepcheckout-custom-options">
52
+ <?php foreach($configurable_options as $option): ?>
53
+ <li><b><?php echo $option['label']; ?>:</b> <?php echo $option['value']; ?></li>
54
+ <?php endforeach; ?>
55
+ </ul>
56
+ <?php endif; ?>
57
+
58
+ <?php endif; ?>
59
+
60
+ <?php endif; ?>
61
+ </td>
62
+ <td class="qty"><?php echo $item->getQty(); ?></td>
63
+ <td class="total">
64
+ <?php if($checkoutHelper->settings['display_tax_included']): ?>
65
+ <?php if($minimumDiscount || $maximumDiscount) { ?>
66
+ <span class="prpayment-interval-price">
67
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $maximumDiscount) * $this->helper('checkout')->getSubtotalInclTax($item)) . ' ' . $this->__('a') . ' ' .
68
+ $this->helper('checkout')->formatPrice((1 - $minimumDiscount) * $this->helper('checkout')->getSubtotalInclTax($item)); ?>
69
+ </span>
70
+ <span class="prpayment-fixed-price" style="display:none;">
71
+ <?php
72
+ echo $this->helper('checkout')->formatPrice((1 - $fixedDiscount) * $this->helper('checkout')->getSubtotalInclTax($item));
73
+ ?>
74
+ </span>
75
+ <?php } else { ?>
76
+ <?php echo $this->helper('checkout')->formatPrice($this->helper('checkout')->getSubtotalInclTax($item)); ?>
77
+ <?php } ?>
78
+ <?php else: ?>
79
+ <?php if($minimumDiscount || $maximumDiscount) { ?>
80
+ <span class="prpayment-interval-price">
81
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $maximumDiscount) * $this->helper('checkout')->getRowTotal()) . ' ' . $this->__('a') . ' ' .
82
+ $this->helper('checkout')->formatPrice((1 - $minimumDiscount) * $this->helper('checkout')->getRowTotal()); ?>
83
+ </span>
84
+ <span class="prpayment-fixed-price" style="display:none;">
85
+ <?php echo $this->helper('checkout')->formatPrice((1 - $fixedDiscount) * $this->helper('checkout')->getRowTotal()); ?>
86
+ </span>
87
+ <?php }else{ ?>
88
+ <?php echo $this->helper('checkout')->formatPrice($item->getRowTotal()); ?>
89
+ <?php } ?>
90
+ <?php endif; ?>
91
+ </td>
92
+ </tr>
93
+ <?php endforeach; ?>
94
+ </table>
95
+ <?php
96
+ $ShippingValue = 0;
97
+ $SubtotalValue = 0;
98
+ ?>
99
+ <table class="onestepcheckout-totals">
100
+ <?php foreach($this->getTotals() as $total): ?>
101
+ <?php if(!$total->getTitle()){continue;}?>
102
+ <?php
103
+ $fullInfo = $total->getFullInfo();
104
+
105
+ if(!empty($fullInfo) && $checkoutHelper->settings['display_full_tax']):
106
+ foreach ($fullInfo as $info):
107
+ $rates = current($info['rates']);
108
+ $amount = $info['amount'];
109
+ ?>
110
+ <tr>
111
+ <td class="title"><?php echo $rates['title'] ?> (<?php echo $rates['percent'] ?>%)</td><td class="value"><?php echo $this->helper('checkout')->formatPrice($amount); ?></td>
112
+ </tr>
113
+ <?php endforeach;
114
+ endif;?>
115
+ <tr<?php if($total->getCode() == 'grand_total'): ?> class="grand-total"<?php endif; ?>>
116
+ <td class="title">
117
+ <?php
118
+
119
+ $code = $total->getCode();
120
+ $value = $total->getValue();
121
+
122
+ if($code == 'subtotal') {
123
+ $total_name = $this->__('Subtotal');
124
+ $SubtotalValue = $value;
125
+ }
126
+ elseif($code == 'shipping') {
127
+ $total_name = $this->__('Shipping');
128
+ if($checkoutHelper->settings['display_tax_included']) {
129
+ $value += $this->getQuote()->getShippingAddress()->getShippingTaxAmount();
130
+ }
131
+ $ShippingValue = $value;
132
+ }
133
+ elseif($code == 'grand_total') {
134
+ $total_name = $this->__('Grand total');
135
+ }
136
+ else {
137
+ $total_name = $total->getTitle();
138
+ }
139
+
140
+ echo $total_name;
141
+
142
+ ?>
143
+ </td>
144
+ <td class="value">
145
+ <?php if(($minimumDiscount || $maximumDiscount) && ($code != 'shipping')) { ?>
146
+ <?php if($code == 'grand_total'){ ?>
147
+ <span class="prpayment-interval-price">
148
+ <?php
149
+ echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $maximumDiscount) * $SubtotalValue + $ShippingValue) . ' ' . $this->__('a') . ' ' .
150
+ $this->helper('checkout')->formatPrice((1 - $minimumDiscount) * $SubtotalValue + $ShippingValue);
151
+ ?>
152
+ </span>
153
+ <span class="prpayment-fixed-price" style="display:none;">
154
+ <?php echo $this->helper('checkout')->formatPrice((1 - $fixedDiscount) * $SubtotalValue + $ShippingValue); ?>
155
+ </span>
156
+ <?php } else{ ?>
157
+ <span class="prpayment-interval-price">
158
+ <?php
159
+ echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $maximumDiscount) * $value) . ' ' . $this->__('a') . ' ' .
160
+ $this->helper('checkout')->formatPrice((1 - $minimumDiscount) * $value);
161
+ ?>
162
+ </span>
163
+ <span class="prpayment-fixed-price" style="display:none;">
164
+ <?php echo $this->helper('checkout')->formatPrice((1 - $fixedDiscount) * $value); ?>
165
+ </span>
166
+ <?php } ?>
167
+
168
+ <?php }else{ ?>
169
+ <?php echo $this->helper('checkout')->formatPrice($value); ?>
170
+ <?php } ?>
171
+ </td>
172
+ </tr>
173
+ <?php endforeach; ?>
174
+ </table>
175
+ <script type="text/javascript">
176
+ //<![CDATA[
177
+ var total = <?php echo $this->getGrandTotal();?>;
178
+ if(payment.reloadcallback){
179
+ var url = '<?php echo $this->getUrl('onestepcheckout/ajax/paymentrefresh', array('_secure'=>true)); ?>';
180
+ paymentrefresh(url);
181
+ payment.countreload = 0;
182
+ payment.reloadcallback = false;
183
+ }
184
+ //]]>
185
+ </script>
app/design/frontend/base/default/template/prpayment/price.phtml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_coreHelper = $this->helper('core');
3
+ $_weeeHelper = $this->helper('weee');
4
+ $_taxHelper = $this->helper('tax');
5
+ /* @var $_coreHelper Mage_Core_Helper_Data */
6
+ /* @var $_weeeHelper Mage_Weee_Helper_Data */
7
+ /* @var $_taxHelper Mage_Tax_Helper_Data */
8
+
9
+ $_product = $this->getProduct();
10
+ $_storeId = $_product->getStoreId();
11
+ $_id = $_product->getId();
12
+ $_weeeSeparator = '';
13
+ $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
14
+ $_minimalPriceValue = $_product->getMinimalPrice();
15
+ $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
16
+ ?>
17
+ <?php $_price = $_taxHelper->getPrice($_product, $_product->getPrice()) ?>
18
+ <?php $_regularPrice = $_taxHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?>
19
+ <p class="old-price">
20
+ <span class="price-label"><?php echo $this->__('Regular Price:') ?></span>
21
+ <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
22
+ <?php echo $_coreHelper->currency($_regularPrice, true, false) ?>
23
+ </span>
24
+ </p>
25
+ <p class="payrandom-price">
26
+ <span class="payrandom-price-label"><?php echo $this->__('Precio PayRandom') ?></span>
27
+ <a href="#" class="payrandom-price-element" id="payrandom-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>" onclick="prPaymentOpenHelp(<?php echo $_id ?>); return false;">
28
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/help.png');?>" alt="PayRandom" />
29
+ </a>
30
+ </p>
31
+ <?php
32
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($_id);
33
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
34
+
35
+ $_fromPrice = (1 - $deal->getMaximumDiscount()) * $_price;
36
+ $_toPrice = (1 - $deal->getMinimumDiscount()) * $_price;
37
+ $_discounts = json_decode($deal->getDiscounts(), true);
38
+
39
+ if($_fromPrice == 0){
40
+ $_fromPriceText = Mage::helper('prpayment')->__('Free');
41
+ }else{
42
+ $_fromPriceText = $this->helper('checkout')->formatPrice($_fromPrice);
43
+ }
44
+
45
+ if($_toPrice == 0){
46
+ $_toPriceText = Mage::helper('prpayment')->__('Free');
47
+ }else{
48
+ $_toPriceText = $this->helper('checkout')->formatPrice($_toPrice);
49
+ }
50
+ ?>
51
+ <p class="payrandom-price-from-to">
52
+ <span class="payrandom-price-from-to-label"><?php echo $this->__('From') ?></span>
53
+ <span class="payrandom-price-from-to-element" id="payrandom-price-from-to-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
54
+ <?php echo $_fromPriceText; ?>
55
+ </span>
56
+ <br/>
57
+ <span class="payrandom-price-from-to-label"><?php echo $this->__('to') ?></span>
58
+ <span class="payrandom-price-from-to-element" id="payrandom-price-from-to-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
59
+ <?php echo $_toPriceText; ?>
60
+ </span>
61
+ </p>
62
+ <div id="payrandom-modalbox-info-<?php echo $_id ?>" class="payrandom-modalbox" style="display:none;">
63
+ <div class="payrandom-modalbox-header">
64
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/logo_pr_white_small.png');?>" alt="PayRandom" />
65
+ <a href="#" onclick="prPaymentCloseHelp(<?php echo $_id;?>); return false;" id="payrandom-modalbox-close" class="payrandom-modalbox-close"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/close.png');?>" alt="close" /></a>
66
+ </div>
67
+ <div class="payrandom-modalbox-content">
68
+ <div id="payrandom-maincontent-<?php echo $_id;?>" class="payrandom-modalbox-content-maincontent">
69
+ <div class="payrandom-modalbox-content-divimg">
70
+ <img src="<?php echo PayRandom_PRPayment_Helper_Data_Api::getRouletteImg($_discounts, $_price, $this->__('Free'), 250, 250);?>" alt="Roulette" />
71
+ </div>
72
+
73
+ <h2 class="payrandom-modalbox-h2"><?php echo $this->__('Compra y juega con PayRandom') ?></h2>
74
+ <p><?php echo $this->__('¡Consigue este producto por uno de los precios que vés en la ruleta!') ?></p>
75
+ <p><span class="payrandom-modalbox-howitworks"><?php echo $this->__('Cómo funciona') ?>:</span></p>
76
+ <a href="#" onclick="$('payrandom-maincontent-<?php echo $_id;?>').hide();$('payrandom-video-<?php echo $_id;?>').show(); return false;" target="_blank"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/video.png');?>" alt="help" /></a>
77
+ </div>
78
+ <div id="payrandom-video-<?php echo $_id;?>" class="payrandom-modalbox-content-video" style="display: none;">
79
+ <iframe id="how-it-works" src="//player.vimeo.com/video/91405153" width="465" height="260" frameborder="0" allowfullscreen></iframe>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ <script type="text/javascript">
84
+ document.observe('dom:loaded', function() {
85
+ $("payrandom-modalbox-close").on("click", function (e) {
86
+ $('how-it-works').setAttribute('src','');
87
+ $('how-it-works').setAttribute('src','//player.vimeo.com/video/91405153');
88
+ });
89
+ });
90
+ </script>
app/design/frontend/base/default/template/prpayment/price_full.phtml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_coreHelper = $this->helper('core');
3
+ $_weeeHelper = $this->helper('weee');
4
+ $_taxHelper = $this->helper('tax');
5
+ /* @var $_coreHelper Mage_Core_Helper_Data */
6
+ /* @var $_weeeHelper Mage_Weee_Helper_Data */
7
+ /* @var $_taxHelper Mage_Tax_Helper_Data */
8
+
9
+ $_product = $this->getProduct();
10
+ $_storeId = $_product->getStoreId();
11
+ $_id = $_product->getId();
12
+ $_weeeSeparator = '';
13
+ $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
14
+ $_minimalPriceValue = $_product->getMinimalPrice();
15
+ $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
16
+ ?>
17
+ <?php $_price = $_taxHelper->getPrice($_product, $_product->getPrice()) ?>
18
+ <?php $_regularPrice = $_taxHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?>
19
+ <?php
20
+ $dealProduct = Mage::getModel('prpayment/dealproduct')->loadByProductId($_id);
21
+ $deal = Mage::getModel('prpayment/deal')->load($dealProduct->getDealId());
22
+
23
+ $_fromPrice = (1 - $deal->getMaximumDiscount()) * $_price;
24
+ $_toPrice = (1 - $deal->getMinimumDiscount()) * $_price;
25
+ $_discounts = json_decode($deal->getDiscounts(), true);
26
+
27
+ if($_fromPrice == 0){
28
+ $_fromPriceText = Mage::helper('prpayment')->__('Free');
29
+ }else{
30
+ $_fromPriceText = $this->helper('checkout')->formatPrice($_fromPrice);
31
+ }
32
+
33
+ if($_toPrice == 0){
34
+ $_toPriceText = Mage::helper('prpayment')->__('Free');
35
+ }else{
36
+ $_toPriceText = $this->helper('checkout')->formatPrice($_toPrice);
37
+ }
38
+ ?>
39
+ <p class="old-price">
40
+ <span class="price-label"><?php echo $this->__('Regular Price:') ?></span>
41
+ <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
42
+ <?php echo $_coreHelper->currency($_regularPrice, true, false) ?>
43
+ </span>
44
+ </p>
45
+ <div class="payrandom-price-full">
46
+ <div class="payrandom-price-full-left">
47
+ <p class="payrandom-price-full-left-header"><?php echo $this->__('Ruleta de precios');?></p>
48
+ <p class="payrandom-price-full-left-logo"><img width="120" src="<?php echo $this->getSkinUrl('images/prpayment/logo_pr_150.png');?>" alt="PayRandom" /></p>
49
+ <p class="payrandom-price-full-left-header"><?php echo $this->__('PRECIO MÍNIMO:');?></p>
50
+ <p class="payrandom-price-full-left-price"><?php echo $_fromPriceText;?></p>
51
+ <p>
52
+ <a href="#" class="payrandom-price-full-left-element" id="payrandom-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>" onclick="prPaymentOpenHelp(<?php echo $_id ?>); return false;">
53
+ <span class="payrandom-price-full-left-howitworks"><?php echo $this->__('Cómo funciona') ?></span>
54
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/help.png');?>" alt="PayRandom" />
55
+ </a>
56
+ </p>
57
+ </div>
58
+ <div class="payrandom-price-full-right">
59
+ <a href="#" class="payrandom-price-full-left-element" onclick="prPaymentOpenHelp(<?php echo $_id ?>); return false;">
60
+ <img src="<?php echo PayRandom_PRPayment_Helper_Data_Api::getRouletteImg($_discounts, $_price, $this->__('Free'), 450, 450);?>" alt="PayRandom" width="100%"/>
61
+ </a>
62
+ </div>
63
+ <div class="payrandom-price-full-bottom"></div>
64
+ </div>
65
+ <div id="payrandom-modalbox-info-<?php echo $_id ?>" class="payrandom-modalbox" style="display:none;">
66
+ <div class="payrandom-modalbox-header">
67
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/logo_pr_white_small.png');?>" alt="PayRandom" />
68
+ <a href="#" onclick="prPaymentCloseHelp(<?php echo $_id;?>); return false;" id="payrandom-modalbox-close" class="payrandom-modalbox-close"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/close.png');?>" alt="close" /></a>
69
+ </div>
70
+ <div class="payrandom-modalbox-content">
71
+ <div id="payrandom-maincontent-<?php echo $_id;?>" class="payrandom-modalbox-content-maincontent">
72
+ <div class="payrandom-modalbox-content-divimg">
73
+ <img src="<?php echo PayRandom_PRPayment_Helper_Data_Api::getRouletteImg($_discounts, $_price, $this->__('Free'), 250, 250);?>" alt="Roulette" />
74
+ </div>
75
+
76
+ <h2 class="payrandom-modalbox-h2"><?php echo $this->__('Compra y juega con PayRandom') ?></h2>
77
+ <p><?php echo $this->__('¡Consigue este producto por uno de los precios que vés en la ruleta!') ?></p>
78
+ <p><span class="payrandom-modalbox-howitworks"><?php echo $this->__('Cómo funciona') ?>:</span></p>
79
+ <a href="#" onclick="$('payrandom-maincontent-<?php echo $_id;?>').hide();$('payrandom-video-<?php echo $_id;?>').show(); return false;" target="_blank"><img src="<?php echo $this->getSkinUrl('images/prpayment/modalbox/video.png');?>" alt="help" /></a>
80
+ </div>
81
+ <div id="payrandom-video-<?php echo $_id;?>" class="payrandom-modalbox-content-video" style="display: none;">
82
+ <iframe id="how-it-works" src="//player.vimeo.com/video/91405153" width="465" height="260" frameborder="0" allowfullscreen></iframe>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ <script type="text/javascript">
87
+ document.observe('dom:loaded', function() {
88
+ $("payrandom-modalbox-close").on("click", function (e) {
89
+ $('how-it-works').setAttribute('src','');
90
+ $('how-it-works').setAttribute('src','//player.vimeo.com/video/91405153');
91
+ });
92
+ });
93
+ </script>
app/design/frontend/base/default/template/prpayment/redirect.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <form name="prpaymentform" method="post" action="<?php echo Mage::helper('prpayment/api')->getOrdersUrl();?>">
2
+ <?php foreach($this->getParameters() as $name => $value){ ?>
3
+ <input type="hidden" name="<?php echo htmlentities($name);?>" value="<?php echo htmlentities($value);?>" />
4
+ <?php } ?>
5
+ </form>
6
+ <script type="text/javascript">
7
+ document.prpaymentform.submit();
8
+ </script>
app/design/frontend/base/default/template/prpayment/review.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->getChildHtml('items_before'); ?>
2
+ <div id="checkout-review-table-wrapper">
3
+ <table class="data-table" id="checkout-review-table">
4
+ <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
5
+ <col />
6
+ <col width="1" />
7
+ <col width="1" />
8
+ <col width="1" />
9
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
10
+ <col width="1" />
11
+ <col width="1" />
12
+ <?php endif; ?>
13
+ <thead>
14
+ <tr>
15
+ <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
16
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
17
+ <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
18
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
19
+ </tr>
20
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
21
+ <tr>
22
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
23
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
24
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
25
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
26
+ </tr>
27
+ <?php endif; ?>
28
+ </thead>
29
+ <tr>
30
+ <td colspan="4">
31
+ <img src="<?php echo $this->getSkinUrl('images/prpayment/logo_pr.png');?>" alt="PayRandom" />
32
+ </td>
33
+ </tr>
34
+ <?php echo $this->getChildHtml('totals'); ?>
35
+ <tbody>
36
+ <?php foreach($this->getItems() as $_item): ?>
37
+ <?php echo $this->getItemHtml($_item)?>
38
+ <?php endforeach ?>
39
+ </tbody>
40
+ </table>
41
+ </div>
42
+ <?php echo $this->getChildHtml('items_after'); ?>
43
+ <script type="text/javascript">
44
+ //<![CDATA[
45
+ decorateTable('checkout-review-table');
46
+ truncateOptions();
47
+ //]]>
48
+ </script>
49
+ <div id="checkout-review-submit">
50
+ <?php echo $this->getChildHtml('agreements') ?>
51
+ <div class="buttons-set" id="review-buttons-container">
52
+ <p class="f-left"><?php echo $this->__('Forgot an Item?') ?> <a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Your Cart') ?></a></p>
53
+ <?php echo $this->getChildHtml('button') ?>
54
+ <span class="please-wait" id="review-please-wait" style="display:none;">
55
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
56
+ </span>
57
+ </div>
58
+ <script type="text/javascript">
59
+ //<![CDATA[
60
+ review = new Review('<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>', '<?php echo $this->getUrl('checkout/onepage/success') ?>', $('checkout-agreements'));
61
+ //]]>
62
+ </script>
63
+ </div>
app/design/frontend/base/default/template/prpayment/tax/checkout/grandtotal.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $cartDeal = $this->getCartDeal();
3
+ ?>
4
+ <?php if ($this->includeTax() && $this->getTotalExclTax()>=0):?>
5
+ <tr>
6
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
7
+ <strong><?php echo $this->helper('tax')->__('Grand Total Excl. Tax')?></strong>
8
+ </td>
9
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
10
+ <strong><?php echo $this->helper('checkout')->formatPrice($this->getTotalExclTax()) ?></strong>
11
+ </td>
12
+ </tr>
13
+ <?php echo $this->renderTotals('taxes', $this->getColspan()); ?>
14
+ <tr>
15
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
16
+ <strong><?php echo $this->helper('tax')->__('Grand Total Incl. Tax')?></strong>
17
+ </td>
18
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
19
+ <strong><?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?></strong>
20
+ </td>
21
+ </tr>
22
+ <?php else:?>
23
+ <?php
24
+ $subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
25
+ $difTotal = $this->getTotal()->getValue() - $subTotal;
26
+ ?>
27
+ <tr>
28
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
29
+ <strong><?php echo $this->getTotal()->getTitle() ?></strong>
30
+
31
+ </td>
32
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
33
+ <strong><?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $cartDeal->getMaximumDiscount()) * $subTotal + $difTotal) . ' ' . $this->__('a') . ' ' .
34
+ $this->helper('checkout')->formatPrice((1 - $cartDeal->getMinimumDiscount()) * $subTotal + $difTotal) ?>
35
+
36
+ </strong>
37
+ </td>
38
+ </tr>
39
+ <?php endif;?>
app/design/frontend/base/default/template/prpayment/tax/checkout/subtotal.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $cartDeal = $this->getCartDeal();
3
+ ?>
4
+ <?php if ($this->displayBoth()):?>
5
+ <tr>
6
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
7
+ <?php echo $this->helper('tax')->__('Subtotal (Excl. Tax)') ?>
8
+ </td>
9
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
10
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $cartDeal->getMaximumDiscount()) * $this->getTotal()->getValueExclTax()) ?>
11
+ <?php echo $this->__('a'); ?>
12
+ <?php echo $this->helper('checkout')->formatPrice((1 - $cartDeal->getMinimumDiscount()) * $this->getTotal()->getValueExclTax()) ?>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
17
+ <?php echo $this->helper('tax')->__('Subtotal (Incl. Tax)') ?>
18
+ </td>
19
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
20
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $cartDeal->getMaximumDiscount()) * $this->getTotal()->getValueInclTax()) ?>
21
+ <?php echo $this->__('a'); ?>
22
+ <?php echo $this->helper('checkout')->formatPrice((1 - $cartDeal->getMinimumDiscount()) * $this->getTotal()->getValueInclTax()) ?>
23
+ </td>
24
+ </tr>
25
+ <?php else : ?>
26
+ <tr>
27
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
28
+ <?php echo $this->getTotal()->getTitle() ?>
29
+ </td>
30
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
31
+ <?php echo $this->__('de') . ' ' . $this->helper('checkout')->formatPrice((1 - $cartDeal->getMaximumDiscount()) * $this->getTotal()->getValue()) ?>
32
+ <?php echo $this->__('a'); ?>
33
+ <?php echo $this->helper('checkout')->formatPrice((1 - $cartDeal->getMinimumDiscount()) * $this->getTotal()->getValue()) ?>
34
+ </td>
35
+ </tr>
36
+ <?php endif;?>
app/etc/modules/PayRandom_PRPayment.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category PayRandom
5
+ * @package PayRandom_PRPayment
6
+ * @copyright Copyright (c) 2013 PayRandom (http://www.payrandom.com)
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <PayRandom_PRPayment>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ </PayRandom_PRPayment>
15
+ </modules>
16
+ </config>
app/locale/en_US/PayRandom_PRPayment.csv ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "a","to"
2
+ "Asignar ruleta","Assign roulette"
3
+ "Asignar ruleta PayRandom","Assign PayRandom roulette"
4
+ "Atracción","Attraction"
5
+ "Atracción","Attraction"
6
+ "Atracción","Attraction"
7
+ "Atracción Alta","High Atracction"
8
+ "Atracción Media","Medium Attraction"
9
+ "Atracción Muy Alta","Maximum Attraction"
10
+ "Cómo funciona","How it works"
11
+ "Cómo funciona","How it works"
12
+ "Compra y Juega","Buy & Play"
13
+ "Compra y Juega","Buy & Play"
14
+ "Compra y Juega","Buy & Play"
15
+ "Compra y Juega con PayRandom","Buy & Play with PayRandom"
16
+ "Compra y Juega con PayRandom","Buy & Play with PayRandom"
17
+ "Compra y juega con PayRandom","Buy & Play with PayRandom"
18
+ "Configura la ruleta","Set your roulette"
19
+ "¡Consigue este producto por uno de los precios que vés en la ruleta!","Get this product for one of the prices that you see on roulette!"
20
+ "¡Consigue este producto por uno de los precios que vés en la ruleta!","Get this product for one of the prices that you see on roulette!"
21
+ "Continua con el proceso de compra y al final jugarás el precio con <strong>PayRandom</strong>","Continuing with the buying process and ultimately the price will be fixed with <strong> PayRandom </ strong>"
22
+ "de","from"
23
+ "Debes saber que para jugar con <strong>PayRandom</strong> primero debes demostrar que puedes pagar el precio que te toque, por eso se hará previamente una reserva del <strong>importe máximo</strong> de la compra a través de PayPal.","You should know in order to play with <strong> PayRandom </ strong> you must first prove that you can pay the price that you get, so we will previously make a <strong> maximum amount </ strong> of the purchase reservation through PayPal."
24
+ "Desde","From"
25
+ "Equilibrio","Balance"
26
+ "Equilibrio","Balance"
27
+ "Escribe valor 0 si quieres poner el premio GRATIS","Write 0 if you wanna choose FREE section"
28
+ "Generando la ruleta...","Generating roulette..."
29
+ "Guardar y asignar","Save and assign"
30
+ "Hasta","Up to"
31
+ "Icono de la oferta","Offer icon"
32
+ "Importe mínimo","Minimum Price"
33
+ "Los números de la ruleta","Roulette numbers"
34
+ "Los precios <strong>PayRandom</strong> no incluyen los gastos de envío.","PayRandom prices do not include shipping taxes"
35
+ "Más información","More information"
36
+ "Ninguno","None"
37
+ "Nombre","Name"
38
+ "Nueva ruleta","New Roulette"
39
+ "Nueva ruleta","New Roulette"
40
+ "Ponle nombre a la ruleta","Name your roulette"
41
+ "Porcentaje","Percentage"
42
+ "Precio","Price"
43
+ "Precio fijo","Fixed Price"
44
+ "Precio medio","Estimated Price"
45
+ "Precio medio","Estimated Price"
46
+ "Precio medio","Estimated Price"
47
+ "Precio medio","Estimated Price"
48
+ "PRECIO MÍNIMO:","Minimum Price"
49
+ "Precio original","Original Price"
50
+ "Precio original","Original Price"
51
+ "Producto","Product"
52
+ "Producto","Product"
53
+ "Productos PR en juego","Products on sale"
54
+ "Productos PR vendidos","Sold products"
55
+ "Recalcular","Recalculate"
56
+ "Recalcular","Recalculate"
57
+ "Ruleta de precios","Price roulette"
58
+ "Ruleta predefinida","Predefined roulette"
59
+ "Sin precio fijo","No fixed price"
60
+ "Información de la cuenta","Account Information"
61
+ "Añadir ruleta PayRandom","Add PayRandom Roulette"
62
+ "Oferta guardada correctamente","Deal"
63
+ "Descuentos de la oferta","Deal discounts"
64
+ "Descuentos de la oferta","Deal discounts"
65
+ "Oferta guardada correctamente","Deal was successfully saved"
66
+ "Eliminar ruleta PayRandom","Delete PayRandom Roulette"
67
+ "Descuento","Discount"
68
+ "Editar ruleta PayRandom","Edit PayRandom Roulette"
69
+ "Gratis","Free"
70
+ "Desde","From"
71
+ "Nombre","Name"
72
+ "Producto sin ID","No product id"
73
+ "Opciones","Options"
74
+ "PayRandom","PayRandom"
75
+ "PayRandom-Información de la cuenta","PayRandom - Account info"
76
+ "Precio PayRandom","PayRandom Price:"
77
+ "Porcentajes","Percentages"
78
+ "Precios","Prices"
79
+ "Descuentos de la ruleta","Roulette discounts"
80
+ "Esta oferta no puede ser guardada con PayRandom","The deal cannot be saved in PayRandom"
81
+ "Este producto no puede ser guardado con PayRandom","The product cannot be saved in PayRandom"
82
+ "a","to"
83
+ "Ver formato","View format"
84
+ "Now","Now"
85
+ "Fixed price hint", "Fixed price must be greater than average price"
86
+ "Free", "Free"
87
+ "Ruleta", "Roulette"
88
+ "Con precio fijo", "Fixed Price"
89
+ "Dashboard","Dashboard"
90
+ "Ruletas predefinidas", "Predefined Roulettes"
app/locale/es_ES/PayRandom_PRPayment.csv ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "a","a"
2
+ "Asignar ruleta","Asignar ruleta"
3
+ "Asignar ruleta PayRandom","Asignar ruleta PayRandom"
4
+ "Atracción","Atracción"
5
+ "Atracción","Atracción"
6
+ "Atracción","Atracción"
7
+ "Atracción Alta","Atracción Alta"
8
+ "Atracción Media","Atracción Media"
9
+ "Atracción Muy Alta","Atracción Muy Alta"
10
+ "Cómo funciona","Cómo funciona"
11
+ "Cómo funciona","Cómo funciona"
12
+ "Compra y Juega","Compra y Juega"
13
+ "Compra y Juega","Compra y Juega"
14
+ "Compra y Juega","Compra y Juega"
15
+ "Compra y Juega con PayRandom","Compra y Juega con PayRandom"
16
+ "Compra y Juega con PayRandom","Compra y Juega con PayRandom"
17
+ "Compra y juega con PayRandom","Compra y Juega con PayRandom"
18
+ "Configura la ruleta","Configura la ruleta"
19
+ "¡Consigue este producto por uno de los precios que vés en la ruleta!","¡Consigue este producto por uno de los precios que vés en la ruleta!"
20
+ "¡Consigue este producto por uno de los precios que vés en la ruleta!","¡Consigue este producto por uno de los precios que vés en la ruleta!"
21
+ "Continua con el proceso de compra y al final jugarás el precio con <strong>PayRandom</strong>","Continua con el proceso de compra y al final jugarás el precio con <strong>PayRandom</strong>"
22
+ "de","de"
23
+ "Debes saber que para jugar con <strong>PayRandom</strong> primero debes demostrar que puedes pagar el precio que te toque, por eso se hará previamente una reserva del <strong>importe máximo</strong> de la compra a través de PayPal.","Debes saber que para jugar con <strong>PayRandom</strong> primero debes demostrar que puedes pagar el precio que te toque, por eso se hará previamente una reserva del <strong>importe máximo</strong> de la compra a través de PayPal."
24
+ "Desde","Desde"
25
+ "Equilibrio","Equilibrio"
26
+ "Equilibrio","Equilibrio"
27
+ "Escribe valor 0 si quieres poner el premio GRATIS","Escribe valor 0 si quieres poner el premio GRATIS"
28
+ "Generando la ruleta...","Generando la ruleta..."
29
+ "Guardar y asignar","Guardar y asignar"
30
+ "Hasta","Hasta"
31
+ "Icono de la oferta","Icono de la oferta"
32
+ "Importe mínimo","Importe mínimo"
33
+ "Los números de la ruleta","Los números de la ruleta"
34
+ "Los precios <strong>PayRandom</strong> no incluyen los gastos de envío.","Los precios <strong>PayRandom</strong> no incluyen los gastos de envío."
35
+ "Más información","Más información"
36
+ "Ninguno","Ninguno"
37
+ "Nombre","Nombre"
38
+ "Nueva ruleta","Nueva ruleta"
39
+ "Nueva ruleta","Nueva ruleta"
40
+ "Ponle nombre a la ruleta","Ponle nombre a la ruleta"
41
+ "Porcentaje","Porcentaje"
42
+ "Precio","Precio"
43
+ "Precio fijo","Precio fijo"
44
+ "Precio medio","Precio medio"
45
+ "Precio medio","Precio medio"
46
+ "Precio medio","Precio medio"
47
+ "Precio medio","Precio medio"
48
+ "PRECIO MÍNIMO:","PRECIO MÍNIMO:"
49
+ "Precio original","Precio original"
50
+ "Precio original","Precio original"
51
+ "Producto","Producto"
52
+ "Producto","Producto"
53
+ "Productos PR en juego","Productos en juego"
54
+ "Productos PR vendidos","Productos vendidos"
55
+ "Recalcular","Recalcular"
56
+ "Recalcular","Recalcular"
57
+ "Ruleta de precios","Ruleta de precios"
58
+ "Ruleta predefinida","Ruleta predefinida"
59
+ "Sin precio fijo","Sin precio fijo"
60
+ "Información de la cuenta","Información de la cuenta"
61
+ "Añadir ruleta PayRandom","Añadir ruleta PayRandom"
62
+ "Oferta guardada correctamente","Oferta guardada correctamente"
63
+ "Descuentos de la oferta","Descuentos de la oferta"
64
+ "Descuentos de la oferta","Descuentos de la oferta"
65
+ "Oferta guardada correctamente","Oferta guardada correctamente"
66
+ "Eliminar ruleta PayRandom","Eliminar ruleta PayRandom"
67
+ "Descuento","Descuento"
68
+ "Editar ruleta PayRandom","Editar ruleta PayRandom"
69
+ "Gratis","Gratis"
70
+ "Desde","Desde"
71
+ "Nombre","Nombre"
72
+ "Producto sin ID","Producto sin ID"
73
+ "Opciones","Opciones"
74
+ "PayRandom","PayRandom"
75
+ "PayRandom-Información de la cuenta","PayRandom-Información de la cuenta"
76
+ "Precio PayRandom","Precio PayRandom:"
77
+ "Porcentajes","Porcentajes"
78
+ "Precios","Precios"
79
+ "Descuentos de la ruleta","Descuentos de la ruleta"
80
+ "Esta oferta no puede ser guardada con PayRandom","Esta oferta no puede ser guardada con PayRandom"
81
+ "Este producto no puede ser guardado con PayRandom","Este producto no puede ser guardado con PayRandom"
82
+ "a","a"
83
+ "Ver formato","Ver formato"
84
+ "Now","Ahora"
85
+ "Fixed price hint", "Precio fijo debe ser mayor que precio medio"
86
+ "Free", "Gratis"
87
+ "Ruleta", "Ruleta"
88
+ "Con precio fijo", "Con precio fijo"
89
+ "Dashboard","Panel de control"
90
+ "Ruletas predefinidas", "Ruletas predefinidas"
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>PayRandom</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://docs.payrandom.com/license.txt">PayRandom EULA</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>PayRandom is a gamified payment method including a price roulette which determines by random the price to pay.</summary>
10
+ <description>PayRandom will help you growing your sales by making your products more attractive!&#xD;
11
+ With PayRandom, your visitors get the opportunity to buy a product with a big discount or even for Free. &#xD;
12
+ They will enjoy shopping with you because you are offering them a funny way to purchase, having the possibility of buying a product at a price randomly fixed by a roulette.&#xD;
13
+ PayRandom runs with PayPal payment gateway giving all the security, reliability and extreme flexibility process. With PayRandom your customers will have the confidence to have a leading brand in transactions giving you all the assurance of a safe purchase.&#xD;
14
+ You can easily associate a price roulette to a product, getting more attention from your customers because the lowest price of the roulette is the one promoted by including a powerful claim in the product photo at your Home Page.&#xD;
15
+ The roulette has always 8 prices, and you have the possiblity to add the alternative of a fixed price to increase your conversion rate. &#xD;
16
+ You will have information about the necessary minimum sales to reach average price of the roulette. &#xD;
17
+ The PayRandom Magento extension has very easy and flexible configuration. Defining roulette prices, there is an ability to specify products where your customers can use PayRandom. So you can display PayRandom for promoted products only.&#xD;
18
+ </description>
19
+ <notes>First version of PayRandom Extension</notes>
20
+ <authors><author><name>PayRandom</name><user>PayRandom</user><email>it@payrandom.com</email></author></authors>
21
+ <date>2014-04-29</date>
22
+ <time>15:34:59</time>
23
+ <contents><target name="magecommunity"><dir name="PayRandom"><dir name="PRPayment"><dir name="Block"><dir name="Adminhtml"><dir name="Deals"><dir name="Choose"><file name="Grid.php" hash="ec061d3b1bb6736fda14c6112c6d9180"/></dir><file name="Choose.php" hash="10d96478b62e82a3061021d5064d290d"/><dir name="Current"><file name="Grid.php" hash="c9a5a7c225996f62b56a46f3bae2438b"/></dir><file name="Current.php" hash="7c803f8b3eaba2ef9a59dbfd1a23e16d"/><dir name="Edit"><file name="Form.php" hash="3fdb136efba57275a8aad2da1a8bb1d8"/><dir name="Tab"><file name="Form.php" hash="1f3aad8b3b8a7f0fe2fbcf91b76f638e"/></dir><file name="Tabs.php" hash="bd75caf0e5c8c91788a251a41b1e3be3"/></dir><file name="Edit.php" hash="41e3bb79ba574d2ebd9e3c28adfb2a68"/><dir name="Predefined"><file name="Grid.php" hash="714fe9b96f2d0dd816b917edb32ed24f"/></dir><file name="Predefined.php" hash="5bbfb9af7ee7366be25ed3bf5aa06d29"/><dir name="Sold"><file name="Grid.php" hash="3aaf280afd9723d0c6bac1e49736581e"/></dir><file name="Sold.php" hash="d92cf88b0b8069182d65055a6fb1526f"/></dir><dir name="Renderer"><file name="Amount.php" hash="933f0b9c592e8822003035e170568ae7"/><file name="Attraction.php" hash="37a3c0bb2b56489edfe8c051e9446c82"/><file name="Balance.php" hash="c73257ad37f67e425b0de2f90344df14"/><file name="Discount.php" hash="2d766415283487a0ff15396bc33556d2"/><dir name="Fixed"><file name="Value.php" hash="862708174d77b15d091834c317c440e6"/></dir><file name="Option.php" hash="90060431bd574c47ee0264ce947e154d"/></dir></dir><dir name="Catalog"><dir name="Product"><file name="Grid.php" hash="bc1d6048c895ce6d40810227a12b98cf"/><file name="Renderer.php" hash="524c65c3bfb07489a4dd29a2f080af0d"/></dir></dir><dir name="Checkout"><dir name="Cart"><dir name="Item"><file name="Renderer.php" hash="609e2297cddc6849368d1dc8bc1f24dd"/></dir></dir><file name="Cart.php" hash="889215ccd3ad5f9ff94e11387e0f5abc"/><dir name="Onepage"><file name="Link.php" hash="4ccbdb30d2c33d6d8c4d800aab16c17a"/><file name="Payment.php" hash="fb064f0e9fa903c933176602951b2fb0"/><dir name="Review"><file name="Info.php" hash="17cc8e1f74bfe14614ed449559f1a065"/></dir><dir name="Shipping"><file name="Method.php" hash="ddf7ff811bbd7dbe0e400d1df4495f47"/></dir></dir></dir><dir name="Form"><file name="Prpayment.php" hash="6a779901a6fd77c68b99f128c0a9306e"/></dir><dir name="Product"><file name="Price.php" hash="a39bd1d0c2055854dc0c3b9e9502e2cb"/><file name="View.php" hash="d29e3ef952fba72f6699b2aef764d3e5"/></dir><dir name="Tax"><dir name="Checkout"><file name="Grandtotal.php" hash="d73afe8ccd5922532add0caeeac3233b"/><file name="Subtotal.php" hash="1be4da79b745aa37912db036a33ff125"/></dir></dir></dir><dir name="Helper"><dir name="Data"><file name="Api.php" hash="0a7760bba51586c371e6a4360b59f71c"/><file name="Data.php" hash="95303c70a7ccba6e1fdc15b961b34861"/></dir><file name="Data.php" hash="fa746683e9db49545e3829a697455518"/></dir><dir name="Model"><file name="Deal.php" hash="537c4041eb577650bc1d5c1372dc034c"/><file name="Dealproduct.php" hash="c966a33508f79fe921468f358572cf76"/><file name="Observer.php" hash="bfcbff0707d2574d3d867733df95f64b"/><file name="Predefineddeal.php" hash="5c736bbe4720bd4f482639616d0d8a63"/><file name="Productstatistics.php" hash="28cd4d60b117141b9c4b6a414e04113f"/><dir name="Resource"><dir name="Deal"><file name="Collection.php" hash="61fe437cc7cfa1d6ea77c112e44f6ecf"/></dir><file name="Deal.php" hash="f223ffab2a66b549f15ee4749f7622c3"/><dir name="Dealproduct"><file name="Collection.php" hash="eb155a1c8711d46ba9db7735f811c415"/></dir><file name="Dealproduct.php" hash="19b0242542caf7849588739e34945b1e"/><dir name="Predefineddeal"><file name="Collection.php" hash="d953e93ef475932a1095fbf881b66ad6"/></dir><file name="Predefineddeal.php" hash="38af309769889889c89013d7e49dae62"/><dir name="Productstatistics"><file name="Collection.php" hash="13bd0b2faea482ce1183b1c30c446162"/></dir><file name="Productstatistics.php" hash="fbd701977d216f28f621e59722d06bc7"/><file name="Setup.php" hash="b327add31afe9162c24b5dfd1b06ce00"/></dir><file name="Standard.php" hash="a2b5c9a2deba34b3070ff4498ebe00f6"/></dir><dir name="controllers"><file name="DealsController.php" hash="21f8adc4501a7ff1f26c2ae051fba33a"/><file name="InfoController.php" hash="96bae98409222c080c8565735420d284"/><file name="PaymentController.php" hash="3fda6ed2fa5ed2fa8bf6b0a25264ce0b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0b58e940181753164477dec0455a1348"/><file name="config.xml" hash="587900b2333687fc6fd6243df784bdd3"/><file name="system.xml" hash="dfd67caad87b7b8c6dfd82ad4a65334c"/></dir><dir name="sql"><dir name="prpayment_setup"><file name="mysql4-install-0.1.0.php" hash="d6bf603584056482b491cc4a536bc7d3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="prpayment.xml" hash="ac76542c7295ba12045f32b63d9d9660"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="prpayment"><dir name="deal"><file name="design.phtml" hash="49e22aaef0a6dde0ea5f7f05d759b2a4"/></dir><file name="info.phtml" hash="2f9a25742a6337d9ecb17d783253ee43"/><file name="predefinedgrid.phtml" hash="e46771bf9dcb9f1422c4d646ea21469e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="prpayment.xml" hash="d4dd2c11cb5fe5c1e15b8abb918cd866"/></dir><dir name="template"><dir name="prpayment"><file name="addtocart_pr.phtml" hash="aa3bf04e703543e5b99a6c70a1a8e059"/><dir name="catalog"><dir name="product"><file name="list.phtml" hash="0991f482eeeb4a81c0c51c5929032919"/><dir name="view"><file name="addtocart.phtml" hash="3ff238ba02085969de12866c343c80f9"/><dir name="type"><file name="default.phtml" hash="6c60f13f1c36b063699d0306ac2cfd95"/></dir></dir></dir></dir><dir name="checkout"><dir name="cart"><dir name="item"><file name="default.phtml" hash="b9fe40f7315f4658b291a1090c38b0f9"/></dir></dir><file name="cart.phtml" hash="37f68ee4b94eb3ec2cde95497af5be94"/><dir name="onepage"><file name="link.phtml" hash="c21bc1dbc3dacdbe92cd67f958e5d3c9"/><file name="payment.phtml" hash="55014ab54566609d25ba9e04c5f90ae6"/><dir name="review"><file name="button.phtml" hash="95a6025399dc1a5aaee92418db1645e1"/><file name="item.phtml" hash="cddc602fbf397012a59226c6995fd1cc"/></dir><file name="shipping_method.phtml" hash="d64d7f019c9892d9518e8eb55bb1ee99"/></dir></dir><dir name="form"><file name="prpayment.phtml" hash="b4cc8f26a63e1dc429526bd1940967ca"/></dir><dir name="onestepcheckout"><file name="checkout.phtml" hash="e63249adb87ebd92a0395fb6eb5ba62e"/><file name="summary.phtml" hash="0381513fddad38dcdde9908d0e03b861"/></dir><file name="price.phtml" hash="997a7074af4fa5321f3b2723e93ffc28"/><file name="price_full.phtml" hash="5a2571b1db5a8f3a5fb77c1f9c97c1ed"/><file name="redirect.phtml" hash="ce19453190dd3da44307a9fff0fc28c6"/><file name="review.phtml" hash="348c7335e1cc6272fda82d387e925365"/><dir name="tax"><dir name="checkout"><file name="grandtotal.phtml" hash="573ee13960cc22fe1f82a6e6b5f59d93"/><file name="subtotal.phtml" hash="3ba179826fe726b1dbaf2f28fd01980e"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PayRandom_PRPayment.xml" hash="5727f69a925695996b91b8c2d9ce7961"/></dir></target><target name="magelocale"><dir name="en_US"><file name="PayRandom_PRPayment.csv" hash="4a77de13290afbba8a6ab86d48fd9952"/></dir><dir name="es_ES"><file name="PayRandom_PRPayment.csv" hash="9205ff2e8882c315af5b4546037ae2e3"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="prpayment"><file name="prpayment.css" hash="f74edce6be2fc686d40187a885b2569d"/></dir></dir><dir name="images"><dir name="prpayment"><file name="help.png" hash="3823cae9129bb395adc500da9c916e60"/><file name="information_excl.png" hash="5c579e56b01614427244ee2eb7fc3c39"/><file name="information_question.png" hash="1b7e201ebeb1488eac878972d713bddd"/><file name="lens.png" hash="3f3c5062fb252d4c36aa2c4e8e4bad46"/><file name="logo_pr.png" hash="70c26e9646f29cc9d20f0282255a7358"/><file name="logo_pr_150.png" hash="3c01749276daadc0264c4a2f76e6d31f"/><file name="logo_pr_min.png" hash="faa5607318a4374d4cf05e084395b9ea"/><file name="logo_pr_small.png" hash="28b30e484bb5c5d5edeeee0ff7abbf08"/><file name="logo_pr_white.png" hash="2647615b68e66afbfd95e47841f7708e"/><file name="logo_pr_white_small.png" hash="0d5f9a3b75b6d5f995a070456b92da9b"/><dir name="modalbox"><file name="close.png" hash="499499a5192b89b8913932e89b9f6ab5"/><file name="roulette.png" hash="24f3c2f22f1b728a50feba99782a1e64"/><file name="video.png" hash="886d90d7581990a37453d6000d5770f1"/></dir><file name="roulette.png" hash="ec9910bb274ce88c25aac5f5205fafc0"/><file name="roulette_2.png" hash="6df658e3cb931521b45701a71170639a"/></dir></dir><dir name="js"><dir name="prpayment"><file name="prpayment.js" hash="5a3c6afd979d7cb17e3352468a7a4311"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="css"><dir name="prpayment"><file name="adminprpayment.css" hash="dbf325b91e00387f3f6b6d430137fff6"/></dir></dir><dir name="js"><dir name="prpayment"><file name="adminprpayment.js" hash="0810daf51e0a2998a70765a107625f60"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="images"><dir name="prpayment"><file name="add.png" hash="2e14e917525c03a9bb424723a405d425"/><file name="attraction_high.png" hash="2fa86c803e339ddeaa77bd31a85f12ce"/><file name="attraction_medium.png" hash="a16ef183a243735eab349226ae364b37"/><file name="attraction_very_high.png" hash="67c036c80d26ae1984fd84dddfaa8251"/><file name="delete.png" hash="e225c29689687426e53541caeac2fc9c"/><file name="edit.png" hash="d80e84602f3a7599df1bc4ee42328a92"/><file name="payrandom.png" hash="95dcb57f8ff5550a46a66b53ddbd03a6"/><file name="slider-attraction.png" hash="64eca9aed81a1a39c39175f0d85b5a6b"/><file name="slider-handler-shadow.png" hash="e197e1486183c8fcef304da95f493b15"/><file name="slider-handler.png" hash="0fea74dd25fa6923e3f8ee4aea01348e"/><file name="slider.png" hash="3fce1f1d383e93fa2eaa7a61fab731db"/></dir></dir></dir></dir></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
26
+ </package>
skin/adminhtml/base/default/css/prpayment/adminprpayment.css ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .prpayment-design-box {
2
+ border: 1px solid #dcdcdc;
3
+ background-color: #fafafa;
4
+ min-height: 600px;
5
+ padding: 30px;
6
+ color: #656c72;
7
+ }
8
+
9
+ .prpayment-design-box-left {
10
+ min-height: 600px;
11
+ padding-right: 20px;
12
+ float: left;
13
+ width: 40%;
14
+ }
15
+
16
+ .prpayment-design-box-right {
17
+ width: 53%;
18
+ float: left;
19
+ padding: 0 20px;
20
+ border-left: 1px solid #dcdcdc;
21
+ }
22
+
23
+ .prpayment-design-element {
24
+ margin-bottom: 20px;
25
+ }
26
+
27
+ .prpayment-design-group {
28
+ margin-bottom: 20px;
29
+ }
30
+
31
+ .prpayment-design-deal-header{
32
+ text-align: center;
33
+ width: 24%;
34
+ }
35
+ .prpayment-design-deal{
36
+ margin: 0 10px;
37
+ width: 90%;
38
+ text-align: right;
39
+ }
40
+
41
+ .prpayment-design-deal-result {
42
+ text-align: center;
43
+ }
44
+
45
+ .prpayment-design-deal-red{
46
+ color: #fc8d8e;
47
+ }
48
+
49
+ .prpayment-design-deal-green{
50
+ color: #8fcb9f;
51
+ }
52
+
53
+ .prpayment-design-box-bigimage {
54
+ text-align: center;
55
+ }
56
+
57
+ .prpayment-design-box-bottom{
58
+ background-color: #fff;
59
+ border: 1px solid #dcdcdc;
60
+ padding: 20px 40px;
61
+ margin-bottom: 10px;
62
+ }
63
+
64
+ .prpayment-design-box-bottom th {
65
+ color: #EB5E00;
66
+ text-align: center;
67
+ }
68
+
69
+ .prpayment-design-box-bottom td {
70
+ text-align: center;
71
+ }
72
+
73
+ .prpayment-design-recaluclate {
74
+ text-align: center;
75
+ line-height: 300px;
76
+ min-height: 600px;
77
+ }
78
+
79
+ .prpayment-design-loading {
80
+ background-color: #EAE2CA;
81
+ border: 3px solid #DFD7BA;
82
+ color: #611B06;
83
+ font-size: 14px;
84
+ font-weight: bold;
85
+ padding: 85px;
86
+ text-align: center;
87
+ }
88
+
89
+ .prpayment-slider-handle {
90
+ width: 21px;
91
+ height: 21px;
92
+ background-image: url('../../../../default/default/images/prpayment/slider-handler-shadow.png');
93
+ cursor: col-resize;
94
+ }
95
+
96
+ #predefinedDealsGridInfo_table input{
97
+ display: none;
98
+ }
skin/adminhtml/base/default/js/prpayment/adminprpayment.js ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function prPaymentAssignPredefined(){
2
+ if(predefinedForm.validate()){
3
+ var predefinedDeal = $$('input:checked[type="radio"][name="id"]').pluck('title');
4
+ var avgPrice = $('avgPrice').value;
5
+ if(predefinedDeal != ''){
6
+ window.location = predefinedDeal + 'avg_price/' + avgPrice ;
7
+ }
8
+ }
9
+ }
10
+
11
+ function getAvgPriceFromDeals(){
12
+ var sum = 0;
13
+ var total = 0;
14
+ for(var i = 1; i <= 8; i++){
15
+ sum += parseFloat($('deal' + i).value.replace(",", "."));
16
+ total++;
17
+ }
18
+ return sum / total;
19
+ }
20
+
21
+ function getDiffDiscountsFromDeals(){
22
+ var avgPrice = getAvgPriceFromDeals();
23
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
24
+
25
+ if(avgPrice > 0){
26
+ for(var i = 1; i <= 8; i++){
27
+ ret[i - 1] = (parseFloat($('deal' + i).value.replace(",", ".")) / avgPrice) - 1;
28
+ }
29
+ }
30
+ return ret;
31
+ }
32
+
33
+ function updateDiffDiscountsFromDeals(redrawRoulette){
34
+ if(redrawRoulette){
35
+ $('roulette').hide();
36
+ $('recalculate').show();
37
+ }
38
+ var diffDiscounts = getDiffDiscountsFromDeals();
39
+ var realDiscounts = getRealDiscountsFromDeals();
40
+ for(var i = 1; i <= 8; i++){
41
+ var value = ((diffDiscounts[i - 1]) * 100).toFixed(2);
42
+ $('result-deal-' + i).removeClassName('prpayment-design-deal-green').removeClassName('prpayment-design-deal-red');
43
+
44
+ text = value;
45
+ if(value < 0){
46
+ $('result-deal-' + i).addClassName('prpayment-design-deal-green');
47
+ }else if(value > 0){
48
+ $('result-deal-' + i).addClassName('prpayment-design-deal-red');
49
+ text = '+' + value;
50
+ }
51
+ if(value == -100){
52
+ $('result-deal-' + i).update('GRATIS');
53
+ }else{
54
+ $('result-deal-' + i).update(text + '%');
55
+ }
56
+
57
+ $('real_discount_' + i).value = realDiscounts[i - 1];
58
+ }
59
+ updateLblAvgPriceFromDeals();
60
+ updateLblBalanceFromDeals();
61
+ updateLblAttractionFromDeals();
62
+ updateExampleIcon();
63
+ }
64
+
65
+ function getPricesFromDeals(){
66
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
67
+
68
+ for(var i = 1; i <= 8; i++){
69
+ ret[i - 1] = parseFloat($('deal' + i).value.replace(",", "."));
70
+ }
71
+ return ret;
72
+ }
73
+
74
+
75
+ function updateLblAvgPriceFromDeals(){
76
+ var avgPrice = getAvgPriceFromDeals();
77
+ $('lblAvgPrice').update(avgPrice.toFixed(2));
78
+ $('avg_price').value = avgPrice.toFixed(2);
79
+ }
80
+
81
+ function updateLblBalanceFromDeals(){
82
+ var realDiscounts = getRealDiscountsFromDeals();
83
+ var realDiscounts100 = realDiscounts.map(function (x) {
84
+ return x * 100;
85
+ });
86
+
87
+ $('lblBalance').update(calcBalance(getPricesFromDeals()).toFixed());
88
+ }
89
+
90
+ function updateLblAttractionFromDeals(){
91
+ var attraction = calcAttraction(getPricesFromDeals());
92
+ if (attraction < 10) {
93
+ $$('.deal-attraction').each(Element.hide);
94
+ $$('.deal-attraction-medium').each(Element.show);
95
+ } else if (attraction < 150) {
96
+ $$('.deal-attraction').each(Element.hide);
97
+ $$('.deal-attraction-high').each(Element.show);
98
+ } else {
99
+ $$('.deal-attraction').each(Element.hide);
100
+ $$('.deal-attraction-very-high').each(Element.show);
101
+ }
102
+ }
103
+
104
+
105
+ function arrSum(arrData){
106
+ return arrData.reduce(function(pv, cv) { return pv + cv; }, 0);
107
+ }
108
+
109
+ function calcBalance(arrData){
110
+ return 2 * calcVariance(arrData) / 10;
111
+ }
112
+
113
+ function calcAttraction(arrData){
114
+ var num100 = 0;
115
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
116
+
117
+ for(var i = 1; i <= 8; i++){
118
+ if (parseFloat($('deal' + i).value.replace(",", ".")) == 0) {
119
+ num100++;
120
+ }
121
+ }
122
+
123
+ correction = 0;
124
+ switch(num100){
125
+ case 0:
126
+ correction = 0;
127
+ break;
128
+ case 1:
129
+ correction = 10;
130
+ break;
131
+ case 2:
132
+ correction = 30;
133
+ break;
134
+ case 3:
135
+ correction = 50;
136
+ break;
137
+ default:
138
+ correction = 100;
139
+ break;
140
+ }
141
+ return calcVariance(arrData) + correction;
142
+ }
143
+
144
+ function calcVariance(arrData){
145
+ var sum = arrSum(arrData);
146
+ var avg = sum / arrData.length;
147
+
148
+ return arrSum(arrData.map(function (x) {return x * x ;})) / arrData.length - avg * avg;
149
+ }
150
+
151
+ function setAttraction(attractionNumber, price){
152
+ if(!price) return;
153
+
154
+ var predefinedAttraction = [
155
+ [-0.05, -0.05, -0.05, 0.00, 0.00, 0.05, 0.05, 0.05],
156
+ [-0.25, -0.20, -0.15, 0.00, 0.00, 0.15, 0.20, 0.25],
157
+ [-0.25, -0.25, 0.00, 0.00, 0.00, 0.00, 0.25, 0.25],
158
+ [-0.40, -0.40, -0.20, -0.20, 0.20, 0.20, 0.40, 0.40],
159
+ [-0.50, -0.40, -0.30, -0.20, 0.20, 0.30, 0.40, 0.50],
160
+ [-1.00, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857],
161
+ [-1.00, 0.00, 0.00, 0.00, 0.25, 0.25, 0.25, 0.25]
162
+ ];
163
+
164
+ var diffDiscounts = predefinedAttraction[attractionNumber];
165
+ for(var i = 1; i <= 8; i++){
166
+ $('deal' + i).value = (price + price * diffDiscounts[i - 1]).toFixed(2);
167
+ }
168
+
169
+ updateDiffDiscountsFromDeals();
170
+ recalculate(500);
171
+ }
172
+
173
+
174
+ function getAvgDiscount(discounts){
175
+ var sum = 0;
176
+ var total = 0;
177
+ for(var i = 0; i < 8; i++){
178
+ sum += parseFloat(discounts[i]);
179
+ total++;
180
+ }
181
+ return sum / total;
182
+ }
183
+
184
+ function getDiffDiscounts(discounts){
185
+ var avgDiscount = getAvgDiscount(discounts);
186
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
187
+
188
+ for(var i = 0; i < 8; i++){
189
+ ret[i] = (parseFloat(discounts[i]) / avgDiscount) - 1;
190
+ }
191
+ return ret;
192
+ }
193
+
194
+ function recalculate(waitFor){
195
+ var newImg = new Image;
196
+ newImg.src = 'http://payrandom.zlworks.com/api/v1/roulette?sizes=600x600&free_text=' + jsTranslate.freeText + '&prices=' + JSON.stringify(getPricesFromDeals());
197
+
198
+
199
+ // Timer to avoid flicking when loading from cache
200
+ var timer = setTimeout(
201
+ function() {
202
+ $('roulette').hide();
203
+ $('recalculate').hide();
204
+ $('prpayment-loading').show();
205
+ }, waitFor
206
+ );
207
+
208
+ newImg.onload = function() {
209
+ clearTimeout(timer);
210
+ $('roulette').show();
211
+ $('prpayment-loading').hide();
212
+ $('roulette-img').src = this.src;
213
+ }
214
+ }
215
+
216
+
217
+ function updateFixedPrice(){
218
+ if($$('[name="radioFixedPrice"]:checked')[0].value == '1'){
219
+ $('fixed_price').addClassName('required-entry');
220
+ $('fixed_price').addClassName('validate-fixed-price');
221
+ }else{
222
+ $('fixed_price').removeClassName('required-entry');
223
+ $('fixed_price').removeClassName('validate-fixed-price');
224
+ if ($('advice-required-entry-fixed_price')) {
225
+ $('fixed_price').removeClassName('validation-failed');
226
+ $('advice-required-entry-fixed_price').remove();
227
+ }
228
+ }
229
+ }
230
+
231
+ function updateExampleIcon(){
232
+ var freeText = jsTranslate.freeText;
233
+ var upToText = jsTranslate.upToText;
234
+ var fromText = jsTranslate.fromText;
235
+ var fromFreeText = jsTranslate.fromFreeText;
236
+
237
+ if($('dealIcon').value == 'percentages'){
238
+ var realDiscounts = getRealDiscountsFromDeals();
239
+ jsText = (Math.max.apply(null, realDiscounts) * 100).toFixed(0) + '%';
240
+
241
+ var newImg = new Image;
242
+ newImg.src = 'http://payrandom.zlworks.com/api/v1/watermark?sizes=85x85&offer_text=' + encodeURIComponent(jsText) + '&upper_text=' + encodeURIComponent(upToText);
243
+
244
+ newImg.onload = function() {
245
+ $('iconExample').src = this.src;
246
+ $('iconExample').show();
247
+ }
248
+ }else if($('dealIcon').value == 'prices'){
249
+ var prices = getPricesFromDeals();
250
+ var price = Math.min.apply(null, prices)
251
+ if(price == 0){
252
+ jsText = freeText;
253
+ fromText = fromFreeText;
254
+ }else{
255
+ jsText = (price).toFixed(2) + '€';
256
+ }
257
+ var newImg = new Image;
258
+ newImg.src = 'http://payrandom.zlworks.com/api/v1/watermark?sizes=85x85&offer_text=' + encodeURIComponent(jsText) + '&upper_text=' + encodeURIComponent(fromText);
259
+
260
+ newImg.onload = function() {
261
+ $('iconExample').src = this.src;
262
+ $('iconExample').show();
263
+ }
264
+
265
+ }else{
266
+ $('iconExample').hide();
267
+ }
268
+ }
269
+
270
+
271
+ function getRealDiscountsFromDeals(){
272
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
273
+
274
+ for(var i = 1; i <= 8; i++){
275
+ ret[i - 1] = 1 - parseFloat($('deal' + i).value.replace(",", ".")) / parseFloat($('real_price').value);
276
+ }
277
+
278
+ return ret;
279
+ }
280
+
281
+ function getPricesFromDeals(){
282
+ var ret = [0, 0, 0, 0, 0, 0, 0, 0];
283
+
284
+ for(var i = 1; i <= 8; i++){
285
+ ret[i - 1] = parseFloat($('deal' + i).value.replace(",", "."));
286
+ }
287
+ return ret;
288
+ }
skin/adminhtml/default/default/images/prpayment/add.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/attraction_high.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/attraction_medium.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/attraction_very_high.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/delete.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/edit.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/payrandom.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/slider-attraction.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/slider-handler-shadow.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/slider-handler.png ADDED
Binary file
skin/adminhtml/default/default/images/prpayment/slider.png ADDED
Binary file
skin/frontend/base/default/css/prpayment/prpayment.css ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .payrandom-information {
2
+ background-color: white;
3
+ border: 1px solid #3498d4;
4
+ border-radius: 6px;
5
+ padding: 0px;
6
+ color: #292929;
7
+ margin-bottom: 10px;
8
+ }
9
+
10
+ .payrandom-information .payrandom-information-img{
11
+ margin-left: 10px;
12
+ background-image: url(../../images/prpayment/information_excl.png);
13
+ background-repeat: no-repeat;
14
+ background-position: center left;
15
+ }
16
+
17
+ .payrandom-information .payrandom-information-content{
18
+ padding: 10px 10px 10px 35px;
19
+ }
20
+
21
+ .payrandom-information .payrandom-information-content .payrandom-information-content-right {
22
+ float: right;
23
+ }
24
+ .payrandom-price-full {
25
+ margin-top: 5px;
26
+ border: 1px solid #eee;
27
+ box-shadow: 1px 1px 2px #eee;
28
+ background-color: white;
29
+ background-image: url(../../images/prpayment/lens.png);
30
+ background-position: 98% 5%;
31
+ background-repeat: no-repeat;
32
+ }
33
+ .payrandom-price-full .payrandom-price-full-left { width: 35%; float: left; padding: 20px 5px 10px 10px; }
34
+ .payrandom-price-full .payrandom-price-full-right { padding-top: 20px; padding-right: 20px; width: 50%; float: right; }
35
+ .payrandom-price-full .payrandom-price-full-left-header{ font-size: 1.2em; color: #565656; font-family: helvetica, arial, sans-serif;}
36
+ .payrandom-price-full .payrandom-price-full-left-price{ font-weight: bold; font-size: 1.8em; color: #f18000; font-family: helvetica, arial, sans-serif;}
37
+
38
+
39
+ .payrandom-price-full .payrandom-price-full-left .payrandom-price-full-left-howitworks{
40
+ color: #3498D4;
41
+ text-decoration: underline;
42
+ }
43
+
44
+ .payrandom-price-full .payrandom-price-full-bottom { clear: both; }
45
+
46
+ .payrandom-price { margin-top: 5px;}
47
+ .payrandom-price .payrandom-price-label { color: #cc4c2d; white-space:nowrap; font-weight:bold; }
48
+ .payrandom-price .payrandom-price-element { color: #cc4c2d; float: right;}
49
+
50
+ .payrandom-price-from-to { margin-top: 5px;}
51
+ .payrandom-price-from-to .payrandom-price-from-to-label { color: #999; white-space:nowrap; }
52
+ .payrandom-price-from-to .payrandom-price-from-to-element { color: #cc4c2d; font-weight:bold;}
53
+
54
+ .payrandom-modalbox {
55
+ font-family: helvetica, arial, sans-serif;
56
+ position: fixed;
57
+ top: 30%;
58
+ width: 500px;
59
+ height: 340px;
60
+
61
+ border: 1px solid #3498d4;
62
+ border-top: 1px solid #3498d4;
63
+
64
+ background-color: #f7fbfe;
65
+ z-index:1002;
66
+ overflow: auto;
67
+
68
+ box-shadow: 1px 1px 5px #888;
69
+ }
70
+
71
+ .payrandom-modalbox img{
72
+ border: none !important;
73
+ }
74
+ .payrandom-modalbox .payrandom-modalbox-header {
75
+ padding: 10px 5px 10px 20px;
76
+ background-color: #3498d4;
77
+ }
78
+
79
+
80
+ .payrandom-modalbox .payrandom-modalbox-close {
81
+ float: right;
82
+ }
83
+
84
+ .payrandom-modalbox .payrandom-modalbox-content {
85
+ padding: 16px;
86
+ font-weight: bold;
87
+ font-size: 14px;
88
+ line-height: 1.2em;
89
+ color: #5d5d5d;
90
+ }
91
+
92
+ .payrandom-modalbox .payrandom-modalbox-content .payrandom-modalbox-content-divimg {
93
+ float: left;
94
+ width: 250px;
95
+ margin-right: 10px;
96
+ }
97
+
98
+ .payrandom-modalbox .payrandom-modalbox-content .payrandom-modalbox-h2 {
99
+ color: #3397d2;
100
+ font-weight: bold;
101
+ font-size: 20px;
102
+ }
103
+
104
+ .payrandom-modalbox .payrandom-modalbox-content .payrandom-modalbox-howitworks{
105
+ color: #3498D4;
106
+ }
107
+
skin/frontend/base/default/images/prpayment/help.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/information_excl.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/information_question.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/lens.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr_150.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr_min.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr_small.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr_white.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/logo_pr_white_small.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/modalbox/close.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/modalbox/roulette.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/modalbox/video.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/roulette.png ADDED
Binary file
skin/frontend/base/default/images/prpayment/roulette_2.png ADDED
Binary file
skin/frontend/base/default/js/prpayment/prpayment.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function prPaymentOpenHelp(id){
2
+ $("payrandom-modalbox-info-" + id).appear({ duration: 0.3 }).centerHorizontally().centerVertically();
3
+ }
4
+
5
+ function prPaymentCloseHelp(id){
6
+ new Effect.DropOut("payrandom-modalbox-info-" + id);
7
+ $("payrandom-video-" + id).hide();
8
+ $("payrandom-maincontent-" + id).show();
9
+ }
10
+
11
+ Element.addMethods({
12
+ centerHorizontally: function(element) {
13
+ if (!(element = $(element))) return;
14
+
15
+ var vpWidth = $(document).viewport.getWidth();
16
+ var width = element.getWidth();
17
+
18
+ element.style.left = (vpWidth / 2) - (width / 2) + 'px';
19
+ return element;
20
+ },
21
+ centerVertically: function(element) {
22
+ if (!(element = $(element))) return;
23
+
24
+ var vpHeight = $(document).viewport.getHeight();
25
+ var height = element.getLayout().get('margin-box-height');
26
+
27
+ var avTop = (vpHeight / 2) - (height / 2);
28
+
29
+ if (avTop <= 10)
30
+ avTop = 10;
31
+
32
+ element.style.top = avTop+ 'px';
33
+ return element;
34
+ }
35
+ });