Skip to content

Commit 29b19c1

Browse files
author
Jonatan Machado
committed
Adicionado ajustado relaciomaneto de pagaentos com os id do ebit
1 parent a01d075 commit 29b19c1

File tree

5 files changed

+72
-139
lines changed

5 files changed

+72
-139
lines changed

app/code/community/Ceicom/EbitIntegration/Block/Adminhtml/Form/Field/Idebit.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
<?php
2+
3+
/**
4+
*
5+
* @category Ceicom
6+
* @package Ceicom_EbitIntegration
7+
* @author Jonatan <jonatan@ceicom.com.br>
8+
* @website http://www.ceicom.com.br
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
*/
11+
212
class Ceicom_EbitIntegration_Block_Adminhtml_Form_Field_Idebit
313
extends Mage_Core_Block_Html_Select
414
{
@@ -16,10 +26,9 @@ public function _toHtml()
1626
array("value" => "28","label" => "28 (Cartão de Débito / Débito em Conta)",)
1727
);
1828

19-
2029
foreach ($options as $option) {
2130
$this->addOption($option['value'], $option['label']);
22-
31+
2332
}
2433

2534
return parent::_toHtml();

app/code/community/Ceicom/EbitIntegration/Block/Adminhtml/Form/Field/Pagamentos.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<?php
2+
3+
/**
4+
*
5+
* @category Ceicom
6+
* @package Ceicom_EbitIntegration
7+
* @author Jonatan <jonatan@ceicom.com.br>
8+
* @website http://www.ceicom.com.br
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
*/
11+
212
class Ceicom_EbitIntegration_Block_Adminhtml_Form_Field_Pagamentos
313
extends Mage_Core_Block_Html_Select
414
{
515
public function _toHtml()
616
{
717

8-
918
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
1019
$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Selecione--')));
1120

app/code/community/Ceicom/EbitIntegration/Block/Adminhtml/Pagamentos.php

Lines changed: 39 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -16,139 +16,68 @@ class Ceicom_EbitIntegration_Block_Adminhtml_Pagamentos extends Mage_Adminhtml_B
1616
*/
1717

1818

19-
protected $_itemRenderer;
19+
protected $_itemRendererEbit;
20+
protected $_itemRendererPag;
2021

21-
public function _prepareToRender()
22+
public function _prepareToRender($name)
2223
{
24+
Mage::log($name);
2325
$this->addColumn('idebit', array(
24-
'label' => Mage::helper('ceicom_ebitintegration')->__('idebit'),
25-
'renderer' => $this->_getRenderer(),
26+
'label' => Mage::helper('ceicom_ebitintegration')->__('IdEbit'),
27+
'renderer' => $this->_getRendererEbit(),
2628
));
2729

2830
$this->addColumn('pagamentos', array(
29-
'label' => Mage::helper('ceicom_ebitintegration')->__('pagamentos'),
30-
'renderer' => $this->_getRenderer(),
31+
'label' => Mage::helper('ceicom_ebitintegration')->__('Pagamentos'),
32+
'renderer' => $this->_getRendererPag(),
3133
));
3234

3335

3436
$this->_addAfter = false;
35-
$this->_addButtonLabel = Mage::helper('ceicom_ebitintegration')->__('Add');
37+
$this->_addButtonLabel = Mage::helper('ceicom_ebitintegration')->__('Relacionar outro');
38+
Mage::log($name);
3639

37-
Mage::log($columnName);
3840
}
3941

40-
protected function _getRenderer()
42+
protected function _getRendererEbit()
4143
{
42-
if (!$this->_itemRenderer) {
43-
$this->_itemRenderer = $this->getLayout()->createBlock(
44-
'ceicom_ebitintegration/adminhtml_form_field_pagamentos', '',
44+
45+
if (!$this->_itemRendererEbit) {
46+
$this->_itemRendererEbit = $this->getLayout()->createBlock(
47+
'ceicom_ebitintegration/adminhtml_form_field_idebit', '',
4548
array('is_render_to_js_template' => true)
4649
);
4750
}
48-
return $this->_itemRenderer;
51+
return $this->_itemRendererEbit;
4952
}
5053

51-
protected function _prepareArrayRow(Varien_Object $row)
52-
{
54+
protected function _getRendererPag()
55+
{
5356

54-
//Mage::log($row);
55-
if ($row->getData('_id')) {
56-
$row->setData(
57-
'option_extra_attr_' . $this->_getRenderer()
58-
->calcOptionHash($row->getData('pagamentos')),
59-
'selected="selected"'
60-
);
57+
if (!$this->_itemRendererPag) {
58+
$this->_itemRendererPag = $this->getLayout()->createBlock(
59+
'ceicom_ebitintegration/adminhtml_form_field_pagamentos', '',
60+
array('is_render_to_js_template' => true)
61+
);
62+
}
63+
return $this->_itemRendererPag;
6164
}
6265

63-
}
66+
protected function _prepareArrayRow(Varien_Object $row)
67+
{
68+
$row->setData(
69+
'option_extra_attr_' . $this->_getRendererPag()
70+
->calcOptionHash($row->getData('pagamentos')),
71+
'selected="selected"'
72+
);
73+
74+
$row->setData(
75+
'option_extra_attr_' . $this->_getRendererEbit()
76+
->calcOptionHash($row->getData('idebit')),
77+
'selected="selected"'
78+
);
6479

65-
// protected function _renderCellTemplate($columnName)
66-
// {
67-
// if (empty($this->_columns[$columnName])) {
68-
// throw new Exception('Wrong column name specified.');
69-
// }
70-
//
71-
// $payments = Mage::getSingleton('payment/config')->getActiveMethods();
72-
// $methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Selecione--')));
73-
//
74-
// foreach ($payments as $paymentCode => $paymentModel) {
75-
// $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
76-
// $methods[$paymentCode] = array(
77-
// 'label' => $paymentTitle,
78-
// 'value' => $paymentCode,
79-
// );
80-
// }
81-
//
82-
// //Pagamentos
83-
// $pagamentosCosts = Mage::getStoreConfig('ceicom_ebitintegration/config/ebitintegration_pagamentos');
84-
// //echo $shippingCosts;
85-
//
86-
// Mage::log($methods);
87-
//
88-
// if ($pagamentosCosts) {
89-
//
90-
// $pagamentosCosts = unserialize($pagamentosCosts);
91-
// if (array_keys($pagamentosCosts)) {
92-
// foreach($pagamentosCosts as $pagamentosCost) {
93-
// if ($paymentCode == $pagamentosCost['pagamentos']) {
94-
// $namePagamento = $pagamentosCost['pagamentos'];
95-
// }
96-
// }
97-
//
98-
// } else {
99-
// // errors here
100-
// }
101-
// }
102-
//
103-
// Mage::log($pagamentosCosts);
104-
//
105-
// $column = $this->_columns[$columnName];
106-
// $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
107-
// $value = $this->getElement()->getValue();
108-
//
109-
// if($columnName == 'id_ebit')
110-
// {
111-
// $rendered = '<select name="'.$inputName.'">';
112-
//
113-
// $options = array
114-
// (
115-
// array("value" => "14","label" => "14 (Outros)",),
116-
// array("value" => "05","label" => "05 (Cartão de Crédito)",),
117-
// array("value" => "08","label" => "08 (Boleto Bancário)",),
118-
// array("value" => "24","label" => "24 (Cartão da Loja)",),
119-
// array("value" => "25","label" => "25 (Pagamento por Celular)",),
120-
// array("value" => "28","label" => "28 (Cartão de Débito / Débito em Conta)",)
121-
// );
122-
//
123-
// foreach($options as $option)
124-
// {
125-
// $selected = $option['value'] == $pagamentosCost['id_ebit'] ? 'selected' : '';
126-
// $rendered .= '<option ' . $selected . ' value="'.$option['value'].'">'.$option['label'].'</option>';
127-
// }
128-
//
129-
// $rendered .= '</select>';
130-
//
131-
// return $rendered;
132-
// }
133-
// elseif($columnName == 'pagamentos')
134-
// {
135-
//
136-
// $rendered = '<select name="'.$inputName.'">';
137-
//
138-
// foreach($methods as $method)
139-
// {
140-
// $selected = $method['value'] == $pagamentosCost['pagamentos'] ? 'selected' : '';
141-
// $rendered .= '<option ' . $selected . ' value="'.$method['value'].'">'.$method['label'].'</option>';
142-
// }
143-
//
144-
// $rendered .= '</select>';
145-
//
146-
// return $rendered;
147-
// }
148-
// else
149-
// return parent::_renderCellTemplate($columnName);
150-
151-
//}
80+
}
15281
}
15382

15483

app/code/community/Ceicom/EbitIntegration/etc/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</ebitintegration_buscapeid>
8181

8282
<ebitintegration_pagamentos translate="label">
83-
<label>Configurar pagamento com o id do Ebit</label>
83+
<label>Relacionar meus pagamentos com o Ebit</label>
8484
<comment>
8585
<![CDATA[
8686
ID do tipo de pagamento. Valores aceitos são:<br>

app/design/frontend/base/default/template/ceicom/ebitintegration/ebitintegration.phtml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ $EbitIntegrationPopup = Mage::getStoreConfig('ceicom_ebitintegration/config/ebit
6868
$cepAddress = $address->getPostcode();
6969

7070
//Forma de pagamento
71-
$paymentType = $order->getPayment()->getMethodInstance();
71+
72+
$payment = $order->getPayment();
73+
$paymentType = $payment->getMethodInstance();
7274
$paymentId = $paymentType->getCode();
7375
$paymentTitle = $paymentType->getTitle();
7476

75-
$paymentCctype = $order->getPayment()->getData('cc_type');
76-
$paymentParcel = $order->getPayment()->getData('additional_data');
77+
$paymentcParcel = $payment->getData('additional_data');
78+
$paymentcType = $payment->getData('cc_type');
7779

7880

7981
//Pagamentos
@@ -84,8 +86,8 @@ $EbitIntegrationPopup = Mage::getStoreConfig('ceicom_ebitintegration/config/ebit
8486
$pagamentosCosts = unserialize($pagamentosCosts);
8587
if (array_keys($pagamentosCosts)) {
8688
foreach($pagamentosCosts as $pagamentosCost) {
87-
if ($paymentTitle == $pagamentosCost['pagamentos']) {
88-
$idPagamento = $pagamentosCost['id_ebit'];
89+
if ($paymentId == $pagamentosCost['pagamentos']) {
90+
$idPagamento = $pagamentosCost['idebit'];
8991
$namePagamento = $pagamentosCost['pagamentos'];
9092
}
9193

@@ -96,25 +98,6 @@ $EbitIntegrationPopup = Mage::getStoreConfig('ceicom_ebitintegration/config/ebit
9698
}
9799
}
98100

99-
print_r($pagamentosCosts);
100-
101-
// if ($paymentTitle == $namePagamento) {
102-
// $idPagamento = $idPagamento ? $idPagamento : '14';
103-
// }else{
104-
// $idPagamento = '14';
105-
// }
106-
//
107-
// //print_r($paymentType);
108-
// print_r('Id pagamento: ' . $idPagamento);
109-
// print_r('<br>Name pagamento: ' . $paymentTitle);
110-
// print_r('<br>Bandeira: ' . $paymentCctype);
111-
// print_r('<br>Parcelas: ' . $paymentParcel);
112-
// print_r('<br>$EbitIntegrationStoreid: ' . $EbitIntegrationStoreid);
113-
114-
115-
116-
117-
// echo $this->getLayout()->createBlock($paymentType->getInfoBlockType())->setData('info', $order->getPayment())->toHtml();
118101

119102
//pega as infos de cada produto
120103
$priceAll = '';
@@ -178,9 +161,12 @@ $EbitIntegrationPopup = Mage::getStoreConfig('ceicom_ebitintegration/config/ebit
178161
$htmlParam .= '&sku=' . $skuAll;
179162
$htmlParam .= '&ean=' . $eanAll;
180163
$htmlParam .= '&plataform=0';
181-
$htmlParam .= '&paymentType=' . $paymentTitle;
164+
$htmlParam .= '&paymentType=' . $idPagamento;
182165
$htmlParam .= '&buscapeId=' . $EbitIntegrationBuscapeid;
183166
$htmlParam .= '&storeId=' . $EbitIntegrationStoreid;
167+
$htmlParam .= $paymentcParcel ? '&parcels=' . $paymentcParcel : '';
168+
$htmlParam .= $paymentcType ? '&cardFlag=' . $paymentcType : '';
169+
184170
$htmlParam .= '"/>';
185171

186172
//imprime o html

0 commit comments

Comments
 (0)