Version Notes
- Allow to define variable which relate to product attribute
- Allow to define variable which relate to customer attribute
- Allow to define static values
Download this release
Release Info
Developer | Magento Core Team |
Extension | Easy_PDF_Invoice_Custom_Variables |
Version | 1.0.0.4 |
Comparing to | |
See all releases |
Version 1.0.0.4
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables.php +12 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit.php +64 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Form.php +19 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tab/Form.php +82 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tab/Intergration.php +16 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tabs.php +29 -0
- app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Grid.php +86 -0
- app/code/community/VES/PdfProCustomVariables/Helper/Data.php +6 -0
- app/code/community/VES/PdfProCustomVariables/Model/Mysql4/Pdfprocustomvariables.php +10 -0
- app/code/community/VES/PdfProCustomVariables/Model/Mysql4/Pdfprocustomvariables/Collection.php +10 -0
- app/code/community/VES/PdfProCustomVariables/Model/Observer.php +2 -0
- app/code/community/VES/PdfProCustomVariables/Model/Pdfprocustomvariables.php +41 -0
- app/code/community/VES/PdfProCustomVariables/controllers/Adminhtml/VariablesController.php +184 -0
- app/code/community/VES/PdfProCustomVariables/etc/config.xml +118 -0
- app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-install-1.0.0.php +21 -0
- app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-upgrade-1.0.0-1.0.0.1.php +10 -0
- app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-upgrade-1.0.0.1-1.0.0.2.php +10 -0
- app/design/adminhtml/default/default/layout/ves_pdfprocustomvariables.xml +8 -0
- app/design/adminhtml/default/default/template/ves_pdfprocustomvariables/intergrationcode.phtml +40 -0
- app/etc/modules/VES_PdfProCustomVariables.xml +10 -0
- package.xml +20 -0
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_pdfprocustomvariables';
|
7 |
+
$this->_blockGroup = 'pdfprocustomvariables';
|
8 |
+
$this->_headerText = Mage::helper('pdfprocustomvariables')->__('Variables Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('pdfprocustomvariables')->__('Add Variable');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'pdfprocustomvariables';
|
11 |
+
$this->_controller = 'adminhtml_pdfprocustomvariables';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('pdfprocustomvariables')->__('Save Variable'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('pdfprocustomvariables')->__('Delete Variable'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('pdfprocustomvariables_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'pdfprocustomvariables_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'pdfprocustomvariables_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
|
35 |
+
function toggleActionsSelect(action) {
|
36 |
+
if(action == 'attribute') {
|
37 |
+
$('attribute_id').parentNode.parentNode.show();
|
38 |
+
$('static_value').parentNode.parentNode.hide();
|
39 |
+
$('attribute_id_customer').parentNode.parentNode.hide();
|
40 |
+
}else if(action == 'static') {
|
41 |
+
$('static_value').parentNode.parentNode.show();
|
42 |
+
$('attribute_id').parentNode.parentNode.hide();
|
43 |
+
$('attribute_id_customer').parentNode.parentNode.hide();
|
44 |
+
}else if(action == 'customer') {
|
45 |
+
$('static_value').parentNode.parentNode.hide();
|
46 |
+
$('attribute_id').parentNode.parentNode.hide();
|
47 |
+
$('attribute_id_customer').parentNode.parentNode.show();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
toggleActionsSelect($('variable_type').value);
|
52 |
+
";
|
53 |
+
// $this->_formInitScripts [] = "toggleActionsSelect($('type').value)";
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getHeaderText()
|
57 |
+
{
|
58 |
+
if( Mage::registry('pdfprocustomvariables_data') && Mage::registry('pdfprocustomvariables_data')->getId() ) {
|
59 |
+
return Mage::helper('pdfprocustomvariables')->__("Edit Variable '%s'", $this->htmlEscape(Mage::registry('pdfprocustomvariables_data')->getName()));
|
60 |
+
} else {
|
61 |
+
return Mage::helper('pdfprocustomvariables')->__('Add Variable');
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('pdfprocustomvariables_form', array('legend'=>Mage::helper('pdfprocustomvariables')->__('Item information')));
|
10 |
+
|
11 |
+
/*name*/
|
12 |
+
$fieldset->addField('name', 'text', array(
|
13 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Variable Name'),
|
14 |
+
'class' => 'required-entry validate-code',
|
15 |
+
'required' => true,
|
16 |
+
'name' => 'name',
|
17 |
+
));
|
18 |
+
$disabled = Mage::registry('pdfprocustomvariables_data')->getId()?true:false;
|
19 |
+
/*variable type*/
|
20 |
+
$fieldset->addField('variable_type', 'select', array(
|
21 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Type'),
|
22 |
+
'required' => true,
|
23 |
+
'name' => 'variable_type',
|
24 |
+
'disabled' => $disabled,
|
25 |
+
'options' => array(
|
26 |
+
'attribute' => Mage::helper('catalogrule')->__('Product Attribute'),
|
27 |
+
'customer' => Mage::helper('catalogrule')->__('Customer Attribute'),
|
28 |
+
/*'static' => Mage::helper('catalogrule')->__('Static'),*/
|
29 |
+
),
|
30 |
+
'onchange' => 'toggleActionsSelect(this.value)',
|
31 |
+
));
|
32 |
+
|
33 |
+
/*static value hidden*/
|
34 |
+
$fieldset->addField('static_value', 'text', array(
|
35 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Static Value'),
|
36 |
+
'required' => false,
|
37 |
+
'name' => 'static_value',
|
38 |
+
));
|
39 |
+
|
40 |
+
/*get all attribute to select*/
|
41 |
+
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
|
42 |
+
->addVisibleFilter();
|
43 |
+
foreach($collection as $att) {
|
44 |
+
$attribute['value'] = $att->getAttributeId();
|
45 |
+
$attribute['label'] = $att->getFrontendLabel();
|
46 |
+
$attributes[] = $attribute;
|
47 |
+
}
|
48 |
+
|
49 |
+
/*attribute id*/
|
50 |
+
$fieldset->addField('attribute_id', 'select', array(
|
51 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Attributes'),
|
52 |
+
'required' => true,
|
53 |
+
'name' => 'attribute_id',
|
54 |
+
'values' => $attributes
|
55 |
+
));
|
56 |
+
|
57 |
+
/*customer attributes*/
|
58 |
+
$collection_customer = Mage::getModel('customer/entity_attribute_collection')
|
59 |
+
->addVisibleFilter();
|
60 |
+
foreach($collection_customer as $att) {
|
61 |
+
$attribute_customer['value'] = $att->getAttributeId();
|
62 |
+
$attribute_customer['label'] = $att->getFrontendLabel();
|
63 |
+
$attributes_customer[] = $attribute_customer;
|
64 |
+
}
|
65 |
+
|
66 |
+
$fieldset->addField('attribute_id_customer', 'select', array(
|
67 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Attributes'),
|
68 |
+
'required' => true,
|
69 |
+
'name' => 'attribute_id_customer',
|
70 |
+
'values' => $attributes_customer
|
71 |
+
));
|
72 |
+
|
73 |
+
if ( Mage::getSingleton('adminhtml/session')->getPdfProCustomVariablesData() )
|
74 |
+
{
|
75 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getPdfProCustomVariablesData());
|
76 |
+
Mage::getSingleton('adminhtml/session')->setPdfProCustomVariablesData(null);
|
77 |
+
} elseif ( Mage::registry('pdfprocustomvariables_data') ) {
|
78 |
+
$form->setValues(Mage::registry('pdfprocustomvariables_data')->getData());
|
79 |
+
}
|
80 |
+
return parent::_prepareForm();
|
81 |
+
}
|
82 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tab/Intergration.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Edit_Tab_Intergration extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
$this->setTemplate('ves_pdfprocustomvariables/intergrationcode.phtml');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getPdfProCustomVariables() {
|
10 |
+
return Mage::registry('pdfprocustomvariables_data');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function getPdfProCustomVariableLabel($variable_code) {
|
14 |
+
|
15 |
+
}
|
16 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('pdfprocustomvariables_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('pdfprocustomvariables')->__('Variables Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Variable Information'),
|
18 |
+
'title' => Mage::helper('pdfprocustomvariables')->__('Variable Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
$this->addTab('itergration_section', array(
|
23 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Implementation Code'),
|
24 |
+
'title' => Mage::helper('pdfprocustomvariables')->__('Implementation Code'),
|
25 |
+
'content' => $this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_edit_tab_intergration')->toHtml(),
|
26 |
+
));
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Block/Adminhtml/Pdfprocustomvariables/Grid.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Block_Adminhtml_Pdfprocustomvariables_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('pdfprocustomvariablesGrid');
|
9 |
+
$this->setDefaultSort('custom_variable_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('custom_variable_id', array(
|
24 |
+
'header' => Mage::helper('pdfprocustomvariables')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'custom_variable_id',
|
28 |
+
));
|
29 |
+
$this->addColumn('variable_type', array(
|
30 |
+
'header' => Mage::helper('pdfprocustomvariables')->__('Type'),
|
31 |
+
'width' => '150px',
|
32 |
+
'index' => 'variable_type',
|
33 |
+
'type' => 'options',
|
34 |
+
'options' => array(
|
35 |
+
'attribute' => Mage::helper('catalogrule')->__('Product Attribute'),
|
36 |
+
'customer' => Mage::helper('catalogrule')->__('Customer Attribute'),
|
37 |
+
/*'static' => Mage::helper('catalogrule')->__('Static'),*/
|
38 |
+
),
|
39 |
+
));
|
40 |
+
$this->addColumn('name', array(
|
41 |
+
'header' => Mage::helper('pdfprocustomvariables')->__('Variable Name'),
|
42 |
+
'align' =>'left',
|
43 |
+
'index' => 'name',
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->addColumn('action',
|
47 |
+
array(
|
48 |
+
'header' => Mage::helper('pdfprocustomvariables')->__('Action'),
|
49 |
+
'width' => '100',
|
50 |
+
'type' => 'action',
|
51 |
+
'getter' => 'getId',
|
52 |
+
'actions' => array(
|
53 |
+
array(
|
54 |
+
'caption' => Mage::helper('pdfprocustomvariables')->__('Edit'),
|
55 |
+
'url' => array('base'=> '*/*/edit'),
|
56 |
+
'field' => 'id'
|
57 |
+
)
|
58 |
+
),
|
59 |
+
'filter' => false,
|
60 |
+
'sortable' => false,
|
61 |
+
'index' => 'stores',
|
62 |
+
'is_system' => true,
|
63 |
+
));
|
64 |
+
|
65 |
+
return parent::_prepareColumns();
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function _prepareMassaction()
|
69 |
+
{
|
70 |
+
$this->setMassactionIdField('custom_variable_id');
|
71 |
+
$this->getMassactionBlock()->setFormFieldName('pdfprocustomvariables');
|
72 |
+
|
73 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
74 |
+
'label' => Mage::helper('pdfprocustomvariables')->__('Delete'),
|
75 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
76 |
+
'confirm' => Mage::helper('pdfprocustomvariables')->__('Are you sure?')
|
77 |
+
));
|
78 |
+
return $this;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function getRowUrl($row)
|
82 |
+
{
|
83 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Model/Mysql4/Pdfprocustomvariables.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Model_Mysql4_Pdfprocustomvariables extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the pdfprocustomvariables_id refers to the key field in your database table.
|
8 |
+
$this->_init('pdfprocustomvariables/pdfprocustomvariables', 'custom_variable_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Model/Mysql4/Pdfprocustomvariables/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Model_Mysql4_Pdfprocustomvariables_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('pdfprocustomvariables/pdfprocustomvariables');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/VES/PdfProCustomVariables/Model/Observer.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_PdfProCustomVariables_Model_Observer { public function getFormatedDate($date,$type = null){ $dateFormated = new Varien_Object(array( 'full' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_FULL)), 'long' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG)), 'medium' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)), 'short' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)), )); if($type) return $dateFormated->getData($type); return $dateFormated; } public function isExistAttribute($product, $att_code) { $atts = $product->getAttributes(); foreach($atts as $att) { if($att_code == $att->getAttributeCode()) return true; } return false; } public function getAvailableAttributeCodesOfProduct(Mage_Catalog_Model_Product $product){ $attributes = $product->getAttributes(); $result = array(); foreach($attributes as $attribute) { $result[$attribute->getAttributeCode()] = $attribute->getAttributeCode(); } return $result; } public function getAvailableAttributeCodesOfCustomer(Mage_Catalog_Model_Customer $customer){ $attributes = $customer->getAttributes(); $result = array(); foreach($attributes as $attribute) { $result[$attribute->getAttributeCode()] = $attribute->getAttributeCode(); } return $result; } public function ves_pdfpro_data_prepare_after($observer){ $type = $observer->getType(); if($type=='item'){ $itemData = $observer->getSource(); $item = $observer->getModel(); $product = Mage::getModel('catalog/product')->load($item->getProductId()); $itemProduct = new Varien_Object(); $order = Mage::getModel('sales/order')->load($item->getOrderId()); $orderCurrencyCode = $order->getOrderCurrencyCode(); $availableAttributes = $this->getAvailableAttributeCodesOfProduct($product); $collection = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->getCollection(); foreach ($collection->getData() as $data) { switch($data['variable_type']) { case 'attribute': $attributeInfo = new Varien_Object(Mage::getModel('catalog/product_attribute_api')->info($data['attribute_id'])); switch($attributeInfo->getFrontendInput()) { case 'text': isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $src = $product->getData($attributeInfo->getAttributeCode()) : $src = ''; $itemProduct->setData($data['name'], $src); break; case 'textarea': isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $src = $product->getData($attributeInfo->getAttributeCode()) : $src = ''; $itemProduct->setData($data['name'], $src); break; case 'date': if(isset($availableAttributes[$attributeInfo->getAttributeCode()])) { $date = $product->getData($attributeInfo->getAttributeCode()); $dateFormated = new Varien_Object(array( 'full' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_FULL)), 'long' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG)), 'medium' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)), 'short' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)), )); $itemProduct->setData($data['name'],$dateFormated); }else { $itemProduct->setData($data['name'],''); } break; case 'price': isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $price = Mage::helper('pdfpro')->currency($product->getData($attributeInfo->getAttributeCode()),$orderCurrencyCode) : $price = ''; $itemProduct->setData($data['name'], $price); break; case 'multiselect': $label_arr = $product->getAttributeText($attributeInfo->getAttributeCode()); count($label_arr) == 0 ? $label = '' : $label = implode(',', $label_arr); $itemProduct->setData($data['name'], $label); break; case 'select': (isset($availableAttributes[$attributeInfo->getAttributeCode()]) && $product->getData($attributeInfo->getAttributeCode()) != '') ? $label = $product->getResource()->getAttribute($attributeInfo->getAttributeCode())->getFrontend()->getValue($product) : $label = ''; $itemProduct->setData($data['name'], $label); break; case 'boolean': isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $label = $product->getResource()->getAttribute($attributeInfo->getAttributeCode())->getFrontend()->getValue($product) : $label = ''; $itemProduct->setData($data['name'], $label); break; case 'media_image': isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $src = Mage::getBaseUrl('media') . 'catalog/product' . $product->getData($attributeInfo->getAttributeCode()) : $src = ''; $itemProduct->setData($data['name'], $src); break; default: isset($availableAttributes[$attributeInfo->getAttributeCode()]) ? $src = $product->getData($attributeInfo->getAttributeCode()) : $src = ''; $itemProduct->setData($data['name'], $src); break; } break; case 'static': $itemData->setData($data['name'], $data['static_value']); break; } } $itemData->setData('product',$itemProduct); } else if ($type == 'customer') { $customerData = $observer->getSource(); $item = $observer->getModel(); $customer = Mage::getModel('customer/customer')->load($item->getId()); $availableAttributes = $this->getAvailableAttributeCodesOfCustomer($customer); $collection = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->getCollection(); foreach($collection->getData() as $data) { if($data['variable_type'] == 'customer') { $attributeInfo = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables') ->getAttributeInfo($data['attribute_id_customer']); switch($attributeInfo['frontend_input']) { case 'text': isset($availableAttributes[$attributeInfo['attribute_code']]) ? $src = $customer->getData($attributeInfo['attribute_code']) : $src = ''; $customerData->setData($data['name'], $src); break; case 'boolean': isset($availableAttributes[$attributeInfo['attribute_code']]) ? ($customer->getData($attributeInfo['attribute_code']) == 1 ? $label = Mage::helper('core/translate')->__('Yes') : $label = Mage::helper('core/translate')->__('No')) : $label = ''; $customerData->setData($data['name'], $label); break; case 'select': (isset($availableAttributes[$attributeInfo['attribute_code']]) && $customer->getData($attributeInfo['attribute_code']) != '') ? $label = $customer->getResource()->getAttribute($attributeInfo['attribute_code'])->getFrontend()->getValue($customer) : $label = ''; echo $label;exit; $customerData->setData($data['name'], $label); break; case 'date': if(isset($availableAttributes[$attributeInfo['attribute_code']])) { $date = $customer->getData($attributeInfo['attribute_code']); $dateFormated = new Varien_Object(array( 'full' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_FULL)), 'long' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG)), 'medium' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)), 'short' => Mage::app()->getLocale()->date(strtotime($date))->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)), )); $customerData->setData($data['name'],$dateFormated); }else { $customerData->setData($data['name'],''); } break; default: isset($availableAttributes[$attributeInfo['attribute_code']]) ? $src = $customer->getData($attributeInfo['attribute_code']) : $src = ''; $customerData->setData($data['name'], $src); break; } } } } } }
|
app/code/community/VES/PdfProCustomVariables/Model/Pdfprocustomvariables.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Model_Pdfprocustomvariables extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('pdfprocustomvariables/pdfprocustomvariables');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function checkAttributeFrontendType($variable, $type = null) {
|
12 |
+
switch($variable->getData('variable_type')){
|
13 |
+
case 'attribute':
|
14 |
+
$attributeId = $variable->getAttributeId();
|
15 |
+
$attributeInfo = Mage::getModel('catalog/product_attribute_api')->info($attributeId);
|
16 |
+
break;
|
17 |
+
case 'customer':
|
18 |
+
$attributeId = $variable->getAttributeIdCustomer();
|
19 |
+
$attributeInfo = $this->getAttributeInfo($attributeId);
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
return $attributeInfo['frontend_input']=='date';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* get attribute info from attribute id
|
28 |
+
* in eav/attribute table
|
29 |
+
* @param unknown $attribute_id
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function getAttributeInfo($attribute_id) {
|
33 |
+
$resource = Mage::getSingleton('core/resource');
|
34 |
+
$readConnection = $resource->getConnection('core_read');
|
35 |
+
$table = $resource->getTableName('eav/attribute');
|
36 |
+
$select = $readConnection->select()->from($table, array('*'))->where('attribute_id = ?', $attribute_id);
|
37 |
+
$rowsArray = $readConnection->fetchRow($select);
|
38 |
+
|
39 |
+
return $rowsArray;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/VES/PdfProCustomVariables/controllers/Adminhtml/VariablesController.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_PdfProCustomVariables_Adminhtml_VariablesController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('pdfprocustomvariables/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Variables Manager'), Mage::helper('adminhtml')->__('Variable Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('pdfprocustomvariables_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('pdfprocustomvariables/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Variable Manager'), Mage::helper('adminhtml')->__('Variable Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Variable News'), Mage::helper('adminhtml')->__('Variable News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('pdfprocustomvariables')->__('Variable does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
try {
|
56 |
+
$testModel = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->load($data['name'],'name');
|
57 |
+
$id = $this->getRequest()->getParam('id');
|
58 |
+
if(($testModel->getId() && !$id) || ($id && ($testModel->getId() != $id))){
|
59 |
+
throw new Mage_Core_Exception(Mage::helper('pdfprocustomvariables')->__('The variable name "%s" is already exist. Please use other variable name.',$data['name']));
|
60 |
+
}
|
61 |
+
|
62 |
+
$model = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables');
|
63 |
+
$model->setData($data)
|
64 |
+
->setId($id);
|
65 |
+
|
66 |
+
$model->save();
|
67 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('pdfprocustomvariables')->__('Variable was successfully saved'));
|
68 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
69 |
+
|
70 |
+
if ($this->getRequest()->getParam('back')) {
|
71 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
$this->_redirect('*/*/');
|
75 |
+
return;
|
76 |
+
} catch (Exception $e) {
|
77 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
78 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
79 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('pdfprocustomvariables')->__('Unable to find Variable to save'));
|
84 |
+
$this->_redirect('*/*/');
|
85 |
+
}
|
86 |
+
|
87 |
+
public function deleteAction() {
|
88 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
89 |
+
try {
|
90 |
+
$model = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables');
|
91 |
+
|
92 |
+
$model->setId($this->getRequest()->getParam('id'))
|
93 |
+
->delete();
|
94 |
+
|
95 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Variable was successfully deleted'));
|
96 |
+
$this->_redirect('*/*/');
|
97 |
+
} catch (Exception $e) {
|
98 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
99 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
100 |
+
}
|
101 |
+
}
|
102 |
+
$this->_redirect('*/*/');
|
103 |
+
}
|
104 |
+
|
105 |
+
public function massDeleteAction() {
|
106 |
+
$pdfprocustomvariablesIds = $this->getRequest()->getParam('pdfprocustomvariables');
|
107 |
+
if(!is_array($pdfprocustomvariablesIds)) {
|
108 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Variable(s)'));
|
109 |
+
} else {
|
110 |
+
try {
|
111 |
+
foreach ($pdfprocustomvariablesIds as $pdfprocustomvariablesId) {
|
112 |
+
$pdfprocustomvariables = Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->load($pdfprocustomvariablesId);
|
113 |
+
$pdfprocustomvariables->delete();
|
114 |
+
}
|
115 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
116 |
+
Mage::helper('adminhtml')->__(
|
117 |
+
'Total of %d record(s) were successfully deleted', count($pdfprocustomvariablesIds)
|
118 |
+
)
|
119 |
+
);
|
120 |
+
} catch (Exception $e) {
|
121 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
122 |
+
}
|
123 |
+
}
|
124 |
+
$this->_redirect('*/*/index');
|
125 |
+
}
|
126 |
+
|
127 |
+
public function massStatusAction()
|
128 |
+
{
|
129 |
+
$pdfprocustomvariablesIds = $this->getRequest()->getParam('pdfprocustomvariables');
|
130 |
+
if(!is_array($pdfprocustomvariablesIds)) {
|
131 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Variable(s)'));
|
132 |
+
} else {
|
133 |
+
try {
|
134 |
+
foreach ($pdfprocustomvariablesIds as $pdfprocustomvariablesId) {
|
135 |
+
$pdfprocustomvariables = Mage::getSingleton('pdfprocustomvariables/pdfprocustomvariables')
|
136 |
+
->load($pdfprocustomvariablesId)
|
137 |
+
->setStatus($this->getRequest()->getParam('status'))
|
138 |
+
->setIsMassupdate(true)
|
139 |
+
->save();
|
140 |
+
}
|
141 |
+
$this->_getSession()->addSuccess(
|
142 |
+
$this->__('Total of %d record(s) were successfully updated', count($pdfprocustomvariablesIds))
|
143 |
+
);
|
144 |
+
} catch (Exception $e) {
|
145 |
+
$this->_getSession()->addError($e->getMessage());
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$this->_redirect('*/*/index');
|
149 |
+
}
|
150 |
+
|
151 |
+
public function exportCsvAction()
|
152 |
+
{
|
153 |
+
$fileName = 'pdfprocustomvariables.csv';
|
154 |
+
$content = $this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_grid')
|
155 |
+
->getCsv();
|
156 |
+
|
157 |
+
$this->_sendUploadResponse($fileName, $content);
|
158 |
+
}
|
159 |
+
|
160 |
+
public function exportXmlAction()
|
161 |
+
{
|
162 |
+
$fileName = 'pdfprocustomvariables.xml';
|
163 |
+
$content = $this->getLayout()->createBlock('pdfprocustomvariables/adminhtml_pdfprocustomvariables_grid')
|
164 |
+
->getXml();
|
165 |
+
|
166 |
+
$this->_sendUploadResponse($fileName, $content);
|
167 |
+
}
|
168 |
+
|
169 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
170 |
+
{
|
171 |
+
$response = $this->getResponse();
|
172 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
173 |
+
$response->setHeader('Pragma', 'public', true);
|
174 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
175 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
176 |
+
$response->setHeader('Last-Modified', date('r'));
|
177 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
178 |
+
$response->setHeader('Content-Length', strlen($content));
|
179 |
+
$response->setHeader('Content-type', $contentType);
|
180 |
+
$response->setBody($content);
|
181 |
+
$response->sendResponse();
|
182 |
+
die;
|
183 |
+
}
|
184 |
+
}
|
app/code/community/VES/PdfProCustomVariables/etc/config.xml
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<VES_PdfProCustomVariables>
|
5 |
+
<version>1.0.0.2</version>
|
6 |
+
</VES_PdfProCustomVariables>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<customvariable_cp>
|
11 |
+
<use>admin</use>
|
12 |
+
<args>
|
13 |
+
<module>VES_PdfProCustomVariables</module>
|
14 |
+
<frontName>customvariable_cp</frontName>
|
15 |
+
</args>
|
16 |
+
</customvariable_cp>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
<adminhtml>
|
20 |
+
<menu>
|
21 |
+
<pdfpro>
|
22 |
+
<children>
|
23 |
+
<custom_variables>
|
24 |
+
<title>Manage Custom Variables</title>
|
25 |
+
<sort_order>25</sort_order>
|
26 |
+
<action>customvariable_cp/adminhtml_variables</action>
|
27 |
+
</custom_variables>
|
28 |
+
</children>
|
29 |
+
</pdfpro>
|
30 |
+
</menu>
|
31 |
+
<acl>
|
32 |
+
<resources>
|
33 |
+
<all>
|
34 |
+
<title>Allow Everything</title>
|
35 |
+
</all>
|
36 |
+
<admin>
|
37 |
+
<children>
|
38 |
+
<pdfpro>
|
39 |
+
<children>
|
40 |
+
<custom_variables>
|
41 |
+
<title>Easy PDF -Custom Variables</title>
|
42 |
+
<sort_order>10</sort_order>
|
43 |
+
</custom_variables>
|
44 |
+
</children>
|
45 |
+
</pdfpro>
|
46 |
+
</children>
|
47 |
+
</admin>
|
48 |
+
</resources>
|
49 |
+
</acl>
|
50 |
+
<layout>
|
51 |
+
<updates>
|
52 |
+
<pdfprocustomvariables>
|
53 |
+
<file>ves_pdfprocustomvariables.xml</file>
|
54 |
+
</pdfprocustomvariables>
|
55 |
+
</updates>
|
56 |
+
</layout>
|
57 |
+
</adminhtml>
|
58 |
+
<global>
|
59 |
+
<events>
|
60 |
+
<ves_pdfpro_data_prepare_after>
|
61 |
+
<observers>
|
62 |
+
<pdfprocustomvariables>
|
63 |
+
<class>pdfprocustomvariables/observer</class>
|
64 |
+
<method>ves_pdfpro_data_prepare_after</method>
|
65 |
+
</pdfprocustomvariables>
|
66 |
+
</observers>
|
67 |
+
</ves_pdfpro_data_prepare_after>
|
68 |
+
</events>
|
69 |
+
|
70 |
+
<models>
|
71 |
+
<pdfprocustomvariables>
|
72 |
+
<class>VES_PdfProCustomVariables_Model</class>
|
73 |
+
<resourceModel>pdfprocustomvariables_mysql4</resourceModel>
|
74 |
+
</pdfprocustomvariables>
|
75 |
+
<pdfprocustomvariables_mysql4>
|
76 |
+
<class>VES_PdfProCustomVariables_Model_Mysql4</class>
|
77 |
+
<entities>
|
78 |
+
<pdfprocustomvariables>
|
79 |
+
<table>ves_pdfprocustomvariables_customvariables</table>
|
80 |
+
</pdfprocustomvariables>
|
81 |
+
</entities>
|
82 |
+
</pdfprocustomvariables_mysql4>
|
83 |
+
</models>
|
84 |
+
|
85 |
+
<resources>
|
86 |
+
<pdfprocustomvariables_setup>
|
87 |
+
<setup>
|
88 |
+
<module>VES_PdfProCustomVariables</module>
|
89 |
+
</setup>
|
90 |
+
<connection>
|
91 |
+
<use>core_setup</use>
|
92 |
+
</connection>
|
93 |
+
</pdfprocustomvariables_setup>
|
94 |
+
<pdfprocustomvariables_write>
|
95 |
+
<connection>
|
96 |
+
<use>core_write</use>
|
97 |
+
</connection>
|
98 |
+
</pdfprocustomvariables_write>
|
99 |
+
<pdfprocustomvariables_read>
|
100 |
+
<connection>
|
101 |
+
<use>core_read</use>
|
102 |
+
</connection>
|
103 |
+
</pdfprocustomvariables_read>
|
104 |
+
</resources>
|
105 |
+
|
106 |
+
<blocks>
|
107 |
+
<pdfprocustomvariables>
|
108 |
+
<class>VES_PdfProCustomVariables_Block</class>
|
109 |
+
</pdfprocustomvariables>
|
110 |
+
</blocks>
|
111 |
+
|
112 |
+
<helpers>
|
113 |
+
<pdfprocustomvariables>
|
114 |
+
<class>VES_PdfProCustomVariables_Helper</class>
|
115 |
+
</pdfprocustomvariables>
|
116 |
+
</helpers>
|
117 |
+
</global>
|
118 |
+
</config>
|
app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
DROP TABLE IF EXISTS {$this->getTable('pdfprocustomvariables/pdfprocustomvariables')};
|
10 |
+
CREATE TABLE {$this->getTable('pdfprocustomvariables/pdfprocustomvariables')} (
|
11 |
+
`custom_variable_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`name` varchar(255) NOT NULL default '',
|
13 |
+
`variable_type` varchar(255) NOT NULL default '',
|
14 |
+
`attribute_id` int(11) unsigned not null,
|
15 |
+
`static_value` text not null,
|
16 |
+
PRIMARY KEY (`custom_variable_id`)
|
17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
+
|
19 |
+
");
|
20 |
+
|
21 |
+
$installer->endSetup();
|
app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-upgrade-1.0.0-1.0.0.1.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE `{$this->getTable('pdfprocustomvariables/pdfprocustomvariables')}`
|
7 |
+
MODIFY `name` varchar(30) NOT NULL default ''
|
8 |
+
");
|
9 |
+
|
10 |
+
$installer->endSetup();
|
app/code/community/VES/PdfProCustomVariables/sql/pdfprocustomvariables_setup/mysql4-upgrade-1.0.0.1-1.0.0.2.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE `{$this->getTable('pdfprocustomvariables/pdfprocustomvariables')}`
|
7 |
+
ADD `attribute_id_customer` int(11) unsigned not null AFTER `attribute_id`
|
8 |
+
");
|
9 |
+
|
10 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/ves_pdfprocustomvariables.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<customvariable_cp_adminhtml_variables_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="pdfprocustomvariables/adminhtml_pdfprocustomvariables" name="pdfprocustomvariables" />
|
6 |
+
</reference>
|
7 |
+
</customvariable_cp_adminhtml_variables_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/ves_pdfprocustomvariables/intergrationcode.phtml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->getPdfProCustomVariables()->getId()):?>
|
2 |
+
<ul class="messages">
|
3 |
+
<li class="notice-msg">
|
4 |
+
<ul>
|
5 |
+
<li><?php echo $this->__("Now you can add this below code to your PDF template to display your custom variable.")?></li>
|
6 |
+
</ul>
|
7 |
+
</li>
|
8 |
+
</ul>
|
9 |
+
<?php $variableType = $this->getPdfProCustomVariables()->getVariableType();?>
|
10 |
+
<?php if($variableType == 'attribute'):?>
|
11 |
+
<?php if(Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->checkAttributeFrontendType($this->getPdfProCustomVariables(), 'date')):?>
|
12 |
+
<pre>{{var item.product.<?php echo $this->getPdfProCustomVariables()->getName()?>.full}}</pre><br />
|
13 |
+
<pre>{{var item.product.<?php echo $this->getPdfProCustomVariables()->getName()?>.long}}</pre><br />
|
14 |
+
<pre>{{var item.product.<?php echo $this->getPdfProCustomVariables()->getName()?>.medium}}</pre><br />
|
15 |
+
<pre>{{var item.product.<?php echo $this->getPdfProCustomVariables()->getName()?>.short}}</pre>
|
16 |
+
<?php else:?>
|
17 |
+
<pre>{{var item.product.<?php echo $this->getPdfProCustomVariables()->getName()?>}}</pre>
|
18 |
+
<?php endif;?>
|
19 |
+
<?php elseif($this->getPdfProCustomVariables()->getVariableType() == 'static'):?>
|
20 |
+
<pre>{{var item.<?php echo $this->getPdfProCustomVariables()->getName()?>}}</pre>
|
21 |
+
<?php elseif($variableType == 'customer'):?>
|
22 |
+
<?php if(Mage::getModel('pdfprocustomvariables/pdfprocustomvariables')->checkAttributeFrontendType($this->getPdfProCustomVariables(), 'date')):?>
|
23 |
+
<pre>{{var customer.<?php echo $this->getPdfProCustomVariables()->getName()?>.full}}</pre><br />
|
24 |
+
<pre>{{var customer.<?php echo $this->getPdfProCustomVariables()->getName()?>.long}}</pre><br />
|
25 |
+
<pre>{{var customer.<?php echo $this->getPdfProCustomVariables()->getName()?>.medium}}</pre><br />
|
26 |
+
<pre>{{var customer.<?php echo $this->getPdfProCustomVariables()->getName()?>.short}}</pre>
|
27 |
+
<?php else:?>
|
28 |
+
<pre>{{var customer.<?php echo $this->getPdfProCustomVariables()->getName()?>}}</pre>
|
29 |
+
<?php endif;?>
|
30 |
+
<?php endif;?>
|
31 |
+
<br />
|
32 |
+
<?php else:?>
|
33 |
+
<ul class="messages">
|
34 |
+
<li class="notice-msg">
|
35 |
+
<ul>
|
36 |
+
<li><?php echo $this->__("You need to save this variable before you can see the implementation code.")?></li>
|
37 |
+
</ul>
|
38 |
+
</li>
|
39 |
+
</ul>
|
40 |
+
<?php endif;?>
|
app/etc/modules/VES_PdfProCustomVariables.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<VES_PdfProCustomVariables>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</VES_PdfProCustomVariables>
|
8 |
+
<depends><VES_PdfPro /></depends>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Easy_PDF_Invoice_Custom_Variables</name>
|
4 |
+
<version>1.0.0.4</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL V3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Allow you to add custom variables to use in your PDF Template</summary>
|
10 |
+
<description>Allow you to add custom variables to use in your PDF Template.</description>
|
11 |
+
<notes>- Allow to define variable which relate to product attribute
|
12 |
+
- Allow to define variable which relate to customer attribute
|
13 |
+
- Allow to define static values</notes>
|
14 |
+
<authors><author><name>Easy PDF Invoice</name><user>auto-converted</user><email>easypdfinvoice@gmail.com</email></author></authors>
|
15 |
+
<date>2013-02-26</date>
|
16 |
+
<time>13:43:44</time>
|
17 |
+
<contents><target name="mageetc"><dir name="modules"><file name="VES_PdfProCustomVariables.xml" hash="725a4a253ef0276565852b1ff0fa07bc"/></dir></target><target name="magecommunity"><dir name="VES"><dir name="PdfProCustomVariables"><dir name="Block"><dir name="Adminhtml"><dir name="Pdfprocustomvariables"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="3870bf494d27ac725fdf0277bcaff17e"/><file name="Intergration.php" hash="236d9e8f74e88befcc05a3d848a8ae56"/></dir><file name="Form.php" hash="1f87d9ee6ce3df463f027ff96aae6cda"/><file name="Tabs.php" hash="1261d8486ffd5c6f41af7e97ddbd56e8"/></dir><file name="Edit.php" hash="25810b8c5ca254c10a0e981e1639e7b9"/><file name="Grid.php" hash="2f8f5025bb9df25d4c2a473821fd74fe"/></dir><file name="Pdfprocustomvariables.php" hash="91f8d4310da8f8da46c6a142e5b38738"/></dir></dir><dir name="Helper"><file name="Data.php" hash="2aba96822fcc8fb043792d40baa2e90a"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Pdfprocustomvariables"><file name="Collection.php" hash="96ce5d49fee8ca2e52164714a42a9b28"/></dir><file name="Pdfprocustomvariables.php" hash="4718330435a78a6313914cb5e062d3d7"/></dir><file name="Observer.php" hash="fd8a6a0d590a93edd2e3196c95c3eacc"/><file name="Pdfprocustomvariables.php" hash="2a59045a44ac17f641eb4ce26f1960af"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VariablesController.php" hash="13b5cccde7acdc30197eb258975916ff"/></dir></dir><dir name="etc"><file name="config.xml" hash="fab63b17cf036596080c7a4b88da99c6"/></dir><dir name="sql"><dir name="pdfprocustomvariables_setup"><file name="mysql4-install-1.0.0.php" hash="203b4b818ccba7bd2107ae1047192b42"/><file name="mysql4-upgrade-1.0.0-1.0.0.1.php" hash="05564671ba8ea3cad6c07202921f1b5a"/><file name="mysql4-upgrade-1.0.0.1-1.0.0.2.php" hash="a036e5b1226ff5bfcdf8181ac983b5e0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ves_pdfprocustomvariables.xml" hash="347f0604dabbc274177ab47b06587cf3"/></dir><dir name="template"><dir name="ves_pdfprocustomvariables"><file name="intergrationcode.phtml" hash="abdd9e53f9f63fe0b945b4af075f3d7b"/></dir></dir></dir></dir></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies/>
|
20 |
+
</package>
|