Version Notes
Send your transactional e-mails through the Campaign Commander NMP platform
Download this release
Release Info
Developer | Magento Core Team |
Extension | Campaign_Commander_Transactional_Email_1_5 |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 1.3.1
- app/code/community/Emv/Core/Model/Service/Soap/Api.php +1 -0
- app/code/community/Emv/Core/etc/config.xml +4 -4
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit.php +38 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit/Attributes.php +83 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit/Form.php +240 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/Grid.php +96 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/New.php +29 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emt/New/Form.php +94 -0
- app/code/community/Emv/Emt/Block/Adminhtml/Emts.php +32 -0
- app/code/community/Emv/Emt/Constants.php +7 -0
- app/code/community/Emv/Emt/Helper/Data.php +24 -0
- app/code/community/Emv/Emt/Helper/Emvtemplate.php +40 -0
- app/code/community/Emv/Emt/Model/Attribute.php +48 -0
- app/code/community/Emv/Emt/Model/Emt.php +173 -0
- app/code/community/Emv/Emt/Model/Mage/Core/Email/Template.php +159 -0
- app/code/community/Emv/Emt/Model/MageTemplate.php +26 -0
- app/code/community/Emv/Emt/Model/Mailmode.php +48 -0
- app/code/community/Emv/Emt/Model/Mysql4/Attribute.php +38 -0
- app/code/community/Emv/Emt/Model/Mysql4/Attribute/Collection.php +40 -0
- app/code/community/Emv/Emt/Model/Mysql4/Emt.php +41 -0
- app/code/community/Emv/Emt/Model/Mysql4/Emt/Collection.php +96 -0
- app/code/community/Emv/Emt/Model/Mysql4/Mailmode.php +19 -0
- app/code/community/Emv/Emt/Model/Mysql4/Mailmode/Collection.php +31 -0
- app/code/community/Emv/Emt/Model/Resource/Setup.php +12 -0
- app/code/community/Emv/Emt/controllers/Adminhtml/EmtController.php +484 -0
- app/code/community/Emv/Emt/etc/adminhtml.xml +38 -0
- app/code/community/Emv/Emt/etc/config.xml +75 -0
- app/code/community/Emv/Emt/sql/emvemt_setup/mysql4-install-0.1.0.php +40 -0
- app/code/community/Emv/Emt/sql/emvemt_setup/mysql4-upgrade-0.1.0-0.2.0.php +16 -0
- package.xml +4 -4
app/code/community/Emv/Core/Model/Service/Soap/Api.php
CHANGED
@@ -92,6 +92,7 @@ class Emv_Core_Model_Service_Soap_Api
|
|
92 |
$this->_sessionId = $wsResult->return;
|
93 |
} catch (Exception $e) {
|
94 |
Mage::log($e->getMessage(), null, Mage::helper('emvcore')->LOG_FILE);
|
|
|
95 |
if($e->getMessage() === 'Could not connect to host' ||
|
96 |
$e->getMessage() === 'Service Temporarily Unavailable' )
|
97 |
{
|
92 |
$this->_sessionId = $wsResult->return;
|
93 |
} catch (Exception $e) {
|
94 |
Mage::log($e->getMessage(), null, Mage::helper('emvcore')->LOG_FILE);
|
95 |
+
Mage::log($e, null, Mage::helper('emvcore')->LOG_FILE);
|
96 |
if($e->getMessage() === 'Could not connect to host' ||
|
97 |
$e->getMessage() === 'Service Temporarily Unavailable' )
|
98 |
{
|
app/code/community/Emv/Core/etc/config.xml
CHANGED
@@ -39,10 +39,10 @@
|
|
39 |
</emvcore_setup>
|
40 |
</resources>
|
41 |
<emv>
|
42 |
-
|
43 |
-
<transactional_service>https://
|
44 |
-
<notification_service>
|
45 |
-
|
46 |
</emv>
|
47 |
</global>
|
48 |
<adminhtml>
|
39 |
</emvcore_setup>
|
40 |
</resources>
|
41 |
<emv>
|
42 |
+
<wsdl_list>
|
43 |
+
<transactional_service>https://p5apic.emv2.com/apitransactional/services/TransactionalService?wsdl</transactional_service>
|
44 |
+
<notification_service>http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl</notification_service>
|
45 |
+
</wsdl_list>
|
46 |
</emv>
|
47 |
</global>
|
48 |
<adminhtml>
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{9A8DC590-314F-402c-A1B5-45669D8D3DA0}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Block_Adminhtml_Emt_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{E35B4FB9-C0A2-4362-8A9C-9F73B3A95889}
|
14 |
+
*/
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
$this->_blockGroup = 'emvemt';
|
19 |
+
$this->_controller = 'adminhtml_emt';
|
20 |
+
$this->_headerText = Mage::helper('emvemt')->__('Configure Campaign Commander Account');
|
21 |
+
|
22 |
+
if(!Mage::getSingleton('admin/session')->isAllowed('emvemt/emt/delete'))
|
23 |
+
{
|
24 |
+
$this->removeButton('delete');
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Retrieve text for header element depending on loaded page
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getHeaderText()
|
34 |
+
{
|
35 |
+
return Mage::helper('emvemt')->__("Edit %s Email",
|
36 |
+
$this->htmlEscape(Mage::registry('mage_template_name')));
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit/Attributes.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Block_Adminhtml_Emt_Edit_Attributes extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->setTemplate('emt/attributes.phtml');
|
7 |
+
}
|
8 |
+
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
$this->setChild('add_button_emv_dyn',
|
12 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
13 |
+
->setData(array(
|
14 |
+
'label' => Mage::helper('emvemt')->__('Add New EMV DYN Attribute'),
|
15 |
+
'class' => 'add',
|
16 |
+
'id' => 'add_new_attribute_emv_dyn',
|
17 |
+
'on_click' => 'emvAttribute.addEmvDyn();'
|
18 |
+
))
|
19 |
+
);
|
20 |
+
$this->setChild('add_button_emv_content',
|
21 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
22 |
+
->setData(array(
|
23 |
+
'label' => Mage::helper('emvemt')->__('Add New EMV CONTENT Attribute'),
|
24 |
+
'class' => 'add',
|
25 |
+
'id' => 'add_new_attribute_emv_content',
|
26 |
+
'on_click' => 'emvAttribute.addEmvContent();'
|
27 |
+
))
|
28 |
+
);
|
29 |
+
|
30 |
+
$this->setChild('delete_button',
|
31 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
32 |
+
->setData(array(
|
33 |
+
'label' => Mage::helper('emvemt')->__('Remove'),
|
34 |
+
'class' => 'delete delete-product-option',
|
35 |
+
'on_click' => 'emvAttribute.remove(event)'
|
36 |
+
))
|
37 |
+
);
|
38 |
+
|
39 |
+
parent::_prepareLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getFieldId()
|
43 |
+
{
|
44 |
+
return 'emv_attribute';
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getFieldName ()
|
48 |
+
{
|
49 |
+
return 'attributes';
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Build HTML select element of attribute set attributes
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getMageAttributesInputHtml()
|
58 |
+
{
|
59 |
+
$input = '<input type="text" id="'.$this->getFieldId().'_{{index}}_mage_attribute" name="'.
|
60 |
+
$this->getFieldName().'[{{index}}][mage_attribute]" size="50" maxlength="200" />';
|
61 |
+
return $input;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getAddButtonHtml()
|
65 |
+
{
|
66 |
+
return $this->getChildHtml('add_button_emv_dyn');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getAddEmvContentButtonHtml()
|
70 |
+
{
|
71 |
+
return $this->getChildHtml('add_button_emv_content');
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getDeleteButtonHtml()
|
75 |
+
{
|
76 |
+
return $this->getChildHtml('delete_button');
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _toJson($data)
|
80 |
+
{
|
81 |
+
return Mage::helper('emvemt')->jsonEncode($data);
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/Edit/Form.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{F6ADA887-E2B8-4107-9915-B14420DCDFE7}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Block_Adminhtml_Emt_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Prepare block children and data
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
protected function _prepareLayout()
|
17 |
+
{
|
18 |
+
$onclick = "
|
19 |
+
var url = '".$this->getUrl('emvemt/emt/getEmvTemplateSelectAjax')."';
|
20 |
+
new Ajax.Updater(\$('emv_template_id').parentNode, url, {parameters:
|
21 |
+
{ accountId : $('emv_account_id').value,
|
22 |
+
from: $('from_date').value ,
|
23 |
+
to :$('to_date').value},
|
24 |
+
method: 'post'}
|
25 |
+
);";
|
26 |
+
|
27 |
+
$this->setChild('get_emv_templates',
|
28 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
29 |
+
->setData(array(
|
30 |
+
'label' => Mage::helper('emvemt')->__('Get Campaign Commander templates'),
|
31 |
+
'onclick' => $onclick,
|
32 |
+
'class' => 'save'
|
33 |
+
))
|
34 |
+
);
|
35 |
+
|
36 |
+
parent::_prepareLayout();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* opGUID{AB2272B3-0BEE-42bd-96EC-E2C54C40CB9B}
|
41 |
+
*/
|
42 |
+
protected function _prepareForm()
|
43 |
+
{
|
44 |
+
$form = new Varien_Data_Form(
|
45 |
+
array(
|
46 |
+
'id' => 'edit_form',
|
47 |
+
'action' => $this->getUrl('*/*/save'),
|
48 |
+
'method' => 'post',
|
49 |
+
));
|
50 |
+
|
51 |
+
$emtModel = Mage::registry('current_emvemt');
|
52 |
+
|
53 |
+
if(null === $emtModel)
|
54 |
+
{
|
55 |
+
$emtModel = new Varien_Object();
|
56 |
+
}
|
57 |
+
|
58 |
+
if ($emtModel->getId()) {
|
59 |
+
$form->addField('id', 'hidden', array(
|
60 |
+
'name' => 'id',
|
61 |
+
));
|
62 |
+
}
|
63 |
+
|
64 |
+
$fieldset = $form->addFieldset('emt_info',
|
65 |
+
array(
|
66 |
+
'legend' => Mage::helper('emvemt')->__('Campaign Commander EMT mode'),
|
67 |
+
'class' => 'fieldset-wide',
|
68 |
+
));
|
69 |
+
|
70 |
+
$magentoTemplatesArray = Mage::registry('mage_templates')->toOptionArray();
|
71 |
+
|
72 |
+
$fieldset->addField('mage_template_id', 'select', array(
|
73 |
+
'value' => $emtModel->getMageTemplateId(),
|
74 |
+
'label' => Mage::helper('emvemt')->__('Magento Template Name'),
|
75 |
+
'name' => 'mage_template_id',
|
76 |
+
'disabled' => 'true',
|
77 |
+
'required' => true,
|
78 |
+
'class' => 'validate-select',
|
79 |
+
'values' => $magentoTemplatesArray,
|
80 |
+
));
|
81 |
+
|
82 |
+
$accountsArray = Mage::registry('emt_accounts')->toOptionArray();
|
83 |
+
|
84 |
+
$fieldset->addField('emv_account_id', 'select', array(
|
85 |
+
'value' => $emtModel->getEmvAccountId(),
|
86 |
+
'label' => Mage::helper('emvemt')->__('Campaign Commander Account'),
|
87 |
+
'name' => 'emv_account_id',
|
88 |
+
'required' => true,
|
89 |
+
'disabled' => true,
|
90 |
+
'class' => 'validate-select',
|
91 |
+
'values' => $accountsArray,
|
92 |
+
));
|
93 |
+
|
94 |
+
// javascript removing unused input according to selected send mail mode
|
95 |
+
$mailModeOnClick = "var sendModeSelect = $('emv_send_mail_mode_id');
|
96 |
+
sendModeValue = sendModeSelect.options[sendModeSelect.selectedIndex].value;
|
97 |
+
hideField(sendModeValue);
|
98 |
+
";
|
99 |
+
|
100 |
+
$mailModesArray = Mage::registry('mail_modes')->toOptionArray();
|
101 |
+
|
102 |
+
// translate mail mode
|
103 |
+
foreach($mailModesArray as $key => $value)
|
104 |
+
{
|
105 |
+
$mailModesArray[$key]['label'] = Mage::helper('emvemt')->__($mailModesArray[$key]['label']);
|
106 |
+
}
|
107 |
+
|
108 |
+
$fieldset->addField('emv_send_mail_mode_id', 'select', array(
|
109 |
+
'value' => $emtModel->getEmvSendMailModeId(),
|
110 |
+
'label' => Mage::helper('emvemt')->__('Send Mail Mode'),
|
111 |
+
'name' => 'emv_send_mail_mode_id',
|
112 |
+
'required' => true,
|
113 |
+
'class' => 'validate-select',
|
114 |
+
'onclick' => $mailModeOnClick,
|
115 |
+
'values' => $mailModesArray,
|
116 |
+
));
|
117 |
+
|
118 |
+
$classicModeId = Mage::getModel('emvemt/mailmode')->getIdByName('classic');
|
119 |
+
$sendModeId = Mage::getModel('emvemt/mailmode')->getIdByName('emv send');
|
120 |
+
|
121 |
+
if(null === $emtModel->getEmvTemplateId() ||
|
122 |
+
$emtModel->getEmvSendMailModeId() === $classicModeId)
|
123 |
+
{
|
124 |
+
$fieldset->addField('emv_template_id', 'note', array(
|
125 |
+
'label' => Mage::helper('emvemt')->__('Campaign Commander Template Name'),
|
126 |
+
'required' => true,
|
127 |
+
'class' => 'validate-select',
|
128 |
+
));
|
129 |
+
}
|
130 |
+
else
|
131 |
+
{
|
132 |
+
$fieldset->addField('emv_template_id', 'select', array(
|
133 |
+
'value' => $emtModel->getEmvTemplateId(),
|
134 |
+
'label' => Mage::helper('emvemt')->__('Campaign Commander Template Name'),
|
135 |
+
'name' => 'emv_template_id',
|
136 |
+
'required' => true,
|
137 |
+
'class' => 'validate-select',
|
138 |
+
'values' => array(
|
139 |
+
Mage::registry('current_emv_template_array')
|
140 |
+
),
|
141 |
+
));
|
142 |
+
}
|
143 |
+
|
144 |
+
$displayAttributes = '';
|
145 |
+
if($emtModel->getEmvSendMailModeId() === $classicModeId)
|
146 |
+
{
|
147 |
+
$displayAttributes = ' style="display :none;"';
|
148 |
+
}
|
149 |
+
|
150 |
+
$getEmvTemplateButtonParam = array(
|
151 |
+
'text' => '<span id="emtTemplateButtonContainer"'.$displayAttributes.'>'.
|
152 |
+
$this->getChildHtml('get_emv_templates').'</span>',
|
153 |
+
);
|
154 |
+
|
155 |
+
$fieldset->addField('get_emv_templates', 'note', $getEmvTemplateButtonParam);
|
156 |
+
|
157 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(
|
158 |
+
Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
|
159 |
+
);
|
160 |
+
|
161 |
+
$dateFromParam = array(
|
162 |
+
'value' => '',
|
163 |
+
'label' => Mage::helper('emvemt')->__('from'),
|
164 |
+
'name' => 'from_date',
|
165 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
166 |
+
'format' => $dateFormatIso,
|
167 |
+
);
|
168 |
+
|
169 |
+
$fieldset->addField('from_date', 'date', $dateFromParam);
|
170 |
+
|
171 |
+
$dateToParam = array(
|
172 |
+
'value' => '',
|
173 |
+
'label' => Mage::helper('emvemt')->__('to'),
|
174 |
+
'name' => 'to_date',
|
175 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
176 |
+
'format' => $dateFormatIso,
|
177 |
+
);
|
178 |
+
|
179 |
+
$fieldset->addField('to_date', 'date', $dateToParam);
|
180 |
+
|
181 |
+
$fieldset = $form->addFieldset('attribute_mapping_info', array(
|
182 |
+
'legend' => Mage::helper('emvemt')->__('Attribute mapping'),
|
183 |
+
'class' => 'fieldset-wide',
|
184 |
+
));
|
185 |
+
|
186 |
+
$attributesBlock = $this->getLayout()
|
187 |
+
->createBlock('emvemt/adminhtml_emt_edit_attributes');
|
188 |
+
|
189 |
+
$attributes = Mage::registry('emt_attributes');
|
190 |
+
|
191 |
+
if (is_array($attributes) && count($attributes) > 0) {
|
192 |
+
$attributesBlock->setAttributesData($attributes);
|
193 |
+
}
|
194 |
+
|
195 |
+
$attributeBlockParam = array(
|
196 |
+
'label' => Mage::helper('emvemt')->__('Attributes Mapping'),
|
197 |
+
'text' => '<div id="attributes_details">' . $attributesBlock->toHtml() . '</div>',
|
198 |
+
|
199 |
+
// Dirty but it's the only way i've found to hide field in this form
|
200 |
+
'note' => '<script type="text/javascript">
|
201 |
+
function hideField(mailMode)
|
202 |
+
{
|
203 |
+
if(mailMode == '.Mage::getModel('emvemt/mailmode')->getIdByName('classic').
|
204 |
+
' || mailMode == '.Mage::getModel('emvemt/mailmode')->getIdByName('emv send').')
|
205 |
+
{
|
206 |
+
$("emv_template_id").parentNode.parentNode.style.display = "none";
|
207 |
+
$("to_date").parentNode.parentNode.style.display = "none";
|
208 |
+
$("from_date").parentNode.parentNode.style.display = "none";
|
209 |
+
$("get_emv_templates").parentNode.parentNode.style.display = "none";
|
210 |
+
$("attributes_details").style.display = "none";
|
211 |
+
}
|
212 |
+
else
|
213 |
+
{
|
214 |
+
if (mailMode == '.Mage::getModel('emvemt/mailmode')->getIdByName('emv create').')
|
215 |
+
{
|
216 |
+
$("emtTemplateButtonContainer").style.display = "";
|
217 |
+
$("emv_template_id").parentNode.parentNode.style.display = "";
|
218 |
+
$("get_emv_templates").parentNode.parentNode.style.display = "";
|
219 |
+
$("to_date").style.display = "";
|
220 |
+
$("from_date").style.display = "";
|
221 |
+
$("to_date").parentNode.parentNode.style.display = "";
|
222 |
+
$("from_date").parentNode.parentNode.style.display = "";
|
223 |
+
$("attributes_details").style.display = "";
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
$("note_attributes_box").style.display = "none";
|
228 |
+
hideField("'.Mage::getModel('emvemt/mailmode')->load($emtModel->getEmvSendMailModeId())->getId().'");
|
229 |
+
</script>'
|
230 |
+
);
|
231 |
+
|
232 |
+
$fieldset->addField('attributes_box', 'note', $attributeBlockParam);
|
233 |
+
|
234 |
+
$form->setUseContainer(true);
|
235 |
+
$form->setValues($emtModel->getData());
|
236 |
+
$this->setForm($form);
|
237 |
+
|
238 |
+
return parent::_prepareForm();
|
239 |
+
}
|
240 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/Grid.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{C577B255-D27F-4f41-83AC-42EC479B65FD}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Block_Adminhtml_Emt_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{7424594D-9EF0-4882-9D74-3B97D7EFBF7E}
|
14 |
+
*/
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = Mage::getResourceModel('emvemt/emt_collection');
|
18 |
+
$collection->getMagentoEMTName()->getEmvTemplateName();
|
19 |
+
$this->setCollection($collection);
|
20 |
+
parent::_prepareCollection();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* opGUID{78D0EB9B-29A9-4660-981E-60899AB408C4}
|
25 |
+
*/
|
26 |
+
protected function _prepareColumns()
|
27 |
+
{
|
28 |
+
$this->addColumn('id', array(
|
29 |
+
'header' => Mage::helper('emvemt')->__('EMT ID'),
|
30 |
+
'index' => 'id',
|
31 |
+
'type' => 'number',
|
32 |
+
));
|
33 |
+
|
34 |
+
$this->addColumn('template_code', array(
|
35 |
+
'header' => Mage::helper('emvemt')->__('Magento Template Name'),
|
36 |
+
'index' => 'template_code',
|
37 |
+
'type' => 'varchar',
|
38 |
+
));
|
39 |
+
|
40 |
+
//list of all avaiable modes
|
41 |
+
$sets = Mage::getModel('emvemt/mailmode')->getCollection()
|
42 |
+
->toOptionHash();
|
43 |
+
|
44 |
+
// translate mail mode
|
45 |
+
foreach($sets as $key => $value)
|
46 |
+
{
|
47 |
+
$sets[$key] = Mage::helper('emvemt')->__($value);
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->addColumn('emv_send_mail_mode_id',
|
51 |
+
array(
|
52 |
+
'header'=> Mage::helper('emvemt')->__('Mode'),
|
53 |
+
'width' => '100px',
|
54 |
+
'index' => 'emv_send_mail_mode_id',
|
55 |
+
'type' => 'options',
|
56 |
+
'options' => $sets,
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('emv_template_id_and_name', array(
|
60 |
+
'header' => Mage::helper('emvemt')->__('Campaign Commander Template Id And Name'),
|
61 |
+
'index' => 'emv_template_id_and_name',
|
62 |
+
'type' => 'varchar',
|
63 |
+
'filter' => false,
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('action', array(
|
67 |
+
'header' => Mage::helper('emvemt')->__('Action'),
|
68 |
+
'type' => 'action',
|
69 |
+
'width' => '100',
|
70 |
+
'getter' => 'getId',
|
71 |
+
'actions' => array(
|
72 |
+
array(
|
73 |
+
'caption' => Mage::helper('emvemt')->__('Edit'),
|
74 |
+
'url' => array('base'=> '*/*/edit'),
|
75 |
+
'field' => 'id',
|
76 |
+
)
|
77 |
+
),
|
78 |
+
'filter' => false,
|
79 |
+
'sortable' => false,
|
80 |
+
'is_system' => true,
|
81 |
+
));
|
82 |
+
|
83 |
+
return parent::_prepareColumns();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* opGUID{725A831A-D817-4a84-ADE2-0D07AF6E43E7}
|
88 |
+
*
|
89 |
+
* @param var $row
|
90 |
+
*/
|
91 |
+
public function getRowUrl($row)
|
92 |
+
{
|
93 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/New.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Block_Adminhtml_Emt_New extends Mage_Adminhtml_Block_Widget_Form_Container
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* opGUID{E35B4FB9-C0A2-4362-8A9C-9F73B3A95889}
|
6 |
+
*/
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
|
11 |
+
$this->_blockGroup = 'emvemt';
|
12 |
+
$this->_controller = 'adminhtml_emt';
|
13 |
+
$this->_mode = 'new';
|
14 |
+
$this->_headerText = $this->getHeaderText();
|
15 |
+
|
16 |
+
$this->removeButton('delete');
|
17 |
+
$this->removeButton('save');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Retrieve text for header element depending on loaded page
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getHeaderText()
|
26 |
+
{
|
27 |
+
return Mage::helper('emvemt')->__('New Campaign Commander Transactional Email');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emt/New/Form.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Block_Adminhtml_Emt_New_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Prepare block children and data
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
$onclick = "document.getElementById('new_form').submit();";
|
12 |
+
$this->setChild('continue_button',
|
13 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
14 |
+
->setData(array(
|
15 |
+
'label' => Mage::helper('emvemt')->__('Continue'),
|
16 |
+
'onclick' => $onclick,
|
17 |
+
'class' => 'save'
|
18 |
+
))
|
19 |
+
);
|
20 |
+
|
21 |
+
parent::_prepareLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* opGUID{AB2272B3-0BEE-42bd-96EC-E2C54C40CB9B}
|
26 |
+
*/
|
27 |
+
protected function _prepareForm()
|
28 |
+
{
|
29 |
+
$form = new Varien_Data_Form(
|
30 |
+
array(
|
31 |
+
'id' => 'new_form',
|
32 |
+
'action' => $this->getUrl('*/*/save'),
|
33 |
+
'method' => 'post',
|
34 |
+
));
|
35 |
+
|
36 |
+
$fieldset = $form->addFieldset('emt_info',
|
37 |
+
array(
|
38 |
+
'legend' => Mage::helper('emvemt')->__('Campaign Commander EMT mode'),
|
39 |
+
'class' => 'fieldset-wide',
|
40 |
+
));
|
41 |
+
|
42 |
+
$emvAccount = Mage::getResourceModel('emvcore/account_collection');
|
43 |
+
|
44 |
+
$onchange = "new Ajax.Updater(\$('mage_template_id').parentNode, '".$this->getUrl('emvemt/emt/getNotMappedMagentoTemplateSelectAjax').
|
45 |
+
"', {parameters:
|
46 |
+
{ emvAccount : $('emv_account_id').value
|
47 |
+
},
|
48 |
+
method: 'post'});";
|
49 |
+
|
50 |
+
$fieldset->addField('emv_account_id', 'select', array(
|
51 |
+
'value' => '',
|
52 |
+
'label' => Mage::helper('emvemt')->__('Campaign Commander Account'),
|
53 |
+
'name' => 'emv_account_id',
|
54 |
+
'required' => true,
|
55 |
+
'class' => 'validate-select',
|
56 |
+
'values' => $emvAccount->toOptionArray(),
|
57 |
+
'onchange' => $onchange,
|
58 |
+
));
|
59 |
+
|
60 |
+
$accountId = $emvAccount->getFirstItem()->getId();
|
61 |
+
|
62 |
+
$mageTemplate = Mage::getModel('emvemt/mageTemplate')->getNotMappedMageTemplateCollection($accountId);
|
63 |
+
|
64 |
+
if($mageTemplate->getSize() == 0)
|
65 |
+
{
|
66 |
+
$fieldset->addField('mage_template_id', 'note', array(
|
67 |
+
'label' => Mage::helper('emvemt')->__('Magento Template Name'),
|
68 |
+
'required' => true,
|
69 |
+
'class' => 'validate-select',
|
70 |
+
'text' => '<strong>' . Mage::helper('emvemt')->__('There is no Magento templates not mapped with this account.') . '</strong>',
|
71 |
+
));
|
72 |
+
}
|
73 |
+
else
|
74 |
+
{
|
75 |
+
$fieldset->addField('mage_template_id', 'select', array(
|
76 |
+
'value' => '',
|
77 |
+
'label' => Mage::helper('emvemt')->__('Magento Template Name'),
|
78 |
+
'name' => 'mage_template_id',
|
79 |
+
'required' => true,
|
80 |
+
'class' => 'validate-select',
|
81 |
+
'values' => $mageTemplate->toOptionArray(),
|
82 |
+
));
|
83 |
+
}
|
84 |
+
|
85 |
+
$fieldset->addField('continue_button', 'note', array(
|
86 |
+
'text' => $this->getChildHtml('continue_button'),
|
87 |
+
));
|
88 |
+
|
89 |
+
$form->setUseContainer(true);
|
90 |
+
$this->setForm($form);
|
91 |
+
|
92 |
+
return parent::_prepareForm();
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Emv/Emt/Block/Adminhtml/Emts.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{B2448BA4-891E-4142-80B7-486CAD6C9033}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Block_Adminhtml_Emts extends Mage_Adminhtml_Block_Widget_Grid_Container
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{2D94FA5D-18EE-4b9b-B71A-D7AAF0DCF89C}
|
14 |
+
*/
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
$this->_blockGroup = 'emvemt';
|
19 |
+
$this->_controller = 'adminhtml_emt';
|
20 |
+
$this->_headerText = Mage::helper('emvemt')->__('Campaign Commander Transactional Emails');
|
21 |
+
$this->_updateButton('add', 'label', Mage::helper('emvemt')->__('Add New Transactional Email'));
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* opGUID{2CE48FD6-34B7-4dee-9223-333B43DAD129}
|
26 |
+
*/
|
27 |
+
protected function _prepareLayout()
|
28 |
+
{
|
29 |
+
parent::_prepareLayout();
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Emv/Emt/Constants.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Emv_Emt_Constants
|
3 |
+
{
|
4 |
+
const ATTRIBUTE_TYPE_EMV_CONTENT = 'EMV_CONTENT';
|
5 |
+
|
6 |
+
const ATTRIBUTE_TYPE_EMV_DYN = 'EMV_DYN';
|
7 |
+
}
|
app/code/community/Emv/Emt/Helper/Data.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{528B8F2F-9AE2-4ac2-9593-847C94BBB789}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Encode the mixed $valueToEncode into the JSON format
|
14 |
+
*
|
15 |
+
* @param mixed $valueToEncode
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function jsonEncode($valueToEncode)
|
19 |
+
{
|
20 |
+
$json = Zend_Json::encode($valueToEncode);
|
21 |
+
|
22 |
+
return $json;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Emv/Emt/Helper/Emvtemplate.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Emv_Emt_Helper_Emvtemplate extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Return an array of strings between [EMV DYN] and [EMV /DYN]
|
8 |
+
*/
|
9 |
+
public function getEmvAttributesFromText($text)
|
10 |
+
{
|
11 |
+
preg_match_all('/\[EMV\sDYN\](.*)\[EMV\s\/DYN\]/U', $text, $attributes);
|
12 |
+
|
13 |
+
return $attributes[1];
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Return an array of strings between [EMV CONTENT] and [EMV /CONTENT]
|
18 |
+
*/
|
19 |
+
public function getEmvAttributesContentFromText($text)
|
20 |
+
{
|
21 |
+
preg_match_all('/\[EMV\sCONTENT\](.*)\[EMV\s\/CONTENT\]/U', $text, $attributes);
|
22 |
+
|
23 |
+
return $attributes[1];
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Convert an array of mapping to an array understandable by the webservice method sendObject
|
28 |
+
* @param array $attributes
|
29 |
+
*/
|
30 |
+
public function _attributesToWebServiceRequest($attributes)
|
31 |
+
{
|
32 |
+
$wsArray = array();
|
33 |
+
foreach($attributes as $key => $value)
|
34 |
+
{
|
35 |
+
$wsArray[] = array('key' => $key, 'value' => $value);
|
36 |
+
}
|
37 |
+
|
38 |
+
return array('entry' => $wsArray);
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Emv/Emt/Model/Attribute.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Model_Attribute extends Mage_Catalog_Model_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('emvemt/attribute');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function validate()
|
10 |
+
{
|
11 |
+
$error = array();
|
12 |
+
|
13 |
+
if (!Zend_Validate::is($this->getMageAttribute(), 'NotEmpty')) {
|
14 |
+
$errors[] = Mage::helper('emvemt')->__('Magento attribute is required.');
|
15 |
+
}
|
16 |
+
|
17 |
+
if (!Zend_Validate::is($this->getEmvAttribute(), 'NotEmpty')) {
|
18 |
+
$errors[] = Mage::helper('emvemt')->__('Campaign Commander attribute is required.');
|
19 |
+
}
|
20 |
+
|
21 |
+
if ($this->mageAttributeExists()) {
|
22 |
+
$errors[] = Mage::helper('emvemt')->__("Magento attribute '%s' is already mapped.",
|
23 |
+
$this->htmlEscape($this->getMageAttribute()));
|
24 |
+
}
|
25 |
+
|
26 |
+
if ($this->emvAttributeExists()) {
|
27 |
+
$errors[] = Mage::helper('emvemt')->__("Campaign Commander attribute '%s' is already mapped.",
|
28 |
+
$this->htmlEscape($this->getEmvAttribute()));
|
29 |
+
}
|
30 |
+
|
31 |
+
if (empty($errors)) {
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
return $errors;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function mageAttributeExists()
|
38 |
+
{
|
39 |
+
$result = $this->_getResource()->mageAttributeExists($this);
|
40 |
+
return (is_array($result) && count($result) > 0 ) ? true : false;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function emvAttributeExists()
|
44 |
+
{
|
45 |
+
$result = $this->_getResource()->emvAttributeExists($this);
|
46 |
+
return (is_array($result) && count($result) > 0 ) ? true : false;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Emv/Emt/Model/Emt.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{2EB12F64-51A5-4e90-9048-2BE20B080487}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Emt extends Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{B23F7DF5-EE1D-4947-9B8E-415CDB6F889F}
|
14 |
+
*/
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/emt');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* opGUID{EDA1DA15-1173-4b9c-ACA9-F11EF205DCE2}
|
22 |
+
*/
|
23 |
+
protected function beforeSave()
|
24 |
+
{
|
25 |
+
return parent::_beforeSave();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Validate first page of emt creation
|
30 |
+
*/
|
31 |
+
public function validateNewForm()
|
32 |
+
{
|
33 |
+
$error = array();
|
34 |
+
|
35 |
+
if (!Zend_Validate::is($this->getEmvAccountId(), 'NotEmpty')) {
|
36 |
+
$errors[] = Mage::helper('emvemt')->__('An EMV account is required.');
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!Zend_Validate::is($this->getMageTemplateId(), 'NotEmpty')) {
|
40 |
+
$errors[] = Mage::helper('emvemt')->__('A Magento template is required.');
|
41 |
+
}
|
42 |
+
|
43 |
+
if ($this->mageTemplateMapped()) {
|
44 |
+
$errors[] = Mage::helper('emvemt')->__('This Magento template is already mapped.');
|
45 |
+
}
|
46 |
+
|
47 |
+
if (empty($errors)) {
|
48 |
+
return true;
|
49 |
+
}
|
50 |
+
return $errors;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* opGUID{A7EFFDD7-1441-4e26-BCEE-3DCEEAFBE894}
|
55 |
+
*/
|
56 |
+
public function validate()
|
57 |
+
{
|
58 |
+
$return = $this->validateNewForm();
|
59 |
+
|
60 |
+
if(is_array($return))
|
61 |
+
{
|
62 |
+
$errors = $this->validateNewForm();
|
63 |
+
}
|
64 |
+
else
|
65 |
+
{
|
66 |
+
$errors = array();
|
67 |
+
}
|
68 |
+
|
69 |
+
if (!Zend_Validate::is($this->getEmvSendMailModeId(), 'NotEmpty')) {
|
70 |
+
$errors[] = Mage::helper('emvemt')->__('Send mail mode is required.');
|
71 |
+
}
|
72 |
+
else
|
73 |
+
{
|
74 |
+
/* @var $mailModeModel Emv_Emt_Model_MailMode_Collection */
|
75 |
+
$mailMode = Mage::getModel('emvemt/mailmode')->load($this->getSendMailModeId());
|
76 |
+
if (null === $mailMode)
|
77 |
+
{
|
78 |
+
$errors[] = Mage::helper('emvemt')->__('This send mail mode don\'t exists.');
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
if ($this->getEmvSendMailModeId() ==
|
83 |
+
Mage::getModel('emvemt/mailmode')->getIdByName('emv create'))
|
84 |
+
{
|
85 |
+
|
86 |
+
if (!Zend_Validate::is($this->getEmvTemplateId(), 'NotEmpty'))
|
87 |
+
{
|
88 |
+
$errors[] = Mage::helper('emvemt')->__('Campaign Commander template is required.');
|
89 |
+
}
|
90 |
+
else
|
91 |
+
{
|
92 |
+
try {
|
93 |
+
/* @var $account Emv_Core_Model_Account */
|
94 |
+
$account = Mage::getModel('emvcore/account')->load($this->getEmvAccountId());
|
95 |
+
|
96 |
+
/* @var $emvApiModel Emv_Core_Model_Service_Soap_Api */
|
97 |
+
$emvApiModel = Mage::getModel('emvcore/service_soap_api', $account);
|
98 |
+
|
99 |
+
if (null === $emvApiModel->getTemplateById($this->getEmvTemplateId()))
|
100 |
+
{
|
101 |
+
$errors[] = Mage::helper('emvemt')
|
102 |
+
->__('This Campaign Commander template don\'t exists.');
|
103 |
+
}
|
104 |
+
} catch (Exception $e) {
|
105 |
+
$errors[] = $e->getMessage();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
if (empty($errors)) {
|
111 |
+
return true;
|
112 |
+
}
|
113 |
+
return $errors;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function mageTemplateMapped()
|
117 |
+
{
|
118 |
+
$result = $this->_getResource()->mageTemplateMapped($this);
|
119 |
+
return (is_array($result) && count($result) > 0 ) ? true : false;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function emvTemplateExists()
|
123 |
+
{
|
124 |
+
$result = $this->_getResource()->emvTemplateExists($this);
|
125 |
+
return (is_array($result) && count($result) > 0 ) ? true : false;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Return send mail mode according to template and store id
|
130 |
+
* @param $templateId
|
131 |
+
* @param $storeId
|
132 |
+
*/
|
133 |
+
public function getMode($templateId, $storeId)
|
134 |
+
{
|
135 |
+
$accountId = Mage::getStoreConfig('emvcore/emv_account/account', $storeId);
|
136 |
+
|
137 |
+
if($accountId === null || $accountId == 0)
|
138 |
+
{
|
139 |
+
return null;
|
140 |
+
}
|
141 |
+
|
142 |
+
$emts = $this->_getEmtFromTemplateIdAndAccountId($templateId, $accountId);
|
143 |
+
$emts->getMailModeName();
|
144 |
+
$emt = $emts->getFirstItem();
|
145 |
+
|
146 |
+
return $emt->getName();
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getEmvEmt($mageTemplateId, $accountId)
|
150 |
+
{
|
151 |
+
$emts = $this->_getEmtFromTemplateIdAndAccountId($mageTemplateId, $accountId);
|
152 |
+
$emt = $emts->getFirstItem();
|
153 |
+
|
154 |
+
return $emt;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
*
|
159 |
+
* @param int $mageTemplateId
|
160 |
+
* @param int $accountId
|
161 |
+
* @return Emv_Emt_Model_Mysql4_Emt_Collection
|
162 |
+
*/
|
163 |
+
protected function _getEmtFromTemplateIdAndAccountId($mageTemplateId, $accountId)
|
164 |
+
{
|
165 |
+
/* @var $emts Emv_Emt_Model_Mysql4_Emt_Collection */
|
166 |
+
$emts = $this->getCollection();
|
167 |
+
|
168 |
+
$emts->addAccountFilter($accountId)
|
169 |
+
->addMageTemplateFilter($mageTemplateId);
|
170 |
+
|
171 |
+
return $emts;
|
172 |
+
}
|
173 |
+
}
|
app/code/community/Emv/Emt/Model/Mage/Core/Email/Template.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Model_Mage_Core_Email_Template extends Mage_Core_Model_Email_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
private $forceEmvSend = false;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Send transactional email to recipient
|
9 |
+
*
|
10 |
+
* @param int $templateId
|
11 |
+
* @param string|array $sender sender information can be declared as part of config path
|
12 |
+
* @param string $email recipient email
|
13 |
+
* @param string $name recipient name
|
14 |
+
* @param array $vars varianles which can be used in template
|
15 |
+
* @param int|null $storeId
|
16 |
+
* @return Mage_Core_Model_Email_Template
|
17 |
+
*/
|
18 |
+
public function sendTransactional($templateId, $sender, $email, $name, $vars=array(), $storeId=null)
|
19 |
+
{
|
20 |
+
if (is_numeric($templateId)) {
|
21 |
+
$this->load($templateId);
|
22 |
+
} else {
|
23 |
+
$localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
|
24 |
+
$this->loadDefault($templateId, $localeCode);
|
25 |
+
}
|
26 |
+
|
27 |
+
/* @var $emt Emv_Emt_Model_Emt */
|
28 |
+
$emt = Mage::getModel('emvemt/emt');
|
29 |
+
$mode = $emt->getMode($templateId, $storeId);
|
30 |
+
|
31 |
+
if($mode === null)
|
32 |
+
{
|
33 |
+
$mode = 'classic';
|
34 |
+
}
|
35 |
+
|
36 |
+
if($this->forceEmvSend)
|
37 |
+
{
|
38 |
+
$mode = 'emv send';
|
39 |
+
}
|
40 |
+
|
41 |
+
switch($mode)
|
42 |
+
{
|
43 |
+
case 'classic':
|
44 |
+
parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
45 |
+
break;
|
46 |
+
case 'emv create':
|
47 |
+
try {
|
48 |
+
$accountId = Mage::getStoreConfig('emvcore/emv_account/account', $storeId);
|
49 |
+
/* @var $account Emv_Emt_Model_Emt */
|
50 |
+
$emvemt = Mage::getModel('emvemt/emt')->getEmvEmt($templateId, $accountId);
|
51 |
+
|
52 |
+
$emvTemplateId = $emvemt->getEmvTemplateId();
|
53 |
+
|
54 |
+
/* @var $account Emv_Core_Model_Account */
|
55 |
+
$account = Mage::getModel('emvcore/account')->load($accountId);
|
56 |
+
/* @var $emvApiModel Emv_Core_Model_Service_Soap_Api */
|
57 |
+
$emvApiModel = Mage::getModel('emvcore/service_soap_api', $account);
|
58 |
+
|
59 |
+
/* @var $attributes Emv_Emt_Model_Mysql4_Attribute_Collection */
|
60 |
+
$attributes = Mage::getResourceModel('emvemt/attribute_collection');
|
61 |
+
$mappedEmvDynAttributes = $attributes->addEmtFilter($emvemt->getId())
|
62 |
+
->addAttributeTypeFilter(Emv_Emt_Constants::ATTRIBUTE_TYPE_EMV_DYN)
|
63 |
+
->load()->getMapping();
|
64 |
+
|
65 |
+
// get magento template variable value
|
66 |
+
$realValueEmvDynAttributes = $this->prepareAttributes($mappedEmvDynAttributes, $vars);
|
67 |
+
|
68 |
+
/* @var $attributes Emv_Emt_Model_Mysql4_Attribute_Collection */
|
69 |
+
$attributes2 = Mage::getResourceModel('emvemt/attribute_collection');
|
70 |
+
$mappedEmvContentAttributes = $attributes2->addEmtFilter($emvemt->getId())
|
71 |
+
->addAttributeTypeFilter(Emv_Emt_Constants::ATTRIBUTE_TYPE_EMV_CONTENT)
|
72 |
+
->load()->getMapping();
|
73 |
+
|
74 |
+
// get magento template variable value
|
75 |
+
$realValueEmvContentAttributes = $this->prepareAttributes($mappedEmvContentAttributes, $vars);
|
76 |
+
|
77 |
+
//Send the email
|
78 |
+
$emvTemplate = $emvApiModel->getTemplateById($emvTemplateId);
|
79 |
+
$emvApiModel->sendEmv($emvTemplate,
|
80 |
+
Mage::helper('emvemt/emvtemplate')->_attributesToWebServiceRequest($realValueEmvDynAttributes),
|
81 |
+
$email, Mage::helper('emvemt/emvtemplate')->_attributesToWebServiceRequest($realValueEmvContentAttributes));
|
82 |
+
} catch (Exception $e) {
|
83 |
+
Mage::log('Error with CC trying do send mail in classic mode', null,
|
84 |
+
Mage::helper('emvcore')->LOG_FILE);
|
85 |
+
parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
86 |
+
}
|
87 |
+
break;
|
88 |
+
case 'emv send':
|
89 |
+
try {
|
90 |
+
$this->setTemplateText($this->getProcessedTemplate($vars));
|
91 |
+
$this->setTemplateSubject($this->getProcessedTemplateSubject($vars));
|
92 |
+
$accountId = Mage::getStoreConfig('emvcore/emv_account/account', $storeId);
|
93 |
+
/* @var $account Emv_Core_Model_Account */
|
94 |
+
$account = Mage::getModel('emvcore/account')->load($accountId);
|
95 |
+
|
96 |
+
if (!is_array($sender)) {
|
97 |
+
$this->setSenderName(Mage::getStoreConfig('trans_email/ident_'.$sender.'/name', $storeId));
|
98 |
+
$this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_'.$sender.'/email', $storeId));
|
99 |
+
} else {
|
100 |
+
$this->setSenderName($sender['name']);
|
101 |
+
$this->setSenderEmail($sender['email']);
|
102 |
+
}
|
103 |
+
|
104 |
+
/* @var $emvApiModel Emv_Core_Model_Service_Soap_Api */
|
105 |
+
$emvApiModel = Mage::getModel('emvcore/service_soap_api', $account);
|
106 |
+
if($name === null)
|
107 |
+
{
|
108 |
+
$name = $email;
|
109 |
+
}
|
110 |
+
$emvApiModel->sendEmvEmt($this, $name, $email);
|
111 |
+
} catch (Exception $e) {
|
112 |
+
Mage::log('Error with CC trying do send mail in classic mode', null,
|
113 |
+
Mage::helper('emvcore')->LOG_FILE);
|
114 |
+
parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
115 |
+
}
|
116 |
+
break;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Return values of magento template variables in an array
|
122 |
+
* @param array $attributesArray
|
123 |
+
* @param array $var array of magento instance (cutomer, order ...) where we going to
|
124 |
+
* pick values
|
125 |
+
*/
|
126 |
+
public function prepareAttributes($attributesArray, $var)
|
127 |
+
{
|
128 |
+
|
129 |
+
$attributesWithValues = array();
|
130 |
+
|
131 |
+
$this->setTemplateStyles(null);
|
132 |
+
|
133 |
+
foreach($attributesArray as $emv => $mage)
|
134 |
+
{
|
135 |
+
if(preg_match(Varien_Filter_Template::CONSTRUCTION_PATTERN, $mage))
|
136 |
+
{
|
137 |
+
$this->setTemplateText($mage);
|
138 |
+
$attributesWithValues[$emv] = $this->getProcessedTemplate($var);
|
139 |
+
}
|
140 |
+
else
|
141 |
+
{
|
142 |
+
//it's a constant
|
143 |
+
$attributesWithValues[$emv] = $mage;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $attributesWithValues;
|
148 |
+
}
|
149 |
+
|
150 |
+
public function forceEmvSend()
|
151 |
+
{
|
152 |
+
$this->forceEmvSend = true;
|
153 |
+
}
|
154 |
+
|
155 |
+
public function disableForceEmvSend()
|
156 |
+
{
|
157 |
+
$this->forceEmvSend = false;
|
158 |
+
}
|
159 |
+
}
|
app/code/community/Emv/Emt/Model/MageTemplate.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Emv_Emt_Model_MageTemplate extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function getNotMappedMageTemplateCollection($emvAccountId)
|
7 |
+
{
|
8 |
+
if(!is_numeric($emvAccountId))
|
9 |
+
{
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
|
13 |
+
/* @var $magentoTemplates Mage_Core_Model_Mysql4_Email_Template_Collection */
|
14 |
+
$magentoTemplates = Mage::getResourceModel('core/email_template_collection');
|
15 |
+
|
16 |
+
$emt = Mage::getResourceModel('emvemt/emt_collection');
|
17 |
+
$emt->addFieldToFilter('emv_account_id', $emvAccountId);
|
18 |
+
$emt->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('mage_template_id')->where("emv_account_id = ?", $emvAccountId);
|
19 |
+
|
20 |
+
$magentoTemplates->addFieldToFilter('template_id', array('nin' => $emt->getSelect()));
|
21 |
+
|
22 |
+
$magentoTemplates->load();
|
23 |
+
|
24 |
+
return $magentoTemplates;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Emv/Emt/Model/Mailmode.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{2EB12F64-51A5-4e90-9048-2BE20B080487}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Mailmode extends Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{B23F7DF5-EE1D-4947-9B8E-415CDB6F889F}
|
14 |
+
*/
|
15 |
+
public function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/mailmode');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getIdByName($name)
|
21 |
+
{
|
22 |
+
/* @var $emts Emv_Emt_Model_Mysql4_Mailmode_Collection */
|
23 |
+
$modes = $this->getCollection();
|
24 |
+
|
25 |
+
$modes->addNameFilter($name);
|
26 |
+
$mode = $modes->getFirstItem();
|
27 |
+
|
28 |
+
return $mode->getId();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* opGUID{EDA1DA15-1173-4b9c-ACA9-F11EF205DCE2}
|
33 |
+
*/
|
34 |
+
protected function beforeSave()
|
35 |
+
{
|
36 |
+
$this->validate();
|
37 |
+
return parent::_beforeSave();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* opGUID{A7EFFDD7-1441-4e26-BCEE-3DCEEAFBE894}
|
42 |
+
*/
|
43 |
+
private function validate()
|
44 |
+
{
|
45 |
+
//TODO
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Attribute.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Model_Mysql4_Attribute extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('emvemt/attribute', 'id');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function mageAttributeExists(Mage_Core_Model_Abstract $attribute)
|
10 |
+
{
|
11 |
+
return $this->_fieldAlreadyExist('mage_attribute', $attribute->getMageAttribute,
|
12 |
+
$attribute->getEmvEmtId, $attribute->getId());
|
13 |
+
}
|
14 |
+
|
15 |
+
public function emvAttributeExists(Mage_Core_Model_Abstract $attribute)
|
16 |
+
{
|
17 |
+
return $this->_fieldAlreadyExist('emv_attribute', $attribute->getEmvAttribute,
|
18 |
+
$attribute->getEmvEmtId, $attribute->getId());
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Check if a value associated to an emt already exists in a column
|
23 |
+
* @param $columnName string database column where to check unicity
|
24 |
+
* @param $fieldValue string value to check unicity
|
25 |
+
* @param $emtId string
|
26 |
+
* @param $mappingId integer
|
27 |
+
*/
|
28 |
+
protected function _fieldAlreadyExist($columnName, $fieldValue, $emtId, $mappingId)
|
29 |
+
{
|
30 |
+
$attributeTable = $this->getTable('emvemt/attribute');
|
31 |
+
$select = $this->_getReadAdapter()->select();
|
32 |
+
$select->from($attributeTable);
|
33 |
+
$select->where("{$attributeTable}.{$columnName} = '{$fieldValue}' ".
|
34 |
+
"AND {$attributeTable}.emv_emt_id = '{$emtId}' ".
|
35 |
+
"AND {$attributeTable}.id != '{$mappingId}'");
|
36 |
+
return $this->_getReadAdapter()->fetchRow($select);
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Attribute/Collection.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emv_Emt_Model_Mysql4_Attribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('emvemt/attribute','emvemt/attribute');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function addEmtFilter($emtId)
|
11 |
+
{
|
12 |
+
$this->getSelect()->where('main_table.emv_emt_id = ?', $emtId);
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function addAttributeTypeFilter($attributeType)
|
17 |
+
{
|
18 |
+
$this->getSelect()->where('main_table.emv_attribute_type = ?', $attributeType);
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Return mapped attributes in an array of array (key is Campaign Commander attribute name, value is
|
24 |
+
* magento attribute name).
|
25 |
+
* ex :
|
26 |
+
* array ( 'emvAttribute1' => 'customer.firstname',
|
27 |
+
* 'emvAttribute2' => 'customer.lastname')
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
public function getMapping()
|
31 |
+
{
|
32 |
+
$mappedAttributes = array();
|
33 |
+
foreach($this as $mapping)
|
34 |
+
{
|
35 |
+
$mappedAttributes[$mapping->getEmvAttribute()] = $mapping->getMageAttribute();
|
36 |
+
}
|
37 |
+
|
38 |
+
return $mappedAttributes;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Emt.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{7F6F8AE8-32E4-464d-BC2A-41496B850033}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Mysql4_Emt extends Mage_Core_Model_Mysql4_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{CC97992D-58AB-4416-9D3D-A745A91C759D}
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/emt','id');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function mageTemplateMapped(Mage_Core_Model_Abstract $emt)
|
21 |
+
{
|
22 |
+
$emtTable = $this->getTable('emvemt/emt');
|
23 |
+
$select = $this->_getReadAdapter()->select();
|
24 |
+
$select->from($emtTable);
|
25 |
+
$select->where("{$emtTable}.mage_template_id = '{$emt->getMageTemplateId()}' AND ".
|
26 |
+
"{$emtTable}.emv_account_id = '{$emt->getEmvAccountId()}' AND ".
|
27 |
+
"{$emtTable}.id != '{$emt->getId()}'");
|
28 |
+
return $this->_getReadAdapter()->fetchRow($select);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function emvTemplateExists(Mage_Core_Model_Abstract $emt)
|
32 |
+
{
|
33 |
+
$emtTable = $this->getTable('emvemt/emt');
|
34 |
+
$select = $this->_getReadAdapter()->select();
|
35 |
+
$select->from($emtTable);
|
36 |
+
$select->where("{$emtTable}.emv_template_id = '{$emt->getEmvTemplateId()}' ".
|
37 |
+
"AND {$emtTable}.id != '{$emt->getId()}'");
|
38 |
+
return $this->_getReadAdapter()->fetchRow($select);
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Emt/Collection.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{BC3880C7-9F66-4b24-A15E-84573DEE1F72}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Mysql4_Emt_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{CEA29ABD-15C0-4159-96C7-0FEFA9101B67}
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/emt','emvemt/emt');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Join collection with the Magento template name
|
22 |
+
*/
|
23 |
+
public function getMagentoEMTName()
|
24 |
+
{
|
25 |
+
$this->join('core/email_template', 'mage_template_id=template_id', 'template_code');
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Join collection with the Magento template name
|
31 |
+
*/
|
32 |
+
public function getMailModeName()
|
33 |
+
{
|
34 |
+
$this->join('emvemt/mailmode', 'emv_send_mail_mode_id=`emvemt/mailmode`.id', 'name');
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function addAccountFilter($accountId)
|
39 |
+
{
|
40 |
+
$this->addFieldToFilter('emv_account_id', array('eq' => $accountId));
|
41 |
+
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function addMageTemplateFilter($mageTemplateId)
|
46 |
+
{
|
47 |
+
$this->addFieldToFilter('mage_template_id', array('eq' => $mageTemplateId));
|
48 |
+
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Join collection with EMV template name thanks to campaign commander webservices
|
54 |
+
*/
|
55 |
+
public function getEMVTemplateName()
|
56 |
+
{
|
57 |
+
foreach ($this as $emt)
|
58 |
+
{
|
59 |
+
$id = $emt->getEmvTemplateId();
|
60 |
+
|
61 |
+
if($id !== null)
|
62 |
+
{
|
63 |
+
try {
|
64 |
+
|
65 |
+
/* @var $account Emv_Core_Model_Account */
|
66 |
+
$account = Mage::getModel('emvcore/account')->load($emt->getEmvAccountId());
|
67 |
+
|
68 |
+
/* @var $soap Emv_Core_Model_Service_Soap_Api */
|
69 |
+
$soap = Mage::getModel('emvcore/service_soap_api', $account);
|
70 |
+
|
71 |
+
$EMVTemplate = $soap->getTemplateById($id);
|
72 |
+
|
73 |
+
if(isset($EMVTemplate->name))
|
74 |
+
{
|
75 |
+
$emt->setEmvTemplateIdAndName( $id. ' / ' . $EMVTemplate->name);
|
76 |
+
}
|
77 |
+
else
|
78 |
+
{
|
79 |
+
$emt->setEmvTemplateIdAndName( $id. ' / No Name');
|
80 |
+
}
|
81 |
+
|
82 |
+
} catch (Exception $e) {
|
83 |
+
// if we couln't connect to the WS we just display the Id
|
84 |
+
$emt->setEmvTemplateIdAndName( $id );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
$emt->setEmvTemplateIdAndName( '' );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Mailmode.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{7F6F8AE8-32E4-464d-BC2A-41496B850033}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Mysql4_Mailmode extends Mage_Core_Model_Mysql4_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{CC97992D-58AB-4416-9D3D-A745A91C759D}
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/mailmode','id');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Emv/Emt/Model/Mysql4/Mailmode/Collection.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{BC3880C7-9F66-4b24-A15E-84573DEE1F72}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Mysql4_Mailmode_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* opGUID{CEA29ABD-15C0-4159-96C7-0FEFA9101B67}
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('emvemt/mailmode','emvemt/mailmode');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function toOptionArray()
|
21 |
+
{
|
22 |
+
return $this->_toOptionArray('id', 'name');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function addNameFilter($name)
|
26 |
+
{
|
27 |
+
$this->addFieldToFilter('name', array('eq' => $name));
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Emv/Emt/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{4757F1CF-7E30-475d-B6FA-81A4944D693F}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
10 |
+
{
|
11 |
+
|
12 |
+
}
|
app/code/community/Emv/Emt/controllers/Adminhtml/EmtController.php
ADDED
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category
|
5 |
+
* @package
|
6 |
+
* @author cservieres <info@x2i.fr>
|
7 |
+
* @version 1.0 eaGUID{C6D231D8-0B37-457d-9DE1-7B4AA8B86B9B}
|
8 |
+
*/
|
9 |
+
class Emv_Emt_Adminhtml_EmtController extends Mage_Adminhtml_Controller_Action
|
10 |
+
{
|
11 |
+
|
12 |
+
protected function _initAction()
|
13 |
+
{
|
14 |
+
$this->loadLayout();
|
15 |
+
$this->_setActiveMenu('system/emvemt');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initialise the account model.
|
20 |
+
*
|
21 |
+
* @return Emv_Emt_Model_Emt
|
22 |
+
*/
|
23 |
+
protected function _initEmt()
|
24 |
+
{
|
25 |
+
$id = $this->getRequest()->getParam('id', null);
|
26 |
+
$emtModel = Mage::getModel('emvemt/emt')->load($id);
|
27 |
+
Mage::register('current_emvemt', $emtModel);
|
28 |
+
|
29 |
+
// take attributes of this emt
|
30 |
+
$collection = Mage::getResourceModel('emvemt/attribute_collection')
|
31 |
+
->addEmtFilter($emtModel->getId())
|
32 |
+
->load();
|
33 |
+
$result = array();
|
34 |
+
foreach ($collection as $attribute) {
|
35 |
+
$result[] = $attribute->getData();
|
36 |
+
}
|
37 |
+
|
38 |
+
Mage::register('emt_attributes', $result);
|
39 |
+
|
40 |
+
return $emtModel;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* opGUID{013E0776-95CB-44d2-97D3-DC99D91F7C34}
|
45 |
+
*/
|
46 |
+
public function indexAction()
|
47 |
+
{
|
48 |
+
$this->_initAction();
|
49 |
+
$this->_addContent($this->getLayout()->createBlock('emvemt/adminhtml_emts'));
|
50 |
+
$this->renderLayout();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* opGUID{FF53F7D3-4A3E-4549-B687-FF295606F803}
|
55 |
+
*/
|
56 |
+
public function editAction()
|
57 |
+
{
|
58 |
+
$this->_initAction();
|
59 |
+
$emtModel = $this->_initEmt();
|
60 |
+
|
61 |
+
$data = $this->_getSession()->getEditEmtFormData(true);
|
62 |
+
if(isset($data))
|
63 |
+
{
|
64 |
+
// set entered data if was error when we do save
|
65 |
+
$emtModel->addData($data);
|
66 |
+
}
|
67 |
+
|
68 |
+
try {
|
69 |
+
if(null !== $emtModel->getEmvAccountId() && null !== $emtModel->getEmvTemplateId())
|
70 |
+
{
|
71 |
+
/* @var $account Emv_Core_Model_Account */
|
72 |
+
$account = Mage::getModel('emvcore/account')->load($emtModel->getEmvAccountId());
|
73 |
+
|
74 |
+
/* @var $soap Emv_Core_Model_Service_Soap_Api */
|
75 |
+
$soap = Mage::getModel('emvcore/service_soap_api', $account);
|
76 |
+
|
77 |
+
Mage::register('current_emv_template_array',
|
78 |
+
$soap->getTemplateInfoInArray($emtModel->getEmvTemplateId()));
|
79 |
+
}
|
80 |
+
|
81 |
+
$mageTemplateName = Mage::getModel('core/email_template')
|
82 |
+
->load($emtModel->getMageTemplateId())->getTemplateCode();
|
83 |
+
Mage::register('mage_template_name', $mageTemplateName);
|
84 |
+
Mage::register('emt_accounts', Mage::getResourceModel('emvcore/account_collection'));
|
85 |
+
Mage::register('mail_modes', Mage::getResourceModel('emvemt/mailmode_collection'));
|
86 |
+
Mage::register('mage_templates', Mage::getResourceModel('core/email_template_collection'));
|
87 |
+
|
88 |
+
$this->_addContent($this->getLayout()->createBlock('emvemt/adminhtml_emt_edit'));
|
89 |
+
$this->renderLayout();
|
90 |
+
} catch (Exception $e) {
|
91 |
+
$this->_getSession()->addError($e->getMessage());
|
92 |
+
$this->_redirect('*/*/index');
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
public function newAction()
|
98 |
+
{
|
99 |
+
|
100 |
+
// Check if an emv account is set
|
101 |
+
$emvAccount = Mage::getResourceModel('emvcore/account_collection');
|
102 |
+
$accountId = $emvAccount->getFirstItem()->getId();
|
103 |
+
if(null === $accountId)
|
104 |
+
{
|
105 |
+
$this->_getSession()->addError(Mage::helper('emvemt')->__('A Campaign Commander account has not been set.'));
|
106 |
+
$this->_redirect('*/*/index');
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
$this->_initAction();
|
111 |
+
$this->_addContent($this->getLayout()->createBlock('emvemt/adminhtml_emt_new'));
|
112 |
+
$this->renderLayout();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Return an select with emv from periode $from to $to
|
117 |
+
*/
|
118 |
+
public function getEmvTemplateSelectAjaxAction()
|
119 |
+
{
|
120 |
+
$data = $this->getRequest()->getPost();
|
121 |
+
$data['from'] = Mage::helper('core')->escapeHtml($data['from']);
|
122 |
+
$data['to'] = Mage::helper('core')->escapeHtml($data['to']);
|
123 |
+
$data['accountId'] = Mage::helper('core')->escapeHtml($data['accountId']);
|
124 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(
|
125 |
+
Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
|
126 |
+
);
|
127 |
+
|
128 |
+
$locale = Mage::app()->getLocale()->getLocale();
|
129 |
+
|
130 |
+
/* @var $from_2 Zend_Date */
|
131 |
+
/* @var $to_2 Zend_Date */
|
132 |
+
if(!Zend_Date::isDate($data['from'], $dateFormatIso, $locale))
|
133 |
+
{
|
134 |
+
//set a default large periode to match all campaign commander templates
|
135 |
+
$from_2 = new Zend_Date('1980-01-01', 'YYYY-MM-dd', $locale);
|
136 |
+
}
|
137 |
+
else
|
138 |
+
{
|
139 |
+
$from_2 = new Zend_Date($data['from'], $dateFormatIso, $locale);
|
140 |
+
}
|
141 |
+
|
142 |
+
if(!Zend_Date::isDate($data['to'], $dateFormatIso, $locale))
|
143 |
+
{
|
144 |
+
$to_2 = Zend_Date::now($locale);
|
145 |
+
}
|
146 |
+
else
|
147 |
+
{
|
148 |
+
$to_2 = new Zend_Date($data['to'], $dateFormatIso, $locale);
|
149 |
+
}
|
150 |
+
|
151 |
+
// make the period cover all the day because Zend_Date set hour to 00:00:00 by default
|
152 |
+
// so we add 23h59m59s
|
153 |
+
$to_2->addHour(23);
|
154 |
+
$to_2->addMinute(59);
|
155 |
+
$to_2->addSecond(59);
|
156 |
+
|
157 |
+
$apiDateFormat = 'YYYY-MM-dd HH:mm:ss';
|
158 |
+
|
159 |
+
try {
|
160 |
+
/* @var $account Emv_Core_Model_Account */
|
161 |
+
$account = Mage::getModel('emvcore/account')->load($data['accountId']);
|
162 |
+
|
163 |
+
/* @var $soap Emv_Core_Model_Service_Soap_Api */
|
164 |
+
$soap = Mage::getModel('emvcore/service_soap_api', $account);
|
165 |
+
|
166 |
+
$templatesId = $soap->getTemplatesByPeriod($from_2->toString($apiDateFormat),
|
167 |
+
$to_2->toString($apiDateFormat));
|
168 |
+
|
169 |
+
$options = array();
|
170 |
+
if(is_array($templatesId))
|
171 |
+
{
|
172 |
+
foreach ($templatesId as $templateId)
|
173 |
+
{
|
174 |
+
$options[] = $soap->getTemplateInfoInArray($templateId);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
elseif($templatesId !== null)
|
178 |
+
{
|
179 |
+
$options[] = $soap->getTemplateInfoInArray($templatesId);
|
180 |
+
}
|
181 |
+
else
|
182 |
+
{
|
183 |
+
echo '<strong id="emv_template_id">'.
|
184 |
+
Mage::helper('emvemt')->__('There isn\'t any template in this period').
|
185 |
+
'</strong>';
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
|
189 |
+
$select = $this->getLayout()->createBlock('adminhtml/html_select')
|
190 |
+
->setId('emv_template_id')
|
191 |
+
->setName('emv_template_id')
|
192 |
+
->setOptions($options);
|
193 |
+
|
194 |
+
echo $select->getHtml();
|
195 |
+
} catch (Exception $e) {
|
196 |
+
echo $e->getMessage();
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Display a select of magento template not already mapped with the emv account given in post
|
202 |
+
*/
|
203 |
+
public function getNotMappedMagentoTemplateSelectAjaxAction()
|
204 |
+
{
|
205 |
+
$data = $this->getRequest()->getPost();
|
206 |
+
|
207 |
+
/* @var $magentoTemplates Mage_Core_Model_Mysql4_Email_Template_Collection */
|
208 |
+
$magentoTemplates = Mage::getModel('emvemt/mageTemplate')->getNotMappedMageTemplateCollection($data['emvAccount']);
|
209 |
+
|
210 |
+
if($magentoTemplates->getSize() == 0)
|
211 |
+
{
|
212 |
+
echo '<strong id="mage_template_id">'.
|
213 |
+
Mage::helper('emvemt')->__('There is no Magento templates not mapped with this account.').
|
214 |
+
'</strong>';
|
215 |
+
}
|
216 |
+
else
|
217 |
+
{
|
218 |
+
$options = $magentoTemplates->toOptionArray();
|
219 |
+
|
220 |
+
$select = $this->getLayout()->createBlock('adminhtml/html_select')
|
221 |
+
->setId('mage_template_id')
|
222 |
+
->setName('mage_template_id')
|
223 |
+
->setOptions($options);
|
224 |
+
|
225 |
+
echo $select->getHtml();
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getEmvAttributesSelectAjaxAction()
|
230 |
+
{
|
231 |
+
$data = $this->getRequest()->getPost();
|
232 |
+
|
233 |
+
$data['emv_attribute_type'] = Mage::helper('core')->escapeHtml($data['emv_attribute_type']);
|
234 |
+
$data['emvTemplateId'] = Mage::helper('core')->escapeHtml($data['emvTemplateId']);
|
235 |
+
$data['index'] = Mage::helper('core')->escapeHtml($data['index']);
|
236 |
+
$data['accountId'] = Mage::helper('core')->escapeHtml($data['accountId']);
|
237 |
+
if(key_exists('default_value', $data))
|
238 |
+
{
|
239 |
+
$data['default_value'] = Mage::helper('core')->escapeHtml($data['default_value']);
|
240 |
+
}
|
241 |
+
|
242 |
+
if(isset($data['emvTemplateId']))
|
243 |
+
{
|
244 |
+
$options = array('' => $this->__('Custom attribute, no mapping'));
|
245 |
+
|
246 |
+
/* @var $account Emv_Core_Model_Account */
|
247 |
+
$account = Mage::getModel('emvcore/account')->load($data['accountId']);
|
248 |
+
|
249 |
+
/* @var $soap Emv_Core_Model_Service_Soap_Api */
|
250 |
+
$soap = Mage::getModel('emvcore/service_soap_api', $account);
|
251 |
+
|
252 |
+
try {
|
253 |
+
$template = $soap->getTemplateById($data['emvTemplateId']);
|
254 |
+
|
255 |
+
$text = '';
|
256 |
+
if(isset($template->body))
|
257 |
+
{
|
258 |
+
$text .= $template->body;
|
259 |
+
}
|
260 |
+
if(isset($template->from))
|
261 |
+
{
|
262 |
+
$text .= $template->from;
|
263 |
+
}
|
264 |
+
if(isset($template->to))
|
265 |
+
{
|
266 |
+
$text .= $template->to;
|
267 |
+
}
|
268 |
+
if(isset($template->replyTo))
|
269 |
+
{
|
270 |
+
$text .= $template->replyTo;
|
271 |
+
}
|
272 |
+
if(isset($template->replyToEmail))
|
273 |
+
{
|
274 |
+
$text .= $template->replyToEmail;
|
275 |
+
}
|
276 |
+
if(isset($template->subject))
|
277 |
+
{
|
278 |
+
$text .= $template->subject;
|
279 |
+
}
|
280 |
+
|
281 |
+
$attributes = array();
|
282 |
+
|
283 |
+
if(Emv_Emt_Constants::ATTRIBUTE_TYPE_EMV_CONTENT == $data['emv_attribute_type'])
|
284 |
+
{
|
285 |
+
$attributes = Mage::helper('emvemt/emvtemplate')->getEmvAttributesContentFromText($text);
|
286 |
+
}
|
287 |
+
elseif(Emv_Emt_Constants::ATTRIBUTE_TYPE_EMV_DYN == $data['emv_attribute_type'])
|
288 |
+
{
|
289 |
+
$attributes = Mage::helper('emvemt/emvtemplate')->getEmvAttributesFromText($text);
|
290 |
+
}
|
291 |
+
|
292 |
+
foreach ($attributes as $attribute)
|
293 |
+
{
|
294 |
+
$options[$attribute] = $attribute;
|
295 |
+
}
|
296 |
+
|
297 |
+
$select = $this->getLayout()->createBlock('adminhtml/html_select')
|
298 |
+
->setId('emv_attribute_'.$data['index'].'_emv_attribute')
|
299 |
+
->setName('attributes['.$data['index'].'][emv_attribute]')
|
300 |
+
->setOptions($options);
|
301 |
+
if(isset($data['default_value']))
|
302 |
+
{
|
303 |
+
$select->setValue($data['default_value']);
|
304 |
+
}
|
305 |
+
echo $select->getHtml();
|
306 |
+
} catch (Exception $e) {
|
307 |
+
echo $e->getMessage();
|
308 |
+
}
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
public function saveAction()
|
313 |
+
{
|
314 |
+
if ($data = $this->getRequest()->getPost())
|
315 |
+
{
|
316 |
+
$emtId = $this->getRequest()->getParam('id', null);
|
317 |
+
|
318 |
+
$emtModel = Mage::getModel('emvemt/emt')->load($emtId);
|
319 |
+
$emtModel->addData($data);
|
320 |
+
|
321 |
+
//reset emt template if user switch mail mode from 'emv create / Campaign Commander Template' to 'emv send' or 'classic'
|
322 |
+
if($emtModel->getEmvSendMailModeId() ===
|
323 |
+
Mage::getModel('emvemt/mailmode')->getIdByName('classic') ||
|
324 |
+
$emtModel->getEmvSendMailModeId() ===
|
325 |
+
Mage::getModel('emvemt/mailmode')->getIdByName('emv send'))
|
326 |
+
{
|
327 |
+
$emtModel->setEmvTemplateId(null);
|
328 |
+
}
|
329 |
+
|
330 |
+
if (null !== $emtId)
|
331 |
+
{
|
332 |
+
// we're in mode edit (2nd form)
|
333 |
+
$result = $emtModel->validate();
|
334 |
+
if (is_array($result))
|
335 |
+
{
|
336 |
+
$this->_getSession()->setEditEmtFormData($data);
|
337 |
+
foreach ($result as $message)
|
338 |
+
{
|
339 |
+
$this->_getSession()->addError($message);
|
340 |
+
}
|
341 |
+
$this->_redirect('*/*/edit', array('id'=>$emtModel->getId()));
|
342 |
+
return $this;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
else
|
346 |
+
{
|
347 |
+
// set send mode to classic by default
|
348 |
+
$emtModel->setEmvSendMailModeId(
|
349 |
+
Mage::getModel('emvemt/mailmode')->getIdByName('classic'));
|
350 |
+
|
351 |
+
// we're in 1st form
|
352 |
+
$result = $emtModel->validateNewForm();
|
353 |
+
|
354 |
+
if (is_array($result))
|
355 |
+
{
|
356 |
+
foreach ($result as $message)
|
357 |
+
{
|
358 |
+
$this->_getSession()->addError($message);
|
359 |
+
}
|
360 |
+
$this->_redirect('*/*/new');
|
361 |
+
return $this;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
try {
|
366 |
+
$emtModel->save();
|
367 |
+
|
368 |
+
if(null !== $emtId)
|
369 |
+
{
|
370 |
+
// User come from edit mode
|
371 |
+
// delete old mapping attribute
|
372 |
+
$this->_deleteAllEmtAttribute($emtModel->getId());
|
373 |
+
|
374 |
+
if($emtModel->getEmvSendMailModeId() ===
|
375 |
+
Mage::getModel('emvemt/mailmode')->getIdByName('emv create'))
|
376 |
+
{
|
377 |
+
$attributes = $this->getRequest()->getParam('attributes');
|
378 |
+
if (is_array($attributes))
|
379 |
+
{
|
380 |
+
$modelId = $emtModel->getId();
|
381 |
+
|
382 |
+
foreach ($attributes as $attrInfo)
|
383 |
+
{
|
384 |
+
if (isset($attrInfo['delete']) && $attrInfo['delete'] == 1) {
|
385 |
+
continue;
|
386 |
+
}
|
387 |
+
|
388 |
+
$attributeModel = Mage::getModel('emvemt/attribute')
|
389 |
+
->setEmvAttribute($attrInfo['emv_attribute'])
|
390 |
+
->setEmvAttributeType($attrInfo['emv_attribute_type'])
|
391 |
+
->setMageAttribute($attrInfo['mage_attribute'])
|
392 |
+
->setEmvEmtId($modelId);
|
393 |
+
|
394 |
+
$result = $attributeModel->validate();
|
395 |
+
|
396 |
+
if (is_array($result))
|
397 |
+
{
|
398 |
+
$this->_getSession()->setEditEmtFormData($data);
|
399 |
+
foreach ($result as $message)
|
400 |
+
{
|
401 |
+
$this->_getSession()->addError($message);
|
402 |
+
}
|
403 |
+
$this->_redirect('*/*/edit', array('id'=>$emtModel->getId()));
|
404 |
+
return $this;
|
405 |
+
}
|
406 |
+
$attributeModel->save();
|
407 |
+
}
|
408 |
+
}
|
409 |
+
}
|
410 |
+
$this->_getSession()->addSuccess(
|
411 |
+
Mage::helper('emvemt')->__('The Campaign Commander account has been saved.'));
|
412 |
+
$this->_redirect('*/*/');
|
413 |
+
}
|
414 |
+
else
|
415 |
+
{
|
416 |
+
//user come from New form so we redirect him to second part of form (edit)
|
417 |
+
$this->_redirect('*/*/edit', array('id'=>$emtModel->getId()));
|
418 |
+
}
|
419 |
+
return;
|
420 |
+
} catch (Exception $e) {
|
421 |
+
$this->_getSession()->addError($e->getMessage());
|
422 |
+
$this->_getSession()->setEditEmtFormData($data);
|
423 |
+
if(null !== $emtId)
|
424 |
+
{
|
425 |
+
$this->_redirect('*/*/edit', array('id'=>$emtModel->getId()));
|
426 |
+
}
|
427 |
+
else
|
428 |
+
{
|
429 |
+
$this->_redirect('*/*/');
|
430 |
+
}
|
431 |
+
return;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
$this->_redirect('*/*/');
|
435 |
+
return;
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Delete all mapping attribute of an emt
|
440 |
+
**/
|
441 |
+
protected function _deleteAllEmtAttribute($emtId)
|
442 |
+
{
|
443 |
+
$collection = Mage::getResourceModel('emvemt/attribute_collection')
|
444 |
+
->addEmtFilter($emtId);
|
445 |
+
$collection->walk('delete');
|
446 |
+
}
|
447 |
+
|
448 |
+
public function deleteAction()
|
449 |
+
{
|
450 |
+
if ($id = $this->getRequest()->getParam('id'))
|
451 |
+
{
|
452 |
+
try {
|
453 |
+
$this->_deleteAllEmtAttribute($id);
|
454 |
+
|
455 |
+
$model = Mage::getModel('emvemt/emt')->load($id);
|
456 |
+
$model->delete();
|
457 |
+
$this->_getSession()->addSuccess(
|
458 |
+
Mage::helper('emvemt')->__('EMT deleted.'));
|
459 |
+
$this->_redirect('*/*/');
|
460 |
+
return;
|
461 |
+
}
|
462 |
+
catch (Exception $e) {
|
463 |
+
$this->_getSession()->addError($e->getMessage());
|
464 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getPost('id')));
|
465 |
+
return;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('emvemt')
|
469 |
+
->__('Unable to find an emt to delete.'));
|
470 |
+
$this->_redirect('*/*/');
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* opGUID{DEBEFFFC-1E57-43a2-8A05-DA0F0F15FAE2}
|
475 |
+
*
|
476 |
+
* @return boolean
|
477 |
+
*/
|
478 |
+
protected function _isallowed()
|
479 |
+
{
|
480 |
+
//TODO
|
481 |
+
return true;
|
482 |
+
}
|
483 |
+
|
484 |
+
}
|
app/code/community/Emv/Emt/etc/adminhtml.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<system>
|
5 |
+
<children>
|
6 |
+
<emvemt translate="title" module="emvemt">
|
7 |
+
<title>Campaign Commander EMT</title>
|
8 |
+
<sort_order>1000</sort_order>
|
9 |
+
<action>emailvisionemt/emt</action>
|
10 |
+
</emvemt>
|
11 |
+
</children>
|
12 |
+
</system>
|
13 |
+
</menu>
|
14 |
+
<acl>
|
15 |
+
<resources>
|
16 |
+
<admin>
|
17 |
+
<children>
|
18 |
+
<system>
|
19 |
+
<children>
|
20 |
+
<emvemt translate="title" module="emvemt">
|
21 |
+
<title>Campaign Commander EMT</title>
|
22 |
+
<sort_order>1000</sort_order>
|
23 |
+
</emvemt>
|
24 |
+
<config>
|
25 |
+
<children>
|
26 |
+
<emvemt translate="title" module="emvemt">
|
27 |
+
<title>Campaign Commander EMT</title>
|
28 |
+
<sort_order>1000</sort_order>
|
29 |
+
</emvemt>
|
30 |
+
</children>
|
31 |
+
</config>
|
32 |
+
</children>
|
33 |
+
</system>
|
34 |
+
</children>
|
35 |
+
</admin>
|
36 |
+
</resources>
|
37 |
+
</acl>
|
38 |
+
</config>
|
app/code/community/Emv/Emt/etc/config.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Emv_Emt>
|
5 |
+
<version>0.2.0</version>
|
6 |
+
</Emv_Emt>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<emvemt>
|
11 |
+
<class>Emv_Emt_Block</class>
|
12 |
+
</emvemt>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<emvemt>
|
16 |
+
<class>Emv_Emt_Helper</class>
|
17 |
+
</emvemt>
|
18 |
+
</helpers>
|
19 |
+
<models>
|
20 |
+
<core>
|
21 |
+
<rewrite>
|
22 |
+
<email_template>Emv_Emt_Model_Mage_Core_Email_Template</email_template>
|
23 |
+
</rewrite>
|
24 |
+
</core>
|
25 |
+
<emvemt>
|
26 |
+
<class>Emv_Emt_Model</class>
|
27 |
+
<resourceModel>emvemt_mysql4</resourceModel>
|
28 |
+
</emvemt>
|
29 |
+
<emvemt_mysql4>
|
30 |
+
<class>Emv_Emt_Model_Mysql4</class>
|
31 |
+
<entities>
|
32 |
+
<emt>
|
33 |
+
<table>emv_emt</table>
|
34 |
+
</emt>
|
35 |
+
<attribute>
|
36 |
+
<table>emv_emt_attribute_mapping</table>
|
37 |
+
</attribute>
|
38 |
+
<mailmode>
|
39 |
+
<table>emv_emt_send_mail_mode</table>
|
40 |
+
</mailmode>
|
41 |
+
</entities>
|
42 |
+
</emvemt_mysql4>
|
43 |
+
</models>
|
44 |
+
<resources>
|
45 |
+
<emvemt_setup>
|
46 |
+
<setup>
|
47 |
+
<module>Emv_Emt</module>
|
48 |
+
<class>Emv_Emt_Model_Resource_Setup</class>
|
49 |
+
</setup>
|
50 |
+
</emvemt_setup>
|
51 |
+
</resources>
|
52 |
+
</global>
|
53 |
+
<adminhtml>
|
54 |
+
<translate>
|
55 |
+
<modules>
|
56 |
+
<Emv_Emt>
|
57 |
+
<files>
|
58 |
+
<default>Emv_Emt.csv</default>
|
59 |
+
</files>
|
60 |
+
</Emv_Emt>
|
61 |
+
</modules>
|
62 |
+
</translate>
|
63 |
+
</adminhtml>
|
64 |
+
<admin>
|
65 |
+
<routers>
|
66 |
+
<emvemt>
|
67 |
+
<use>admin</use>
|
68 |
+
<args>
|
69 |
+
<module>Emv_Emt_Adminhtml</module>
|
70 |
+
<frontName>emailvisionemt</frontName>
|
71 |
+
</args>
|
72 |
+
</emvemt>
|
73 |
+
</routers>
|
74 |
+
</admin>
|
75 |
+
</config>
|
app/code/community/Emv/Emt/sql/emvemt_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $installer Emv_Emt_Model_Resource_Setup */
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
-- DROP TABLE {$installer->getTable('emvemt/mailmode')};
|
9 |
+
CREATE TABLE {$installer->getTable('emvemt/mailmode')}
|
10 |
+
(
|
11 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
12 |
+
`name` VARCHAR(150) NOT NULL,
|
13 |
+
PRIMARY KEY (`id`),
|
14 |
+
UNIQUE UQ_emv_emt_send_mail_mode_Mode(`name`)
|
15 |
+
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='All emv mail mode';
|
16 |
+
|
17 |
+
-- DROP TABLE {$installer->getTable('emvemt/emt')};
|
18 |
+
CREATE TABLE {$installer->getTable('emvemt/emt')}(
|
19 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
20 |
+
`mage_template_id` int(10) NOT NULL REFERENCES core_email_template (template_id) ON DELETE CASCADE,
|
21 |
+
`emv_account_id` int(10) REFERENCES emv_account (`id`),
|
22 |
+
`emv_send_mail_mode_id` int(10) REFERENCES emv_emt_send_mail_mode (`id`),
|
23 |
+
`emv_template_id` INTEGER,
|
24 |
+
PRIMARY KEY (`id`)
|
25 |
+
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Transactional email mapping';
|
26 |
+
|
27 |
+
-- DROP TABLE {$installer->getTable('emvemt/attribute')};
|
28 |
+
CREATE TABLE {$installer->getTable('emvemt/attribute')}
|
29 |
+
(
|
30 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
31 |
+
`emv_emt_id` INTEGER NOT NULL REFERENCES emv_emt (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
32 |
+
`emv_attribute` VARCHAR(200) NOT NULL,
|
33 |
+
`mage_attribute` VARCHAR(200) NOT NULL,
|
34 |
+
PRIMARY KEY (`id`)
|
35 |
+
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relation table between for attribute mapping in emt';
|
36 |
+
|
37 |
+
INSERT INTO {$installer->getTable('emvemt/mailmode')} (`name`) VALUES ('classic'), ('emv create'), ('emv send');
|
38 |
+
");
|
39 |
+
|
40 |
+
$installer->endSetup();
|
app/code/community/Emv/Emt/sql/emvemt_setup/mysql4-upgrade-0.1.0-0.2.0.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $installer Emv_Emt_Model_Resource_Setup */
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
ALTER TABLE {$installer->getTable('emvemt/attribute')}
|
9 |
+
ADD COLUMN `emv_attribute_type` VARCHAR(200) NOT NULL AFTER emv_emt_id
|
10 |
+
");
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
UPDATE {$installer->getTable('emvemt/attribute')} SET `emv_attribute_type` = '".Emv_Emt_Constants::ATTRIBUTE_TYPE_EMV_DYN."'
|
14 |
+
");
|
15 |
+
|
16 |
+
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Campaign_Commander_Transactional_Email_1_5</name>
|
4 |
-
<version>1.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Send your transactional e-mails through the Campaign Commander NMP platform</description>
|
11 |
<notes>Send your transactional e-mails through the Campaign Commander NMP platform</notes>
|
12 |
<authors><author><name>Luis Diaz</name><user>auto-converted</user><email>ldiaz@emailvision.com</email></author></authors>
|
13 |
-
<date>2012-05-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocale"><dir name="en_US"><file name="Emv_Core.csv" hash="4a68f62b3bb6003f38632e8726c41d73"/><file name="Emv_Emt.csv" hash="9550fdad59ad6d262f3da8aa09e5b88e"/></dir><dir name="fr_FR"><file name="Emv_Core.csv" hash="5d7c94b493825d9efb5ef60178bdab50"/><file name="Emv_Emt.csv" hash="42e00b78ebb2c8ac9181f98566015506"/></dir></target><target name="mageetc"><dir name="modules"><file name="Emv_Core.xml" hash="e25dd0ea40fad09e0d1f6260f46e65ac"/><file name="Emv_Emt.xml" hash="d1e26edb25bce0b78e6c14792c07ac03"/></dir></target><target name="magecommunity"><dir name="Emv"><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Account"><dir name="Edit"><file name="Form.php" hash="9e090720d3b7fc7406d2e4d4f95dbc90"/></dir><file name="Edit.php" hash="34bc1566c3693acccaa4c8e40b31cb5c"/><file name="Grid.php" hash="3d175f0e1b7ccc7dec1c9ffa30cacb76"/></dir><file name="Accounts.php" hash="3f35eecb2bf23417c0fab4746bda6d0c"/></dir></dir><dir name="Helper"><file name="Config.php" hash="455cd67728b1e6876e9fd8d55ca3253b"/><file name="Data.php" hash="896b9955cc2d6b27b9eca4d2508b7169"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Account"><file name="Collection.php" hash="39c1a08471b3bdd0563f3002a32a4db8"/></dir><file name="Account.php" hash="cea2093a18291b7dd24e25b6f8ce0da0"/></dir><dir name="Resource"><file name="Setup.php" hash="6fc36453ff6c01ac0534731816355bd0"/></dir><dir name="Service"><dir name="Soap"><file name="Api.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Campaign_Commander_Transactional_Email_1_5</name>
|
4 |
+
<version>1.3.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Send your transactional e-mails through the Campaign Commander NMP platform</description>
|
11 |
<notes>Send your transactional e-mails through the Campaign Commander NMP platform</notes>
|
12 |
<authors><author><name>Luis Diaz</name><user>auto-converted</user><email>ldiaz@emailvision.com</email></author></authors>
|
13 |
+
<date>2012-05-16</date>
|
14 |
+
<time>14:53:35</time>
|
15 |
+
<contents><target name="magelocale"><dir name="en_US"><file name="Emv_Core.csv" hash="4a68f62b3bb6003f38632e8726c41d73"/><file name="Emv_Emt.csv" hash="9550fdad59ad6d262f3da8aa09e5b88e"/></dir><dir name="fr_FR"><file name="Emv_Core.csv" hash="5d7c94b493825d9efb5ef60178bdab50"/><file name="Emv_Emt.csv" hash="42e00b78ebb2c8ac9181f98566015506"/></dir></target><target name="mageetc"><dir name="modules"><file name="Emv_Core.xml" hash="e25dd0ea40fad09e0d1f6260f46e65ac"/><file name="Emv_Emt.xml" hash="d1e26edb25bce0b78e6c14792c07ac03"/></dir></target><target name="magecommunity"><dir name="Emv"><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Account"><dir name="Edit"><file name="Form.php" hash="9e090720d3b7fc7406d2e4d4f95dbc90"/></dir><file name="Edit.php" hash="34bc1566c3693acccaa4c8e40b31cb5c"/><file name="Grid.php" hash="3d175f0e1b7ccc7dec1c9ffa30cacb76"/></dir><file name="Accounts.php" hash="3f35eecb2bf23417c0fab4746bda6d0c"/></dir></dir><dir name="Helper"><file name="Config.php" hash="455cd67728b1e6876e9fd8d55ca3253b"/><file name="Data.php" hash="896b9955cc2d6b27b9eca4d2508b7169"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Account"><file name="Collection.php" hash="39c1a08471b3bdd0563f3002a32a4db8"/></dir><file name="Account.php" hash="cea2093a18291b7dd24e25b6f8ce0da0"/></dir><dir name="Resource"><file name="Setup.php" hash="6fc36453ff6c01ac0534731816355bd0"/></dir><dir name="Service"><dir name="Soap"><file name="Api.php" hash="7c3b56a47f4f08494aca648a7829ac1a"/><file name="Config.php" hash="11eb39167cb8354f2da28215c16476e8"/><file name="SoapClient.php" hash="32117ab80f05f6e15b03edc879f806c1"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Account.php" hash="cbc4ee876efd1abcdaa5c57cc08714c2"/></dir></dir></dir><file name="Account.php" hash="a8a6c2c45ab0979666d09732e8d3eda2"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AccountController.php" hash="91447d74999979c278b65dd85f5c06d8"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2e84807c5c503bd91ed673dfb5f579bd"/><file name="config.xml" hash="7bc75acc341d88e151534b02c86512ac"/><file name="system.xml" hash="4e14237f7d69bd20a8f4fd7fded54ba7"/></dir><dir name="sql"><dir name="emvcore_setup"><file name="mysql4-install-0.1.0.php" hash="7bc6d6e7c03398c40008d89ed86e27bc"/></dir></dir><file name="Exception.php" hash="227e1046ebceb99af7bc2b441bb4997d"/></dir><dir name="Emt"><dir name="Block"><dir name="Adminhtml"><dir name="Emt"><dir name="Edit"><file name="Attributes.php" hash="cc2a88773ca64fe7e88b0f460b3b05fc"/><file name="Form.php" hash="7ff998d35df74c4733f06a9fa6ddcae4"/></dir><dir name="New"><file name="Form.php" hash="f2f06b70d36dc2eefe9d4bf7f49ab633"/></dir><file name="Edit.php" hash="be44792b12374f6d6f4c5687fd5e04b0"/><file name="Grid.php" hash="68a88335f6725d1fc818bf4519e01603"/><file name="New.php" hash="6ac499b1064c29fd6893c61cb29209c4"/></dir><file name="Emts.php" hash="b0e91f038bfea92da099a94cb5c232a3"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3bcd2a0563cf4a604cefac0a41884819"/><file name="Emvtemplate.php" hash="5e8ebfdb935fc132917aba8426e9b0cc"/></dir><dir name="Model"><dir name="Mage"><dir name="Core"><dir name="Email"><file name="Template.php" hash="a44ff4883a2762943d2ce4109001e7a5"/></dir></dir></dir><dir name="Mysql4"><dir name="Attribute"><file name="Collection.php" hash="a029255fdb8ccb45250959e08bd7f304"/></dir><dir name="Emt"><file name="Collection.php" hash="5bb76339b2bcf526f440643b367b7682"/></dir><dir name="Mailmode"><file name="Collection.php" hash="98b8005f11a230829c8b1664d9222f2c"/></dir><file name="Attribute.php" hash="13fe2d1ca2efa66b4184da68a629135c"/><file name="Emt.php" hash="9a5e2265b2e5841f07cb175229f79971"/><file name="Mailmode.php" hash="7585af6b9d102fc52788ac0083d338ae"/></dir><dir name="Resource"><file name="Setup.php" hash="62b3de559b3484cec6767a174cda42e9"/></dir><file name="Attribute.php" hash="430f2ba97ded59d319fcd8579555c53c"/><file name="Emt.php" hash="51ad525e79f8d3939bba7b5a5ec69f2f"/><file name="MageTemplate.php" hash="66051e8c63d2012c022d7bf45a3e880b"/><file name="Mailmode.php" hash="d77ce590e7302f0115dcd2075468595c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="EmtController.php" hash="e0d5dcab55e6b147ab8f3e7867f48fb8"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="46610ec63dd5443130e59dbc900e3541"/><file name="config.xml" hash="837cdaf661abefaefba7fca6ab421419"/></dir><dir name="sql"><dir name="emvemt_setup"><file name="mysql4-install-0.1.0.php" hash="a7d12df049f2c1377a072fa7899dcb6c"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="34df942808b7609c10077b493e87f2c2"/></dir></dir><file name="Constants.php" hash="89e516eb1ad83482283537dc7911a2c6"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="emt"><file name="attributes.phtml" hash="b6508fa8b577e1fe2ae56c635f2ca923"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|