Payment_Reembolso - Version 0.2.0

Version Notes

CHANGES:
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso.php
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Grid.php
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit.php
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tabs.php
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Form.php
->A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tab/Form.php
->A app/code/local/Mage/Reembolso/controllers/Adminhtml/ReembolsoController.php
->U app/code/local/Mage/Reembolso/etc/config.xml
->U app/code/local/Mage/Reembolso/etc/system.xml
->A app/code/local/Mage/Reembolso/Model/Adminhtml/Status.php
->A app/code/local/Mage/Reembolso/Model/Adminhtml/Reembolso.php
->A app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso.php
->A app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso/Collection.php
->U app/code/local/Mage/Reembolso/Model/Quote.php
->U app/code/local/Mage/Reembolso/Model/Reembolso.php
->A app/code/local/Mage/Reembolso/sql/reembolso_setup/mysql4-install-0.1.0.php
->U app/design/frontend/default/default/template/reembolso/form.phtml
->U app/design/frontend/default/default/template/reembolso/info.phtml
->U app/design/adminhtml/default/default/layout/reembolso.xml

Download this release

Release Info

Developer Magento Core Team
Extension Payment_Reembolso
Version 0.2.0
Comparing to
See all releases


Code changes from version 0.1.5 to 0.2.0

Files changed (29) hide show
  1. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso.php +12 -0
  2. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit.php +45 -0
  3. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Form.php +20 -0
  4. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tab/Form.php +67 -0
  5. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tabs.php +24 -0
  6. app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Grid.php +132 -0
  7. app/code/local/Mage/Reembolso/Block/Form.php +1 -0
  8. app/code/local/Mage/Reembolso/Block/Info.php +1 -0
  9. app/code/local/Mage/Reembolso/Block/Reembolso.php +22 -0
  10. app/code/local/Mage/Reembolso/Helper/Data.php +4 -1
  11. app/code/local/Mage/Reembolso/INFO-reembolso.txt +20 -0
  12. app/code/local/Mage/Reembolso/Model/Adminhtml/Reembolso.php +8 -0
  13. app/code/local/Mage/Reembolso/Model/Adminhtml/Status.php +12 -0
  14. app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso.php +10 -0
  15. app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso/Collection.php +79 -0
  16. app/code/local/Mage/Reembolso/Model/Quote.php +6 -31
  17. app/code/local/Mage/Reembolso/Model/Reembolso.php +49 -31
  18. app/code/local/Mage/Reembolso/controllers/Adminhtml/ReembolsoController.php +188 -0
  19. app/code/local/Mage/Reembolso/controllers/IndexController.php +47 -0
  20. app/code/local/Mage/Reembolso/etc/config.xml +147 -60
  21. app/code/local/Mage/Reembolso/etc/system.xml +0 -52
  22. app/code/local/Mage/Reembolso/sql/reembolso_setup/mysql4-install-0.1.0.php +22 -0
  23. app/design/adminhtml/default/default/layout/reembolso.xml +8 -0
  24. app/design/adminhtml/default/default/template/reembolso/form.phtml +9 -7
  25. app/design/adminhtml/default/default/template/reembolso/info.phtml +4 -1
  26. app/design/frontend/default/default/template/reembolso/form.phtml +9 -1
  27. app/design/frontend/default/default/template/reembolso/info.phtml +5 -4
  28. app/etc/modules/Reembolso.xml +0 -5
  29. package.xml +28 -16
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ class Mage_Reembolso_Block_Adminhtml_Reembolso extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_reembolso';
7
+ $this->_blockGroup = 'reembolso';
8
+ $this->_headerText = Mage::helper('reembolso')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('reembolso')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit.php ADDED
@@ -0,0 +1,45 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Block_Adminhtml_Reembolso_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'reembolso';
11
+ $this->_controller = 'adminhtml_reembolso';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('reembolso')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('reembolso')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('reembolso_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'reembolso_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'reembolso_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('reembolso_data') && Mage::registry('reembolso_data')->getId() ) {
40
+ return Mage::helper('reembolso')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('reembolso_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('reembolso')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Block_Adminhtml_Reembolso_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+
18
+ return parent::_prepareForm();
19
+ }
20
+ }
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tab/Form.php ADDED
@@ -0,0 +1,67 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Block_Adminhtml_Reembolso_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+
10
+ $fieldset = $form->addFieldset('reembolso_form', array('legend'=>Mage::helper('reembolso')->__('Item information')));
11
+
12
+ $fieldset->addField('title', 'text', array(
13
+ 'label' => Mage::helper('reembolso')->__('Title'),
14
+ 'class' => 'required-entry',
15
+ 'required' => true,
16
+ 'name' => 'title',
17
+ ));
18
+
19
+ $fieldset->addField('above', 'text', array(
20
+ 'label' => Mage::helper('reembolso')->__('Above'),
21
+ 'class' => 'required-entry',
22
+ 'required' => true,
23
+ 'name' => 'above',
24
+ ));
25
+
26
+ $fieldset->addField('shipping_method', 'select', array(
27
+ 'label' => Mage::helper('reembolso')->__('Shipping Methods'),
28
+ 'name' => 'shipping_method',
29
+ 'values' => Mage::getResourceModel('reembolso/reembolso_collection')->getShippingMethods(),
30
+ 'selected' => 'flatrate',
31
+ ));
32
+
33
+ Mage::log(Mage::helper('reembolso')->__('Shipping Methods'));
34
+
35
+ $fieldset->addField('type', 'select', array(
36
+ 'label' => Mage::helper('reembolso')->__('Type'),
37
+ 'name' => 'type',
38
+ 'values' => array(
39
+ array(
40
+ 'value' => 1,
41
+ 'label' => Mage::helper('reembolso')->__('Fixed'),
42
+ ),
43
+
44
+ array(
45
+ 'value' => 2,
46
+ 'label' => Mage::helper('reembolso')->__('Percent'),
47
+ ),
48
+ ),
49
+ ));
50
+
51
+ $fieldset->addField('value', 'text', array(
52
+ 'label' => Mage::helper('reembolso')->__('Value'),
53
+ 'class' => 'required-entry',
54
+ 'required' => true,
55
+ 'name' => 'value',
56
+ ));
57
+ //Mage::log(Mage::registry('reembolso_data')->getData());
58
+ if ( Mage::getSingleton('adminhtml/session')->getReembolsoData() )
59
+ {
60
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getReembolsoData());
61
+ Mage::getSingleton('adminhtml/session')->setReembolsoData(null);
62
+ } elseif ( Mage::registry('reembolso_data') ) {
63
+ $form->setValues(Mage::registry('reembolso_data')->getData());
64
+ }
65
+ return parent::_prepareForm();
66
+ }
67
+ }
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Block_Adminhtml_Reembolso_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('reembolso_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('reembolso')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('reembolso')->__('Item Information'),
18
+ 'title' => Mage::helper('reembolso')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('reembolso/adminhtml_reembolso_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Grid.php ADDED
@@ -0,0 +1,132 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Block_Adminhtml_Reembolso_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('reembolsoGrid');
9
+ $this->setDefaultSort('reembolso_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('reembolso/adminhtml_reembolso')->getCollection()->prepareSummary();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('reembolso_id', array(
24
+ 'header' => Mage::helper('reembolso')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'reembolso_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('reembolso')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ $this->addColumn('above', array(
37
+ 'header' => Mage::helper('reembolso')->__('Above'),
38
+ 'align' =>'left',
39
+ 'width' => '100px',
40
+ 'index' => 'above',
41
+ ));
42
+
43
+ $this->addColumn('shipping_method', array(
44
+ 'header' => Mage::helper('reembolso')->__('Shipping Method'),
45
+ 'align' => 'left',
46
+ 'width' => '150px',
47
+ 'index' => 'shipping_method',
48
+ 'type' => 'options',
49
+ 'options' => Mage::getResourceModel('reembolso/reembolso_collection')->getShippingMethods(),
50
+ ));
51
+
52
+ $this->addColumn('type', array(
53
+ 'header' => Mage::helper('reembolso')->__('Type'),
54
+ 'align' => 'left',
55
+ 'width' => '100px',
56
+ 'index' => 'type',
57
+ 'type' => 'options',
58
+ 'options' => array(
59
+ 1 => 'Fixed',
60
+ 2 => 'Percent',
61
+ ),
62
+ ));
63
+
64
+ $this->addColumn('value', array(
65
+ 'header' => Mage::helper('reembolso')->__('Value'),
66
+ 'align' =>'left',
67
+ 'width' => '100px',
68
+ 'index' => 'value',
69
+ 'type' => 'number',
70
+ ));
71
+
72
+ $this->addColumn('action',
73
+ array(
74
+ 'header' => Mage::helper('reembolso')->__('Action'),
75
+ 'width' => '100',
76
+ 'type' => 'action',
77
+ 'getter' => 'getReembolsoId',
78
+ 'actions' => array(
79
+ array(
80
+ 'caption' => Mage::helper('reembolso')->__('Edit'),
81
+ 'url' => array('base'=> '*/*/edit'),
82
+ 'field' => 'i'
83
+ )
84
+ ),
85
+ 'filter' => false,
86
+ 'sortable' => false,
87
+ 'index' => 'stores',
88
+ 'is_system' => true,
89
+ ));
90
+
91
+ $this->addExportType('*/*/exportCsv', Mage::helper('reembolso')->__('CSV'));
92
+ $this->addExportType('*/*/exportXml', Mage::helper('reembolso')->__('XML'));
93
+
94
+ return parent::_prepareColumns();
95
+ }
96
+
97
+ protected function _prepareMassaction()
98
+ {
99
+ $this->setMassactionIdField('reembolso_id');
100
+ $this->getMassactionBlock()->setFormFieldName('reembolso');
101
+
102
+ $this->getMassactionBlock()->addItem('delete', array(
103
+ 'label' => Mage::helper('reembolso')->__('Delete'),
104
+ 'url' => $this->getUrl('*/*/massDelete'),
105
+ 'confirm' => Mage::helper('reembolso')->__('Are you sure?')
106
+ ));
107
+
108
+ $statuses = Mage::getSingleton('reembolso/adminhtml_status')->getOptionArray();
109
+
110
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
111
+ $this->getMassactionBlock()->addItem('status', array(
112
+ 'label'=> Mage::helper('reembolso')->__('Change status'),
113
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
114
+ 'additional' => array(
115
+ 'visibility' => array(
116
+ 'name' => 'status',
117
+ 'type' => 'select',
118
+ 'class' => 'required-entry',
119
+ 'label' => Mage::helper('reembolso')->__('Status'),
120
+ 'values' => $statuses
121
+ )
122
+ )
123
+ ));
124
+ return $this;
125
+ }
126
+
127
+ public function getRowUrl($row)
128
+ {
129
+ return $this->getUrl('*/*/edit', array('id' => $row->getReembolsoId()));
130
+ }
131
+
132
+ }
app/code/local/Mage/Reembolso/Block/Form.php CHANGED
@@ -2,6 +2,7 @@
2
class Mage_Reembolso_Block_Form extends Mage_Payment_Block_Form {
3
4
protected function _construct() {
5
parent::_construct();
6
$this->setTemplate('reembolso/form.phtml');
7
}
2
class Mage_Reembolso_Block_Form extends Mage_Payment_Block_Form {
3
4
protected function _construct() {
5
+ Mage::log('Form de reembolso');
6
parent::_construct();
7
$this->setTemplate('reembolso/form.phtml');
8
}
app/code/local/Mage/Reembolso/Block/Info.php CHANGED
@@ -2,6 +2,7 @@
2
class Mage_Reembolso_Block_Info extends Mage_Payment_Block_Info {
3
4
protected function _construct() {
5
parent::_construct();
6
$this->setTemplate('reembolso/info.phtml');
7
}
2
class Mage_Reembolso_Block_Info extends Mage_Payment_Block_Info {
3
4
protected function _construct() {
5
+ Mage::log('Info de reembolso');
6
parent::_construct();
7
$this->setTemplate('reembolso/info.phtml');
8
}
app/code/local/Mage/Reembolso/Block/Reembolso.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ class Mage_Reembolso_Block_Reembolso extends Mage_Core_Block_Template
3
+ {
4
+
5
+ public function _construct(){
6
+ Mage::log(__FILE__);
7
+ }
8
+
9
+ public function _prepareLayout()
10
+ {
11
+ return parent::_prepareLayout();
12
+ }
13
+
14
+ public function getReembolso()
15
+ {
16
+ if (!$this->hasData('reembolso')) {
17
+ $this->setData('reembolso', Mage::registry('reembolso'));
18
+ }
19
+ return $this->getData('reembolso');
20
+
21
+ }
22
+ }
app/code/local/Mage/Reembolso/Helper/Data.php CHANGED
@@ -1,3 +1,6 @@
1
<?php
2
- class Mage_Reembolso_Helper_Data extends Mage_Core_Helper_Data {
3
}
1
<?php
2
+
3
+ class Mage_Reembolso_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
}
app/code/local/Mage/Reembolso/INFO-reembolso.txt ADDED
@@ -0,0 +1,20 @@
1
+ ES | Reembolso permite configurar los reembolsos de todos los metodos de envio que tengamos instalados en nuestra tienda Magento. Reembolso calcula el valor que se debe abonar mediante este m�todo de pago. Por cada reembolso se debe ingresar un titulo, el metodo de envio al cual se le va a aplicar el reembolso, el tipo (si es fijo o variable), el valor del reembolso y el importe a partir del cual se va a seleccionar que valor se le aplica al monto final.
2
+
3
+ EN | Refund allows users to set up refunds for all shipping methods installed in our Magento store. Refund determines the value the user must pay by using this payment method. For each refund you must enter a title, the refund shipping method, the refund type (either fixed or variable), the refund value and the amount from which the value applied to the total amount will be selected.
4
+
5
+
6
+ 0.2.0
7
+
8
+ * Create Module - Reembolso
9
+
10
+ <b>DEFAULT:</b>
11
+ app/code/local/Mage/Reembolso/Block/
12
+ app/code/local/Mage/Reembolso/etc/
13
+ app/code/local/Mage/Reembolso/controllers/
14
+ app/code/local/Mage/Reembolso/Helper/
15
+ app/code/local/Mage/Reembolso/Model/
16
+ app/code/local/Mage/Reembolso/sql/
17
+ app/design/frontend/default/default/template/reembolso/
18
+ app/design/adminhtml/default/default/template/reembolso
19
+ app/design/adminhtml/default/default/layout/reembolso.xml
20
+ app/etc/Modules/Reembolso.xml
app/code/local/Mage/Reembolso/Model/Adminhtml/Reembolso.php ADDED
@@ -0,0 +1,8 @@
1
+ <?php
2
+ class Mage_Reembolso_Model_Adminhtml_Reembolso extends Mage_Core_Model_Abstract {
3
+
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->_init('reembolso/reembolso');
7
+ }
8
+ }
app/code/local/Mage/Reembolso/Model/Adminhtml/Status.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ class Mage_Reembolso_Model_Adminhtml_Status extends Varien_Object {
3
+ const STATUS_ENABLED = 1;
4
+ const STATUS_DISABLED = 2;
5
+
6
+ static public function getOptionArray() {
7
+ return array(
8
+ self::STATUS_ENABLED => Mage::helper('reembolso')->__('Enabled'),
9
+ self::STATUS_DISABLED => Mage::helper('reembolso')->__('Disabled')
10
+ );
11
+ }
12
+ }
app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso.php ADDED
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Model_Mysql4_Reembolso extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the reembolso_id refers to the key field in your database table.
8
+ $this->_init('reembolso/reembolso', 'reembolso_id');
9
+ }
10
+ }
app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso/Collection.php ADDED
@@ -0,0 +1,79 @@
1
+ <?php
2
+ class Mage_Reembolso_Model_Mysql4_Reembolso_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('reembolso/reembolso');
8
+ }
9
+
10
+ public function prepareSummary(){
11
+ $this->setConnection($this->getResource()->getReadConnection());
12
+ $this->getSelect()
13
+ ->from(array('main_table'=>$this->getTable('reembolso')),array(
14
+ 'reembolso_id',
15
+ 'title',
16
+ 'shipping_method',
17
+ 'type',
18
+ 'value',
19
+ 'above',
20
+ ))
21
+ ->group(array('reembolso_id'));
22
+ return $this;
23
+ }
24
+
25
+ public function getShippingMethods(){
26
+ $keys=array();
27
+ foreach(Mage::getModel('adminhtml/system_config_source_shipping_allmethods')->toOptionArray() as $key=>$method){
28
+ $keys[$key.'_'.$key] = $method['label'];
29
+ }
30
+ return $keys;
31
+ }
32
+
33
+
34
+ // ----------------------------------
35
+
36
+
37
+ public function getMethodPayment($shipping=null,$total=null){
38
+ /* el $shipping trae el metodo de envio y el $total trae el total de la compra
39
+ para saber que metodo se debe asignar, segun el above de la DB */
40
+ $datos = array();
41
+ $datos['error'] = false;
42
+ $items = array();
43
+
44
+ if($shipping === null) return ;
45
+ if($total === null) return ;
46
+
47
+ $this
48
+ ->addFieldToFilter('shipping_method',$shipping)
49
+ ->addFieldToFilter('above',array('lt'=>$total))
50
+ ->getSelect()
51
+ ->order('above DESC');
52
+
53
+ $items = $this->getItems();
54
+
55
+ if(empty($items)){
56
+ $datos['error'] = true;
57
+ return $datos;
58
+ }
59
+
60
+ $datos['id'] = $items[0]->getData('reembolso_id');
61
+ $datos['title'] = $items[0]->getData('title');
62
+ $datos['shipping'] = $items[0]->getData('shipping_method');
63
+ $datos['type'] = $items[0]->getData('type');
64
+ $datos['value'] = $items[0]->getData('value');
65
+
66
+ if($datos['type'] == 1){ // 1=>'Fixed' - 2=>'Percent'
67
+ $total_envio = $datos['value'];
68
+ $total_final = $total + $datos['value'];
69
+ } else {
70
+ $total_envio = ($total * ($datos['value']/100));
71
+ $total_final = $total + ($total * $datos['value']/100);
72
+ }
73
+ $datos['total_shipping'] = $total_envio;
74
+ $datos['total'] = $total_final;
75
+
76
+ return $datos;
77
+ }
78
+
79
+ }
app/code/local/Mage/Reembolso/Model/Quote.php CHANGED
@@ -1,46 +1,21 @@
1
<?php
2
class Mage_Reembolso_Model_Quote extends Mage_Sales_Model_Quote {
3
4
- public function getAmount() {
5
- $totals = parent::getTotals();
6
- // Tomo el valor de la compra....
7
- $subtotal = $this->getSubTotalAmount();
8
- $valores = Mage::getModel('reembolso/reembolso');
9
-
10
- // Tomo el valor tope contra el cual comparar...
11
- $val = $valores->getValorTope();
12
- if($subtotal < $val){
13
- // Si el valor inferior es fijo.....
14
- if($valores->getValInfFix() == '1'){
15
- $amount = $valores->getValorInferior();
16
- // Si el velor inferior es porcentaje....
17
- } else {
18
- $amount = ($subtotal * $valores->getValorInferior()) / 100;
19
- }
20
- } else {
21
- if($valores->getValSupFix() == '1'){
22
- $amount = $valores->getValorSuperior();
23
- }else{
24
- $amount = ($subtotal * $valores->getValorSuperior()) /100;
25
- }
26
- }
27
- return $amount;
28
- }
29
-
30
-
31
- public function getTotals() {
32
$res = parent::getTotals();
33
-
34
if (isset($res['shipping']) && is_object($res['shipping'])) {
35
if (!is_null($this->_payments) && $this->getPayment()->hasMethodInstance() && $this->getPayment()->getMethodInstance()->getCode() == 'reembolso') {
36
$model = Mage::getModel('reembolso/reembolso');
37
$res['shipping']->setData('title',$res['shipping']->getData('title') . ' + ' . $model->getReembolsoTitle());
38
}
39
}
40
return $res;
41
}
42
43
public function collectTotals() {
44
$res = parent::collectTotals();
45
$sum_amount = 0;
46
@@ -48,8 +23,8 @@ class Mage_Reembolso_Model_Quote extends Mage_Sales_Model_Quote {
48
foreach ($res->getAllShippingAddresses() as $address) {
49
50
$this->setSubTotalAmount($address->getGrandTotal() - $address->getShippingAmount());
51
- $sum_amount = $this->getAmount();
52
-
53
$address->setShippingAmount($address->getShippingAmount() + $address->getShippingTaxAmount() + $sum_amount);
54
$address->setBaseShippingAmount($address->getBaseShippingAmount() + $address->getBaseShippingTaxAmount() + $sum_amount);
55
1
<?php
2
class Mage_Reembolso_Model_Quote extends Mage_Sales_Model_Quote {
3
4
+ public function getTotals() {
5
$res = parent::getTotals();
6
if (isset($res['shipping']) && is_object($res['shipping'])) {
7
if (!is_null($this->_payments) && $this->getPayment()->hasMethodInstance() && $this->getPayment()->getMethodInstance()->getCode() == 'reembolso') {
8
$model = Mage::getModel('reembolso/reembolso');
9
$res['shipping']->setData('title',$res['shipping']->getData('title') . ' + ' . $model->getReembolsoTitle());
10
}
11
}
12
+
13
return $res;
14
}
15
16
public function collectTotals() {
17
+ // tomo todos los datos del metodo de envio
18
+ $model = Mage::getModel('reembolso/reembolso')->getShippMethod();
19
$res = parent::collectTotals();
20
$sum_amount = 0;
21
23
foreach ($res->getAllShippingAddresses() as $address) {
24
25
$this->setSubTotalAmount($address->getGrandTotal() - $address->getShippingAmount());
26
+ $sum_amount = $model['total_shipping'];
27
+
28
$address->setShippingAmount($address->getShippingAmount() + $address->getShippingTaxAmount() + $sum_amount);
29
$address->setBaseShippingAmount($address->getBaseShippingAmount() + $address->getBaseShippingTaxAmount() + $sum_amount);
30
app/code/local/Mage/Reembolso/Model/Reembolso.php CHANGED
@@ -2,39 +2,57 @@
2
class Mage_Reembolso_Model_Reembolso extends Mage_Payment_Model_Method_Abstract {
3
4
protected $_code = 'reembolso';
5
-
6
protected $_formBlockType = 'reembolso/form';
7
protected $_infoBlockType = 'reembolso/info';
8
-
9
- public function getReembolsoTitle(){
10
- return $this->getConfigData('title');
11
- }
12
-
13
- public function getValorTope(){
14
- return $this->getConfigData('montotope');
15
- }
16
-
17
- public function getValorInferior(){
18
- return $this->getConfigData('valorinferior');
19
- }
20
-
21
- public function getValorSuperior(){
22
- return $this->getConfigData('valorsuperior');
23
}
24
25
- public function getValInfFix() {
26
- return $this->getConfigData('valinffix');
27
- }
28
-
29
- public function getValSupFix(){
30
- return $this->getConfigData('valsupfix');
31
- }
32
-
33
- public function getCustomTextForm(){
34
- return $this->getConfigData('customtextform');
35
- }
36
-
37
- public function getCustomTextInfo(){
38
- return $this->getConfigData('customtextinfo');
39
- }
40
}
2
class Mage_Reembolso_Model_Reembolso extends Mage_Payment_Model_Method_Abstract {
3
4
protected $_code = 'reembolso';
5
+
6
protected $_formBlockType = 'reembolso/form';
7
protected $_infoBlockType = 'reembolso/info';
8
+
9
+ public function isAvailable($quote=null){
10
+ $allow = true;
11
+ $data = $this->getShippMethod();
12
+
13
+ Mage::log('Error: '.$data['title']);
14
+ if($data['error']) $allow = false;
15
+ return $allow;
16
+ }
17
+
18
+ // Tomar todos los datos desde los parametros almacenados en la DB
19
+
20
+ public function getShippMethod(){
21
+ $quote = Mage::getModel('checkout/session')->getQuote();
22
+ $ids = array();
23
+ $data = array();
24
+ // trae el Metodo de envio
25
+ foreach($quote->getAllShippingAddresses() as $addr){
26
+ array_push($ids,$addr->getShippingMethod());
27
+ }
28
+
29
+ // se agrega esta linea porque si no esta instanciado el Chek Out no encuentra ningun ShippingMethod y da error
30
+ if(empty($ids)) $ids[0] = 1;
31
+
32
+ // trae el total de la compra
33
+ $subtotal = $quote->getTotals();
34
+ // traigo todos los datos del metodo de envio
35
+ $data = Mage::getModel('reembolso/adminhtml_reembolso')->getResourceCollection()->getMethodPayment($ids[0],$subtotal['subtotal']->getData('value'));
36
+
37
+ // esto no lo usa. Si el metodo no esta definido en la DB, no muestra el contrarembolso (isAvailable)
38
+ if($data['error']){
39
+ $data['id'] = 0;
40
+ $data['title'] = Mage::helper('adminhtml')->__('Sin definir');
41
+ $data['shipping'] = Mage::helper('adminhtml')->__('Sin definir');
42
+ $data['type'] = 1;
43
+ $data['value'] = 0;
44
+ $data['total_shipping'] = 0;
45
+ }
46
+ // ----------------------------------------------
47
+
48
+ return $data;
49
+ }
50
+
51
+ public function getReembolsoTitle(){
52
+ // aca tomo el titulo
53
+ $data = $this->getShippMethod();
54
+
55
+ return $data['title'];
56
}
57
58
}
app/code/local/Mage/Reembolso/controllers/Adminhtml/ReembolsoController.php ADDED
@@ -0,0 +1,188 @@
1
+ <?php
2
+
3
+ class Mage_Reembolso_Adminhtml_ReembolsoController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('reembolso/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('reembolso/adminhtml_reembolso')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('reembolso_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('reembolso/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('reembolso/adminhtml_reembolso_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('reembolso/adminhtml_reembolso_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reembolso')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+
57
+ $model = Mage::getModel('reembolso/adminhtml_reembolso');
58
+ $model->setData($data)
59
+ ->setId($this->getRequest()->getParam('id'));
60
+
61
+ try {
62
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
63
+ $model->setCreatedTime(now())
64
+ ->setUpdateTime(now());
65
+ } else {
66
+ $model->setUpdateTime(now());
67
+ }
68
+
69
+ $model->save();
70
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reembolso')->__('Item was successfully saved'));
71
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
72
+
73
+ if ($this->getRequest()->getParam('back')) {
74
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
75
+ Mage::log('PLease: '.$this->_redirect('*/*/edit', array('id' => $model->getId())));
76
+ return;
77
+ }
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ } catch (Exception $e) {
81
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
82
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
83
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
84
+ return;
85
+ }
86
+ }
87
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reembolso')->__('Unable to find item to save'));
88
+ $this->_redirect('*/*/');
89
+ }
90
+
91
+ public function deleteAction() {
92
+ if( $this->getRequest()->getParam('id') > 0 ) {
93
+ try {
94
+ $model = Mage::getModel('reembolso/adminhtml_reembolso');
95
+
96
+ $model->setId($this->getRequest()->getParam('id'))
97
+ ->delete();
98
+
99
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
100
+ $this->_redirect('*/*/');
101
+ } catch (Exception $e) {
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
104
+ }
105
+ }
106
+ $this->_redirect('*/*/');
107
+ }
108
+
109
+ public function massDeleteAction() {
110
+ $reembolsoIds = $this->getRequest()->getParam('reembolso');
111
+ if(!is_array($reembolsoIds)) {
112
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
113
+ } else {
114
+ try {
115
+ foreach ($reembolsoIds as $reembolsoId) {
116
+ $reembolso = Mage::getModel('reembolso/adminhtml_reembolso')->load($reembolsoId);
117
+ $reembolso->delete();
118
+ }
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(
120
+ Mage::helper('adminhtml')->__(
121
+ 'Total of %d record(s) were successfully deleted', count($reembolsoIds)
122
+ )
123
+ );
124
+ } catch (Exception $e) {
125
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
126
+ }
127
+ }
128
+ $this->_redirect('*/*/index');
129
+ }
130
+
131
+ public function massStatusAction()
132
+ {
133
+ $reembolsoIds = $this->getRequest()->getParam('reembolso');
134
+ if(!is_array($reembolsoIds)) {
135
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
136
+ } else {
137
+ try {
138
+ foreach ($reembolsoIds as $reembolsoId) {
139
+ $reembolso = Mage::getSingleton('reembolso/reembolso')
140
+ ->load($reembolsoId)
141
+ ->setStatus($this->getRequest()->getParam('status'))
142
+ ->setIsMassupdate(true)
143
+ ->save();
144
+ }
145
+ $this->_getSession()->addSuccess(
146
+ $this->__('Total of %d record(s) were successfully updated', count($reembolsoIds))
147
+ );
148
+ } catch (Exception $e) {
149
+ $this->_getSession()->addError($e->getMessage());
150
+ }
151
+ }
152
+ $this->_redirect('*/*/index');
153
+ }
154
+
155
+ public function exportCsvAction()
156
+ {
157
+ $fileName = 'reembolso.csv';
158
+ $content = $this->getLayout()->createBlock('reembolso/adminhtml_reembolso_grid')
159
+ ->getCsv();
160
+
161
+ $this->_sendUploadResponse($fileName, $content);
162
+ }
163
+
164
+ public function exportXmlAction()
165
+ {
166
+ $fileName = 'reembolso.xml';
167
+ $content = $this->getLayout()->createBlock('reembolso/adminhtml_reembolso_grid')
168
+ ->getXml();
169
+
170
+ $this->_sendUploadResponse($fileName, $content);
171
+ }
172
+
173
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
174
+ {
175
+ $response = $this->getResponse();
176
+ $response->setHeader('HTTP/1.1 200 OK','');
177
+ $response->setHeader('Pragma', 'public', true);
178
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
179
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
180
+ $response->setHeader('Last-Modified', date('r'));
181
+ $response->setHeader('Accept-Ranges', 'bytes');
182
+ $response->setHeader('Content-Length', strlen($content));
183
+ $response->setHeader('Content-type', $contentType);
184
+ $response->setBody($content);
185
+ $response->sendResponse();
186
+ die;
187
+ }
188
+ }
app/code/local/Mage/Reembolso/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
1
+ <?php
2
+ class Mage_Reembolso_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/reembolso?id=15
11
+ * or
12
+ * http://site.com/reembolso/id/15
13
+ */
14
+ /*
15
+ $reembolso_id = $this->getRequest()->getParam('id');
16
+
17
+ if($reembolso_id != null && $reembolso_id != '') {
18
+ $reembolso = Mage::getModel('reembolso/reembolso')->load($reembolso_id)->getData();
19
+ } else {
20
+ $reembolso = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($reembolso == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $reembolsoTable = $resource->getTableName('reembolso');
32
+
33
+ $select = $read->select()
34
+ ->from($reembolsoTable,array('reembolso_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $reembolso = $read->fetchRow($select);
39
+ }
40
+ Mage::register('reembolso', $reembolso);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Mage/Reembolso/etc/config.xml CHANGED
@@ -1,61 +1,148 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <global>
4
- <models>
5
- <reembolso>
6
- <class>Mage_Reembolso_Model</class>
7
- </reembolso>
8
- <sales>
9
- <rewrite>
10
- <quote>Mage_Reembolso_Model_Quote</quote>
11
- </rewrite>
12
- </sales>
13
- </models>
14
-
15
- <resources>
16
- <reembolso_setup>
17
- <setup>
18
- <module>Mage_Reembolso</module>
19
- </setup>
20
- <connection>
21
- <use>core_setup</use>
22
- </connection>
23
- </reembolso_setup>
24
- <reembolso_write>
25
- <use>core_write</use>
26
- </reembolso_write>
27
- <reembolso_read>
28
- <use>core_read</use>
29
- </reembolso_read>
30
- </resources>
31
- </global>
32
-
33
- <adminhtml>
34
- <translate>
35
- <modules>
36
- <Mage_Reembolso>
37
- <files>
38
- <default>Mage_Reembolso.csv</default>
39
- </files>
40
- </Mage_Reembolso>
41
- </modules>
42
- </translate>
43
- </adminhtml>
44
-
45
- <default>
46
- <payment>
47
- <reembolso>
48
- <active>1</active>
49
- <model>reembolso/reembolso</model>
50
- <order_status>1</order_status>
51
- <title>Reembolso</title>
52
- <allowspecific>0</allowspecific>
53
- <valorinferior>3</valorinferior>
54
- <valinffix>1</valinffix>
55
- <valorsuperior>3</valorsuperior>
56
- <valsupfix>0</valsupfix>
57
- <montotope>100</montotope>
58
- </reembolso>
59
- </payment>
60
- </default>
61
</config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mage_Reembolso>
5
+ <version>0.1.0</version>
6
+ </Mage_Reembolso>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <sales>
12
+ <rewrite>
13
+ <quote>Mage_Reembolso_Model_Quote</quote>
14
+ </rewrite>
15
+ </sales>
16
+ <reembolso>
17
+ <class>Mage_Reembolso_Model</class>
18
+ <resourceModel>reembolso_mysql4</resourceModel>
19
+ </reembolso>
20
+ <reembolso_mysql4>
21
+ <class>Mage_Reembolso_Model_Mysql4</class>
22
+ <entities>
23
+ <reembolso>
24
+ <table>reembolso</table>
25
+ </reembolso>
26
+ </entities>
27
+ </reembolso_mysql4>
28
+ </models>
29
+ <resources>
30
+ <reembolso_setup>
31
+ <setup>
32
+ <module>Mage_Reembolso</module>
33
+ </setup>
34
+ <connection>
35
+ <use>core_setup</use>
36
+ </connection>
37
+ </reembolso_setup>
38
+ <reembolso_write>
39
+ <connection>
40
+ <use>core_write</use>
41
+ </connection>
42
+ </reembolso_write>
43
+ <reembolso_read>
44
+ <connection>
45
+ <use>core_read</use>
46
+ </connection>
47
+ </reembolso_read>
48
+ </resources>
49
+ <blocks>
50
+ <reembolso>
51
+ <class>Mage_Reembolso_Block</class>
52
+ </reembolso>
53
+ </blocks>
54
+ <helpers>
55
+ <reembolso>
56
+ <class>Mage_Reembolso_Helper</class>
57
+ </reembolso>
58
+ </helpers>
59
+ </global>
60
+
61
+ <frontend>
62
+ <routers>
63
+ <reembolso>
64
+ <use>standard</use>
65
+ <args>
66
+ <module>Mage_Reembolso</module>
67
+ <frontName>reembolso</frontName>
68
+ </args>
69
+ </reembolso>
70
+ </routers>
71
+ <layout>
72
+ <updates>
73
+ <reembolso>
74
+ <file>reembolso.xml</file>
75
+ </reembolso>
76
+ </updates>
77
+ </layout>
78
+ </frontend>
79
+
80
+ <admin>
81
+ <routers>
82
+ <reembolso>
83
+ <use>admin</use>
84
+ <args>
85
+ <module>Mage_Reembolso</module>
86
+ <frontName>reembolso</frontName>
87
+ </args>
88
+ </reembolso>
89
+ </routers>
90
+ </admin>
91
+
92
+ <adminhtml>
93
+ <menu>
94
+ <sales>
95
+ <children>
96
+ <tax>
97
+ <children>
98
+ <reembolso module="reembolso">
99
+ <title>Reembolso</title>
100
+ <sort_order>71</sort_order>
101
+ <action>reembolso/adminhtml_reembolso</action>
102
+ </reembolso>
103
+ </children>
104
+ </tax>
105
+ </children>
106
+ </sales>
107
+ </menu>
108
+ <acl>
109
+ <resources>
110
+ <all>
111
+ <title>Allow Everything</title>
112
+ </all>
113
+ <admin>
114
+ <children>
115
+ <Mage_Reembolso>
116
+ <title> Reembolso Module</title>
117
+ <sort_order>10</sort_order>
118
+ </Mage_Reembolso>
119
+ </children>
120
+ </admin>
121
+ </resources>
122
+ </acl>
123
+ <layout>
124
+ <updates>
125
+ <reembolso>
126
+ <file>reembolso.xml</file>
127
+ </reembolso>
128
+ </updates>
129
+ </layout>
130
+ </adminhtml>
131
+
132
+ <default>
133
+ <payment>
134
+ <reembolso>
135
+ <active>1</active>
136
+ <model>reembolso/reembolso</model>
137
+ <order_status>1</order_status>
138
+ <title>Reembolso</title>
139
+ <allowspecific>0</allowspecific>
140
+ <valorinferior>3</valorinferior>
141
+ <valinffix>1</valinffix>
142
+ <valorsuperior>3</valorsuperior>
143
+ <valsupfix>0</valsupfix>
144
+ <montotope>100</montotope>
145
+ </reembolso>
146
+ </payment>
147
+ </default>
148
</config>
app/code/local/Mage/Reembolso/etc/system.xml CHANGED
@@ -19,14 +19,6 @@
19
<show_in_website>1</show_in_website>
20
<show_in_store>0</show_in_store>
21
</active>
22
- <title translate="label">
23
- <label>Title</label>
24
- <frontend_type>text</frontend_type>
25
- <sort_order>20</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
- </title>
30
<order_status translate="label">
31
<label>New order status</label>
32
<frontend_type>select</frontend_type>
@@ -54,50 +46,6 @@
54
<show_in_website>1</show_in_website>
55
<show_in_store>1</show_in_store>
56
</specificcountry>
57
- <montotope translate="label">
58
- <label>Capture Amount</label>
59
- <frontend_type>text</frontend_type>
60
- <sort_order>60</sort_order>
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
- </montotope>
65
- <valorinferior translate="label">
66
- <label>Lower value</label>
67
- <frontend_type>text</frontend_type>
68
- <sort_order>70</sort_order>
69
- <show_in_default>1</show_in_default>
70
- <show_in_website>1</show_in_website>
71
- <show_in_store>0</show_in_store>
72
- </valorinferior>
73
- <valinffix translate="label comment">
74
- <label>Lower value fix</label>
75
- <comment>If NO is selected, the lower value is take in percent</comment>
76
- <frontend_type>select</frontend_type>
77
- <source_model>adminhtml/system_config_source_yesno</source_model>
78
- <sort_order>71</sort_order>
79
- <show_in_default>1</show_in_default>
80
- <show_in_website>1</show_in_website>
81
- <show_in_store>0</show_in_store>
82
- </valinffix>
83
- <valorsuperior translate="label">
84
- <label>Higher value</label>
85
- <frontend_type>text</frontend_type>
86
- <sort_order>80</sort_order>
87
- <show_in_default>1</show_in_default>
88
- <show_in_website>1</show_in_website>
89
- <show_in_store>0</show_in_store>
90
- </valorsuperior>
91
- <valsupfix translate="label comment">
92
- <label>Higher value fix</label>
93
- <comment>If NO is selected, the higher value is take in percent</comment>
94
- <frontend_type>select</frontend_type>
95
- <source_model>adminhtml/system_config_source_yesno</source_model>
96
- <sort_order>81</sort_order>
97
- <show_in_default>1</show_in_default>
98
- <show_in_website>1</show_in_website>
99
- <show_in_store>0</show_in_store>
100
- </valsupfix>
101
<customtextform translate="label">
102
<label>Custom text for checkout page in form</label>
103
<frontend_type>textarea</frontend_type>
19
<show_in_website>1</show_in_website>
20
<show_in_store>0</show_in_store>
21
</active>
22
<order_status translate="label">
23
<label>New order status</label>
24
<frontend_type>select</frontend_type>
46
<show_in_website>1</show_in_website>
47
<show_in_store>1</show_in_store>
48
</specificcountry>
49
<customtextform translate="label">
50
<label>Custom text for checkout page in form</label>
51
<frontend_type>textarea</frontend_type>
app/code/local/Mage/Reembolso/sql/reembolso_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('reembolso')};
10
+ CREATE TABLE {$this->getTable('reembolso')} (
11
+ `reembolso_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `shipping_method` varchar(255) NOT NULL default '',
14
+ `type` smallint(6) NOT NULL default '0',
15
+ `value` smallint(6) NOT NULL default '0',
16
+ `above` smallint(6) NOT NULL default '0',
17
+ PRIMARY KEY (`reembolso_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+
20
+ ");
21
+
22
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/reembolso.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <reembolso_adminhtml_reembolso_index>
4
+ <reference name="content">
5
+ <block type="reembolso/adminhtml_reembolso" name="reembolso" />
6
+ </reference>
7
+ </reembolso_adminhtml_reembolso_index>
8
+ </layout>
app/design/adminhtml/default/default/template/reembolso/form.phtml CHANGED
@@ -1,7 +1,9 @@
1
- <div id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
2
- <table>
3
- <tr>
4
- <td><?php echo $this->__('El pago ser&aacute; realizado en la direcci&oacute;n de destino') ?></td>
5
- </tr>
6
- </table>
7
- </div>
1
+ <ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none">
2
+ <li>
3
+ <div class="input-box">
4
+ <?php if ($this->getMethod()->getCustomText()): ?>
5
+ <?php echo $this->getMethod()->getCustomText() ?><br />
6
+ <?php endif; ?>
7
+ </div>
8
+ </li>
9
+ </ul>
app/design/adminhtml/default/default/template/reembolso/info.phtml CHANGED
@@ -1 +1,4 @@
1
- <p><?php echo $this->__('Pago contra reembolso') ?></p>
1
+ <?php echo $this->getMethod()->getTitle() ?><br /><br/>
2
+ <?php if ($this->getMethod()->getCustomText()): ?>
3
+ <?php echo $this->getMethod()->getCustomText() ?><br />
4
+ <?php endif; ?>
app/design/frontend/default/default/template/reembolso/form.phtml CHANGED
@@ -6,7 +6,15 @@
6
</tr>
7
<?php } else { ?>
8
<tr>
9
- <td><?php echo $this->__('El pago ser&aacute; realizado en la direcci&oacute;n de destino') ?></td>
10
</tr>
11
<?php } ?>
12
</table>
6
</tr>
7
<?php } else { ?>
8
<tr>
9
+ <td>
10
+ <?php
11
+ echo $this->__('El pago ser&aacute; realizado en la direcci&oacute;n de destino a traves de ');
12
+ echo $this->getMethod()->getReembolsoTitle() . ".";
13
+ $data = $this->getMethod()->getShippMethod();
14
+ echo "<br/><strong>".$this->__('Costo: ');
15
+ echo Mage::helper('checkout')->formatPrice($data['total_shipping'])."</strong>";
16
+ ?>
17
+ </td>
18
</tr>
19
<?php } ?>
20
</table>
app/design/frontend/default/default/template/reembolso/info.phtml CHANGED
@@ -1,5 +1,6 @@
1
- <p><?php echo $this->getMethod()->getReembolsoTitle() ?><br />
2
- <?php if ($this->getMethod()->getCustomTextInfo()): ?>
3
- <?php echo $this->getMethod()->getCustomTextInfo() ?><br />
4
- <?php endif; ?>
5
</p>
1
+ <p>
2
+ <?php echo $this->getMethod()->getReembolsoTitle() ?><br />
3
+ <?php if ($this->getMethod()->getCustomTextInfo()): ?>
4
+ <?php echo $this->getMethod()->getCustomTextInfo() ?><br />
5
+ <?php endif; ?>
6
</p>
app/etc/modules/Reembolso.xml CHANGED
@@ -1,5 +1,4 @@
1
<?xml version="1.0"?>
2
-
3
<config>
4
<modules>
5
<!-- declare Mage_Reembolso module -->
@@ -8,10 +7,6 @@
8
<active>true</active>
9
<!-- this module will be located in app/code/local code pool -->
10
<codePool>local</codePool>
11
- <!-- specify dependencies for correct module loading order -->
12
- <depends>
13
- <Mage_Payment />
14
- </depends>
15
<!-- declare module's version information for database updates -->
16
<version>0.1.0</version>
17
</Mage_Reembolso>
1
<?xml version="1.0"?>
2
<config>
3
<modules>
4
<!-- declare Mage_Reembolso module -->
7
<active>true</active>
8
<!-- this module will be located in app/code/local code pool -->
9
<codePool>local</codePool>
10
<!-- declare module's version information for database updates -->
11
<version>0.1.0</version>
12
</Mage_Reembolso>
package.xml CHANGED
@@ -1,27 +1,39 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Payment_Reembolso</name>
4
- <version>0.1.5</version>
5
<stability>stable</stability>
6
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
<channel>community</channel>
8
<extends/>
9
- <summary>This is the cash on deluvery paument method.</summary>
10
- <description>It establishes different amount for the amount of the purchase. If it is minor that the Certain amount, the amount of the service will be a fixed value; if the amount is major that the Certain amount, the amount of the service will be a percentage of the same one.
11
- To do:
12
- Set from the control panel the fixed value, the value percentage and the Certain amount.</description>
13
- <notes>* Fix error, not work version 0.1.4
14
- * Change message text
15
16
- &lt;b&gt;CHANGES:&lt;/b&gt;
17
- -&gt;U app/code/local/Mage/Reembolso/Model/Reembolso.php
18
- -&gt;U app/code/local/Mage/Reembolso/Model/Quote.php
19
- -&gt;U app/design/frontend/default/default/template/reembolso/form.phtml
20
- -&gt;U app/design/frontend/default/default/template/reembolso/info.phtml</notes>
21
- <authors><author><name>Sophie</name><user>auto-converted</user><email>lalyostres@gmail.com</email></author><author><name>Manuel</name><user>auto-converted</user><email>manuelcanepa@gmail.com</email></author></authors>
22
- <date>2008-12-05</date>
23
- <time>09:18:18</time>
24
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="reembolso"><file name="form.phtml" hash="ce75a81d61ec34a17aafc9f8c3b22dcc"/><file name="info.phtml" hash="57dfa8759788a77326a833603cb978e6"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="reembolso"><file name="form.phtml" hash="cdc021084d6bdf947fb5119242bae56e"/><file name="info.phtml" hash="65dad5a1fdbd665a48652ed66abc5cb6"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="es_ES"><file name="Mage_Reembolso.csv" hash="42e01f656ee2d0223e95e10ed54b26ce"/></dir></target><target name="magelocal"><dir name="Mage"><dir name="Reembolso"><dir name="Block"><file name="Form.php" hash="21f1e325029d98571ec884bca2234e65"/><file name="Info.php" hash="33f48eab752f05362c553b63de5d9c42"/></dir><dir name="etc"><file name="config.xml" hash="7c46dc9ef3f9811fe3cf40de917a6656"/><file name="system.xml" hash="8e1bf64b00d65ed46452f359e9b8ae01"/></dir><dir name="Helper"><file name="Data.php" hash="1445d2b92929e66446fe0c1ae4620d55"/></dir><dir name="Model"><file name="Quote.php" hash="6059126218ee9aa9f3a6c18e41ef6255"/><file name="Reembolso.php" hash="c12f04e6c635318e0fb1e8c35ecb5093"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Reembolso.xml" hash="a5a370ae7cb7f2b0f72b15e7d500f47d"/></dir></target></contents>
25
<compatible/>
26
<dependencies/>
27
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Payment_Reembolso</name>
4
+ <version>0.2.0</version>
5
<stability>stable</stability>
6
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
<channel>community</channel>
8
<extends/>
9
+ <summary>This is the cash on delyvery payment method.</summary>
10
+ <description>ES | Reembolso permite configurar los reembolsos de todos los metodos de envio que tengamos instalados en nuestra tienda Magento. Reembolso calcula el valor que se debe abonar mediante este m&#xE9;todo de pago. Por cada reembolso se debe ingresar un titulo, el metodo de envio al cual se le va a aplicar el reembolso, el tipo (si es fijo o variable), el valor del reembolso y el importe a partir del cual se va a seleccionar que valor se le aplica al monto final.
11
12
+ EN | Refund allows users to set up refunds for all shipping methods installed in our Magento store. Refund determines the value the user must pay by using this payment method. For each refund you must enter a title, the refund shipping method, the refund type (either fixed or variable), the refund value and the amount from which the value applied to the total amount will be selected.</description>
13
+ <notes>&lt;b&gt;CHANGES:&lt;/b&gt;
14
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso.php
15
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Grid.php
16
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit.php
17
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tabs.php
18
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Form.php
19
+ -&gt;A app/code/local/Mage/Reembolso/Block/Adminhtml/Reembolso/Edit/Tab/Form.php
20
+ -&gt;A app/code/local/Mage/Reembolso/controllers/Adminhtml/ReembolsoController.php
21
+ -&gt;U app/code/local/Mage/Reembolso/etc/config.xml
22
+ -&gt;U app/code/local/Mage/Reembolso/etc/system.xml
23
+ -&gt;A app/code/local/Mage/Reembolso/Model/Adminhtml/Status.php
24
+ -&gt;A app/code/local/Mage/Reembolso/Model/Adminhtml/Reembolso.php
25
+ -&gt;A app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso.php
26
+ -&gt;A app/code/local/Mage/Reembolso/Model/Mysql4/Reembolso/Collection.php
27
+ -&gt;U app/code/local/Mage/Reembolso/Model/Quote.php
28
+ -&gt;U app/code/local/Mage/Reembolso/Model/Reembolso.php
29
+ -&gt;A app/code/local/Mage/Reembolso/sql/reembolso_setup/mysql4-install-0.1.0.php
30
+ -&gt;U app/design/frontend/default/default/template/reembolso/form.phtml
31
+ -&gt;U app/design/frontend/default/default/template/reembolso/info.phtml
32
+ -&gt;U app/design/adminhtml/default/default/layout/reembolso.xml</notes>
33
+ <authors><author><name>Sophie</name><user>auto-converted</user><email>lalyostres@gmail.com</email></author><author><name>Manuel</name><user>auto-converted</user><email>manuelcanepa@gmail.com</email></author><author><name>Gaspar Mac</name><user>auto-converted</user><email>gasparmac@gmail.com</email></author></authors>
34
+ <date>2009-02-13</date>
35
+ <time>10:34:53</time>
36
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="reembolso.xml" hash="c70542d55d3c5486dfe96d62d62b38c2"/></dir><dir name="template"><dir name="reembolso"><file name="form.phtml" hash="a0299c5836ce66e8748328a918fdb1d8"/><file name="info.phtml" hash="308cfe38ecfbe667beee4618b40e6b33"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="reembolso"><file name="form.phtml" hash="aa973739122a483aca2ddfc6d1fd902f"/><file name="info.phtml" hash="28b00b8074bdf7cabed24d30911eb5b4"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="es_ES"><file name="Mage_Reembolso.csv" hash="42e01f656ee2d0223e95e10ed54b26ce"/></dir></target><target name="magelocal"><dir name="Mage"><dir name="Reembolso"><dir name="Block"><dir name="Adminhtml"><dir name="Reembolso"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="01a74473e969de469badea3afcc4d93c"/></dir><file name="Form.php" hash="a255a1faec8bd6827af597faa26ab479"/><file name="Tabs.php" hash="5cde7719cc092d44345454537eea652a"/></dir><file name="Edit.php" hash="48be62d8c1b09560fd5d876ee592b4e1"/><file name="Grid.php" hash="45e4cdff8d222d8f985f2975a064283a"/></dir><file name="Reembolso.php" hash="405131c5f3c12f61e6fde5089a030bc7"/></dir><file name="Form.php" hash="5374b819bbb8aa88127fda1122f7b2e8"/><file name="Info.php" hash="7bcb79c4df796dea63a2ac00ea991422"/><file name="Reembolso.php" hash="0db6644de2cfdc8dc7badb2cb8a84b23"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ReembolsoController.php" hash="8724a1fb8ae96f1111807588386b45e2"/></dir><file name="IndexController.php" hash="637815ee5aa7d6b9253ec713abfd559e"/></dir><dir name="etc"><file name="config.xml" hash="08ac3fd8cc285ae94e482bf9ab075b12"/><file name="system.xml" hash="462888971106de537e8618190d352bac"/></dir><dir name="Helper"><file name="Data.php" hash="981e6afa35c5a3b2a2a93cd032dda366"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Reembolso.php" hash="094caad3d400d674dad90528eb3ef7ea"/><file name="Status.php" hash="738364aabca63cc0ab1227f372cbd1c0"/></dir><dir name="Mysql4"><dir name="Reembolso"><file name="Collection.php" hash="6be9cec7d9098472f1514bc0b3189035"/></dir><file name="Reembolso.php" hash="5e4d2cadd46fdf0e919f6402c78ed985"/></dir><file name="Quote.php" hash="49051c6e369921f1de5835b780a30da9"/><file name="Reembolso.php" hash="cca1fcd38fb94d55ec75f53646e8790c"/></dir><dir name="sql"><dir name="reembolso_setup"><file name="mysql4-install-0.1.0.php" hash="66e352a38f890bce4c7173a1ce4c71e4"/></dir></dir><file name="INFO-reembolso.txt" hash="d8d8daf56685ebca48267cb516abc198"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Reembolso.xml" hash="142e434873aea670fe99f6e83f35a44b"/></dir></target></contents>
37
<compatible/>
38
<dependencies/>
39
</package>