Version Notes
Kartparadigm Store Credit
Download this release
Release Info
Developer | Kartparadigm |
Extension | Kartparadigm_StoreCredit |
Version | 1.0.0.5 |
Comparing to | |
See all releases |
Version 1.0.0.5
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits.php +30 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits/List.php +68 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits/List1.php +38 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Grid.php +16 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php +111 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries.php +13 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Edit.php +28 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Edit/Form.php +62 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Grid.php +63 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1.php +13 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Edit.php +29 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Edit/Form.php +70 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Grid.php +193 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Collection.php +34 -0
- app/code/community/Kartparadigm/StoreCredit/Block/Credit.php +45 -0
- app/code/community/Kartparadigm/StoreCredit/Helper/Data.php +62 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Creditinfo.php +78 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Creditinfo.php +9 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Creditinfo/Collection.php +10 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Sendcreditstofriend.php +9 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Sendcreditstofriend/Collection.php +10 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Observer.php +688 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Resource/Rule.php +127 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Resource/Setup.php +5 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Resource/Transaction.php +75 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Sendcreditstofriend.php +11 -0
- app/code/community/Kartparadigm/StoreCredit/Model/Source.php +15 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/CreditsController.php +276 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/CustomerController.php +387 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/Promo/CatalogController.php +89 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/Sales/Order/CreditmemoController.php +111 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/Checkout/OnepageController.php +84 -0
- app/code/community/Kartparadigm/StoreCredit/controllers/IndexController.php +215 -0
- app/code/community/Kartparadigm/StoreCredit/etc/adminhtml.xml +68 -0
- app/code/community/Kartparadigm/StoreCredit/etc/config.xml +226 -0
- app/code/community/Kartparadigm/StoreCredit/etc/system.xml +142 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/install-0.1.0.php +67 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.1.0-0.2.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.2.0-0.3.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.3.0-0.4.0.php +58 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.4.0-0.5.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.5.0-0.6.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.6.0-0.7.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.7.0-0.8.0.php +19 -0
- app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.8.0-0.9.0.php +19 -0
- app/code/community/Mage/Adminhtml/Block/Sales/Totals.php +113 -0
- app/design/adminhtml/default/default/layout/credit.xml +75 -0
- app/design/adminhtml/default/default/template/kartparadigm/storecredit/credit.phtml +38 -0
- app/design/adminhtml/default/default/template/kartparadigm/storecredit/customer/main.phtml +133 -0
- app/design/adminhtml/default/default/template/kartparadigm/storecredit/payment.phtml +49 -0
- app/design/adminhtml/default/default/template/kartparadigm/storecredit/storecreditview.phtml +14 -0
- app/design/adminhtml/default/default/template/kartparadigm/storecredit/transaction.phtml +9 -0
- app/design/frontend/base/default/layout/credit.xml +55 -0
- app/design/frontend/base/default/template/kartparadigm/mycredits.phtml +55 -0
- app/design/frontend/base/default/template/kartparadigm/mytransactions.phtml +65 -0
- app/design/frontend/base/default/template/kartparadigm/payment.phtml +104 -0
- app/design/frontend/base/default/template/kartparadigm/product.phtml +10 -0
- app/design/frontend/base/default/template/kartparadigm/sendcreditsform.phtml +67 -0
- app/design/frontend/base/default/template/kartparadigm/totalcredits.phtml +39 -0
- app/etc/modules/Kartparadigm_StoreCredit.xml +9 -0
- app/locale/en_US/template/email/caritor_email_template1.html +12 -0
- package.xml +18 -0
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Customer_Edit_Tab_Credits
|
3 |
+
extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface {
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->setTemplate('kartparadigm/storecredit/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->__('Store Credit');
|
16 |
+
}
|
17 |
+
public function getTabTitle()
|
18 |
+
{
|
19 |
+
return $this->__('Store Credit');
|
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/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits/List.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class
|
3 |
+
Kartparadigm_StoreCredit_Block_Adminhtml_Customer_Edit_Tab_Credits_List extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('cardsGrid');
|
8 |
+
$this->setDefaultSort('t_id');
|
9 |
+
$this->setDefaultDir('DESC');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
//$this->setFilterVisibility(false);
|
12 |
+
}
|
13 |
+
protected function _prepareCollection(){
|
14 |
+
$col = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$this->getRequest()->getParam('id'))->setOrder('t_id','desc');
|
15 |
+
$this->setCollection($col);
|
16 |
+
return parent::_prepareCollection();
|
17 |
+
}
|
18 |
+
protected function _prepareColumns()
|
19 |
+
{
|
20 |
+
$this->addColumn('action_date', array(
|
21 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Date'),
|
22 |
+
'index' => 'action_date',
|
23 |
+
'sortable' => true,
|
24 |
+
'filter' => false,
|
25 |
+
));
|
26 |
+
$this->addColumn('My_Website', array(
|
27 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Website'),
|
28 |
+
'index' => 'website1',
|
29 |
+
'sortable' => false,
|
30 |
+
'type' => 'options',
|
31 |
+
'options'=> Mage::getModel('kartparadigm_storecredit/creditinfo')->getWebsites(),
|
32 |
+
));
|
33 |
+
$this->addColumn('action', array(
|
34 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Action'),
|
35 |
+
'index' => 'action',
|
36 |
+
'sortable' => false,
|
37 |
+
'type' => 'options',
|
38 |
+
'options' => array('Credited ' => $this->__('Created'), 'Updated' => $this->__('Updated'), 'Used' => $this->__('Used'), 'Refunded' =>$this->__('Refunded'), 'Deducted' => $this->__('Deducted'), 'Crdits' => $this->__('Crdits')),
|
39 |
+
));
|
40 |
+
$this->addColumn('action credits', array(
|
41 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Balance Change'),
|
42 |
+
'index' => 'action_credits',
|
43 |
+
'sortable' => false,
|
44 |
+
'filter' => false,
|
45 |
+
));
|
46 |
+
$this->addColumn('credits', array(
|
47 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Balance'),
|
48 |
+
'index' => 'total_credits',
|
49 |
+
'sortable' => false,
|
50 |
+
'filter' => false,
|
51 |
+
));
|
52 |
+
$this->addColumn('customer_notification_status', array(
|
53 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Customer notified?'),
|
54 |
+
'index' => 'customer_notification_status',
|
55 |
+
'sortable' => false,
|
56 |
+
'filter' => false,
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->addColumn('custom_msg', array(
|
60 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Additional Information'),
|
61 |
+
'index' => 'custom_msg',
|
62 |
+
'sortable' => false,
|
63 |
+
));
|
64 |
+
return parent::_prepareColumns();
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
68 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Edit/Tab/Credits/List1.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class
|
3 |
+
Kartparadigm_StoreCredit_Block_Adminhtml_Customer_Edit_Tab_Credits_List1 extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('cardsGrid');
|
8 |
+
$this->setDefaultSort('total_credits');
|
9 |
+
$this->setDefaultDir('DESC');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
$this->setPagerVisibility(false);
|
12 |
+
$this->setFilterVisibility(false);
|
13 |
+
}
|
14 |
+
protected function _prepareCollection(){
|
15 |
+
$collection1;
|
16 |
+
$col2 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$this->getRequest()->getParam('id'))->setOrder('t_id','desc')->addFieldToFilter('website1','Main Website')->getLastItem();
|
17 |
+
foreach($col2 as $col)
|
18 |
+
$collection1 = $col;
|
19 |
+
$this->setCollection($col2);
|
20 |
+
return parent::_prepareCollection();
|
21 |
+
}
|
22 |
+
protected function _prepareColumns()
|
23 |
+
{
|
24 |
+
$this->addColumn('total_credits', array(
|
25 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Store Credits'),
|
26 |
+
'index' => 'total_credits',
|
27 |
+
'sortable' => false,
|
28 |
+
));
|
29 |
+
$this->addColumn('website1', array(
|
30 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Website'),
|
31 |
+
'index' => 'website1',
|
32 |
+
'sortable' => false,
|
33 |
+
));
|
34 |
+
return parent::_prepareColumns();
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Customer/Grid.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
|
3 |
+
{
|
4 |
+
public function _prepareMassaction()
|
5 |
+
{
|
6 |
+
|
7 |
+
parent::_prepareMassaction();
|
8 |
+
$this->getMassactionBlock()->addItem('my_action', array(
|
9 |
+
'label' => Mage::helper('customer')->__('Send Credits'),
|
10 |
+
'url' => $this->getUrl('*/*/sendCredits')
|
11 |
+
));
|
12 |
+
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* description
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Promo_Catalog_Edit_Tab_Actions
|
35 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
36 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
37 |
+
{
|
38 |
+
/**
|
39 |
+
* Prepare content for tab
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getTabLabel()
|
44 |
+
{
|
45 |
+
return Mage::helper('catalogrule')->__('Store Credit');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Prepare title for tab
|
50 |
+
*
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function getTabTitle()
|
54 |
+
{
|
55 |
+
return Mage::helper('catalogrule')->__('Actions');
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Returns status flag about this tab can be showen or not
|
60 |
+
*
|
61 |
+
* @return true
|
62 |
+
*/
|
63 |
+
public function canShowTab()
|
64 |
+
{
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Returns status flag about this tab hidden or not
|
70 |
+
*
|
71 |
+
* @return true
|
72 |
+
*/
|
73 |
+
public function isHidden()
|
74 |
+
{
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function _prepareForm()
|
79 |
+
{
|
80 |
+
$model = Mage::registry('current_promo_catalog_rule');
|
81 |
+
|
82 |
+
$form = new Varien_Data_Form();
|
83 |
+
|
84 |
+
$form->setHtmlIdPrefix('rule_');
|
85 |
+
|
86 |
+
$fieldset = $form->addFieldset('action_fieldset', array(
|
87 |
+
'legend' => Mage::helper('catalogrule')->__('Apply Credits To The Rule')
|
88 |
+
)
|
89 |
+
);
|
90 |
+
|
91 |
+
|
92 |
+
$fieldset->addField('store_credit', 'text', array(
|
93 |
+
'name' => 'store_credit',
|
94 |
+
'class' => 'validate-not-negative-number',
|
95 |
+
'label' => Mage::helper('catalogrule')->__('Store Credit'),
|
96 |
+
));
|
97 |
+
$form->setValues($model->getData());
|
98 |
+
|
99 |
+
//$form->setUseContainer(true);
|
100 |
+
|
101 |
+
if ($model->isReadonly()) {
|
102 |
+
foreach ($fieldset->getElements() as $element) {
|
103 |
+
$element->setReadonly(true, true);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
$this->setForm($form);
|
108 |
+
|
109 |
+
return parent::_prepareForm();
|
110 |
+
}
|
111 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries extends
|
3 |
+
Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
$this->_controller = 'adminhtml_registries';
|
7 |
+
$this->_blockGroup = 'kartparadigm_storecredit';
|
8 |
+
$this->_headerText = Mage::helper('kartparadigm_storecredit')->__('Manage Store Credit Transactions');
|
9 |
+
parent::__construct();
|
10 |
+
$this->_removeButton('add');
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Edit.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries_Edit
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
$data = array(
|
7 |
+
'label' => 'Back',
|
8 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/credits/customer') . '\')',
|
9 |
+
'class' => 'back'
|
10 |
+
);
|
11 |
+
$this->addButton ('my_back', $data, 0, 100, 'header');
|
12 |
+
parent::__construct();
|
13 |
+
$this->_objectId = 'id';
|
14 |
+
$this->_blockGroup = 'kartparadigm_storecredit';
|
15 |
+
$this->_controller = 'adminhtml_registries';
|
16 |
+
$this->_mode = 'edit';
|
17 |
+
$this->_removeButton('reset');
|
18 |
+
$this->_updateButton('save', 'label', Mage::helper('kartparadigm_storecredit')->__('Send Credits'));
|
19 |
+
$this->_removeButton('back');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getHeaderText(){
|
23 |
+
if(Mage::registry('registries_data') &&
|
24 |
+
Mage::registry('registries_data')->getId())
|
25 |
+
return Mage::helper('kartparadigm_storecredit')->__("Send Credits '%s'", $this->htmlEscape(Mage::registry('registries_data')->getTitle()));
|
26 |
+
return Mage::helper('kartparadigm_storecredit')->__('Send Credits');
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Edit/Form.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_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('*/*/send', array('id'=> $this->getRequest()->getParam('id'))),
|
9 |
+
'method' => 'post',
|
10 |
+
'enctype' => 'multipart/form-data'
|
11 |
+
));
|
12 |
+
$form->setUseContainer(true);
|
13 |
+
$this->setForm($form);
|
14 |
+
$data;
|
15 |
+
if (Mage::getSingleton('adminhtml/session')->getFormData()){
|
16 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData();
|
17 |
+
Mage::getSingleton('adminhtml/session')->setFormData(null);
|
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_storecredit')->__('Credits information')));
|
22 |
+
|
23 |
+
$fieldset->addField('email', 'multiselect', array(
|
24 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('email Id'),
|
25 |
+
'name'=> 'email',
|
26 |
+
'class'=> 'required-entry',
|
27 |
+
'required' => true,
|
28 |
+
'values' => $data,
|
29 |
+
));
|
30 |
+
|
31 |
+
$fieldset->addField('credits', 'text', array(
|
32 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Credits'),
|
33 |
+
'class'=> 'required-entry',
|
34 |
+
'required' => true,
|
35 |
+
'name'=> 'credits',
|
36 |
+
));
|
37 |
+
|
38 |
+
$fieldset->addField('notify', 'checkbox', array(
|
39 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Notify Customers'),
|
40 |
+
'value' => 'true',
|
41 |
+
'name'=> 'notify',
|
42 |
+
));
|
43 |
+
|
44 |
+
$fieldset->addField('store_view', 'select', array(
|
45 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Store View'),
|
46 |
+
'name'=> 'store_view',
|
47 |
+
'options'=> Mage::getModel('kartparadigm_storecredit/creditinfo')->getStoreviews(),
|
48 |
+
));
|
49 |
+
|
50 |
+
$fieldset->addField('message', 'textarea', array(
|
51 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Message'),
|
52 |
+
'class'=> 'required-entry',
|
53 |
+
'required' => true,
|
54 |
+
'name'=> 'message',
|
55 |
+
));
|
56 |
+
|
57 |
+
|
58 |
+
$form->setValues($data);
|
59 |
+
return parent::_prepareForm();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries/Grid.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries_Grid
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('cardsGrid');
|
8 |
+
$this->setDefaultSort('t_id');
|
9 |
+
$this->setDefaultDir('ASC');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
}
|
12 |
+
protected function _prepareCollection(){
|
13 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection();
|
14 |
+
$collection->getSelect()->join(array('refer' => 'customer_entity'),'refer.entity_id = main_table.c_id');
|
15 |
+
$this->setCollection($collection);
|
16 |
+
return parent::_prepareCollection();
|
17 |
+
}
|
18 |
+
protected function _prepareColumns()
|
19 |
+
{
|
20 |
+
$this->addColumn('c_id', array(
|
21 |
+
'header' => Mage::helper('kartparadigm_storecredit')->__('Customer Id'),
|
22 |
+
'index'=> 'c_id',
|
23 |
+
'sortable' => false,
|
24 |
+
));
|
25 |
+
$this->addColumn('email', array(
|
26 |
+
'header' => Mage::helper('kartparadigm_storecredit')->__('Customer Email'),
|
27 |
+
'index'=> 'email',
|
28 |
+
'sortable' => false,
|
29 |
+
));
|
30 |
+
$this->addColumn('action', array(
|
31 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Action On Credits'),
|
32 |
+
'index' => 'action',
|
33 |
+
'sortable' => false,
|
34 |
+
));
|
35 |
+
$this->addColumn('action credits', array(
|
36 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Credits Added'),
|
37 |
+
'index' => 'action_credits',
|
38 |
+
'sortable' => false,
|
39 |
+
));
|
40 |
+
$this->addColumn('credits', array(
|
41 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Total Credits'),
|
42 |
+
'index' => 'total_credits',
|
43 |
+
'sortable' => false,
|
44 |
+
));
|
45 |
+
$this->addColumn('action_date', array(
|
46 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Action Date'),
|
47 |
+
'index' => 'action_date',
|
48 |
+
'sortable' => false,
|
49 |
+
));
|
50 |
+
$this->addColumn('custom_msg', array(
|
51 |
+
'header'=> Mage::helper('kartparadigm_storecredit')->__('Message'),
|
52 |
+
'index' => 'custom_msg',
|
53 |
+
'sortable' => false,
|
54 |
+
));
|
55 |
+
return parent::_prepareColumns();
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getRowUrl($row)
|
59 |
+
{
|
60 |
+
return $this->getUrl('*/*/showTransaction', array('id'=>$row->getId()));
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries1 extends
|
3 |
+
Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
$this->_controller = 'adminhtml_registries1';
|
7 |
+
$this->_blockGroup = 'kartparadigm_storecredit';
|
8 |
+
$this->_headerText = Mage::helper('kartparadigm_storecredit')->__('Manage Customer Credits');
|
9 |
+
parent::__construct();
|
10 |
+
$this->_removeButton('add');
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Edit.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries1_Edit
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct(){
|
6 |
+
$data = array(
|
7 |
+
'label' => 'Back',
|
8 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/credits') . '\')',
|
9 |
+
'class' => 'back'
|
10 |
+
);
|
11 |
+
$this->addButton ('my_back', $data, 0, 100, 'header');
|
12 |
+
parent::__construct();
|
13 |
+
$this->_objectId = 'id';
|
14 |
+
$this->_blockGroup = 'kartparadigm_storecredit';
|
15 |
+
$this->_controller = 'adminhtml_registries1';
|
16 |
+
$this->_mode = 'edit';
|
17 |
+
$this->_removeButton('reset');
|
18 |
+
$this->_removeButton('back');
|
19 |
+
$this->_removeButton('delete');
|
20 |
+
$this->_removeButton('save');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getHeaderText(){
|
24 |
+
if(Mage::registry('registries_data') &&
|
25 |
+
Mage::registry('registries_data')->getId())
|
26 |
+
return Mage::helper('kartparadigm_storecredit')->__("Send Credits '%s'", $this->htmlEscape(Mage::registry('registries_data')->getTitle()));
|
27 |
+
return Mage::helper('kartparadigm_storecredit')->__('Transaction Information');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Edit/Form.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries1_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 |
+
'method' => 'post',
|
9 |
+
'enctype' => 'multipart/form-data'
|
10 |
+
));
|
11 |
+
$form->setUseContainer(true);
|
12 |
+
$this->setForm($form);
|
13 |
+
$data;
|
14 |
+
if (Mage::getSingleton('adminhtml/session')->getFormData()){
|
15 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData();
|
16 |
+
Mage::log($data);
|
17 |
+
Mage::getSingleton('adminhtml/session')->setFormData(null);
|
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_storecredit')->__('Credits information')));
|
22 |
+
|
23 |
+
$fieldset->addField('t_id', 'text', array(
|
24 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Transaction Id'),
|
25 |
+
'name'=> 'tid',
|
26 |
+
'disabled' => 'true',
|
27 |
+
'value' => $data['t_id'],
|
28 |
+
));
|
29 |
+
|
30 |
+
$fieldset->addField('action_credits', 'text', array(
|
31 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Credits Applaid'),
|
32 |
+
'name'=> 'credits',
|
33 |
+
'disabled' => 'true',
|
34 |
+
'value' => $data['action_credits'],
|
35 |
+
));
|
36 |
+
$fieldset->addField('total_credits', 'text', array(
|
37 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('current credits'),
|
38 |
+
'name'=> 'tcredits',
|
39 |
+
'disabled' => 'true',
|
40 |
+
'value' => $data['total_credits'],
|
41 |
+
));
|
42 |
+
$fieldset->addField('c_id', 'text', array(
|
43 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('customer Id'),
|
44 |
+
'name'=> 'cid',
|
45 |
+
'disabled' => 'true',
|
46 |
+
'value' => $data['c_id'],
|
47 |
+
));
|
48 |
+
$fieldset->addField('action', 'text', array(
|
49 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Action'),
|
50 |
+
'name'=> 'action',
|
51 |
+
'disabled' => 'true',
|
52 |
+
'value' => $data['action'],
|
53 |
+
));
|
54 |
+
$fieldset->addField('action_date', 'text', array(
|
55 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Transaction Date'),
|
56 |
+
'name'=> 'date',
|
57 |
+
'disabled' => 'true',
|
58 |
+
'value' => $data['action_date'],
|
59 |
+
));
|
60 |
+
$fieldset->addField('custom_msg', 'text', array(
|
61 |
+
'label' => Mage::helper('kartparadigm_storecredit')->__('Message'),
|
62 |
+
'name'=> 'message',
|
63 |
+
'disabled' => 'true',
|
64 |
+
'value' => $data['custom_msg'],
|
65 |
+
));
|
66 |
+
$form->setValues($data);
|
67 |
+
return parent::_prepareForm();
|
68 |
+
}
|
69 |
+
}
|
70 |
+
?>
|
app/code/community/Kartparadigm/StoreCredit/Block/Adminhtml/Registries1/Grid.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Adminhtml_Registries1_Grid
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('customerGrid');
|
9 |
+
$this->setUseAjax(true);
|
10 |
+
$this->setDefaultSort('entity_id');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
/*
|
17 |
+
|
18 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection();
|
19 |
+
$collection->getSelect()->columns(array('id' => 'MAX(t_id)'))->group(array('c_id'));
|
20 |
+
$collection->getSelect()->join(array('refer' => 'customer_entity'),'refer.entity_id = main_table.c_id');
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
*/
|
25 |
+
|
26 |
+
$collection1 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection();
|
27 |
+
$collection1->getSelect()->columns('MAX(t_id)')->group(array('c_id'));
|
28 |
+
//$select = $collection1->getSelect();
|
29 |
+
$arr1 = array();
|
30 |
+
$i = 0;
|
31 |
+
//if($collection1 > 0) {
|
32 |
+
foreach($collection1 as $s)
|
33 |
+
$arr1[$i++] = $s['MAX(t_id)'];
|
34 |
+
if(count($arr1) > 0) {
|
35 |
+
|
36 |
+
$collection = Mage::getModel('customer/customer')->getCollection()
|
37 |
+
->addNameToSelect()
|
38 |
+
->joinTable('kartparadigm_storecredit/creditinfo', 'c_id=entity_id', array('*'), "t_id IN (".implode(',',$arr1).")", 'right');
|
39 |
+
|
40 |
+
//$collection->joinAttribute('t_id', array('in' => $select))->group(array('c_id'));
|
41 |
+
$collection->getSelect()->columns('MAX(t_id) as t_id')->group(array('c_id'));
|
42 |
+
$collection->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
|
43 |
+
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
|
44 |
+
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
|
45 |
+
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
|
46 |
+
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
|
47 |
+
|
48 |
+
|
49 |
+
$this->setCollection($collection);
|
50 |
+
}
|
51 |
+
return parent::_prepareCollection();
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _prepareColumns()
|
55 |
+
{
|
56 |
+
$this->addColumn('entity_id', array(
|
57 |
+
'header' => Mage::helper('customer')->__('ID'),
|
58 |
+
'width' => '50px',
|
59 |
+
'index' => 'entity_id',
|
60 |
+
'type' => 'number',
|
61 |
+
));
|
62 |
+
/*$this->addColumn('firstname', array(
|
63 |
+
'header' => Mage::helper('customer')->__('First Name'),
|
64 |
+
'index' => 'firstname'
|
65 |
+
));
|
66 |
+
$this->addColumn('lastname', array(
|
67 |
+
'header' => Mage::helper('customer')->__('Last Name'),
|
68 |
+
'index' => 'lastname'
|
69 |
+
));*/
|
70 |
+
$this->addColumn('name', array(
|
71 |
+
'header' => Mage::helper('customer')->__('Name'),
|
72 |
+
'index' => 'name'
|
73 |
+
));
|
74 |
+
$this->addColumn('email', array(
|
75 |
+
'header' => Mage::helper('customer')->__('Email'),
|
76 |
+
'width' => '150',
|
77 |
+
'index' => 'email'
|
78 |
+
));
|
79 |
+
|
80 |
+
$groups = Mage::getResourceModel('customer/group_collection')
|
81 |
+
->addFieldToFilter('customer_group_id', array('gt'=> 0))
|
82 |
+
->load()
|
83 |
+
->toOptionHash();
|
84 |
+
|
85 |
+
/* $this->addColumn('group', array(
|
86 |
+
'header' => Mage::helper('customer')->__('Group'),
|
87 |
+
'width' => '100',
|
88 |
+
'index' => 'group_id',
|
89 |
+
'type' => 'options',
|
90 |
+
'options' => $groups,
|
91 |
+
));*/
|
92 |
+
|
93 |
+
$this->addColumn('Telephone', array(
|
94 |
+
'header' => Mage::helper('customer')->__('Telephone'),
|
95 |
+
'width' => '100',
|
96 |
+
'index' => 'billing_telephone'
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('billing_postcode', array(
|
100 |
+
'header' => Mage::helper('customer')->__('ZIP'),
|
101 |
+
'width' => '90',
|
102 |
+
'index' => 'billing_postcode',
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('billing_country_id', array(
|
106 |
+
'header' => Mage::helper('customer')->__('Country'),
|
107 |
+
'width' => '100',
|
108 |
+
'type' => 'country',
|
109 |
+
'index' => 'billing_country_id',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('billing_region', array(
|
113 |
+
'header' => Mage::helper('customer')->__('State/Province'),
|
114 |
+
'width' => '100',
|
115 |
+
'index' => 'billing_region',
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('customer_since', array(
|
119 |
+
'header' => Mage::helper('customer')->__('Customer Since'),
|
120 |
+
'type' => 'datetime',
|
121 |
+
'align' => 'center',
|
122 |
+
'index' => 'created_at',
|
123 |
+
'gmtoffset' => true
|
124 |
+
));
|
125 |
+
$model = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('t_id');
|
126 |
+
$this->addColumn('total_credits', array(
|
127 |
+
'header' => Mage::helper('customer')->__('current credits'),
|
128 |
+
'align' => 'center',
|
129 |
+
'index' => 'total_credits',
|
130 |
+
'gmtoffset' => true
|
131 |
+
));
|
132 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
133 |
+
$this->addColumn('website_id', array(
|
134 |
+
'header' => Mage::helper('customer')->__('Website'),
|
135 |
+
'align' => 'center',
|
136 |
+
'width' => '80px',
|
137 |
+
'type' => 'options',
|
138 |
+
'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
|
139 |
+
'index' => 'website_id',
|
140 |
+
));
|
141 |
+
}
|
142 |
+
|
143 |
+
$this->addColumn('action',
|
144 |
+
array(
|
145 |
+
'header' => Mage::helper('customer')->__('Action'),
|
146 |
+
'width' => '100',
|
147 |
+
'type' => 'action',
|
148 |
+
'getter' => 'getId',
|
149 |
+
'actions' => array(
|
150 |
+
array(
|
151 |
+
'caption' => Mage::helper('customer')->__('Edit'),
|
152 |
+
'url' => array('base'=> 'adminhtml/customer/edit'),
|
153 |
+
'field' => 'id'
|
154 |
+
)
|
155 |
+
),
|
156 |
+
'filter' => false,
|
157 |
+
'sortable' => false,
|
158 |
+
'index' => 'stores',
|
159 |
+
'is_system' => true,
|
160 |
+
));
|
161 |
+
|
162 |
+
$this->addExportType('adminhtml/customer/exportCsv', Mage::helper('customer')->__('CSV'));
|
163 |
+
$this->addExportType('adminhtml/customer/exportXml', Mage::helper('customer')->__('Excel XML'));
|
164 |
+
return parent::_prepareColumns();
|
165 |
+
}
|
166 |
+
|
167 |
+
protected function _prepareMassaction()
|
168 |
+
{
|
169 |
+
$this->setMassactionIdField('entity_id');
|
170 |
+
$this->getMassactionBlock()->setFormFieldName('customer');
|
171 |
+
|
172 |
+
|
173 |
+
$this->getMassactionBlock()->addItem('my_action', array(
|
174 |
+
'label' => Mage::helper('customer')->__('Send Credits'),
|
175 |
+
'url' => $this->getUrl('*/customer/sendCredits')
|
176 |
+
));
|
177 |
+
|
178 |
+
|
179 |
+
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
public function getGridUrl()
|
184 |
+
{
|
185 |
+
return $this->getUrl('*/*/grid', array('_current'=> true));
|
186 |
+
}
|
187 |
+
|
188 |
+
public function getRowUrl($row)
|
189 |
+
{
|
190 |
+
return $this->getUrl('adminhtml/customer/edit', array('id'=>$row->getId()));
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Collection.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Collection extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
9 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
10 |
+
$id = $customerData->getId();
|
11 |
+
|
12 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->setOrder('t_id','desc')->addFieldToFilter('website1','Main Website');
|
13 |
+
$this->setCollection($collection);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _prepareLayout()
|
18 |
+
{
|
19 |
+
parent::_prepareLayout();
|
20 |
+
|
21 |
+
$pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
|
22 |
+
$pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
|
23 |
+
$pager->setCollection($this->getCollection());
|
24 |
+
$this->setChild('pager', $pager);
|
25 |
+
$this->getCollection()->load();
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getPagerHtml()
|
30 |
+
{
|
31 |
+
return $this->getChildHtml('pager');
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
app/code/community/Kartparadigm/StoreCredit/Block/Credit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Block_Credit extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
|
6 |
+
public function displayCreditsOfProduct($pid)
|
7 |
+
{
|
8 |
+
//Mage::log($pid." is product id");
|
9 |
+
$t=time();
|
10 |
+
$wid = Mage::app()->getWebsite()->getId();
|
11 |
+
$cgId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
12 |
+
|
13 |
+
$model = Mage::getResourceModel('catalogrule/rule');
|
14 |
+
|
15 |
+
$id = $pid;
|
16 |
+
$rules = $model->getRulesFromProduct($t,$wid,$cgId,$id);
|
17 |
+
$credits = array();
|
18 |
+
$sort_order = array();
|
19 |
+
$i;
|
20 |
+
$totalCredits = 0;
|
21 |
+
foreach($rules as $rule)
|
22 |
+
{
|
23 |
+
// var_dump($rule);
|
24 |
+
|
25 |
+
$credits[$rule['sort_order']] = $rule['store_credit'];
|
26 |
+
|
27 |
+
//echo " Credits ". $rule['store_credit'] ." \t ";
|
28 |
+
if($rule['action_stop'] == 1)
|
29 |
+
$i = $rule['sort_order'];
|
30 |
+
|
31 |
+
}
|
32 |
+
ksort($credits);
|
33 |
+
|
34 |
+
foreach($credits as $key=>$sid)
|
35 |
+
{
|
36 |
+
if($key == $i){
|
37 |
+
$totalCredits += $sid;;
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
$totalCredits += $sid;;
|
41 |
+
}
|
42 |
+
//Mage::log("total Credits of the product " . $totalCredits);
|
43 |
+
return $totalCredits;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Helper/Data.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Helper_Data extends
|
3 |
+
Mage_Core_Helper_Abstract {
|
4 |
+
public function getIsEnabled(){
|
5 |
+
return Mage::getStoreConfigFlag('mycustom_section/mycustom_group2/field1'); //replace section & group with appropriate values.
|
6 |
+
}
|
7 |
+
public function getTaxEnabled(){
|
8 |
+
return Mage::getStoreConfigFlag('mycustom_section/mycustom_group/field1'); //replace section & group with appropriate values.
|
9 |
+
}
|
10 |
+
public function getIsShippingEnabled(){
|
11 |
+
return Mage::getStoreConfigFlag('mycustom_section/mycustom_group/field2'); //replace section & group with appropriate values.
|
12 |
+
}
|
13 |
+
public function getRefundDeductConfig(){
|
14 |
+
return Mage::getStoreConfigFlag('mycustom_section/mycustom_group/field3'); //replace section & group with appropriate values.
|
15 |
+
}
|
16 |
+
public function getCreditRates(){
|
17 |
+
$arr = array();
|
18 |
+
$arr['credits'] = Mage::getStoreConfig('mycustom_section/mycustom_group4/field1');
|
19 |
+
$arr['basevalue'] = Mage::getStoreConfig('mycustom_section/mycustom_group4/field2');
|
20 |
+
return $arr;
|
21 |
+
}
|
22 |
+
public function getCredits($product)
|
23 |
+
{
|
24 |
+
if(Mage::getStoreConfigFlag('mycustom_section/mycustom_group2/field1')){
|
25 |
+
$t=time();
|
26 |
+
$wid = Mage::app()->getWebsite()->getId();
|
27 |
+
$cgId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
28 |
+
|
29 |
+
$model = Mage::getResourceModel('catalogrule/rule');
|
30 |
+
|
31 |
+
$id = $product->getId();
|
32 |
+
$rules = $model->getRulesFromProduct($t,$wid,$cgId,$id);
|
33 |
+
$credits = array();
|
34 |
+
$sort_order = array();
|
35 |
+
$si;
|
36 |
+
foreach($rules as $rule)
|
37 |
+
{
|
38 |
+
// var_dump($rule);
|
39 |
+
|
40 |
+
$credits[$rule['sort_order']] = $rule['store_credit'];
|
41 |
+
|
42 |
+
//echo " Credits ". $rule['store_credit'] ." \t ";
|
43 |
+
if($rule['action_stop'] == 1)
|
44 |
+
$si = $rule['sort_order'];
|
45 |
+
|
46 |
+
}
|
47 |
+
ksort($credits);
|
48 |
+
$totalCredits=0;
|
49 |
+
foreach($credits as $key=>$sid)
|
50 |
+
{
|
51 |
+
if($key == $si){
|
52 |
+
$totalCredits += $sid;;
|
53 |
+
break;
|
54 |
+
}
|
55 |
+
$totalCredits += $sid;;
|
56 |
+
}
|
57 |
+
return $totalCredits;
|
58 |
+
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
app/code/community/Kartparadigm/StoreCredit/Model/Creditinfo.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Creditinfo extends
|
3 |
+
Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/creditinfo');
|
8 |
+
parent::_construct();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getWebsites() {
|
12 |
+
$site = Mage::getResourceModel('core/website_collection');
|
13 |
+
$websites = array();
|
14 |
+
$i = 0;
|
15 |
+
foreach($site as $s)
|
16 |
+
$websites[ $i++ ] = $s['name'];
|
17 |
+
|
18 |
+
return $websites;
|
19 |
+
|
20 |
+
}
|
21 |
+
public function getStoreviews() {
|
22 |
+
$_storeName = array();
|
23 |
+
$i=0;
|
24 |
+
$site = Mage::app()->getWebsites();
|
25 |
+
foreach($site as $s){
|
26 |
+
$allStores = $s->getStoreIds();
|
27 |
+
foreach ($allStores as $_eachStoreId => $val)
|
28 |
+
{
|
29 |
+
$_storeName[Mage::app()->getStore($_eachStoreId)->getName()] = Mage::app()->getStore($_eachStoreId)->getName();
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
return $_storeName;
|
34 |
+
}
|
35 |
+
|
36 |
+
/*-------------------------------------------Return the credits Of the product to the observer-------------------------------------*/
|
37 |
+
|
38 |
+
public function getCreditsOfProduct($pid)
|
39 |
+
{
|
40 |
+
//Mage::log($pid." is product id");
|
41 |
+
$t=time();
|
42 |
+
$wid = Mage::app()->getWebsite()->getId();
|
43 |
+
$cgId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
44 |
+
|
45 |
+
$model = Mage::getResourceModel('catalogrule/rule');
|
46 |
+
|
47 |
+
$id = $pid;
|
48 |
+
$rules = $model->getRulesFromProduct($t,$wid,$cgId,$id);
|
49 |
+
$credits = array();
|
50 |
+
$sort_order = array();
|
51 |
+
$i;
|
52 |
+
$totalCredits = 0;
|
53 |
+
foreach($rules as $rule)
|
54 |
+
{
|
55 |
+
// var_dump($rule);
|
56 |
+
|
57 |
+
$credits[$rule['sort_order']] = $rule['store_credit'];
|
58 |
+
|
59 |
+
//echo " Credits ". $rule['store_credit'] ." \t ";
|
60 |
+
if($rule['action_stop'] == 1)
|
61 |
+
$i = $rule['sort_order'];
|
62 |
+
|
63 |
+
}
|
64 |
+
ksort($credits);
|
65 |
+
|
66 |
+
foreach($credits as $key=>$sid)
|
67 |
+
{
|
68 |
+
if($key == $i){
|
69 |
+
$totalCredits += $sid;;
|
70 |
+
break;
|
71 |
+
}
|
72 |
+
$totalCredits += $sid;;
|
73 |
+
}
|
74 |
+
//Mage::log("total Credits of the product " . $totalCredits);
|
75 |
+
return $totalCredits;
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Creditinfo.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Mysql4_Creditinfo extends
|
3 |
+
Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/creditinfo', 't_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Creditinfo/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Mysql4_Creditinfo_Collection extends
|
3 |
+
Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/creditinfo');
|
8 |
+
parent::_construct();
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Sendcreditstofriend.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Mysql4_Sendcreditstofriend extends
|
3 |
+
Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/sendcreditstofriend', 'receiver_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Mysql4/Sendcreditstofriend/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Mysql4_Sendcreditstofriend_Collection extends
|
3 |
+
Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/sendcreditstofriend');
|
8 |
+
parent::_construct();
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Observer.php
ADDED
@@ -0,0 +1,688 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Observer
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Exports an order after it is placed
|
6 |
+
*
|
7 |
+
* @param Varien_Event_Observer $observer observer object
|
8 |
+
*
|
9 |
+
* @return boolean
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
public function set_credits_discountamount($observer)
|
15 |
+
{
|
16 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
17 |
+
//Mage::log(Mage::helper('kartparadigm_storecredit')->getRefundDeductConfig() . " configuration settings ");
|
18 |
+
Mage::log($array2);
|
19 |
+
$session = Mage::getSingleton('checkout/session');
|
20 |
+
if(Mage::helper('customer')->isLoggedIn()) {
|
21 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
22 |
+
$customer_group=Mage::getModel('customer/group')->load(Mage::getSingleton('customer/session')->getCustomerGroupId())->getCustomerGroupCode();
|
23 |
+
}
|
24 |
+
|
25 |
+
$val1 = Mage::getSingleton('adminhtml/session')->getValue();
|
26 |
+
if(isset($val1))
|
27 |
+
{
|
28 |
+
$amt = Mage::getSingleton('checkout/session')->getCredits()['totalCredits'];
|
29 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
30 |
+
}
|
31 |
+
else{
|
32 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
33 |
+
$amt = Mage::getSingleton('checkout/session')->getCredits()['discountCredits'];
|
34 |
+
}
|
35 |
+
$isvirtual=0;
|
36 |
+
foreach($quote->getAllItems() as $item){
|
37 |
+
if($item->getIsVirtual()==1) {
|
38 |
+
$isvirtual=1;
|
39 |
+
}
|
40 |
+
if(Mage::getModel('catalog/product')->load($item->getProductId())->getTypeId()=='customproduct'){
|
41 |
+
$isvirtual=1;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
$total=$quote->getGrandTotal();
|
45 |
+
|
46 |
+
$subTotal = $quote->getSubtotal();
|
47 |
+
//Mage::log($quote->getGrandTotal()."this is grand total");
|
48 |
+
//Mage::log($quote->getSubtotal()."this is sub total");
|
49 |
+
|
50 |
+
if (!Mage::helper('kartparadigm_storecredit')->getTaxEnabled()){
|
51 |
+
$tax = $quote->getShippingAddress()->getData('tax_amount');
|
52 |
+
}
|
53 |
+
if(!Mage::helper('kartparadigm_storecredit')->getIsShippingEnabled()){
|
54 |
+
$shippingPrice = $quote->getShippingAddress()->getShippingAmount();
|
55 |
+
}
|
56 |
+
$totalCredits = Mage::getSingleton('checkout/session')->getCredits()['totalCredits'];
|
57 |
+
|
58 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
59 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp);
|
60 |
+
//echo $expirydate;
|
61 |
+
//echo $nowdate;
|
62 |
+
$balance;
|
63 |
+
//echo $amt;
|
64 |
+
$amt2;
|
65 |
+
$amt1;
|
66 |
+
|
67 |
+
|
68 |
+
if(isset($amt)){
|
69 |
+
/*---------------------Calculating Default Currency Value----------------------- */
|
70 |
+
$amt1 = ($array2['basevalue'] * $amt) / $array2['credits'];
|
71 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
72 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
73 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
74 |
+
$amt2 = Mage::helper('directory')->currencyConvert($amt1, $baseCurrencyCode, $currentCurrencyCode);
|
75 |
+
}
|
76 |
+
else{
|
77 |
+
$amt2 = $amt1;
|
78 |
+
}
|
79 |
+
// $amt2 = Mage::helper('core')->currency($amt1, true, false);
|
80 |
+
//Mage::log($amt1." = amount = ".$amt2 );
|
81 |
+
//----------------------------------------------------------------
|
82 |
+
if($total > $amt2) {
|
83 |
+
if(($total - $tax - $shippingPrice) > $amt2){
|
84 |
+
$discountAmount = $amt2;
|
85 |
+
$balance = $totalCredits - $amt;
|
86 |
+
}else{
|
87 |
+
$discountAmount = $subTotal;
|
88 |
+
$points = round(($discountAmount * $amt)/$amt2);
|
89 |
+
//Mage::log($points."Conver Points");
|
90 |
+
$balance = $totalCredits - $points;
|
91 |
+
}
|
92 |
+
}
|
93 |
+
else {
|
94 |
+
$discountAmount = $total - $tax - $shippingPrice;
|
95 |
+
$points = round(($discountAmount * $amt)/$amt2);
|
96 |
+
//Mage::log($points."Conver Points");
|
97 |
+
$balance = $totalCredits - $points;
|
98 |
+
}
|
99 |
+
Mage::getSingleton('core/session')->setBalance($balance);
|
100 |
+
|
101 |
+
Mage::getSingleton('checkout/session')->setDiscount($totalCredits - $balance);
|
102 |
+
$msg = "Current Credits In Your Account : " . $balance;
|
103 |
+
Mage::getSingleton('core/session')->setCredits($msg);
|
104 |
+
if ($discountAmount > 0) {
|
105 |
+
|
106 |
+
|
107 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
108 |
+
|
109 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
110 |
+
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
111 |
+
|
112 |
+
$baseDiscount = $discountAmount/$rates[$currentCurrencyCode];
|
113 |
+
|
114 |
+
}
|
115 |
+
else{
|
116 |
+
$baseDiscount = $discountAmount;
|
117 |
+
}
|
118 |
+
$total = $quote->getBaseSubtotal();
|
119 |
+
$quote->setSubtotal(0);
|
120 |
+
$quote->setBaseSubtotal(0);
|
121 |
+
$quote->setSubtotalWithDiscount(0);
|
122 |
+
$quote->setBaseSubtotalWithDiscount(0);
|
123 |
+
$quote->setGrandTotal(0);
|
124 |
+
$quote->setBaseGrandTotal(0);
|
125 |
+
$canAddItems = $quote->isVirtual() ? ('billing') : ('shipping');
|
126 |
+
foreach($quote->getAllAddresses() as $address) {
|
127 |
+
$address->setSubtotal(0);
|
128 |
+
$address->setBaseSubtotal(0);
|
129 |
+
$address->setGrandTotal(0);
|
130 |
+
$address->setBaseGrandTotal(0);
|
131 |
+
$address->collectTotals();
|
132 |
+
$quote->setSubtotal((float)$quote->getSubtotal() + $address->getSubtotal());
|
133 |
+
$quote->setBaseSubtotal((float)$quote->getBaseSubtotal() + $address->getBaseSubtotal());
|
134 |
+
$quote->setSubtotalWithDiscount((float)$quote->getSubtotalWithDiscount() + $address->getSubtotalWithDiscount());
|
135 |
+
$quote->setBaseSubtotalWithDiscount((float)$quote->getBaseSubtotalWithDiscount() + $address->getBaseSubtotalWithDiscount());
|
136 |
+
$quote->setGrandTotal((float)$quote->getGrandTotal() + $address->getGrandTotal());
|
137 |
+
$quote->setBaseGrandTotal((float)$quote->getBaseGrandTotal() + $address->getBaseGrandTotal());
|
138 |
+
$quote->save();
|
139 |
+
$quote->setSubtotalWithDiscount($quote->getSubtotal() - $discountAmount)->setBaseSubtotalWithDiscount($quote->getBaseSubtotal() - $baseDiscount)->save();
|
140 |
+
if ($address->getAddressType() == $canAddItems) {
|
141 |
+
$address->setSubtotalWithDiscount((float)$address->getSubtotalWithDiscount() - $discountAmount);
|
142 |
+
$address->setGrandTotal((float)$address->getGrandTotal() - $discountAmount);
|
143 |
+
$address->setBaseSubtotalWithDiscount((float)$address->getBaseSubtotalWithDiscount() - $baseDiscount);
|
144 |
+
$address->setBaseGrandTotal((float)$address->getBaseGrandTotal() - $baseDiscount);
|
145 |
+
if ($address->getDiscountDescription()) {
|
146 |
+
$address->setDiscountAmount(-($address->getDiscountAmount() - $discountAmount));
|
147 |
+
$address->setDiscountDescription($address->getDiscountDescription() . ', Store Credits');
|
148 |
+
|
149 |
+
$address->setBaseDiscountAmount(-($address->getBaseDiscountAmount() - $baseDiscount));
|
150 |
+
}
|
151 |
+
else {
|
152 |
+
$address->setDiscountAmount(-($discountAmount));
|
153 |
+
$address->setDiscountDescription('Store Credits');
|
154 |
+
$address->setBaseDiscountAmount(-($baseDiscount));
|
155 |
+
}
|
156 |
+
$address->save();
|
157 |
+
}
|
158 |
+
}
|
159 |
+
foreach($quote->getAllItems() as $item) {
|
160 |
+
|
161 |
+
// We apply discount amount based on the ratio between the GrandTotal and the RowTotal
|
162 |
+
$rat = $item->getPriceInclTax() / $quote->getSubtotal();
|
163 |
+
$rat1 = $item->getBasePriceInclTax() / $quote->getBaseSubtotal();
|
164 |
+
$ratdisc = $discountAmount * $rat;
|
165 |
+
$ratdisc1 = $baseDiscount * $rat1;
|
166 |
+
//Mage::log($item->getDiscountAmount()."include tax".$item->getBaseDiscountAmount());
|
167 |
+
$item->setDiscountAmount(($item->getDiscountAmount() + $ratdisc) * $item->getQty());
|
168 |
+
$item->setBaseDiscountAmount(($item->getBaseDiscountAmount() + $ratdisc1) * $item->getQty())->save();
|
169 |
+
}
|
170 |
+
}else if($totalCredits == 0){
|
171 |
+
|
172 |
+
$msg = "Sorry You Have No Credits In Your Account";
|
173 |
+
Mage::getSingleton('core/session')->setCredits($msg);
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
/*-----------------------------------------------------After checkout Inserting data into table --------------------------- */
|
181 |
+
|
182 |
+
public function debitOrder(Varien_Event_Observer $observer)
|
183 |
+
{
|
184 |
+
|
185 |
+
try {
|
186 |
+
$arr = array();
|
187 |
+
$id = Mage::getModel("sales/order")->getCollection()->getLastItem()->getIncrementId();
|
188 |
+
|
189 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($id);
|
190 |
+
$_grand = $order->getGrandTotal();
|
191 |
+
$custname = $order->getCustomerName();
|
192 |
+
//echo "<br> cumstomer id :".$order->getCustomerId();
|
193 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
194 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp);
|
195 |
+
$amt =Mage::getSingleton('checkout/session')->getDiscount();
|
196 |
+
$totalCredits = Mage::getSingleton('checkout/session')->getCredits()['totalCredits'];
|
197 |
+
|
198 |
+
$balance = Mage::getSingleton('core/session')->getBalance();
|
199 |
+
$arr['c_id'] = $order->getCustomerId();
|
200 |
+
$arr['action_credits'] = - $amt;
|
201 |
+
$arr['total_credits'] = $balance;
|
202 |
+
$arr['store_view'] = Mage::app()->getStore()->getName();
|
203 |
+
$arr['state'] = 1;
|
204 |
+
$arr['order_id'] = $id;
|
205 |
+
$arr['action'] = "Used";
|
206 |
+
$arr['custom_msg'] = "By User:Using For Order " . $arr['order_id'];
|
207 |
+
$arr['customer_notification_status'] = 'Notified';
|
208 |
+
$arr['action_date'] = $nowdate;
|
209 |
+
$arr['website1'] = "Main Website";
|
210 |
+
|
211 |
+
if($amt > 0) {
|
212 |
+
$credits = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
213 |
+
|
214 |
+
$model = Mage::getModel('kartparadigm_storecredit/creditinfo')->setData($arr);
|
215 |
+
|
216 |
+
try{
|
217 |
+
|
218 |
+
$model->save();
|
219 |
+
}
|
220 |
+
catch(Exception $e)
|
221 |
+
{
|
222 |
+
|
223 |
+
echo $e->getMessage();
|
224 |
+
}
|
225 |
+
|
226 |
+
$successMessage = Mage::helper('kartparadigm_storecredit')->__('Credits Inserted Successfully');
|
227 |
+
Mage::getSingleton('core/session')->addSuccess($successMessage);
|
228 |
+
|
229 |
+
|
230 |
+
|
231 |
+
}else{
|
232 |
+
//throw new Exception("Insufficient Data provided");
|
233 |
+
}
|
234 |
+
|
235 |
+
} catch (Mage_Core_Exception $e) {
|
236 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
237 |
+
$this->_redirectUrl($this->_getRefererUrl());
|
238 |
+
}
|
239 |
+
|
240 |
+
Mage::getSingleton('checkout/session')->unsCredits();
|
241 |
+
Mage::getSingleton('core/session')->unsBalance();
|
242 |
+
Mage::getSingleton('core/session')->unsCredits();
|
243 |
+
Mage::getSingleton('adminhtml/session')->unsValue();
|
244 |
+
Mage::getSingleton('checkout/session')->unsDiscount();
|
245 |
+
|
246 |
+
}
|
247 |
+
/* --------------------------------------------------- Refund The Credits To Customer Account --------------------------------- */
|
248 |
+
|
249 |
+
public function addCredits($observer)
|
250 |
+
{
|
251 |
+
|
252 |
+
$creditmemo = $observer->getCreditmemo();
|
253 |
+
//Mage::log($creditmemo);
|
254 |
+
//Mage::log($creditmemo->getBaseGrandTotal());
|
255 |
+
$order = $creditmemo->getOrder();
|
256 |
+
//Mage::log($order);
|
257 |
+
$store_id = $order->getStoreId();
|
258 |
+
$website_id = Mage::getModel('core/store')->load($store_id)->getWebsiteId();
|
259 |
+
$website = Mage::app()->getWebsite($website_id);
|
260 |
+
//Mage::log( $website->getName());
|
261 |
+
$sName = Mage::app()->getStore($store_id)->getName();
|
262 |
+
//Mage::log( $sid);
|
263 |
+
//Mage::log(Mage::getSingleton('adminhtml/session')->getTotal()['status']);
|
264 |
+
|
265 |
+
|
266 |
+
if (Mage::helper('kartparadigm_storecredit')->getRefundDeductConfig())
|
267 |
+
{
|
268 |
+
// Deduct the credits which are gained at the time of invoice
|
269 |
+
|
270 |
+
$credits = array();
|
271 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
272 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp);
|
273 |
+
$credits['c_id'] = $order->getCustomerId();
|
274 |
+
$credits['order_id'] = $order->getIncrementId();
|
275 |
+
$credits['website1'] = 'Main Website';
|
276 |
+
$credits['store_view'] = $sName;
|
277 |
+
$credits['action_date'] = $nowdate;
|
278 |
+
$credits['action'] = "Deducted";
|
279 |
+
$credits['customer_notification_status'] = 'Notified';
|
280 |
+
$credits['state'] = 1;
|
281 |
+
//$credits['custom_msg'] = 'By admin : Deducted the Credits of the Order ' . $credits['order_id'] ;
|
282 |
+
|
283 |
+
foreach ($creditmemo->getAllItems() as $item) {
|
284 |
+
$orderItem = Mage::getResourceModel('sales/order_item_collection');
|
285 |
+
$orderItem->addIdFilter($item->getOrderItemId());
|
286 |
+
$data = $orderItem->getData();
|
287 |
+
|
288 |
+
//Mage::log($data);
|
289 |
+
$credits['action_credits'] = - ($data[0]['credits'] * $item->getQty());
|
290 |
+
|
291 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$order->getCustomerId())->addFieldToFilter('website1','Main Website')->getLastItem();
|
292 |
+
|
293 |
+
$totalcredits = $collection->getTotalCredits();
|
294 |
+
$credits['total_credits'] = $totalcredits + $credits['action_credits'] ;
|
295 |
+
$credits['custom_msg'] = "By User:For Return The Product " .$item->getName()." For Quantity " . round($item->getQty()) ; //Custom Message
|
296 |
+
$credits['item_id'] = $item->getOrderItemId();
|
297 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
298 |
+
$table1->setData($credits);
|
299 |
+
try{
|
300 |
+
if($credits['action_credits'] != 0)
|
301 |
+
$table1->save();
|
302 |
+
}catch(Exception $e){
|
303 |
+
Mage::log($e);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
// End Deduct the credits which are gained at the time of invoice
|
308 |
+
|
309 |
+
}
|
310 |
+
//end
|
311 |
+
if(Mage::getSingleton('adminhtml/session')->getTotal()['status'] == 1)
|
312 |
+
{
|
313 |
+
|
314 |
+
$val = array();
|
315 |
+
|
316 |
+
|
317 |
+
$val['c_id'] = $order->getCustomerId();
|
318 |
+
|
319 |
+
$val['order_id'] = $order->getIncrementId();
|
320 |
+
|
321 |
+
$val['website1'] = $website->getName();
|
322 |
+
|
323 |
+
$val['store_view'] = $sName;
|
324 |
+
|
325 |
+
|
326 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$val['c_id'])->addFieldToFilter('website1',$val['website1'])->getLastItem();
|
327 |
+
|
328 |
+
|
329 |
+
$currentCurrencyRefund = Mage::getSingleton('adminhtml/session')->getTotal()['credits'];
|
330 |
+
/*------------------------Convert Current currency(refunded amount is current currency) to credit points-------------- */
|
331 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
332 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
333 |
+
$baseCurrency;
|
334 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
335 |
+
|
336 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
337 |
+
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
338 |
+
|
339 |
+
$baseCurrency = $currentCurrencyRefund/$rates[$currentCurrencyCode];
|
340 |
+
|
341 |
+
}
|
342 |
+
else{
|
343 |
+
$baseCurrency = $currentCurrencyRefund;
|
344 |
+
}
|
345 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
346 |
+
//$amt1 = ($array2['basevalue'] * $amt) / $array2['credits'];
|
347 |
+
if(isset($array2)){
|
348 |
+
$refundCredits = round(($array2['credits'] * $baseCurrency) / $array2['basevalue']);
|
349 |
+
}
|
350 |
+
else{
|
351 |
+
$refundCredits = round($baseCurrency);
|
352 |
+
}
|
353 |
+
/*---------------------end------------------ */
|
354 |
+
$val['action_credits'] = $refundCredits;
|
355 |
+
$val['total_credits'] = $collection->getTotalCredits() + $refundCredits;
|
356 |
+
$val['action_date'] = $nowdate;
|
357 |
+
$val['action'] = "Refunded";
|
358 |
+
$val['custom_msg'] = 'By admin : return product by customer to the order ' . $val['order_id'] ;
|
359 |
+
$val['customer_notification_status'] = 'Notified';
|
360 |
+
$val['state'] = 0;
|
361 |
+
//Mage::getSingleton('adminhtml/session')->unsTotal();
|
362 |
+
$model = Mage::getSingleton('kartparadigm_storecredit/creditinfo');
|
363 |
+
//Mage::log($creditmemo->getDiscountAmount());
|
364 |
+
//Mage::log($creditmemo->getDiscountDescription());
|
365 |
+
//checking
|
366 |
+
if($creditmemo->getDiscountDescription() == "Store Credits"){
|
367 |
+
$total = $creditmemo->getGrandTotal() - ($creditmemo->getDiscountAmount());
|
368 |
+
}
|
369 |
+
else{
|
370 |
+
$total = $creditmemo->getGrandTotal();
|
371 |
+
}
|
372 |
+
$model->setData($val);
|
373 |
+
try{
|
374 |
+
if($total >= $currentCurrencyRefund){
|
375 |
+
if( $currentCurrencyRefund > 0)
|
376 |
+
{
|
377 |
+
|
378 |
+
$model->save();
|
379 |
+
|
380 |
+
}
|
381 |
+
}
|
382 |
+
else{
|
383 |
+
|
384 |
+
Mage::getSingleton('adminhtml/session')->setErr('true');
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
} catch(Mage_Core_Exception $e){
|
389 |
+
//Mage::log($e);
|
390 |
+
}
|
391 |
+
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
/*-----------------------------------------------------Unset Existing Sessions--------------------------- */
|
396 |
+
|
397 |
+
public function unset_session_inreorder(Varien_Event_Observer $observer)
|
398 |
+
{
|
399 |
+
|
400 |
+
$value = Mage::getSingleton('checkout/session')->getCredits();
|
401 |
+
if(isset($value)){
|
402 |
+
Mage::getSingleton('checkout/session')->unsCredits();
|
403 |
+
Mage::getSingleton('core/session')->unsBalance();
|
404 |
+
Mage::getSingleton('core/session')->unsCredits();
|
405 |
+
Mage::getSingleton('adminhtml/session')->unsValue();
|
406 |
+
Mage::getSingleton('checkout/session')->unsDiscount();
|
407 |
+
|
408 |
+
}
|
409 |
+
}
|
410 |
+
/*----------------------------------------------- end ------------------------------------ */
|
411 |
+
/*--------------------------------------------------- Event At The Time Of Login ------------------------------------------------*/
|
412 |
+
public function assigncredits(Varien_Event_Observer $observer)
|
413 |
+
{
|
414 |
+
$customer = $observer->getCustomer();
|
415 |
+
$arr = array();
|
416 |
+
$arr1 = array();
|
417 |
+
//Mage::log($customer->getEmail());
|
418 |
+
//Mage::log($customer->getId()."customer id");
|
419 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
420 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp); //current data
|
421 |
+
$collection = Mage::getModel('kartparadigm_storecredit/sendcreditstofriend')->getCollection()->addFieldToFilter('receiver_email',$customer->getEmail())->addFieldToFilter('status',0); //retriving values from sendcreditstofriend
|
422 |
+
//Mage::log(count($collection));
|
423 |
+
$arr = array();
|
424 |
+
if(count($collection) > 0){
|
425 |
+
foreach($collection as $col){
|
426 |
+
//Mage::log($col['s_id']."sender id");
|
427 |
+
if($col['status'] == 0){
|
428 |
+
|
429 |
+
$arr1['c_id'] = $customer->getId();
|
430 |
+
$arr1['website1'] = "Main Website";
|
431 |
+
$arr1['action_credits'] = $col['credits'];
|
432 |
+
$arr1['total_credits'] = $col['credits'];
|
433 |
+
$arr1['action'] = "Updated";
|
434 |
+
$arr1['state'] = 0;
|
435 |
+
$arr1['store_view'] = Mage::app()->getStore()->getName();
|
436 |
+
$arr1['action_date'] = $nowdate;
|
437 |
+
$arr1['custom_msg'] = "Send By : " . $col['sname']." Message( ".$col['message']." )";
|
438 |
+
$arr1['customer_notification_status'] = 'No';
|
439 |
+
|
440 |
+
$arr['status'] = 1;
|
441 |
+
|
442 |
+
$id = $col['receiver_id'];
|
443 |
+
|
444 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
445 |
+
$table1->setData($arr1);
|
446 |
+
|
447 |
+
$table2 = Mage::getModel('kartparadigm_storecredit/sendcreditstofriend')->load($id)->addData($arr);
|
448 |
+
|
449 |
+
/*-------------------------------------------------------------------------------------*/
|
450 |
+
try{
|
451 |
+
|
452 |
+
$table1->save();
|
453 |
+
$table2->setId($id)->save();
|
454 |
+
//$this->_redirect('*/*/');
|
455 |
+
|
456 |
+
}catch(Exception $e){
|
457 |
+
Mage::log($e);
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
|
462 |
+
}//end if
|
463 |
+
}//end foreach
|
464 |
+
}//end if
|
465 |
+
}
|
466 |
+
|
467 |
+
|
468 |
+
|
469 |
+
/*-----------------------------------Save Store Credit in Cart ---------------------------------------------*/
|
470 |
+
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
|
471 |
+
{
|
472 |
+
// set the additional options on the product
|
473 |
+
if(Mage::getStoreConfigFlag('mycustom_section/mycustom_group2/field1')){
|
474 |
+
$action = Mage::app()->getFrontController()->getAction();
|
475 |
+
if ($action->getFullActionName() == 'checkout_cart_add')
|
476 |
+
{
|
477 |
+
|
478 |
+
|
479 |
+
$product = $observer->getProduct();
|
480 |
+
// Mage::log($product);
|
481 |
+
|
482 |
+
$totalCredits = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCreditsOfProduct($product->getId());
|
483 |
+
|
484 |
+
if($totalCredits > 0) {
|
485 |
+
|
486 |
+
// if ($options = $action->getRequest()->getParam('extra_option'))
|
487 |
+
//{
|
488 |
+
//$product = $observer->getProduct();
|
489 |
+
// Mage::log($product);
|
490 |
+
|
491 |
+
// add to the additional options array
|
492 |
+
$additionalOptions = array();
|
493 |
+
if ($additionalOption = $product->getCustomOption('additional_options'))
|
494 |
+
{
|
495 |
+
$additionalOptions = (array) unserialize($additionalOption->getValue());
|
496 |
+
}
|
497 |
+
|
498 |
+
|
499 |
+
$additionalOptions[] = array(
|
500 |
+
'label' => "Credits",
|
501 |
+
'value' => $totalCredits,
|
502 |
+
);
|
503 |
+
|
504 |
+
|
505 |
+
// add the additional options array with the option code additional_options
|
506 |
+
$observer->getProduct()
|
507 |
+
->addCustomOption('additional_options', serialize($additionalOptions));
|
508 |
+
//}
|
509 |
+
}
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
/*-----------------------------------Save Store Credit in the Order ---------------------------------------------*/
|
514 |
+
public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
|
515 |
+
{
|
516 |
+
$quoteItem = $observer->getItem();
|
517 |
+
if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
|
518 |
+
$orderItem = $observer->getOrderItem();
|
519 |
+
$options = $orderItem->getProductOptions();
|
520 |
+
$options['additional_options'] = unserialize($additionalOptions->getValue());
|
521 |
+
$var;
|
522 |
+
if (count($options['additional_options'] > 0)) {
|
523 |
+
if ($options['additional_options'][0]['value'] != '')
|
524 |
+
$i = 0;
|
525 |
+
$val = $options['additional_options'][0]['value'];
|
526 |
+
|
527 |
+
}
|
528 |
+
//Mage::log($val." trgy");
|
529 |
+
$orderItem->setCredits($val);
|
530 |
+
$orderItem->setProductOptions($options);
|
531 |
+
}
|
532 |
+
|
533 |
+
}
|
534 |
+
/*--------------------------------Add Credit to the Customer Storecredit -------------------------------------- */
|
535 |
+
|
536 |
+
|
537 |
+
public function getCustomOptionsOfProduct(Varien_Event_Observer $observer)
|
538 |
+
{
|
539 |
+
$invoice = $observer->getEvent()->getInvoice();
|
540 |
+
$invoidData = $invoice->getData();
|
541 |
+
//Mage::log($invoidData);
|
542 |
+
$orderId = $invoidData['order_id'];
|
543 |
+
$cid = $invoidData['customer_id'];
|
544 |
+
$order1 = Mage::getModel('sales/order')->load($orderId);
|
545 |
+
$Incrementid = $order1->getIncrementId();
|
546 |
+
//Mage::log( $Incrementid."Order Id");
|
547 |
+
|
548 |
+
// Assign Field To Inset Into CreditInfo Table
|
549 |
+
|
550 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
551 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp); // Current TimeStamp
|
552 |
+
|
553 |
+
$arr['c_id'] = $cid;//Customer Id
|
554 |
+
$arr['store_view'] = Mage::app()->getStore()->getName(); //Storeview
|
555 |
+
$arr['state'] = 1; //State Of Transaction
|
556 |
+
$arr['order_id'] = $Incrementid; //OrderId
|
557 |
+
$arr['action'] = "Crdits"; //Action
|
558 |
+
$arr['customer_notification_status'] = 'Notified'; //Email Sending Status
|
559 |
+
$arr['action_date'] = $nowdate; //Current TimeStamp
|
560 |
+
$arr['website1'] = "Main Website"; //Website
|
561 |
+
|
562 |
+
foreach ($invoice->getAllItems() as $item) {
|
563 |
+
|
564 |
+
//Mage::log($item->getQty()."Item Quntity");
|
565 |
+
|
566 |
+
$orderItem = Mage::getResourceModel('sales/order_item_collection');
|
567 |
+
$orderItem->addIdFilter($item->getOrderItemId());
|
568 |
+
$data = $orderItem->getData();
|
569 |
+
$arr['action_credits'] = $data[0]['credits'] * $item->getQty();
|
570 |
+
|
571 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$cid)->addFieldToFilter('website1','Main Website')->getLastItem();
|
572 |
+
|
573 |
+
$totalcredits = $collection->getTotalCredits();
|
574 |
+
$arr['total_credits'] = $arr['action_credits'] + $totalcredits;
|
575 |
+
$arr['custom_msg'] = "By User:For Purchage The Product " .$item->getName()." For Quantity " . round($item->getQty()) ; //Custom Message
|
576 |
+
$arr['item_id'] = $item->getOrderItemId();
|
577 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
578 |
+
$table1->setData($arr);
|
579 |
+
try{
|
580 |
+
if($arr['action_credits'] > 0)
|
581 |
+
$table1->save();
|
582 |
+
|
583 |
+
}catch(Exception $e){
|
584 |
+
Mage::log($e);
|
585 |
+
}
|
586 |
+
|
587 |
+
}//end Foreach
|
588 |
+
|
589 |
+
|
590 |
+
|
591 |
+
}
|
592 |
+
/* -------------------------------AddCancelOrderCreditToCustomerAccount---------------------------------------------- */
|
593 |
+
public function addCancelOrderCredits(Varien_Event_Observer $observer)
|
594 |
+
{
|
595 |
+
$arr = array();
|
596 |
+
$item = $observer->getEvent()->getItem();
|
597 |
+
Mage::log($item['base_discount_amount']);
|
598 |
+
$qty = $item['qty_ordered'] - $item['qty_invoiced'];
|
599 |
+
$orderId = $item['order_id'];
|
600 |
+
$order1 = Mage::getModel('sales/order')->load($orderId);
|
601 |
+
Mage::log($Incrementid . "Increament Id");
|
602 |
+
if($order1['discount_description'] == "Store Credits")
|
603 |
+
{
|
604 |
+
Mage::log("hiiiiii");
|
605 |
+
$arr['order_id'] = $order1->getIncrementId();
|
606 |
+
if($qty > 0){
|
607 |
+
//-----------------------
|
608 |
+
|
609 |
+
//$rat = $item['base_price_incl_tax'] / $order1['base_subtotal'];
|
610 |
+
// Mage::log($item['base_discount_amount']."");
|
611 |
+
//Mage::log("QUANTITY " . $qty);
|
612 |
+
$baseDiscount = ($item['base_discount_amount'] * $qty) / $item['qty_ordered'];
|
613 |
+
//calculating Points
|
614 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
615 |
+
|
616 |
+
$points = ($array2['credits'] * $baseDiscount) / $array2['basevalue'] ;
|
617 |
+
|
618 |
+
|
619 |
+
$arr['action_credits'] = $points;
|
620 |
+
Mage::log($arr['action_credits']."return credits of the product");
|
621 |
+
|
622 |
+
//-----------------------------------------------
|
623 |
+
}
|
624 |
+
$arr['c_id'] = $order1['customer_id'];
|
625 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
626 |
+
$arr['action_date'] = date('Y-m-d H:m:s', $currentTimestamp);
|
627 |
+
$arr['store_view'] = Mage::app()->getStore()->getName(); //Storeview
|
628 |
+
$arr['state'] = 1; //State Of Transaction
|
629 |
+
$arr['website1'] = "Main Website" ; //Website
|
630 |
+
$arr['action'] = "Refunded";
|
631 |
+
$arr['custom_msg'] = "By Admin:For Cancel The Order " . $arr['order_id']." Of Product With Name " .$item['name']; //Custom Message
|
632 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$arr['c_id'])->addFieldToFilter('website1','Main Website')->getLastItem();
|
633 |
+
|
634 |
+
$totalcredits = $collection->getTotalCredits();
|
635 |
+
$arr['total_credits'] = $arr['action_credits'] + $totalcredits;
|
636 |
+
$arr['customer_notification_status'] = 'Notified'; //Email Sending Status
|
637 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
638 |
+
$table1->setData($arr);
|
639 |
+
try{
|
640 |
+
if($arr['action_credits'] > 0)
|
641 |
+
$table1->save();
|
642 |
+
|
643 |
+
}catch(Exception $e){
|
644 |
+
Mage::log($e);
|
645 |
+
}
|
646 |
+
}
|
647 |
+
}
|
648 |
+
/*------------------Disable Module------------------------------------------*/
|
649 |
+
public function disableModule(Varien_Event_Observer $observer)
|
650 |
+
{
|
651 |
+
|
652 |
+
$conf = $observer->getEvent();
|
653 |
+
$moduleName = 'Kartparadigm_StoreCredit';
|
654 |
+
$nodePath = "/modules/$moduleName/active";
|
655 |
+
//Mage::log($conf);
|
656 |
+
Mage::log($conf['modules'][65]);
|
657 |
+
Mage::log("hai");
|
658 |
+
if(!Mage::helper('core/data')->isModuleOutputEnabled($moduleName))
|
659 |
+
{
|
660 |
+
Mage::getConfig()->setNode($nodePath, 'false', true);
|
661 |
+
$outputPath = "advanced/modules_disable_output/$moduleName";
|
662 |
+
if (!Mage::getStoreConfig($outputPath)) {
|
663 |
+
Mage::app()->getStore()->setConfig($outputPath, true);
|
664 |
+
}
|
665 |
+
$resource = Mage::getSingleton('core/resource');
|
666 |
+
$writeConnection = $resource->getConnection('core_write');
|
667 |
+
|
668 |
+
|
669 |
+
$query = 'UPDATE core_config_data SET value = 0 WHERE path="mycustom_section/mycustom_group2/field1"';
|
670 |
+
$writeConnection->query($query);
|
671 |
+
// Mage::log('kkkkkkkkkkkkkkk');
|
672 |
+
|
673 |
+
}else{
|
674 |
+
$resource = Mage::getSingleton('core/resource');
|
675 |
+
$writeConnection = $resource->getConnection('core_write');
|
676 |
+
|
677 |
+
|
678 |
+
$query = 'UPDATE core_config_data SET value = 1 WHERE path="mycustom_section/mycustom_group2/field1"';
|
679 |
+
$writeConnection->query($query);
|
680 |
+
}
|
681 |
+
|
682 |
+
|
683 |
+
|
684 |
+
}
|
685 |
+
|
686 |
+
|
687 |
+
|
688 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Resource/Rule.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Resource_Rule extends Mage_CatalogRule_Model_Resource_Rule
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Inserts rule data into catalogrule/rule_product table
|
6 |
+
*
|
7 |
+
* @param Mage_CatalogRule_Model_Rule $rule
|
8 |
+
* @param array $websiteIds
|
9 |
+
* @param array $productIds
|
10 |
+
*/
|
11 |
+
public function insertRuleData(Mage_CatalogRule_Model_Rule $rule, array $websiteIds, array $productIds = array())
|
12 |
+
{
|
13 |
+
/** @var $write Varien_Db_Adapter_Interface */
|
14 |
+
$write = $this->_getWriteAdapter();
|
15 |
+
|
16 |
+
$customerGroupIds = $rule->getCustomerGroupIds();
|
17 |
+
$fromTime = (int) strtotime($rule->getFromDate());
|
18 |
+
$toTime = (int) strtotime($rule->getToDate());
|
19 |
+
$toTime = $toTime ? ($toTime + self::SECONDS_IN_DAY - 1) : 0;
|
20 |
+
$sortOrder = (int) $rule->getSortOrder();
|
21 |
+
$actionOperator = $rule->getSimpleAction();
|
22 |
+
$actionAmount = (float) $rule->getDiscountAmount();
|
23 |
+
$subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : '';
|
24 |
+
$subActionAmount = (float) $rule->getSubDiscountAmount();
|
25 |
+
$actionStop = (int) $rule->getStopRulesProcessing();
|
26 |
+
$storeCredit = (int) $rule->getStoreCredit();//Get Store Credit Value From The Rule
|
27 |
+
/** @var $helper Mage_Catalog_Helper_Product_Flat */
|
28 |
+
$helper = $this->_factory->getHelper('catalog/product_flat');
|
29 |
+
|
30 |
+
if ($helper->isEnabled() && $helper->isBuiltAllStores()) {
|
31 |
+
/** @var $store Mage_Core_Model_Store */
|
32 |
+
foreach ($this->_app->getStores(false) as $store) {
|
33 |
+
if (in_array($store->getWebsiteId(), $websiteIds)) {
|
34 |
+
/** @var $selectByStore Varien_Db_Select */
|
35 |
+
$selectByStore = $rule->getProductFlatSelect($store->getId())
|
36 |
+
->joinLeft(array('cg' => $this->getTable('customer/customer_group')),
|
37 |
+
$write->quoteInto('cg.customer_group_id IN (?)', $customerGroupIds),
|
38 |
+
array('cg.customer_group_id'))
|
39 |
+
->reset(Varien_Db_Select::COLUMNS)
|
40 |
+
->columns(array(
|
41 |
+
new Zend_Db_Expr($store->getWebsiteId()),
|
42 |
+
'cg.customer_group_id',
|
43 |
+
'p.entity_id',
|
44 |
+
new Zend_Db_Expr($rule->getId()),
|
45 |
+
new Zend_Db_Expr($fromTime),
|
46 |
+
new Zend_Db_Expr($toTime),
|
47 |
+
new Zend_Db_Expr("'" . $actionOperator . "'"),
|
48 |
+
new Zend_Db_Expr($actionAmount),
|
49 |
+
new Zend_Db_Expr($actionStop),
|
50 |
+
new Zend_Db_Expr($sortOrder),
|
51 |
+
new Zend_Db_Expr("'" . $subActionOperator . "'"),
|
52 |
+
new Zend_Db_Expr($subActionAmount),
|
53 |
+
));
|
54 |
+
|
55 |
+
if (count($productIds) > 0) {
|
56 |
+
$selectByStore->where('p.entity_id IN (?)', array_keys($productIds));
|
57 |
+
}
|
58 |
+
|
59 |
+
$selects = $write->selectsByRange('entity_id', $selectByStore, self::RANGE_PRODUCT_STEP);
|
60 |
+
foreach ($selects as $select) {
|
61 |
+
$write->query(
|
62 |
+
$write->insertFromSelect(
|
63 |
+
$select, $this->getTable('catalogrule/rule_product'), array(
|
64 |
+
'website_id',
|
65 |
+
'customer_group_id',
|
66 |
+
'product_id',
|
67 |
+
'rule_id',
|
68 |
+
'from_time',
|
69 |
+
'to_time',
|
70 |
+
'action_operator',
|
71 |
+
'action_amount',
|
72 |
+
'action_stop',
|
73 |
+
'sort_order',
|
74 |
+
'sub_simple_action',
|
75 |
+
'sub_discount_amount',
|
76 |
+
), Varien_Db_Adapter_Interface::INSERT_IGNORE
|
77 |
+
)
|
78 |
+
);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
if (count($productIds) == 0) {
|
84 |
+
Varien_Profiler::start('__MATCH_PRODUCTS__');
|
85 |
+
$productIds = $rule->getMatchingProductIds();
|
86 |
+
Varien_Profiler::stop('__MATCH_PRODUCTS__');
|
87 |
+
}
|
88 |
+
|
89 |
+
$rows = array();
|
90 |
+
foreach ($productIds as $productId => $validationByWebsite) {
|
91 |
+
foreach ($websiteIds as $websiteId) {
|
92 |
+
foreach ($customerGroupIds as $customerGroupId) {
|
93 |
+
if (empty($validationByWebsite[$websiteId])) {
|
94 |
+
continue;
|
95 |
+
}
|
96 |
+
$rows[] = array(
|
97 |
+
'rule_id' => $rule->getId(),
|
98 |
+
'from_time' => $fromTime,
|
99 |
+
'to_time' => $toTime,
|
100 |
+
'website_id' => $websiteId,
|
101 |
+
'customer_group_id' => $customerGroupId,
|
102 |
+
'product_id' => $productId,
|
103 |
+
'action_operator' => $actionOperator,
|
104 |
+
'action_amount' => $actionAmount,
|
105 |
+
'action_stop' => $actionStop,
|
106 |
+
'sort_order' => $sortOrder,
|
107 |
+
'sub_simple_action' => $subActionOperator,
|
108 |
+
'sub_discount_amount' => $subActionAmount,
|
109 |
+
'store_credit' => $storeCredit, //inset Store Credit Value in catalogrule_product
|
110 |
+
);
|
111 |
+
|
112 |
+
if (count($rows) == 1000) {
|
113 |
+
$write->insertMultiple($this->getTable('catalogrule/rule_product'), $rows);
|
114 |
+
$rows = array();
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
if (!empty($rows)) {
|
121 |
+
$write->insertMultiple($this->getTable('catalogrule/rule_product'), $rows);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Resource_Setup extends
|
3 |
+
Mage_Core_Model_Resource_Setup
|
4 |
+
{
|
5 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Resource/Transaction.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Resource_Transaction extends Mage_Core_Model_Resource_Transaction
|
3 |
+
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Initialize objects save transaction
|
9 |
+
*
|
10 |
+
* @return Mage_Core_Model_Resource_Transaction
|
11 |
+
* @throws Exception
|
12 |
+
*/
|
13 |
+
public function save()
|
14 |
+
{
|
15 |
+
$this->_startTransaction();
|
16 |
+
$error = false;
|
17 |
+
|
18 |
+
try {
|
19 |
+
|
20 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
21 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
22 |
+
foreach ($this->_objects as $object) {
|
23 |
+
|
24 |
+
// default credits to base credits
|
25 |
+
$defaultCredits = Mage::getSingleton('adminhtml/session')->getTotal()['credits'];
|
26 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
27 |
+
|
28 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
29 |
+
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
30 |
+
|
31 |
+
$baseCredits = $defaultCredits/$rates[$currentCurrencyCode];
|
32 |
+
|
33 |
+
}
|
34 |
+
else{
|
35 |
+
$baseCredits = $defaultCredits;
|
36 |
+
}
|
37 |
+
|
38 |
+
//
|
39 |
+
$object->setRefundedstorecreditAmount($defaultCredits);
|
40 |
+
$object->setBaseRefundedstorecreditAmount($baseCredits);
|
41 |
+
//Mage::log($object->getRefundedstorecreditAmount());
|
42 |
+
$object->save();
|
43 |
+
}
|
44 |
+
} catch (Exception $e) {
|
45 |
+
$error = $e;
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($error === false) {
|
49 |
+
try {
|
50 |
+
$this->_runCallbacks();
|
51 |
+
} catch (Exception $e) {
|
52 |
+
$error = $e;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
if ($error) {
|
57 |
+
$this->_rollbackTransaction();
|
58 |
+
throw $error;
|
59 |
+
} else {
|
60 |
+
if(Mage::getSingleton('adminhtml/session')->getErr() == 'true')
|
61 |
+
{
|
62 |
+
Mage::getSingleton('adminhtml/session')->unsErr();
|
63 |
+
Mage::throwException('Store Credit Must Be Less Than Grand Total');
|
64 |
+
}
|
65 |
+
Mage::getSingleton('adminhtml/session')->unsTotal();
|
66 |
+
$this->_commitTransaction();
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
}
|
75 |
+
|
app/code/community/Kartparadigm/StoreCredit/Model/Sendcreditstofriend.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Sendcreditstofriend extends
|
3 |
+
Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_init('kartparadigm_storecredit/sendcreditstofriend');
|
8 |
+
parent::_construct();
|
9 |
+
}
|
10 |
+
|
11 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/Model/Source.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Model_Source
|
3 |
+
{
|
4 |
+
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
|
9 |
+
array('value' => 0, 'label' => Mage::helper('kartparadigm_storecredit')->__('No')),
|
10 |
+
array('value' => 1, 'label' => Mage::helper('kartparadigm_storecredit')->__('Yes')),
|
11 |
+
// and so on...
|
12 |
+
);
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/CreditsController.php
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_Adminhtml_CreditsController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
return $this;
|
10 |
+
}
|
11 |
+
public function editsAction()
|
12 |
+
{
|
13 |
+
$this->loadLayout();
|
14 |
+
$this->renderLayout();
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
/* ---------------------------------------------for retriving the customers------------------------------------------ */
|
18 |
+
public function customerAction()
|
19 |
+
{
|
20 |
+
$this->loadLayout();
|
21 |
+
$this->renderLayout();
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
/* ------------------------------------------ link to system->configurations of store credit ------------------------------------*/
|
25 |
+
public function settingsAction()
|
26 |
+
{
|
27 |
+
// $redirect = '<meta http-equiv="refresh" content="0;url='..'"/> ';
|
28 |
+
$this->loadLayout();
|
29 |
+
$url = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/mycustom_section");
|
30 |
+
$this->getResponse()->setRedirect($url);
|
31 |
+
$this->renderLayout();
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function massDeleteAction()
|
36 |
+
{
|
37 |
+
$registryIds = $this->getRequest()->getParam('registries');
|
38 |
+
if(!is_array($registryIds)) {
|
39 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('kartparadigm_storecredit')->__('Please select one or more registries.'));
|
40 |
+
} else {
|
41 |
+
try {
|
42 |
+
$registry = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
43 |
+
foreach ($registryIds as $registryId) {
|
44 |
+
$registry->load($registryId)->delete();
|
45 |
+
}
|
46 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
47 |
+
Mage::helper('adminhtml')->__('Total of %d
|
48 |
+
record(s) were deleted.', count($registryIds))
|
49 |
+
);
|
50 |
+
} catch (Exception $e) {
|
51 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$this->_redirect('*/*/index');
|
55 |
+
}
|
56 |
+
/*-----------------------------------Admin use the store credits in reorder ----------------------------------------------*/
|
57 |
+
public function usecreditsAction()
|
58 |
+
{
|
59 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
60 |
+
$balance;
|
61 |
+
$points;
|
62 |
+
$discountAmount;
|
63 |
+
$id = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
|
64 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->addFieldToFilter('website1','Main Website')->getLastItem();
|
65 |
+
$amt = $collection->getTotalCredits();
|
66 |
+
Mage::log($amt);
|
67 |
+
$creditData['totalCredits'] = $amt;
|
68 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
69 |
+
$grandTotal = $quote->getGrandTotal();
|
70 |
+
$subTotal = $quote->getSubtotal();
|
71 |
+
Mage::log($quote->getSubtotal()."Sub Total");
|
72 |
+
|
73 |
+
if (!Mage::helper('kartparadigm_storecredit')->getTaxEnabled()){
|
74 |
+
$tax = $quote->getShippingAddress()->getData('tax_amount');
|
75 |
+
}
|
76 |
+
if(!Mage::helper('kartparadigm_storecredit')->getIsShippingEnabled()){
|
77 |
+
$shippingPrice = $quote->getShippingAddress()->getShippingAmount();
|
78 |
+
}
|
79 |
+
|
80 |
+
$amt1 = ($array2['basevalue'] * $amt) / $array2['credits'];
|
81 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
82 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
83 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
84 |
+
$amt2 = Mage::helper('directory')->currencyConvert($amt1, $baseCurrencyCode, $currentCurrencyCode);
|
85 |
+
}
|
86 |
+
else{
|
87 |
+
$amt2 = $amt1;
|
88 |
+
}
|
89 |
+
|
90 |
+
if($grandTotal > $amt2) {
|
91 |
+
|
92 |
+
|
93 |
+
if(($grandTotal - $tax - $shippingPrice) > $amt2){
|
94 |
+
$discountAmount = $amt2;
|
95 |
+
$points = round(($discountAmount * $amt)/$amt2);
|
96 |
+
$balance = 0;
|
97 |
+
}else{
|
98 |
+
$discountAmount = $subTotal;
|
99 |
+
$points = round(($discountAmount * $amt)/$amt2);
|
100 |
+
$balance = $amt - $points;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
else {
|
104 |
+
$discountAmount = $grandTotal - $tax - $shippingPrice;
|
105 |
+
$points = round(($discountAmount * $amt)/$amt2);
|
106 |
+
$balance = $amt - $points;
|
107 |
+
}
|
108 |
+
$creditData['discountCredits'] = $points;
|
109 |
+
//$creditData['balance'] = $balance;
|
110 |
+
|
111 |
+
if($discountAmount > 0) {
|
112 |
+
|
113 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
114 |
+
|
115 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
116 |
+
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
117 |
+
|
118 |
+
$baseDiscount = $discountAmount/$rates[$currentCurrencyCode];
|
119 |
+
|
120 |
+
}
|
121 |
+
else{
|
122 |
+
$baseDiscount = $discountAmount;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
//we calculate the Ratio of taxes between GrandTotal & Discount Amount to know how tach we need to remove.
|
127 |
+
|
128 |
+
$msg = "Remaining Credits In Your Accoount Are ".$balance;
|
129 |
+
//Mage::getSingleton('core/session')->setCredits($msg);
|
130 |
+
|
131 |
+
|
132 |
+
$quote->setGrandTotal($quote->getGrandTotal()-$discountAmount)
|
133 |
+
->setBaseGrandTotal($quote->getBaseGrandTotal()-$baseDiscount)
|
134 |
+
->setSubtotalWithDiscount($quote->getSubtotal()-$discountAmount)
|
135 |
+
->setBaseSubtotalWithDiscount($quote->getBaseSubtotal()-$baseDiscount)
|
136 |
+
->save();
|
137 |
+
|
138 |
+
$canAddItems = $quote->isVirtual()? ('billing') : ('shipping');
|
139 |
+
foreach ($quote->getAllAddresses() as $address) {
|
140 |
+
|
141 |
+
$address->setSubtotal(0);
|
142 |
+
$address->setBaseSubtotal(0);
|
143 |
+
|
144 |
+
$address->setGrandTotal(0);
|
145 |
+
$address->setBaseGrandTotal(0);
|
146 |
+
|
147 |
+
$address->collectTotals();
|
148 |
+
|
149 |
+
if($address->getAddressType()==$canAddItems) {
|
150 |
+
|
151 |
+
$address->setSubtotal((float) $quote->getSubtotal());
|
152 |
+
$address->setBaseSubtotal((float) $quote->getBaseSubtotal());
|
153 |
+
$address->setSubtotalWithDiscount((float) $quote->getSubtotalWithDiscount());
|
154 |
+
$address->setBaseSubtotalWithDiscount((float) $quote->getBaseSubtotalWithDiscount());
|
155 |
+
$address->setGrandTotal((float) $quote->getGrandTotal());
|
156 |
+
$address->setBaseGrandTotal((float) $quote->getBaseGrandTotal());
|
157 |
+
$address->setDiscountAmount(-$discountAmount);
|
158 |
+
$address->setDiscountDescription('Store Credits');
|
159 |
+
$address->setBaseDiscountAmount(-$baseDiscount);
|
160 |
+
$address->save();
|
161 |
+
}//end: if
|
162 |
+
} //end: foreach
|
163 |
+
foreach($quote->getAllItems() as $item) {
|
164 |
+
|
165 |
+
// We apply discount amount based on the ratio between the GrandTotal and the RowTotal
|
166 |
+
$rat = $item->getPriceInclTax() / $quote->getGrandTotal();
|
167 |
+
$rat1 = $item->getBasePriceInclTax() / $quote->getBaseGrandTotal();
|
168 |
+
$ratdisc = $discountAmount * $rat;
|
169 |
+
$ratdisc1 = $baseDiscount * $rat1;
|
170 |
+
Mage::log($item->getDiscountAmount()."include tax".$item->getBaseDiscountAmount());
|
171 |
+
$item->setDiscountAmount(($item->getDiscountAmount() + $ratdisc) * $item->getQty());
|
172 |
+
$item->setBaseDiscountAmount(($item->getBaseDiscountAmount() + $ratdisc1) * $item->getQty())->save();
|
173 |
+
}//end: foreach
|
174 |
+
Mage::getSingleton('checkout/session')->setCredits($creditData);
|
175 |
+
Mage::getSingleton('core/session')->setBalance($balance);
|
176 |
+
Mage::getSingleton('adminhtml/session')->setValue("true");
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
}
|
181 |
+
/*-------------------------------- end------------------------------------------------------------------------------------- */
|
182 |
+
|
183 |
+
/*-----------------------------------Admin unselect the store credits in reorder ----------------------------------------------*/
|
184 |
+
public function unselectAction()
|
185 |
+
{
|
186 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
187 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
188 |
+
$total = $quote->getBaseGrandTotal();
|
189 |
+
$amt = Mage::getSingleton('checkout/session')->getCredits()['discountCredits'];
|
190 |
+
$discountAmount;
|
191 |
+
$amt1 = ($array2['basevalue'] * $amt) / $array2['credits'];
|
192 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
193 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
194 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
195 |
+
$discountAmount = Mage::helper('directory')->currencyConvert($amt1, $baseCurrencyCode, $currentCurrencyCode);
|
196 |
+
}
|
197 |
+
else{
|
198 |
+
$discountAmount = $amt1;
|
199 |
+
}
|
200 |
+
Mage::log( $discountAmount."discount Amount");
|
201 |
+
|
202 |
+
if($discountAmount >= 0) {
|
203 |
+
|
204 |
+
//we calculate the Ratio of taxes between GrandTotal & Discount Amount to know how tach we need to remove.
|
205 |
+
|
206 |
+
//$msg = "Remaining Credits In Your Accoount Are ".$balance;
|
207 |
+
//Mage::getSingleton('core/session')->setCredits($msg);
|
208 |
+
|
209 |
+
|
210 |
+
$quote->setGrandTotal($quote->getGrandTotal() + $discountAmount)
|
211 |
+
->setBaseGrandTotal($quote->getBaseGrandTotal() + $discountAmount)
|
212 |
+
->setSubtotalWithDiscount($quote->getSubtotal() + $discountAmount)
|
213 |
+
->setBaseSubtotalWithDiscount($quote->getBaseSubtotal() + $discountAmount)
|
214 |
+
->save();
|
215 |
+
|
216 |
+
$canAddItems = $quote->isVirtual()? ('billing') : ('shipping');
|
217 |
+
foreach ($quote->getAllAddresses() as $address) {
|
218 |
+
|
219 |
+
$address->setSubtotal(0);
|
220 |
+
$address->setBaseSubtotal(0);
|
221 |
+
|
222 |
+
$address->setGrandTotal(0);
|
223 |
+
$address->setBaseGrandTotal(0);
|
224 |
+
|
225 |
+
$address->collectTotals();
|
226 |
+
|
227 |
+
if($address->getAddressType()==$canAddItems) {
|
228 |
+
|
229 |
+
$address->setSubtotal((float) $quote->getSubtotal());
|
230 |
+
$address->setBaseSubtotal((float) $quote->getBaseSubtotal());
|
231 |
+
$address->setSubtotalWithDiscount((float) $quote->getSubtotalWithDiscount());
|
232 |
+
$address->setBaseSubtotalWithDiscount((float) $quote->getBaseSubtotalWithDiscount());
|
233 |
+
$address->setGrandTotal((float) $quote->getGrandTotal());
|
234 |
+
$address->setBaseGrandTotal((float) $quote->getBaseGrandTotal());
|
235 |
+
$address->save();
|
236 |
+
}//end: if
|
237 |
+
} //end: foreach
|
238 |
+
foreach($quote->getAllItems() as $item){
|
239 |
+
//We apply discount amount based on the ratio between the GrandTotal and the RowTotal
|
240 |
+
$rat=$item->getPriceInclTax()/$total;
|
241 |
+
$ratdisc=$discountAmount*$rat;
|
242 |
+
|
243 |
+
|
244 |
+
$item->setDiscountAmount($ratdisc);
|
245 |
+
$item->setBaseDiscountAmount($ratdisc)->save();
|
246 |
+
|
247 |
+
|
248 |
+
} //end: foreach
|
249 |
+
Mage::getSingleton('checkout/session')->unsCredits();
|
250 |
+
Mage::getSingleton('core/session')->unsBalance();
|
251 |
+
Mage::getSingleton('adminhtml/session')->unsValue();
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
}
|
257 |
+
/*-------------------------------- end------------------------------------------------------------------------------------- */
|
258 |
+
public function showTransactionAction()
|
259 |
+
{
|
260 |
+
$table = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('t_id',$this->getRequest()->getParam('id'));
|
261 |
+
foreach($table as $t)
|
262 |
+
{
|
263 |
+
Mage::getSingleton('adminhtml/session')->setFormData($t);
|
264 |
+
//Mage::log($t->getActionCredits()."hi");
|
265 |
+
}
|
266 |
+
$this->loadLayout();
|
267 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
268 |
+
$this->renderLayout();
|
269 |
+
}
|
270 |
+
public function gridAction()
|
271 |
+
{
|
272 |
+
$this->getResponse()->setBody(
|
273 |
+
$this->getLayout()->createBlock('kartparadigm_storecredit/adminhtml_registries1_grid')->toHtml());
|
274 |
+
}
|
275 |
+
|
276 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/CustomerController.php
ADDED
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Adminhtml/controllers/CustomerController.php';
|
3 |
+
class Kartparadigm_StoreCredit_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
|
4 |
+
{
|
5 |
+
public function saveAction()
|
6 |
+
{
|
7 |
+
$data = $this->getRequest()->getPost();
|
8 |
+
//Mage::log($data['credit_value']);
|
9 |
+
|
10 |
+
if ($data) {
|
11 |
+
|
12 |
+
//Inset the credits added by admin
|
13 |
+
|
14 |
+
$date = new Zend_Date(Mage::getModel('core/date')->timestamp());
|
15 |
+
$date=$date->toString('Y-M-d H:m:s');
|
16 |
+
$col = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$data['customer_id'])->addFieldToFilter('website1',$data['website1'])->getLastItem();
|
17 |
+
$tdata = array();
|
18 |
+
$tdata['c_id'] = $data['customer_id'];
|
19 |
+
$tdata['action_credits'] = $data['credit_value'];
|
20 |
+
|
21 |
+
|
22 |
+
// Action Of The Admin
|
23 |
+
if($col->getTotalCredits() == '')
|
24 |
+
$tdata['action'] = "Created";
|
25 |
+
else
|
26 |
+
$tdata['action'] = "Updated";
|
27 |
+
//
|
28 |
+
$tdata['website1'] = $data['website1'];
|
29 |
+
if($data['notification'] == 'on')
|
30 |
+
$tdata['customer_notification_status'] = "Notified";
|
31 |
+
else
|
32 |
+
$tdata['customer_notification_status'] = "No";
|
33 |
+
$tdata['state'] = "completed";
|
34 |
+
$tdata['custom_msg'] = "By admin : admin (".$data['description'].")";
|
35 |
+
$tdata['action_date'] = $date;
|
36 |
+
$tdata['store_view'] = $data['storeview1'];
|
37 |
+
|
38 |
+
$tdata['total_credits'] = $col->getTotalCredits() + ($data['credit_value']);
|
39 |
+
if($tdata['total_credits'] <= 0)
|
40 |
+
{
|
41 |
+
$tdata['action_credits'] = -$col->getTotalCredits();
|
42 |
+
$tdata['total_credits'] = 0;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
Mage::log($col->getTotalCredits());
|
47 |
+
|
48 |
+
if(isset($data['credit_value']) && ($data['credit_value'] != 0) && ($col->getTotalCredits() > 0 || ($col->getTotalCredits() == '' && $data['credit_value'] > 0) || $tdata['total_credits'] > 0))
|
49 |
+
{
|
50 |
+
|
51 |
+
|
52 |
+
$model = Mage::getModel('kartparadigm_storecredit/creditinfo')->setData($tdata);
|
53 |
+
try{
|
54 |
+
|
55 |
+
$model->save();
|
56 |
+
if($data['notification'] === 'on'){
|
57 |
+
|
58 |
+
$templateName = Mage::getStoreConfig('mycustom_section/mycustom_group1/caritor_email_template');
|
59 |
+
|
60 |
+
Mage::log($templateName."sreehari");
|
61 |
+
// for sending mail to admin after order placed
|
62 |
+
$emailTemplate = Mage::getModel('core/email_template')
|
63 |
+
->loadDefault('caritor_email_template');
|
64 |
+
$name = Mage::getStoreConfig('mycustom_section/mycustom_group1/sender_email_identity');
|
65 |
+
$group = "ident_".$name;
|
66 |
+
|
67 |
+
$email = Mage::getStoreConfig('trans_email/'.$group.'/email');
|
68 |
+
|
69 |
+
|
70 |
+
$emailTemplateVariables = array();
|
71 |
+
$emailTemplateVariables['var1'] = $data['account']['firstname'];
|
72 |
+
$emailTemplateVariables['var2'] = $tdata['action_credits'];
|
73 |
+
$emailTemplateVariables['var3'] = $data['storeview1'];
|
74 |
+
$emailTemplateVariables['var4'] = $tdata['total_credits'];
|
75 |
+
$emailTemplateVariables['var5'] = $tdata['action'];
|
76 |
+
$emailTemplateVariables['var6'] = $tdata['action_date'];
|
77 |
+
$emailTemplateVariables['var7'] = $data['description'];
|
78 |
+
$emailTemplateVariables['var8'] = $this->getUrl('customer/account/login/');
|
79 |
+
|
80 |
+
$emailTemplate->getProcessedTemplate($emailTemplateVariables);
|
81 |
+
Mage::log($name);
|
82 |
+
|
83 |
+
$emailTemplate->setSenderName($name);
|
84 |
+
$emailTemplate->setSenderEmail($email);
|
85 |
+
$emailTemplate->setReplyTo($email);
|
86 |
+
try {
|
87 |
+
$emailTemplate->send($data['account']['email'], $data['account']['firstname'], $emailTemplateVariables);
|
88 |
+
} catch (Exception $e) {
|
89 |
+
echo $e->getMessage();
|
90 |
+
}
|
91 |
+
|
92 |
+
//
|
93 |
+
}
|
94 |
+
|
95 |
+
}catch(Exception $e)
|
96 |
+
{
|
97 |
+
|
98 |
+
echo $e->getMessage();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
//
|
104 |
+
|
105 |
+
$redirectBack = $this->getRequest()->getParam('back', false);
|
106 |
+
$this->_initCustomer('customer_id');
|
107 |
+
|
108 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
109 |
+
$customer = Mage::registry('current_customer');
|
110 |
+
|
111 |
+
/** @var $customerForm Mage_Customer_Model_Form */
|
112 |
+
$customerForm = Mage::getModel('customer/form');
|
113 |
+
$customerForm->setEntity($customer)
|
114 |
+
->setFormCode('adminhtml_customer')
|
115 |
+
->ignoreInvisible(false)
|
116 |
+
;
|
117 |
+
|
118 |
+
$formData = $customerForm->extractData($this->getRequest(), 'account');
|
119 |
+
|
120 |
+
// Handle 'disable auto_group_change' attribute
|
121 |
+
if (isset($formData['disable_auto_group_change'])) {
|
122 |
+
$formData['disable_auto_group_change'] = empty($formData['disable_auto_group_change']) ? '0' : '1';
|
123 |
+
}
|
124 |
+
|
125 |
+
$errors = $customerForm->validateData($formData);
|
126 |
+
if ($errors !== true) {
|
127 |
+
foreach ($errors as $error) {
|
128 |
+
$this->_getSession()->addError($error);
|
129 |
+
}
|
130 |
+
$this->_getSession()->setCustomerData($data);
|
131 |
+
$this->getResponse()->setRedirect($this->getUrl('*/customer/edit', array('id' => $customer->getId())));
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
$customerForm->compactData($formData);
|
136 |
+
|
137 |
+
// Unset template data
|
138 |
+
if (isset($data['address']['_template_'])) {
|
139 |
+
unset($data['address']['_template_']);
|
140 |
+
}
|
141 |
+
|
142 |
+
$modifiedAddresses = array();
|
143 |
+
if (!empty($data['address'])) {
|
144 |
+
/** @var $addressForm Mage_Customer_Model_Form */
|
145 |
+
$addressForm = Mage::getModel('customer/form');
|
146 |
+
$addressForm->setFormCode('adminhtml_customer_address')->ignoreInvisible(false);
|
147 |
+
|
148 |
+
foreach (array_keys($data['address']) as $index) {
|
149 |
+
$address = $customer->getAddressItemById($index);
|
150 |
+
if (!$address) {
|
151 |
+
$address = Mage::getModel('customer/address');
|
152 |
+
}
|
153 |
+
|
154 |
+
$requestScope = sprintf('address/%s', $index);
|
155 |
+
$formData = $addressForm->setEntity($address)
|
156 |
+
->extractData($this->getRequest(), $requestScope);
|
157 |
+
|
158 |
+
// Set default billing and shipping flags to address
|
159 |
+
$isDefaultBilling = isset($data['account']['default_billing'])
|
160 |
+
&& $data['account']['default_billing'] == $index;
|
161 |
+
$address->setIsDefaultBilling($isDefaultBilling);
|
162 |
+
$isDefaultShipping = isset($data['account']['default_shipping'])
|
163 |
+
&& $data['account']['default_shipping'] == $index;
|
164 |
+
$address->setIsDefaultShipping($isDefaultShipping);
|
165 |
+
|
166 |
+
$errors = $addressForm->validateData($formData);
|
167 |
+
if ($errors !== true) {
|
168 |
+
foreach ($errors as $error) {
|
169 |
+
$this->_getSession()->addError($error);
|
170 |
+
}
|
171 |
+
$this->_getSession()->setCustomerData($data);
|
172 |
+
$this->getResponse()->setRedirect($this->getUrl('*/customer/edit', array(
|
173 |
+
'id' => $customer->getId())
|
174 |
+
));
|
175 |
+
return;
|
176 |
+
}
|
177 |
+
|
178 |
+
$addressForm->compactData($formData);
|
179 |
+
|
180 |
+
// Set post_index for detect default billing and shipping addresses
|
181 |
+
$address->setPostIndex($index);
|
182 |
+
|
183 |
+
if ($address->getId()) {
|
184 |
+
$modifiedAddresses[] = $address->getId();
|
185 |
+
} else {
|
186 |
+
$customer->addAddress($address);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
// Default billing and shipping
|
192 |
+
if (isset($data['account']['default_billing'])) {
|
193 |
+
$customer->setData('default_billing', $data['account']['default_billing']);
|
194 |
+
}
|
195 |
+
if (isset($data['account']['default_shipping'])) {
|
196 |
+
$customer->setData('default_shipping', $data['account']['default_shipping']);
|
197 |
+
}
|
198 |
+
if (isset($data['account']['confirmation'])) {
|
199 |
+
$customer->setData('confirmation', $data['account']['confirmation']);
|
200 |
+
}
|
201 |
+
|
202 |
+
// Mark not modified customer addresses for delete
|
203 |
+
foreach ($customer->getAddressesCollection() as $customerAddress) {
|
204 |
+
if ($customerAddress->getId() && !in_array($customerAddress->getId(), $modifiedAddresses)) {
|
205 |
+
$customerAddress->setData('_deleted', true);
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if (Mage::getSingleton('admin/session')->isAllowed('customer/newsletter')
|
210 |
+
&& !$customer->getConfirmation()
|
211 |
+
) {
|
212 |
+
$customer->setIsSubscribed(isset($data['subscription']));
|
213 |
+
}
|
214 |
+
|
215 |
+
if (isset($data['account']['sendemail_store_id'])) {
|
216 |
+
$customer->setSendemailStoreId($data['account']['sendemail_store_id']);
|
217 |
+
}
|
218 |
+
|
219 |
+
$isNewCustomer = $customer->isObjectNew();
|
220 |
+
try {
|
221 |
+
$sendPassToEmail = false;
|
222 |
+
// Force new customer confirmation
|
223 |
+
if ($isNewCustomer) {
|
224 |
+
$customer->setPassword($data['account']['password']);
|
225 |
+
$customer->setForceConfirmed(true);
|
226 |
+
if ($customer->getPassword() == 'auto') {
|
227 |
+
$sendPassToEmail = true;
|
228 |
+
$customer->setPassword($customer->generatePassword());
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
Mage::dispatchEvent('adminhtml_customer_prepare_save', array(
|
233 |
+
'customer' => $customer,
|
234 |
+
'request' => $this->getRequest()
|
235 |
+
));
|
236 |
+
|
237 |
+
$customer->save();
|
238 |
+
|
239 |
+
// Send welcome email
|
240 |
+
if ($customer->getWebsiteId() && (isset($data['account']['sendemail']) || $sendPassToEmail)) {
|
241 |
+
$storeId = $customer->getSendemailStoreId();
|
242 |
+
if ($isNewCustomer) {
|
243 |
+
$customer->sendNewAccountEmail('registered', '', $storeId);
|
244 |
+
} elseif ((!$customer->getConfirmation())) {
|
245 |
+
// Confirm not confirmed customer
|
246 |
+
$customer->sendNewAccountEmail('confirmed', '', $storeId);
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
if (!empty($data['account']['new_password'])) {
|
251 |
+
$newPassword = $data['account']['new_password'];
|
252 |
+
if ($newPassword == 'auto') {
|
253 |
+
$newPassword = $customer->generatePassword();
|
254 |
+
}
|
255 |
+
$customer->changePassword($newPassword);
|
256 |
+
$customer->sendPasswordReminderEmail();
|
257 |
+
}
|
258 |
+
|
259 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
260 |
+
Mage::helper('adminhtml')->__('The customer has been saved.')
|
261 |
+
);
|
262 |
+
Mage::dispatchEvent('adminhtml_customer_save_after', array(
|
263 |
+
'customer' => $customer,
|
264 |
+
'request' => $this->getRequest()
|
265 |
+
));
|
266 |
+
|
267 |
+
if ($redirectBack) {
|
268 |
+
$this->_redirect('*/*/edit', array(
|
269 |
+
'id' => $customer->getId(),
|
270 |
+
'_current' => true
|
271 |
+
));
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
} catch (Mage_Core_Exception $e) {
|
275 |
+
$this->_getSession()->addError($e->getMessage());
|
276 |
+
$this->_getSession()->setCustomerData($data);
|
277 |
+
$this->getResponse()->setRedirect($this->getUrl('*/customer/edit', array('id' => $customer->getId())));
|
278 |
+
} catch (Exception $e) {
|
279 |
+
$this->_getSession()->addException($e,
|
280 |
+
Mage::helper('adminhtml')->__('An error occurred while saving the customer.'));
|
281 |
+
$this->_getSession()->setCustomerData($data);
|
282 |
+
$this->getResponse()->setRedirect($this->getUrl('*/customer/edit', array('id'=>$customer->getId())));
|
283 |
+
return;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
$this->getResponse()->setRedirect($this->getUrl('*/customer'));
|
287 |
+
}
|
288 |
+
/*------------------------------Send credits Form to multiple customers------------------------------------ */
|
289 |
+
|
290 |
+
public function sendCreditsAction()
|
291 |
+
{
|
292 |
+
$customersIds = $this->getRequest()->getParam('customer');
|
293 |
+
$registry = Mage::getModel('customer/customer');
|
294 |
+
|
295 |
+
if ($customersIds) {
|
296 |
+
$emails = array();
|
297 |
+
$i = 0;
|
298 |
+
foreach($customersIds as $id2)
|
299 |
+
{
|
300 |
+
$registry->load((int) $id2);
|
301 |
+
$emails[] = array(
|
302 |
+
'label' => $registry->getEmail(),
|
303 |
+
'value' => $id2
|
304 |
+
);
|
305 |
+
}
|
306 |
+
//Mage::register('registry_data', $emails);
|
307 |
+
Mage::getSingleton('adminhtml/session')->setFormData($emails);
|
308 |
+
$this->loadLayout();
|
309 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
310 |
+
$this->renderLayout();
|
311 |
+
}
|
312 |
+
|
313 |
+
}
|
314 |
+
/*------------------------------------------sending credits to multiple customers-------------------------------- */
|
315 |
+
|
316 |
+
public function sendAction()
|
317 |
+
{
|
318 |
+
Mage::log(count($this->getRequest()->getParams()));
|
319 |
+
$count = count($this->getRequest()->getParams());
|
320 |
+
$customersIds = $this->getRequest()->getParam('email');
|
321 |
+
|
322 |
+
$credits = $this->getRequest()->getParam('credits');
|
323 |
+
|
324 |
+
$message = $this->getRequest()->getParam('message');
|
325 |
+
$storeview = $this->getRequest()->getParam('store_view');
|
326 |
+
|
327 |
+
if($this->getRequest()->getParam('notify'))
|
328 |
+
Mage::log("hhhhh");
|
329 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
330 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp);
|
331 |
+
foreach($customersIds as $id){
|
332 |
+
|
333 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->addFieldToFilter('website1','Main Website')->getLastItem();
|
334 |
+
|
335 |
+
$arr1['c_id'] = $id;
|
336 |
+
$arr1['website1'] = "Main Website";
|
337 |
+
$arr1['action_credits'] = $credits;
|
338 |
+
$arr1['total_credits'] = $collection->getTotalCredits() + $credits;
|
339 |
+
$arr1['action'] = "Updated";
|
340 |
+
$arr1['state'] = 0;
|
341 |
+
$arr1['store_view'] = $storeview;
|
342 |
+
$arr1['action_date'] = $nowdate;
|
343 |
+
$arr1['custom_msg'] = "Send By Admin: admin( ".$message." )";
|
344 |
+
$arr1['customer_notification_status'] = 'No';
|
345 |
+
|
346 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
347 |
+
$table1->setData($arr1);
|
348 |
+
|
349 |
+
try{
|
350 |
+
$table1->save();
|
351 |
+
if($count == 7){
|
352 |
+
$emailTemplate = Mage::getModel('core/email_template')
|
353 |
+
->loadDefault('caritor_email_template');
|
354 |
+
$name = Mage::getStoreConfig('mycustom_section/mycustom_group1/sender_email_identity');
|
355 |
+
$group = "ident_".$name;
|
356 |
+
|
357 |
+
$email = Mage::getStoreConfig('trans_email/'.$group.'/email');
|
358 |
+
|
359 |
+
$customerData = Mage::getModel('customer/customer')->load($id)->getData();
|
360 |
+
|
361 |
+
$emailTemplateVariables = array();
|
362 |
+
$emailTemplateVariables['var1'] = $customerData['firstname'];
|
363 |
+
$emailTemplateVariables['var4'] = $arr1['total_credits'];
|
364 |
+
$emailTemplateVariables['var5'] = $message;
|
365 |
+
$emailTemplateVariables['var8'] = "http://localhost/jaypore/index.php/customer/account/login/";
|
366 |
+
|
367 |
+
$emailTemplate->getProcessedTemplate($emailTemplateVariables);
|
368 |
+
//Mage::log($name);
|
369 |
+
|
370 |
+
$emailTemplate->setSenderName($name);
|
371 |
+
$emailTemplate->setSenderEmail($email);
|
372 |
+
$emailTemplate->setReplyTo($email);
|
373 |
+
try {
|
374 |
+
$emailTemplate->send($customerData['email'], $customerData['firstname'], $emailTemplateVariables);
|
375 |
+
} catch (Exception $e) {
|
376 |
+
echo $e->getMessage();
|
377 |
+
}
|
378 |
+
}//end if for sending credits email update
|
379 |
+
}catch(Exception $e){
|
380 |
+
Mage::log($e);
|
381 |
+
}
|
382 |
+
|
383 |
+
}
|
384 |
+
$this->_redirect('*/credits/customer');
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/Promo/CatalogController.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Adminhtml/controllers/Promo/CatalogController.php';
|
3 |
+
class Kartparadigm_StoreCredit_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Promo_CatalogController
|
4 |
+
{
|
5 |
+
/*-----------this method is used to store store credit field value in store_credit field of the catalogrule table--------------- */
|
6 |
+
public function saveAction()
|
7 |
+
{
|
8 |
+
if ($this->getRequest()->getPost()) {
|
9 |
+
try {
|
10 |
+
$model = Mage::getModel('catalogrule/rule');
|
11 |
+
Mage::dispatchEvent(
|
12 |
+
'adminhtml_controller_catalogrule_prepare_save',
|
13 |
+
array('request' => $this->getRequest())
|
14 |
+
);
|
15 |
+
$data = $this->getRequest()->getPost();
|
16 |
+
$data = $this->_filterDates($data, array('from_date', 'to_date'));
|
17 |
+
if ($id = $this->getRequest()->getParam('rule_id')) {
|
18 |
+
$model->load($id);
|
19 |
+
if ($id != $model->getId()) {
|
20 |
+
Mage::throwException(Mage::helper('catalogrule')->__('Wrong rule specified.'));
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
$validateResult = $model->validateData(new Varien_Object($data));
|
25 |
+
if ($validateResult !== true) {
|
26 |
+
foreach($validateResult as $errorMessage) {
|
27 |
+
$this->_getSession()->addError($errorMessage);
|
28 |
+
}
|
29 |
+
$this->_getSession()->setPageData($data);
|
30 |
+
$this->_redirect('*/*/edit', array('id'=>$model->getId()));
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
|
34 |
+
$data['conditions'] = $data['rule']['conditions'];
|
35 |
+
unset($data['rule']);
|
36 |
+
|
37 |
+
$autoApply = false;
|
38 |
+
if (!empty($data['auto_apply'])) {
|
39 |
+
$autoApply = true;
|
40 |
+
unset($data['auto_apply']);
|
41 |
+
}
|
42 |
+
|
43 |
+
$model->loadPost($data);
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
Mage::getSingleton('adminhtml/session')->setPageData($model->getData());
|
48 |
+
|
49 |
+
$model->setStoreCredit($data['store_credit']);//this line is used to set the store credit value to the object of credit rule table
|
50 |
+
|
51 |
+
$model->save();
|
52 |
+
|
53 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
54 |
+
Mage::helper('catalogrule')->__('The rule has been saved.')
|
55 |
+
);
|
56 |
+
Mage::getSingleton('adminhtml/session')->setPageData(false);
|
57 |
+
if ($autoApply) {
|
58 |
+
$this->getRequest()->setParam('rule_id', $model->getId());
|
59 |
+
$this->_forward('applyRules');
|
60 |
+
} else {
|
61 |
+
Mage::getModel('catalogrule/flag')->loadSelf()
|
62 |
+
->setState(1)
|
63 |
+
->save();
|
64 |
+
if ($this->getRequest()->getParam('back')) {
|
65 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
$this->_redirect('*/*/');
|
69 |
+
}
|
70 |
+
return;
|
71 |
+
} catch (Mage_Core_Exception $e) {
|
72 |
+
$this->_getSession()->addError($e->getMessage());
|
73 |
+
} catch (Exception $e) {
|
74 |
+
$this->_getSession()->addError(
|
75 |
+
Mage::helper('catalogrule')->__('An error occurred while saving the rule data. Please review the log and try again.')
|
76 |
+
);
|
77 |
+
Mage::logException($e);
|
78 |
+
Mage::getSingleton('adminhtml/session')->setPageData($data);
|
79 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('rule_id')));
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$this->_redirect('*/*/');
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/Adminhtml/Sales/Order/CreditmemoController.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php';
|
3 |
+
class Kartparadigm_StoreCredit_Adminhtml_Sales_Order_CreditmemoController extends Mage_Adminhtml_Sales_Order_CreditmemoController
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Save creditmemo and related order, invoice in one transaction
|
10 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
11 |
+
*/
|
12 |
+
protected function _saveCreditmemo($creditmemo)
|
13 |
+
{
|
14 |
+
|
15 |
+
|
16 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
17 |
+
->addObject($creditmemo)
|
18 |
+
->addObject($creditmemo->getOrder());
|
19 |
+
if ($creditmemo->getInvoice()) {
|
20 |
+
$transactionSave->addObject($creditmemo->getInvoice());
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
$transactionSave->save();
|
25 |
+
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Save creditmemo
|
31 |
+
* We can save only new creditmemo. Existing creditmemos are not editable
|
32 |
+
*/
|
33 |
+
public function saveAction()
|
34 |
+
{
|
35 |
+
|
36 |
+
|
37 |
+
$data = $this->getRequest()->getPost('creditmemo');
|
38 |
+
if (!empty($data['comment_text'])) {
|
39 |
+
Mage::getSingleton('adminhtml/session')->setCommentText($data['comment_text']);
|
40 |
+
}
|
41 |
+
|
42 |
+
try {
|
43 |
+
$creditmemo = $this->_initCreditmemo();
|
44 |
+
if ($creditmemo) {
|
45 |
+
if (($creditmemo->getGrandTotal() <=0) && (!$creditmemo->getAllowZeroGrandTotal())) {
|
46 |
+
Mage::throwException(
|
47 |
+
$this->__('Credit memo\'s total must be positive.')
|
48 |
+
);
|
49 |
+
}
|
50 |
+
|
51 |
+
$comment = '';
|
52 |
+
if (!empty($data['comment_text'])) {
|
53 |
+
$creditmemo->addComment(
|
54 |
+
$data['comment_text'],
|
55 |
+
isset($data['comment_customer_notify']),
|
56 |
+
isset($data['is_visible_on_front'])
|
57 |
+
);
|
58 |
+
if (isset($data['comment_customer_notify'])) {
|
59 |
+
$comment = $data['comment_text'];
|
60 |
+
}
|
61 |
+
}
|
62 |
+
/*------------------------------checking checkbox status ------------------------------------------------------*/
|
63 |
+
if($data['return_credits'] == 1){
|
64 |
+
|
65 |
+
$arr['status'] = $data['return_credits'];
|
66 |
+
$arr['credits'] = $data['returncredits'];
|
67 |
+
Mage::getSingleton('adminhtml/session')->setTotal($arr);
|
68 |
+
|
69 |
+
}else{
|
70 |
+
if (isset($data['do_refund'])) {
|
71 |
+
$creditmemo->setRefundRequested(true);
|
72 |
+
}
|
73 |
+
if (isset($data['do_offline'])) {
|
74 |
+
$creditmemo->setOfflineRequested((bool)(int)$data['do_offline']);
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
/* --------------------------------------------------------------------------------------- */
|
79 |
+
|
80 |
+
$creditmemo->register();
|
81 |
+
if (!empty($data['send_email'])) {
|
82 |
+
$creditmemo->setEmailSent(true);
|
83 |
+
}
|
84 |
+
|
85 |
+
$creditmemo->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
|
86 |
+
|
87 |
+
$this->_saveCreditmemo($creditmemo);
|
88 |
+
$creditmemo->sendEmail(!empty($data['send_email']), $comment);
|
89 |
+
$this->_getSession()->addSuccess($this->__('The credit memo has been created.'));
|
90 |
+
|
91 |
+
Mage::getSingleton('adminhtml/session')->getCommentText(true);
|
92 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $creditmemo->getOrderId()));
|
93 |
+
|
94 |
+
return;
|
95 |
+
} else {
|
96 |
+
$this->_forward('noRoute');
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
} catch (Mage_Core_Exception $e) {
|
100 |
+
$this->_getSession()->addError($e->getMessage());
|
101 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
102 |
+
} catch (Exception $e) {
|
103 |
+
Mage::logException($e);
|
104 |
+
$this->_getSession()->addError($this->__('Cannot save the credit memo.'));
|
105 |
+
}
|
106 |
+
$this->_redirect('*/*/new', array('_current' => true));
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/Checkout/OnepageController.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
3 |
+
class Kartparadigm_StoreCredit_Checkout_OnepageController extends Mage_Checkout_OnepageController
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Save payment ajax action
|
7 |
+
*
|
8 |
+
* Sets either redirect or a JSON response
|
9 |
+
*/
|
10 |
+
public function savePaymentAction()
|
11 |
+
{
|
12 |
+
if ($this->_expireAjax()) {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
try {
|
16 |
+
if (!$this->getRequest()->isPost()) {
|
17 |
+
$this->_ajaxRedirectResponse();
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
$data = $this->getRequest()->getPost('payment', array());
|
22 |
+
$result = $this->getOnepage()->savePayment($data);
|
23 |
+
|
24 |
+
// get section and redirect data
|
25 |
+
$redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
|
26 |
+
if (empty($result['error']) && !$redirectUrl) {
|
27 |
+
$this->loadLayout('checkout_onepage_review');
|
28 |
+
$result['goto_section'] = 'review';
|
29 |
+
$result['update_section'] = array(
|
30 |
+
'name' => 'review',
|
31 |
+
'html' => $this->_getReviewHtml()
|
32 |
+
);
|
33 |
+
}
|
34 |
+
if ($redirectUrl) {
|
35 |
+
$result['redirect'] = $redirectUrl;
|
36 |
+
}
|
37 |
+
} catch (Mage_Payment_Exception $e) {
|
38 |
+
if ($e->getFields()) {
|
39 |
+
$result['fields'] = $e->getFields();
|
40 |
+
}
|
41 |
+
$result['error'] = $e->getMessage();
|
42 |
+
} catch (Mage_Core_Exception $e) {
|
43 |
+
$result['error'] = $e->getMessage();
|
44 |
+
} catch (Exception $e) {
|
45 |
+
Mage::logException($e);
|
46 |
+
$result['error'] = $this->__('Unable to set Payment Method.');
|
47 |
+
}
|
48 |
+
|
49 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
50 |
+
}
|
51 |
+
/**
|
52 |
+
* Order success action
|
53 |
+
*/
|
54 |
+
public function successAction()
|
55 |
+
{
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
$session = $this->getOnepage()->getCheckout();
|
60 |
+
if (!$session->getLastSuccessQuoteId()) {
|
61 |
+
$this->_redirect('checkout/cart');
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
$lastQuoteId = $session->getLastQuoteId();
|
66 |
+
$lastOrderId = $session->getLastOrderId();
|
67 |
+
$lastRecurringProfiles = $session->getLastRecurringProfileIds();
|
68 |
+
if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
|
69 |
+
$this->_redirect('checkout/cart');
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$session->clear();
|
74 |
+
$this->loadLayout();
|
75 |
+
$this->_initLayoutMessages('checkout/session');
|
76 |
+
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
$this->renderLayout();
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/controllers/IndexController.php
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kartparadigm_StoreCredit_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
/* ---------------------- Display The Store Credit Account --------------------------------------------- */
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
/* -----------------Checking Customer Is Login Or Not ------------------------------------------------- */
|
8 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
9 |
+
$handles = array('default');
|
10 |
+
$handles[] = 'customer_account';// setting the handle for same layout
|
11 |
+
$this->loadLayout($handles);
|
12 |
+
$this->renderLayout();
|
13 |
+
}
|
14 |
+
else
|
15 |
+
$this->_redirect('customer/account/login');
|
16 |
+
}
|
17 |
+
/* ------------------------------ Apply Credit TO The Total -------------------------------------------------------- */
|
18 |
+
public function applyCreditsAction()
|
19 |
+
{
|
20 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
21 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
22 |
+
$id = $customerData->getId();
|
23 |
+
$creditData = array();
|
24 |
+
$data = $this->getRequest()->getParam('Credits');
|
25 |
+
//Mage::log($data);
|
26 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->addFieldToFilter('website1',Mage::app()->getWebsite()->getName())->getLastItem();
|
27 |
+
$totalcredits = $collection->getTotalCredits();
|
28 |
+
//Mage::log('totalcredits'.$totalcredits);
|
29 |
+
//$collection = Mage::getModel('tele_storecredit/creditinfo')->getCollection()->addFieldToFilter('gift_code',$data);
|
30 |
+
if(count($collection)>=1 && $data <= $totalcredits && $data > 0){
|
31 |
+
$creditData['totalCredits'] = $totalcredits;
|
32 |
+
$creditData['discountCredits'] = $data;
|
33 |
+
Mage::getSingleton('checkout/session')->setCredits($creditData);
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
else if($data > $totalcredits) {
|
38 |
+
Mage::getSingleton('checkout/session')->unsCredits();
|
39 |
+
$msg = "Please Enter Less Than Or Equal to " . $totalcredits ." Credits ";
|
40 |
+
Mage::getSingleton('core/session')->setCredits($msg);
|
41 |
+
}
|
42 |
+
else {
|
43 |
+
Mage::getSingleton('checkout/session')->unsCredits();
|
44 |
+
Mage::getSingleton('core/session')->unsBalance();
|
45 |
+
$msg = "Please Enter Greater Than 0 Credits ";
|
46 |
+
Mage::getSingleton('core/session')->setCredits($msg);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
$msg = "Please Login To Applay Credits";
|
51 |
+
Mage::getSingleton('core/session')->setCredits($msg);
|
52 |
+
}
|
53 |
+
|
54 |
+
$this->_redirect('checkout/cart/');
|
55 |
+
}
|
56 |
+
public function cancelCreditsAction()
|
57 |
+
{
|
58 |
+
|
59 |
+
$this->_redirect('checkout/cart/index');
|
60 |
+
}
|
61 |
+
|
62 |
+
public function reAction()
|
63 |
+
{
|
64 |
+
$p1 = Mage::app()->getRequest()->getPost('p1');
|
65 |
+
$response['status'] = 0;
|
66 |
+
$sidebar= $this->getLayout()->createBlock('checkout/cart_totals')->setTemplate('checkout/cart/totals.phtml')->toHtml();
|
67 |
+
$response['refreshtotalBLK'] = $sidebar;
|
68 |
+
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
|
69 |
+
}
|
70 |
+
|
71 |
+
public function updateAction()
|
72 |
+
{
|
73 |
+
|
74 |
+
$creditData['totalCredits'] = $_POST['total'];
|
75 |
+
$creditData['discountCredits'] = $_POST['discount'];
|
76 |
+
Mage::getSingleton('checkout/session')->setCredits($creditData);
|
77 |
+
Mage::getSingleton('core/session')->unsCredits();
|
78 |
+
|
79 |
+
//Mage::log($_POST);
|
80 |
+
|
81 |
+
|
82 |
+
}
|
83 |
+
/* --------------------------------- sharing credits to friend---------------------------------------------------- */
|
84 |
+
public function sendcreditsAction()
|
85 |
+
{
|
86 |
+
|
87 |
+
$data = $this->getRequest()->getParams();
|
88 |
+
Mage::log($data);
|
89 |
+
|
90 |
+
$collection1 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$data['id'])->addFieldToFilter('website1','Main Website')->getLastItem();
|
91 |
+
if($collection1->getTotalCredits() >= $data['credits']){
|
92 |
+
|
93 |
+
/*-------------------- value store in sendcreditstofriend table-------------------------------------*/
|
94 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
95 |
+
$nowdate = date('Y-m-d H:m:s', $currentTimestamp);
|
96 |
+
$arr = array();
|
97 |
+
$arr1 = array();
|
98 |
+
$arr['s_id'] = $data['id'];
|
99 |
+
$arr['receiver_name'] = $data['name'];
|
100 |
+
$arr['receiver_email'] = $data['email'];
|
101 |
+
$arr['credits'] = $data['credits'];
|
102 |
+
$arr['message'] = $data['message'];
|
103 |
+
$arr['date'] = $nowdate;
|
104 |
+
$arr['status'] = 0;
|
105 |
+
$arr['sname'] = $data['sname'];
|
106 |
+
/*-----------------------------------------------------------------------------------------*/
|
107 |
+
|
108 |
+
|
109 |
+
//Mage::log($arr['date']);
|
110 |
+
$users = mage::getModel('customer/customer')->getCollection()
|
111 |
+
->addAttributeToSelect('email');
|
112 |
+
|
113 |
+
foreach ($users as $user)
|
114 |
+
{
|
115 |
+
|
116 |
+
if($user->getData()['email'] == $arr['receiver_email'])
|
117 |
+
{
|
118 |
+
|
119 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$user->getData()['entity_id'])->addFieldToFilter('website1','Main Website')->getLastItem();
|
120 |
+
|
121 |
+
/* ------------------------if the customer exists add credits to his account -------------------------------------- */
|
122 |
+
$arr1['c_id'] = $user->getData()['entity_id'];
|
123 |
+
$arr1['website1'] = "Main Website";
|
124 |
+
$arr1['action_credits'] = $data['credits'];
|
125 |
+
$arr1['total_credits'] = $collection->getTotalCredits() + $data['credits'];
|
126 |
+
$arr1['action'] = "Updated";
|
127 |
+
$arr1['state'] = 0;
|
128 |
+
$arr1['store_view'] = Mage::app()->getStore()->getName();
|
129 |
+
$arr1['action_date'] = $nowdate;
|
130 |
+
$arr1['custom_msg'] = "Send By : " . $data['sname']." Message( ".$data['message']." )";
|
131 |
+
$arr1['customer_notification_status'] = 'No';
|
132 |
+
|
133 |
+
$arr['status'] = 1;
|
134 |
+
|
135 |
+
$table1 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
136 |
+
$table1->setData($arr1);
|
137 |
+
|
138 |
+
/*-------------------------------------------------------------------------------------*/
|
139 |
+
try{
|
140 |
+
|
141 |
+
$table1->save();
|
142 |
+
//$this->_redirect('*/*/');
|
143 |
+
|
144 |
+
}catch(Exception $e){
|
145 |
+
Mage::log($e);
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
149 |
+
}
|
150 |
+
/*-----------------------------------deduct the sender credits from sender store credit account ---------------------------*/
|
151 |
+
$arr2['c_id'] = $data['id'];
|
152 |
+
$arr2['website1'] = "Main Website";
|
153 |
+
$arr2['action_credits'] = -$data['credits'];
|
154 |
+
$collection1 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$data['id'])->addFieldToFilter('website1','Main Website')->getLastItem();
|
155 |
+
|
156 |
+
$arr2['total_credits'] = $collection1->getTotalCredits() - $data['credits'];
|
157 |
+
$arr2['action'] = "Updated";
|
158 |
+
$arr2['state'] = 0;
|
159 |
+
$arr2['store_view'] = Mage::app()->getStore()->getName();
|
160 |
+
$arr2['action_date'] = $nowdate;
|
161 |
+
$arr2['custom_msg'] = "Send To : " . $data['name']." Message( ".$data['message']." )";
|
162 |
+
$arr2['customer_notification_status'] = 'No';
|
163 |
+
|
164 |
+
|
165 |
+
$table2 = Mage::getModel('kartparadigm_storecredit/creditinfo');
|
166 |
+
$table2->setData($arr2);
|
167 |
+
|
168 |
+
$table = Mage::getModel('kartparadigm_storecredit/sendcreditstofriend');
|
169 |
+
$table->setData($arr);
|
170 |
+
try{
|
171 |
+
|
172 |
+
$table->save();
|
173 |
+
$table2->save();
|
174 |
+
|
175 |
+
$emailTemplate = Mage::getModel('core/email_template')
|
176 |
+
->loadDefault('caritor_email_template1');
|
177 |
+
$name = Mage::getStoreConfig('mycustom_section/mycustom_group1/sender_email_identity');
|
178 |
+
$group = "ident_".$name;
|
179 |
+
|
180 |
+
$email = Mage::getStoreConfig('trans_email/'.$group.'/email');
|
181 |
+
|
182 |
+
|
183 |
+
$emailTemplateVariables = array();
|
184 |
+
$emailTemplateVariables['var1'] = $data['name'];
|
185 |
+
$emailTemplateVariables['var2'] = $data['credits'];
|
186 |
+
$emailTemplateVariables['var3'] = $data['sname'];
|
187 |
+
$emailTemplateVariables['var4'] = $nowdate;
|
188 |
+
$emailTemplateVariables['var5'] = $data['message'];
|
189 |
+
$emailTemplateVariables['var8'] = "http://localhost/jaypore/index.php/customer/account/login/";
|
190 |
+
|
191 |
+
$emailTemplate->getProcessedTemplate($emailTemplateVariables);
|
192 |
+
//Mage::log($name);
|
193 |
+
|
194 |
+
$emailTemplate->setSenderName($name);
|
195 |
+
$emailTemplate->setSenderEmail($email);
|
196 |
+
$emailTemplate->setReplyTo($email);
|
197 |
+
try {
|
198 |
+
$emailTemplate->send($data['email'], $data['name'], $emailTemplateVariables);
|
199 |
+
} catch (Exception $e) {
|
200 |
+
echo $e->getMessage();
|
201 |
+
}
|
202 |
+
|
203 |
+
}catch(Exception $e){
|
204 |
+
Mage::log($e);
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
else{
|
209 |
+
$msg = "Please Enter less than " . $collection1->getTotalCredits()." Credits";
|
210 |
+
Mage::getSingleton("core/session")->setMsg($msg);
|
211 |
+
|
212 |
+
}
|
213 |
+
$this->_redirect('*/*/');
|
214 |
+
}
|
215 |
+
}
|
app/code/community/Kartparadigm/StoreCredit/etc/adminhtml.xml
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<kartparadigm_storecredit module="kartparadigm_storecredit">
|
5 |
+
<title>Store Credit</title>
|
6 |
+
<sort_order>71</sort_order>
|
7 |
+
<children>
|
8 |
+
<settings module="kartparadigm_storecredit">
|
9 |
+
<title>Settings</title>
|
10 |
+
<sort_order>0</sort_order>
|
11 |
+
<action>adminhtml/credits/settings</action>
|
12 |
+
</settings>
|
13 |
+
<customers module="kartparadigm_storecredit">
|
14 |
+
<title>Manage Customer Credits</title>
|
15 |
+
<sort_order>0</sort_order>
|
16 |
+
<action>adminhtml/credits/customer</action>
|
17 |
+
</customers>
|
18 |
+
<transactions module="kartparadigm_storecredit">
|
19 |
+
<title>Manage Transactions</title>
|
20 |
+
<sort_order>0</sort_order>
|
21 |
+
<action>adminhtml/credits/index</action>
|
22 |
+
</transactions>
|
23 |
+
</children>
|
24 |
+
</kartparadigm_storecredit>
|
25 |
+
|
26 |
+
</menu>
|
27 |
+
|
28 |
+
<acl>
|
29 |
+
<resources>
|
30 |
+
<admin>
|
31 |
+
<children>
|
32 |
+
<storecredit translate="title" module="kartparadigm_storecredit">
|
33 |
+
<title>Credits</title>
|
34 |
+
<sort_order>300</sort_order>
|
35 |
+
<children>
|
36 |
+
<transactions translate="title" module="kartparadigm_storecredit">
|
37 |
+
<title>Credits</title>
|
38 |
+
<sort_order>0</sort_order>
|
39 |
+
</transactions>
|
40 |
+
<customers translate="title" module="kartparadigm_storecredit">
|
41 |
+
<title>Credits</title>
|
42 |
+
<sort_order>0</sort_order>
|
43 |
+
</customers>
|
44 |
+
<settings translate="title" module="kartparadigm_storecredit">
|
45 |
+
<title>Credits</title>
|
46 |
+
<sort_order>0</sort_order>
|
47 |
+
</settings>
|
48 |
+
</children>
|
49 |
+
</storecredit>
|
50 |
+
<system>
|
51 |
+
<children>
|
52 |
+
<config>
|
53 |
+
<children>
|
54 |
+
<mycustom_section translate="title" module="kartparadigm_storecredit">
|
55 |
+
<title>My Custom Section</title>
|
56 |
+
<sort_order>100</sort_order>
|
57 |
+
</mycustom_section>
|
58 |
+
</children>
|
59 |
+
</config>
|
60 |
+
</children>
|
61 |
+
</system>
|
62 |
+
</children>
|
63 |
+
</admin>
|
64 |
+
</resources>
|
65 |
+
</acl>
|
66 |
+
|
67 |
+
</config>
|
68 |
+
|
app/code/community/Kartparadigm/StoreCredit/etc/config.xml
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Kartparadigm_StoreCredit>
|
5 |
+
<version>0.9.0</version>
|
6 |
+
</Kartparadigm_StoreCredit>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<kartparadigm_storecredit>
|
11 |
+
<class>Kartparadigm_StoreCredit_Model</class>
|
12 |
+
<resourceModel>kartparadigm_storecredit_mysql4</resourceModel>
|
13 |
+
</kartparadigm_storecredit>
|
14 |
+
<kartparadigm_storecredit_mysql4>
|
15 |
+
<class>Kartparadigm_StoreCredit_Model_Mysql4</class>
|
16 |
+
<entities>
|
17 |
+
<creditinfo>
|
18 |
+
<table>kartparadigm_storecredit_creditinfo</table>
|
19 |
+
</creditinfo>
|
20 |
+
<sendcreditstofriend>
|
21 |
+
<table>kartparadigm_storecredit_sendcreditstofriend</table>
|
22 |
+
</sendcreditstofriend>
|
23 |
+
</entities>
|
24 |
+
</kartparadigm_storecredit_mysql4>
|
25 |
+
<core>
|
26 |
+
<rewrite>
|
27 |
+
<resource_transaction>Kartparadigm_StoreCredit_Model_Resource_Transaction</resource_transaction>
|
28 |
+
</rewrite>
|
29 |
+
</core>
|
30 |
+
<catalogrule_resource>
|
31 |
+
<rewrite>
|
32 |
+
<rule>Kartparadigm_StoreCredit_Model_Resource_Rule</rule>
|
33 |
+
</rewrite>
|
34 |
+
</catalogrule_resource>
|
35 |
+
</models>
|
36 |
+
<blocks>
|
37 |
+
<kartparadigm_storecredit>
|
38 |
+
<class>Kartparadigm_StoreCredit_Block</class>
|
39 |
+
<!--this is a new block page for that custom module-->
|
40 |
+
</kartparadigm_storecredit>
|
41 |
+
|
42 |
+
</blocks>
|
43 |
+
<helpers>
|
44 |
+
<kartparadigm_storecredit>
|
45 |
+
<class>Kartparadigm_StoreCredit_Helper</class>
|
46 |
+
</kartparadigm_storecredit>
|
47 |
+
</helpers>
|
48 |
+
<resources>
|
49 |
+
<kartparadigm_storecredit_setup>
|
50 |
+
<setup>
|
51 |
+
<module>Kartparadigm_StoreCredit</module>
|
52 |
+
<class>Kartparadigm_StoreCredit_Model_Resource_Setup</class>
|
53 |
+
</setup>
|
54 |
+
<connection>
|
55 |
+
<use>core_setup</use>
|
56 |
+
</connection>
|
57 |
+
</kartparadigm_storecredit_setup>
|
58 |
+
<kartparadigm_storecredit_write>
|
59 |
+
<connection>
|
60 |
+
<use>core_write</use>
|
61 |
+
</connection>
|
62 |
+
</kartparadigm_storecredit_write>
|
63 |
+
<kartparadigm_storecredit_read>
|
64 |
+
<connection>
|
65 |
+
<use>core_read</use>
|
66 |
+
</connection>
|
67 |
+
</kartparadigm_storecredit_read>
|
68 |
+
</resources>
|
69 |
+
<events>
|
70 |
+
<sales_quote_collect_totals_after>
|
71 |
+
<observers>
|
72 |
+
<kartparadigm_storecredit>
|
73 |
+
<type>singleton</type>
|
74 |
+
<class>Kartparadigm_StoreCredit_Model_Observer</class>
|
75 |
+
<method>set_credits_discountamount</method>
|
76 |
+
</kartparadigm_storecredit>
|
77 |
+
</observers>
|
78 |
+
</sales_quote_collect_totals_after>
|
79 |
+
<sales_order_place_after>
|
80 |
+
<observers>
|
81 |
+
<kartparadigm_storecredit>
|
82 |
+
<class>kartparadigm_storecredit/observer</class>
|
83 |
+
<method>debitOrder</method>
|
84 |
+
</kartparadigm_storecredit>
|
85 |
+
</observers>
|
86 |
+
</sales_order_place_after>
|
87 |
+
<sales_order_creditmemo_save_before>
|
88 |
+
<observers>
|
89 |
+
<kartparadigm_storecredit>
|
90 |
+
<class>kartparadigm_storecredit/observer</class>
|
91 |
+
<method>addCredits</method>
|
92 |
+
</kartparadigm_storecredit>
|
93 |
+
</observers>
|
94 |
+
</sales_order_creditmemo_save_before>
|
95 |
+
<sales_convert_order_to_quote>
|
96 |
+
<observers>
|
97 |
+
<kartparadigm_storecredit>
|
98 |
+
<class>kartparadigm_storecredit/observer</class>
|
99 |
+
<method>unset_session_inreorder</method>
|
100 |
+
</kartparadigm_storecredit>
|
101 |
+
</observers>
|
102 |
+
</sales_convert_order_to_quote>
|
103 |
+
<customer_login>
|
104 |
+
<observers>
|
105 |
+
<kartparadigm_storecredit>
|
106 |
+
<class>kartparadigm_storecredit/observer</class>
|
107 |
+
<method>assigncredits</method>
|
108 |
+
</kartparadigm_storecredit>
|
109 |
+
</observers>
|
110 |
+
</customer_login>
|
111 |
+
<catalog_product_load_after>
|
112 |
+
<observers>
|
113 |
+
<kartparadigm_storecredit>
|
114 |
+
<type>model</type>
|
115 |
+
<class>kartparadigm_storecredit/observer</class>
|
116 |
+
<method>catalogProductLoadAfter</method>
|
117 |
+
</kartparadigm_storecredit>
|
118 |
+
</observers>
|
119 |
+
</catalog_product_load_after>
|
120 |
+
<sales_convert_quote_item_to_order_item>
|
121 |
+
<observers>
|
122 |
+
<kartparadigm_storecredit>
|
123 |
+
<type>model</type>
|
124 |
+
<class>kartparadigm_storecredit/observer</class>
|
125 |
+
<method>salesConvertQuoteItemToOrderItem</method>
|
126 |
+
</kartparadigm_storecredit>
|
127 |
+
</observers>
|
128 |
+
</sales_convert_quote_item_to_order_item>
|
129 |
+
<sales_order_invoice_save_after>
|
130 |
+
<observers>
|
131 |
+
<kartparadigm_storecredit>
|
132 |
+
<type>model</type>
|
133 |
+
<class>kartparadigm_storecredit/observer</class>
|
134 |
+
<method>getCustomOptionsOfProduct</method>
|
135 |
+
</kartparadigm_storecredit>
|
136 |
+
</observers>
|
137 |
+
</sales_order_invoice_save_after>
|
138 |
+
<checkout_cart_product_add_after>
|
139 |
+
<observers>
|
140 |
+
<kartparadigm_storecredit>
|
141 |
+
<type>model</type>
|
142 |
+
<class>kartparadigm_storecredit/observer</class>
|
143 |
+
<method>addCreditsToCart</method>
|
144 |
+
</kartparadigm_storecredit>
|
145 |
+
</observers>
|
146 |
+
</checkout_cart_product_add_after>
|
147 |
+
<sales_order_item_cancel>
|
148 |
+
<observers>
|
149 |
+
<kartparadigm_storecredit>
|
150 |
+
<type>model</type>
|
151 |
+
<class>kartparadigm_storecredit/observer</class>
|
152 |
+
<method>addCancelOrderCredits</method>
|
153 |
+
</kartparadigm_storecredit>
|
154 |
+
</observers>
|
155 |
+
</sales_order_item_cancel>
|
156 |
+
<adminhtml_system_config_advanced_disableoutput_render_before>
|
157 |
+
<observers>
|
158 |
+
<kartparadigm_storecredit>
|
159 |
+
<type>model</type>
|
160 |
+
<class>kartparadigm_storecredit/observer</class>
|
161 |
+
<method>disableModule</method>
|
162 |
+
</kartparadigm_storecredit>
|
163 |
+
</observers>
|
164 |
+
</adminhtml_system_config_advanced_disableoutput_render_before>
|
165 |
+
</events>
|
166 |
+
<template>
|
167 |
+
<email>
|
168 |
+
<caritor_email_template translate="label" module="kartparadigm_storecredit">
|
169 |
+
<label>Updating Store Credits</label>
|
170 |
+
<file>caritor_email_template.html</file>
|
171 |
+
<type>html</type>
|
172 |
+
</caritor_email_template>
|
173 |
+
<caritor_email_template1 translate="label" module="kartparadigm_storecredit">
|
174 |
+
<label>Sharing Store Credits</label>
|
175 |
+
<file>caritor_email_template1.html</file>
|
176 |
+
<type>html</type>
|
177 |
+
</caritor_email_template1>
|
178 |
+
</email>
|
179 |
+
</template>
|
180 |
+
</global>
|
181 |
+
<frontend>
|
182 |
+
<routers>
|
183 |
+
<checkout>
|
184 |
+
<args>
|
185 |
+
<modules>
|
186 |
+
<Kartparadigm_StoreCredit before='Mage_Checkout'>Kartparadigm_StoreCredit_Checkout</Kartparadigm_StoreCredit>
|
187 |
+
</modules>
|
188 |
+
</args>
|
189 |
+
</checkout>
|
190 |
+
<kartparadigm_storecredit>
|
191 |
+
<use>standard</use>
|
192 |
+
<args>
|
193 |
+
<module>Kartparadigm_StoreCredit</module>
|
194 |
+
<frontName>storecredit</frontName>
|
195 |
+
</args>
|
196 |
+
</kartparadigm_storecredit>
|
197 |
+
</routers>
|
198 |
+
<layout>
|
199 |
+
<updates>
|
200 |
+
<kartparadigm_storecredit module="Kartparadigm_StoreCredit">
|
201 |
+
<file>credit.xml</file>
|
202 |
+
</kartparadigm_storecredit>
|
203 |
+
</updates>
|
204 |
+
</layout>
|
205 |
+
</frontend>
|
206 |
+
<admin>
|
207 |
+
<routers>
|
208 |
+
<adminhtml>
|
209 |
+
<args>
|
210 |
+
<modules>
|
211 |
+
<kartparadigm_storecredit before="Mage_Adminhtml">Kartparadigm_StoreCredit_Adminhtml</kartparadigm_storecredit>
|
212 |
+
</modules>
|
213 |
+
</args>
|
214 |
+
</adminhtml>
|
215 |
+
</routers>
|
216 |
+
</admin>
|
217 |
+
<adminhtml>
|
218 |
+
<layout>
|
219 |
+
<updates>
|
220 |
+
<kartparadigm_storecredit module="kartparadigm_storecredit">
|
221 |
+
<file>credit.xml</file>
|
222 |
+
</kartparadigm_storecredit>
|
223 |
+
</updates>
|
224 |
+
</layout>
|
225 |
+
</adminhtml>
|
226 |
+
</config>
|
app/code/community/Kartparadigm/StoreCredit/etc/system.xml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<mycustom_tab module="kartparadigm_storecredit" translate="label">
|
5 |
+
<label>KartParadigm Extensions</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</mycustom_tab>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<mycustom_section module="kartparadigm_storecredit" translate="label">
|
11 |
+
<label>Store Credit</label>
|
12 |
+
<sort_order>200</sort_order>
|
13 |
+
<show_in_default>1</show_in_default>
|
14 |
+
<show_in_website>1</show_in_website>
|
15 |
+
<show_in_store>1</show_in_store>
|
16 |
+
<tab>mycustom_tab</tab>
|
17 |
+
<groups>
|
18 |
+
|
19 |
+
<mycustom_group4 translate="label">
|
20 |
+
<label>Credit Rate Settings</label>
|
21 |
+
|
22 |
+
<sort_order>10</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<field2 translate="label tooltip comment">
|
28 |
+
<label>Base Currency Value</label>
|
29 |
+
<comment>Enter Base Currency Value which is equls to number of credits</comment>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
</field2>
|
35 |
+
<field1 translate="label tooltip comment">
|
36 |
+
<label>Number Of Credits</label>
|
37 |
+
<comment>Enter number of credits equals to base currency setting</comment>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>1</show_in_store>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
</field1>
|
43 |
+
|
44 |
+
</fields>
|
45 |
+
</mycustom_group4>
|
46 |
+
<mycustom_group translate="label">
|
47 |
+
<label>Redeemed Settings</label>
|
48 |
+
|
49 |
+
<sort_order>10</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<fields>
|
54 |
+
<field3 translate="label tooltip comment">
|
55 |
+
<label> Deduct Credits Of the Order While Refund </label>
|
56 |
+
<comment> Deduct Credits Of the Order At The Time Of Refund? </comment>
|
57 |
+
<tooltip> Select Yes/No Deduct Credits of the order At The Time Of Refund </tooltip>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
<frontend_type>select</frontend_type>
|
62 |
+
<source_model>kartparadigm_storecredit/source</source_model>
|
63 |
+
</field3>
|
64 |
+
<field1 translate="label tooltip comment">
|
65 |
+
<label>Apply Redeemed Credits To Tax Price</label>
|
66 |
+
<comment>Store Credits Deducted From Tax Price</comment>
|
67 |
+
<tooltip>Select Yes/No To Apply Credits To Tax Price</tooltip>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
<frontend_type>select</frontend_type>
|
72 |
+
<source_model>kartparadigm_storecredit/source</source_model>
|
73 |
+
</field1>
|
74 |
+
<field2 translate="label tooltip comment">
|
75 |
+
<label>Apply Redeemed Credits To Shipping Price</label>
|
76 |
+
<comment>Store Credits Deducted From Shipping Price</comment>
|
77 |
+
<tooltip>Select Yes/No To Apply Credits To Shipping Price Price</tooltip>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>1</show_in_website>
|
80 |
+
<show_in_store>1</show_in_store>
|
81 |
+
<frontend_type>select</frontend_type>
|
82 |
+
<source_model>kartparadigm_storecredit/source</source_model>
|
83 |
+
</field2>
|
84 |
+
</fields>
|
85 |
+
</mycustom_group>
|
86 |
+
<mycustom_group1 translate="label">
|
87 |
+
<label>Email Setting</label>
|
88 |
+
|
89 |
+
<sort_order>10</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
<fields>
|
94 |
+
<sender_email_identity translate="label">
|
95 |
+
<label>Email Sender</label>
|
96 |
+
<frontend_type>select</frontend_type>
|
97 |
+
<source_model>adminhtml/system_config_source_email_identity</source_model>
|
98 |
+
<sort_order>20</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>1</show_in_website>
|
101 |
+
<show_in_store>1</show_in_store>
|
102 |
+
</sender_email_identity>
|
103 |
+
<caritor_email_template translate="label">
|
104 |
+
<label>Email Template</label>
|
105 |
+
<frontend_type>select</frontend_type>
|
106 |
+
<source_model>adminhtml/system_config_source_email_template</source_model>
|
107 |
+
<sort_order>40</sort_order>
|
108 |
+
<show_in_default>1</show_in_default>
|
109 |
+
<show_in_website>1</show_in_website>
|
110 |
+
<show_in_store>1</show_in_store>
|
111 |
+
</caritor_email_template>
|
112 |
+
|
113 |
+
|
114 |
+
</fields>
|
115 |
+
</mycustom_group1>
|
116 |
+
<mycustom_group2 translate="label">
|
117 |
+
<label>Enable</label>
|
118 |
+
|
119 |
+
<sort_order>10</sort_order>
|
120 |
+
<show_in_default>1</show_in_default>
|
121 |
+
<show_in_website>1</show_in_website>
|
122 |
+
<show_in_store>1</show_in_store>
|
123 |
+
<fields>
|
124 |
+
<field1 translate="label tooltip comment">
|
125 |
+
<label>Enable</label>
|
126 |
+
<comment>Choose Yes To Enable This Module</comment>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
<frontend_type>select</frontend_type>
|
131 |
+
<source_model>kartparadigm_storecredit/source</source_model>
|
132 |
+
</field1>
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
</fields>
|
137 |
+
</mycustom_group2>
|
138 |
+
|
139 |
+
</groups>
|
140 |
+
</mycustom_section>
|
141 |
+
</sections>
|
142 |
+
</config>
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Create Registry Gift Table
|
8 |
+
*
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
$tableName = $installer->getTable('kartparadigm_storecredit/creditinfo');
|
13 |
+
// Check if the table already exists
|
14 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
15 |
+
$table = $installer->getConnection()
|
16 |
+
->newTable($installer->getTable('kartparadigm_storecredit/creditinfo'))
|
17 |
+
->addColumn('t_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'identity' => true,
|
19 |
+
'unsigned' => true,
|
20 |
+
'nullable' => false,
|
21 |
+
'primary' => true,
|
22 |
+
), 'Transaction Id')
|
23 |
+
->addColumn('c_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 25, array(
|
24 |
+
'nullable' => true,
|
25 |
+
), 'Customer Id')
|
26 |
+
->addColumn('website1', Varien_Db_Ddl_Table::TYPE_VARCHAR, 25, array(
|
27 |
+
'nullable' => true,
|
28 |
+
), 'Website')
|
29 |
+
->addColumn('total_credits', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
30 |
+
'nullable' => true,
|
31 |
+
), 'Total Credits')
|
32 |
+
->addColumn('action_credits', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
33 |
+
'nullable' => true,
|
34 |
+
), 'Credit Due To Action')
|
35 |
+
->addColumn('action', Varien_Db_Ddl_Table::TYPE_VARCHAR, 25, array(
|
36 |
+
'nullable' => true,
|
37 |
+
), 'Operaration On Credits')
|
38 |
+
->addColumn('state', Varien_Db_Ddl_Table::TYPE_INTEGER, 2, array(
|
39 |
+
'nullable' => true,
|
40 |
+
), 'State Of Credits')
|
41 |
+
->addColumn('store_view', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
42 |
+
'nullable' => true,
|
43 |
+
), 'Store View')
|
44 |
+
->addColumn('action_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
45 |
+
array(),
|
46 |
+
'Created Date')
|
47 |
+
->addColumn('custom_msg', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(
|
48 |
+
'nullable' => true,
|
49 |
+
), 'Custom Message')
|
50 |
+
->addColumn('customer_notification_status', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(
|
51 |
+
'nullable' => true,
|
52 |
+
), 'Customer Notification Status')
|
53 |
+
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 100, array(
|
54 |
+
'nullable' => true,
|
55 |
+
), 'Order For Credits')
|
56 |
+
->addForeignKey(
|
57 |
+
$installer->getFkName(
|
58 |
+
'kartparadigm_storecredit/creditinfo',
|
59 |
+
'c_id',
|
60 |
+
'customer/entity',
|
61 |
+
'entity_id'
|
62 |
+
),
|
63 |
+
'c_id', $installer->getTable('customer/entity'), 'entity_id',
|
64 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE);
|
65 |
+
$installer->getConnection()->createTable($table);
|
66 |
+
}
|
67 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.1.0-0.2.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('sales_flat_order'),
|
10 |
+
'refundedstorecredit_amount',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Refundedstorecredit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.2.0-0.3.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('sales_flat_creditmemo'),
|
10 |
+
'refundedstorecredit_amount',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Refundedstorecredit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.3.0-0.4.0.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Create Sending Credits Tables Of Store Credit
|
8 |
+
*
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
$tableName = $installer->getTable('kartparadigm_storecredit/sendcreditstofriend');
|
13 |
+
// Check if the table already exists
|
14 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
15 |
+
$table = $installer->getConnection()
|
16 |
+
->newTable($installer->getTable('kartparadigm_storecredit/sendcreditstofriend'))
|
17 |
+
->addColumn('receiver_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'identity' => true,
|
19 |
+
'unsigned' => true,
|
20 |
+
'nullable' => false,
|
21 |
+
'primary' => true,
|
22 |
+
), 'Receiver Id')
|
23 |
+
->addColumn('s_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 25, array(
|
24 |
+
'nullable' => true,
|
25 |
+
), 'Sender Id')
|
26 |
+
->addColumn('sname', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
|
27 |
+
'nullable' => true,
|
28 |
+
), 'Sender Name')
|
29 |
+
->addColumn('receiver_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 25, array(
|
30 |
+
'nullable' => true,
|
31 |
+
), 'Receiver Name')
|
32 |
+
->addColumn('receiver_email', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
33 |
+
'nullable' => true,
|
34 |
+
), 'Receiver Email')
|
35 |
+
->addColumn('credits', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
36 |
+
'nullable' => true,
|
37 |
+
), 'Sending Credits')
|
38 |
+
->addColumn('message', Varien_Db_Ddl_Table::TYPE_VARCHAR, 25, array(
|
39 |
+
'nullable' => true,
|
40 |
+
), 'Message To Receiver')
|
41 |
+
->addColumn('date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
42 |
+
array(),
|
43 |
+
'Send Date')
|
44 |
+
->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
45 |
+
'nullable' => true,
|
46 |
+
), 'Status Of Shared Credits')
|
47 |
+
->addForeignKey(
|
48 |
+
$installer->getFkName(
|
49 |
+
'kartparadigm_storecredit/sendcreditstofriend',
|
50 |
+
's_id',
|
51 |
+
'customer/entity',
|
52 |
+
'entity_id'
|
53 |
+
),
|
54 |
+
's_id', $installer->getTable('customer/entity'), 'entity_id',
|
55 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE);
|
56 |
+
$installer->getConnection()->createTable($table);
|
57 |
+
}
|
58 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.4.0-0.5.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('catalogrule'),
|
10 |
+
'store_credit',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Store Credit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.5.0-0.6.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('catalogrule_product'),
|
10 |
+
'store_credit',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Store Credit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.6.0-0.7.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('sales_flat_order_item'),
|
10 |
+
'credits',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Credit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.7.0-0.8.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('kartparadigm_storecredit_creditinfo'),
|
10 |
+
'itemId',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Item Ids'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Kartparadigm/StoreCredit/sql/kartparadigm_storecredit_setup/upgrade-0.8.0-0.9.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$connection = $installer->getConnection();
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->getConnection()
|
9 |
+
->addColumn($installer->getTable('sales_flat_creditmemo'),
|
10 |
+
'base_refundedstorecredit_amount',
|
11 |
+
array(
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
13 |
+
'nullable' => true,
|
14 |
+
'default' => null,
|
15 |
+
'comment' => 'Refundedstorecredit Amount'
|
16 |
+
)
|
17 |
+
);
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/code/community/Mage/Adminhtml/Block/Sales/Totals.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Mage_Adminhtml_Block_Sales_Totals extends Mage_Sales_Block_Order_Totals
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* Format total value based on order currency
|
31 |
+
*
|
32 |
+
* @param Varien_Object $total
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function formatValue($total)
|
36 |
+
{
|
37 |
+
if (!$total->getIsFormated()) {
|
38 |
+
return $this->helper('adminhtml/sales')->displayPrices(
|
39 |
+
$this->getOrder(),
|
40 |
+
$total->getBaseValue(),
|
41 |
+
$total->getValue()
|
42 |
+
);
|
43 |
+
}
|
44 |
+
return $total->getValue();
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Initialize order totals array
|
49 |
+
*
|
50 |
+
* @return Mage_Sales_Block_Order_Totals
|
51 |
+
*/
|
52 |
+
protected function _initTotals()
|
53 |
+
{
|
54 |
+
$this->_totals = array();
|
55 |
+
$this->_totals['subtotal'] = new Varien_Object(array(
|
56 |
+
'code' => 'subtotal',
|
57 |
+
'value' => $this->getSource()->getSubtotal(),
|
58 |
+
'base_value'=> $this->getSource()->getBaseSubtotal(),
|
59 |
+
'label' => $this->helper('sales')->__('Subtotal')
|
60 |
+
));
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add shipping
|
64 |
+
*/
|
65 |
+
if (!$this->getSource()->getIsVirtual() && ((float) $this->getSource()->getShippingAmount() || $this->getSource()->getShippingDescription()))
|
66 |
+
{
|
67 |
+
$this->_totals['shipping'] = new Varien_Object(array(
|
68 |
+
'code' => 'shipping',
|
69 |
+
'value' => $this->getSource()->getShippingAmount(),
|
70 |
+
'base_value'=> $this->getSource()->getBaseShippingAmount(),
|
71 |
+
'label' => $this->helper('sales')->__('Shipping & Handling')
|
72 |
+
));
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Add discount
|
77 |
+
*/
|
78 |
+
if (((float)$this->getSource()->getDiscountAmount()) != 0) {
|
79 |
+
if ($this->getSource()->getDiscountDescription()) {
|
80 |
+
$discountLabel = $this->helper('sales')->__('%s', $this->getSource()->getDiscountDescription());
|
81 |
+
} else {
|
82 |
+
$discountLabel = $this->helper('sales')->__('Discount');
|
83 |
+
}
|
84 |
+
$this->_totals['discount'] = new Varien_Object(array(
|
85 |
+
'code' => 'discount',
|
86 |
+
'value' => $this->getSource()->getDiscountAmount(),
|
87 |
+
'base_value'=> $this->getSource()->getBaseDiscountAmount(),
|
88 |
+
'label' => $discountLabel
|
89 |
+
));
|
90 |
+
}
|
91 |
+
|
92 |
+
if (((float)$this->getSource()->getRefundedstorecreditAmount()) != 0) {
|
93 |
+
$this->_totals['refundedstorecredit_amount'] = new Varien_Object(array(
|
94 |
+
'code' => 'refundedstorecredit_amount',
|
95 |
+
'strong' => true,
|
96 |
+
'value' => $this->getSource()->getRefundedstorecreditAmount(),
|
97 |
+
'base_value'=> $this->getSource()->getBaseRefundedstorecreditAmount(),
|
98 |
+
'label' => $this->helper('sales')->__('Refunded Store Credit'),
|
99 |
+
'area' => 'footer'
|
100 |
+
));
|
101 |
+
}
|
102 |
+
$this->_totals['grand_total'] = new Varien_Object(array(
|
103 |
+
'code' => 'grand_total',
|
104 |
+
'strong' => true,
|
105 |
+
'value' => $this->getSource()->getGrandTotal(),
|
106 |
+
'base_value'=> $this->getSource()->getBaseGrandTotal(),
|
107 |
+
'label' => $this->helper('sales')->__('Grand Total'),
|
108 |
+
'area' => 'footer'
|
109 |
+
));
|
110 |
+
|
111 |
+
return $this;
|
112 |
+
}
|
113 |
+
}
|
app/design/adminhtml/default/default/layout/credit.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<adminhtml_customer_edit>
|
4 |
+
<reference name="left">
|
5 |
+
<reference name="customer_edit_tabs">
|
6 |
+
<block type="kartparadigm_storecredit/adminhtml_customer_edit_tab_credits" name="tab_credits_main"
|
7 |
+
template="kartparadigm/storecredit/customer/main.phtml">
|
8 |
+
<block
|
9 |
+
type="kartparadigm_storecredit/adminhtml_customer_edit_tab_credits_list" name="tab_credits_list" as="credits_list" />
|
10 |
+
<block
|
11 |
+
type="kartparadigm_storecredit/adminhtml_customer_edit_tab_credits_list1" name="tab_credits_list1" as="credits_list1" />
|
12 |
+
</block>
|
13 |
+
<action method="addTab">
|
14 |
+
<name>kartparadigm_storecredit</name>
|
15 |
+
<block>tab_credits_main</block>
|
16 |
+
</action>
|
17 |
+
</reference>
|
18 |
+
</reference>
|
19 |
+
</adminhtml_customer_edit>
|
20 |
+
|
21 |
+
<adminhtml_credits_index>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="kartparadigm_storecredit/adminhtml_registries" name="registries" />
|
24 |
+
</reference>
|
25 |
+
</adminhtml_credits_index>
|
26 |
+
|
27 |
+
<adminhtml_credits_customer>
|
28 |
+
<reference name="content">
|
29 |
+
<block type="kartparadigm_storecredit/adminhtml_registries1" name="registries1" />
|
30 |
+
</reference>
|
31 |
+
</adminhtml_credits_customer>
|
32 |
+
|
33 |
+
<adminhtml_sales_order_creditmemo_new>
|
34 |
+
<reference name="order_items">
|
35 |
+
<block type="adminhtml/sales_order_creditmemo_create_items" name="storecredit" as="storecredit" template="kartparadigm/storecredit/credit.phtml" />
|
36 |
+
</reference>
|
37 |
+
</adminhtml_sales_order_creditmemo_new>
|
38 |
+
|
39 |
+
<adminhtml_sales_order_creditmemo_updateqty>
|
40 |
+
<reference name="order_items">
|
41 |
+
<block type="adminhtml/sales_order_creditmemo_create_items" name="storecredit" as="storecredit" template="kartparadigm/storecredit/credit.phtml" />
|
42 |
+
</reference>
|
43 |
+
</adminhtml_sales_order_creditmemo_updateqty>
|
44 |
+
|
45 |
+
<adminhtml_sales_order_create_index>
|
46 |
+
<reference name="billing_method">
|
47 |
+
<block type="core/template" name="pay1" as="pay1" template="kartparadigm/storecredit/payment.phtml" />
|
48 |
+
</reference>
|
49 |
+
</adminhtml_sales_order_create_index>
|
50 |
+
|
51 |
+
<adminhtml_sales_order_create_load_block_billing_method>
|
52 |
+
<reference name="billing_method">
|
53 |
+
<block type="core/template" name="pay1" as="pay1" template="kartparadigm/storecredit/payment.phtml" />
|
54 |
+
</reference>
|
55 |
+
</adminhtml_sales_order_create_load_block_billing_method>
|
56 |
+
|
57 |
+
<adminhtml_customer_sendcredits>
|
58 |
+
<reference name="content">
|
59 |
+
<block type="kartparadigm_storecredit/adminhtml_registries_edit" name="edit_registry_tabs" />
|
60 |
+
</reference>
|
61 |
+
</adminhtml_customer_sendcredits>
|
62 |
+
|
63 |
+
<adminhtml_credits_showtransaction module="kartparadigm_storecredit">
|
64 |
+
<reference name="content">
|
65 |
+
<block type="kartparadigm_storecredit/adminhtml_registries1_edit" name="transaction" as="transaction" />
|
66 |
+
</reference>
|
67 |
+
</adminhtml_credits_showtransaction>
|
68 |
+
|
69 |
+
<adminhtml_promo_catalog_edit>
|
70 |
+
<reference name="promo_catalog_edit_tabs">
|
71 |
+
<block type="kartparadigm_storecredit/adminhtml_promo_catalog_edit_tab_actions" name="promo_catalog_edit_tab_actions1"/>
|
72 |
+
<action method="addTab" ifconfig="mycustom_section/mycustom_group2/field1"><name>actions_section1</name><block>kartparadigm_storecredit/adminhtml_promo_catalog_edit_tab_actions</block></action>
|
73 |
+
</reference>
|
74 |
+
</adminhtml_promo_catalog_edit>
|
75 |
+
</layout>
|
app/design/adminhtml/default/default/template/kartparadigm/storecredit/credit.phtml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- -----------------Enable Or Disable The Textfield Option -------------------------------------------------- -->
|
2 |
+
<?php if(Mage::getStoreConfigFlag('mycustom_section/mycustom_group2/field1')) : ?>
|
3 |
+
<script type="text/javascript">
|
4 |
+
function OnChangeCheckbox (checkbox) {
|
5 |
+
if (checkbox.checked) {
|
6 |
+
document.getElementById("returncredits").disabled = false;
|
7 |
+
}
|
8 |
+
else {
|
9 |
+
document.getElementById("returncredits").disabled = true;
|
10 |
+
}
|
11 |
+
}
|
12 |
+
function check(obj)
|
13 |
+
{
|
14 |
+
var amount = obj.value;
|
15 |
+
if(amount < 0)
|
16 |
+
{
|
17 |
+
alert("Store Credits Must be Positive");
|
18 |
+
|
19 |
+
}
|
20 |
+
}
|
21 |
+
</script>
|
22 |
+
<!------------------------------------------------------------------------------------------------------------- -->
|
23 |
+
<?php $creditmemo = $this->getSource();
|
24 |
+
|
25 |
+
if($creditmemo->getDiscountDescription() == "Store Credits"){
|
26 |
+
Mage::log($creditmemo->getDiscountAmount());
|
27 |
+
$total = $creditmemo->getGrandTotal() - ($creditmemo->getDiscountAmount());
|
28 |
+
}
|
29 |
+
else{
|
30 |
+
$total = $creditmemo->getGrandTotal();
|
31 |
+
}?>
|
32 |
+
|
33 |
+
<label class="normal" for="return_credits"><?php echo Mage::helper('sales')->__('Refund To Store Credit') ?></label>
|
34 |
+
<input id="return_credits" name="creditmemo[return_credits]" value="1" type="checkbox" onclick="OnChangeCheckbox (this)" />
|
35 |
+
<input type="text" value="<?php echo $total;?>" name="creditmemo[returncredits]" id="returncredits" style="width:11%" disabled="disabled" onchange="check(this)"/>
|
36 |
+
<label for="creditmemo[returncredits]" id="label"> </label>
|
37 |
+
|
38 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/kartparadigm/storecredit/customer/main.phtml
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- -----------------Enable Or Disable The Storeview Select Option -------------------------------------------------- -->
|
2 |
+
<script type="text/javascript">
|
3 |
+
function OnChangeCheckbox (checkbox) {
|
4 |
+
if (checkbox.checked) {
|
5 |
+
document.getElementById("storeview1").disabled = false;
|
6 |
+
}
|
7 |
+
else {
|
8 |
+
document.getElementById("storeview1").disabled = true;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
</script>
|
12 |
+
<!-- -------------------------------------Store Credit Balance Section------------------------------------------------- -->
|
13 |
+
|
14 |
+
|
15 |
+
<div class="entry-edit">
|
16 |
+
<div class="entry-edit-head">
|
17 |
+
<h4 class="icon-head head-customer-view"><?php echo
|
18 |
+
$this->__('Store Credit Balance') ?></h4>
|
19 |
+
</div>
|
20 |
+
<?php //echo $this->getChildHtml('credits_list1');
|
21 |
+
?>
|
22 |
+
<?php
|
23 |
+
$resource = Mage::getSingleton('core/resource');
|
24 |
+
$readConnection = $resource->getConnection('core_read');
|
25 |
+
$id = $this->getRequest()->getParam('id');
|
26 |
+
$query = 'select website1, total_credits from kartparadigm_storecredit_creditinfo where t_id in (SELECT MAX(t_id) FROM kartparadigm_storecredit_creditinfo where c_id = '. $id .' GROUP BY website1)';
|
27 |
+
$results = $readConnection->fetchAll($query);
|
28 |
+
//var_dump($results);
|
29 |
+
?>
|
30 |
+
<table class="form-list" border='1'>
|
31 |
+
<tr>
|
32 |
+
<th class="value"> Website </th>
|
33 |
+
<th class="value"> Store Credits </th>
|
34 |
+
</tr>
|
35 |
+
<?php foreach($results as $key => $val):?>
|
36 |
+
|
37 |
+
<tr>
|
38 |
+
<td class="value"><?php echo $val['website1']; ?></td>
|
39 |
+
<td class="value"><?php echo $val['total_credits'];?></td>
|
40 |
+
</tr>
|
41 |
+
<?php endforeach; ?>
|
42 |
+
</table>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
|
46 |
+
<!-- ---------------------------------------Update Balance Section------------------------------------------------------ -->
|
47 |
+
<?php
|
48 |
+
$site = Mage::getResourceModel('core/website_collection');
|
49 |
+
//foreach($site as $s){
|
50 |
+
//echo $s['name'];
|
51 |
+
//echo "<br/>";
|
52 |
+
//}
|
53 |
+
?>
|
54 |
+
<div class="entry-edit">
|
55 |
+
<div class="entry-edit-head">
|
56 |
+
<h4 class="icon-head head-customer-view"><?php echo
|
57 |
+
$this->__('Sending Credits Information') ?></h4> </div>
|
58 |
+
<?php
|
59 |
+
$col1 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$this->getRequest()->getParam('id'))->getLastItem();
|
60 |
+
?>
|
61 |
+
<table class="form-list" cellspacing="0">
|
62 |
+
<tbody>
|
63 |
+
<tr>
|
64 |
+
<td class="label"><label for="website1">Website</label></td>
|
65 |
+
<td class="value"><select id="website1" name="website1">
|
66 |
+
<?php foreach($site as $s): ?>
|
67 |
+
<option value="<?php echo $s['name'] ?>"><?php echo $s['name'] ?></option>
|
68 |
+
<?php endforeach; ?>
|
69 |
+
</select>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
|
73 |
+
<tr>
|
74 |
+
<td class="label"><label for="credit_value">Update Balance</label></td>
|
75 |
+
<td class="value">
|
76 |
+
<input id="credit_value" name="credit_value" value="" title="Add or subtract a credit value" class=" input-text" type="text"> <!--<p class="note" id="note_credit_value"><span>You can add or subtract an amount from customer’s balance by entering a number. For e.g, enter “99” to add $99 and “-99” to subtract $99</span></p> -->
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
+
<tr>
|
80 |
+
<td class="label"><label for="notification"> Notify Customer by Email </label> </td>
|
81 |
+
<td class="value"><input type="checkbox" id="notification" name="notification" onclick="OnChangeCheckbox (this)"/> </td>
|
82 |
+
|
83 |
+
</tr>
|
84 |
+
<tr>
|
85 |
+
<td class="label"><label for="storeview1"> Send Email Notification From the Following Store View </label> </td>
|
86 |
+
<td class="value"><select name="storeview1" id="storeview1" disabled='true'>
|
87 |
+
<?php
|
88 |
+
|
89 |
+
$site = Mage::app()->getWebsites();
|
90 |
+
foreach($site as $s){ ?>
|
91 |
+
<optgroup label="<?php echo $s['name'];?>">
|
92 |
+
<?php
|
93 |
+
$allStores = $s->getStoreIds();
|
94 |
+
foreach ($allStores as $_eachStoreId => $val)
|
95 |
+
{
|
96 |
+
//$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
|
97 |
+
$_storeName = Mage::app()->getStore($_eachStoreId)->getName();
|
98 |
+
//$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
99 |
+
?>
|
100 |
+
<option value="<?php echo $_storeName; ?>"><?php echo $_storeName; ?></option>
|
101 |
+
<?php
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
}
|
106 |
+
?>
|
107 |
+
</select> </td>
|
108 |
+
|
109 |
+
</tr>
|
110 |
+
|
111 |
+
<tr>
|
112 |
+
<td class="label"><label for="description">Comment</label></td>
|
113 |
+
<td class="value">
|
114 |
+
<textarea id="description" name="description" title="Comment" class=" input-text" /> </textarea> </td>
|
115 |
+
</tr>
|
116 |
+
</tbody>
|
117 |
+
</table>
|
118 |
+
|
119 |
+
|
120 |
+
</div>
|
121 |
+
|
122 |
+
<!-- -----------------------------------------Balance History Section ---------------------------------------------- -->
|
123 |
+
|
124 |
+
<div class="entry-edit">
|
125 |
+
<div class="entry-edit-head">
|
126 |
+
<h4 class="icon-head head-customer-view"><?php echo
|
127 |
+
$this->__('Transaction History') ?></h4>
|
128 |
+
</div>
|
129 |
+
<?php echo $this->getChildHtml('credits_list');
|
130 |
+
?>
|
131 |
+
</div>
|
132 |
+
|
133 |
+
|
app/design/adminhtml/default/default/template/kartparadigm/storecredit/payment.phtml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if(Mage::getStoreConfigFlag('mycustom_section/mycustom_group2/field1')) : ?>
|
2 |
+
<?php
|
3 |
+
$id = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
|
4 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->addFieldToFilter('website1','Main Website')->getLastItem();
|
5 |
+
$totalcredits = $collection->getTotalCredits();
|
6 |
+
?>
|
7 |
+
<!-- -----------------Enable Or Disable The Storeview Select Option -------------------------------------------------- -->
|
8 |
+
<script type="text/javascript">
|
9 |
+
function OnChangeCheckbox (checkbox) {
|
10 |
+
if (checkbox.checked) {
|
11 |
+
//alert('heee');
|
12 |
+
new Ajax.Request("<?php echo $this->getUrl('kartparadigm_storecredit/adminhtml_credits/usecredits') ?>", {
|
13 |
+
method: 'Post',
|
14 |
+
onComplete: function(result) {
|
15 |
+
|
16 |
+
window.location.reload(true);
|
17 |
+
|
18 |
+
}
|
19 |
+
});
|
20 |
+
}
|
21 |
+
else {
|
22 |
+
new Ajax.Request("<?php echo $this->getUrl('kartparadigm_storecredit/adminhtml_credits/unselect') ?>", {
|
23 |
+
method: 'Post',
|
24 |
+
onComplete: function(transport) {
|
25 |
+
|
26 |
+
window.location.reload(true);
|
27 |
+
|
28 |
+
}
|
29 |
+
});
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
</script>
|
35 |
+
<!-- ----------------------- script ended -------------------------------------------------------------------------- -->
|
36 |
+
|
37 |
+
|
38 |
+
<?php $session = Mage::getSingleton('core/session')->getBalance(); if(isset($session)) : ?>
|
39 |
+
<input type="checkbox" name="storecredit" id="storecredit" onclick="OnChangeCheckbox (this)" checked="checked" />
|
40 |
+
<label for="storecredit"> Use Store Credit <spam id="remaining">(<?php echo $session; ?> </spam> available) </label>
|
41 |
+
<?php else : ?>
|
42 |
+
<input type="checkbox" name="storecredit" id="storecredit" onclick="OnChangeCheckbox (this)" />
|
43 |
+
<label for="storecredit"> Use Store Credit ( <spam id="remaining"><?php echo $totalcredits;?> </spam> available) </label>
|
44 |
+
<?php endif; ?>
|
45 |
+
</div>
|
46 |
+
<div id="img">
|
47 |
+
</div>
|
48 |
+
|
49 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/kartparadigm/storecredit/storecreditview.phtml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<?php
|
3 |
+
Mage::log(Mage::getSingleton('core/session')->getMsg());
|
4 |
+
if(Mage::getSingleton('core/session')->getMsg() == 1) :
|
5 |
+
?>
|
6 |
+
<h1> Refunded To StoreCredit </h1>
|
7 |
+
<?php
|
8 |
+
Mage::getSingleton('core/session')->unsMsg();
|
9 |
+
Mage::getSingleton('core/session')->unsTotal();
|
10 |
+
?>
|
11 |
+
<?php endif; ?>
|
12 |
+
</div>
|
13 |
+
|
14 |
+
|
app/design/adminhtml/default/default/template/kartparadigm/storecredit/transaction.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$var = $this->getRequest()->getParams();
|
4 |
+
|
5 |
+
$table = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('t_id',$this->getRequest()->getParam('id'));
|
6 |
+
foreach($table as $t)
|
7 |
+
var_dump($t);
|
8 |
+
|
9 |
+
?>
|
app/design/frontend/base/default/layout/credit.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<customer_account translate="label">
|
4 |
+
<reference name="customer_account_navigation">
|
5 |
+
<action method="addLink" ifconfig="mycustom_section/mycustom_group2/field1"><name>Credits Info</name><path>storecredit</path><label>My Credits</label></action>
|
6 |
+
</reference>
|
7 |
+
</customer_account>
|
8 |
+
|
9 |
+
<kartparadigm_storecredit_index_index>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="core/template" name="credits" as="credits" template="kartparadigm/totalcredits.phtml" />
|
12 |
+
<block type="kartparadigm_storecredit/collection" name="mytransactions" as="mytransactions" template="kartparadigm/mytransactions.phtml" />
|
13 |
+
<block type="core/template" name="sendcreditstofriend" as="sendcreditstofriend" template="kartparadigm/sendcreditsform.phtml" />
|
14 |
+
<block type="kartparadigm_storecredit/credit" name="rulecredits" as="rulecredits" template="kartparadigm/rulecredits.phtml" />
|
15 |
+
</reference>
|
16 |
+
</kartparadigm_storecredit_index_index>
|
17 |
+
<checkout_onepage_index>
|
18 |
+
<reference name="checkout.onepage.payment">
|
19 |
+
<block type="core/template" name="storecredit" as="storecredit" template="kartparadigm/payment.phtml"/>
|
20 |
+
</reference>
|
21 |
+
</checkout_onepage_index>
|
22 |
+
<checkout_cart_index>
|
23 |
+
<reference name="checkout.cart">
|
24 |
+
<block type="core/text_list" name="coupon.and.discount" as="coupon">
|
25 |
+
<action method="insert">
|
26 |
+
<block>checkout.cart.coupon</block>
|
27 |
+
</action>
|
28 |
+
<block type="core/template" name="discountblock" template="kartparadigm/mycredits.phtml" after="checkout.cart.coupon" />
|
29 |
+
</block>
|
30 |
+
</reference>
|
31 |
+
</checkout_cart_index>
|
32 |
+
|
33 |
+
<checkout_onepage_paymentmethod>
|
34 |
+
<remove name="right"/>
|
35 |
+
<remove name="left"/>
|
36 |
+
|
37 |
+
<block type="checkout/onepage_payment_methods" name="root" output="toHtml" template="checkout/onepage/payment/methods.phtml">
|
38 |
+
<action method="setMethodFormTemplate" ifconfig="mycustom_section/mycustom_group2/field1"><method>purchaseorder</method><template>kartparadigm/payment.phtml</template></action>
|
39 |
+
<block type="core/template" name="checkout.onepage.payment.methods.scripts" as="scripts" />
|
40 |
+
<block type="core/template" name="checkout.onepage.payment.methods.additional" as="additional" />
|
41 |
+
</block>
|
42 |
+
</checkout_onepage_paymentmethod>
|
43 |
+
|
44 |
+
<catalog_product_view>
|
45 |
+
<reference name="product.info.extrahint">
|
46 |
+
<block type="kartparadigm_storecredit/credit" name="pcredits" as="pcredits" template="kartparadigm/product.phtml" />
|
47 |
+
</reference>
|
48 |
+
<reference name="">
|
49 |
+
|
50 |
+
|
51 |
+
</reference>
|
52 |
+
</catalog_product_view>
|
53 |
+
|
54 |
+
|
55 |
+
</layout>
|
app/design/frontend/base/default/template/kartparadigm/mycredits.phtml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::helper('kartparadigm_storecredit')->getIsEnabled()): ?>
|
2 |
+
<?php
|
3 |
+
|
4 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) :
|
5 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
6 |
+
$id = $customerData->getId();
|
7 |
+
|
8 |
+
$col2 = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->setOrder('t_id','desc')->addFieldToFilter('website1',Mage::app()->getWebsite()->getName())->setCurPage(1)->setPageSize(1);
|
9 |
+
foreach($col2 as $col)
|
10 |
+
$totalBalance = $col->getTotalCredits();
|
11 |
+
?>
|
12 |
+
<div style="border: solid 1px #DDD;margin-bottom: 2em;">
|
13 |
+
<div> <h2 style="font-size: 14px;
|
14 |
+
color: #E26703;
|
15 |
+
font-weight: bold;
|
16 |
+
margin-left: 1em;background-image: url(<?php echo $this->getSkinUrl('images/i_discount.gif') ?>);background-repeat: no-repeat;
|
17 |
+
padding: 0px 0px 0px 21px;margin-top: 10px;text-transform: uppercase;">Customer Credits </h2> </div>
|
18 |
+
<div style="margin-left: 1em;
|
19 |
+
line-height: 23px;
|
20 |
+
padding-bottom: 1em;">
|
21 |
+
<div style="font-weight: bold;"> Your Total Available Credits : <spam style="color: #1E7EC8"> <?php if($totalBalance > 0 )
|
22 |
+
echo $totalBalance ; else echo "0";?></spam></div>
|
23 |
+
<form action="<?php echo Mage::getBaseUrl()?>storecredit/index/applyCredits" method="post">
|
24 |
+
<label for="Credits"> Enter Credits To Use For Purchage </label> <br>
|
25 |
+
<input type="text" name="Credits" id="Credits" style="width: 90%;
|
26 |
+
font-size: 12px;" class="input-text required-entry" required="true" />
|
27 |
+
|
28 |
+
<button type="submit" title="Apply Coupon" class="button" value="Apply Credits" style="margin-top: 10px;"><span style="border-color: #406A83;
|
29 |
+
background: none repeat scroll 0% 0% #618499;"><span style="border-color: #406A83;
|
30 |
+
background: none repeat scroll 0% 0% #618499;">Apply Credits</span></span></button>
|
31 |
+
</form>
|
32 |
+
<?php
|
33 |
+
|
34 |
+
$credits = Mage::getSingleton('core/session')->getCredits();
|
35 |
+
if($credits){
|
36 |
+
echo "<h4 style='color:orange; font-size: 11px;margin-top: 10px;'>".$credits."</h4>";
|
37 |
+
echo "<h4 style='color:orange; font-size: 11px;margin-top: 10px;'><span style='font-size:12px;'>***</span> Credits Are Deducted After The Checkout </h4>";
|
38 |
+
}
|
39 |
+
Mage::getSingleton('core/session')->unsCredits();
|
40 |
+
|
41 |
+
?>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
<?php else : ?>
|
45 |
+
<div style="border: 1px solid #DDD;
|
46 |
+
height: 3em;
|
47 |
+
padding-top: 2em;
|
48 |
+
padding-left: 2em;
|
49 |
+
margin-bottom: 2em;">
|
50 |
+
To Apply Store Credits Please<a href="<?php echo $this->getBaseUrl()?>customer/account/login"> Login </a>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php endif; ?>
|
54 |
+
|
55 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/kartparadigm/mytransactions.phtml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style>
|
2 |
+
table, td, th {
|
3 |
+
border: 1px solid #CCC;
|
4 |
+
}
|
5 |
+
|
6 |
+
th {
|
7 |
+
background-color: #F6F6F6;
|
8 |
+
color: #000;
|
9 |
+
}
|
10 |
+
td {
|
11 |
+
padding: 15px;
|
12 |
+
}
|
13 |
+
</style>
|
14 |
+
|
15 |
+
|
16 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
17 |
+
<?php $collection = $this->getCollection(); ?>
|
18 |
+
<div class="page-title">
|
19 |
+
<h1><?php echo $this->__('Transactions history ') ?></h1>
|
20 |
+
</div>
|
21 |
+
<?php echo $this->getPagerHtml(); ?>
|
22 |
+
<?php if($collection->getSize()): ?>
|
23 |
+
<table class="data-table" id="my-custom-table">
|
24 |
+
<col width="1" />
|
25 |
+
<col width="1" />
|
26 |
+
<col width="1" />
|
27 |
+
<col width="1" />
|
28 |
+
<col width="1" />
|
29 |
+
<col width="1" />
|
30 |
+
<thead>
|
31 |
+
<tr>
|
32 |
+
<th><?php echo $this->__('ACTION') ?></th>
|
33 |
+
<th><?php echo $this->__('STORE CREDITS APPLAID') ?></th>
|
34 |
+
<th><?php echo $this->__('CURRENT STORE CREDITS') ?></th>
|
35 |
+
<th><?php echo $this->__('ACTION DATE') ?></th>
|
36 |
+
<th><?php echo $this->__('MESSAGE') ?></th>
|
37 |
+
</tr>
|
38 |
+
</thead>
|
39 |
+
<tbody>
|
40 |
+
<?php $_odd = ''; ?>
|
41 |
+
<?php foreach ($collection as $_obj): ?>
|
42 |
+
<tr>
|
43 |
+
|
44 |
+
<td><?php echo $_obj->getAction(); ?></td>
|
45 |
+
<td><?php echo $_obj->getActionCredits(); ?></td>
|
46 |
+
<td><?php echo $_obj->getTotalCredits(); ?></td>
|
47 |
+
<td><?php echo $_obj->getActionDate(); ?></td>
|
48 |
+
<?php $order = Mage::getModel('sales/order')->load($_obj->getOrderId(), 'increment_id');
|
49 |
+
$orderid = $order->getId();
|
50 |
+
if(is_numeric($orderid))
|
51 |
+
$url= Mage::getBaseUrl().'sales/order/view/order_id/'.$orderid;
|
52 |
+
else
|
53 |
+
$url="#"; ?>
|
54 |
+
<td> <?php echo $_obj->getCustomMsg() ; if($_obj->getOrderId()) echo "<br/><a href = $url style='align:center;color: #1E7EC8;'>View Order</div>" ;?> </td>
|
55 |
+
</tr>
|
56 |
+
<?php endforeach; ?>
|
57 |
+
</tbody>
|
58 |
+
</table>
|
59 |
+
<script type="text/javascript">decorateTable('my-custom-table');</script>
|
60 |
+
<?php echo $this->getPagerHtml(); ?>
|
61 |
+
<?php else: ?>
|
62 |
+
<p><?php echo $this->__('The collection is empty.'); ?></p>
|
63 |
+
<?php endif ?>
|
64 |
+
|
65 |
+
|
app/design/frontend/base/default/template/kartparadigm/payment.phtml
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::helper('kartparadigm_storecredit')->getIsEnabled()): ?>
|
2 |
+
<?php
|
3 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
4 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
5 |
+
$id = $customerData->getId();
|
6 |
+
|
7 |
+
$collection = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->addFieldToFilter('website1',Mage::app()->getWebsite()->getName())->getLastItem();
|
8 |
+
$totalcredits = $collection->getTotalCredits();
|
9 |
+
}
|
10 |
+
?>
|
11 |
+
<!-- -----------------Enable Or Disable The Storeview Select Option -------------------------------------------------- -->
|
12 |
+
<script type="text/javascript">
|
13 |
+
function OnChangeCheckbox (checkbox) {
|
14 |
+
if (checkbox.checked) {
|
15 |
+
document.getElementById("enable").style.display = 'block';
|
16 |
+
document.getElementById('msg').innerHTML = "please enter less than " + document.getElementById('remaining').innerHTML + " Credits ";
|
17 |
+
}
|
18 |
+
else {
|
19 |
+
document.getElementById("enable").style.display = 'none';
|
20 |
+
document.getElementById('msg').innerHTML = "Please Select The Checkbox For Apply Credits ";
|
21 |
+
document.getElementById('remaining').innerHTML = <?php echo $totalcredits ?>;
|
22 |
+
document.getElementById('credits').value = 0;
|
23 |
+
//document.cookie = 'name='+ 0 ;
|
24 |
+
//document.cookie = 'total='+<?php echo $totalcredits ?> ;
|
25 |
+
|
26 |
+
new Ajax.Request("<?php echo $this->getUrl('kartparadigm_storecredit/index/update') ?>", {
|
27 |
+
method: 'Post',
|
28 |
+
parameters: {discount:0,total:<?php echo $totalcredits ?>},
|
29 |
+
onComplete: function(transport) {
|
30 |
+
//alert('hi');
|
31 |
+
//window.location.reload(true);
|
32 |
+
|
33 |
+
}
|
34 |
+
});
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
function val(obj)
|
40 |
+
{
|
41 |
+
|
42 |
+
var x = document.getElementById('credits').value;
|
43 |
+
var totalbalance = <?php echo $totalcredits ;?>;
|
44 |
+
|
45 |
+
if( totalbalance >= x && x >= 0 ){
|
46 |
+
//document.cookie = 'name='+x ;
|
47 |
+
//document.cookie = 'total='+totalbalance ;
|
48 |
+
new Ajax.Request("<?php echo $this->getUrl('kartparadigm_storecredit/index/update') ?>", {
|
49 |
+
method: 'Post',
|
50 |
+
parameters: {discount:x,total:totalbalance},
|
51 |
+
onComplete: function(transport) {
|
52 |
+
//alert('hi');
|
53 |
+
//window.location.reload(true);
|
54 |
+
|
55 |
+
}
|
56 |
+
});
|
57 |
+
document.getElementById('credits').value = x;
|
58 |
+
document.getElementById('msg').innerHTML = "changed the credits to " + x;
|
59 |
+
//document.getElementById('remaining').innerHTML = totalbalance - x;
|
60 |
+
|
61 |
+
}
|
62 |
+
else{
|
63 |
+
document.getElementById('remaining').innerHTML = totalbalance;
|
64 |
+
document.getElementById('msg').innerHTML = "please enter less than " + totalbalance+ " and greater than 0 credits ";
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
function displayButton(obj){
|
71 |
+
|
72 |
+
|
73 |
+
document.getElementById('credits1').style.display = "block";
|
74 |
+
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
</script>
|
79 |
+
<!-- ----------------------- script ended -------------------------------------------------------------------------- -->
|
80 |
+
|
81 |
+
|
82 |
+
<?php $session = Mage::getSingleton('checkout/session')->getCredits(); if(isset($session)) : ?>
|
83 |
+
<input type="checkbox" name="storecredit" id="storecredit" onclick="OnChangeCheckbox (this)" checked="checked" />
|
84 |
+
<label for="storecredit"> Use Customer Credit To Checkout (Total Available Credits : <spam id="remaining"><?php echo $totalcredits; ?> </spam>) </label>
|
85 |
+
<div id="msg" style="color: #1E7EC8"> Edit Credits To Apply More/Less than You Applaid Before </div>
|
86 |
+
<div id="enable">
|
87 |
+
<div> Using Credits :<input type="textbox" name="credits" id="credits" value="<?php echo Mage::getSingleton('checkout/session')->getDiscount(); ?>" onchange="displayButton(value)" /></div>
|
88 |
+
<input type="button" name="credits1" onclick="val(this)" id="credits1" value="Apply Credits" style="display : none;"/>
|
89 |
+
<?php else : ?>
|
90 |
+
<input type="checkbox" name="storecredit" id="storecredit" onclick="OnChangeCheckbox (this)" />
|
91 |
+
<label for="storecredit"> Use Customer Credit To Checkout (Available Credits : <spam id="remaining"><?php echo $totalcredits ; ?> </spam> ) </label>
|
92 |
+
<div id="msg" style="color: #1E7EC8"> Please Select The Checkbox For Apply Credits </div>
|
93 |
+
<div id="enable" style="display: none;">
|
94 |
+
<div> Using Credits : <input type="textbox" name="credits" id="credits" value="0" /></div>
|
95 |
+
<input type="button" name="credits1" onclick="val(this)" id="credits1" value="Apply Credits" />
|
96 |
+
<?php endif; ?>
|
97 |
+
</div>
|
98 |
+
<div id="img">
|
99 |
+
</div>
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
<?php endif; ?>
|
104 |
+
|
app/design/frontend/base/default/template/kartparadigm/product.phtml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$product = Mage::registry('product');
|
4 |
+
$pid = $product->getId();
|
5 |
+
$totalCredits = $this->displayCreditsOfProduct($pid);
|
6 |
+
?>
|
7 |
+
<div style="color: #CD5033;
|
8 |
+
font: 13px/1.55 Arial,Helvetica,sans-serif;
|
9 |
+
font-weight: bold;"><?php if($totalCredits > 0): ?>Credit Points : <?php echo $totalCredits; ?><?php endif; ?> </div>
|
10 |
+
|
app/design/frontend/base/default/template/kartparadigm/sendcreditsform.phtml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="my-account"><div class="page-title" style="margin: 20px 0px 25px;">
|
2 |
+
<h1>Send Credits To Friend</h1>
|
3 |
+
</div>
|
4 |
+
<div style="font-size: 20px; color: #008000"><?php
|
5 |
+
$msg = Mage::getSingleton("core/session")->getMsg();
|
6 |
+
if(isset($msg)){
|
7 |
+
echo $msg;
|
8 |
+
Mage::getSingleton("core/session")->unsMsg();
|
9 |
+
}
|
10 |
+
?>
|
11 |
+
</div>
|
12 |
+
<form action="<?php echo $this->getBaseUrl()?>storecredit/index/sendcredits" method="post" id="form-validate" autocomplete="off">
|
13 |
+
<div class="fieldset">
|
14 |
+
<h2 class="legend">Receiver Information</h2>
|
15 |
+
<ul class="form-list">
|
16 |
+
<li class="fields">
|
17 |
+
<div class="customer-name">
|
18 |
+
<div class="field name-name">
|
19 |
+
<label for="name" class="required"><em>*</em>Name</label>
|
20 |
+
<div class="input-box">
|
21 |
+
<input id="name" name="name" value="" title="Name" maxlength="255" class="input-text required-entry" type="text">
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="email" class="required"><em>*</em>Email Address</label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input name="email" id="email" value="" title="Email Address" class="input-text required-entry validate-email" type="text">
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
<li>
|
33 |
+
<label for="credits" class="required"><em>*</em>Enter Credits</label>
|
34 |
+
<div class="input-box">
|
35 |
+
<input name="credits" id="credits" value="" title="Email Address" class="input-text required-entry" type="number">
|
36 |
+
</div>
|
37 |
+
</li>
|
38 |
+
<li>
|
39 |
+
<label for="message" class="required"><em>*</em>Write Message</label>
|
40 |
+
<div class="input-box">
|
41 |
+
<textarea name="message" id="message" value="" title="Message" class="input-text required-entry"></textarea>
|
42 |
+
</div>
|
43 |
+
</li>
|
44 |
+
</ul>
|
45 |
+
</div>
|
46 |
+
<?php
|
47 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
48 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
49 |
+
$id = $customerData->getId();
|
50 |
+
$name = $customerData->getName();
|
51 |
+
?>
|
52 |
+
<input type="hidden" value="<?php echo $id ?>" name="id" id="id" />
|
53 |
+
<input type="hidden" value="<?php echo $name ?>" name="sname" id="sname" />
|
54 |
+
<?php } ?>
|
55 |
+
<div class="buttons-set">
|
56 |
+
<p class="required">* Required Fields</p>
|
57 |
+
<button type="submit" title="Send" class="button"><span><span>Send</span></span></button>
|
58 |
+
</div>
|
59 |
+
|
60 |
+
</form>
|
61 |
+
|
62 |
+
|
63 |
+
<script type="text/javascript">
|
64 |
+
//<![CDATA[
|
65 |
+
var dataForm = new VarienForm('form-validate', true);
|
66 |
+
//]]>
|
67 |
+
</script></div>
|
app/design/frontend/base/default/template/kartparadigm/totalcredits.phtml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style>
|
2 |
+
#blc{
|
3 |
+
margin-bottom: 1em;
|
4 |
+
|
5 |
+
}
|
6 |
+
</style>
|
7 |
+
|
8 |
+
<div id="blc">
|
9 |
+
<h2 style="font-size: 20px;
|
10 |
+
font-weight: normal;
|
11 |
+
border-bottom: 1px solid rgb(221, 221, 221);
|
12 |
+
width: 100%;
|
13 |
+
overflow: hidden;
|
14 |
+
margin: 0px 0px 25px;"> Store Credits </h2>
|
15 |
+
|
16 |
+
<?php
|
17 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
18 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
19 |
+
$id = $customerData->getId();
|
20 |
+
}
|
21 |
+
$col = Mage::getModel('kartparadigm_storecredit/creditinfo')->getCollection()->addFieldToFilter('c_id',$id)->getLastItem();
|
22 |
+
|
23 |
+
?>
|
24 |
+
<?php
|
25 |
+
$array2 = Mage::helper('kartparadigm_storecredit')->getCreditRates();
|
26 |
+
$amt1 = ($array2['basevalue'] * $col->getTotalCredits()) / $array2['credits'];
|
27 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
28 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
29 |
+
if ($baseCurrencyCode != $currentCurrencyCode) {
|
30 |
+
$amt2 = Mage::helper('directory')->currencyConvert($amt1, $baseCurrencyCode, $currentCurrencyCode);
|
31 |
+
}
|
32 |
+
else{
|
33 |
+
$amt2 = $amt1;
|
34 |
+
}
|
35 |
+
?>
|
36 |
+
<div style="font-size : 17px;">Your Total Credits are : <em style="color: #000"><?php
|
37 |
+
$totalCredits = $col->getTotalCredits(); ?> <?php if($totalCredits > 0): echo $totalCredits; ?>(<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol()."".$amt2?>) <?php else : ?> <?php echo "0"; ?> <?php endif; ?></em></div>
|
38 |
+
|
39 |
+
</div>
|
app/etc/modules/Kartparadigm_StoreCredit.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Kartparadigm_StoreCredit>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Kartparadigm_StoreCredit>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/en_US/template/email/caritor_email_template1.html
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--@subject Caritor custom email module @-->
|
2 |
+
|
3 |
+
<div>
|
4 |
+
|
5 |
+
<h1>Dear {{var var1}}</h1>
|
6 |
+
|
7 |
+
<p style="font-family:Verdana,Arial;font-weight:normal">{{var var3}} send {{var var2}} Credits . Through his account on <a href= {{var var8}} style="color:#3696c2" target="_blank"> {{var var8}} </a> .You can use for Those For purchase.</p>
|
8 |
+
|
9 |
+
<div style="font-family:Verdana,Arial;font-weight:normal"> We appreciate your business. </div>
|
10 |
+
|
11 |
+
<div style="font-family:Verdana,Arial;font-weight:normal"> To Log in <a href= {{var var8}}> click here</a> </div>
|
12 |
+
</div>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Kartparadigm_StoreCredit</name>
|
4 |
+
<version>1.0.0.5</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Maintaining Customer Credits</summary>
|
10 |
+
<description>Efficiently maintain customer credits in all store views.</description>
|
11 |
+
<notes>Kartparadigm Store Credit</notes>
|
12 |
+
<authors><author><name>Kartparadigm</name><user>kartparadigm</user><email>kartparadigm@gmail.com</email></author></authors>
|
13 |
+
<date>2015-03-24</date>
|
14 |
+
<time>05:14:19</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Kartparadigm"><dir name="StoreCredit"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><dir name="Credits"><file name="List.php" hash="243615c727cebfe59d273da8b85b5db0"/><file name="List1.php" hash="44228eee4508701546e2e4f794431b14"/></dir><file name="Credits.php" hash="8af8e7e7ae5634de6b7dc6dda9349269"/></dir></dir><file name="Grid.php" hash="335c1bee870644f106315be703e4c0d0"/></dir><dir name="Promo"><dir name="Catalog"><dir name="Edit"><dir name="Tab"><file name="Actions.php" hash="36fe787ce9fd4c5d6283c35c741add92"/></dir></dir></dir></dir><dir name="Registries"><dir name="Edit"><file name="Form.php" hash="a2a4f87d29506b1bfd7adf9e420a3e8d"/></dir><file name="Edit.php" hash="2328aeadf074d5e7740947b8bfc54a84"/><file name="Grid.php" hash="99fd3e2d4528bd98aeda18783c2653c0"/></dir><file name="Registries.php" hash="77e441d9f86462eea31cd1ab3abbc24e"/><dir name="Registries1"><dir name="Edit"><file name="Form.php" hash="78c893545865890297ac7f4d406d9afd"/></dir><file name="Edit.php" hash="b38d2e821374c9babdbe4c8de1dd71f0"/><file name="Grid.php" hash="74af81c3af7fe14a52fc03b9d06c5c38"/></dir><file name="Registries1.php" hash="5f821c5722e3e2ec2c635f13efae5270"/></dir><file name="Collection.php" hash="06203b41373cbb51433aaff716e54a45"/><file name="Credit.php" hash="c207b8719fa5aba99fe0f49110b71e12"/></dir><dir name="Helper"><file name="Data.php" hash="d25b537a7ba596762dfd7a5475684ea9"/></dir><dir name="Model"><file name="Creditinfo.php" hash="a96ee7fd6d660ff6de22dbbdbc90a7ae"/><dir name="Mysql4"><dir name="Creditinfo"><file name="Collection.php" hash="6f62213e7f4f62d0f90ffaeb6ff61f03"/></dir><file name="Creditinfo.php" hash="85e01354a1e6973e74dd8fdf11af4eb8"/><dir name="Sendcreditstofriend"><file name="Collection.php" hash="93b7db3ec026d02fc205c8fc5e23630e"/></dir><file name="Sendcreditstofriend.php" hash="32be8731fb112f18d70e06e2b388ebd3"/></dir><file name="Observer.php" hash="101c9544d255c95fb6952c8bb6ab6cd1"/><dir name="Resource"><file name="Rule.php" hash="b6471332cf41e96cc6e60e57505bd0f5"/><file name="Setup.php" hash="7f5ed91bf4d6ab4bc2dd3496fdf37d1c"/><file name="Transaction.php" hash="95cf90e2ab034c722109f741ca446d0e"/></dir><file name="Sendcreditstofriend.php" hash="711f4fbee2493698486fbc162e1fda6e"/><file name="Source.php" hash="8f51c351a0c8d70ac2308f5b7f39a1aa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CreditsController.php" hash="9d545f6cce030f7353de9b44d1ae35c8"/><file name="CustomerController.php" hash="61e052319e374c395d521d58bb67442c"/><dir name="Promo"><file name="CatalogController.php" hash="aac0c07d33396bc86c5adcfc234838d7"/></dir><dir name="Sales"><dir name="Order"><file name="CreditmemoController.php" hash="4e971e6c64d0763a570e315ccd0d980c"/></dir></dir></dir><dir name="Checkout"><file name="OnepageController.php" hash="2a9734b2099905ba8f0fd1ac79b614c6"/></dir><file name="IndexController.php" hash="d70f263cc210ed21eee8d1564aead14d"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1a78218db0c18efcf81ed04ba8b655c2"/><file name="config.xml" hash="39065261bc245ba54799940bea51d5e0"/><file name="system.xml" hash="4b4ef37096e12405ea23e9a7de8efa10"/></dir><dir name="sql"><dir name="kartparadigm_storecredit_setup"><file name="install-0.1.0.php" hash="0e60f75abadb436a7fbc9682245773ab"/><file name="upgrade-0.1.0-0.2.0.php" hash="9e9d855251ffa1ef256e4821a5e903c9"/><file name="upgrade-0.2.0-0.3.0.php" hash="4bafbe8bba6b4d6e824487220d1b49fb"/><file name="upgrade-0.3.0-0.4.0.php" hash="1f7b1d85ca78d5d42afb5f9c064b9acd"/><file name="upgrade-0.4.0-0.5.0.php" hash="4a3ba65764d6ae5bbde2bd48dba46bdc"/><file name="upgrade-0.5.0-0.6.0.php" hash="d60d6c4631750a02202220552c73d373"/><file name="upgrade-0.6.0-0.7.0.php" hash="37acfd4ef86bc0a7d7f7deaa393fdfbb"/><file name="upgrade-0.7.0-0.8.0.php" hash="3f23d2d79ea4b93b1012194677e55da0"/><file name="upgrade-0.8.0-0.9.0.php" hash="ae7b43bf8747d56bede623e52c824597"/></dir></dir></dir></dir><dir name="Mage"><dir name="Adminhtml"><dir name="Block"><dir name="Sales"><file name="Totals.php" hash="9d15eca76b896d950a59234c82d3786f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="credit.xml" hash="128baf9ae30f2a2e01cd1779a9356229"/></dir><dir name="template"><dir name="kartparadigm"><dir name="storecredit"><file name="credit.phtml" hash="67a2b79a158a9b7190b1b6c6e970d7c9"/><dir name="customer"><file name="main.phtml" hash="db60ca5b83d64d2e180e84b86b48b126"/></dir><file name="payment.phtml" hash="d8c9566e168e25d371ed718e122394f9"/><file name="storecreditview.phtml" hash="81b3e839f3321b9b46ef70d80839c6a6"/><file name="transaction.phtml" hash="f2852bdefed025ee6ef326ffd990b932"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="credit.xml" hash="bdfdd8dbf648bf7846c9b4eab07a68a9"/></dir><dir name="template"><dir name="kartparadigm"><file name="mycredits.phtml" hash="8f3daee8faac9b6262eed78c33af08b1"/><file name="mytransactions.phtml" hash="f104dcf3016d7d414b139f81aa8e9517"/><file name="payment.phtml" hash="bab542921a9690d9afd006d541ac82b0"/><file name="product.phtml" hash="640ee05cb6c5ad478b3f6fffcac82764"/><file name="sendcreditsform.phtml" hash="db4cb8365272bd3e02f1976f8a542841"/><file name="totalcredits.phtml" hash="601bd8258fd0c06adcc16910db6a5037"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Kartparadigm_StoreCredit.xml" hash="01384259ebcca87af5b4e122cc95c2e8"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="caritor_email_template1.html" hash="4aa55abbeb482a6b156eadcfeda159e4"/></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9</max></package></required></dependencies>
|
18 |
+
</package>
|