Kartparadigm_Giftcard - Version 1.5.0.0

Version Notes

Giftcard Extension Tested in 1.8 and Working Fine

Download this release

Release Info

Developer Kartparadigm
Extension Kartparadigm_Giftcard
Version 1.5.0.0
Comparing to
See all releases


Version 1.5.0.0

Files changed (94) hide show
  1. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Catalog/Form/Renderer/Fieldset/Element.php +10 -0
  2. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Customer/Edit/Tab/Giftcard.php +30 -0
  3. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Customer/Edit/Tab/Giftcard/List.php +81 -0
  4. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend.php +13 -0
  5. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit.php +24 -0
  6. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Form.php +101 -0
  7. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Form.php~ +101 -0
  8. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Tabs.php~ +34 -0
  9. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries.php +13 -0
  10. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Edit.php +24 -0
  11. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Edit/Form.php +138 -0
  12. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Grid.php +130 -0
  13. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates.php +20 -0
  14. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Edit.php +25 -0
  15. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Edit/Form.php +122 -0
  16. app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Grid.php +129 -0
  17. app/code/community/Kartparadigm/Giftcard/Block/Balance.php +17 -0
  18. app/code/community/Kartparadigm/Giftcard/Block/Catalog/Product/View/Type.php +6 -0
  19. app/code/community/Kartparadigm/Giftcard/Block/Payment/Form.php +17 -0
  20. app/code/community/Kartparadigm/Giftcard/Block/Payment/Info.php +6 -0
  21. app/code/community/Kartparadigm/Giftcard/Block/View.php +12 -0
  22. app/code/community/Kartparadigm/Giftcard/Helper/Data.php +29 -0
  23. app/code/community/Kartparadigm/Giftcard/Helper/Data.php~ +29 -0
  24. app/code/community/Kartparadigm/Giftcard/Helper/Payment.php +17 -0
  25. app/code/community/Kartparadigm/Giftcard/Helper/Payment.php~ +17 -0
  26. app/code/community/Kartparadigm/Giftcard/Model/Custommethods.php +86 -0
  27. app/code/community/Kartparadigm/Giftcard/Model/Giftcard.php +10 -0
  28. app/code/community/Kartparadigm/Giftcard/Model/Giftcardtemplate.php +12 -0
  29. app/code/community/Kartparadigm/Giftcard/Model/Giftcardtrans.php +10 -0
  30. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard.php +9 -0
  31. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard.php~ +9 -0
  32. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard/Collection.php +10 -0
  33. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard/Collection.php~ +10 -0
  34. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate.php +9 -0
  35. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate.php~ +9 -0
  36. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate/Collection.php +10 -0
  37. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate/Collection.php~ +10 -0
  38. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans.php +9 -0
  39. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans.php~ +9 -0
  40. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans/Collection.php +10 -0
  41. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans/Collection.php~ +10 -0
  42. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Template.php~ +9 -0
  43. app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Templates.php~ +9 -0
  44. app/code/community/Kartparadigm/Giftcard/Model/Observer.php +601 -0
  45. app/code/community/Kartparadigm/Giftcard/Model/Observer.php~ +601 -0
  46. app/code/community/Kartparadigm/Giftcard/Model/Product/Type.php +28 -0
  47. app/code/community/Kartparadigm/Giftcard/Model/Product/Type.php~ +28 -0
  48. app/code/community/Kartparadigm/Giftcard/Model/Quote.php +17 -0
  49. app/code/community/Kartparadigm/Giftcard/Model/Quote/Payment.php +16 -0
  50. app/code/community/Kartparadigm/Giftcard/Model/Quote/Payment.php~ +16 -0
  51. app/code/community/Kartparadigm/Giftcard/Model/Quote/Total.php~ +71 -0
  52. app/code/community/Kartparadigm/Giftcard/Model/Resource/Setup.php +5 -0
  53. app/code/community/Kartparadigm/Giftcard/Model/Resource/Setup.php~ +5 -0
  54. app/code/community/Kartparadigm/Giftcard/controllers/Adminhtml/GiftcardController.php +340 -0
  55. app/code/community/Kartparadigm/Giftcard/controllers/Adminhtml/TemplateController.php +235 -0
  56. app/code/community/Kartparadigm/Giftcard/controllers/CustomerController.php +78 -0
  57. app/code/community/Kartparadigm/Giftcard/controllers/IndexController.php +116 -0
  58. app/code/community/Kartparadigm/Giftcard/etc/adminhtml.xml +72 -0
  59. app/code/community/Kartparadigm/Giftcard/etc/adminhtml.xml~ +72 -0
  60. app/code/community/Kartparadigm/Giftcard/etc/config.xml +245 -0
  61. app/code/community/Kartparadigm/Giftcard/etc/config.xml~ +245 -0
  62. app/code/community/Kartparadigm/Giftcard/etc/system.xml +181 -0
  63. app/code/community/Kartparadigm/Giftcard/etc/system.xml~ +181 -0
  64. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/install-0.1.0.php +38 -0
  65. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.0-0.1.1.php +108 -0
  66. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.1-0.1.2 .php +80 -0
  67. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.2-0.1.3.php +124 -0
  68. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.3-0.1.4.php +8 -0
  69. app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.4-0.1.5.php +79 -0
  70. app/design/adminhtml/base/default/template/kartparadigm/giftcard/customer/main.phtml +9 -0
  71. app/design/adminhtml/default/default/layout/giftcard.xml +124 -0
  72. app/design/adminhtml/default/default/template/kartparadigm/giftcard/view.phtml +115 -0
  73. app/design/adminhtml/default/default/template/kartparadigm/giftcard/view.phtml~ +115 -0
  74. app/design/adminhtml/default/kartparadigm/template/catalog/form/renderer/fieldset/element.phtml +60 -0
  75. app/design/adminhtml/default/kartparadigm/template/catalog/product/edit.phtml +135 -0
  76. app/design/frontend/base/default/layout/kartparadigm/giftcard.xml +83 -0
  77. app/design/frontend/base/default/template/kartparadigm/giftcard/customer/balance.phtml +65 -0
  78. app/design/frontend/base/default/template/kartparadigm/giftcard/customer/balview.phtml +77 -0
  79. app/design/frontend/base/default/template/kartparadigm/giftcard/customer/shareview.phtml +27 -0
  80. app/design/frontend/base/default/template/kartparadigm/giftcard/payment/form.phtml +2 -0
  81. app/design/frontend/base/default/template/kartparadigm/giftcard/product/coupon.phtml +92 -0
  82. app/design/frontend/base/default/template/kartparadigm/giftcard/product/giftcardprice.phtml +34 -0
  83. app/design/frontend/base/default/template/kartparadigm/giftcard/product/listprice.phtml +24 -0
  84. app/design/frontend/base/default/template/kartparadigm/giftcard/product/media.phtml +232 -0
  85. app/design/frontend/base/default/template/kartparadigm/giftcard/product/type.phtml +177 -0
  86. app/etc/modules/Kartparadigm_Giftcard.xml +15 -0
  87. app/locale/en_US/Kartparadigm_Giftcard.csv +40 -0
  88. app/locale/en_US/template/email/giftcard/custom_email_template1.html +85 -0
  89. media/giftcard/bar.gif +0 -0
  90. media/giftcard/clos.png +0 -0
  91. media/giftcard/greet.jpg +0 -0
  92. package.xml +18 -0
  93. skin/frontend/base/default/js/giftcard/blurbox.js +306 -0
  94. skin/frontend/base/default/js/giftcard/jquery.min-1.11.1.js +4 -0
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Catalog/Form/Renderer/Fieldset/Element.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('giftcard/catalog/form/renderer/fieldset/element.phtml');
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Customer/Edit/Tab/Giftcard.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Customer_Edit_Tab_Giftcard
3
+ extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+ public function __construct()
5
+ {
6
+ $this->setTemplate('kartparadigm/giftcard/customer/main.phtml');
7
+ parent::_construct();
8
+ }
9
+ public function getCustomerId()
10
+ {
11
+ return Mage::registry('current_customer')->getId();
12
+ }
13
+ public function getTabLabel()
14
+ {
15
+ return $this->__('Gift Cards');
16
+ }
17
+ public function getTabTitle()
18
+ {
19
+ return $this->__('Click to view the customer Gift Cards');
20
+ }
21
+ public function canShowTab()
22
+ {
23
+ return true;
24
+ }
25
+ public function isHidden()
26
+ {
27
+ return false;
28
+ }
29
+ }
30
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Customer/Edit/Tab/Giftcard/List.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Customer_Edit_Tab_Giftcard_List extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct(){
5
+ parent::__construct();
6
+ $this->setId('cardsGrid');
7
+ $this->setDefaultSort('giftcard_id');
8
+ $this->setDefaultDir('ASC');
9
+ $this->setSaveParametersInSession(true);
10
+ }
11
+ protected function _prepareCollection(){
12
+ $id = $this->getRequest()->getParam('id');
13
+ $model = Mage::getModel('customer/customer')->load($id);
14
+ $col = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('receiver_mail',$model['email']);
15
+ $this->setCollection($col);
16
+
17
+ return parent::_prepareCollection();
18
+ }
19
+ protected function _prepareColumns()
20
+ {
21
+ $this->addColumn('giftcard_id', array(
22
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Id'),
23
+ 'width'=> 50,
24
+ 'index'=> 'giftcard_id',
25
+ 'sortable' => false,
26
+ ));
27
+ $this->addColumn('order_id', array(
28
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Order ID'),
29
+ 'index'=> 'order_id',
30
+ 'sortable' => true,
31
+ ));
32
+ $this->addColumn('receiver_name', array(
33
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Customer Name'),
34
+ 'index'=> 'customer_name',
35
+ 'sortable' => true,
36
+ ));
37
+ $this->addColumn('giftcard_code', array(
38
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Code'),
39
+ 'index'=> 'giftcard_code',
40
+ 'sortable' => true,
41
+ ));
42
+ $this->addColumn('giftcard_val', array(
43
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Value'),
44
+ 'index'=> 'giftcard_val',
45
+ 'sortable' => true,
46
+ ));
47
+ $this->addColumn('giftcard_bal', array(
48
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Balance'),
49
+ 'index'=> 'giftcard_bal',
50
+ 'sortable' => true,
51
+ ));
52
+ $this->addColumn('created_date', array(
53
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Created Date'),
54
+ 'index'=> 'created_date',
55
+ 'sortable' => true,
56
+ ));
57
+ $this->addColumn('expiry_date', array(
58
+ 'header'=> Mage::helper('kartparadigm_giftcard')->__('Expiry Date'),
59
+ 'index'=> 'expiry_date',
60
+ 'sortable' => true,
61
+ ));
62
+ $this->addColumn('giftcard_status', array(
63
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Status'),
64
+ 'index' => 'giftcard_status',
65
+ 'type' => 'options',
66
+ 'options' => array(
67
+ 0 => 'Inactive',
68
+ 1 => 'Active',
69
+ 2 => 'Processing',
70
+ 3 => 'Redeemed',
71
+ 4 => 'Expired',
72
+ 5 => 'Canceled',
73
+ ),
74
+ ));
75
+ return parent::_prepareColumns();
76
+ }
77
+
78
+
79
+
80
+ }
81
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Groupsend extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct(){
5
+ $this->_controller = 'adminhtml_groupsend';
6
+ $this->_blockGroup = 'kartparadigm_giftcard';
7
+ $this->_headerText = Mage::helper('kartparadigm_giftcard')->__('Giftcard Sending To Group');
8
+ $this->_addButtonLabel = Mage::helper('kartparadigm_giftcard')->__('Add New Giftcard');
9
+ parent::__construct();
10
+ $this->_removeButton('add');//to remove add new button
11
+ }
12
+ }
13
+ ?>
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Groupsend_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ public function __construct(){
5
+ parent::__construct();
6
+ $this->_objectId = 'id';
7
+
8
+ $this->_controller = 'adminhtml_groupsend';
9
+ $this->_blockGroup = 'kartparadigm_giftcard';
10
+
11
+ $this->_mode = 'edit';
12
+ $this->_updateButton('save', 'label', Mage::helper('kartparadigm_giftcard')->__('Send Giftcard To Group'));
13
+ $this->_updateButton('delete', 'label', Mage::helper('kartparadigm_giftcard')->__('Delete Giftcard'));
14
+
15
+
16
+ }
17
+ public function getHeaderText()
18
+ {
19
+ if(Mage::registry('registry_data') && Mage::registry('registry_data')->getId())
20
+ return Mage::helper('kartparadigm_giftcard')->__("Edit Giftcard '%s'", $this->htmlEscape(Mage::registry('registry_data')->getGiftcardName()));
21
+ return Mage::helper('kartparadigm_giftcard')->__('Send Giftcard To Group');
22
+ }
23
+ }
24
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Form.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Groupsend_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ Mage::log('Prepare Form');
8
+ $form = new Varien_Data_Form(array(
9
+ 'id' => 'edit_form',
10
+ 'action' => $this->getUrl('*/*/send', array(
11
+ 'id' => $this->getRequest()->getParam('id')
12
+ )) ,
13
+ 'method' => 'post',
14
+ 'enctype' => 'multipart/form-data'
15
+ ));
16
+ $form->setUseContainer(true);
17
+ $this->setForm($form);
18
+ if (Mage::getSingleton('adminhtml/session')->getFormData()) {
19
+ $data = Mage::getSingleton('adminhtml/session')->getFormData();
20
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
21
+ }
22
+ elseif (Mage::registry('registry_data')) $data = Mage::registry('registry_data')->getData();
23
+ $fieldset = $form->addFieldset('registry_form', array(
24
+ 'legend' => Mage::helper('kartparadigm_giftcard')->__('Gift Card information')
25
+ ));
26
+ $fieldset->addField('giftcard_name', 'text', array(
27
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Name') ,
28
+ 'class' => 'required-entry',
29
+ 'required' => true,
30
+ 'name' => 'giftcard_name',
31
+ ));
32
+ $fieldset->addField('giftcard_val', 'text', array(
33
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Amount') ,
34
+ 'class' => 'required-entry',
35
+ 'required' => true,
36
+ 'name' => 'giftcard_val',
37
+ ));
38
+ $customerGroupModel = new Mage_Customer_Model_Group();
39
+ $customerGroups = array();
40
+ $allCustomerGroups = $customerGroupModel->getCollection()->addFieldToFilter('customer_group_id', array(
41
+ 'nin' => array(
42
+ 0
43
+ )
44
+ ))->toOptionHash();
45
+ $fieldset->addField('customer_groups', 'select', array(
46
+ 'name' => 'customer_groups',
47
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Customer Group') ,
48
+ 'class' => 'required-entry',
49
+ 'required' => true,
50
+ 'options' => $allCustomerGroups,
51
+ ));
52
+ $fieldset->addField('giftcard_status', 'select', array(
53
+ 'name' => 'giftcard_status',
54
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Status') ,
55
+ 'class' => 'required-entry',
56
+ 'required' => true,
57
+ 'options' => array(
58
+ 0 => Mage::helper('kartparadigm_giftcard')->__('Inactive') ,
59
+ 1 => Mage::helper('kartparadigm_giftcard')->__('Active') ,
60
+ ) ,
61
+ ));
62
+ $fieldset->addField('store_id', 'select', array( //can use multiselect
63
+ 'name' => 'store_id[]',
64
+ 'label' => Mage::helper('cms')->__('Store View') ,
65
+ 'title' => Mage::helper('cms')->__('Store View') ,
66
+ 'required' => true,
67
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ,
68
+ ));
69
+ $fieldset->addField('giftcard_currency', 'select', array(
70
+ 'name' => 'giftcard_currency',
71
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Currency') ,
72
+ 'class' => 'required-entry',
73
+ 'required' => true,
74
+ 'values' => Mage::getSingleton('adminhtml/system_config_source_currency')->toOptionArray(false) ,
75
+ 'value' => Mage::app()->getStore()->getDefaultCurrency()->getCurrencyCode() ,
76
+ ));
77
+ // date field
78
+ $fieldset->addField('giftcard_msg', 'textarea', array(
79
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Message'),
80
+ 'class'=> 'required-entry',
81
+ 'required' => true,
82
+ 'name'=> 'giftcard_msg',
83
+ ));
84
+
85
+
86
+ $arr = array(
87
+ 'name' => 'expiry_date',
88
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Expiry Date') ,
89
+ 'required' => true,
90
+ 'image' => $this->getSkinUrl('images/grid-cal.gif') ,
91
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ,
92
+ );
93
+ if (version_compare(Mage::getVersion() , '1.1.8', '>=')) {
94
+ $arr['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
95
+ }
96
+ $expireAt = $fieldset->addField('expiry_date', 'date', $arr);
97
+ $form->setValues($data);
98
+ return parent::_prepareForm();
99
+ }
100
+ }
101
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Form.php~ ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Block_Adminhtml_Groupsend_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ Mage::log('Prepare Form');
8
+ $form = new Varien_Data_Form(array(
9
+ 'id' => 'edit_form',
10
+ 'action' => $this->getUrl('*/*/send', array(
11
+ 'id' => $this->getRequest()->getParam('id')
12
+ )) ,
13
+ 'method' => 'post',
14
+ 'enctype' => 'multipart/form-data'
15
+ ));
16
+ $form->setUseContainer(true);
17
+ $this->setForm($form);
18
+ if (Mage::getSingleton('adminhtml/session')->getFormData()) {
19
+ $data = Mage::getSingleton('adminhtml/session')->getFormData();
20
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
21
+ }
22
+ elseif (Mage::registry('registry_data')) $data = Mage::registry('registry_data')->getData();
23
+ $fieldset = $form->addFieldset('registry_form', array(
24
+ 'legend' => Mage::helper('tele_giftcard')->__('Gift Card information')
25
+ ));
26
+ $fieldset->addField('giftcard_name', 'text', array(
27
+ 'label' => Mage::helper('tele_giftcard')->__('Giftcard Name') ,
28
+ 'class' => 'required-entry',
29
+ 'required' => true,
30
+ 'name' => 'giftcard_name',
31
+ ));
32
+ $fieldset->addField('giftcard_val', 'text', array(
33
+ 'label' => Mage::helper('tele_giftcard')->__('Giftcard Amount') ,
34
+ 'class' => 'required-entry',
35
+ 'required' => true,
36
+ 'name' => 'giftcard_val',
37
+ ));
38
+ $customerGroupModel = new Mage_Customer_Model_Group();
39
+ $customerGroups = array();
40
+ $allCustomerGroups = $customerGroupModel->getCollection()->addFieldToFilter('customer_group_id', array(
41
+ 'nin' => array(
42
+ 0
43
+ )
44
+ ))->toOptionHash();
45
+ $fieldset->addField('customer_groups', 'select', array(
46
+ 'name' => 'customer_groups',
47
+ 'label' => Mage::helper('tele_giftcard')->__('Customer Group') ,
48
+ 'class' => 'required-entry',
49
+ 'required' => true,
50
+ 'options' => $allCustomerGroups,
51
+ ));
52
+ $fieldset->addField('giftcard_status', 'select', array(
53
+ 'name' => 'giftcard_status',
54
+ 'label' => Mage::helper('tele_giftcard')->__('Giftcard Status') ,
55
+ 'class' => 'required-entry',
56
+ 'required' => true,
57
+ 'options' => array(
58
+ 0 => Mage::helper('tele_giftcard')->__('Inactive') ,
59
+ 1 => Mage::helper('tele_giftcard')->__('Active') ,
60
+ ) ,
61
+ ));
62
+ $fieldset->addField('store_id', 'select', array( //can use multiselect
63
+ 'name' => 'store_id[]',
64
+ 'label' => Mage::helper('cms')->__('Store View') ,
65
+ 'title' => Mage::helper('cms')->__('Store View') ,
66
+ 'required' => true,
67
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ,
68
+ ));
69
+ $fieldset->addField('giftcard_currency', 'select', array(
70
+ 'name' => 'giftcard_currency',
71
+ 'label' => Mage::helper('tele_giftcard')->__('Currency') ,
72
+ 'class' => 'required-entry',
73
+ 'required' => true,
74
+ 'values' => Mage::getSingleton('adminhtml/system_config_source_currency')->toOptionArray(false) ,
75
+ 'value' => Mage::app()->getStore()->getDefaultCurrency()->getCurrencyCode() ,
76
+ ));
77
+ // date field
78
+ $fieldset->addField('giftcard_msg', 'textarea', array(
79
+ 'label'=> Mage::helper('tele_giftcard')->__('Giftcard Message'),
80
+ 'class'=> 'required-entry',
81
+ 'required' => true,
82
+ 'name'=> 'giftcard_msg',
83
+ ));
84
+
85
+
86
+ $arr = array(
87
+ 'name' => 'expiry_date',
88
+ 'label' => Mage::helper('tele_giftcard')->__('Expiry Date') ,
89
+ 'required' => true,
90
+ 'image' => $this->getSkinUrl('images/grid-cal.gif') ,
91
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT) ,
92
+ );
93
+ if (version_compare(Mage::getVersion() , '1.1.8', '>=')) {
94
+ $arr['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
95
+ }
96
+ $expireAt = $fieldset->addField('expiry_date', 'date', $arr);
97
+ $form->setValues($data);
98
+ return parent::_prepareForm();
99
+ }
100
+ }
101
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Groupsend/Edit/Tabs.php~ ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Solvingmagento_AffiliateProduct_Block_Adminhtml_Registries_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('giftregistries_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('solvingmagento_affiliateproduct')->__('Manage Gift Cards'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('solvingmagento_affiliateproduct')->__('Gift Certificate Information'),
18
+ 'title' => Mage::helper('solvingmagento_affiliateproduct')->__('Gift Certificate Information'),
19
+ 'content' => $this->getLayout()->createBlock('solvingmagento_affiliateproduct/adminhtml_registries_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ if ($id = Mage::app()->getRequest()->getParam('id')) {
23
+ $this->addTab('history', array(
24
+ 'label' => Mage::helper('solvingmagento_affiliateproduct')->__('Transaction History'),
25
+ 'title' => Mage::helper('solvingmagento_affiliateproduct')->__('Transaction History'),
26
+ 'content' => $this->getLayout()->createBlock('solvingmagento_affiliateproduct/adminhtml_registries_edit_tab_history')
27
+ ->setCertId($id)
28
+ ->toHtml(),
29
+ ));
30
+ }
31
+
32
+ return parent::_beforeToHtml();
33
+ }
34
+ }
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Registries extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct(){
5
+ $this->_controller = 'adminhtml_registries';
6
+ $this->_blockGroup = 'kartparadigm_giftcard';
7
+ $this->_headerText = Mage::helper('kartparadigm_giftcard')->__('Gift Card Manager');
8
+ $this->_addButtonLabel = Mage::helper('kartparadigm_giftcard')->__('Add New Giftcard');
9
+ parent::__construct();
10
+ //$this->_removeButton('add');//to remove add new button
11
+ }
12
+ }
13
+ ?>
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Edit.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Registries_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ public function __construct(){
5
+ parent::__construct();
6
+ $this->_objectId = 'id';
7
+
8
+ $this->_controller = 'adminhtml_registries';
9
+ $this->_blockGroup = 'kartparadigm_giftcard';
10
+
11
+ $this->_mode = 'edit';
12
+ $this->_updateButton('save', 'label', Mage::helper('kartparadigm_giftcard')->__('Save Giftcard'));
13
+ $this->_updateButton('delete', 'label', Mage::helper('kartparadigm_giftcard')->__('Delete Giftcard'));
14
+
15
+
16
+ }
17
+ public function getHeaderText()
18
+ {
19
+ if(Mage::registry('registry_data') && Mage::registry('registry_data')->getId())
20
+ return Mage::helper('kartparadigm_giftcard')->__("Edit Giftcard '%s'", $this->htmlEscape(Mage::registry('registry_data')->getGiftcardName()));
21
+ return Mage::helper('kartparadigm_giftcard')->__('Add Giftcard');
22
+ }
23
+ }
24
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Edit/Form.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Registries_Edit_Form
3
+ extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm(){
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array('id'=> $this->getRequest()->getParam('id'))),
9
+ 'method' => 'post',
10
+ 'enctype' => 'multipart/form-data'
11
+ ));
12
+ $form->setUseContainer(true);
13
+ $this->setForm($form);
14
+ if (Mage::getSingleton('adminhtml/session')->getFormData()){
15
+ $data = Mage::getSingleton('adminhtml/session')->getFormData();
16
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
17
+ }
18
+ elseif(Mage::registry('registry_data'))
19
+ $data = Mage::registry('registry_data')->getData();
20
+ $fieldset = $form->addFieldset('registry_form',
21
+ array('legend'=>Mage::helper('kartparadigm_giftcard')->__('Gift Card information')));
22
+ $fieldset->addField('giftcard_name', 'text', array(
23
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Name'),
24
+ 'class'=> 'required-entry',
25
+ 'required' => true,
26
+ 'name'=> 'giftcard_name',
27
+ ));
28
+ $fieldset->addField('giftcard_val', 'text', array(
29
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Amount'),
30
+ 'class'=> 'required-entry',
31
+ 'required' => true,
32
+ 'name'=> 'giftcard_val',
33
+
34
+ ));
35
+ $fieldset->addField('giftcard_bal', 'text', array(
36
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Balance'),
37
+ 'class'=> 'required-entry',
38
+ 'required' => true,
39
+ 'name'=> 'giftcard_bal',
40
+
41
+ ));
42
+ /*$fieldset->addField('giftcard_currency', 'text', array(
43
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Currency'),
44
+ 'class'=> 'required-entry',
45
+ 'required' => true,
46
+ 'name'=> 'giftcard_currency',
47
+ ));*/
48
+ $fieldset->addField('customer_name', 'text', array(
49
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Sender Name'),
50
+ 'class'=> 'required-entry',
51
+ 'required' => true,
52
+ 'name'=> 'customer_name',
53
+ ));
54
+ $fieldset->addField('customer_mail', 'text', array(
55
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Sender Mail'),
56
+ 'class'=> 'required-entry',
57
+ 'required' => true,
58
+ 'name'=> 'customer_mail',
59
+ ));
60
+ $fieldset->addField('receiver_name', 'text', array(
61
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Receiver Name'),
62
+ 'class'=> 'required-entry',
63
+ 'required' => true,
64
+ 'name'=> 'receiver_name',
65
+ ));
66
+ $fieldset->addField('receiver_mail', 'text', array(
67
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Receiver Email'),
68
+ 'class'=> 'required-entry',
69
+ 'required' => true,
70
+ 'name'=> 'receiver_mail',
71
+ ));
72
+
73
+ $fieldset->addField('giftcard_msg', 'textarea', array(
74
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Giftcard Message'),
75
+ 'class'=> 'required-entry',
76
+ 'required' => true,
77
+ 'name'=> 'giftcard_msg',
78
+ ));
79
+
80
+ $fieldset->addField('giftcard_status', 'select', array(
81
+ 'name' => 'giftcard_status',
82
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Status'),
83
+ 'class' => 'required-entry',
84
+ 'required' => true,
85
+ 'options' => array(
86
+ 0 => Mage::helper('kartparadigm_giftcard')->__('Inactive'),
87
+ 1 => Mage::helper('kartparadigm_giftcard')->__('Active'),
88
+ 2 => Mage::helper('kartparadigm_giftcard')->__('Processing'),
89
+ 3 => Mage::helper('kartparadigm_giftcard')->__('Redeemed'),
90
+ 4 => Mage::helper('kartparadigm_giftcard')->__('Expired'),
91
+ 5 => Mage::helper('kartparadigm_giftcard')->__('Cancelled'),
92
+ ),
93
+ ));
94
+
95
+
96
+ //store field
97
+ $fieldset->addField('store_id', 'select', array( //can use multiselect
98
+ 'name' => 'store_id[]',
99
+ 'label' => Mage::helper('cms')->__('Store View'),
100
+ 'title' => Mage::helper('cms')->__('Store View'),
101
+ 'required' => true,
102
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
103
+ ));
104
+
105
+ $fieldset->addField('giftcard_currency', 'select', array(
106
+ 'name' => 'giftcard_currency',
107
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Currency'),
108
+ 'class' => 'required-entry',
109
+ 'required' => true,
110
+ 'values' => Mage::getSingleton('adminhtml/system_config_source_currency')
111
+ ->toOptionArray(false),
112
+ 'value' => Mage::app()->getStore()->getDefaultCurrency()->getCurrencyCode(),
113
+ ));
114
+
115
+ // date field
116
+ $arr = array(
117
+ 'name' => 'expiry_date',
118
+ 'label'=> Mage::helper('kartparadigm_giftcard')->__('Expiry Date'),
119
+ 'required'=> true,
120
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
121
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
122
+ );
123
+ if (version_compare(Mage::getVersion(), '1.1.8', '>=')) {
124
+ $arr['input_format'] = Varien_Date::DATE_INTERNAL_FORMAT;
125
+ }
126
+ $expireAt = $fieldset->addField('expiry_date', 'date', $arr);
127
+
128
+
129
+ $form->setValues($data);
130
+ return parent::_prepareForm();
131
+ }
132
+ }
133
+
134
+
135
+
136
+
137
+
138
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Registries/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Registries_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+
4
+ {
5
+ public function __construct()
6
+
7
+ {
8
+ parent::__construct();
9
+ $this->setId('registriesGrid');
10
+ $this->setDefaultSort('giftcard_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+ protected function _prepareColumns()
21
+ {
22
+ $this->addColumn('giftcard_id', array(
23
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Id') ,
24
+ 'width' => 50,
25
+ 'index' => 'giftcard_id',
26
+ 'sortable' => true,
27
+ 'type' => 'number',
28
+ ));
29
+ $this->addColumn('order_id', array(
30
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Order ID') ,
31
+ 'index' => 'order_id',
32
+ 'sortable' => true,
33
+ 'type' => 'number',
34
+ ));
35
+ $this->addColumn('customer_name', array(
36
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Customer Name') ,
37
+ 'index' => 'receiver_name',
38
+ 'sortable' => true,
39
+ 'type'=>'text',
40
+ ));
41
+ $this->addColumn('giftcard_code', array(
42
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Code') ,
43
+ 'index' => 'giftcard_code',
44
+ 'sortable' => true,
45
+ 'type'=>'text',
46
+ ));
47
+ $this->addColumn('giftcard_bal', array(
48
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Balance') ,
49
+ 'index' => 'giftcard_bal',
50
+ 'sortable' => true,
51
+ 'type' => 'currency',
52
+ 'currency' => 'giftcard_currency',
53
+ ));
54
+ $this->addColumn('store_id', array(
55
+ 'header' => $this->__('Store View') ,
56
+ 'width' => '200px',
57
+ 'index' => 'store_id',
58
+ 'type' => 'store',
59
+ 'store_all' => false,
60
+ 'store_view' => true,
61
+ ));
62
+ $this->addColumn('created_date', array(
63
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Created Date') ,
64
+ 'index' => 'created_date',
65
+ 'sortable' => true,
66
+ 'type' => 'date',
67
+ ));
68
+ $this->addColumn('giftcard_status', array(
69
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Giftcard Status') ,
70
+ 'index' => 'giftcard_status',
71
+ 'type' => 'options',
72
+ 'sortable' => true,
73
+ 'options' => array(
74
+ 0 => 'Inactive',
75
+ 1 => 'Active',
76
+ 2 => 'Processing',
77
+ 3 => 'Redeemed',
78
+ 4 => 'Expired',
79
+ 5 => 'Cancelled',
80
+ ) ,
81
+ ));
82
+ $this->addColumn('is_notified', array(
83
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Is Notified') ,
84
+ 'index' => 'is_notified',
85
+ 'type' => 'options',
86
+ 'sortable' => true,
87
+ 'options' => array(
88
+ 0 => 'NO',
89
+ 1 => 'YES',
90
+ ) ,
91
+ ));
92
+ $this->addColumn('action_view', array(
93
+ 'header' => $this->helper('kartparadigm_giftcard')->__('Print') ,
94
+ 'width' => 15,
95
+ 'getter' => 'getId',
96
+ 'sortable' => false,
97
+ 'filter' => false,
98
+ 'type' => 'action',
99
+ 'actions' => array(
100
+ array(
101
+ 'caption' => Mage::helper('kartparadigm_giftcard')->__('Print') ,
102
+ 'url' => array(
103
+ 'base' => '*/*/view'
104
+ ) ,
105
+ 'field' => 'id'
106
+ )
107
+ )
108
+ ));
109
+ return parent::_prepareColumns();
110
+ }
111
+ protected function _prepareMassaction()
112
+ {
113
+ $this->setMassactionIdField('giftcard_id');
114
+ $this->getMassactionBlock()->setFormFieldName('registries');
115
+ $this->getMassactionBlock()->addItem('delete', array(
116
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Delete') ,
117
+ 'url' => $this->getUrl('*/*/massDelete') ,
118
+ 'confirm' => Mage::helper('kartparadigm_giftcard')->__('Are you sure?')
119
+ ));
120
+ return $this;
121
+ }
122
+ public function getRowUrl($row) //disable edit giftcard option
123
+
124
+ {
125
+ return $this->getUrl('*/*/edit', array(
126
+ 'id' => $row->getGiftcardId()
127
+ ));
128
+ }
129
+ }
130
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Templates extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+
4
+ {
5
+ public
6
+
7
+ function __construct()
8
+ {
9
+ $this->_controller = 'adminhtml_templates';
10
+ $this->_blockGroup = 'kartparadigm_giftcard';
11
+ $this->_headerText = Mage::helper('kartparadigm_giftcard')->__('Giftcard Template Manager');
12
+ $this->_addButtonLabel = Mage::helper('kartparadigm_giftcard')->__('Add New Template');
13
+ parent::__construct();
14
+
15
+ // $this->_removeButton('add');//to remove add new button
16
+
17
+ }
18
+ }
19
+
20
+ ?>
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Edit.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Templates_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ public function __construct(){
5
+
6
+ parent::__construct();
7
+ $this->_objectId = 'id';
8
+
9
+ $this->_controller = 'adminhtml_templates';
10
+ $this->_blockGroup = 'kartparadigm_giftcard';
11
+
12
+ $this->_mode = 'edit';
13
+ $this->_updateButton('save', 'label', Mage::helper('kartparadigm_giftcard')->__('Save Template'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('kartparadigm_giftcard')->__('Delete Template'));
15
+
16
+
17
+ }
18
+ public function getHeaderText()
19
+ {
20
+ if(Mage::registry('registry_data') && Mage::registry('registry_data')->getId())
21
+ return Mage::helper('kartparadigm_giftcard')->__("Edit Template '%s'", $this->htmlEscape(Mage::registry('registry_data')->getGiftcardName()));
22
+ return Mage::helper('kartparadigm_giftcard')->__('Add Giftcard Template');
23
+ }
24
+ }
25
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Edit/Form.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Templates_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array(
10
+ 'id' => $this->getRequest()->getParam('id')
11
+ )) ,
12
+ 'method' => 'post',
13
+ 'enctype' => 'multipart/form-data'
14
+ ));
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ if (Mage::getSingleton('adminhtml/session')->getFormData()) {
18
+ $data = Mage::getSingleton('adminhtml/session')->getFormData();
19
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
20
+ }
21
+ elseif (Mage::registry('templates_data')) $data = Mage::registry('templates_data')->getData();
22
+ $fieldset = $form->addFieldset('templates_form', array(
23
+ 'legend' => Mage::helper('kartparadigm_giftcard')->__('Templates information')
24
+ ));
25
+ $fieldset->addField('template_name', 'text', array(
26
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Template Name ') ,
27
+ 'class' => 'required-entry',
28
+ 'required' => true,
29
+ 'name' => 'template_name',
30
+ ));
31
+ /* $fieldset->addField('template_layout', 'select', array(
32
+ 'name' => 'template_layout',
33
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Template Design') ,
34
+ 'class' => 'required-entry',
35
+ 'required' => true,
36
+ 'options' => array(
37
+ //'Center Layout' => Mage::helper('kartparadigm_giftcard')->__('Center Layout') ,
38
+ 'Left Layout' => Mage::helper('kartparadigm_giftcard')->__('Left Layout') ,
39
+ // 'Top Layout' => Mage::helper('kartparadigm_giftcard')->__('Top Layout') ,
40
+ ) ,
41
+ ));*/
42
+ $fieldset->addField('theme_color', 'text', array(
43
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Theme Color') ,
44
+ 'required' => true,
45
+ 'name' => 'theme_color',
46
+ 'class' => 'colorpicker',
47
+ ));
48
+ if (isset($data['template_img']) && $data['template_img'] != '') {
49
+ $finderLink1 = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . '' . $data['template_img'];
50
+ $finderName1 = $data['template_img'];
51
+ $fieldset->addField('imagelab', 'label', array(
52
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Template Image') ,
53
+ 'name' => 'image',
54
+ 'value' => $finderLink1,
55
+ 'required' => true,
56
+ 'after_element_html' => '<img src="' . $finderLink1 . '" alt=" ' . $finderName1 . '" height="50" width="50" /><br/><small>image size 250 x 350</small>',
57
+ ));
58
+ $fieldset->addField('template_img', 'image', array(
59
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Change image') ,
60
+ 'required' => false,
61
+ 'name' => 'template_img',
62
+ ));
63
+ }
64
+ else {
65
+ $fieldset->addField('template_img', 'image', array(
66
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Template Image') ,
67
+ 'required' => false,
68
+ 'name' => 'template_img',
69
+ 'after_element_html' => '<br/><small>image size 250 x 600</small>',
70
+ ));
71
+ }
72
+
73
+ /* if (isset($data['background_img']) && $data['background_img'] != '') {
74
+ $finderLink = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . '' . $data['background_img'];
75
+ $finderName = $data['background_img'];
76
+ $fieldset->addField('imagelabel', 'label', array(
77
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Background Image') ,
78
+ 'name' => 'image',
79
+ 'value' => $finderLink,
80
+ 'after_element_html' => '<img src="' . $finderLink . '" alt=" ' . $finderName . '" height="50" width="50" /><br/><small>image size 250 x 350</small>',
81
+ ));
82
+ $fieldset->addField('background_img', 'image', array(
83
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Change image') ,
84
+ 'required' => false,
85
+ 'name' => 'background_img',
86
+ 'after_element_html' => '<br/><small>image size 250 x 600</small>',
87
+ ));
88
+ }
89
+ else {
90
+ $fieldset->addField('background_img', 'image', array(
91
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('BackGround Image') ,
92
+ 'required' => false,
93
+ 'name' => 'background_img',
94
+ ));
95
+ }*/
96
+ $fieldset->addField('text_color', 'text', array(
97
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Text Color') ,
98
+ 'required' => true,
99
+ 'name' => 'text_color',
100
+ 'class' => 'colorpicker',
101
+ ));
102
+ $fieldset->addField('giftcard_note', 'textarea', array(
103
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Notes') ,
104
+ 'class' => 'required-entry',
105
+ 'required' => true,
106
+ 'name' => 'giftcard_note',
107
+ ));
108
+ /* $fieldset->addField('template_status', 'select', array(
109
+ 'name' => 'template_status',
110
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Status') ,
111
+ 'class' => 'required-entry',
112
+ 'required' => true,
113
+ 'options' => array(
114
+ 1 => Mage::helper('kartparadigm_giftcard')->__('Active') ,
115
+ 0 => Mage::helper('kartparadigm_giftcard')->__('Inactive') ,
116
+ ) ,
117
+ ));*/
118
+ $form->setValues($data);
119
+ return parent::_prepareForm();
120
+ }
121
+ }
122
+
app/code/community/Kartparadigm/Giftcard/Block/Adminhtml/Templates/Grid.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Adminhtml_Templates_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+
4
+ {
5
+ public function __construct()
6
+
7
+ {
8
+ parent::__construct();
9
+ $this->setId('templatesGrid');
10
+ $this->setDefaultSort('giftcardtemplate_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+ protected function _prepareColumns()
21
+ {
22
+ $this->addColumn('giftcardtemplate_id', array(
23
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Id') ,
24
+ 'width' => 50,
25
+ 'index' => 'giftcardtemplate_id',
26
+ 'sortable' => true,
27
+ 'type' => 'number',
28
+ ));
29
+ $this->addColumn('template_name', array(
30
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Template Name') ,
31
+ 'index' => 'template_name',
32
+ 'sortable' => true,
33
+ 'type'=>'text',
34
+ ));
35
+ /* $this->addColumn('template_layout', array(
36
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Layout') ,
37
+ 'index' => 'template_layout',
38
+ 'sortable' => true,
39
+ 'type' => 'options',
40
+ 'options' => array(
41
+ 'Center Layout' => 'Ceter Layout',
42
+ 'Left Layout' => 'Left Layout',
43
+ 'Top Layout' => 'Top Layout',
44
+ ) ,
45
+ ));*/
46
+ $this->addColumn('theme_color', array(
47
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Theme Color') ,
48
+ 'index' => 'theme_color',
49
+ 'sortable' => true,
50
+ 'type'=>'text',
51
+ ));
52
+ $this->addColumn('text_color', array(
53
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Text Color') ,
54
+ 'index' => 'text_color',
55
+ 'sortable' => true,
56
+ 'type'=>'text',
57
+ ));
58
+ $this->addColumn('giftcard_note', array(
59
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Note') ,
60
+ 'index' => 'giftcard_note',
61
+ 'sortable' => true,
62
+ 'type'=>'textarea',
63
+ ));
64
+ /*$this->addColumn('template_status', array(
65
+ 'header' => Mage::helper('kartparadigm_giftcard')->__('Status') ,
66
+ 'index' => 'template_status',
67
+ 'sortable' => true,
68
+ 'type' => 'options',
69
+ 'options' => array(
70
+ 0 => 'Inactive',
71
+ 1 => 'Active',
72
+ ) ,
73
+ ));*/
74
+ $this->addColumn('action_edit', array(
75
+ 'header' => $this->helper('kartparadigm_giftcard')->__('Action') ,
76
+ 'width' => 15,
77
+ 'getter' => 'getId',
78
+ 'sortable' => false,
79
+ 'filter' => false,
80
+ 'type' => 'action',
81
+ 'actions' => array(
82
+ array(
83
+ 'caption' => Mage::helper('kartparadigm_giftcard')->__('Edit') ,
84
+ 'url' => array(
85
+ 'base' => '*/*/edit'
86
+ ) ,
87
+ 'field' => 'id'
88
+ )
89
+ )
90
+ ));
91
+ $this->addColumn('action_view', array(
92
+ 'header' => $this->helper('kartparadigm_giftcard')->__('Preview') ,
93
+ 'width' => 15,
94
+ 'getter' => 'getId',
95
+ 'sortable' => false,
96
+ 'filter' => false,
97
+ 'type' => 'action',
98
+ 'actions' => array(
99
+ array(
100
+ 'caption' => Mage::helper('kartparadigm_giftcard')->__('Preview') ,
101
+ 'url' => array(
102
+ 'base' => '*/*/view'
103
+ ) ,
104
+ 'field' => 'id'
105
+ )
106
+ )
107
+ ));
108
+ return parent::_prepareColumns();
109
+ }
110
+ protected function _prepareMassaction()
111
+ {
112
+ $this->setMassactionIdField('giftcardtemplate_id');
113
+ $this->getMassactionBlock()->setFormFieldName('templates');
114
+ $this->getMassactionBlock()->addItem('delete', array(
115
+ 'label' => Mage::helper('kartparadigm_giftcard')->__('Delete') ,
116
+ 'url' => $this->getUrl('*/*/massDelete') ,
117
+ 'confirm' => Mage::helper('kartparadigm_giftcard')->__('Are you sure?')
118
+ ));
119
+ return $this;
120
+ }
121
+ public function getRowUrl($row) //disable edit giftcard option
122
+
123
+ {
124
+ return $this->getUrl('*/*/edit', array(
125
+ 'id' => $row->getGiftcardtemplateId()
126
+ ));
127
+ }
128
+ }
129
+
app/code/community/Kartparadigm/Giftcard/Block/Balance.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_Balance extends Mage_Core_Block_Template
3
+ {
4
+
5
+ public function getCustomerGiftcards()
6
+ {
7
+ $collection = null;
8
+ $currentCustomer =Mage::getSingleton('customer/session')->getCustomer();
9
+
10
+ if($currentCustomer)
11
+ {
12
+ $collection =Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()
13
+ ->addFieldToFilter('receiver_mail',$currentCustomer->getEmail())->addOrder('giftcard_id','DESC');
14
+ }
15
+ return $collection;
16
+ }
17
+ }
app/code/community/Kartparadigm/Giftcard/Block/Catalog/Product/View/Type.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Block_Catalog_Product_View_Type extends Mage_Catalog_Block_Product_View_Abstract
4
+ {
5
+
6
+ }
app/code/community/Kartparadigm/Giftcard/Block/Payment/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Block_Payment_Form extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+
8
+ parent::_construct();
9
+ $this->setTemplate('kartparadigm/giftcard/payment/form.phtml');
10
+ }
11
+
12
+ public function getComments()
13
+ {
14
+
15
+ return Mage::getStoreConfig('payment/kartparadigm_giftcard/comments');
16
+ }
17
+ }
app/code/community/Kartparadigm/Giftcard/Block/Payment/Info.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Block_Payment_Info extends Mage_Payment_Block_Info
4
+ {
5
+
6
+ }
app/code/community/Kartparadigm/Giftcard/Block/View.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Block_View extends Mage_Core_Block_Template
3
+ {
4
+
5
+ public function getGiftcardTrans()
6
+ {
7
+
8
+ $collection =Mage::getModel('kartparadigm_giftcard/giftcardtrans')->getCollection()
9
+ ->addFieldToFilter('giftcard_id',$this->getRequest()->getParam('id'));
10
+ return $collection;
11
+ }
12
+ }
app/code/community/Kartparadigm/Giftcard/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ public function getStatusarray(){
6
+ $arr=array();
7
+ $arr[0]="Inactive";
8
+ $arr[1]="Active";
9
+ $arr[2]="Processing";
10
+ $arr[3]="Redeemed";
11
+ $arr[4]="Expired";
12
+ $arr[5]="Cancelled";
13
+ return $arr;
14
+ }
15
+ public function getCodeMasked($cc=0)
16
+ {
17
+ // Get the cc Length
18
+ $cc_length = strlen($cc);
19
+ $i=0;
20
+ // Replace all characters of credit card except the last four and dashes
21
+ for($i=$cc_length; $i>9; $i--){
22
+ if((isset($cc[$i])) && ($cc[$i] == '-')){continue;}
23
+ $cc[$i] = 'X';
24
+ }
25
+ // Return the masked Credit Card #
26
+ return $cc;
27
+ }
28
+
29
+ }
app/code/community/Kartparadigm/Giftcard/Helper/Data.php~ ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ public function getStatusarray(){
6
+ $arr=array();
7
+ $arr[0]="Inactive";
8
+ $arr[1]="Active";
9
+ $arr[2]="Processing";
10
+ $arr[3]="Redeemed";
11
+ $arr[4]="Expired";
12
+ $arr[5]="Cancelled";
13
+ return $arr;
14
+ }
15
+ public function getCodeMasked($cc=0)
16
+ {
17
+ // Get the cc Length
18
+ $cc_length = strlen($cc);
19
+ $i=0;
20
+ // Replace all characters of credit card except the last four and dashes
21
+ for($i=$cc_length; $i>9; $i--){
22
+ if((isset($cc[$i])) && ($cc[$i] == '-')){continue;}
23
+ $cc[$i] = 'X';
24
+ }
25
+ // Return the masked Credit Card #
26
+ return $cc;
27
+ }
28
+
29
+ }
app/code/community/Kartparadigm/Giftcard/Helper/Payment.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Helper_Payment extends Mage_Payment_Helper_Data
4
+ {
5
+
6
+ public function getStoreMethods($store=null, $quote=null)
7
+ {
8
+
9
+ $fullyPaidByGiftcard = (($quote->getGrandTotal()==$quote->getGiftcardBalused())&&($quote->getGiftcardCode()!=''));
10
+
11
+
12
+ if ($fullyPaidByGiftcard) {
13
+ return array(Mage::getModel(Mage::getStoreConfig(self::XML_PATH_PAYMENT_METHODS.'/kartparadigm_giftcard/model', $store)));
14
+ }
15
+ return parent::getStoreMethods($store, $quote);
16
+ }
17
+ }
app/code/community/Kartparadigm/Giftcard/Helper/Payment.php~ ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Helper_Payment extends Mage_Payment_Helper_Data
4
+ {
5
+
6
+ public function getStoreMethods($store=null, $quote=null)
7
+ {
8
+
9
+ $fullyPaidByGiftcard = (($quote->getGrandTotal()==$quote->getGiftcardBalused())&&($quote->getGiftcardCode()!=''));
10
+
11
+
12
+ if ($fullyPaidByGiftcard) {
13
+ return array(Mage::getModel(Mage::getStoreConfig(self::XML_PATH_PAYMENT_METHODS.'/kartparadigm_giftcard/model', $store)));
14
+ }
15
+ return parent::getStoreMethods($store, $quote);
16
+ }
17
+ }
app/code/community/Kartparadigm/Giftcard/Model/Custommethods.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Custommethods
3
+ {
4
+
5
+
6
+ public function generateRule($code, $amount, $label, $from_date,$to_date,$name){
7
+ $name = (empty($name))? $label : $name;
8
+ $labels[0] = $label;//default store label
9
+ $coupon = Mage::getModel('salesrule/rule');
10
+ $coupon->setName($name)
11
+ ->setDescription($name)
12
+ ->setFromDate($from_date)
13
+ ->setToDate($to_date)
14
+ ->setCouponCode($code)
15
+ ->setUsesPerCoupon(10)
16
+ ->setUsesPerCustomer(1)
17
+ ->setCustomerGroupIds(1) //an array of customer grou pids
18
+ ->setIsActive(0)
19
+ ->setStopRulesProcessing(0)
20
+ ->setIsAdvanced(1)
21
+ ->setProductIds('')
22
+ ->setSortOrder(0)
23
+ ->setSimpleAction('by_fixed')
24
+ ->setDiscountAmount($amount)
25
+ ->setDiscountQty(null)
26
+ ->setDiscountStep('0')
27
+ ->setSimpleFreeShipping('0')
28
+ ->setApplyToShipping('0')
29
+ ->setIsRss(0)
30
+ ->setWebsiteIds(1)
31
+ ->setCouponType(2)
32
+ ->setStoreLabels($labels);
33
+ $coupon->save();
34
+ }
35
+
36
+ public function generateUniqueId($length = null){
37
+ $rndId = crypt(uniqid(rand(),1));
38
+ $rndId = strip_tags(stripslashes($rndId));
39
+ $rndId = str_replace(array(".", "$"),"",$rndId);
40
+ $rndId = strrev(str_replace("/","",$rndId));
41
+ if (!is_null($rndId)){
42
+ return strtoupper(substr($rndId, 0, $length));
43
+ }
44
+ return strtoupper($rndId);
45
+ }
46
+
47
+
48
+ public function getBalance($bal,$code)
49
+ {
50
+ $store = Mage::app()->getStore();
51
+ if ($store->getCurrentCurrencyCode()===$code) {
52
+ return $store->formatPrice($bal, true, false);
53
+ } else {
54
+ return $store->convertPrice($bal, true, false);
55
+ }
56
+ }
57
+
58
+ public function checkCartitems()
59
+ {
60
+ $cart = Mage::getModel('checkout/cart')->getQuote();
61
+
62
+ foreach ($cart->getAllItems() as $item) {
63
+ if ($item->getProduct()->getTypeId() === 'giftcard')
64
+ return true;
65
+ else
66
+ continue;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ public function getConamt($amt,$from,$to){
72
+ Mage::log("conver : ".$amt);
73
+ if ($from != $to) {
74
+ $amt = Mage::helper('directory')->currencyConvert($amt, $from, $to);
75
+ return $amt;
76
+ }
77
+ else
78
+ return $amt;
79
+ Mage::log("conver : ".$amt);
80
+ }
81
+
82
+ }
83
+
84
+
85
+
86
+
app/code/community/Kartparadigm/Giftcard/Model/Giftcard.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Giftcard extends
3
+ Mage_Core_Model_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcard');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Giftcardtemplate.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Giftcardtemplate extends Mage_Core_Model_Abstract
3
+
4
+ {
5
+ public function __construct()
6
+
7
+ {
8
+ $this->_init('kartparadigm_giftcard/giftcardtemplate');
9
+ parent::_construct();
10
+ }
11
+ }
12
+
app/code/community/Kartparadigm/Giftcard/Model/Giftcardtrans.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Giftcardtrans extends
3
+ Mage_Core_Model_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcardtrans');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcard extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcard', 'giftcard_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard.php~ ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcard extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcard', 'giftcard_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcard_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcard');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcard/Collection.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcard_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcard');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcardtemplate extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcardtemplate', 'giftcardtemplate_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate.php~ ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcardtemplate extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcardtemplate', 'giftcardtemplate_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcardtemplate_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcardtemplate');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtemplate/Collection.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcardtemplate_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcardtemplate');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcardtrans extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcardtrans', 'giftcardtrans_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans.php~ ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcardtrans extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcardtrans', 'giftcardtrans_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Mysql4_Giftcardtrans_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('kartparadigm_giftcard/giftcardtrans');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Giftcardtrans/Collection.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Giftcardtrans_Collection extends
3
+ Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/giftcardtrans');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Template.php~ ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Template extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/template', 'template_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Mysql4/Templates.php~ ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tele_Giftcard_Model_Mysql4_Template extends
3
+ Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tele_giftcard/template', 'template_id');
8
+ }
9
+ }
app/code/community/Kartparadigm/Giftcard/Model/Observer.php ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Observer
3
+
4
+ {
5
+ // ------------------------------ Adding Custom Price To Cart --------------------------------------
6
+ public function changingPrice(Varien_Event_Observer $observer)
7
+
8
+ {
9
+ $event = $observer->getEvent();
10
+ $quote_item = $event->getQuoteItem();
11
+ if ($quote_item->getProduct()->getTypeId() === 'giftcard') {
12
+ $new_price = Mage::app()->getRequest()->getPost('customp');
13
+ $data = Mage::app()->getRequest()->getPost();
14
+ if (!is_null($new_price)) {
15
+ $quote_item->setCustomPrice($new_price);
16
+ $quote_item->setOriginalCustomPrice($new_price);
17
+ $quote_item->getProduct()->setIsSuperMode(true);
18
+ }
19
+ else if (($quote_item->getProduct()->getPrice() != $quote_item->getProduct()->getGiftcardValue()) && ($quote_item->getProduct()->getGiftcardValue() != 0)) {
20
+ $quote_item->setCustomPrice($quote_item->getProduct()->getGiftcardValue());
21
+ $quote_item->setOriginalCustomPrice($quote_item->getProduct()->getPrice());
22
+ $quote_item->getProduct()->setIsSuperMode(true);
23
+ }
24
+ }
25
+ }
26
+ // ------------------------------ load product after --------------------------------------
27
+ public function catalogProductLoadAfter(Varien_Event_Observer $observer)
28
+
29
+ {
30
+ // set the additional options on the product
31
+ $action = Mage::app()->getFrontController()->getAction();
32
+ if ($action->getFullActionName() == 'checkout_cart_add') {
33
+ // posting our custom form values in an array called extra_options
34
+ if ($options = $action->getRequest()->getParams()) {
35
+ $product = $observer->getProduct();
36
+ // add to the additional options array
37
+ $additionalOptions = array();
38
+ if ($additionalOption = $product->getCustomOption('additional_options')) {
39
+ $additionalOptions = (array)unserialize($additionalOption->getValue());
40
+ }
41
+ foreach($options as $key => $value) {
42
+ if (($key == 'DeliveryDate' || $key == 'Template' || $key == 'SenderName' || $key == 'ReciptentName' || $key == 'RecipientEmail' || $key == 'Address' || $key == 'CustomMessage') && ($value != '')) {
43
+ /*if($key == 'Template')
44
+ {
45
+ continue;
46
+ }*/
47
+ $additionalOptions[] = array(
48
+ 'label' => $key,
49
+ 'value' => $value,
50
+ );
51
+ }
52
+ }
53
+ $observer->getProduct()->addCustomOption('additional_options', serialize($additionalOptions));
54
+ }
55
+ }
56
+ }
57
+ // ------------------------ Persisting Custom Options in order and invoice--------------------------
58
+ public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
59
+
60
+ {
61
+ $quoteItem = $observer->getItem();
62
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength', Mage::app()->getStore()->getStoreId());
63
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter', Mage::app()->getStore()->getStoreId());
64
+ // ---------------------------Generating Giftcard Codes and updating in database-------------------------
65
+ if ($quoteItem->getProduct()->getTypeId() === 'giftcard') {
66
+ $itemcount = $quoteItem->getQty();
67
+ $codes = '';
68
+ for ($i = 0; $i < $itemcount; $i++) {
69
+ $code = Mage::getModel('kartparadigm_giftcard/custommethods')->generateUniqueId($codelengh);
70
+ $code = join('-', str_split($code, $dashafter)); // adding hypen after every 4 letters
71
+ if ($i == 0) $codes = $code;
72
+ else $codes = $codes . ',' . $code;
73
+ }
74
+ $orderItem = $observer->getOrderItem();
75
+ if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
76
+ $quoteitemid = $quoteItem->getItemId();
77
+ $options = $orderItem->getProductOptions();
78
+ $options['additional_options'] = unserialize($additionalOptions->getValue());
79
+ $options['additional_options'][] = array(
80
+ 'label' => 'Giftcard Code(s)',
81
+ 'value' => $codes,
82
+ );
83
+ $orderItem->setProductOptions($options);
84
+ }
85
+ else {
86
+ $options['additional_options'][] = array(
87
+ 'label' => 'Giftcard Code(s)',
88
+ 'value' => $codes,
89
+ );
90
+ $orderItem->setProductOptions($options);
91
+ }
92
+ Mage::register($quoteitemid, $codes);
93
+ }
94
+ }
95
+ // ----------------------- applying giftcard redeem amount to cartitems subtotal -----------------------
96
+ public function collectTotals(Varien_Event_Observer $observer)
97
+
98
+ {
99
+ $quote = $observer->getEvent()->getQuote();
100
+ $quoteid = $quote->getId();
101
+ $damt = $quote->getGiftcardBalused();
102
+ $damtarr = explode(",", $damt);
103
+ $disamt = array_sum(explode(",", $damt));
104
+ $gbal = $quote->getGiftcardBal();
105
+ $gbalarr = explode(",", $gbal);
106
+ $gcbal = array_sum(explode(",", $gbal));
107
+ $gccode = $quote->getGiftcardCode();
108
+ $discountAmount = $gcbal;
109
+ $disamt = end($damtarr);
110
+ $gcbal = end($gbalarr);
111
+
112
+ if (Mage::getStoreConfig('giftcard/giftcard/suborgrand_select', Mage::app()->getStore()->getStoreId())) {
113
+ $total = $quote->getGrandTotal(); //apply gc to grandtotal
114
+ if($quote->getShippingAddress()->getShippingAmount()>0){
115
+ if(($gcbal-$disamt)!=0)
116
+ $disamt= $gcbal;
117
+ }
118
+ }
119
+ else $total = $quote->getSubtotal(); //apply gc to subtotal
120
+
121
+ array_pop($damtarr);
122
+ $damt1 = implode(",", $damtarr);
123
+ array_pop($gbalarr);
124
+ $gbal1 = implode(",", $gbalarr);
125
+ $total = $total - array_sum($damtarr);
126
+ if (isset($gcbal)) {
127
+ $gcnewbal = 0;
128
+ if ($total > $disamt) {
129
+ $discountAmount = $disamt;
130
+ $gcnewbal = $gcbal - $disamt;
131
+ }
132
+ else {
133
+ $discountAmount = $total;
134
+ $gcnewbal = $gcbal - $total;
135
+ }
136
+ if ($damt1 != '') {
137
+ $damt = $damt1 . "," . $discountAmount;
138
+ $gbal = $gbal1 . "," . $gcnewbal;
139
+ }
140
+ else {
141
+ $damt = $discountAmount;
142
+ $gbal = $gcnewbal;
143
+ }
144
+
145
+ $quote->setGiftcardBalused($damt);
146
+ $discountAmount = array_sum(explode(",", $damt));
147
+ }
148
+ if ($quoteid && $discountAmount > 0) {
149
+ if ($discountAmount > 0) {
150
+ $total = $quote->getBaseSubtotal();
151
+ $quote->setSubtotal(0);
152
+ $quote->setBaseSubtotal(0);
153
+ $quote->setSubtotalWithDiscount(0);
154
+ $quote->setBaseSubtotalWithDiscount(0);
155
+ $quote->setGrandTotal(0);
156
+ $quote->setBaseGrandTotal(0);
157
+ $canAddItems = $quote->isVirtual() ? ('billing') : ('shipping');
158
+ foreach($quote->getAllAddresses() as $address) {
159
+ $address->setSubtotal(0);
160
+ $address->setBaseSubtotal(0);
161
+ $address->setGrandTotal(0);
162
+ $address->setBaseGrandTotal(0);
163
+ $address->collectTotals();
164
+ $quote->setSubtotal((float)$quote->getSubtotal() + $address->getSubtotal());
165
+ $quote->setBaseSubtotal((float)$quote->getBaseSubtotal() + $address->getBaseSubtotal());
166
+ $quote->setSubtotalWithDiscount((float)$quote->getSubtotalWithDiscount() + $address->getSubtotalWithDiscount());
167
+ $quote->setBaseSubtotalWithDiscount((float)$quote->getBaseSubtotalWithDiscount() + $address->getBaseSubtotalWithDiscount());
168
+ $quote->setGrandTotal((float)$quote->getGrandTotal() + $address->getGrandTotal());
169
+ $quote->setBaseGrandTotal((float)$quote->getBaseGrandTotal() + $address->getBaseGrandTotal());
170
+ $quote->save();
171
+ $quote->setSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)->setBaseSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)->save();
172
+ if ($address->getAddressType() == $canAddItems) {
173
+ $address->setSubtotalWithDiscount((float)$address->getSubtotalWithDiscount() - $discountAmount);
174
+ $address->setGrandTotal((float)$address->getGrandTotal() - $discountAmount);
175
+ $address->setBaseSubtotalWithDiscount((float)$address->getBaseSubtotalWithDiscount() - $discountAmount);
176
+ $address->setBaseGrandTotal((float)$address->getBaseGrandTotal() - $discountAmount);
177
+ if ($address->getDiscountDescription()) {
178
+ $address->setDiscountAmount(-($address->getDiscountAmount() - $discountAmount));
179
+ $address->setDiscountDescription($address->getDiscountDescription() . ', Giftcard Discount');
180
+ $address->setBaseDiscountAmount(-($address->getBaseDiscountAmount() - $discountAmount));
181
+ }
182
+ else {
183
+ $address->setDiscountAmount(-($discountAmount));
184
+ $address->setDiscountDescription('Giftcard ' . $gccode);
185
+ $address->setBaseDiscountAmount(-($discountAmount));
186
+ }
187
+ $address->save();
188
+ }
189
+ }
190
+ foreach($quote->getAllItems() as $item) {
191
+ // We apply discount amount based on the ratio between the GrandTotal and the RowTotal
192
+ $rat = $item->getPriceInclTax() / $total;
193
+ $ratdisc = $discountAmount * $rat;
194
+ $item->setDiscountAmount(($item->getDiscountAmount() + $ratdisc) * $item->getQty());
195
+ $item->setBaseDiscountAmount(($item->getBaseDiscountAmount() + $ratdisc) * $item->getQty())->save();
196
+ }
197
+ }
198
+ }
199
+ }
200
+ // -------------------------- Changing giftcard status at invoice generation----------------------------
201
+ // --------------------------- sales_order_invoice_save_after --------------------------------------------
202
+ public function changingStatus(Varien_Event_Observer $observer)
203
+
204
+ {
205
+ $invoice = $observer->getEvent()->getInvoice();
206
+ $order = $invoice->getOrder();
207
+ $orderid = $order->getIncrementId();
208
+ $ordered_items = $order->getAllItems();
209
+ $disamt = $order->getDiscountAmount();
210
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
211
+ $date = $date->toString('Y-M-d H:m:s');
212
+ // ---------------changing giftcard status while redeeming giftcard in order placement------------------
213
+ if (-($disamt) > 0) {
214
+ $collec = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
215
+ foreach($collec as $coll) {
216
+ if ($coll != null) {
217
+ $balused = $coll->getGiftcardBalused();
218
+ $gcbal = $coll->getGiftcardBal();
219
+ if ($gcbal > 0) {
220
+ $status = 1;
221
+ $message = 'Admin Processed Invoice and giftcard reactivated';
222
+ }
223
+ else {
224
+ $status = 3;
225
+ $message = 'Admin Processed Invoice and giftcard expired';
226
+ }
227
+ $transdata = array(
228
+ 'giftcard_val' => $coll->getGiftcardVal() ,
229
+ 'giftcard_id' => $coll->getGiftcardId() ,
230
+ 'order_id' => $orderid,
231
+ 'giftcard_bal' => $gcbal,
232
+ 'giftcard_balused' => 0,
233
+ 'giftcard_currency' => $coll->getGiftcardCurrency() ,
234
+ 'giftcard_code' => $coll->getGiftcardCode() ,
235
+ 'customer_name' => $coll->getCustomerName() ,
236
+ 'customer_mail' => $coll->getCustomerMail() ,
237
+ 'giftcard_name' => $coll->getGiftcardName() ,
238
+ 'created_date' => $coll->getCreatedDate() ,
239
+ 'expiry_date' => $coll->getExpiryDate() ,
240
+ 'transac_date' => $date,
241
+ 'giftcard_status' => $status,
242
+ 'comment' => $message
243
+ );
244
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
245
+ try {
246
+ $insertId = $trasmodel->save();
247
+ }
248
+ catch(Exception $e) {
249
+ }
250
+ $gc = Mage::getModel('kartparadigm_giftcard/giftcard')->load($coll->getGiftcardCode() , 'giftcard_code');
251
+ $gcid = Mage::getModel('kartparadigm_giftcard/giftcard')->load($gc->getGiftcardId());
252
+
253
+ $gcid->setGiftcardStatus($status);
254
+ $gcid->save();
255
+ }
256
+ }
257
+ }
258
+ // --------------------------- activating giftcards present in order-------------------------------
259
+ foreach($ordered_items as $item) { //order item detail
260
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
261
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
262
+ $coll = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('gcpro_id', $item->getProduct()->getId())->addFieldToFilter('order_id', $orderid);
263
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
264
+ $date = $date->toString('Y-M-d H:m:s');
265
+ foreach($coll as $col) {
266
+ $transdata = array(
267
+ 'giftcard_val' => $col['giftcard_val'],
268
+ 'giftcard_id' => $col['giftcard_id'],
269
+ 'order_id' => $col['order_id'],
270
+ 'giftcard_bal' => $col['giftcard_bal'],
271
+ 'giftcard_balused' => 0,
272
+ 'giftcard_currency' => $col['giftcard_currency'],
273
+ 'giftcard_code' => $col['giftcard_code'],
274
+ 'customer_name' => $col['receiver_name'],
275
+ 'customer_mail' => $col['receiver_mail'],
276
+ 'giftcard_name' => $col['giftcard_name'],
277
+ 'created_date' => $col['created_date'],
278
+ 'expiry_date' => $col['expiry_date'],
279
+ 'transac_date' => $date,
280
+ 'giftcard_status' => 1, //active
281
+ 'comment' => 'Generated Invoice And Giftcard Activated'
282
+ );
283
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
284
+ $insertId = $trasmodel->save();
285
+ if (Mage::getModel('catalog/product')->load($col['gcpro_id'])->getAttributeText('giftcard_type') != 'Physical Giftcard') {
286
+ // Sending Giftcard Activated Mail to Customer
287
+ $not = 0;
288
+ $today = date('Y-m-d');
289
+ $not = 1;
290
+ $templateid = Mage::getStoreConfig('giftcard/giftcard/custom_email_template1', Mage::app()->getStore()->getStoreId());
291
+ $emailTemplate = Mage::getModel('core/email_template');
292
+ if (!is_numeric($templateid)) {
293
+ $emailTemplate->loadDefault('custom_email_template1');
294
+ $emailTemplate->setTemplateSubject("Giftcard Receiverd From " . $col['customer_name']);
295
+ }
296
+ else {
297
+ $emailTemplate->load($templateid);
298
+ }
299
+ $type = Mage::getStoreConfig('giftcard/giftcard/giftcard_sender_email', Mage::app()->getStore()->getStoreId());
300
+ // Create an array of variables to assign to template
301
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name', $col['template_name'])->getFirstItem();
302
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
303
+ $imgpath="";
304
+ if (strpos($mediapath, 'localhost') !== false) {
305
+ $row['theme_color'] = "FF0000";
306
+ $row['text_color'] = "00AA00";
307
+ $imgpath = "http://www.imagesbuddy.com/images/165/smile-greeting-card.jpg";
308
+ }
309
+ else if ($row['template_img'] != '')
310
+ $imgpath = $mediapath . $row['template_img'];
311
+ else {
312
+ $row['theme_color'] = "FF0000";
313
+ $row['text_color'] = "00AA00";
314
+ $product = Mage::getModel('catalog/product')->load($col['gcpro_id']);
315
+ try{
316
+ $full_path_url = Mage::helper('catalog/image')->init($product, 'thumbnail');
317
+ }
318
+ catch(Exception $e) {
319
+ $full_path_url = $mediapath."giftcard/greet.jpg";
320
+ }
321
+ $imgpath = $full_path_url;
322
+ }
323
+ $emailTemplateVariables['customername'] = $col['customer_name'];
324
+ $emailTemplateVariables['giftcardname'] = $col['giftcard_name'];
325
+ $emailTemplateVariables['giftcardval'] = Mage::helper('core')->currency($col['giftcard_val']);
326
+ $emailTemplateVariables['giftcardcode'] = $col['giftcard_code'];
327
+ $emailTemplateVariables['templateimg'] = $imgpath;
328
+ $emailTemplateVariables['themecolor'] = "#" . $row['theme_color'];
329
+ $emailTemplateVariables['textcolor'] = "#" . $row['text_color'];
330
+ $emailTemplateVariables['receivername'] = $col['receiver_name'];
331
+ $emailTemplateVariables['gcnote'] = $row['giftcard_note'];
332
+ $emailTemplateVariables['custommsg'] = $col['giftcard_msg'];
333
+ $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $type . '/name'));
334
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $type . '/email'));
335
+ $emailTemplate->send($col['receiver_mail'], $col['receiver_name'], $emailTemplateVariables);
336
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set giftcard_status=1, is_notified=1 where giftcard_id=" . $col['giftcard_id']);
337
+ $writeConnection->commit();
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ // --------------------------------------cancel invoice----------------------------------------------------------
344
+ // ----------------------------------sales_order_payment_cancel--------------------------------------------
345
+ public function kartparadigmCancel(Varien_Event_Observer $observer)
346
+
347
+ {
348
+ $order = $observer->getPayment()->getOrder();
349
+ $orderid = $order->getIncrementId();
350
+ $ordered_items = $order->getAllItems();
351
+ $disamt = $order->getDiscountAmount();
352
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
353
+ $date = $date->toString('Y-M-d H:m:s');
354
+ // -----------------changing giftcard status while redeeming giftcard in order placement---------------
355
+ if (-($disamt) > 0) {
356
+ $collec = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
357
+ foreach($collec as $coll) {
358
+ if ($coll != null) {
359
+ $balused = $coll->getGiftcardBalused();
360
+ $gcbal = $coll->getGiftcardBal();
361
+ $updatebal = $gcbal + $balused; // update balance in trans
362
+ if ($updatebal > 0) {
363
+ $status = 1; //active
364
+ $message = 'Admin Canceled Invoice and added amount to giftcard';
365
+ }
366
+ else {
367
+ $status = 3; //redeemed
368
+ $message = 'Admin Canceled Invoice and giftcard expired';
369
+ }
370
+ $transdata = array(
371
+ 'giftcard_val' => $coll->getGiftcardVal() ,
372
+ 'giftcard_id' => $coll->getGiftcardId() ,
373
+ 'order_id' => $orderid,
374
+ 'giftcard_bal' => $updatebal,
375
+ 'giftcard_balused' => 0,
376
+ 'giftcard_currency' => $coll->getGiftcardCurrency() ,
377
+ 'giftcard_code' => $coll->getGiftcardCode() ,
378
+ 'customer_name' => $coll->getCustomerName() ,
379
+ 'customer_mail' => $coll->getCustomerMail() ,
380
+ 'giftcard_name' => $coll->getGiftcardName() ,
381
+ 'created_date' => $coll->getCreatedDate() ,
382
+ 'expiry_date' => $coll->getExpiryDate() ,
383
+ 'transac_date' => $date,
384
+ 'giftcard_status' => $status,
385
+ 'comment' => $message
386
+ );
387
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
388
+ try {
389
+ $insertId = $trasmodel->save();
390
+ }
391
+ catch(Exception $e) {
392
+ }
393
+ $gc = Mage::getModel('kartparadigm_giftcard/giftcard')->load($coll->getGiftcardCode() , 'giftcard_code');
394
+ $gcid = Mage::getModel('kartparadigm_giftcard/giftcard')->load($gc->getGiftcardId());
395
+ $gcid->setGiftcardBal($updatebal);
396
+ $gcid->setGiftcardStatus($status);
397
+ $gcid->save();
398
+ }
399
+ }
400
+ }
401
+ // ------------------------------- updating giftcard status to canceled---------------------------
402
+ foreach($ordered_items as $item) { //order item detail
403
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
404
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
405
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set giftcard_status=5 where
406
+ order_id=" . $order->getIncrementId());
407
+ $writeConnection->commit();
408
+ $coll = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
409
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
410
+ $date = $date->toString('Y-M-d H:m:s');
411
+ foreach($coll as $col) {
412
+ $transdata = array(
413
+ 'giftcard_val' => $col['giftcard_val'],
414
+ 'giftcard_id' => $col['giftcard_id'],
415
+ 'order_id' => $col['order_id'],
416
+ 'giftcard_bal' => $col['giftcard_bal'],
417
+ 'giftcard_balused' => 0,
418
+ 'giftcard_currency' => $col['giftcard_currency'],
419
+ 'giftcard_code' => $col['giftcard_code'],
420
+ 'customer_name' => $col['customer_name'],
421
+ 'customer_mail' => $col['customer_mail'],
422
+ 'giftcard_name' => $col['giftcard_name'],
423
+ 'created_date' => $col['created_date'],
424
+ 'expiry_date' => $col['expiry_date'],
425
+ 'transac_date' => $date,
426
+ 'giftcard_status' => 5, //canceled
427
+ 'comment' => 'Invoice Canceled And Giftcard Expired'
428
+ );
429
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
430
+ $insertId = $trasmodel->save();
431
+ }
432
+ }
433
+ }
434
+ }
435
+ // ------------------------------- generating giftcard code when buying giftcards-----------------------------
436
+ // -------------------------------sales_model_service_quote_submit_success--------------------------------------
437
+ public function generatecode(Varien_Event_Observer $observer)
438
+
439
+ {
440
+ $order = $observer->getEvent()->getOrder();
441
+ $session = Mage::getSingleton('checkout/session');
442
+ $ordered_items = $session->getQuote()->getAllItems();
443
+ $quote = $session->getQuote();
444
+ $orderid = $order->getIncrementId();
445
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
446
+ $date = $date->toString('Y-M-d H:m:s');
447
+ $todate = new Zend_Date(Mage::getModel('core/date')->timestamp());
448
+ $expireafter = Mage::getStoreConfig('giftcard/giftcard/txt_expiry', Mage::app()->getStore()->getStoreId());
449
+ $exdate = $todate->addDay($expireafter)->toString('Y-M-d H:m:s');
450
+ $gccodes = $quote->getGiftcardCode();
451
+ $codearr = explode(",", $gccodes);
452
+ $gcbal = $quote->getGiftcardBal();
453
+ $balarr = explode(",", $gcbal);
454
+ $balused = $quote->getGiftcardBalused();
455
+ $balusedarr = explode(",", $balused);
456
+ $x = 0;
457
+ foreach($codearr as $gccode) {
458
+ $row = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('giftcard_code', $gccode)->addFieldToFilter('giftcard_status', 1)->getFirstItem();
459
+ $status = 2; //processing
460
+ $balgc=$balarr[$x] - $balusedarr[$x];
461
+ $cod = $row['giftcard_code'];
462
+ // -----------------------Redeeming Giftcard and updating the tables -----------------------------------
463
+ if ($cod != "") {
464
+ $transdata = array(
465
+ 'giftcard_val' => $row['giftcard_val'],
466
+ 'order_id' => $orderid,
467
+ 'giftcard_id' => $row['giftcard_id'],
468
+ 'giftcard_bal' =>$balgc,
469
+ 'giftcard_balused' => $balusedarr[$x],
470
+ 'giftcard_code' => $row['giftcard_code'],
471
+ 'giftcard_currency' => $row['giftcard_currency'],
472
+ 'customer_name' => $row['customer_name'],
473
+ 'customer_mail' => $row['customer_mail'],
474
+ 'giftcard_name' => $row['giftcard_name'],
475
+ 'created_date' => $row['created_date'],
476
+ 'expiry_date' => $row['expiry_date'],
477
+ 'transac_date' => $date,
478
+ 'giftcard_status' => $status,
479
+ 'comment' => 'Giftcard used for purchase in store'
480
+ );
481
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
482
+ try {
483
+ $insertId = $trasmodel->save()->getId();
484
+ }
485
+ catch(Exception $e) {
486
+ }
487
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
488
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set
489
+ giftcard_status=$status,giftcard_bal =$balgc where giftcard_code='" . $cod . "'");
490
+ $writeConnection->commit();
491
+ $x++;
492
+ }
493
+ }
494
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength', Mage::app()->getStore()->getStoreId());
495
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter', Mage::app()->getStore()->getStoreId());
496
+ // ---------------------------Generating Giftcard Codes and updating in database-------------------------
497
+ foreach($ordered_items as $item) { //item detail
498
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
499
+ $recipientname = '';
500
+ $recipientmail = '';
501
+ $address = '';
502
+ $deliverydate = '';
503
+ $message = '';
504
+ $sendermail = '';
505
+ $sendername = '';
506
+ if ($additionalOptions = $item->getOptionByCode('additional_options')) {
507
+ $options = $item->getProductOptions();
508
+ $options['additional_options'] = unserialize($additionalOptions->getValue());
509
+ if (count($options['additional_options'] > 0)) {
510
+ if ($options['additional_options'][1]['value'] != '') {
511
+ $i = 0;
512
+ if ($options['additional_options'][0]['label'] == 'Template') $template = $options['additional_options'][$i++]['value'];
513
+ $sendername = $options['additional_options'][$i++]['value'];
514
+ $recipientname = $options['additional_options'][$i++]['value'];
515
+ $recipientmail = $options['additional_options'][$i++]['value'];
516
+ $message = $options['additional_options'][$i++]['value'];
517
+ $deliverydate = $options['additional_options'][$i++]['value'];
518
+ if ($options['additional_options'][$i++]['value'] != "") $address = $options['additional_options'][$i++]['value'];
519
+ $exdate = date('M-d-Y', strtotime($deliverydate . " +$expireafter days"));
520
+ }
521
+ }
522
+ }
523
+ $sendermail = $order->getCustomerEmail();
524
+ if (empty($recipientname)) {
525
+ $deliverydate = $date;
526
+ $sendername = $order->getCustomerName();
527
+ $template = $options['additional_options'][0]['value'];
528
+ $recipientname = $sendername;
529
+ $recipientmail = $sendermail;
530
+ }
531
+ $itemcount = $item->getQty();
532
+ $codes = Mage::registry($item->getId());
533
+ Mage::unregister($item->getId());
534
+ $codes = explode(",", $codes);
535
+ for ($i = 0; $i < $itemcount; $i++) {
536
+ $currencycode = Mage::app()->getStore()->getCurrentCurrencyCode();
537
+ $code = $codes[$i];
538
+ $amount = $item->getPrice(); // discount amount
539
+ // getting giftcard value
540
+ $gcvalue = Mage::getModel('catalog/product')->load($item->getProductId())->getGiftcardValue();
541
+ if ($gcvalue > $amount) $bal = $gcvalue;
542
+ else $bal = $amount;
543
+ $proid = $item->getProductId();
544
+ $itemname = $item->getName();
545
+ $comment = 'Giftcard Order Placed By ' . $order->getCustomerName();
546
+ $customername = $order->getCustomerName();
547
+ $data = array(
548
+ 'giftcard_val' => $bal,
549
+ 'order_id' => $orderid,
550
+ 'giftcard_bal' => $bal,
551
+ 'giftcard_code' => $code,
552
+ 'giftcard_currency' => $currencycode,
553
+ 'customer_name' => $sendername,
554
+ 'customer_mail' => $sendermail,
555
+ 'gcpro_id' => $proid,
556
+ 'giftcard_name' => $item->getName() ,
557
+ 'created_date' => $date,
558
+ 'expiry_date' => $exdate,
559
+ 'giftcard_status' => 0,
560
+ 'store_id' => Mage::app()->getStore()->getStoreId() ,
561
+ 'added_by' => $customername,
562
+ 'receiver_name' => $recipientname,
563
+ 'receiver_mail' => $recipientmail,
564
+ 'giftcard_address' => $address,
565
+ 'giftcard_msg' => $message,
566
+ 'delivery_date' => $deliverydate,
567
+ 'is_notified' => 0,
568
+ 'template_name' => $template
569
+ );
570
+ $model = Mage::getModel('kartparadigm_giftcard/giftcard')->setData($data);
571
+ try {
572
+ $insertId = $model->save()->getId();
573
+ // inserting in to trans table
574
+ $transdata = array(
575
+ 'giftcard_val' => $bal,
576
+ 'giftcard_id' => $insertId,
577
+ 'order_id' => $orderid,
578
+ 'giftcard_bal' => $bal,
579
+ 'giftcard_balused' => 0,
580
+ 'giftcard_code' => $code,
581
+ 'giftcard_currency' => $currencycode,
582
+ 'customer_name' => $recipientname,
583
+ 'customer_mail' => $recipientmail,
584
+ 'giftcard_name' => $item->getName() ,
585
+ 'created_date' => $date,
586
+ 'expiry_date' => $exdate,
587
+ 'transac_date' => $date,
588
+ 'giftcard_status' => 0,
589
+ 'comment' => $comment
590
+ );
591
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
592
+ $trasmodel->save();
593
+ }
594
+ catch(Exception $e) {
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ }
601
+
app/code/community/Kartparadigm/Giftcard/Model/Observer.php~ ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Observer
3
+
4
+ {
5
+ // ------------------------------ Adding Custom Price To Cart --------------------------------------
6
+ public function changingPrice(Varien_Event_Observer $observer)
7
+
8
+ {
9
+ $event = $observer->getEvent();
10
+ $quote_item = $event->getQuoteItem();
11
+ if ($quote_item->getProduct()->getTypeId() === 'giftcard') {
12
+ $new_price = Mage::app()->getRequest()->getPost('customp');
13
+ $data = Mage::app()->getRequest()->getPost();
14
+ if (!is_null($new_price)) {
15
+ $quote_item->setCustomPrice($new_price);
16
+ $quote_item->setOriginalCustomPrice($new_price);
17
+ $quote_item->getProduct()->setIsSuperMode(true);
18
+ }
19
+ else if (($quote_item->getProduct()->getPrice() != $quote_item->getProduct()->getGiftcardValue()) && ($quote_item->getProduct()->getGiftcardValue() != 0)) {
20
+ $quote_item->setCustomPrice($quote_item->getProduct()->getGiftcardValue());
21
+ $quote_item->setOriginalCustomPrice($quote_item->getProduct()->getPrice());
22
+ $quote_item->getProduct()->setIsSuperMode(true);
23
+ }
24
+ }
25
+ }
26
+ // ------------------------------ load product after --------------------------------------
27
+ public function catalogProductLoadAfter(Varien_Event_Observer $observer)
28
+
29
+ {
30
+ // set the additional options on the product
31
+ $action = Mage::app()->getFrontController()->getAction();
32
+ if ($action->getFullActionName() == 'checkout_cart_add') {
33
+ // posting our custom form values in an array called extra_options
34
+ if ($options = $action->getRequest()->getParams()) {
35
+ $product = $observer->getProduct();
36
+ // add to the additional options array
37
+ $additionalOptions = array();
38
+ if ($additionalOption = $product->getCustomOption('additional_options')) {
39
+ $additionalOptions = (array)unserialize($additionalOption->getValue());
40
+ }
41
+ foreach($options as $key => $value) {
42
+ if (($key == 'DeliveryDate' || $key == 'Template' || $key == 'SenderName' || $key == 'ReciptentName' || $key == 'RecipientEmail' || $key == 'Address' || $key == 'CustomMessage') && ($value != '')) {
43
+ /*if($key == 'Template')
44
+ {
45
+ continue;
46
+ }*/
47
+ $additionalOptions[] = array(
48
+ 'label' => $key,
49
+ 'value' => $value,
50
+ );
51
+ }
52
+ }
53
+ $observer->getProduct()->addCustomOption('additional_options', serialize($additionalOptions));
54
+ }
55
+ }
56
+ }
57
+ // ------------------------ Persisting Custom Options in order and invoice--------------------------
58
+ public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
59
+
60
+ {
61
+ $quoteItem = $observer->getItem();
62
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength', Mage::app()->getStore()->getStoreId());
63
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter', Mage::app()->getStore()->getStoreId());
64
+ // ---------------------------Generating Giftcard Codes and updating in database-------------------------
65
+ if ($quoteItem->getProduct()->getTypeId() === 'giftcard') {
66
+ $itemcount = $quoteItem->getQty();
67
+ $codes = '';
68
+ for ($i = 0; $i < $itemcount; $i++) {
69
+ $code = Mage::getModel('kartparadigm_giftcard/custommethods')->generateUniqueId($codelengh);
70
+ $code = join('-', str_split($code, $dashafter)); // adding hypen after every 4 letters
71
+ if ($i == 0) $codes = $code;
72
+ else $codes = $codes . ',' . $code;
73
+ }
74
+ $orderItem = $observer->getOrderItem();
75
+ if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
76
+ $quoteitemid = $quoteItem->getItemId();
77
+ $options = $orderItem->getProductOptions();
78
+ $options['additional_options'] = unserialize($additionalOptions->getValue());
79
+ $options['additional_options'][] = array(
80
+ 'label' => 'Giftcard Code(s)',
81
+ 'value' => $codes,
82
+ );
83
+ $orderItem->setProductOptions($options);
84
+ }
85
+ else {
86
+ $options['additional_options'][] = array(
87
+ 'label' => 'Giftcard Code(s)',
88
+ 'value' => $codes,
89
+ );
90
+ $orderItem->setProductOptions($options);
91
+ }
92
+ Mage::register($quoteitemid, $codes);
93
+ }
94
+ }
95
+ // ----------------------- applying giftcard redeem amount to cartitems subtotal -----------------------
96
+ public function collectTotals(Varien_Event_Observer $observer)
97
+
98
+ {
99
+ $quote = $observer->getEvent()->getQuote();
100
+ $quoteid = $quote->getId();
101
+ $damt = $quote->getGiftcardBalused();
102
+ $damtarr = explode(",", $damt);
103
+ $disamt = array_sum(explode(",", $damt));
104
+ $gbal = $quote->getGiftcardBal();
105
+ $gbalarr = explode(",", $gbal);
106
+ $gcbal = array_sum(explode(",", $gbal));
107
+ $gccode = $quote->getGiftcardCode();
108
+ $discountAmount = $gcbal;
109
+ $disamt = end($damtarr);
110
+ $gcbal = end($gbalarr);
111
+
112
+ if (Mage::getStoreConfig('giftcard/giftcard/suborgrand_select', Mage::app()->getStore()->getStoreId())) {
113
+ $total = $quote->getGrandTotal(); //apply gc to grandtotal
114
+ if($quote->getShippingAddress()->getShippingAmount()>0){
115
+ if(($gcbal-$disamt)!=0)
116
+ $disamt= $gcbal;
117
+ }
118
+ }
119
+ else $total = $quote->getSubtotal(); //apply gc to subtotal
120
+
121
+ array_pop($damtarr);
122
+ $damt1 = implode(",", $damtarr);
123
+ array_pop($gbalarr);
124
+ $gbal1 = implode(",", $gbalarr);
125
+ $total = $total - array_sum($damtarr);
126
+ if (isset($gcbal)) {
127
+ $gcnewbal = 0;
128
+ if ($total > $disamt) {
129
+ $discountAmount = $disamt;
130
+ $gcnewbal = $gcbal - $disamt;
131
+ }
132
+ else {
133
+ $discountAmount = $total;
134
+ $gcnewbal = $gcbal - $total;
135
+ }
136
+ if ($damt1 != '') {
137
+ $damt = $damt1 . "," . $discountAmount;
138
+ $gbal = $gbal1 . "," . $gcnewbal;
139
+ }
140
+ else {
141
+ $damt = $discountAmount;
142
+ $gbal = $gcnewbal;
143
+ }
144
+
145
+ $quote->setGiftcardBalused($damt);
146
+ $discountAmount = array_sum(explode(",", $damt));
147
+ }
148
+ if ($quoteid && $discountAmount > 0) {
149
+ if ($discountAmount > 0) {
150
+ $total = $quote->getBaseSubtotal();
151
+ $quote->setSubtotal(0);
152
+ $quote->setBaseSubtotal(0);
153
+ $quote->setSubtotalWithDiscount(0);
154
+ $quote->setBaseSubtotalWithDiscount(0);
155
+ $quote->setGrandTotal(0);
156
+ $quote->setBaseGrandTotal(0);
157
+ $canAddItems = $quote->isVirtual() ? ('billing') : ('shipping');
158
+ foreach($quote->getAllAddresses() as $address) {
159
+ $address->setSubtotal(0);
160
+ $address->setBaseSubtotal(0);
161
+ $address->setGrandTotal(0);
162
+ $address->setBaseGrandTotal(0);
163
+ $address->collectTotals();
164
+ $quote->setSubtotal((float)$quote->getSubtotal() + $address->getSubtotal());
165
+ $quote->setBaseSubtotal((float)$quote->getBaseSubtotal() + $address->getBaseSubtotal());
166
+ $quote->setSubtotalWithDiscount((float)$quote->getSubtotalWithDiscount() + $address->getSubtotalWithDiscount());
167
+ $quote->setBaseSubtotalWithDiscount((float)$quote->getBaseSubtotalWithDiscount() + $address->getBaseSubtotalWithDiscount());
168
+ $quote->setGrandTotal((float)$quote->getGrandTotal() + $address->getGrandTotal());
169
+ $quote->setBaseGrandTotal((float)$quote->getBaseGrandTotal() + $address->getBaseGrandTotal());
170
+ $quote->save();
171
+ $quote->setSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)->setBaseSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)->save();
172
+ if ($address->getAddressType() == $canAddItems) {
173
+ $address->setSubtotalWithDiscount((float)$address->getSubtotalWithDiscount() - $discountAmount);
174
+ $address->setGrandTotal((float)$address->getGrandTotal() - $discountAmount);
175
+ $address->setBaseSubtotalWithDiscount((float)$address->getBaseSubtotalWithDiscount() - $discountAmount);
176
+ $address->setBaseGrandTotal((float)$address->getBaseGrandTotal() - $discountAmount);
177
+ if ($address->getDiscountDescription()) {
178
+ $address->setDiscountAmount(-($address->getDiscountAmount() - $discountAmount));
179
+ $address->setDiscountDescription($address->getDiscountDescription() . ', Giftcard Discount');
180
+ $address->setBaseDiscountAmount(-($address->getBaseDiscountAmount() - $discountAmount));
181
+ }
182
+ else {
183
+ $address->setDiscountAmount(-($discountAmount));
184
+ $address->setDiscountDescription('Giftcard ' . $gccode);
185
+ $address->setBaseDiscountAmount(-($discountAmount));
186
+ }
187
+ $address->save();
188
+ }
189
+ }
190
+ foreach($quote->getAllItems() as $item) {
191
+ // We apply discount amount based on the ratio between the GrandTotal and the RowTotal
192
+ $rat = $item->getPriceInclTax() / $total;
193
+ $ratdisc = $discountAmount * $rat;
194
+ $item->setDiscountAmount(($item->getDiscountAmount() + $ratdisc) * $item->getQty());
195
+ $item->setBaseDiscountAmount(($item->getBaseDiscountAmount() + $ratdisc) * $item->getQty())->save();
196
+ }
197
+ }
198
+ }
199
+ }
200
+ // -------------------------- Changing giftcard status at invoice generation----------------------------
201
+ // --------------------------- sales_order_invoice_save_after --------------------------------------------
202
+ public function changingStatus(Varien_Event_Observer $observer)
203
+
204
+ {
205
+ $invoice = $observer->getEvent()->getInvoice();
206
+ $order = $invoice->getOrder();
207
+ $orderid = $order->getIncrementId();
208
+ $ordered_items = $order->getAllItems();
209
+ $disamt = $order->getDiscountAmount();
210
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
211
+ $date = $date->toString('Y-M-d H:m:s');
212
+ // ---------------changing giftcard status while redeeming giftcard in order placement------------------
213
+ if (-($disamt) > 0) {
214
+ $collec = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
215
+ foreach($collec as $coll) {
216
+ if ($coll != null) {
217
+ $balused = $coll->getGiftcardBalused();
218
+ $gcbal = $coll->getGiftcardBal();
219
+ if ($gcbal > 0) {
220
+ $status = 1;
221
+ $message = 'Admin Processed Invoice and giftcard reactivated';
222
+ }
223
+ else {
224
+ $status = 3;
225
+ $message = 'Admin Processed Invoice and giftcard expired';
226
+ }
227
+ $transdata = array(
228
+ 'giftcard_val' => $coll->getGiftcardVal() ,
229
+ 'giftcard_id' => $coll->getGiftcardId() ,
230
+ 'order_id' => $orderid,
231
+ 'giftcard_bal' => $gcbal,
232
+ 'giftcard_balused' => 0,
233
+ 'giftcard_currency' => $coll->getGiftcardCurrency() ,
234
+ 'giftcard_code' => $coll->getGiftcardCode() ,
235
+ 'customer_name' => $coll->getCustomerName() ,
236
+ 'customer_mail' => $coll->getCustomerMail() ,
237
+ 'giftcard_name' => $coll->getGiftcardName() ,
238
+ 'created_date' => $coll->getCreatedDate() ,
239
+ 'expiry_date' => $coll->getExpiryDate() ,
240
+ 'transac_date' => $date,
241
+ 'giftcard_status' => $status,
242
+ 'comment' => $message
243
+ );
244
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
245
+ try {
246
+ $insertId = $trasmodel->save();
247
+ }
248
+ catch(Exception $e) {
249
+ }
250
+ $gc = Mage::getModel('kartparadigm_giftcard/giftcard')->load($coll->getGiftcardCode() , 'giftcard_code');
251
+ $gcid = Mage::getModel('kartparadigm_giftcard/giftcard')->load($gc->getGiftcardId());
252
+
253
+ $gcid->setGiftcardStatus($status);
254
+ $gcid->save();
255
+ }
256
+ }
257
+ }
258
+ // --------------------------- activating giftcards present in order-------------------------------
259
+ foreach($ordered_items as $item) { //order item detail
260
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
261
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
262
+ $coll = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('gcpro_id', $item->getProduct()->getId())->addFieldToFilter('order_id', $orderid);
263
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
264
+ $date = $date->toString('Y-M-d H:m:s');
265
+ foreach($coll as $col) {
266
+ $transdata = array(
267
+ 'giftcard_val' => $col['giftcard_val'],
268
+ 'giftcard_id' => $col['giftcard_id'],
269
+ 'order_id' => $col['order_id'],
270
+ 'giftcard_bal' => $col['giftcard_bal'],
271
+ 'giftcard_balused' => 0,
272
+ 'giftcard_currency' => $col['giftcard_currency'],
273
+ 'giftcard_code' => $col['giftcard_code'],
274
+ 'customer_name' => $col['receiver_name'],
275
+ 'customer_mail' => $col['receiver_mail'],
276
+ 'giftcard_name' => $col['giftcard_name'],
277
+ 'created_date' => $col['created_date'],
278
+ 'expiry_date' => $col['expiry_date'],
279
+ 'transac_date' => $date,
280
+ 'giftcard_status' => 1, //active
281
+ 'comment' => 'Generated Invoice And Giftcard Activated'
282
+ );
283
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
284
+ $insertId = $trasmodel->save();
285
+ if (Mage::getModel('catalog/product')->load($col['gcpro_id'])->getAttributeText('giftcard_type') != 'Physical Giftcard') {
286
+ // Sending Giftcard Activated Mail to Customer
287
+ $not = 0;
288
+ $today = date('Y-m-d');
289
+ $not = 1;
290
+ $templateid = Mage::getStoreConfig('giftcard/giftcard/custom_email_template1', Mage::app()->getStore()->getStoreId());
291
+ $emailTemplate = Mage::getModel('core/email_template');
292
+ if (!is_numeric($templateid)) {
293
+ $emailTemplate->loadDefault('custom_email_template1');
294
+ $emailTemplate->setTemplateSubject("Giftcard Receiverd From " . $col['customer_name']);
295
+ }
296
+ else {
297
+ $emailTemplate->load($templateid);
298
+ }
299
+ $type = Mage::getStoreConfig('giftcard/giftcard/giftcard_sender_email', Mage::app()->getStore()->getStoreId());
300
+ // Create an array of variables to assign to template
301
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name', $col['template_name'])->getFirstItem();
302
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
303
+ $imgpath="";
304
+ if (strpos($mediapath, 'localhost') !== false) {
305
+ $row['theme_color'] = "FF0000";
306
+ $row['text_color'] = "00AA00";
307
+ $imgpath = "http://www.imagesbuddy.com/images/165/smile-greeting-card.jpg";
308
+ }
309
+ else if ($row['template_img'] != '')
310
+ $imgpath = $mediapath . $row['template_img'];
311
+ else {
312
+ $row['theme_color'] = "FF0000";
313
+ $row['text_color'] = "00AA00";
314
+ $product = Mage::getModel('catalog/product')->load($col['gcpro_id']);
315
+ try{
316
+ $full_path_url = Mage::helper('catalog/image')->init($product, 'thumbnail');
317
+ }
318
+ catch(Exception $e) {
319
+ $full_path_url = $mediapath."giftcard/greet.jpg";
320
+ }
321
+ $imgpath = $full_path_url;
322
+ }
323
+ $emailTemplateVariables['customername'] = $col['customer_name'];
324
+ $emailTemplateVariables['giftcardname'] = $col['giftcard_name'];
325
+ $emailTemplateVariables['giftcardval'] = Mage::helper('core')->currency($col['giftcard_val']);
326
+ $emailTemplateVariables['giftcardcode'] = $col['giftcard_code'];
327
+ $emailTemplateVariables['templateimg'] = $imgpath;
328
+ $emailTemplateVariables['themecolor'] = "#" . $row['theme_color'];
329
+ $emailTemplateVariables['textcolor'] = "#" . $row['text_color'];
330
+ $emailTemplateVariables['receivername'] = $col['receiver_name'];
331
+ $emailTemplateVariables['gcnote'] = $row['giftcard_note'];
332
+ $emailTemplateVariables['custommsg'] = $col['giftcard_msg'];
333
+ $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $type . '/name'));
334
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $type . '/email'));
335
+ $emailTemplate->send($col['receiver_mail'], $col['receiver_name'], $emailTemplateVariables);
336
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set giftcard_status=1, is_notified=1 where giftcard_id=" . $col['giftcard_id']);
337
+ $writeConnection->commit();
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ // --------------------------------------cancel invoice----------------------------------------------------------
344
+ // ----------------------------------sales_order_payment_cancel--------------------------------------------
345
+ public function kartparadigmCancel(Varien_Event_Observer $observer)
346
+
347
+ {
348
+ $order = $observer->getPayment()->getOrder();
349
+ $orderid = $order->getIncrementId();
350
+ $ordered_items = $order->getAllItems();
351
+ $disamt = $order->getDiscountAmount();
352
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
353
+ $date = $date->toString('Y-M-d H:m:s');
354
+ // -----------------changing giftcard status while redeeming giftcard in order placement---------------
355
+ if (-($disamt) > 0) {
356
+ $collec = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
357
+ foreach($collec as $coll) {
358
+ if ($coll != null) {
359
+ $balused = $coll->getGiftcardBalused();
360
+ $gcbal = $coll->getGiftcardBal();
361
+ $updatebal = $gcbal + $balused; // update balance in trans
362
+ if ($updatebal > 0) {
363
+ $status = 1; //active
364
+ $message = 'Admin Canceled Invoice and added amount to giftcard';
365
+ }
366
+ else {
367
+ $status = 3; //redeemed
368
+ $message = 'Admin Canceled Invoice and giftcard expired';
369
+ }
370
+ $transdata = array(
371
+ 'giftcard_val' => $coll->getGiftcardVal() ,
372
+ 'giftcard_id' => $coll->getGiftcardId() ,
373
+ 'order_id' => $orderid,
374
+ 'giftcard_bal' => $updatebal,
375
+ 'giftcard_balused' => 0,
376
+ 'giftcard_currency' => $coll->getGiftcardCurrency() ,
377
+ 'giftcard_code' => $coll->getGiftcardCode() ,
378
+ 'customer_name' => $coll->getCustomerName() ,
379
+ 'customer_mail' => $coll->getCustomerMail() ,
380
+ 'giftcard_name' => $coll->getGiftcardName() ,
381
+ 'created_date' => $coll->getCreatedDate() ,
382
+ 'expiry_date' => $coll->getExpiryDate() ,
383
+ 'transac_date' => $date,
384
+ 'giftcard_status' => $status,
385
+ 'comment' => $message
386
+ );
387
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
388
+ try {
389
+ $insertId = $trasmodel->save();
390
+ }
391
+ catch(Exception $e) {
392
+ }
393
+ $gc = Mage::getModel('kartparadigm_giftcard/giftcard')->load($coll->getGiftcardCode() , 'giftcard_code');
394
+ $gcid = Mage::getModel('kartparadigm_giftcard/giftcard')->load($gc->getGiftcardId());
395
+ $gcid->setGiftcardBal($updatebal);
396
+ $gcid->setGiftcardStatus($status);
397
+ $gcid->save();
398
+ }
399
+ }
400
+ }
401
+ // ------------------------------- updating giftcard status to canceled---------------------------
402
+ foreach($ordered_items as $item) { //order item detail
403
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
404
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
405
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set giftcard_status=5 where
406
+ order_id=" . $order->getIncrementId());
407
+ $writeConnection->commit();
408
+ $coll = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('order_id', $order->getIncrementId());
409
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
410
+ $date = $date->toString('Y-M-d H:m:s');
411
+ foreach($coll as $col) {
412
+ $transdata = array(
413
+ 'giftcard_val' => $col['giftcard_val'],
414
+ 'giftcard_id' => $col['giftcard_id'],
415
+ 'order_id' => $col['order_id'],
416
+ 'giftcard_bal' => $col['giftcard_bal'],
417
+ 'giftcard_balused' => 0,
418
+ 'giftcard_currency' => $col['giftcard_currency'],
419
+ 'giftcard_code' => $col['giftcard_code'],
420
+ 'customer_name' => $col['customer_name'],
421
+ 'customer_mail' => $col['customer_mail'],
422
+ 'giftcard_name' => $col['giftcard_name'],
423
+ 'created_date' => $col['created_date'],
424
+ 'expiry_date' => $col['expiry_date'],
425
+ 'transac_date' => $date,
426
+ 'giftcard_status' => 5, //canceled
427
+ 'comment' => 'Invoice Canceled And Giftcard Expired'
428
+ );
429
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
430
+ $insertId = $trasmodel->save();
431
+ }
432
+ }
433
+ }
434
+ }
435
+ // ------------------------------- generating giftcard code when buying giftcards-----------------------------
436
+ // -------------------------------sales_model_service_quote_submit_success--------------------------------------
437
+ public function generatecode(Varien_Event_Observer $observer)
438
+
439
+ {
440
+ $order = $observer->getEvent()->getOrder();
441
+ $session = Mage::getSingleton('checkout/session');
442
+ $ordered_items = $session->getQuote()->getAllItems();
443
+ $quote = $session->getQuote();
444
+ $orderid = $order->getIncrementId();
445
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
446
+ $date = $date->toString('Y-M-d H:m:s');
447
+ $todate = new Zend_Date(Mage::getModel('core/date')->timestamp());
448
+ $expireafter = Mage::getStoreConfig('giftcard/giftcard/txt_expiry', Mage::app()->getStore()->getStoreId());
449
+ $exdate = $todate->addDay($expireafter)->toString('Y-M-d H:m:s');
450
+ $gccodes = $quote->getGiftcardCode();
451
+ $codearr = explode(",", $gccodes);
452
+ $gcbal = $quote->getGiftcardBal();
453
+ $balarr = explode(",", $gcbal);
454
+ $balused = $quote->getGiftcardBalused();
455
+ $balusedarr = explode(",", $balused);
456
+ $x = 0;
457
+ foreach($codearr as $gccode) {
458
+ $row = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('giftcard_code', $gccode)->addFieldToFilter('giftcard_status', 1)->getFirstItem();
459
+ $status = 2; //processing
460
+ $balgc=$balarr[$x] - $balusedarr[$x];
461
+ $cod = $row['giftcard_code'];
462
+ // -----------------------Redeeming Giftcard and updating the tables -----------------------------------
463
+ if ($cod != "") {
464
+ $transdata = array(
465
+ 'giftcard_val' => $row['giftcard_val'],
466
+ 'order_id' => $orderid,
467
+ 'giftcard_id' => $row['giftcard_id'],
468
+ 'giftcard_bal' =>$balgc,
469
+ 'giftcard_balused' => $balusedarr[$x],
470
+ 'giftcard_code' => $row['giftcard_code'],
471
+ 'giftcard_currency' => $row['giftcard_currency'],
472
+ 'customer_name' => $row['customer_name'],
473
+ 'customer_mail' => $row['customer_mail'],
474
+ 'giftcard_name' => $row['giftcard_name'],
475
+ 'created_date' => $row['created_date'],
476
+ 'expiry_date' => $row['expiry_date'],
477
+ 'transac_date' => $date,
478
+ 'giftcard_status' => $status,
479
+ 'comment' => 'Giftcard used for purchase in store'
480
+ );
481
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
482
+ try {
483
+ $insertId = $trasmodel->save()->getId();
484
+ }
485
+ catch(Exception $e) {
486
+ }
487
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
488
+ $writeConnection->query("Update kartparadigm_giftcard_giftcard set
489
+ giftcard_status=$status,giftcard_bal =$balgc, where giftcard_code='" . $cod . "'");
490
+ $writeConnection->commit();
491
+ $x++;
492
+ }
493
+ }
494
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength', Mage::app()->getStore()->getStoreId());
495
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter', Mage::app()->getStore()->getStoreId());
496
+ // ---------------------------Generating Giftcard Codes and updating in database-------------------------
497
+ foreach($ordered_items as $item) { //item detail
498
+ if ($item->getProduct()->getTypeId() === 'giftcard') {
499
+ $recipientname = '';
500
+ $recipientmail = '';
501
+ $address = '';
502
+ $deliverydate = '';
503
+ $message = '';
504
+ $sendermail = '';
505
+ $sendername = '';
506
+ if ($additionalOptions = $item->getOptionByCode('additional_options')) {
507
+ $options = $item->getProductOptions();
508
+ $options['additional_options'] = unserialize($additionalOptions->getValue());
509
+ if (count($options['additional_options'] > 0)) {
510
+ if ($options['additional_options'][1]['value'] != '') {
511
+ $i = 0;
512
+ if ($options['additional_options'][0]['label'] == 'Template') $template = $options['additional_options'][$i++]['value'];
513
+ $sendername = $options['additional_options'][$i++]['value'];
514
+ $recipientname = $options['additional_options'][$i++]['value'];
515
+ $recipientmail = $options['additional_options'][$i++]['value'];
516
+ $message = $options['additional_options'][$i++]['value'];
517
+ $deliverydate = $options['additional_options'][$i++]['value'];
518
+ if ($options['additional_options'][$i++]['value'] != "") $address = $options['additional_options'][$i++]['value'];
519
+ $exdate = date('M-d-Y', strtotime($deliverydate . " +$expireafter days"));
520
+ }
521
+ }
522
+ }
523
+ $sendermail = $order->getCustomerEmail();
524
+ if (empty($recipientname)) {
525
+ $deliverydate = $date;
526
+ $sendername = $order->getCustomerName();
527
+ $template = $options['additional_options'][0]['value'];
528
+ $recipientname = $sendername;
529
+ $recipientmail = $sendermail;
530
+ }
531
+ $itemcount = $item->getQty();
532
+ $codes = Mage::registry($item->getId());
533
+ Mage::unregister($item->getId());
534
+ $codes = explode(",", $codes);
535
+ for ($i = 0; $i < $itemcount; $i++) {
536
+ $currencycode = Mage::app()->getStore()->getCurrentCurrencyCode();
537
+ $code = $codes[$i];
538
+ $amount = $item->getPrice(); // discount amount
539
+ // getting giftcard value
540
+ $gcvalue = Mage::getModel('catalog/product')->load($item->getProductId())->getGiftcardValue();
541
+ if ($gcvalue > $amount) $bal = $gcvalue;
542
+ else $bal = $amount;
543
+ $proid = $item->getProductId();
544
+ $itemname = $item->getName();
545
+ $comment = 'Giftcard Order Placed By ' . $order->getCustomerName();
546
+ $customername = $order->getCustomerName();
547
+ $data = array(
548
+ 'giftcard_val' => $bal,
549
+ 'order_id' => $orderid,
550
+ 'giftcard_bal' => $bal,
551
+ 'giftcard_code' => $code,
552
+ 'giftcard_currency' => $currencycode,
553
+ 'customer_name' => $sendername,
554
+ 'customer_mail' => $sendermail,
555
+ 'gcpro_id' => $proid,
556
+ 'giftcard_name' => $item->getName() ,
557
+ 'created_date' => $date,
558
+ 'expiry_date' => $exdate,
559
+ 'giftcard_status' => 0,
560
+ 'store_id' => Mage::app()->getStore()->getStoreId() ,
561
+ 'added_by' => $customername,
562
+ 'receiver_name' => $recipientname,
563
+ 'receiver_mail' => $recipientmail,
564
+ 'giftcard_address' => $address,
565
+ 'giftcard_msg' => $message,
566
+ 'delivery_date' => $deliverydate,
567
+ 'is_notified' => 0,
568
+ 'template_name' => $template
569
+ );
570
+ $model = Mage::getModel('kartparadigm_giftcard/giftcard')->setData($data);
571
+ try {
572
+ $insertId = $model->save()->getId();
573
+ // inserting in to trans table
574
+ $transdata = array(
575
+ 'giftcard_val' => $bal,
576
+ 'giftcard_id' => $insertId,
577
+ 'order_id' => $orderid,
578
+ 'giftcard_bal' => $bal,
579
+ 'giftcard_balused' => 0,
580
+ 'giftcard_code' => $code,
581
+ 'giftcard_currency' => $currencycode,
582
+ 'customer_name' => $recipientname,
583
+ 'customer_mail' => $recipientmail,
584
+ 'giftcard_name' => $item->getName() ,
585
+ 'created_date' => $date,
586
+ 'expiry_date' => $exdate,
587
+ 'transac_date' => $date,
588
+ 'giftcard_status' => 0,
589
+ 'comment' => $comment
590
+ );
591
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
592
+ $trasmodel->save();
593
+ }
594
+ catch(Exception $e) {
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ }
601
+
app/code/community/Kartparadigm/Giftcard/Model/Product/Type.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Product_Type
4
+ extends Mage_Catalog_Model_Product_Type_Abstract
5
+ {
6
+
7
+ public function isVirtual($product = null)
8
+ {
9
+ if (is_null($product)) {
10
+ $product = $this->getProduct();
11
+ }
12
+ $item = Mage::getModel('checkout/session')->getQuote()->getItemByProduct($product);
13
+ if (!$item) {
14
+ return false;
15
+ }
16
+
17
+ $_product = Mage::getModel('catalog/product')->load($item->getProductId());
18
+ $attributeValue = $_product->getAttributeText('giftcard_type');
19
+
20
+ if($item->getProductType()=='giftcard' && ($attributeValue=='Physical Giftcard' || $attributeValue=='Mixed Giftcard'))
21
+ return false;
22
+ else
23
+ return true;
24
+ }
25
+
26
+
27
+ }
28
+
app/code/community/Kartparadigm/Giftcard/Model/Product/Type.php~ ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Product_Type
4
+ extends Mage_Catalog_Model_Product_Type_Abstract
5
+ {
6
+
7
+ public function isVirtual($product = null)
8
+ {
9
+ if (is_null($product)) {
10
+ $product = $this->getProduct();
11
+ }
12
+ $item = Mage::getModel('checkout/session')->getQuote()->getItemByProduct($product);
13
+ if (!$item) {
14
+ return false;
15
+ }
16
+
17
+ $_product = Mage::getModel('catalog/product')->load($item->getProductId());
18
+ $attributeValue = $_product->getAttributeText('giftcard_type');
19
+
20
+ if($item->getProductType()=='giftcard' && ($attributeValue=='Physical Giftcard' || $attributeValue=='Mixed Giftcard'))
21
+ return false;
22
+ else
23
+ return true;
24
+ }
25
+
26
+
27
+ }
28
+
app/code/community/Kartparadigm/Giftcard/Model/Quote.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Quote extends Mage_Sales_Model_Quote
4
+ {
5
+ public function isVirtual()
6
+ {
7
+ }
8
+
9
+ public function merge(Mage_Sales_Model_Quote $quote)
10
+ {
11
+ parent::merge($quote);
12
+ if ($quote->getGiftcardCode()) {
13
+ $this->setGiftcardCode($quote->getGiftcardCode());
14
+ }
15
+ return $this;
16
+ }
17
+ }
app/code/community/Kartparadigm/Giftcard/Model/Quote/Payment.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Quote_Payment extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+ protected $_code = 'kartparadigm_giftcard';
6
+ protected $_formBlockType = 'kartparadigm_giftcard/payment_form';
7
+ protected $_infoBlockType = 'kartparadigm_giftcard/payment_info';
8
+ protected $_canUseInternal = false;
9
+
10
+ public function isAvailable($quote=null)
11
+ {
12
+
13
+ return $quote->getGiftcardCode()&&($quote->getGrandTotal()==$quote->getGiftcardBalused());
14
+
15
+ }
16
+ }
app/code/community/Kartparadigm/Giftcard/Model/Quote/Payment.php~ ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Quote_Payment extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+ protected $_code = 'kartparadigm_giftcard';
6
+ protected $_formBlockType = 'kartparadigm_giftcard/payment_form';
7
+ protected $_infoBlockType = 'kartparadigm_giftcard/payment_info';
8
+ protected $_canUseInternal = false;
9
+
10
+ public function isAvailable($quote=null)
11
+ {
12
+
13
+ return $quote->getGiftcardCode()&&($quote->getGrandTotal()==$quote->getGiftcardBalused());
14
+
15
+ }
16
+ }
app/code/community/Kartparadigm/Giftcard/Model/Quote/Total.php~ ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kartparadigm_Giftcard_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->setCode('giftcard');
8
+ }
9
+ public function collect(Mage_Sales_Model_Quote_Address $address)
10
+ {
11
+ parent::collect($address);
12
+ $address->setGiftcertAmount(0);
13
+ $address->setBaseGiftcertAmount(0);
14
+ $quote = $address->getQuote();
15
+ $cardCode = $quote->getGiftcardCode();
16
+ if($cardCode != "")
17
+ {
18
+
19
+ $card = Mage::getModel('kartparadigm_giftcard/giftcard')->load($cardCode, 'giftcard_code');
20
+
21
+
22
+ $totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
23
+ $baseTotal = $totals["subtotal"]->getValue();
24
+ $totalBaseAmount=0;
25
+ $address->setGiftcertAmount($card->getGiftcardBal());
26
+ $address->setBaseGiftcertAmount($card->getGiftcardBal());
27
+ Mage::log($card->getGiftcardBal().','.$card->getGiftcardVal().','.$baseTotal);
28
+ if($baseTotal >$card->getGiftcardBal())
29
+ $bal=0;
30
+ $baseAmount = min($card->getGiftcardBal(), $baseTotal);
31
+ $totalBaseAmount += $baseAmount;
32
+ $baseTotal -= $baseAmount;
33
+
34
+ $cart_amount = $totals["subtotal"]->getValue();
35
+ $gcbal = $card->getGiftcardBal();
36
+ if($gcbal>$cart_amount)
37
+ {
38
+ $balance = $gcbal - $cart_amount;
39
+ $gcbal=$balance;
40
+ }
41
+ else
42
+ {
43
+ $balance = $cart_amount-$gcbal;
44
+ $gcbal=0;
45
+ }
46
+
47
+ Mage::log($address->getGiftcertAmount());
48
+ $address->setBaseGrandTotal($baseTotal);
49
+ $address->setGrandTotal($baseTotal);
50
+
51
+ }
52
+ return $this;
53
+ }
54
+
55
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
56
+ {
57
+ $amount = $address->getGiftcardAmount();
58
+ if ($amount!=0) {
59
+ $quote = $address->getQuote();
60
+ $address->addTotal(array(
61
+ 'code' => $this->getCode(),
62
+ 'title' => 'Gift Cards',
63
+ 'value' => $amount,
64
+ 'giftcert_code' => $quote->getGiftcardCode(),
65
+ 'base_balances' => 100,
66
+ 'balances' =>100,
67
+ ));
68
+ }
69
+ return $this;
70
+ }
71
+ }
app/code/community/Kartparadigm/Giftcard/Model/Resource/Setup.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Resource_Setup extends
3
+ Mage_Core_Model_Resource_Setup
4
+ {
5
+ }
app/code/community/Kartparadigm/Giftcard/Model/Resource/Setup.php~ ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Model_Resource_Setup extends
3
+ Mage_Core_Model_Resource_Setup
4
+ {
5
+ }
app/code/community/Kartparadigm/Giftcard/controllers/Adminhtml/GiftcardController.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Adminhtml_GiftcardController extends Mage_Adminhtml_Controller_Action
3
+
4
+ {
5
+ // -------------------------listing all generated giftcard records--------------------------------------------
6
+ public function indexAction()
7
+
8
+ {
9
+ $this->loadLayout();
10
+ $this->renderLayout();
11
+ return $this;
12
+ }
13
+ // ----------------------------------------View / Print Giftcards option ------------------------
14
+ public function viewAction()
15
+
16
+ {
17
+ $id = $this->getRequest()->getParam('id', null);
18
+ $arr = array();
19
+ $col = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('giftcard_id', $id)->getFirstItem();
20
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name', $col['template_name'])->getFirstItem();
21
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
22
+ Mage::log("Pro Id : ".$col['gcpro_id']);
23
+ if ($row['template_img'] != '')
24
+ $imgpath = $mediapath . $row['template_img'];
25
+ else if($col['gcpro_id']!=''){
26
+ $product = Mage::getModel('catalog/product')->load($col['gcpro_id']);
27
+ try{
28
+ $imgpath = Mage::helper('catalog/image')->init($product, 'thumbnail');
29
+ }
30
+ catch(Exception $e) {
31
+ $imgpath = $mediapath."giftcard/greet.jpg";
32
+ }
33
+ $row['theme_color'] = "00AF00";
34
+ $row['text_color'] = "FF0000";
35
+ }
36
+ else {
37
+ $imgpath = $mediapath."giftcard/greet.jpg";
38
+ $row['theme_color'] = "00AF00";
39
+ $row['text_color'] = "FF0000";
40
+ }
41
+ $barcode = $mediapath . "giftcard/bar.gif";
42
+ $arr['customername'] = $col['customer_name'];
43
+ $arr['giftcardname'] = $col['giftcard_name'];
44
+ $arr['giftcardval'] = Mage::helper('core')->currency($col['giftcard_val']);
45
+ $arr['giftcardcode'] = $col['giftcard_code'];
46
+ $arr['templateimg'] = $imgpath;
47
+ $arr['themecolor'] = "#" . $row['theme_color'];
48
+ $arr['textcolor'] = "#" . $row['text_color'];
49
+ $arr['receivername'] = $col['receiver_name'];
50
+ $arr['gcnote'] = $row['giftcard_note'];
51
+ $arr['gcmsg'] = $col['giftcard_msg'];
52
+ $arr['barcode'] = $barcode;
53
+ $this->loadLayout();
54
+ Mage::register("tempvariables", $arr);
55
+ $this->renderLayout();
56
+ return $this;
57
+ }
58
+ // -------------------------------Send giftcards to groups form load action--------------------------------
59
+ public function groupsendAction()
60
+
61
+ {
62
+ $this->loadLayout();
63
+ $this->renderLayout();
64
+ }
65
+ // ----------------------------------Sending giftcards send action by admin--------------------------------
66
+ public function sendAction()
67
+
68
+ {
69
+ $data = $this->getRequest()->getParams();
70
+ $templateid = Mage::getStoreConfig('affiliateproduct/giftcard/admin_giftcard_template');
71
+ $emailTemplate = Mage::getModel('core/email_template');
72
+ if (!is_numeric($templateid)) {
73
+ $emailTemplate->loadDefault('custom_email_template1');
74
+ $emailTemplate->setTemplateSubject("Giftcard From Store");
75
+ }
76
+ else {
77
+ $emailTemplate->load($templateid);
78
+ }
79
+ $type = Mage::getStoreConfig('giftcard/giftcard/giftcard_sender_email');
80
+ $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('group_id', $data['customer_groups']);
81
+ $lastorderid = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('added_by', 'Admin')->getLastItem()->getOrderId();
82
+ if ($lastorderid) $orderid = $lastorderid + 1; //admin orderid
83
+ else $orderid = 100;
84
+ foreach($customers as $customer) {
85
+ $customermail = $customer->getEmail();
86
+ $customername = $customer->getName();
87
+ $msg = $data['giftcard_msg'];
88
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
89
+ $date = $date->toString('Y-M-d H:m:s');
90
+ $exdate = $data['expiry_date'];
91
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength');
92
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter');
93
+ $code = Mage::getModel('kartparadigm_giftcard/custommethods')->generateUniqueId($codelengh - 1);
94
+ $code = $code . "A"; //admin giftcade
95
+ $code = join('-', str_split($code, $dashafter));
96
+ $data = array(
97
+ 'giftcard_val' => $data['giftcard_val'],
98
+ 'giftcard_bal' => $data['giftcard_val'],
99
+ 'giftcard_code' => $code,
100
+ 'order_id' => $orderid,
101
+ 'giftcard_currency' => $data['giftcard_currency'],
102
+ 'customer_name' => $customername,
103
+ 'customer_mail' => $customermail,
104
+ 'receiver_name' => $customername,
105
+ 'receiver_mail' => $customermail,
106
+ 'giftcard_name' => $data['giftcard_name'],
107
+ 'giftcard_msg' => $data['giftcard_msg'],
108
+ 'created_date' => $date,
109
+ 'store_id' => $data['store_id'],
110
+ 'expiry_date' => $exdate,
111
+ 'giftcard_status' => $data['giftcard_status'],
112
+ 'added_by' => 'Admin',
113
+ 'is_notified' => 1,
114
+ );
115
+ $model = Mage::getModel('kartparadigm_giftcard/giftcard')->setData($data);
116
+ $insertId = $model->save()->getId();
117
+ // inserting in to trans table
118
+ $transdata = array(
119
+ 'giftcard_val' => $data['giftcard_val'],
120
+ 'giftcard_id' => $insertId,
121
+ 'order_id' => $orderid, //
122
+ 'giftcard_bal' => $data['giftcard_val'],
123
+ 'giftcard_balused' => 0,
124
+ 'giftcard_code' => $code,
125
+ 'giftcard_currency' => $data['giftcard_currency'],
126
+ 'customer_name' => $data['receiver_name'],
127
+ 'customer_mail' => $data['receiver_mail'],
128
+ 'giftcard_name' => $data['giftcard_name'],
129
+ 'created_date' => $date,
130
+ 'transac_date' => $date,
131
+ 'store_id' => $data['store_id'],
132
+ 'expiry_date' => $exdate,
133
+ 'giftcard_status' => $data['giftcard_status'],
134
+ 'comment' => "Added By Admin"
135
+ );
136
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
137
+ $trasmodel->save();
138
+
139
+ $orderid++;
140
+ $emailTemplateVariables['customername'] = "Admin";
141
+ $emailTemplateVariables['giftcardname'] = $data['giftcard_name'];
142
+ $emailTemplateVariables['giftcardval'] = Mage::app()->getLocale()->currency($data['giftcard_currency'])->getSymbol()." ".$data['giftcard_val'];
143
+ $emailTemplateVariables['giftcardcode'] = $code;
144
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
145
+ if (strpos($mediapath, 'localhost') !== false)
146
+ $emailTemplateVariables['templateimg'] = "http://www.imagesbuddy.com/images/165/smile-greeting-card.jpg";
147
+ else
148
+ $emailTemplateVariables['templateimg'] = $mediapath . "giftcard/greet.jpg";
149
+ $emailTemplateVariables['themecolor'] = "red";
150
+ $emailTemplateVariables['textcolor'] = "green";
151
+ $emailTemplateVariables['receivername'] = $customername;
152
+ $emailTemplateVariables['custommsg'] = $msg;
153
+ $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $type . '/name'));
154
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $type . '/email'));
155
+ $emailTemplate->send($customermail, $customername, $emailTemplateVariables);
156
+ }
157
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Giftcards Sent Successfully.'));
158
+ $this->loadLayout();
159
+ $this->renderLayout();
160
+ }
161
+ // ----------------------------------------Edit giftcard record option for admin--------------------------------
162
+ public function editAction()
163
+
164
+ {
165
+ $id = $this->getRequest()->getParam('id', null);
166
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcard');
167
+ if ($id) {
168
+ $registry->load((int)$id);
169
+ if ($registry->getId()) {
170
+ $data = $registry->getData();
171
+ if ($data) {
172
+ $registry->setData($data)->setId($id);
173
+ }
174
+ }
175
+ else {
176
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('kartparadigm_giftcard')->__('The Gift Card does not exist'));
177
+ $this->_redirect('*/*/');
178
+ }
179
+ }
180
+ Mage::register('registry_data', $registry);
181
+ $this->loadLayout();
182
+ $this->renderLayout();
183
+ }
184
+ // ------------------------Save Updated/added giftcard record option for admin--------------------------------
185
+ public function saveAction()
186
+
187
+ {
188
+ if ($this->getRequest()->getPost()) {
189
+ try {
190
+ $data = $this->getRequest()->getPost();
191
+ $id = $this->getRequest()->getParam('id');
192
+ if ($data && $id) {
193
+ $registry1 = Mage::getModel('kartparadigm_giftcard/giftcard')->load($id);
194
+ $data['is_notified'] = 1;
195
+ $registry1->setData($data)->setId($id);
196
+ $registry1->save();
197
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Updated Successfully.'));
198
+ }
199
+ else {
200
+ $lastorderid = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()->addFieldToFilter('added_by', 'Admin')->getLastItem()->getOrderId();
201
+ if ($lastorderid) $orderid = $lastorderid + 1; //admin orderid
202
+ else $orderid = 100;
203
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
204
+ $date = $date->toString('Y-M-d H:m:s');
205
+ $today = new Zend_Date(Mage::getModel('core/date')->timestamp());
206
+ $expireafter = Mage::getStoreConfig('giftcard/giftcard/txt_expiry');
207
+ $exdate = $today->addDay($expireafter)->toString('Y-M-d H:m:s');
208
+ $codelengh = Mage::getStoreConfig('giftcard/giftcard/txt_clength');
209
+ $dashafter = Mage::getStoreConfig('giftcard/giftcard/txt_dashafter');
210
+ $code = Mage::getModel('kartparadigm_giftcard/custommethods')->generateUniqueId($codelengh - 1);
211
+ $code = $code . "A"; //admin giftcade
212
+ $code = join('-', str_split($code, $dashafter));
213
+ $data = array(
214
+ 'giftcard_val' => $data['giftcard_val'],
215
+ 'order_id' => $orderid, //
216
+ 'giftcard_bal' => $data['giftcard_bal'],
217
+ 'giftcard_code' => $code,
218
+ 'giftcard_currency' => $data['giftcard_currency'],
219
+ 'customer_name' => $data['customer_name'],
220
+ 'customer_mail' => $data['customer_mail'],
221
+ 'receiver_name' => $data['receiver_name'],
222
+ 'receiver_mail' => $data['receiver_mail'],
223
+ 'giftcard_name' => $data['giftcard_name'],
224
+ 'giftcard_msg' => $data['giftcard_msg'],
225
+ 'created_date' => $date,
226
+ 'store_id' => $data['store_id'],
227
+ 'expiry_date' => $exdate,
228
+ 'giftcard_status' => $data['giftcard_status'],
229
+ 'added_by' => 'Admin',
230
+ 'is_notified' => 1
231
+ );
232
+ $model = Mage::getModel('kartparadigm_giftcard/giftcard')->setData($data);
233
+ $insertId = $model->save()->getId();
234
+ // inserting in to trans table
235
+ $transdata = array(
236
+ 'giftcard_val' => $data['giftcard_val'],
237
+ 'giftcard_id' => $insertId,
238
+ 'order_id' => $orderid, //
239
+ 'giftcard_bal' => $data['giftcard_bal'],
240
+ 'giftcard_balused' => 0,
241
+ 'giftcard_code' => $code,
242
+ 'giftcard_currency' => $data['giftcard_currency'],
243
+ 'customer_name' => $data['receiver_name'],
244
+ 'customer_mail' => $data['receiver_mail'],
245
+ 'giftcard_name' => $data['giftcard_name'],
246
+ 'created_date' => $date,
247
+ 'transac_date' => $date,
248
+ 'store_id' => $data['store_id'],
249
+ 'expiry_date' => $exdate,
250
+ 'giftcard_status' => $data['giftcard_status'],
251
+ 'comment' => "Added By Admin"
252
+ );
253
+ $trasmodel = Mage::getModel('kartparadigm_giftcard/giftcardtrans')->setData($transdata);
254
+ $trasmodel->save();
255
+ // Sending Giftcard Activated Mail to Customer
256
+ $templateid = Mage::getStoreConfig('affiliateproduct/giftcard/admin_giftcard_template');
257
+ $emailTemplate = Mage::getModel('core/email_template');
258
+ if (!is_numeric($templateid)) {
259
+ $emailTemplate->loadDefault('custom_email_template1');
260
+ $emailTemplate->setTemplateSubject("Giftcard From Store");
261
+ }
262
+ else {
263
+ $emailTemplate->load($templateid);
264
+ }
265
+ $type = Mage::getStoreConfig('giftcard/giftcard/giftcard_sender_email');
266
+ // Create an array of variables to assign to template
267
+ $emailTemplateVariables['customername'] = $data['customer_name'];;
268
+ $emailTemplateVariables['giftcardname'] = $data['giftcard_name'];
269
+ $emailTemplateVariables['giftcardval'] =Mage::app()->getLocale()->currency($data['giftcard_currency'])->getSymbol()." ".$data['giftcard_val'];
270
+ $emailTemplateVariables['giftcardcode'] = $code;
271
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
272
+ if (strpos($mediapath, 'localhost') !== false) $emailTemplateVariables['templateimg'] = "http://www.imagesbuddy.com/images/165/smile-greeting-card.jpg";
273
+ else $emailTemplateVariables['templateimg'] = $mediapath . "giftcard/greet.jpg";
274
+ $emailTemplateVariables['themecolor'] = "red";
275
+ $emailTemplateVariables['textcolor'] = "green";
276
+ $emailTemplateVariables['receivername'] = $data['receiver_name'];
277
+ $emailTemplateVariables['custommsg'] = $data['giftcard_msg'];
278
+ $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $type . '/name'));
279
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $type . '/email'));
280
+ $emailTemplate->send($data['receiver_mail'], $data['receiver_name'], $emailTemplateVariables);
281
+ Mage::getSingleton('core/session')->addSuccess("Giftcard Added Succussfully");
282
+ }
283
+ $this->_redirect('*/*/', array(
284
+ 'id' => $this->getRequest()->getParam('gifcard_id')
285
+ ));
286
+ }
287
+ catch(Exception $e) {
288
+ $this->_getSession()->addError(Mage::helper('kartparadigm_giftcard')->__('An error occurred while saving the Giftcard. Please review the log and try again.'));
289
+ $this->_redirect('*/*/', array(
290
+ 'id' => $this->getRequest()->getParam('giftcard_id')
291
+ ));
292
+ return $this;
293
+ }
294
+ }
295
+ }
296
+ // ----------------------------------------Add New Giftcard Option For admin--------------------------------
297
+ public function newAction()
298
+
299
+ {
300
+ $this->_redirect('*/*/edit');
301
+ }
302
+ // ----------------------------------------Delete giftcard option for admin--------------------------------
303
+ public function deleteAction()
304
+
305
+ {
306
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcard');
307
+ $registryId = $this->getRequest()->getParam('id', null);
308
+ try {
309
+ $registry->load($registryId)->delete();
310
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Giftcard deleted Successfully.'));
311
+ }
312
+ catch(Exception $e) {
313
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
314
+ }
315
+ $this->_redirect('*/*/index');
316
+ }
317
+ // --------------------------------------------Giftcards Mass Delete Option-------------------------------------
318
+ public function massDeleteAction()
319
+
320
+ {
321
+ $registryIds = $this->getRequest()->getParam('registries');
322
+ if (!is_array($registryIds)) {
323
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('kartparadigm_giftcard')->__('Please selectone or more giftcards.'));
324
+ }
325
+ else {
326
+ try {
327
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcard');
328
+ foreach($registryIds as $registryId) {
329
+ $registry->load($registryId)->delete();
330
+ }
331
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were deleted.', count($registryIds)));
332
+ }
333
+ catch(Exception $e) {
334
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
335
+ }
336
+ }
337
+ $this->_redirect('*/*/index');
338
+ }
339
+ }
340
+
app/code/community/Kartparadigm/Giftcard/controllers/Adminhtml/TemplateController.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_Adminhtml_TemplateController extends Mage_Adminhtml_Controller_Action
3
+
4
+ {
5
+
6
+ //-------------------------listing all generated template records--------------------------------------------
7
+ public function indexAction()
8
+
9
+ {
10
+ $this->loadLayout();
11
+ $this->renderLayout();
12
+ return $this;
13
+ }
14
+
15
+ //----------------------------------------View / Print Template option ------------------------
16
+ public function viewAction()
17
+
18
+ {
19
+ $id = $this->getRequest()->getParam('id', null);
20
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('giftcardtemplate_id', $id)->getFirstItem();
21
+ $mediapath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
22
+ if ($row['template_img'] != '')
23
+ $imgpath = $mediapath . $row['template_img'];
24
+ else $imgpath = "http://www.imagesbuddy.com/images/165/smile-greeting-card.jpg";
25
+ $barcode = $mediapath . "giftcard/bar.gif";
26
+ $arr['customername'] = "From Name";
27
+ $arr['giftcardname'] = "Giftcard Name";
28
+ $arr['giftcardval'] = "$ 500";
29
+ $arr['giftcardcode'] = "XXXX-XXXX-XXXX";
30
+ $arr['templateimg'] = $imgpath;
31
+ $arr['themecolor'] = "#" . $row['theme_color'];
32
+ $arr['textcolor'] = "#" . $row['text_color'];
33
+ $arr['receivername'] = "Receiver Name";
34
+ $arr['gcnote'] = $row['giftcard_note'];
35
+ $arr['gcmsg'] = "Giftcard Message By Sender :)";
36
+ $arr['barcode'] = $barcode;
37
+ $this->loadLayout();
38
+ Mage::register("tempvariables", $arr);
39
+ $this->renderLayout();
40
+ return $this;
41
+ }
42
+
43
+ //----------------------------------------Edit Template option ------------------------
44
+ public function editAction()
45
+
46
+ {
47
+ $id = $this->getRequest()->getParam('id', null);
48
+
49
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcardtemplate');
50
+ if ($id) {
51
+ $registry->load((int)$id);
52
+ if ($registry->getId()) {
53
+ $data = $registry->getData();
54
+ if ($data) {
55
+ $registry->setData($data)->setId($id);
56
+ }
57
+ }
58
+ else {
59
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('kartparadigm_giftcard')
60
+ ->__('The Giftcard Template does not exist'));
61
+ $this->_redirect('*/*/index');
62
+ }
63
+ }
64
+ Mage::register('templates_data', $registry);
65
+ $this->loadLayout();
66
+ // $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
67
+ $this->renderLayout();
68
+ }
69
+
70
+ //---------------------------------------Save Template action-----------------------------------
71
+ public function saveAction()
72
+
73
+ {
74
+
75
+ if ($this->getRequest()->getPost()) {
76
+
77
+ try {
78
+ $data = $this->getRequest()->getPost();
79
+ $id = $this->getRequest()->getParam('id');
80
+ if ($data && $id) {
81
+ $registry1 = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->load($id);
82
+ $fileName = '';
83
+ $tempfileName = '';
84
+
85
+ if (isset($_FILES['template_img']['name']) && $_FILES['template_img']['name'] != '' && ($_FILES["template_img"]["size"] < 2000000)) {
86
+ try {
87
+ $tempfileName = $_FILES['background_img']['name'];
88
+ $timestamp = time();
89
+ $tempfileExt = strtolower(substr(strrchr($tempfileName, ".") , 1));
90
+ $tempfileNamewoe = rtrim($tempfileName, $tempfileExt);
91
+ $tempfileName = $timestamp .".". $tempfileExt;
92
+ $uploader1 = new Varien_File_Uploader('template_img');
93
+ $uploader1->setAllowRenameFiles(false);
94
+ $uploader1->setFilesDispersion(false);
95
+ $path = Mage::getBaseDir('media') . DS . 'giftcard';
96
+ if (!is_dir($path)) {
97
+ mkdir($path, 0777, true);
98
+ }
99
+ $uploader1->save($path . DS, $tempfileName);
100
+
101
+ }
102
+ catch(Exception $e) {
103
+ echo $e->getMessage();
104
+ }
105
+ }
106
+ else {
107
+ }
108
+ if ($tempfileName != '') {
109
+ $data['template_img'] = 'giftcard/' . $tempfileName;
110
+ unlink(Mage::getBaseDir('media') . DS . $registry1->getTemplateImg());
111
+ }
112
+ else {
113
+ $data['template_img'] = $registry1->getTemplateImg();
114
+ }
115
+
116
+ $registry1->setData($data)->setId($id);
117
+ $registry1->save();
118
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')
119
+ ->__('Updated Successfully.'));
120
+ }
121
+ else {
122
+
123
+ if (isset($_FILES['template_img']['name']) && $_FILES['template_img']['name'] != '' && ($_FILES["template_img"]["size"] < 2000000)) {
124
+ try {
125
+ $tempfileName = $_FILES['template_img']['name'];
126
+ $tempfileExt = strtolower(substr(strrchr($tempfileName, ".") , 1));
127
+ $tempfileNamewoe = rtrim($tempfileName, $tempfileExt);
128
+ $timestamp = time();
129
+ $tempfileName = $timestamp .".". $tempfileExt;
130
+ $uploader1 = new Varien_File_Uploader('template_img');
131
+ $uploader1->setAllowRenameFiles(false);
132
+ $uploader1->setFilesDispersion(false);
133
+ $path = Mage::getBaseDir('media') . DS . 'giftcard';
134
+ if (!is_dir($path)) {
135
+ mkdir($path, 0777, true);
136
+ }
137
+ $uploader1->save($path . DS, $tempfileName);
138
+
139
+ }
140
+ catch(Exception $e) {
141
+ echo $e->getMessage();
142
+ }
143
+ }
144
+ else {
145
+ // $this->_getSession()->addError(Mage::helper('kartparadigm_giftcard')
146
+ //->__('Error in File Upload.'));
147
+ }
148
+ $data = array(
149
+ 'template_name' => $data['template_name'],
150
+
151
+ 'theme_color' => $data['theme_color'], //
152
+ 'text_color' => $data['text_color'],
153
+
154
+ 'template_img' => 'giftcard/' . $tempfileName,
155
+ 'giftcard_note' => $data['giftcard_note'],
156
+
157
+ );
158
+
159
+ $model = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->setData($data);
160
+ $insertId = $model->save()->getId();
161
+ $arg_attribute = 'giftcard_template';
162
+ $arg_value = $data['template_name'];
163
+ $attr_model = Mage::getModel('catalog/resource_eav_attribute');
164
+ $attr = $attr_model->loadByCode('catalog_product', $arg_attribute);
165
+ $attr_id = $attr->getAttributeId();
166
+ $option['attribute_id'] = $attr_id;
167
+ $option['value']['giftcard_template'][0] = $arg_value;
168
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
169
+ $setup->addAttributeOption($option);
170
+
171
+ Mage::getSingleton('core/session')->addSuccess("Template Added Succussfully");
172
+ }
173
+ $this->_redirect('*/*/', array(
174
+ 'id' => $this->getRequest()->getParam('gifcardtemplate_id')
175
+ ));
176
+ }
177
+ catch(Exception $e) {
178
+ $this->_getSession()->addError(Mage::helper('kartparadigm_giftcard')
179
+ ->__('An error occurred while saving the Template. Please review the log and try again.'));
180
+ Mage::logException($e);
181
+ $this->_redirect('*/*/', array(
182
+ 'id' => $this->getRequest()->getParam('giftcardtemplate_id')
183
+ ));
184
+ return $this;
185
+ }
186
+ }
187
+ }
188
+
189
+ //--------------------------------------Add New Template Action-------------------------------------
190
+ public function newAction()
191
+
192
+ {
193
+ $this->_redirect('*/*/edit');
194
+ }
195
+
196
+ //-------------------------------------Delete Template Action--------------------------------------------
197
+ public function deleteAction()
198
+
199
+ {
200
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcardtemplate');
201
+ $registryId = $this->getRequest()->getParam('id', null);
202
+ try {
203
+ $registry->load($registryId)->delete();
204
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Template deleted Successfully.'));
205
+ }
206
+ catch(Exception $e) {
207
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
208
+ }
209
+ $this->_redirect('*/*/index');
210
+ }
211
+
212
+ //------------------------------------------Mass delete template action------------------------------
213
+ public function massDeleteAction()
214
+
215
+ {
216
+ $registryIds = $this->getRequest()->getParam('templates');
217
+ if (!is_array($registryIds)) {
218
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('kartparadigm_giftcard')->__('Please selectone or more giftcards.'));
219
+ }
220
+ else {
221
+ try {
222
+ $registry = Mage::getModel('kartparadigm_giftcard/giftcardtemplate');
223
+ foreach($registryIds as $registryId) {
224
+ $registry->load($registryId)->delete();
225
+ }
226
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were deleted.', count($registryIds)));
227
+ }
228
+ catch(Exception $e) {
229
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
230
+ }
231
+ }
232
+ $this->_redirect('*/*/index');
233
+ }
234
+ }
235
+
app/code/community/Kartparadigm/Giftcard/controllers/CustomerController.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_CustomerController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ // to authenticate only logged in users
6
+ public function preDispatch()
7
+ {
8
+ parent::preDispatch();
9
+ $action = $this->getRequest()->getActionName();
10
+ $loginUrl = Mage::helper('customer')->getLoginUrl();
11
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
12
+ $writeConnection->query("update `kartparadigm_giftcard_giftcard` set giftcard_status=4
13
+ WHERE expiry_date <= CURDATE();");
14
+ $writeConnection->commit();
15
+ if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
16
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
17
+ }
18
+ }
19
+ public function balanceAction()
20
+ {
21
+ $handles = array('default');
22
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
23
+ $handles[] = 'customer_account';// setting the handle for same layout
24
+ }
25
+
26
+ $this->loadLayout($handles);
27
+ $this->renderLayout();
28
+ }
29
+
30
+
31
+ public function viewAction()
32
+ {
33
+ $id = $this->getRequest()->getParam('id');
34
+ $handles = array('default');
35
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
36
+ $handles[] = 'customer_account';// setting the handle for same layout
37
+ }
38
+ $this->loadLayout($handles);
39
+ $this->renderLayout();
40
+ }
41
+
42
+ public function shareviewAction()
43
+ {
44
+
45
+ $handles = array('default');
46
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
47
+ $handles[] = 'customer_account';// setting the handle for same layout
48
+ }
49
+ $this->loadLayout($handles);
50
+ $this->renderLayout();
51
+ }
52
+
53
+
54
+ public function shareAction()
55
+ {
56
+ $data = $this->getRequest()->getParams();
57
+ Mage::log($data,null,'logfile.log');
58
+ $handles = array('default');
59
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
60
+ $handles[] = 'customer_account';// setting the handle for same layout
61
+ $gcrecord=Mage::getModel('kartparadigm_giftcard/giftcard')->load($data['gcid']);
62
+ $gcrecord->setReceiverMail($data['Sharingmail']);
63
+ try{
64
+ $gcrecord->save();
65
+ Mage::getSingleton('core/session')->addSuccess("Giftcard Shared Succussfully");
66
+ }
67
+ catch(exception $e)
68
+ {
69
+ Mage::getSingleton('core/session')->addFailure("Problem In Sharing Giftcard");
70
+ }
71
+
72
+ }
73
+ $this->loadLayout($handles);
74
+ $this->renderLayout();
75
+ }
76
+
77
+
78
+ }
app/code/community/Kartparadigm/Giftcard/controllers/IndexController.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kartparadigm_Giftcard_IndexController extends Mage_Core_Controller_Front_Action
3
+
4
+ {
5
+ public function indexAction()
6
+
7
+ {
8
+ $data = $this->getRequest()->getParams();
9
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
10
+ $customermail = Mage::getSingleton('customer/session')->getCustomer()->getEmail(); //checkout customer
11
+ $collection = Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()
12
+ ->addFieldToFilter('giftcard_code', $data['gc_code'])->getFirstItem();
13
+ $hasgiftcards = Mage::getModel('kartparadigm_giftcard/custommethods')->checkCartitems();
14
+ $storeid = Mage::app()->getStore()->getStoreId();
15
+ $canothersbuy = Mage::getStoreConfig('giftcard/giftcard/othersbuy_select', $storeid);
16
+
17
+ $canbuygiftcards = Mage::getStoreConfig('giftcard/giftcard/giftcardbuy_select', $storeid);
18
+
19
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp());
20
+ $today = $date->toString('Y-M-d H:m:s'); // present date
21
+ $expireday = $collection['expiry_date'];
22
+ if (Mage::getStoreConfig('giftcard/giftcard/suborgrand_select', Mage::app()->getStore()->getStoreId()))
23
+ $total = $quote->getGrandTotal(); //apply gc to grandtotal
24
+ else $total = $quote->getSubtotal(); //apply gc to subtotal
25
+ $damt = $quote->getGiftcardBalused();
26
+ $damtarr = explode(",", $damt);
27
+ $disamt = array_sum(explode(",", $damt));
28
+ $codesstring=$quote->getGiftcardCode();
29
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
30
+ $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
31
+
32
+ $giftbal=Mage::helper('directory')->currencyConvert($collection['giftcard_bal'],$baseCurrencyCode,$currentCurrencyCode);
33
+
34
+ if($total<=$disamt)
35
+ {
36
+ Mage::getSingleton('core/session')->addNotice("Giftcard cannot be applied to '0' total");
37
+ $this->_redirect('checkout/cart/');
38
+ }
39
+ else if (strpos($codesstring, $data['gc_code']) !== false) {
40
+ Mage::getSingleton('core/session')->addNotice("Giftcard already applied to cart");
41
+ $this->_redirect('checkout/cart/');
42
+ }
43
+ else if ($collection['giftcard_status'] == 2) {
44
+ Mage::getSingleton('core/session')->addNotice("Giftcard in processing stage");
45
+ $this->_redirect('checkout/cart/');
46
+ }
47
+ else if ($collection['giftcard_status'] == 3) {
48
+ Mage::getSingleton('core/session')->addError("Giftcard Redeemed");
49
+ $this->_redirect('checkout/cart/');
50
+ }
51
+ else if (strtotime($expireday) < strtotime($today)) {
52
+ Mage::getSingleton('core/session')->addError("Gift Card Code Expired");
53
+ $this->_redirect('checkout/cart/');
54
+ }
55
+ else if ($hasgiftcards && !$canbuygiftcards) {
56
+ Mage::getSingleton('core/session')->addError("Gift Card codes are not allowed to buy giftcards");
57
+ $this->_redirect('checkout/cart/');
58
+ }
59
+ else if (!$canothersbuy && ($customermail!=$collection['receiver_mail'])) {
60
+ Mage::getSingleton('core/session')->addError("Only Giftcard Customer Can Use The Code");
61
+ $this->_redirect('checkout/cart/');
62
+ }
63
+ else {
64
+ if (isset($giftbal)) {
65
+
66
+ // checking giftcard redeem amount isset or apply total giftcard amount
67
+ if (isset($data['redeem_amt']) && ($data['redeem_amt'] > 0) && ($data['redeem_amt'] <= $giftbal)) $amt = $data['redeem_amt'];
68
+ else $amt = $giftbal;
69
+ // checking redeem amount with balance amount in giftcard
70
+ if ($data['redeem_amt'] > $giftbal) {
71
+ Mage::getSingleton('core/session')->addError("Insufficient Giftcard Amount. Your Gift Card '" . $data['gc_code'] . "' balance amount is '" . Mage::getModel('kartparadigm_giftcard/custommethods')
72
+ ->getBalance($amt, $collection['giftcard_currency']) . "'");
73
+ }
74
+ else {
75
+
76
+ if (($quote->getGiftcardCode()) != '') {
77
+ $quote->setGiftcardCode($quote->getGiftcardCode() . "," . $data['gc_code']);
78
+ $quote->setGiftcardBal($quote->getGiftcardBal() . "," . $giftbal);
79
+
80
+ $quote->setGiftcardBalused($quote->getGiftcardBalused() . "," . $amt);
81
+ }
82
+ else {
83
+ $quote->setGiftcardCode($data['gc_code']);
84
+ $quote->setGiftcardBal($giftbal);
85
+
86
+ $quote->setGiftcardBalused($amt);
87
+ }
88
+ $quote->save();
89
+ $bal = Mage::getModel('kartparadigm_giftcard/custommethods')
90
+ ->getBalance($amt, $collection['giftcard_currency']);
91
+ Mage::getSingleton('core/session')
92
+ ->addSuccess("Gift voucher '" . $data['gc_code'] . "' was applied with amount '" . $bal . "' to your order");
93
+ }
94
+ }
95
+
96
+ else {
97
+ Mage::getSingleton('core/session')
98
+ ->addError("Gift voucher '" . $data['gc_code'] . "' applied is not valid");
99
+ }
100
+ $this->_redirect('checkout/cart/');
101
+ }
102
+ }
103
+ public function cancelAction()
104
+
105
+ {
106
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
107
+ $quote->setGiftcardCode('');
108
+ $quote->setGiftcardBal(0);
109
+ $quote->setGiftcardBalused(0);
110
+ $quote->setGiftcardNewbal(0);
111
+ $quote->save();
112
+ Mage::getSingleton('core/session')->addNotice("Gift voucher removed from your order");
113
+ $this->_redirect('checkout/cart/');
114
+ }
115
+ }
116
+
app/code/community/Kartparadigm/Giftcard/etc/adminhtml.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <reference name="head">
4
+ <action method="addJs">
5
+ <file>jscolor/jscolor.js</file>
6
+ </action>
7
+ </reference>
8
+ <menu>
9
+
10
+
11
+
12
+ <kartparadigm_giftcard module="kartparadigm_giftcard">
13
+ <title>Gift Cards</title>
14
+ <sort_order>71</sort_order>
15
+ <children>
16
+ <managegiftcards module="kartparadigm_giftcard">
17
+ <title>Manage GiftCards</title>
18
+ <sort_order>0</sort_order>
19
+ <action>adminhtml/giftcard/index</action>
20
+ </managegiftcards>
21
+ <managetemplates module="kartparadigm_giftcard">
22
+ <title>Manage Templates</title>
23
+ <sort_order>1</sort_order>
24
+ <action>adminhtml/template/index</action>
25
+ </managetemplates>
26
+ <sendgroupgcs module="kartparadigm_giftcard">
27
+ <title>Send Giftcard To Groups</title>
28
+ <sort_order>3</sort_order>
29
+ <action>adminhtml/giftcard/groupsend</action>
30
+ </sendgroupgcs>
31
+ <giftcardsettings module="kartparadigm_giftcard">
32
+ <title>Giftcard Settings</title>
33
+ <sort_order>4</sort_order>
34
+ <action>adminhtml/system_config/edit/section/giftcard</action>
35
+ </giftcardsettings>
36
+
37
+ </children>
38
+ </kartparadigm_giftcard>
39
+ </menu>
40
+ <acl> remove from bottom and uncomment this
41
+ <resources>
42
+ <admin>
43
+ <children>
44
+ <giftcard translate="title" module="kartparadigm_giftcard">
45
+ <title>Gift Cards</title>
46
+ <sort_order>300</sort_order>
47
+ <children>
48
+ <items translate="title" module="kartparadigm_giftcard">
49
+ <title>Manage GiftCards</title>
50
+ <sort_order>0</sort_order>
51
+ </items>
52
+ </children>
53
+ </giftcard>
54
+
55
+ <system>
56
+ <children>
57
+ <config>
58
+ <children>
59
+ <giftcard>
60
+ <title>Giftcard Settings</title> <!-- Used in resources tree -->
61
+ </giftcard>
62
+ </children>
63
+ </config>
64
+ </children>
65
+ </system>
66
+ </children>
67
+ </admin>
68
+ </resources>
69
+ </acl>
70
+
71
+ </config>
72
+
app/code/community/Kartparadigm/Giftcard/etc/adminhtml.xml~ ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <reference name="head">
4
+ <action method="addJs">
5
+ <file>jscolor/jscolor.js</file>
6
+ </action>
7
+ </reference>
8
+ <menu>
9
+
10
+
11
+
12
+ <kartparadigm_giftcard module="kartparadigm_giftcard">
13
+ <title>Gift Cards</title>
14
+ <sort_order>71</sort_order>
15
+ <children>
16
+ <managegiftcards module="kartparadigm_giftcard">
17
+ <title>Manage GiftCards</title>
18
+ <sort_order>0</sort_order>
19
+ <action>adminhtml/giftcard/index</action>
20
+ </managegiftcards>
21
+ <managetemplates module="kartparadigm_giftcard">
22
+ <title>Manage Templates</title>
23
+ <sort_order>1</sort_order>
24
+ <action>adminhtml/template/index</action>
25
+ </managetemplates>
26
+ <sendgroupgcs module="kartparadigm_giftcard">
27
+ <title>Send Giftcard To Groups</title>
28
+ <sort_order>3</sort_order>
29
+ <action>adminhtml/giftcard/groupsend</action>
30
+ </sendgroupgcs>
31
+ <giftcardsettings module="kartparadigm_giftcard">
32
+ <title>Giftcard Settings</title>
33
+ <sort_order>4</sort_order>
34
+ <action>adminhtml/system_config/edit/section/giftcard</action>
35
+ </giftcardsettings>
36
+
37
+ </children>
38
+ </kartparadigm_giftcard>
39
+ </menu>
40
+ <acl> remove from bottom and uncomment this
41
+ <resources>
42
+ <admin>
43
+ <children>
44
+ <giftcard translate="title" module="kartparadigm_giftcard">
45
+ <title>Gift Cards</title>
46
+ <sort_order>300</sort_order>
47
+ <children>
48
+ <items translate="title" module="kartparadigm_giftcard">
49
+ <title>Manage GiftCards</title>
50
+ <sort_order>0</sort_order>
51
+ </items>
52
+ </children>
53
+ </giftcard>
54
+
55
+ <system>
56
+ <children>
57
+ <config>
58
+ <children>
59
+ <giftcard>
60
+ <title>Giftcard Settings</title> <!-- Used in resources tree -->
61
+ </giftcard>
62
+ </children>
63
+ </config>
64
+ </children>
65
+ </system>
66
+ </children>
67
+ </admin>
68
+ </resources>
69
+ </acl>
70
+
71
+ </config>
72
+
app/code/community/Kartparadigm/Giftcard/etc/config.xml ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Kartparadigm_Giftcard>
4
+ <version>0.1.5</version>
5
+ </Kartparadigm_Giftcard>
6
+ </modules>
7
+ <adminhtml>
8
+ <menu>
9
+ <customer translate="title" module="customer">
10
+ <children>
11
+ <giftcards translate="title" module="customer">
12
+ <title>Manage Giftcards</title>
13
+ <action>adminhtml/giftcard/index</action>
14
+ </giftcards>
15
+ </children>
16
+ </customer>
17
+ </menu>
18
+ </adminhtml>
19
+ <global>
20
+ <template>
21
+ <email>
22
+ <custom_email_template1 module="kartparadigm_giftcard">
23
+ <label>Giftcard Template For Customer</label>
24
+ <file>giftcard/custom_email_template1.html</file>
25
+ <type>html</type>
26
+ </custom_email_template1>
27
+ <admin_giftcard_template module="kartparadigm_giftcard">
28
+ <label>Giftcard Template For Admin</label>
29
+ <file>giftcard/admin_giftcard_template.html</file>
30
+ <type>html</type>
31
+ </admin_giftcard_template>
32
+ </email>
33
+ </template>
34
+ <events>
35
+
36
+
37
+ <sales_quote_collect_totals_after>
38
+ <observers>
39
+ <kartparadigm_giftcard_model_observer>
40
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
41
+ <method>collectTotals</method>
42
+ </kartparadigm_giftcard_model_observer>
43
+ </observers>
44
+ </sales_quote_collect_totals_after>
45
+ <checkout_cart_product_add_after>
46
+ <observers>
47
+ <kartparadigm_giftcard>
48
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
49
+ <method>changingPrice</method>
50
+ </kartparadigm_giftcard>
51
+ </observers>
52
+ </checkout_cart_product_add_after>
53
+ <!--Event when Order Invoice generation completed-->
54
+ <sales_order_invoice_save_after>
55
+ <observers>
56
+ <kartparadigm_giftcard_model_observer>
57
+ <type>singleton</type>
58
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
59
+ <method>changingStatus</method>
60
+ </kartparadigm_giftcard_model_observer>
61
+ </observers>
62
+ </sales_order_invoice_save_after>
63
+ <sales_order_payment_cancel>
64
+ <observers>
65
+ <kartparadigm_giftcard_model_observer>
66
+ <type>singleton</type>
67
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
68
+ <method>kartparadigmCancel</method>
69
+ </kartparadigm_giftcard_model_observer>
70
+ </observers>
71
+ </sales_order_payment_cancel>
72
+ <!--Event when checkout process complete-->
73
+ <sales_model_service_quote_submit_success>
74
+ <observers>
75
+ <kartparadigm_giftcard_model_observer>
76
+ <type>singleton</type>
77
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
78
+ <method>generatecode</method>
79
+ </kartparadigm_giftcard_model_observer>
80
+ </observers>
81
+ </sales_model_service_quote_submit_success>
82
+ <!--Event when product loaded into cart -->
83
+ <catalog_product_load_after>
84
+ <observers>
85
+ <kartparadigm_giftcard_model_observer>
86
+ <type>model</type>
87
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
88
+ <method>catalogProductLoadAfter</method>
89
+ </kartparadigm_giftcard_model_observer>
90
+ </observers>
91
+ </catalog_product_load_after>
92
+ <!--Observer to make the custom options persist-->
93
+ <sales_convert_quote_item_to_order_item>
94
+ <observers>
95
+ <kartparadigm_giftcard_model_observer>
96
+ <type>model</type>
97
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
98
+ <method>salesConvertQuoteItemToOrderItem</method>
99
+ </kartparadigm_giftcard_model_observer>
100
+ </observers>
101
+ </sales_convert_quote_item_to_order_item>
102
+ </events>
103
+ <blocks>
104
+ <kartparadigm_giftcard>
105
+ <class>Kartparadigm_Giftcard_Block</class>
106
+ </kartparadigm_giftcard>
107
+ </blocks>
108
+ <helpers>
109
+ <kartparadigm_giftcard>
110
+ <class>Kartparadigm_Giftcard_Helper</class>
111
+ </kartparadigm_giftcard>
112
+ <payment>
113
+ <rewrite>
114
+ <data>Kartparadigm_Giftcard_Helper_Payment</data>
115
+ </rewrite>
116
+ </payment>
117
+ </helpers>
118
+ <models>
119
+ <kartparadigm_giftcard>
120
+ <class>Kartparadigm_Giftcard_Model</class>
121
+ <resourceModel>kartparadigm_giftcard_mysql4</resourceModel>
122
+ </kartparadigm_giftcard>
123
+ <kartparadigm_giftcard_mysql4>
124
+ <class>Kartparadigm_Giftcard_Model_Mysql4</class>
125
+ <entities>
126
+ <giftcard>
127
+ <table>kartparadigm_giftcard_giftcard</table>
128
+ </giftcard>
129
+ <giftcardtrans>
130
+ <table>kartparadigm_giftcard_giftcardtrans</table>
131
+ </giftcardtrans>
132
+ <giftcardtemplate>
133
+ <table>kartparadigm_giftcard_giftcardtemplate</table>
134
+ </giftcardtemplate>
135
+ </entities>
136
+ </kartparadigm_giftcard_mysql4>
137
+ </models>
138
+ <resources>
139
+ <kartparadigm_giftcard_setup>
140
+ <setup>
141
+ <module>Kartparadigm_Giftcard</module>
142
+ <class>Mage_Catalog_Model_Resource_Setup</class>
143
+ </setup>
144
+ </kartparadigm_giftcard_setup>
145
+ </resources>
146
+ <catalog>
147
+ <product>
148
+ <type>
149
+ <giftcard translate="label" module="kartparadigm_giftcard">
150
+ <label>GiftCard Product</label>
151
+ <model>kartparadigm_giftcard/product_type</model>
152
+ <is_qty>0</is_qty>
153
+ <composite>0</composite>
154
+ <can_use_qty_decimals>0</can_use_qty_decimals>
155
+ </giftcard>
156
+ </type>
157
+ </product>
158
+ </catalog>
159
+ </global>
160
+ <frontend>
161
+ <layout>
162
+ <updates>
163
+ <giftcard module="Kartparadigm_Giftcard">
164
+ <file>kartparadigm/giftcard.xml</file>
165
+ </giftcard>
166
+ </updates>
167
+ </layout>
168
+ <routers>
169
+ <kartparadigm_giftcard>
170
+ <use>standard</use>
171
+ <args>
172
+ <module>Kartparadigm_Giftcard</module>
173
+ <frontName>giftcard</frontName>
174
+ </args>
175
+ </kartparadigm_giftcard>
176
+ </routers>
177
+ <translate>
178
+ <modules>
179
+ <Kartparadigm_Giftcard>
180
+ <files>
181
+ <default>Kartparadigm_Giftcard.csv</default>
182
+ </files>
183
+ </Kartparadigm_Giftcard>
184
+ </modules>
185
+ </translate>
186
+ </frontend>
187
+ <!-- Default Values for giftcard fields-->
188
+ <default>
189
+ <giftcard>
190
+ <giftcard>
191
+ <enabled>0</enabled>
192
+ <txt_clength>12</txt_clength>
193
+ <txt_dashafter>4</txt_dashafter>
194
+ <txt_expiry>60</txt_expiry>
195
+ <giftcard_sender_email>Sales</giftcard_sender_email>
196
+ </giftcard>
197
+ </giftcard>
198
+ <payment>
199
+ <kartparadigm_giftcard>
200
+ <active>0</active>
201
+ <model>kartparadigm_giftcard/quote_payment</model>
202
+ <order_status>pending</order_status>
203
+ <title>Gift Card Payment</title>
204
+ <allowspecific>0</allowspecific>
205
+ <comments>
206
+ <![CDATA[This order will be fully paid by the gift card]]>
207
+ </comments>
208
+ </kartparadigm_giftcard>
209
+ </payment>
210
+ </default>
211
+ <admin>
212
+ <routers>
213
+ <adminhtml>
214
+ <args>
215
+ <modules>
216
+ <kartparadigm_giftcard before="Mage_Adminhtml">Kartparadigm_Giftcard_Adminhtml</kartparadigm_giftcard>
217
+ </modules>
218
+ </args>
219
+ </adminhtml>
220
+ </routers>
221
+ </admin>
222
+ <!-- Over loading admin templates in module-->
223
+ <stores>
224
+ <admin>
225
+ <design>
226
+ <package>
227
+ <name>default</name>
228
+ </package>
229
+ <theme>
230
+ <default>kartparadigm</default>
231
+ </theme>
232
+ </design>
233
+ </admin>
234
+ </stores>
235
+ <adminhtml>
236
+ <layout>
237
+ <updates>
238
+ <kartparadigm_giftcard module="Kartparadigm_Giftcard">
239
+ <file>giftcard.xml</file>
240
+ </kartparadigm_giftcard>
241
+ </updates>
242
+ </layout>
243
+ </adminhtml>
244
+
245
+ </config>
app/code/community/Kartparadigm/Giftcard/etc/config.xml~ ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Kartparadigm_Giftcard>
4
+ <version>0.1.5</version>
5
+ </Kartparadigm_Giftcard>
6
+ </modules>
7
+ <adminhtml>
8
+ <menu>
9
+ <customer translate="title" module="customer">
10
+ <children>
11
+ <giftcards translate="title" module="customer">
12
+ <title>Manage Giftcards</title>
13
+ <action>adminhtml/giftcard/index</action>
14
+ </giftcards>
15
+ </children>
16
+ </customer>
17
+ </menu>
18
+ </adminhtml>
19
+ <global>
20
+ <template>
21
+ <email>
22
+ <custom_email_template1 module="kartparadigm_giftcard">
23
+ <label>Giftcard Template For Customer</label>
24
+ <file>giftcard/custom_email_template1.html</file>
25
+ <type>html</type>
26
+ </custom_email_template1>
27
+ <admin_giftcard_template module="kartparadigm_giftcard">
28
+ <label>Giftcard Template For Admin</label>
29
+ <file>giftcard/admin_giftcard_template.html</file>
30
+ <type>html</type>
31
+ </admin_giftcard_template>
32
+ </email>
33
+ </template>
34
+ <events>
35
+
36
+
37
+ <sales_quote_collect_totals_after>
38
+ <observers>
39
+ <kartparadigm_giftcard_model_observer>
40
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
41
+ <method>collectTotals</method>
42
+ </kartparadigm_giftcard_model_observer>
43
+ </observers>
44
+ </sales_quote_collect_totals_after>
45
+ <checkout_cart_product_add_after>
46
+ <observers>
47
+ <kartparadigm_giftcard>
48
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
49
+ <method>changingPrice</method>
50
+ </kartparadigm_giftcard>
51
+ </observers>
52
+ </checkout_cart_product_add_after>
53
+ <!--Event when Order Invoice generation completed-->
54
+ <sales_order_invoice_save_after>
55
+ <observers>
56
+ <kartparadigm_giftcard_model_observer>
57
+ <type>singleton</type>
58
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
59
+ <method>changingStatus</method>
60
+ </kartparadigm_giftcard_model_observer>
61
+ </observers>
62
+ </sales_order_invoice_save_after>
63
+ <sales_order_payment_cancel>
64
+ <observers>
65
+ <kartparadigm_giftcard_model_observer>
66
+ <type>singleton</type>
67
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
68
+ <method>kartparadigmCancel</method>
69
+ </kartparadigm_giftcard_model_observer>
70
+ </observers>
71
+ </sales_order_payment_cancel>
72
+ <!--Event when checkout process complete-->
73
+ <sales_model_service_quote_submit_success>
74
+ <observers>
75
+ <kartparadigm_giftcard_model_observer>
76
+ <type>singleton</type>
77
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
78
+ <method>generatecode</method>
79
+ </kartparadigm_giftcard_model_observer>
80
+ </observers>
81
+ </sales_model_service_quote_submit_success>
82
+ <!--Event when product loaded into cart -->
83
+ <catalog_product_load_after>
84
+ <observers>
85
+ <kartparadigm_giftcard_model_observer>
86
+ <type>model</type>
87
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
88
+ <method>catalogProductLoadAfter</method>
89
+ </kartparadigm_giftcard_model_observer>
90
+ </observers>
91
+ </catalog_product_load_after>
92
+ <!--Observer to make the custom options persist-->
93
+ <sales_convert_quote_item_to_order_item>
94
+ <observers>
95
+ <kartparadigm_giftcard_model_observer>
96
+ <type>model</type>
97
+ <class>Kartparadigm_Giftcard_Model_Observer</class>
98
+ <method>salesConvertQuoteItemToOrderItem</method>
99
+ </kartparadigm_giftcard_model_observer>
100
+ </observers>
101
+ </sales_convert_quote_item_to_order_item>
102
+ </events>
103
+ <blocks>
104
+ <kartparadigm_giftcard>
105
+ <class>Kartparadigm_Giftcard_Block</class>
106
+ </kartparadigm_giftcard>
107
+ </blocks>
108
+ <helpers>
109
+ <kartparadigm_giftcard>
110
+ <class>Kartparadigm_Giftcard_Helper</class>
111
+ </kartparadigm_giftcard>
112
+ <payment>
113
+ <rewrite>
114
+ <data>Kartparadigm_Giftcard_Helper_Payment</data>
115
+ </rewrite>
116
+ </payment>
117
+ </helpers>
118
+ <models>
119
+ <kartparadigm_giftcard>
120
+ <class>Kartparadigm_Giftcard_Model</class>
121
+ <resourceModel>kartparadigm_giftcard_mysql4</resourceModel>
122
+ </kartparadigm_giftcard>
123
+ <kartparadigm_giftcard_mysql4>
124
+ <class>Kartparadigm_Giftcard_Model_Mysql4</class>
125
+ <entities>
126
+ <giftcard>
127
+ <table>kartparadigm_giftcard_giftcard</table>
128
+ </giftcard>
129
+ <giftcardtrans>
130
+ <table>kartparadigm_giftcard_giftcardtrans</table>
131
+ </giftcardtrans>
132
+ <giftcardtemplate>
133
+ <table>kartparadigm_giftcard_giftcardtemplate</table>
134
+ </giftcardtemplate>
135
+ </entities>
136
+ </kartparadigm_giftcard_mysql4>
137
+ </models>
138
+ <resources>
139
+ <kartparadigm_giftcard_setup>
140
+ <setup>
141
+ <module>Kartparadigm_Giftcard</module>
142
+ <class>Mage_Catalog_Model_Resource_Setup</class>
143
+ </setup>
144
+ </kartparadigm_giftcard_setup>
145
+ </resources>
146
+ <catalog>
147
+ <product>
148
+ <type>
149
+ <giftcard translate="label" module="kartparadigm_giftcard">
150
+ <label>GiftCard Product</label>
151
+ <model>kartparadigm_giftcard/product_type</model>
152
+ <is_qty>0</is_qty>
153
+ <composite>0</composite>
154
+ <can_use_qty_decimals>0</can_use_qty_decimals>
155
+ </giftcard>
156
+ </type>
157
+ </product>
158
+ </catalog>
159
+ </global>
160
+ <frontend>
161
+ <layout>
162
+ <updates>
163
+ <giftcard module="Kartparadigm_Giftcard">
164
+ <file>kartparadigm/giftcard.xml</file>
165
+ </giftcard>
166
+ </updates>
167
+ </layout>
168
+ <routers>
169
+ <kartparadigm_giftcard>
170
+ <use>standard</use>
171
+ <args>
172
+ <module>Kartparadigm_Giftcard</module>
173
+ <frontName>giftcard</frontName>
174
+ </args>
175
+ </kartparadigm_giftcard>
176
+ </routers>
177
+ <translate>
178
+ <modules>
179
+ <Kartparadigm_Giftcard>
180
+ <files>
181
+ <default>Kartparadigm_Giftcard.csv</default>
182
+ </files>
183
+ </Kartparadigm_Giftcard>
184
+ </modules>
185
+ </translate>
186
+ </frontend>
187
+ <!-- Default Values for giftcard fields-->
188
+ <default>
189
+ <giftcard>
190
+ <giftcard>
191
+ <enabled>0</enabled>
192
+ <txt_clength>12</txt_clength>
193
+ <txt_dashafter>4</txt_dashafter>
194
+ <txt_expiry>60</txt_expiry>
195
+ <giftcard_sender_email>Sales</giftcard_sender_email>
196
+ </giftcard>
197
+ </giftcard>
198
+ <payment>
199
+ <kartparadigm_giftcard>
200
+ <active>0</active>
201
+ <model>kartparadigm_giftcard/quote_payment</model>
202
+ <order_status>pending</order_status>
203
+ <title>Gift Card Payment</title>
204
+ <allowspecific>0</allowspecific>
205
+ <comments>
206
+ <![CDATA[This order will be fully paid by the gift card]]>
207
+ </comments>
208
+ </kartparadigm_giftcard>
209
+ </payment>
210
+ </default>
211
+ <admin>
212
+ <routers>
213
+ <adminhtml>
214
+ <args>
215
+ <modules>
216
+ <kartparadigm_giftcard before="Mage_Adminhtml">Kartparadigm_Giftcard_Adminhtml</kartparadigm_giftcard>
217
+ </modules>
218
+ </args>
219
+ </adminhtml>
220
+ </routers>
221
+ </admin>
222
+ <!-- Over loading admin templates in module-->
223
+ <stores>
224
+ <admin>
225
+ <design>
226
+ <package>
227
+ <name>default</name>
228
+ </package>
229
+ <theme>
230
+ <default>kartparadigm</default>
231
+ </theme>
232
+ </design>
233
+ </admin>
234
+ </stores>
235
+ <adminhtml>
236
+ <layout>
237
+ <updates>
238
+ <kartparadigm_giftcard module="Kartparadigm_Giftcard">
239
+ <file>giftcard.xml</file>
240
+ </kartparadigm_giftcard>
241
+ </updates>
242
+ </layout>
243
+ </adminhtml>
244
+
245
+ </config>
app/code/community/Kartparadigm/Giftcard/etc/system.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <tabs>
5
+ <kartparadigm_giftcard translate="label">
6
+ <label>Kartparadigm GiftCard</label>
7
+ <sort_order>150</sort_order>
8
+ </kartparadigm_giftcard>
9
+ </tabs>
10
+ <sections>
11
+ <giftcard translate="label" module="kartparadigm_giftcard">
12
+ <label>Giftcard</label>
13
+ <tab>kartparadigm_giftcard</tab>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <giftcard translate="label comment">
20
+ <label>Giftcard Settings</label>
21
+ <sort_order>51</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Module </label>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>9</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ </enabled>
36
+ <txt_clength translate="label comment">
37
+ <label>Code length</label>
38
+ <comment>Text field with store view scope.</comment>
39
+ <frontend_type>text</frontend_type>
40
+ <validate>required-entry</validate>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </txt_clength>
46
+ <txt_dashafter translate="label comment">
47
+ <label>Dash After Every 'X' Chars</label>
48
+ <comment>Text field with store view scope.</comment>
49
+ <frontend_type>text</frontend_type>
50
+ <validate>required-entry</validate>
51
+ <sort_order>11</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <comment><![CDATA[Ex : 3 means code should be QWE-ERT-TYU-RTY]]></comment>
56
+ </txt_dashafter>
57
+ <giftcard_sender_email translate="label">
58
+ <label>Email Sender</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
61
+ <sort_order>20</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </giftcard_sender_email>
66
+ <txt_expiry translate="label comment">
67
+ <label>Giftcard Validity</label>
68
+ <comment>Text field with store view scope.</comment>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>12</sort_order>
71
+ <validate>required-entry</validate>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment><![CDATA[Ex : 60 means 60 days after giftcard purchase]]></comment>
76
+ </txt_expiry>
77
+ <customamt_select translate="label">
78
+ <label>Show Custom Amout Redeem Option: </label>
79
+ <comment>Enable Custom Amount Redeeming Text Box In Giftcard Block</comment>
80
+ <frontend_type>select</frontend_type>
81
+ <sort_order>90</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ </customamt_select>
87
+ <othersbuy_select translate="label">
88
+ <label>Can Other Customers Redeem Giftcard : </label>
89
+ <comment>Yes allows other customers also redeeming giftcard</comment>
90
+ <frontend_type>select</frontend_type>
91
+ <sort_order>90</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <source_model>adminhtml/system_config_source_yesno</source_model>
96
+ </othersbuy_select>
97
+ <giftcardbuy_select translate="label">
98
+ <label>Can Giftcard Code Used To Buy Giftcards : </label>
99
+ <comment>Yes allows buying giftcards with giftcard codes</comment>
100
+ <frontend_type>select</frontend_type>
101
+ <sort_order>90</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ <source_model>adminhtml/system_config_source_yesno</source_model>
106
+ </giftcardbuy_select>
107
+ <suborgrand_select translate="label">
108
+ <label>Apply Giftcard To GrandTotal: </label>
109
+ <comment>'Yes' will deduct from GrandTotal 'No' will deduct from SubTotal</comment>
110
+ <frontend_type>select</frontend_type>
111
+ <sort_order>90</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ </suborgrand_select>
117
+ <custom_email_template1 translate="label">
118
+ <label>Gift Card Email Template for Customer</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_email_template</source_model>
121
+ <sort_order>40</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </custom_email_template1>
126
+ <admin_giftcard_template translate="label">
127
+ <label>Gift Card Email Template for Admin</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_email_template</source_model>
130
+ <sort_order>50</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </admin_giftcard_template>
135
+
136
+ </fields>
137
+ </giftcard>
138
+ </groups>
139
+ </giftcard>
140
+ <payment>
141
+ <groups>
142
+ <kartparadigm_giftcard translate="label" module="kartparadigm_giftcard">
143
+ <label>Gift Card Payment</label>
144
+ <frontend_type>text</frontend_type>
145
+ <sort_order>1</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ <fields>
150
+ <order_status translate="label">
151
+ <label>New order status</label>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>adminhtml/system_config_source_order_status</source_model>
154
+ <sort_order>10</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ </order_status>
159
+
160
+ <title translate="label">
161
+ <label>Title</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>20</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </title>
168
+ <comments translate="label">
169
+ <label>Comments</label>
170
+ <frontend_type>textarea</frontend_type>
171
+ <sort_order>30</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </comments>
176
+ </fields>
177
+ </kartparadigm_giftcard>
178
+ </groups>
179
+ </payment>
180
+ </sections>
181
+ </config>
app/code/community/Kartparadigm/Giftcard/etc/system.xml~ ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <tabs>
5
+ <kartparadigm_giftcard translate="label">
6
+ <label>Kartparadigm GiftCard</label>
7
+ <sort_order>150</sort_order>
8
+ </kartparadigm_giftcard>
9
+ </tabs>
10
+ <sections>
11
+ <giftcard translate="label" module="kartparadigm_giftcard">
12
+ <label>Giftcard</label>
13
+ <tab>kartparadigm_giftcard</tab>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <giftcard translate="label comment">
20
+ <label>Giftcard Settings</label>
21
+ <sort_order>51</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Module </label>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>9</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ </enabled>
36
+ <txt_clength translate="label comment">
37
+ <label>Code length</label>
38
+ <comment>Text field with store view scope.</comment>
39
+ <frontend_type>text</frontend_type>
40
+ <validate>required-entry</validate>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </txt_clength>
46
+ <txt_dashafter translate="label comment">
47
+ <label>Dash After Every 'X' Chars</label>
48
+ <comment>Text field with store view scope.</comment>
49
+ <frontend_type>text</frontend_type>
50
+ <validate>required-entry</validate>
51
+ <sort_order>11</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <comment><![CDATA[Ex : 3 means code should be QWE-ERT-TYU-RTY]]></comment>
56
+ </txt_dashafter>
57
+ <giftcard_sender_email translate="label">
58
+ <label>Email Sender</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
61
+ <sort_order>20</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </giftcard_sender_email>
66
+ <txt_expiry translate="label comment">
67
+ <label>Giftcard Validity</label>
68
+ <comment>Text field with store view scope.</comment>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>12</sort_order>
71
+ <validate>required-entry</validate>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment><![CDATA[Ex : 60 means 60 days after giftcard purchase]]></comment>
76
+ </txt_expiry>
77
+ <customamt_select translate="label">
78
+ <label>Show Custom Amout Redeem Option: </label>
79
+ <comment>Enable Custom Amount Redeeming Text Box In Giftcard Block</comment>
80
+ <frontend_type>select</frontend_type>
81
+ <sort_order>90</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ </customamt_select>
87
+ <customres_select translate="label">
88
+ <label>Can Other Customers Redeem Giftcard : </label>
89
+ <comment>Yes allows other customers also redeeming giftcard</comment>
90
+ <frontend_type>select</frontend_type>
91
+ <sort_order>90</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <source_model>adminhtml/system_config_source_yesno</source_model>
96
+ </customres_select>
97
+ <giftcardbuy_select translate="label">
98
+ <label>Can Giftcard Code Used To Buy Giftcards : </label>
99
+ <comment>Yes allows buying giftcards with giftcard codes</comment>
100
+ <frontend_type>select</frontend_type>
101
+ <sort_order>90</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ <source_model>adminhtml/system_config_source_yesno</source_model>
106
+ </giftcardbuy_select>
107
+ <suborgrand_select translate="label">
108
+ <label>Apply Giftcard To GrandTotal: </label>
109
+ <comment>'Yes' will deduct from GrandTotal 'No' will deduct from SubTotal</comment>
110
+ <frontend_type>select</frontend_type>
111
+ <sort_order>90</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ </suborgrand_select>
117
+ <custom_email_template1 translate="label">
118
+ <label>Gift Card Email Template for Customer</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_email_template</source_model>
121
+ <sort_order>40</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </custom_email_template1>
126
+ <admin_giftcard_template translate="label">
127
+ <label>Gift Card Email Template for Admin</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_email_template</source_model>
130
+ <sort_order>50</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </admin_giftcard_template>
135
+
136
+ </fields>
137
+ </giftcard>
138
+ </groups>
139
+ </giftcard>
140
+ <payment>
141
+ <groups>
142
+ <kartparadigm_giftcard translate="label" module="kartparadigm_giftcard">
143
+ <label>Gift Card Payment</label>
144
+ <frontend_type>text</frontend_type>
145
+ <sort_order>1</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ <fields>
150
+ <order_status translate="label">
151
+ <label>New order status</label>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>adminhtml/system_config_source_order_status</source_model>
154
+ <sort_order>10</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ </order_status>
159
+
160
+ <title translate="label">
161
+ <label>Title</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>20</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </title>
168
+ <comments translate="label">
169
+ <label>Comments</label>
170
+ <frontend_type>textarea</frontend_type>
171
+ <sort_order>30</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </comments>
176
+ </fields>
177
+ </kartparadigm_giftcard>
178
+ </groups>
179
+ </payment>
180
+ </sections>
181
+ </config>
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/install-0.1.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $attributes = array(
8
+ 'price',
9
+ 'tax_class_id'
10
+ );
11
+
12
+ foreach ($attributes as $attributeCode) {
13
+ $applyTo = explode(
14
+ ',',
15
+ $installer->getAttribute(
16
+ Mage_Catalog_Model_Product::ENTITY,
17
+ $attributeCode,
18
+ 'apply_to'
19
+ )
20
+ );
21
+
22
+ if (!in_array('giftcard', $applyTo)) {
23
+ $applyTo[] = 'giftcard';
24
+ $installer->updateAttribute(
25
+ Mage_Catalog_Model_Product::ENTITY,
26
+ $attributeCode,
27
+ 'apply_to',
28
+ join(',', $applyTo)
29
+ );
30
+ }
31
+ }
32
+
33
+
34
+
35
+
36
+ $installer->endSetup();
37
+
38
+
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+
7
+
8
+ /**
9
+ * Create Registry Type Table
10
+ *
11
+ *
12
+ */
13
+
14
+ $tableName = $installer->getTable('kartparadigm_giftcard/giftcard');
15
+ // Check if the table already exists
16
+ if ($installer->getConnection()->isTableExists($tableName) != true) {
17
+ $table = $installer->getConnection()
18
+ ->newTable($installer->getTable('kartparadigm_giftcard/giftcard'))
19
+ ->addColumn('giftcard_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
20
+ 'identity' => true,
21
+ 'unsigned' => true,
22
+ 'nullable' => false,
23
+ 'primary' => true,
24
+ ), 'Giftcard Id')
25
+ ->addColumn('gcpro_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
26
+ 'nullable' => false,
27
+ ), 'Giftcard Product Id')
28
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
29
+ 'nullable' => false,
30
+ ), 'order Id')
31
+ ->addColumn('customer_mail', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
32
+ 'nullable' => true,
33
+ ), 'Customer Mail')
34
+ ->addColumn('giftcard_code', Varien_Db_Ddl_Table::TYPE_TEXT, 25, array(
35
+ 'nullable' => true,
36
+ ), 'Giftcard Code')
37
+ ->addColumn('giftcard_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array(
38
+ 'nullable' => true,
39
+ ), 'Giftcard Currency')
40
+ ->addColumn('giftcard_name', Varien_Db_Ddl_Table::TYPE_TEXT, 250, array(
41
+ 'nullable' => true,
42
+ ), 'name')
43
+
44
+ ->addColumn('receiver_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
45
+ 'nullable' => true,
46
+ ), 'Receiver Name')
47
+ ->addColumn('receiver_mail', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
48
+ 'nullable' => true,
49
+ ), 'Receiver Mail')
50
+ ->addColumn('giftcard_msg', Varien_Db_Ddl_Table::TYPE_TEXT, 300, array(
51
+ 'nullable' => true,
52
+ ), 'Giftcard Message')
53
+ ->addColumn('giftcard_address', Varien_Db_Ddl_Table::TYPE_TEXT, 250, array(
54
+ 'nullable' => true,
55
+ ), 'Giftcard Address')
56
+ ->addColumn('delivery_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
57
+ array(),
58
+ 'Delivery Date'
59
+ )
60
+
61
+ ->addColumn('is_notified', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
62
+ 'nullable' => false,
63
+ ), 'Notified')
64
+
65
+
66
+ ->addColumn('giftcard_val', Varien_Db_Ddl_Table::TYPE_DECIMAL, '10,2', array(
67
+ 'nullable' => true,
68
+ ), 'Giftcard Value')
69
+ ->addColumn('giftcard_bal', Varien_Db_Ddl_Table::TYPE_DECIMAL, '10,2', array(
70
+ 'nullable' => true,
71
+ ), 'Giftcard bal')
72
+ ->addColumn('created_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
73
+ array(),
74
+ 'Created Date'
75
+ )
76
+ ->addColumn('expiry_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
77
+ array(),
78
+ 'Expiry Date'
79
+ )
80
+ ->addColumn('customer_name', Varien_Db_Ddl_Table::TYPE_TEXT, 250, array(
81
+ 'nullable' => true,
82
+ ), 'Customer Name')
83
+ ->addColumn('template_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
84
+ 'nullable' => true,
85
+ ), 'Template Name')
86
+
87
+ ->addColumn('giftcard_status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
88
+ array(
89
+ 'unsigned' => true,
90
+ 'nullable' => false,
91
+ 'default' => '0',
92
+ ),
93
+ 'Status')
94
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
95
+ array(
96
+ 'unsigned' => true,
97
+ 'nullable' => false,
98
+ 'default' => '0',
99
+ ),
100
+ 'Status')
101
+ ->addColumn('added_by', Varien_Db_Ddl_Table::TYPE_TEXT, 25, array(
102
+ 'nullable' => true,
103
+ ), 'Added By')
104
+
105
+ ->setComment('Magento Developers Guide Type Table');
106
+ $installer->getConnection()->createTable($table);
107
+ }
108
+ $installer->endSetup();
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.1-0.1.2 .php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create Giftcardtrans Type Table
8
+ *
9
+ *
10
+ */
11
+ $tableName = $installer->getTable('kartparadigm_giftcard/giftcardtrans');
12
+ // Check if the table already exists
13
+ if ($installer->getConnection()->isTableExists($tableName) != true) {
14
+ $table = $installer->getConnection()
15
+ ->newTable($installer->getTable('kartparadigm_giftcard/giftcardtrans'))
16
+ ->addColumn('giftcardtrans_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'identity' => true,
18
+ 'unsigned' => true,
19
+ 'nullable' => false,
20
+ 'primary' => true,
21
+ ), 'Giftcard Trans Id')
22
+ ->addColumn('giftcard_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
23
+ 'nullable' => false,
24
+ ), 'Giftcard Id')
25
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
26
+ 'nullable' => false,
27
+ ), 'order Id')
28
+ ->addColumn('giftcard_code', Varien_Db_Ddl_Table::TYPE_TEXT, 25, array(
29
+ 'nullable' => true,
30
+ ), 'Giftcard Code')
31
+ ->addColumn('giftcard_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array(
32
+ 'nullable' => true,
33
+ ), 'Giftcard Currency')
34
+ ->addColumn('giftcard_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
35
+ 'nullable' => true,
36
+ ), 'Giftcard Name')
37
+ ->addColumn('giftcard_val', Varien_Db_Ddl_Table::TYPE_DECIMAL, '10,2', array(
38
+ 'nullable' => true,
39
+ ), 'Giftcard Value')
40
+ ->addColumn('giftcard_balused', Varien_Db_Ddl_Table::TYPE_DECIMAL, '10,2', array(
41
+ 'nullable' => true,
42
+ ), 'Giftcard Bal Used')
43
+ ->addColumn('giftcard_bal', Varien_Db_Ddl_Table::TYPE_DECIMAL, '10,2', array(
44
+ 'nullable' => true,
45
+ ), 'Giftcard Balance')
46
+ ->addColumn('created_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
47
+ array(),
48
+ 'Created Date'
49
+ )
50
+ ->addColumn('transac_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
51
+ array(),
52
+ 'Transaction Date'
53
+ )
54
+ ->addColumn('expiry_date', Varien_Db_Ddl_Table::TYPE_DATE, null,
55
+ array(),
56
+ 'Expiry Date'
57
+ )
58
+ ->addColumn('customer_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
59
+ 'nullable' => true,
60
+ ), 'Customer Name')
61
+ ->addColumn('customer_mail', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
62
+ 'nullable' => true,
63
+ ), 'Customer Mail')
64
+ ->addColumn('comment', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
65
+ 'nullable' => true,
66
+ ), 'comment')
67
+ ->addColumn('giftcard_status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
68
+ array(
69
+ 'unsigned' => true,
70
+ 'nullable' => false,
71
+ 'default' => '0',
72
+ ),
73
+ 'Status')
74
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
75
+ 'nullable' => false,
76
+ ), 'Store Id')
77
+ ->setComment('Magento Developer Type Table');
78
+ $installer->getConnection()->createTable($table);
79
+ }
80
+ $installer->endSetup();
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $th = new Mage_Catalog_Model_Resource_Setup();
5
+
6
+ $th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'giftcard_type', array(
7
+ 'group' => 'Prices',
8
+ 'type' => 'int',
9
+ 'attribute_set' => 'Default',
10
+ 'input' => 'select',
11
+ 'label' => 'Giftcard Type',
12
+ 'user_defined' => true,
13
+ 'sort_order' => 990,
14
+ 'required' => true,
15
+ 'used_in_product_listing' => true,
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'backend' => 'eav/entity_attribute_backend_array',
18
+ 'apply_to' => 'giftcard',
19
+ 'option' => array (
20
+ 'values' => array(
21
+ 0 => 'Virtual Giftcard',
22
+ 1 => 'Physical Giftcard',
23
+ 2 => 'Mixed Giftcard',
24
+ )
25
+ ),
26
+
27
+ ));
28
+
29
+ $th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'price_type', array(
30
+ 'group' => 'Prices',
31
+ 'type' => 'int',
32
+ 'attribute_set' => 'Default',
33
+ 'input' => 'select',
34
+ 'label' => 'Giftcard Price Type',
35
+ 'sort_order' => 991,
36
+ 'user_defined' => true,
37
+ 'required' => true,
38
+ 'used_in_product_listing' => true,
39
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
40
+ 'backend' => 'eav/entity_attribute_backend_array',
41
+ 'apply_to' => 'giftcard',
42
+ 'option' => array (
43
+ 'values' => array(
44
+ 0 => 'Fixed Price',
45
+ 1 => 'Range Price',
46
+ )
47
+ ),
48
+
49
+ ));
50
+ $th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'giftcard_value', array(
51
+ 'group' => 'Prices',
52
+ 'type' => 'decimal',
53
+ 'attribute_set' => 'Default', // Your custom Attribute set
54
+ 'backend' => '',
55
+ 'frontend' => '',
56
+ 'label' => 'Giftcard Value',
57
+ 'input' => 'price',
58
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
59
+ 'visible' => true,
60
+ 'sort_order' => 992,
61
+ 'required' => true,
62
+ 'user_defined' => true,
63
+ 'default' => '0',
64
+ 'searchable' => false,
65
+ 'filterable' => false,
66
+ 'comparable' => false,
67
+ 'visible_on_front' => true,
68
+ 'visible_in_advanced_search' => false,
69
+ 'used_in_product_listing' => true,
70
+ 'unique' => false,
71
+
72
+ 'apply_to' => 'giftcard', // Apply to simple product type
73
+ ) );
74
+
75
+ $th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'min_gcamt', array(
76
+ 'group' => 'Prices',
77
+ 'type' => 'decimal',
78
+ 'attribute_set' => 'Default', // Your custom Attribute set
79
+ 'backend' => '',
80
+ 'frontend' => '',
81
+ 'label' => 'Min Giftcard Amount',
82
+ 'input' => 'price',
83
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
84
+ 'visible' => true,
85
+ 'required' => true,
86
+ 'user_defined' => true,
87
+ 'default' => '0',
88
+ 'sort_order' => 993,
89
+ 'searchable' => false,
90
+ 'filterable' => false,
91
+ 'comparable' => false,
92
+ 'visible_on_front' => false,
93
+ 'visible_in_advanced_search' => false,
94
+ 'used_in_product_listing' => true,
95
+ 'unique' => false,
96
+ 'note' => 'Fill it only if you select range price',
97
+ 'apply_to' => 'giftcard', // Apply to simple product type
98
+ ) );
99
+
100
+ $th->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'max_gcamt', array(
101
+ 'group' => 'Prices',
102
+ 'type' => 'decimal',
103
+ 'attribute_set' => 'Default', // Your custom Attribute set
104
+ 'backend' => '',
105
+ 'frontend' => '',
106
+ 'label' => 'Max Giftcard Amount',
107
+ 'input' => 'price',
108
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
109
+ 'visible' => true,
110
+ 'required' => true,
111
+ 'user_defined' => true,
112
+ 'default' => '0',
113
+ 'sort_order' => 994,
114
+ 'searchable' => false,
115
+ 'filterable' => false,
116
+ 'comparable' => false,
117
+ 'visible_on_front' => false,
118
+ 'visible_in_advanced_search' => false,
119
+ 'used_in_product_listing' => true,
120
+ 'unique' => false,
121
+ 'note' => 'Fill it only if you select range price',
122
+ 'apply_to' => 'giftcard', // Apply to simple product type
123
+ ) );
124
+ $installer->endSetup();
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'giftcard_code', 'varchar(200)');
5
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'giftcard_bal', 'varchar(200)');
6
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'giftcard_balused', 'varchar(200)');
7
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'giftcard_newbal', 'varchar(200)');
8
+ $installer->endSetup();
app/code/community/Kartparadigm/Giftcard/sql/kartparadigm_giftcard_setup/upgrade-0.1.4-0.1.5.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create Giftcardtemplates Type Table
8
+ *
9
+ *
10
+ */
11
+ $tableName = $installer->getTable('kartparadigm_giftcard/giftcardtemplate');
12
+ // Check if the table already exists
13
+ if ($installer->getConnection()->isTableExists($tableName) != true) {
14
+ $table = $installer->getConnection()
15
+ ->newTable($installer->getTable('kartparadigm_giftcard/giftcardtemplate'))
16
+ ->addColumn('giftcardtemplate_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'identity' => true,
18
+ 'unsigned' => true,
19
+ 'nullable' => false,
20
+ 'primary' => true,
21
+ ), 'Template Id')
22
+ ->addColumn('template_name', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
23
+ 'nullable' => false,
24
+ ), 'Template Name')
25
+ ->addColumn('template_layout', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
26
+ 'nullable' => false,
27
+ ), 'Template Layout')
28
+ ->addColumn('theme_color', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
29
+ 'nullable' => false,
30
+ ), 'Theme Color')
31
+ ->addColumn('text_color', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
32
+ 'nullable' => false,
33
+ ), 'Text Color')
34
+ ->addColumn('background_img', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
35
+ 'nullable' => true,
36
+ ), 'Background Image')
37
+ ->addColumn('template_img', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
38
+ 'nullable' => true,
39
+ ), 'Template Image')
40
+
41
+ ->addColumn('giftcard_note', Varien_Db_Ddl_Table::TYPE_TEXT, 300, array(
42
+ 'nullable' => true,
43
+ ), 'Giftcard Note')
44
+ ->addColumn('template_status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
45
+ array(
46
+ 'unsigned' => true,
47
+ 'nullable' => false,
48
+ 'default' => '1',
49
+ ),
50
+ 'Status')
51
+
52
+ ->setComment('Template Table');
53
+ $installer->getConnection()->createTable($table);
54
+ }
55
+ $installer->addAttribute('catalog_product', 'giftcard_template',array(
56
+ 'attribute_set' => 'Default', // note the addition of this array key
57
+ 'group' => 'General', // and this one
58
+ 'label' => 'Giftcard Template',
59
+ 'type' => 'varchar',
60
+ 'input' => 'multiselect',
61
+ 'backend' => 'eav/entity_attribute_backend_array',
62
+ 'frontend' => '',
63
+ 'source' => '',
64
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
65
+ 'visible' => true,
66
+ 'required' => false,
67
+ 'is_user_defined' => true,
68
+ 'searchable' => false,
69
+ 'filterable' => false,
70
+ 'comparable' => false,
71
+ 'visible_on_front' => false,
72
+ 'apply_to' => 'giftcard',
73
+ 'visible_in_advanced_search' => false,
74
+ 'unique' => false
75
+ ));
76
+
77
+
78
+
79
+ $installer->endSetup();
app/design/adminhtml/base/default/template/kartparadigm/giftcard/customer/main.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <div class="entry-edit">
2
+ <div class="entry-edit-head">
3
+ <h4 class="icon-head head-customer-view"><?php echo
4
+ $this->__('Customer Gift cards List') ?></h4>
5
+ </div>
6
+ <?php echo $this->getChildHtml('giftcard_list');
7
+ ?>
8
+ </div>
9
+
app/design/adminhtml/default/default/layout/giftcard.xml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <adminhtml_system_config_edit>
5
+ <reference name="head">
6
+ <action method="addJs">
7
+ <file>jscolor/jscolor.js</file>
8
+ </action>
9
+ </reference>
10
+ </adminhtml_system_config_edit>
11
+
12
+
13
+ <adminhtml_giftcard_index>
14
+ <reference name="content">
15
+ <block type="kartparadigm_giftcard/adminhtml_registries" name="registries" />
16
+ </reference>
17
+ </adminhtml_giftcard_index>
18
+
19
+
20
+
21
+ <adminhtml_giftcard_send>
22
+ <reference name="content">
23
+ <block type="kartparadigm_giftcard/adminhtml_groupsend_edit" name="adminhtml_groupsend_tabs" />
24
+ </reference>
25
+ </adminhtml_giftcard_send>
26
+
27
+ <adminhtml_giftcard_groupsend>
28
+ <reference name="content">
29
+ <block type="kartparadigm_giftcard/adminhtml_groupsend_edit" name="adminhtml_groupsend_tabs" />
30
+ </reference>
31
+ </adminhtml_giftcard_groupsend>
32
+
33
+
34
+ <adminhtml_template_index>
35
+ <reference name="content">
36
+ <block type="kartparadigm_giftcard/adminhtml_templates" name="templates" />
37
+ </reference>
38
+ </adminhtml_template_index>
39
+
40
+
41
+ <adminhtml_template_view>
42
+ <reference name="content">
43
+ <block type="core/template" name="template.view" as="template_view" template="kartparadigm/giftcard/view.phtml" />
44
+
45
+ </reference>
46
+ </adminhtml_template_view>
47
+
48
+
49
+ <adminhtml_giftcard_view>
50
+ <reference name="content">
51
+ <block type="core/template" name="giftcard.view" as="giftcard_view" template="kartparadigm/giftcard/view.phtml" />
52
+
53
+ </reference>
54
+ </adminhtml_giftcard_view>
55
+
56
+ <adminhtml_template_edit>
57
+ <reference name="head">
58
+ <action method="addJs">
59
+ <file>jscolor/jscolor.js</file>
60
+ </action>
61
+ </reference>
62
+ <reference name="content">
63
+ <block type="kartparadigm_giftcard/adminhtml_templates_edit" name="edit_template_tabs" />
64
+ </reference>
65
+ </adminhtml_template_edit>
66
+ <adminhtml_template_new>
67
+ <reference name="head">
68
+ <action method="addJs">
69
+ <file>jscolor/jscolor.js</file>
70
+ </action>
71
+ </reference>
72
+ <reference name="content">
73
+ <block type="kartparadigm_giftcard/adminhtml_templates_new" name="new_template_tabs" />
74
+ </reference>
75
+ </adminhtml_template_new>
76
+
77
+
78
+
79
+
80
+
81
+
82
+ <adminhtml_giftcard_new>
83
+ <reference name="head">
84
+ <action method="addJs">
85
+ <file>jscolor/jscolor.js</file>
86
+ </action>
87
+ </reference>
88
+ <reference name="content">
89
+ <block type="kartparadigm_giftcard/adminhtml_registries_new" name="new_registry_tabs" />
90
+ </reference>
91
+ </adminhtml_giftcard_new>
92
+
93
+ <adminhtml_giftcard_edit>
94
+ <reference name="head">
95
+ <action method="addJs">
96
+ <file>jscolor/jscolor.js</file>
97
+ </action>
98
+ </reference>
99
+ <reference name="content">
100
+ <block type="kartparadigm_giftcard/adminhtml_registries_edit" name="edit_registry_tabs" />
101
+ </reference>
102
+ </adminhtml_giftcard_edit>
103
+
104
+
105
+
106
+ <adminhtml_customer_edit>
107
+ <reference name="left">
108
+ <reference name="customer_edit_tabs">
109
+ <block type="kartparadigm_giftcard/adminhtml_customer_edit_tab_giftcard" name="tab_giftcard_main"
110
+ template="kartparadigm/giftcard/customer/main.phtml">
111
+ <block type="kartparadigm_giftcard/adminhtml_customer_edit_tab_giftcard_list" name="tab_giftcard_list" as="giftcard_list" />
112
+ </block>
113
+ <action method="addTab">
114
+ <name>kartparadigm_giftcard</name>
115
+ <block>tab_giftcard_main</block>
116
+ </action>
117
+ </reference>
118
+ </reference>
119
+ </adminhtml_customer_edit>
120
+
121
+
122
+
123
+ </layout>
124
+
app/design/adminhtml/default/default/template/kartparadigm/giftcard/view.phtml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $temp=Mage::registry('tempvariables');
2
+
3
+
4
+
5
+
6
+ ?>
7
+ <script>
8
+ function goBack() {
9
+ window.history.back()
10
+ }
11
+ </script>
12
+ <div class="content-header">
13
+ <table cellspacing="0">
14
+ <tbody><tr>
15
+ <td style="width:50%;"><h3 class="icon-head head-adminhtml-templates">Giftcard Template</h3></td>
16
+ <td class="form-buttons"><button type="button" onclick="printDiv('giftcard')" value="print Giftcard" style="float:right;margin-right:25px;" /><span><span><span>Print Giftcard</span></span></span></button>
17
+
18
+ <button title="View Template" onclick="goBack()" type="button"><span><span><span>Back</span></span></span></button></td>
19
+ </form> </tr>
20
+ </tbody></table>
21
+ </div>
22
+ <center>
23
+ <div id='giftcard' class="giftcard-preview-container" style="width:650px;height:650px;padding-left:10px;
24
+ border: 10px solid gray;">
25
+ <div style="background-repeat: no-repeat;float:left;
26
+ width:350px; height:630px; padding-top:5px;" >
27
+ <img src="<?php echo $temp['templateimg']?>" style="width:350px;height:630px;" alt="Image Name" >
28
+ </div>
29
+ <table style="float:right;padding-top:30px;width:300px;" >
30
+ <tr style="padding:2px 2px;
31
+ height:48px;">
32
+ <td style="padding:2px 2px;
33
+ height:24px;"> <span style="font-weight:bold;
34
+ font-size:20px;color:<?php echo $temp['textcolor'] ?>;"><?php echo $temp['giftcardname']?></td>
35
+ </tr>
36
+ <tr style="padding:2px 2px;
37
+ height:48px;">
38
+ <td style="padding:2px 2px;
39
+ height:24px;">
40
+ <span style="font-weight:bold;
41
+ font-size:16px;
42
+ color:<?php echo $temp['themecolor'] ?>;">From : <span id='from' style="font-size:14px;font-weight:bold;
43
+ color:<?php echo $temp['textcolor'] ?>;" ><?php echo $temp['customername']?></span></span>
44
+ </td>
45
+ </tr>
46
+ <tr style="padding:2px 2px;
47
+ height:48px;">
48
+ <td style="padding:2px 2px;
49
+ height:24px;">
50
+ <span style="font-weight:bold;
51
+ font-size:16px;
52
+ color:<?php echo $temp['themecolor'] ?>;">To : <span id='to' style="font-size:14px;font-weight:bold;
53
+ color:<?php echo $temp['textcolor'] ?>;" ><?php echo $temp['receivername']?></span></span>
54
+ </td>
55
+ </tr>
56
+ <tr style="padding:2px 2px;
57
+ height:48px;">
58
+ <td style="padding:2px 2px;
59
+ height:24px;">
60
+ <div style="margin:0 auto; width:270px; height:120px;padding:5px; line-height:15px; text-align:left;color:<?php echo $temp['textcolor'] ?>;border-radius:10px;border:1px solid gray;" id="txtCustName"><?php echo $temp['gcmsg']?></div>
61
+ </td>
62
+ </tr>
63
+ <tr style="padding:2px 2px;
64
+ height:48px;">
65
+ <td style="padding:2px 2px;
66
+ height:24px;">
67
+ <div style="color:<?php echo $temp['textcolor'] ?>;
68
+ font-weight:bold;
69
+ font-size:12px;
70
+ float:right;
71
+ padding-right:15px;">Giftcard Code: <span class="textcolor" style="color:<?php echo $temp['themecolor'] ?>;"><?php echo $temp['giftcardcode']?></span></div>
72
+ </td>
73
+ </tr>
74
+ <tr style="padding:2px 2px;
75
+ height:48px;" >
76
+ <td style="padding:2px 2px;
77
+ height:24px;">
78
+ <div style="color:<?php echo $temp['themecolor'] ?>;
79
+ font-weight:bold;
80
+ font-size:15px;
81
+ width:100px;
82
+ float:left;">Value : <span style="color:<?php echo $temp['textcolor'] ?>;
83
+ font-size:16px;"><?php echo $temp['giftcardval']?></span></div>
84
+ <img class="imgright barcode" style="width:140px;
85
+ height:50px;
86
+ float:right;" src="<?php echo $temp['barcode']?>" >
87
+ </td>
88
+ </tr>
89
+ <tr style="padding:2px 2px;
90
+ height:48px;" >
91
+ <td style="padding:2px 2px;
92
+ height:24px;">
93
+ <div style="color:<?php echo $temp['themecolor'] ?>;
94
+ font-weight:bold;
95
+ font-size:12px;
96
+ width:240px;
97
+ float:left;"><?php echo $temp['gcnote']?></div>
98
+ </td>
99
+ </tr>
100
+ </table>
101
+
102
+ </div>
103
+ </center>
104
+ <script>
105
+ function printDiv(divName) {
106
+ var printContents = document.getElementById(divName).innerHTML;
107
+ var originalContents = document.body.innerHTML;
108
+
109
+ document.body.innerHTML = printContents;
110
+
111
+ window.print();
112
+
113
+ document.body.innerHTML = originalContents;
114
+ }
115
+ </script>
app/design/adminhtml/default/default/template/kartparadigm/giftcard/view.phtml~ ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $temp=Mage::registry('tempvariables');
2
+
3
+ Mage::log($temp,null,'logfile.log');
4
+
5
+ Mage::log("URL ".$this->getUrl());
6
+ ?>
7
+ <script>
8
+ function goBack() {
9
+ window.history.back()
10
+ }
11
+ </script>
12
+ <div class="content-header">
13
+ <table cellspacing="0">
14
+ <tbody><tr>
15
+ <td style="width:50%;"><h3 class="icon-head head-adminhtml-templates">Giftcard Template</h3></td>
16
+ <td class="form-buttons"><button type="button" onclick="printDiv('giftcard')" value="print Giftcard" style="float:right;margin-right:25px;" /><span><span><span>Print Giftcard</span></span></span></button>
17
+
18
+ <button title="View Template" onclick="goBack()" type="button"><span><span><span>Back</span></span></span></button></td>
19
+ </form> </tr>
20
+ </tbody></table>
21
+ </div>
22
+ <center>
23
+ <div id='giftcard' class="giftcard-preview-container" style="width:650px;height:650px;padding-left:10px;
24
+ border: 10px solid gray;">
25
+ <div style="background-repeat: no-repeat;float:left;
26
+ width:350px; height:630px; padding-top:5px;" >
27
+ <img src="<?php echo $temp['templateimg']?>" style="width:350px;height:630px;" alt="Image Name" >
28
+ </div>
29
+ <table style="float:right;padding-top:30px;width:300px;" >
30
+ <tr style="padding:2px 2px;
31
+ height:48px;">
32
+ <td style="padding:2px 2px;
33
+ height:24px;"> <span style="font-weight:bold;
34
+ font-size:20px;color:<?php echo $temp['textcolor'] ?>;"><?php echo $temp['giftcardname']?></td>
35
+ </tr>
36
+ <tr style="padding:2px 2px;
37
+ height:48px;">
38
+ <td style="padding:2px 2px;
39
+ height:24px;">
40
+ <span style="font-weight:bold;
41
+ font-size:16px;
42
+ color:<?php echo $temp['themecolor'] ?>;">From : <span id='from' style="font-size:14px;font-weight:bold;
43
+ color:<?php echo $temp['textcolor'] ?>;" ><?php echo $temp['customername']?></span></span>
44
+ </td>
45
+ </tr>
46
+ <tr style="padding:2px 2px;
47
+ height:48px;">
48
+ <td style="padding:2px 2px;
49
+ height:24px;">
50
+ <span style="font-weight:bold;
51
+ font-size:16px;
52
+ color:<?php echo $temp['themecolor'] ?>;">To : <span id='to' style="font-size:14px;font-weight:bold;
53
+ color:<?php echo $temp['textcolor'] ?>;" ><?php echo $temp['receivername']?></span></span>
54
+ </td>
55
+ </tr>
56
+ <tr style="padding:2px 2px;
57
+ height:48px;">
58
+ <td style="padding:2px 2px;
59
+ height:24px;">
60
+ <div style="margin:0 auto; width:270px; height:120px;padding:5px; line-height:15px; text-align:left;color:<?php echo $temp['textcolor'] ?>;border-radius:10px;border:1px solid gray;" id="txtCustName"><?php echo $temp['gcmsg']?></div>
61
+ </td>
62
+ </tr>
63
+ <tr style="padding:2px 2px;
64
+ height:48px;">
65
+ <td style="padding:2px 2px;
66
+ height:24px;">
67
+ <div style="color:<?php echo $temp['textcolor'] ?>;
68
+ font-weight:bold;
69
+ font-size:12px;
70
+ float:right;
71
+ padding-right:15px;">Giftcard Code: <span class="textcolor" style="color:<?php echo $temp['themecolor'] ?>;"><?php echo $temp['giftcardcode']?></span></div>
72
+ </td>
73
+ </tr>
74
+ <tr style="padding:2px 2px;
75
+ height:48px;" >
76
+ <td style="padding:2px 2px;
77
+ height:24px;">
78
+ <div style="color:<?php echo $temp['themecolor'] ?>;
79
+ font-weight:bold;
80
+ font-size:15px;
81
+ width:100px;
82
+ float:left;">Value : <span style="color:<?php echo $temp['textcolor'] ?>;
83
+ font-size:16px;"><?php echo $temp['giftcardval']?></span></div>
84
+ <img class="imgright barcode" style="width:140px;
85
+ height:50px;
86
+ float:right;" src="<?php echo $temp['barcode']?>" >
87
+ </td>
88
+ </tr>
89
+ <tr style="padding:2px 2px;
90
+ height:48px;" >
91
+ <td style="padding:2px 2px;
92
+ height:24px;">
93
+ <div style="color:<?php echo $temp['themecolor'] ?>;
94
+ font-weight:bold;
95
+ font-size:12px;
96
+ width:240px;
97
+ float:left;"><?php echo $temp['gcnote']?></div>
98
+ </td>
99
+ </tr>
100
+ </table>
101
+
102
+ </div>
103
+ </center>
104
+ <script>
105
+ function printDiv(divName) {
106
+ var printContents = document.getElementById(divName).innerHTML;
107
+ var originalContents = document.body.innerHTML;
108
+
109
+ document.body.innerHTML = printContents;
110
+
111
+ window.print();
112
+
113
+ document.body.innerHTML = originalContents;
114
+ }
115
+ </script>
app/design/adminhtml/default/kartparadigm/template/catalog/form/renderer/fieldset/element.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * @see Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
30
+ */
31
+ ?>
32
+ <?php $_element = $this->getElement() ?>
33
+ <?php $this->checkFieldDisable() ?>
34
+ <?php
35
+ $elementToggleCode = $_element->getToggleCode() ? $_element->getToggleCode()
36
+ : 'toggleValueElements(this, this.parentNode.parentNode)';
37
+ ?>
38
+
39
+ <?php if ($_element->getType()=='hidden'): ?>
40
+ <tr>
41
+ <td class="hidden" colspan="100"><?php echo trim($_element->getElementHtml()) ?></td>
42
+ </tr>
43
+ <?php else: ?>
44
+ <tr id="<?php echo $this->getAttributeCode() ?>">
45
+ <td class="label"><?php echo trim($this->getElementLabelHtml()) ?></td>
46
+ <td class="value">
47
+ <?php echo trim($this->getElementHtml()) ?>
48
+ <?php if ($_element->getNote()) : ?>
49
+ <p class="note"><?php echo $_element->getNote() ?></p>
50
+ <?php endif; ?>
51
+ </td>
52
+ <td class="scope-label"><span class="nobr"><?php echo $this->getScopeLabel() ?></span></td>
53
+ <?php if ($this->canDisplayUseDefault()): ?>
54
+ <td class="value use-default">
55
+ <input <?php if($_element->getReadonly()):?> disabled="disabled"<?php endif; ?> type="checkbox" name="use_default[]" id="<?php echo $_element->getHtmlId() ?>_default"<?php if ($this->usedDefault()): ?> checked="checked"<?php endif; ?> onclick="<?php echo $elementToggleCode; ?>" value="<?php echo $this->getAttributeCode() ?>"/>
56
+ <label for="<?php echo $_element->getHtmlId() ?>_default" class="normal"><?php echo $this->__('Use Default Value') ?></label>
57
+ </td>
58
+ <?php endif; ?>
59
+ </tr>
60
+ <?php endif; ?>
app/design/adminhtml/default/kartparadigm/template/catalog/product/edit.phtml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ /**
4
+ * Template for Mage_Adminhtml_Block_Catalog_Product_Edit
5
+ */
6
+ ?>
7
+
8
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
9
+ <script>
10
+ var ps=$.noConflict();
11
+ ps(document).ready(function(){
12
+ ps("#min_gcamt").hide();
13
+ ps("#max_gcamt").hide();
14
+ ps("#giftcard_value").show();
15
+ ps("#price_type").change(function() {
16
+
17
+ var data=ps('option:selected',ps(this)).text();
18
+ if(data=='Fixed Price')
19
+ {
20
+ ps("#min_gcamt").hide();
21
+ ps("#max_gcamt").hide();
22
+ ps("#giftcard_value").show();
23
+ }
24
+ else if(data=='Range Price')
25
+ {
26
+ ps("#min_gcamt").show();
27
+ ps("#max_gcamt").show();
28
+ ps("#giftcard_value").hide();
29
+ }
30
+ else
31
+ ps("#giftcard_value").show();
32
+ });
33
+ });
34
+ </script>
35
+
36
+
37
+ <div class="content-header">
38
+ <h3 class="icon-head head-products"><?php echo $this->getHeader() ?></h3>
39
+ <p class="content-buttons form-buttons"><?php echo $this->getBackButtonHtml() ?>
40
+ <?php echo $this->getCancelButtonHtml() ?>
41
+ <?php if($this->getProductId()): ?>
42
+ <?php echo $this->getDeleteButtonHtml() ?>
43
+ <?php if($this->getProductSetId() && $this->getIsConfigured()): ?>
44
+ <?php echo $this->getDuplicateButtonHtml() ?>
45
+ <?php endif; ?>
46
+ <?php endif; ?>
47
+ <?php if($this->getProductSetId() && $this->getIsConfigured()): ?>
48
+ <?php echo $this->getSaveButtonHtml() ?>
49
+ <?php echo $this->getSaveAndEditButtonHtml() ?>
50
+ <?php endif; ?>
51
+ </p>
52
+ </div>
53
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="product_edit_form" enctype="multipart/form-data">
54
+ <?php echo $this->getBlockHtml('formkey')?>
55
+ <div style="display:none"></div>
56
+ </form>
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+ var productTemplateSyntax = /(^|.|\r|\n)({{(\w+)}})/;
60
+ var productForm = new varienForm('product_edit_form', '<?php echo $this->getValidationUrl() ?>');
61
+ productForm._processValidationResult = function(transport) {
62
+ var response = transport.responseText.evalJSON();
63
+ if (response.error){
64
+ if (response.attribute && $(response.attribute)) {
65
+ $(response.attribute).setHasError(true, productForm);
66
+ Validation.ajaxError($(response.attribute), response.message);
67
+ if (!Prototype.Browser.IE){
68
+ $(response.attribute).focus();
69
+ }
70
+ }
71
+ else if ($('messages')) {
72
+ $('messages').innerHTML = '<ul class="messages"><li class="error-msg"><ul><li>' + response.message + '</li></ul></li></ul>';
73
+ }
74
+ }
75
+ else{
76
+ productForm._submit();
77
+ }
78
+ };
79
+ function saveAndContinueEdit(urlTemplate) {
80
+ var template = new Template(urlTemplate, productTemplateSyntax);
81
+ var url = template.evaluate({tab_id:product_info_tabsJsTabs.activeTab.id});
82
+ productForm.submit(url);
83
+ }
84
+ function setSettings(urlTemplate, setElement, typeElement) {
85
+ var template = new Template(urlTemplate, productTemplateSyntax);
86
+ setLocation(template.evaluate({attribute_set:$F(setElement),type:$F(typeElement)}));
87
+ }
88
+
89
+ function setSuperSettings(urlTemplate, attributesClass, validateField) {
90
+ var attributesFields = $$('.' + attributesClass);
91
+ var attributes = Form.serializeElements(attributesFields, true).attribute;
92
+ if(typeof attributes == 'string') {
93
+ attributes = [attributes];
94
+ }
95
+
96
+ if(!attributes) {
97
+ $(validateField).value = 'no-attributes';
98
+ } else {
99
+ $(validateField).value = 'has-attributes';
100
+ }
101
+
102
+ if (productForm.validator.validate()) {
103
+ var template = new Template(urlTemplate, productTemplateSyntax);
104
+ var url = template.evaluate({
105
+ attributes: encode_base64(attributes.join(',')).replace(new RegExp('/','g'),'%2F').replace(new RegExp('=','g'),'%3D')
106
+ });
107
+ setLocation(url);
108
+ }
109
+ }
110
+
111
+ function checkMaxLength(Object, MaxLen)
112
+ {
113
+ if (Object.value.length > MaxLen-1) {
114
+ Object.value = Object.value.substr(0, MaxLen);
115
+ }
116
+ return 1;
117
+ }
118
+
119
+ Event.observe(window, 'load', function() {
120
+ var objName = '<?php echo $this->getSelectedTabId() ?>';
121
+ if (objName) {
122
+ obj = $(objName);
123
+ //IE fix (bubbling event model)
124
+ product_info_tabsJsTabs.setSkipDisplayFirstTab();
125
+ product_info_tabsJsTabs.showTabContent(obj);
126
+ }
127
+ Product.AttributesBridge.setTabsObject(product_info_tabsJsTabs);
128
+ });
129
+
130
+ Validation.addAllThese([
131
+ ['validate-super-product-attributes', '<?php echo Mage::helper('catalog')->__('Please select one or more attributes.') ?>', function(v) {
132
+ return (v != "no-attributes");
133
+ }]]);
134
+ //]]>
135
+ </script>
app/design/frontend/base/default/layout/kartparadigm/giftcard.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <layout version="0.1.0">
3
+ <!--adding new link to Customer Myaccount links-->
4
+ <customer_account>
5
+ <reference name="customer_account_navigation">
6
+ <action method="addLink" translate="label" module="kartparadigm_giftcard" ifconfig="giftcard/giftcard/enabled" ><name>Gift Card</name><path>kartparadigm_giftcard/customer/balance/</path><label>My Gift Cards</label></action>
7
+ </reference>
8
+ </customer_account>
9
+ <PRODUCT_TYPE_giftcard translate="label" module="kartparadigm_giftcard">
10
+ <label>Catalog Product View (Giftcard)</label>
11
+ <reference name="head">
12
+ <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params></params></action>
13
+ <action method="addItem"><type>js</type><name>calendar/calendar.js</name></action>
14
+ <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name></action>
15
+ <block type="core/html_calendar" name="head.calendar" as="calendar" template="page/js/calendar.phtml"></block>
16
+ </reference>
17
+ <reference name="product.info">
18
+
19
+ <block type="kartparadigm_giftcard/catalog_product_view_type" name="product.info.giftcard" as="product_type_data" template="kartparadigm/giftcard/product/type.phtml">
20
+
21
+ <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
22
+ <block type="kartparadigm_giftcard/catalog_product_view_type" name="product.info.gcprice" as="product_type_gcprice" template="kartparadigm/giftcard/product/giftcardprice.phtml"/>
23
+
24
+ </block>
25
+ <reference name="product.info">
26
+ <block type="catalog/product_view_media" name="product.info.media" as="media" template="kartparadigm/giftcard/product/media.phtml" />
27
+ </reference>
28
+ </reference>
29
+
30
+ <reference name="root">
31
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
32
+ </reference>
33
+
34
+ </PRODUCT_TYPE_giftcard>
35
+
36
+ <default>
37
+
38
+ <reference name="catalog_product_price_template">
39
+ <action method="addPriceBlockType"><type>giftcard</type><block>catalog/product_price</block><template>kartparadigm/giftcard/product/listprice.phtml</template></action>
40
+ <!-- duplicate for each product type you need to handle i.e. change the value of the <type> node" -->
41
+ </reference>
42
+ </default>
43
+
44
+ <!-- This will override the coupon output, then adds the coupon block back as well as our own custom creditpoint block-->
45
+ <checkout_cart_index>
46
+ <reference name="checkout.cart">
47
+ <block type="core/text_list" name="coupon.and.discount" as="coupon">
48
+ <action method="insert">
49
+ <block>checkout.cart.coupon</block>
50
+ </action>
51
+ <block type="core/template" name="discountblock" template="kartparadigm/giftcard/product/coupon.phtml" after="checkout.cart.coupon" />
52
+ </block>
53
+ </reference>
54
+ </checkout_cart_index>
55
+
56
+
57
+
58
+ <!-- adding custom page block to customer myaccount-->
59
+ <kartparadigm_giftcard_customer_balance>
60
+ <reference name="my.account.wrapper">
61
+ <block type="kartparadigm_giftcard/balance" name="giftcard.balance" as="giftcard_balance" template="kartparadigm/giftcard/customer/balance.phtml" />
62
+ </reference>
63
+ </kartparadigm_giftcard_customer_balance>
64
+
65
+ <kartparadigm_giftcard_customer_shareview>
66
+ <reference name="my.account.wrapper">
67
+ <block type="kartparadigm_giftcard/balance" name="giftcard.shareview" as="giftcard_shareview" template="kartparadigm/giftcard/customer/shareview.phtml" />
68
+ </reference>
69
+ </kartparadigm_giftcard_customer_shareview>
70
+
71
+ <kartparadigm_giftcard_customer_share>
72
+ <reference name="my.account.wrapper">
73
+ <block type="kartparadigm_giftcard/balance" name="giftcard.share" as="giftcard_share" template="kartparadigm/giftcard/customer/shareview.phtml" />
74
+ </reference>
75
+ </kartparadigm_giftcard_customer_share>
76
+
77
+ <kartparadigm_giftcard_customer_view>
78
+ <reference name="my.account.wrapper">
79
+ <block type="kartparadigm_giftcard/view" name="giftcard.view" as="giftcard_view" template="kartparadigm/giftcard/customer/balview.phtml" />
80
+ </reference>
81
+ </kartparadigm_giftcard_customer_view>
82
+
83
+ </layout>
app/design/frontend/base/default/template/kartparadigm/giftcard/customer/balance.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="category-description" style="margin-right:75px; margin-bottom:20px; "><h3><?php echo $this->__('My Gift Cards')?></h3>
2
+ </div>
3
+ <hr style='border-size:1px'/>
4
+ <?php
5
+ $_collection = $this->getCustomerGiftcards();
6
+ $evenodd="odd";
7
+ $helper = Mage::helper('kartparadigm_giftcard');
8
+ $myarr=$helper->getStatusarray();
9
+ if($_collection->count()<=0):
10
+ echo "<br/><h5>".$this->__('You have not purchased any Giftcard products yet.')."</h5>";
11
+ echo "<br/><br/><hr style='border-size:1px'/>";
12
+ else :
13
+ ?>
14
+ <br/>
15
+
16
+ <br/>
17
+ <br/>
18
+
19
+ <table id="" class="data-table">
20
+ <colgroup><col width="1">
21
+ <col width="1">
22
+ <col width="1">
23
+ <col width="1">
24
+ <col width="1">
25
+ <col width="1">
26
+ </colgroup><thead>
27
+ <tr class="first last">
28
+ <th><?php echo $this->__('Giftcard Code')?></th>
29
+ <th><?php echo $this->__('Giftcard Value')?></th>
30
+ <th><?php echo $this->__('Balance')?></th>
31
+ <th><?php echo $this->__('Added Date')?></th>
32
+ <th><?php echo $this->__('Expire Date')?></th>
33
+ <th><?php echo $this->__('Status')?></th>
34
+ <th>&nbsp;</th>
35
+ </tr>
36
+ </thead>
37
+ <tbody>
38
+ <?php
39
+ $evenodd='odd';
40
+ foreach($_collection as $row): ?>
41
+ <tr class="<?php echo $evenodd?>">
42
+ <td ><?php echo $helper->getCodeMasked($row->getGiftcardCode())?></td>
43
+ <td><?php echo Mage::getModel('kartparadigm_giftcard/custommethods')->getBalance($row->getGiftcardVal(),$row->getGiftcardCurrency())?></td>
44
+ <td><?php echo Mage::getModel('kartparadigm_giftcard/custommethods')->getBalance($row->getGiftcardBal(),$row->getGiftcardCurrency())?></td>
45
+ <td><?php echo $row->getCreatedDate()?></td>
46
+ <td><?php echo $row->getExpiryDate()?></td>
47
+ <td><?php echo $myarr[$row->getGiftcardStatus()]?></td>
48
+ <td class="a-center last"><a class="link-reorder" href="<?php echo Mage::getBaseUrl()?>giftcard/customer/view/id/<?php echo $row->getGiftcardId()?>">View</a>
49
+ <?php if($row->getGiftcardStatus()==1):?>
50
+ <span class="separator">|</span>
51
+
52
+ <a class="link-reorder" href="<?php echo Mage::getBaseUrl()?>giftcard/customer/shareview/id/<?php echo $row->getGiftcardId()?>">Share </a>
53
+
54
+ <?php endif;?>
55
+ </td>
56
+ </tr>
57
+ <?php if($evenodd=='even')
58
+ $evenodd='odd';
59
+ else
60
+ $evenodd='even';?>
61
+ <?php endforeach;?>
62
+ </tbody>
63
+ </table>
64
+ <?php endif;?>
65
+
app/design/frontend/base/default/template/kartparadigm/giftcard/customer/balview.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="category-description" style="margin-right:75px; margin-bottom:20px; "><h3><?php echo $this->__('Gift Card Transactions')?></h3>
3
+
4
+ </div>
5
+ <hr style='border-size:1px'/>
6
+ <?php
7
+ $_collection = $this->getGiftcardTrans();
8
+ $firstitem=$_collection->getFirstItem();
9
+ echo "<br/><h4 style='color:#E26703'>".$this->__('Giftcard Name')." : ".$firstitem->getGiftcardName()."</h4>";
10
+ echo "<h4 style='color:green'>".$this->__('Giftcard Code')." : ".$firstitem->getGiftcardCode()."</h4>";
11
+
12
+ $evenodd="odd";
13
+ $helper = Mage::helper('kartparadigm_giftcard');
14
+ $myarr=$helper->getStatusarray();
15
+ if($_collection->count()<=0):
16
+ echo "<br/><h5>You have not purchased any Giftcard products yet.</h5>";
17
+ echo "<br/><br/><hr style='border-size:1px'/>";
18
+ else :
19
+ ?>
20
+
21
+ <br/>
22
+ <a class="link-reorder" href="<?php echo Mage::getBaseUrl()?>giftcard/customer/balance" style="float:right;margin-right:30px">&lt; <?php echo $this->__('Go back')?> </a>
23
+ <br/>
24
+
25
+ <br/>
26
+ <table id="" class="data-table">
27
+ <colgroup><col width="1">
28
+ <col width="1">
29
+ <col width="1">
30
+ <col width="1">
31
+ <col width="1">
32
+ <col width="1">
33
+ </colgroup><thead>
34
+ <tr class="first last">
35
+ <th><?php echo $this->__('Order ID')?></th>
36
+
37
+ <th><?php echo $this->__('Giftcard Balance')?></th>
38
+ <th><?php echo $this->__('Amount Used')?></th>
39
+ <th><?php echo $this->__('Transaction Date')?></th>
40
+
41
+ <th><?php echo $this->__('Status')?></th>
42
+ <th><?php echo $this->__('Comment')?></th>
43
+ </tr>
44
+ </thead>
45
+ <tbody>
46
+ <?php
47
+ $evenodd='odd';
48
+ foreach($_collection as $row): ?>
49
+ <tr class="<?php echo $evenodd?>">
50
+ <td ><?php
51
+ $orderincreid=$row->getOrderId();
52
+ $order = Mage::getModel('sales/order')->load($orderincreid, 'increment_id');
53
+ $orderid = $order->getId();
54
+ if(is_numeric($orderid))
55
+ $url= Mage::getBaseUrl().'sales/order/view/order_id/'.$orderid;
56
+ else
57
+ $url="#";
58
+ ?>
59
+ <a href="<?php echo $url?>"><?php echo $orderincreid?></a>
60
+ </td>
61
+ <!--<td><?php echo Mage::getModel('kartparadigm_giftcard/custommethods')->getBalance($row->getGiftcardVal(),$row->getGiftcardCurrency())?></td>-->
62
+ <td><?php echo Mage::getModel('kartparadigm_giftcard/custommethods')->getBalance($row->getGiftcardBal(),$row->getGiftcardCurrency())?></td>
63
+ <td><?php echo Mage::getModel('kartparadigm_giftcard/custommethods')->getBalance($row->getGiftcardBalused(),$row->getGiftcardCurrency())?></td>
64
+ <td><?php echo $row->getTransacDate()?></td>
65
+ <!--<td><?php echo $row->getExpiryDate()?></td>-->
66
+ <td><?php echo $myarr[$row->getGiftcardStatus()]?></td>
67
+ <td><?php echo $row->getComment()?></td>
68
+
69
+ </tr>
70
+ <?php if($evenodd=='even')
71
+ $evenodd='odd';
72
+ else
73
+ $evenodd='even';?>
74
+ <?php endforeach;?>
75
+ </tbody>
76
+ </table>
77
+ <?php endif;?>
app/design/frontend/base/default/template/kartparadigm/giftcard/customer/shareview.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <?php
4
+ $gccode=Mage::getModel('kartparadigm_giftcard/giftcard')->load($this->getRequest()->getParam('id'))->getGiftcardCode();
5
+ ?>
6
+ <div class="category-description" style="margin-right:75px; margin-bottom:20px; "><h3><?php echo $this->__('Share Giftcard')?></h3>
7
+ </div>
8
+ <hr style='border-size:1px'/>
9
+ <br/>
10
+ <br/>
11
+ <form id="sharegc_form" name="sharegc_form" action="<?php echo Mage::getBaseUrl()?>giftcard/customer/share" method="post">
12
+ <?php echo $this->__('Giftcard Code')?> : <input type="text" name="GiftcardCode" value="<?php echo $gccode ?>" id='gccode' class="input-text required-entry" >
13
+ <br/>
14
+ <br/>
15
+
16
+ <?php echo $this->__('Sharing Mail ID')?> : <input type="text" name="Sharingmail" id='sharemail' class="input-text required-entry validate-email" >
17
+ <br/>
18
+ <br/>
19
+ <input type="hidden" name="gcid" id='gcid' value="<?php echo $this->getRequest()->getParam('id')?>" >
20
+ <button type="submit" class="button" title="Share Giftcard" name="share" id="share"><span><span><?php echo $this->__('Share Giftcard')?> </span></span></button>
21
+ </form>
22
+
23
+ <script type="text/javascript">
24
+ //< ![CDATA[
25
+ var customForm = new VarienForm('sharegc_form');
26
+ //]]>
27
+ </script>
app/design/frontend/base/default/template/kartparadigm/giftcard/payment/form.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+
2
+ <?php echo htmlspecialchars($this->getComments()) ?>
app/design/frontend/base/default/template/kartparadigm/giftcard/product/coupon.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if( Mage::getStoreConfig('giftcard/giftcard/enabled', Mage::app()->getStore()->getStoreId())):?>
2
+ <?php
3
+ $currentCustomer =Mage::getSingleton('customer/session')->getCustomer();
4
+ $collection =Mage::getModel('kartparadigm_giftcard/giftcard')->getCollection()
5
+ ->addFieldToFilter('receiver_mail',$currentCustomer->getEmail())
6
+ ->addFieldToFilter('giftcard_status',1)
7
+ ->addOrder('giftcard_id','DESC');
8
+ ?>
9
+ <div class="discount">
10
+ <form id="discount-form" action="<?php
11
+ echo Mage::getBaseUrl() ?>giftcard/index/index" method="post">
12
+
13
+ <h2><?php
14
+ echo $this->__('Giftcard Codes') ?></h2>
15
+ <div class="discount-form">
16
+
17
+ <?php if(Mage::getSingleton('customer/session')->isLoggedIn()):?>
18
+ <label for="coupon_code"><?php
19
+ echo $this->__('Choose Giftcard To Apply.') ?></label>
20
+ <div class="input-box">
21
+ <?php $quote=Mage::getSingleton('checkout/session')->getQuote();
22
+ $appliedcodes=$quote->getGiftcardCode();?>
23
+
24
+ <?php if($collection->count()>0):?>
25
+ <select name="gccodes" id="gccodes" class="validate-select" title="Giftcard">
26
+ <option value=""> <?php echo $this->__('Select Giftcard Code')?> </option>
27
+ <?php foreach($collection as $coll):
28
+ if (strpos($appliedcodes,$coll->getGiftcardCode()) !== false)
29
+ continue;?>
30
+ <option value="<?php echo $coll->getGiftcardCode().','.$coll->getGiftcardBal();?>"><?php echo $coll->getGiftcardCode()." (".Mage::helper('core')->currency($coll['giftcard_bal']).")";?>
31
+ <?php endforeach;?>
32
+ </option></select>
33
+ <?php endif;?> </div>
34
+ <?php endif;?>
35
+ <input type="hidden" name="remove" id="remove-coupone" value="0" />
36
+ <div class="input-box">
37
+ <?php echo $this->__('Giftcard Code')?> : <input class="input-text required-entry" id="gc_code" name="gc_code" />
38
+ <br/>
39
+ <?php
40
+ if (Mage::getStoreConfig('giftcard/giftcard/customamt_select', Mage::app()->getStore()->getStoreId())) {
41
+ echo "<br/>".$this->__('Redeem Amount')." : <input class='input-text required-entry' id='redeem_amt' name='redeem_amt' />";
42
+ }
43
+ ?>
44
+ </div>
45
+ <br/>
46
+
47
+ <div class="buttons-set">
48
+ <input type="submit" name="<?php echo $this->__('Apply Code')?>" value="<?php echo $this->__('Redeem Code')?>" class="button" style="color:white;font-weight:bold; border-color: #406A83;
49
+ background:#618499;"/>
50
+
51
+ </div>
52
+ </div>
53
+
54
+ </form>
55
+ <br/>
56
+ <?php
57
+ if (Mage::getSingleton('checkout/session')->getQuote()->getGiftcardBalused() != 0): ?>
58
+ <form action="<?php
59
+ echo Mage::getBaseUrl() ?>giftcard/index/cancel" method="post">
60
+
61
+ <?php
62
+ $gccodes = explode(",", Mage::getSingleton('checkout/session')->getQuote()->getGiftcardCode());
63
+ $gcbals = explode(",", Mage::getSingleton('checkout/session')->getQuote()->getGiftcardBal());
64
+ $gcbalused = explode(",", Mage::getSingleton('checkout/session')->getQuote()->getGiftcardBalused());
65
+ $i = 0;
66
+ foreach($gccodes as $gccode) {
67
+ echo "<h5 style='color:green'>".$this->__('Code').": " . $gccode .$this->__(' Net Bal') ." : " . Mage::helper('core')->currency($gcbals[$i] - $gcbalused[$i], true, false) . "</h5>";
68
+ $i++;
69
+ }
70
+ ?>
71
+ <input type="submit" name="<?php echo $this->__('Cancel Code')?>" value="Cancel Code" class="button" style="color:white;font-weight:bold; border-color: #406A83;
72
+ background:#618499;"/>
73
+
74
+ </form>
75
+ <?php
76
+ endif; ?>
77
+ </div>
78
+ <?php endif;?>
79
+ <script src="<?php echo $this->getSkinUrl('js/giftcard/jquery.min-1.11.1.js')?>"></script>
80
+ <script type="text/javascript">
81
+ var cgc=$.noConflict();
82
+ cgc(document).ready(function() {
83
+ cgc("#gccodes").change(function() {
84
+ var gcdata = cgc('option:selected',cgc(this)).val().split(",");
85
+ cgc("#gc_code").val(gcdata[0]);
86
+ cgc("#redeem_amt").val(gcdata[1]);
87
+ });
88
+ });
89
+ </script>
90
+
91
+
92
+
app/design/frontend/base/default/template/kartparadigm/giftcard/product/giftcardprice.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <?php
4
+ $_product = $this->getProduct();
5
+ if($_product->getAttributeText('price_type')=='Range Price'): // checking price type range or fixed
6
+ ?>
7
+ <span id="product-price-27" class="price">
8
+ <input id="CP_ID" class="input-text price required-entry" type="text" name="custom_price" ></input>
9
+ </span><br/><br/>
10
+ <input id="customp" type="hidden" name="customp" value="<?php echo $_product->getMinGcamt(); ?>"></input>
11
+ <?php endif;?>
12
+ <script src="<?php echo $this->getSkinUrl('js/giftcard/jquery.min-1.11.1.js')?>"></script> <script>
13
+ var min='<?php echo $_product->getMinGcamt(); ?>';
14
+ var max='<?php echo $_product->getMaxGcamt(); ?>';
15
+ min=parseInt(min, 10);
16
+ max=parseInt(max, 10);
17
+ var changeprice=$.noConflict();
18
+
19
+ changeprice(document).ready(function(){
20
+ changeprice("#CP_ID").focusout(function(){
21
+
22
+ if(min<=changeprice("#CP_ID").val()&&changeprice("#CP_ID").val()<=max){
23
+
24
+ changeprice("#customp").val(changeprice("#CP_ID").val());
25
+ }
26
+ else{
27
+ alert("enter price in given range");
28
+ changeprice("#CP_ID").val("");
29
+ }
30
+ });
31
+
32
+ });
33
+ </script>
34
+
app/design/frontend/base/default/template/kartparadigm/giftcard/product/listprice.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ .myprice{
3
+ font-weight: bold;
4
+ font-size: 13px;
5
+ color: #C76200;
6
+ }
7
+ </style>
8
+
9
+ <?php
10
+ $_product = $this->getProduct();
11
+
12
+ if($_product->getAttributeText('price_type')=='Range Price'){ // checking price type range or fixed
13
+ echo $this->__('From')." : <span class='myprice'> ".Mage::helper('core')->currency($_product->getMinGcamt(), true, false)."</span>";
14
+ echo "<br/>".$this->__('To')." : <span class='myprice'>".Mage::helper('core')->currency($_product->getMaxGcamt(), true, false)."</span>";
15
+ }
16
+ else if($_product->getGiftcardValue()!=$_product->getPrice()&& ($_product->getGiftcardValue()!=0)){
17
+ echo $this->__('Price')." : <span class='myprice'> ".Mage::helper('core')->currency($_product->getPrice(), true, false)."</span>";
18
+ echo "<br/>".$this->__('Value'). ": <span class='myprice'> ".Mage::helper('core')->currency($_product->getGiftcardValue(), true, false)."</span>";
19
+ }
20
+ else {
21
+ echo $this->__('Price')." : <span class='myprice'> ".Mage::helper('core')->currency($_product->getPrice(), true, false)."</span>";
22
+ }
23
+ ?>
24
+
app/design/frontend/base/default/template/kartparadigm/giftcard/product/media.phtml ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <?php
4
+
5
+ $_product = $this->getProduct();
6
+ $options=$_product->getAttributeText('giftcard_template');
7
+ $value=reset($options);
8
+ //$row=Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name',$value)->getFirstItem();
9
+ $textcol="red";
10
+ $themecol="green";
11
+ $mediapath=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
12
+ $imgpath=$this->helper('catalog/image')->init($_product, 'image');
13
+ $barcode=$mediapath."giftcard/bar.gif";
14
+ $close=$mediapath."giftcard/clos.png";
15
+
16
+ if(($_product->getGiftcardValue()!=$_product->getPrice())&& ($_product->getGiftcardValue()!=0))
17
+ $price =Mage::helper('core')->currency($_product->getGiftcardValue(), true, false);
18
+ else
19
+ $price=Mage::helper('core')->currency($_product->getPrice());
20
+
21
+
22
+ ?>
23
+ <style type="text/css">
24
+ /* example styling, feel free to move it to your styles.css */
25
+
26
+ .col1-layout .product-view .product-shop {
27
+ float: right;
28
+ width: 290px;
29
+ }
30
+ .product-view .product-img-box {
31
+ float: left;
32
+ width: 550px;
33
+ height:350px;
34
+ }
35
+ .tab .tr{
36
+ padding:2px 2px;
37
+ height:28px;
38
+ }
39
+ .tab td{
40
+ padding:2px 2px;
41
+ height:24px;
42
+ }
43
+ .froml{
44
+ font-weight:bold;
45
+ font-size:16px;
46
+
47
+ }
48
+ .tol{
49
+ font-weight:bold;
50
+ font-size:16px;
51
+
52
+ }
53
+ .proname{
54
+ font-weight:bold;
55
+ font-size:20px;
56
+
57
+ }
58
+ .themecolor{
59
+ color:<?php echo $themecol ?>;
60
+ }
61
+ .textcolor{
62
+ color:<?php echo $textcol ?>;
63
+ }
64
+
65
+ .giftcard-code{
66
+
67
+ font-weight:bold;
68
+ font-size:12px;
69
+ float:right;
70
+ padding-right:15px;
71
+ }
72
+ .val{
73
+ font-weight:bold;
74
+ font-size:15px;
75
+ width:100px;
76
+ float:left;
77
+ }
78
+ .gcnote{
79
+ font-weight:bold;
80
+ font-size:12px;
81
+ width:240px;
82
+ float:left;
83
+ }
84
+ .tab{
85
+ padding-top:20px;margin-left: 250px; width:290px;position: absolute;
86
+ }
87
+ .imgright{
88
+ float:right;
89
+ }
90
+ .barcode{
91
+ width:140px;
92
+ height:50px;
93
+ }
94
+ .amt{
95
+ font-size:16px;
96
+ }
97
+ .giftcard-preview-message-box{
98
+ background-repeat: no-repeat;
99
+ background-image: url('<?php echo $imgpath ?>');
100
+ background-size: 240px 350px;
101
+ }
102
+ .fromto{
103
+ font-size:14px;font-weight:bold;
104
+ }
105
+ .giftcard-preview-container{width:550px;height:350px;}
106
+ .giftcard-preview-message-box {width:525px;position: absolute; height:350px; padding-top:5px}
107
+ .giftcard-message { margin:0 auto; width:270px; height:75px;padding:5px; line-height:15px; text-align:left;color:brown;border-radius:10px;border:1px solid gray; }
108
+ </style>
109
+
110
+ <script src="<?php echo $this->getSkinUrl('js/giftcard/jquery.min-1.11.1.js')?>"></script>
111
+ <script src="<?php echo $this->getSkinUrl('js/giftcard/blurbox.js')?>"></script>
112
+ <script>
113
+ var gctemp=$.noConflict();
114
+ gctemp(document).ready(function() {
115
+ gctemp(".pop").click(function() {
116
+ //alert(pid);
117
+ // gctemp('#popup').hide();
118
+ gctemp('.popup').blurbox({blur: 10, animateBlur: true}).show();
119
+
120
+ });
121
+ gctemp("#quick-close").click(function() {
122
+
123
+ //alert(pid);
124
+ gctemp('.popup').blurbox().hide();
125
+
126
+ });
127
+
128
+ gctemp("#giftcard_template").change(function() {
129
+
130
+
131
+ var array = gctemp('option:selected',gctemp(this)).val().split(",");
132
+ var text="#"+array[0];
133
+ var theme="#"+array[1];
134
+ var url='<?php echo $mediapath;?>';
135
+ var p='url('+url+array[2]+')';
136
+ var dpath='<?php $imgpath ?>';
137
+ var dcolor='<?php $textcol ?>';
138
+ var dthem= '<?php $themecol ?>';
139
+ var note=array[3];
140
+ if(array[0]!='')
141
+ {
142
+ gctemp(".themecolor").css("color",text);
143
+ gctemp(".textcolor").css("color",theme);
144
+ gctemp(".giftcard-preview-message-box").css('background-image',p);
145
+ gctemp(".gcnote").html(note);
146
+ }
147
+ else
148
+ {
149
+ gctemp(".themecolor").css("color",dcolor);
150
+ gctemp(".textcolor").css("color",dthem);
151
+ gctemp(".giftcard-preview-message-box").css('background-image',dpath);
152
+
153
+ }
154
+
155
+
156
+ });
157
+
158
+ });
159
+ </script>
160
+ <div class='pop' class="giftcard-preview-container">
161
+ <div class="giftcard-preview-message-box" >
162
+
163
+ </div>
164
+
165
+ <table class='tab' >
166
+ <tr><td> <span class="proname themecolor"><?php echo $_product->getName();?></td></tr>
167
+ <tr><td>
168
+ <span class="froml textcolor"><?php echo $this->__('From') ?> : <span id='from' class="fromto themecolor" ></span></span></td></tr><tr>
169
+ <td>
170
+ <span class="tol textcolor"><?php echo $this->__('To') ?> : <span id='to' class="fromto themecolor" ></span></span></td></tr>
171
+
172
+ <tr><td>
173
+
174
+ <div class="giftcard-message themecolor" id="txtCustName"></div></td>
175
+ </tr>
176
+ <tr><td>
177
+ <div class="giftcard-code themecolor"><?php echo $this->__('Giftcard Code') ?>: <span class="textcolor" >XXX-XXX</span></div>
178
+ </td>
179
+ </tr>
180
+ <tr><td>
181
+
182
+ <div class="val textcolor"><?php echo $this->__('Value') ?> : <span class="amt themecolor"><?php echo $price?></span></div>
183
+ <img class="imgright barcode" src="<?php echo $barcode?>" class="barcode">
184
+ </td>
185
+ </tr>
186
+ <tr><td>
187
+ <div class="gcnote textcolor"><?php echo $this->__('Giftcards only used for purchase in store only') ?></div>
188
+ </td></tr>
189
+ </table>
190
+
191
+ </div>
192
+
193
+ <!--Pop UP Div-->
194
+
195
+ <div class="popup" style="display:none;width:550px;height:350px;" >
196
+ <img class='imgright' src="<?php echo $close?>" id="quick-close" style="margin-right: -8px;margin-top: -8px;">
197
+
198
+ <div class="giftcard-preview-message-box" >
199
+ </div>
200
+
201
+
202
+ <table class='tab' >
203
+ <tr><td> <span class="proname themecolor"><?php echo $_product->getName();?></td></tr>
204
+ <tr><td>
205
+ <span class="froml textcolor"><?php echo $this->__('From') ?> : <span id='from1' class="fromto themecolor" ></span></span></td></tr><tr>
206
+ <td>
207
+ <span class="tol textcolor"><?php echo $this->__('To') ?> : <span id='to1' class="fromto themecolor" ></span></span></td></tr>
208
+
209
+ <tr><td>
210
+
211
+ <div class="giftcard-message themecolor" id="txtCustName1"></div></td>
212
+ </tr>
213
+ <tr><td>
214
+ <div class="giftcard-code themecolor"><?php echo $this->__('Giftcard Code') ?>: <span class="textcolor" >XXX-XXX</span></div>
215
+ </td>
216
+ </tr>
217
+ <tr><td>
218
+
219
+ <div class="val textcolor"><?php echo $this->__('Value') ?> : <span class="amt themecolor"><?php echo $price?> </span></div>
220
+ <img class="imgright barcode" src="<?php echo $barcode?>" class="barcode">
221
+ </td>
222
+ </tr>
223
+ <tr><td>
224
+ <div class="gcnote textcolor"><?php echo $this->__('Giftcards only used for purchase in store only') ?></div>
225
+ </td></tr>
226
+
227
+ </table>
228
+
229
+ </div>
230
+
231
+
232
+
app/design/frontend/base/default/template/kartparadigm/giftcard/product/type.phtml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+ <?php
5
+ $_product = $this->getProduct();
6
+ echo "<h2>" . $this->getPriceHtml($_product) . "</h2>";
7
+ echo $this->getChildHtml("product_type_gcprice");
8
+ $options = $_product->getAttributeText('giftcard_template');
9
+ if(is_array($options))
10
+ $firsttemp=reset($options);
11
+ if(!isset($firsttemp))
12
+ $firsttemp="";
13
+ ?>
14
+
15
+ <?php
16
+ if (count($options) > 1): ?>
17
+
18
+ <?php echo $this->__('Select Template') ?> : <select name="templates" id="giftcard_template">
19
+ <option value=""><?php echo $this->__('Select Template') ?></option>
20
+ <?php
21
+
22
+ foreach($options as $key => $value):
23
+
24
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name', $value)->getFirstItem();
25
+ ?>
26
+ <option value="<?php
27
+ echo $row['text_color'] . ',' . $row['theme_color'] . ',' . $row['template_img']. ',' . $row['giftcard_note'] ?>">
28
+ <?php
29
+ echo $value; ?>
30
+ </option>
31
+ <?php
32
+ endforeach; ?>
33
+ </select>
34
+
35
+
36
+
37
+ <?php
38
+ elseif(count($options) >= 0):
39
+ $row = Mage::getModel('kartparadigm_giftcard/giftcardtemplate')->getCollection()->addFieldToFilter('template_name', $options)->getFirstItem();
40
+ ?>
41
+ <?php if($row['text_color']!=''):?>
42
+ <?php echo $this->__('Select Template') ?> :<select name="templates" id="giftcard_template">
43
+ <option value=""><?php echo $this->__('Select Template') ?></option>
44
+ <option value="<?php
45
+ echo $row['text_color'] . ',' . $row['theme_color'] . ',' . $row['template_img']. ',' . $row['giftcard_note'] ?>">
46
+ <?php
47
+ echo $options; ?>
48
+ </option>
49
+ </select>
50
+ <?php endif;?>
51
+ <?php
52
+ else:
53
+ echo "";
54
+ endif; ?>
55
+
56
+ <br/> <br/>
57
+ <style type="text/css">
58
+ .box{
59
+
60
+ display: none;
61
+ margin-top: 10px;
62
+ border: 1px #000;
63
+ }
64
+ .customform{ background: #fff; }
65
+ td{
66
+
67
+ padding:2px 2px;
68
+ }
69
+ </style>
70
+ <script src="<?php echo $this->getSkinUrl('js/giftcard/jquery.min-1.11.1.js') ?>"></script>
71
+ <script type="text/javascript">
72
+ var gc=$.noConflict();
73
+
74
+ gc(document).ready(function(){
75
+ gc('input[type="checkbox"]').click(function(){
76
+ if(gc(this).attr("value")=="customform"){
77
+ gc(".customform").toggle();
78
+ }
79
+
80
+ });
81
+
82
+
83
+ gc("#giftcard_template").change(function() {
84
+ var templat = gc('option:selected',gc(this)).text();
85
+ var trimtemplat = gc.trim(templat)
86
+ gc("#template").val(trimtemplat);
87
+ });
88
+
89
+ gc("#txt1").keyup(function(){
90
+ gc("#from").html(gc(this).val());
91
+ gc("#from1").html(gc(this).val());
92
+ });
93
+ gc("#txt2").keyup(function(){
94
+ gc("#to").html(gc(this).val());
95
+ gc("#to1").html(gc(this).val());
96
+ });
97
+
98
+ gc("#txt1").blur(function(){
99
+ gc("#from").html(gc(this).val());
100
+ gc("#from1").html(gc(this).val());
101
+ });
102
+ gc("#txt2").blur(function(){
103
+ gc("#to").html(gc(this).val());
104
+ gc("#to1").html(gc(this).val());
105
+ });
106
+
107
+ gc('#tb1').keyup(function(e){
108
+ var keyed = gc(this).val().replace(/[\n]/g,'<br />');
109
+ gc("#txtCustName").html(keyed);
110
+ gc("#txtCustName1").html(keyed);
111
+ });
112
+
113
+ gc('#tb1').blur(function(e){
114
+ var keyed = gc(this).val().replace(/[\n]/g,'<br />');
115
+ gc("#txtCustName").html(keyed);
116
+ gc("#txtCustName1").html(keyed);
117
+ });
118
+
119
+ });
120
+ </script>
121
+
122
+ </head>
123
+ <body>
124
+ <div>
125
+ <label><input type="checkbox" name="colorCheckbox" value="customform"><?php echo $this->__('Send To Someone') ?> </label>
126
+
127
+ </div>
128
+ <input type="hidden" name="Template" id='template' value="<?php echo $firsttemp; ?>" class="input-text " >
129
+
130
+ <div class="customform box">
131
+ <table>
132
+ <tr>
133
+ <td><?php echo $this->__('SenderName') ?>:</td><td><input type="text" name="SenderName" id='txt1' class="input-text " ><br /></td></tr>
134
+ <tr>
135
+ <td><?php echo $this->__('RecipientName') ?>:</td><td><input type="text" name="ReciptentName" id='txt2' class="input-text " ><br /></td></tr>
136
+ <tr>
137
+ <td> <?php echo $this->__('RecipientEmail') ?>:</td><td> <input type="email" name="RecipientEmail" id='txt3' class="input-text " ><br /></td></tr>
138
+
139
+
140
+ <tr><td><?php echo $this->__('CustomMessage') ?>: </td><td><textarea rows= "3" cols="18" id='tb1' name="CustomMessage" class="input-text "></textarea></td></tr>
141
+ <tr>
142
+ <td><?php echo $this->__('Delivery Date') ?> :</td><td><span>
143
+ <input type="text" style="width: 120px;" class="input-text" value="" id="selected_date" name="DeliveryDate"/>
144
+ <img style="" title="Select Date" id="date_select_trig" class="v-middle" alt="" src="<?php
145
+ echo $this->getSkinUrl('images/calendar.gif'); ?> "/>
146
+
147
+ <script type="text/javascript">
148
+ // <![CDATA[
149
+ Calendar.setup({
150
+ inputField: "selected_date",
151
+ ifFormat: "%m/%e/%Y ",
152
+ showsTime: true,
153
+ button: "date_select_trig",
154
+ align: "Bl",
155
+ singleClick : true
156
+ });
157
+ // ]]>
158
+ </script>
159
+ </span>
160
+ </td></tr>
161
+
162
+ <?php
163
+ $attributeValue = $_product->getAttributeText('giftcard_type');
164
+ if (($attributeValue == 'Physical Giftcard' || $attributeValue == 'Mixed Giftcard')): ?>
165
+ <tr>
166
+ <td> <?php echo $this->__('RecipientAddress') ?>: </td><td><textarea rows= "3" cols="18" name="Address" class="input-text " ></textarea><br /></td></tr>
167
+ <?php
168
+ endif; ?>
169
+ <tr><td class="pop" style="cursor:pointer"><a >Preview Giftcard</a></td></tr>
170
+ </table>
171
+
172
+
173
+ </div>
174
+
175
+
176
+
177
+
app/etc/modules/Kartparadigm_Giftcard.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Kartparadigm_Giftcard>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Catalog />
9
+ <Mage_Adminhtml />
10
+ <Mage_Checkout />
11
+ <Mage_Sales />
12
+ </depends>
13
+ </Kartparadigm_Giftcard>
14
+ </modules>
15
+ </config>
app/locale/en_US/Kartparadigm_Giftcard.csv ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Select Template,Select Template
2
+ RecipientAddress,RecipientAddress
3
+ Delivery Date,DeliveryDate
4
+ CustomMessage,CustomMessage
5
+ RecipientEmail,RecipientEmail
6
+ RecipientName,RecipientName
7
+ SenderName,SenderName
8
+ Send To Someone,Send To Someone
9
+ Giftcards only used for purchase in store only,Giftcards only used for purchase in store only
10
+ Value,Value
11
+ Giftcard Code,Giftcard Code
12
+ To,To
13
+ From,From
14
+ Price,Price
15
+ Value,Value
16
+ Enter your Giftcard code if you have one,Enter your Giftcard code if you have one
17
+ Giftcard Codes,Giftcard Codes
18
+ Redeem Amount,Redeem Amount
19
+ Apply Code,Apply Code
20
+ Cancel Code,Cancel Code
21
+ Code,Code
22
+ Redeem Code,Redeem Code
23
+ You have not purchased any Giftcard products yet.,You have not purchased any Giftcard products yet.
24
+ My Gift Card Products,My Gift Card Products
25
+ View,View
26
+ Status,Status
27
+ Expire Date,Expire Date
28
+ Added Date,Added Date
29
+ Balance,Balance
30
+ Giftcard Value,Giftcard Value
31
+ Gift Card Transactions,Gift Card Transactions
32
+ Giftcard Name,Giftcard Name
33
+ Comment,Comment
34
+ Status,Status
35
+ Transaction Date,Transaction Date
36
+ Amount Used,Amount Used
37
+ Giftcard Balance,Giftcard Balance
38
+ Order ID,Order ID
39
+ Sharing Mail ID,Sharing Mail ID
40
+ Share Giftcard,Share Giftcard
app/locale/en_US/template/email/giftcard/custom_email_template1.html ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="giftcard-preview-container" style="width:550px;height:370px;
3
+ border-radius: 10px;padding-left:10px;">
4
+ <div style="background-repeat: no-repeat;float:left;
5
+ width:240px; height:350px; padding-top:5px;" >
6
+ <img src="{{var templateimg}}" style="width:240px;height:350px;" alt="Image Name" >
7
+ </div>
8
+ <table style="float:right;padding-top:10px;width:290px;" >
9
+ <tr style="padding:2px 2px;
10
+ height:28px;">
11
+ <td style="padding:2px 2px;
12
+ height:24px;"> <span style="font-weight:bold;
13
+ font-size:20px;color:{{var textcolor}};">{{var giftcardname}}</td>
14
+ </tr>
15
+ <tr style="padding:2px 2px;
16
+ height:28px;">
17
+ <td style="padding:2px 2px;
18
+ height:24px;">
19
+ <span style="font-weight:bold;
20
+ font-size:16px;
21
+ color:{{var themecolor}};">From : <span id='from' style="font-size:14px;font-weight:bold;
22
+ color:{{var textcolor}};" >{{var customername}}</span></span>
23
+ </td>
24
+ </tr>
25
+ <tr style="padding:2px 2px;
26
+ height:28px;">
27
+ <td style="padding:2px 2px;
28
+ height:24px;">
29
+ <span style="font-weight:bold;
30
+ font-size:16px;
31
+ color:{{var themecolor}};">To : <span id='to' style="font-size:14px;font-weight:bold;
32
+ color:{{var textcolor}};" >{{var receivername}}</span></span>
33
+ </td>
34
+ </tr>
35
+ <tr style="padding:2px 2px;
36
+ height:28px;">
37
+ <td style="padding:2px 2px;
38
+ height:24px;">
39
+ <div style="margin:0 auto; width:270px; height:75px;padding:5px; line-height:15px; text-align:left;color:{{var textcolor}};border-radius:10px;border:1px solid gray;" id="txtCustName">{{var custommsg}}</div>
40
+ </td>
41
+ </tr>
42
+ <tr style="padding:2px 2px;
43
+ height:28px;">
44
+ <td style="padding:2px 2px;
45
+ height:24px;">
46
+ <div style="color:{{var textcolor}};
47
+ font-weight:bold;
48
+ font-size:12px;
49
+ float:right;
50
+ padding-right:15px;">Giftcard Code: <span style="color:{{var themecolor}};">{{var giftcardcode}}</span></div>
51
+ </td>
52
+ </tr>
53
+ <tr style="padding:2px 2px;
54
+ height:28px;" >
55
+ <td style="padding:2px 2px;
56
+ height:24px;">
57
+ <div style="color:{{var themecolor}};
58
+ font-weight:bold;
59
+ font-size:15px;
60
+ width:100px;
61
+ float:left;">Value : <span style="color:{{var textcolor}};
62
+ font-size:16px;">{{var giftcardval}}</span></div>
63
+ <img style="width:140px;
64
+ height:50px;
65
+ float:right;" src="http://www.barcoding.com/images/Barcodes/code93.gif" >
66
+ </td>
67
+ </tr>
68
+ <tr style="padding:2px 2px;
69
+ height:40px;" >
70
+ <td style="padding:2px 2px;
71
+ height:40px;">
72
+ <div style="color:{{var themecolor}};
73
+ font-weight:bold;
74
+ font-size:12px;
75
+ width:240px;
76
+ float:left;">{{var gcnote}}</div>
77
+ </td>
78
+ </tr>
79
+ </table>
80
+
81
+ </div>
82
+ <br/>
83
+ <br/>
84
+
85
+ <h4 style="color:brown;"><a href="{{store_url =''}}">Click here To Buy Products</a></h4>
media/giftcard/bar.gif ADDED
Binary file
media/giftcard/clos.png ADDED
Binary file
media/giftcard/greet.jpg ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Kartparadigm_Giftcard</name>
4
+ <version>1.5.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Giftcard Extension For Selling Giftcard type products in magento store</summary>
10
+ <description>Giftcard product codes are used to buy products from store</description>
11
+ <notes>Giftcard Extension Tested in 1.8 and Working Fine</notes>
12
+ <authors><author><name>Kartparadigm</name><user>kartparadigm</user><email>kartparadigm@gmail.com</email></author></authors>
13
+ <date>2015-03-19</date>
14
+ <time>06:48:08</time>
15
+ <contents><target name="magecommunity"><dir name="Kartparadigm"><dir name="Giftcard"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Form"><dir name="Renderer"><dir name="Fieldset"><file name="Element.php" hash="17050e37b24626ee24ad6ac2b7a4822a"/></dir></dir></dir></dir><dir name="Customer"><dir name="Edit"><dir name="Tab"><dir name="Giftcard"><file name="List.php" hash="7abb5f6a9d0098b30b65944b40fd9ad5"/></dir><file name="Giftcard.php" hash="a76ded858f806fcfbd98f55a22911a15"/></dir></dir></dir><dir name="Groupsend"><dir name="Edit"><file name="Form.php" hash="c3b50bf823b004ba57e2219c42b7ef96"/><file name="Form.php~" hash="dfd150e3c6d08630791a6238b88a8328"/><file name="Tabs.php~" hash="894890ac5d0f7ef6dae1dbb162861bee"/></dir><file name="Edit.php" hash="163356d156d010e175864d9fd9a20472"/></dir><file name="Groupsend.php" hash="3df73363e8501c9e743b5441cc8af43c"/><dir name="Registries"><dir name="Edit"><file name="Form.php" hash="a49e7bb6f609aa02863a2e31f7246355"/></dir><file name="Edit.php" hash="cab16c05aa27713b1f0ee1c7a87f0074"/><file name="Grid.php" hash="83e7cf397a098b8781d22739ee1f73f9"/></dir><file name="Registries.php" hash="5e4db8fdafb8dab2b66ebeb5127b21a9"/><dir name="Templates"><dir name="Edit"><file name="Form.php" hash="dfd2051bb0a9795a43b3434eda069efd"/></dir><file name="Edit.php" hash="96ab9201e133b99ab6dc325fcfb2f161"/><file name="Grid.php" hash="69e8f1ebb651f59f76b2ce0401ee5d5e"/></dir><file name="Templates.php" hash="004967e1c9ebbc58a7bb4d1cd9cbeaf7"/></dir><file name="Balance.php" hash="86c44b60c5a7a45f20892f61a37b6e29"/><dir name="Catalog"><dir name="Product"><dir name="View"><file name="Type.php" hash="b5e6bfdfcd4e10bf347be102cc7b501b"/></dir></dir></dir><dir name="Payment"><file name="Form.php" hash="a3f96979e4213379e95746c280cfd934"/><file name="Info.php" hash="a77b1cbfc1a625997d255d2ca12752a0"/></dir><file name="View.php" hash="5ef34e972c5d02b5f2aa9491da9d33d5"/></dir><dir name="Helper"><file name="Data.php" hash="16ecfad5aff0b9b921d32823a2a860a5"/><file name="Data.php~" hash="16ecfad5aff0b9b921d32823a2a860a5"/><file name="Payment.php" hash="bcd7ff2a288daba5c8757154e114b854"/><file name="Payment.php~" hash="bcd7ff2a288daba5c8757154e114b854"/></dir><dir name="Model"><file name="Custommethods.php" hash="3cebfb6a54d4a9ad3f6ad58a7dbf37e2"/><file name="Giftcard.php" hash="081146193dc762092716247ca8392565"/><file name="Giftcardtemplate.php" hash="fbb3912a24b90428915b2f88648c88a0"/><file name="Giftcardtrans.php" hash="5adb9c6700568f721b1fd639a7a5c549"/><dir name="Mysql4"><dir name="Giftcard"><file name="Collection.php" hash="fc8623fa3ef4eead6dae31ed78c5fc92"/><file name="Collection.php~" hash="05bf9f2c151bf7ce8d13a2261fb12f51"/></dir><file name="Giftcard.php" hash="c5b07a78a587883f3e189bfa324e9cc8"/><file name="Giftcard.php~" hash="9d3b8baf73c040696528017971b060fa"/><dir name="Giftcardtemplate"><file name="Collection.php" hash="ab9b4578b8f188e8a50b4c94d0725685"/><file name="Collection.php~" hash="f2fbfe9e9332e27ef96b28183d223d16"/></dir><file name="Giftcardtemplate.php" hash="3a4132f99a06bd4b20254377aadd19fc"/><file name="Giftcardtemplate.php~" hash="f5c9a2f6443ad607e8e3a05e3f18847a"/><dir name="Giftcardtrans"><file name="Collection.php" hash="6f3b6dc5328295ea86989abd02a0424c"/><file name="Collection.php~" hash="b6cf8f0827786f6e97c9b25b54bd16a5"/></dir><file name="Giftcardtrans.php" hash="fb63b8ebf8f84ffb4b0ada2e8e6b3068"/><file name="Giftcardtrans.php~" hash="fc622dd95f06afe35cae494d0b81c456"/><file name="Template.php~" hash="8c54ea2544046ccf890e47d4ed3cd5db"/><file name="Templates.php~" hash="8c54ea2544046ccf890e47d4ed3cd5db"/></dir><file name="Observer.php" hash="b57d809d5d18c5052a4666b26c5218f2"/><file name="Observer.php~" hash="9fb9820e8f86a8558a6405046434a91e"/><dir name="Product"><file name="Type.php" hash="8f4056f991455ce5047887560bd42283"/><file name="Type.php~" hash="8f4056f991455ce5047887560bd42283"/></dir><dir name="Quote"><file name="Payment.php" hash="6ad5e1533144996c5589c5971cec133e"/><file name="Payment.php~" hash="6ad5e1533144996c5589c5971cec133e"/><file name="Total.php~" hash="660d49fadd0c041c9fd989788137f359"/></dir><file name="Quote.php" hash="e6124ea8cef66f0a71940b35297f43eb"/><dir name="Resource"><file name="Setup.php" hash="9a09b300732fdbe5ebcd4914e607b46f"/><file name="Setup.php~" hash="9a09b300732fdbe5ebcd4914e607b46f"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GiftcardController.php" hash="9dd4f4ca4ab3583769d5d3140ad58edc"/><file name="TemplateController.php" hash="9dee0be88f3c6ecc33356b1ba671b15d"/></dir><file name="CustomerController.php" hash="3c65b0337b06565b9b106a82afc706d6"/><file name="IndexController.php" hash="e4fb8ec50fdf8f25a810207b64e05f0d"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2f753c2c901fe16df9b2dbdf93cc6731"/><file name="adminhtml.xml~" hash="2f753c2c901fe16df9b2dbdf93cc6731"/><file name="config.xml" hash="42b89e028d48411ecfa3a0fe82dc4d6e"/><file name="config.xml~" hash="42b89e028d48411ecfa3a0fe82dc4d6e"/><file name="system.xml" hash="a7601b0b343995dc25ad0631b529e079"/><file name="system.xml~" hash="26287cd1d9461c900a4e5a19ec858f95"/></dir><dir name="sql"><dir name="kartparadigm_giftcard_setup"><file name="install-0.1.0.php" hash="832d74de34ac2105e69ae96db29ea848"/><file name="upgrade-0.1.0-0.1.1.php" hash="091e1f143d0b588364f6452db953b0ee"/><file name="upgrade-0.1.1-0.1.2 .php" hash="738146964a99b9752e00cfbce581de0e"/><file name="upgrade-0.1.2-0.1.3.php" hash="703f3f61b6ae27bf3ce52a3a0f0b64c6"/><file name="upgrade-0.1.3-0.1.4.php" hash="fe8b9c9ceb3955e85ceef9a99f123591"/><file name="upgrade-0.1.4-0.1.5.php" hash="6eb4e7e4c9abd0fca35e26b9ec7f4f09"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="giftcard.xml" hash="1c0f86139a17fac13d4393fccbdd7b74"/></dir><dir name="template"><dir name="kartparadigm"><dir name="giftcard"><file name="view.phtml" hash="be2ac452b636c0050c8bca2b20b3d399"/><file name="view.phtml~" hash="bdbdb46981fb80bdc0b29de58a08ea8f"/></dir></dir></dir></dir><dir name="kartparadigm"><dir name="template"><dir name="catalog"><dir name="form"><dir name="renderer"><dir name="fieldset"><file name="element.phtml" hash="2161df86482407f1d97c31bc0d4cedce"/></dir></dir></dir><dir name="product"><file name="edit.phtml" hash="b4071beacb31042d3e8fd5f5ac0c6127"/></dir></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="kartparadigm"><dir name="giftcard"><dir name="customer"><file name="main.phtml" hash="d7eca62cebcb44d6386870f32e79b1d7"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="kartparadigm"><file name="giftcard.xml" hash="19e29afe175650261b05310d1c6ba91b"/></dir></dir><dir name="template"><dir name="kartparadigm"><dir name="giftcard"><dir name="customer"><file name="balance.phtml" hash="74e76ca3735feab4bf02bc72090ba0b8"/><file name="balview.phtml" hash="22e843fd69058ca76527bd130b3b78d5"/><file name="shareview.phtml" hash="da8e03e56ad748f54a6dc8710dd2a558"/></dir><dir name="payment"><file name="form.phtml" hash="5bee798c8677379f565bd2ee6e05a79b"/></dir><dir name="product"><file name="coupon.phtml" hash="8b637da2ba83dec8d980eba60c629fc2"/><file name="giftcardprice.phtml" hash="b7412477510cc777380db91d18f639f3"/><file name="listprice.phtml" hash="ca21cf3ca82946ccaa20e0041d5e2da6"/><file name="media.phtml" hash="6f6af8239b788467854e15a736d855b1"/><file name="type.phtml" hash="d25055ec13b4b19eb6daf5ba3c0fc8d6"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Kartparadigm_Giftcard.xml" hash="f5df5aa804a3e1df5efa551b8a5e7fe6"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="giftcard"><file name="custom_email_template1.html" hash="3eba5b074ba17c3ff643de246e6edfe1"/></dir></dir></dir><file name="Kartparadigm_Giftcard.csv" hash="dc235c2229d9e2b2b40bf5e4bc69afe2"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="giftcard"><file name="blurbox.js" hash="1d248e0b91cb6e61264e43c93dc497ce"/><file name="jquery.min-1.11.1.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="giftcard"><file name="bar.gif" hash="aed53f61e4a67494a2829e7d9c32597b"/><file name="clos.png" hash="3af928af8bfcc76e5935a665b81b0c62"/><file name="greet.jpg" hash="f9be686771c81af6e1d5bc98846f3c6a"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/js/giftcard/blurbox.js ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;(function (factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ // AMD. Register as an anonymous module.
4
+ define(['jquery'], factory);
5
+ } else {
6
+ // Browser globals
7
+ factory(jQuery);
8
+ }
9
+ }(function ($, undefined) {
10
+ "use strict";
11
+
12
+ var style = '\
13
+ body, html { width: 100%; height: 100%; margin: 0; padding: 0; }\
14
+ .blurbox-noscroll { overflow: hidden; height: 100%; width: 100%; }\
15
+ .blurbox-hidden { display: none !important; }\
16
+ #blurbox-wrapper { overflow: auto; overflow-x:hidden;padding: 10px; border-radius: 5px; background-color: white; opacity: 0; position: fixed; top: 50%; left: 50%; z-index: 9999; width: 100%; height: 100%; max-width: 100%; max-height: 100%; display: block; }\
17
+ #blurbox-wrapper.blurbox-small { box-sizing: border-box; }\
18
+ #blurbox-wrapper.blurbox-show { opacity: 1; }\
19
+ #blurbox-darkenbg { opacity: 0; top: 0; left: 0; z-index: 9998; position: fixed; height: 100%; width: 100%; }\
20
+ #blurbox-darkenbg.blurbox-show { opacity: 1; }\
21
+ @media (max-width: 480px) {\
22
+ #blurbox-wrapper { margin: 0; left: 0; height: 100%; width: 100%; top: 100%; opacity: 1; border-radius: 0; max-height: none; max-width: none; }\
23
+ #blurbox-wrapper.blurbox-show { top: 0; }\
24
+ }\
25
+ ',
26
+ ffsvg = 'url("data:image/svg+xml;utf8,'+encodeURIComponent('<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><filter id="blur"><feGaussianBlur stdDeviation="')+'{blur}'+encodeURIComponent('" /></filter></svg>')+'#blur")';
27
+
28
+ $('head').append('<style>'+style+'</style>');
29
+ var pluginName = 'blurbox',
30
+ plugin = function( element, options ) {
31
+ this.element = $(element);
32
+ this.options = $.extend( {}, plugin.defaults, options);
33
+ this._init();
34
+ };
35
+
36
+ $.extend(plugin, {
37
+ defaults: {
38
+ blur: 3,
39
+ animateBlur: true,
40
+ duration: 300,
41
+ autosize: true,
42
+ bgColor: 'rgba(0,0,0,0.2)',
43
+ bodyContent: null
44
+ },
45
+ activeBlurbox: null,
46
+ darkenbg: null,
47
+ wrapper: null,
48
+ bodyContent: null,
49
+ styleProps: {
50
+ filter: 'filter',
51
+ transition: 'transition',
52
+ },
53
+ cssProps: {
54
+ filter: 'filter',
55
+ transition: 'transition'
56
+ },
57
+ stylePropVals: {
58
+ filter: 'blur({blur}px)',
59
+ transition: '{prop} {dur}ms'
60
+ },
61
+ stylePrefixes: ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'],
62
+ transitionEndEvents: 'webkitTransitionEnd mozTransitionEnd msTransitionEnd oTransitionEnd',
63
+ _init: function() {
64
+ this.darkenbg = $('#blurbox-darkenbg');
65
+ if(!this.darkenbg.length) {
66
+ this.darkenbg = $('<div id="blurbox-darkenbg" class="blurbox-hidden">');
67
+ $('body').append(this.darkenbg);
68
+ this.darkenbg.click(function() {
69
+ plugin.activeBlurbox.hide();
70
+ });
71
+ }
72
+
73
+ this.wrapper = $('#blurbox-wrapper');
74
+ if(!this.wrapper.length) {
75
+ this.wrapper = $('<div id="blurbox-wrapper" class="blurbox-hidden">');
76
+ $('body').append(this.wrapper);
77
+ }
78
+
79
+ this.bodyContent = $('body').children(':first');
80
+
81
+ this._determineProps();
82
+ },
83
+ _testStylePrefixes: function(s, prop, testVal) {
84
+ // test no prefix first
85
+ if(s[prop] !== undefined) {
86
+ s[prop] = testVal;
87
+ if(s[testprop] === testVal) {
88
+ plugin.styleProps[prop] = prop;
89
+ plugin.cssProps[prop] = prop;
90
+ return;
91
+ }
92
+ }
93
+ var capprop = prop.substr(0,1).toUpperCase()+prop.substr(1),
94
+ testprop;
95
+ $.each(this.stylePrefixes, function(i,v) {
96
+ testprop = v+capprop;
97
+ // check if the property exists
98
+ if(s[testprop] !== undefined) {
99
+ // try setting it (for webkit)
100
+ s[testprop] = testVal;
101
+ if(s[testprop] === testVal) {
102
+ plugin.styleProps[prop] = testprop;
103
+ plugin.cssProps[prop] = '-'+v.toLowerCase()+'-'+prop;
104
+ return false;
105
+ }
106
+ }
107
+ });
108
+ },
109
+ _determineProps: function() {
110
+ var s = $('<div>')[0].style;
111
+ plugin._testStylePrefixes(s, 'filter', 'blur(3px)')
112
+ if(plugin.styleProps.filter === 'filter') {
113
+ // test for moz
114
+ var testval = ffsvg.replace('{blur}',1);
115
+ s.filter = testval;
116
+ if(s.filter === testval) {
117
+ plugin.stylePropVals.filter = ffsvg;
118
+ }
119
+ }
120
+ plugin._testStylePrefixes(s, 'transition', 'width 100ms');
121
+ },
122
+ _applyProp: function(el,prop,subs) {
123
+ var val = plugin.stylePropVals[prop];
124
+ if($.isPlainObject(subs)) {
125
+ $.each(subs, function(k,v) {
126
+ val = val.replace('{'+k+'}', v);
127
+ });
128
+ } else {
129
+ // array of property values
130
+ var vals = [];
131
+ $.each(subs, function(i,sub) {
132
+ $.each(sub, function(k,v) {
133
+ vals.push(val.replace('{'+k+'}', v));
134
+ });
135
+ });
136
+ val = vals.join(', ');
137
+ }
138
+
139
+ el.style[plugin.styleProps[prop]] = val;
140
+ },
141
+ _removeProp: function(el, prop) {
142
+ el.style[plugin.styleProps[prop]] = '';
143
+ },
144
+ hide: function(options) {
145
+ if(this.activeBlurbox) {
146
+ this.activeBlurbox.hide(options);
147
+ }
148
+ }
149
+ });
150
+
151
+ plugin._init();
152
+
153
+ $.extend(plugin.prototype, {
154
+ _init: function() {
155
+ this.displayed = false;
156
+ //this.element.detach();
157
+ this.applyOptions(this.options);
158
+ },
159
+
160
+ applyOptions: function(options) {
161
+ this.options = $.extend( {}, plugin.defaults, options);;
162
+
163
+ this.bodyContent = this.options.bodyContent || plugin.bodyContent;
164
+ this.bodyContent.addClass('blurbox-bodyContent');
165
+
166
+ // apply styles
167
+ var isSmall = $('body').width() <= 480;
168
+ plugin._applyProp(plugin.wrapper[0], 'transition', {prop:isSmall ? 'top' : 'opacity',dur:this.options.duration});
169
+ plugin._applyProp(plugin.darkenbg[0], 'transition', {prop:'opacity',dur:this.options.duration});
170
+ if(this.options.animateBlur) {
171
+ plugin._applyProp(this.bodyContent[0], 'transition', {prop:plugin.cssProps.filter,dur:this.options.duration});
172
+ } else {
173
+ plugin._removeProp(this.bodyContent[0], 'transition');
174
+ }
175
+
176
+ plugin.darkenbg.css('backgroundColor', this.options.bgColor || '');
177
+ },
178
+
179
+ show: function(options) {
180
+ this.applyOptions((options && $.isPlainObject(options)) || {});
181
+
182
+ if(plugin.activeBlurbox) {
183
+ plugin.activeBlurbox.hide();
184
+ }
185
+
186
+ $(document).trigger('blurbox.willShow', this);
187
+
188
+ this.element.detach();
189
+
190
+ var isBig = $('body').width() > 480;
191
+
192
+ plugin.wrapper.addClass(isBig ? 'blurbox-big' : 'blurbox-small');
193
+
194
+ if(isBig && this.options.autosize) {
195
+ this.autosize(true);
196
+ }
197
+
198
+ // prevent scroll on body
199
+ this.bodyContent.addClass('blurbox-noscroll');
200
+ // set the popup content and 'show' it
201
+ plugin.wrapper.html(this.element);
202
+ this.element.show();
203
+ // blur it
204
+ if(isBig && this.options.animateBlur && this.options.blur > 0) {
205
+ plugin._applyProp(this.bodyContent[0], 'filter', {blur:this.options.blur});
206
+ }
207
+ plugin.wrapper.removeClass('blurbox-hidden');
208
+ if(this.options.bgColor) {
209
+ plugin.darkenbg.removeClass('blurbox-hidden');
210
+ }
211
+ if(isBig) {
212
+ plugin.wrapper.css({'margin-left':'-'+(plugin.wrapper.width()/2)+'px', 'margin-top':'-'+(plugin.wrapper.height()/2)+'px'})
213
+ }
214
+
215
+ var t = this,
216
+ endAnim = function() {
217
+ if(!t.options.animateBlur && t.options.blur > 0) {
218
+ plugin._applyProp(t.bodyContent[0], 'filter', {blur:t.options.blur});
219
+ }
220
+ plugin.wrapper.off(plugin.tranisitionEndEvents);
221
+ clearTimeout(timeout);
222
+ },
223
+ timeout;
224
+ // set timeout at 0 to let elements be rendered first after display:none has been removed
225
+ setTimeout(function() {
226
+ plugin.wrapper.addClass('blurbox-show');
227
+ if(t.options.bgColor) {
228
+ plugin.darkenbg.addClass('blurbox-show');
229
+ }
230
+ t.bodyContent.on('click.blurbox', $.proxy(t.hide,t));
231
+
232
+ timeout = setTimeout(endAnim, t.options.duration+50);
233
+ plugin.wrapper.on(plugin.tranisitionEndEvents, endAnim);
234
+ },0);
235
+
236
+ this.displayed = true;
237
+ plugin.activeBlurbox = this;
238
+
239
+ $(document).trigger('blurbox.didShow', this);
240
+
241
+ return this;
242
+ },
243
+
244
+ hide: function(options) {
245
+ this.applyOptions((options && $.isPlainObject(options)) || {});
246
+
247
+ $(document).trigger('blurbox.willHide', this);
248
+ this.bodyContent.off('click.blurbox');
249
+ // allow scroll on body
250
+ this.bodyContent.removeClass('blurbox-noscroll');
251
+ // hide the wrapper
252
+ plugin.wrapper.removeClass('blurbox-show');
253
+ // hide the overlay
254
+ plugin.darkenbg.removeClass('blurbox-show');
255
+ // set a timeout and listen for transition end events, whichever happens first end the animation
256
+ var endAnim = function() {
257
+ // at end of animation, display:none the wrapper
258
+ plugin.wrapper.addClass('blurbox-hidden').removeClass('blurbox-big').removeClass('blurbox-small');
259
+ plugin.wrapper.css({height:'',width:'','margin-left':'', 'margin-top':''});
260
+ // and the overlay
261
+ plugin.darkenbg.addClass('blurbox-hidden');
262
+ // stop listening for animation end events and clear the timeout
263
+ plugin.wrapper.off(plugin.tranisitionEndEvents);
264
+ clearTimeout(timeout);
265
+ },
266
+ timeout = setTimeout(endAnim, this.options.duration);
267
+ plugin.wrapper.on(plugin.tranisitionEndEvents, endAnim);
268
+ plugin._removeProp(this.bodyContent[0], 'filter');
269
+ this.displayed = false;
270
+ plugin.activeBlurbox = null;
271
+ $(document).trigger('blurbox.didHide', this);
272
+ return this;
273
+ },
274
+
275
+ toggle: function(options) {
276
+ return this.displayed ? this.hide(options) : this.show(options);
277
+ },
278
+
279
+ autosize: function(renderOffscreen) {
280
+ if(renderOffscreen) {
281
+ var style = this.element.attr('style');
282
+ // render off screen for size
283
+ this.element.css({position:'absolute',left:'100000px',display:'block'});
284
+ $('body').append(this.element);
285
+ }
286
+ var width = this.element.width();
287
+ var height = this.element.height();
288
+ if(renderOffscreen) {
289
+ this.element.detach();
290
+ style ? this.element.attr('style', style) : this.element.removeAttr('style');
291
+ }
292
+ plugin.wrapper.css({width:width,height:height});
293
+ }
294
+ });
295
+
296
+ $.fn[pluginName] = function ( options ) {
297
+ if(!this.length) return null;
298
+ var p = $.data(this, 'plugin_' + pluginName);
299
+ if (p) { return p; }
300
+ p = new plugin( this, options );
301
+ $.data(this, 'plugin_' + pluginName, p);
302
+ return p;
303
+ };
304
+
305
+ $[pluginName] = plugin;
306
+ }));
skin/frontend/base/default/js/giftcard/jquery.min-1.11.1.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
2
+ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;
3
+ if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==cb()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===cb()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ab:bb):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:bb,isPropagationStopped:bb,isImmediatePropagationStopped:bb,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ab,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ab,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ab,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=bb;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=bb),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function db(a){var b=eb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var eb="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fb=/ jQuery\d+="(?:null|\d+)"/g,gb=new RegExp("<(?:"+eb+")[\\s/>]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/<tbody/i,lb=/<|&#?\w+;/,mb=/<(?:script|style|link)/i,nb=/checked\s*(?:[^=]|=\s*.checked.)/i,ob=/^$|\/(?:java|ecma)script/i,pb=/^true\/(.*)/,qb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,rb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"<table>"!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")
4
+ },cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$b=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_b||(_b=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_b),_b=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});