Version Notes
Credit points are an added bonus to our customers on the site and just one of the ways we thank you for being a loyal customer.
Download this release
Release Info
| Developer | indianic |
| Extension | Inic_Creditpayment |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/Inic/Creditpayment/Block/Adminhtml/Customer/Edit/Tab/Credit.php +97 -0
- app/code/local/Inic/Creditpayment/Block/Adminhtml/Customer/Editcustomer.php +236 -0
- app/code/local/Inic/Creditpayment/Helper/Data.php +6 -0
- app/code/local/Inic/Creditpayment/Model/Checkout/Type/Multishipping.php +60 -0
- app/code/local/Inic/Creditpayment/Model/Checkout/Type/Onepage.php +49 -0
- app/code/local/Inic/Creditpayment/Model/Creditpayment.php +12 -0
- app/code/local/Inic/Creditpayment/Model/Customer.php +15 -0
- app/code/local/Inic/Creditpayment/Model/Method/Creditpayment.php +10 -0
- app/code/local/Inic/Creditpayment/Model/Mysql4/Creditpayment.php +13 -0
- app/code/local/Inic/Creditpayment/Model/Mysql4/Creditpayment/Collection.php +12 -0
- app/code/local/Inic/Creditpayment/Model/Observer.php +154 -0
- app/code/local/Inic/Creditpayment/controllers/Adminhtml/Sales/Order/CreateController.php +671 -0
- app/code/local/Inic/Creditpayment/etc/config.xml +162 -0
- app/code/local/Inic/Creditpayment/etc/system.xml +102 -0
- app/code/local/Inic/Creditpayment/sql/creditpayment_setup/mysql4-install-0.1.0.php +42 -0
- app/design/adminhtml/default/default/layout/creditpayment.xml +15 -0
- app/design/adminhtml/default/default/template/creditpayment/creditpayment.phtml +26 -0
- app/design/adminhtml/default/default/template/creditpayment/js.phtml +32 -0
- app/design/frontend/base/default/layout/creditpayment.xml +14 -0
- app/design/frontend/base/default/template/creditpayment/customer/account/dashboard.phtml +56 -0
- app/design/frontend/base/default/template/creditpayment/customer/creditpayment.phtml +13 -0
- app/etc/modules/Inic_Creditpayment.xml +17 -0
- package.xml +28 -0
app/code/local/Inic/Creditpayment/Block/Adminhtml/Customer/Edit/Tab/Credit.php
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Inic_Creditpayment_Block_Adminhtml_Customer_Edit_Tab_Credit extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
public function __construct()
|
| 8 |
+
{
|
| 9 |
+
|
| 10 |
+
$this->setTemplate('creditpayment/creditpayment.phtml');
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
public function getCreditData()
|
| 14 |
+
{
|
| 15 |
+
$customer = Mage::registry('current_customer');
|
| 16 |
+
$creditLimit = $customer->getCreditLimit();
|
| 17 |
+
return $creditLimit;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Return Tab label
|
| 22 |
+
*
|
| 23 |
+
* @return string
|
| 24 |
+
*/
|
| 25 |
+
public function getTabLabel()
|
| 26 |
+
{
|
| 27 |
+
return $this->__('Customer Credit Limit');
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Return Tab title
|
| 32 |
+
*
|
| 33 |
+
* @return string
|
| 34 |
+
*/
|
| 35 |
+
public function getTabTitle()
|
| 36 |
+
{
|
| 37 |
+
return $this->__('Credit Tab');
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Can show tab in tabs
|
| 42 |
+
*
|
| 43 |
+
* @return boolean
|
| 44 |
+
*/
|
| 45 |
+
public function canShowTab()
|
| 46 |
+
{
|
| 47 |
+
$customer = Mage::registry('current_customer');
|
| 48 |
+
return (bool)$customer->getId();
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Tab is hidden
|
| 53 |
+
*
|
| 54 |
+
* @return boolean
|
| 55 |
+
*/
|
| 56 |
+
public function isHidden()
|
| 57 |
+
{
|
| 58 |
+
$customer =Mage::registry('current_customer');
|
| 59 |
+
$customerGroup = $customer->getGroupId();
|
| 60 |
+
$SelectedCustomerGroups = Mage::getStoreConfig('payment/creditpayment/specificcustomers');
|
| 61 |
+
$enabled_module = Mage::getStoreConfig('payment/creditpayment/active');
|
| 62 |
+
$SelectedCustomerGroupsArray = explode(",", $SelectedCustomerGroups);
|
| 63 |
+
if($enabled_module){
|
| 64 |
+
if($SelectedCustomerGroups != ""){
|
| 65 |
+
if(in_array($customerGroup, $SelectedCustomerGroupsArray)) {
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
return true;
|
| 69 |
+
}
|
| 70 |
+
else
|
| 71 |
+
{
|
| 72 |
+
return false;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
else{
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
public function selectedGroup(){
|
| 81 |
+
$SelectedCustomerGroups = Mage::getStoreConfig('payment/creditpayment/specificcustomers');
|
| 82 |
+
return $SelectedCustomerGroups;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Defines after which tab, this tab should be rendered
|
| 87 |
+
*
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function getAfter()
|
| 91 |
+
{
|
| 92 |
+
return 'account';
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
}
|
| 97 |
+
?>
|
app/code/local/Inic/Creditpayment/Block/Adminhtml/Customer/Editcustomer.php
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Inic_Creditpayment_Block_Adminhtml_Customer_Editcustomer extends Mage_Adminhtml_Block_Customer_Edit_Tab_Account
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
public function initForm()
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
$form = new Varien_Data_Form();
|
| 9 |
+
$form->setHtmlIdPrefix('_account');
|
| 10 |
+
$form->setFieldNameSuffix('account');
|
| 11 |
+
|
| 12 |
+
$customer = Mage::registry('current_customer');
|
| 13 |
+
/** added by IndiaNIC ***/
|
| 14 |
+
$customer->getCreditLimit();
|
| 15 |
+
/** added by IndiaNIC ***/
|
| 16 |
+
/** @var $customerForm Mage_Customer_Model_Form */
|
| 17 |
+
$customerForm = Mage::getModel('customer/form');
|
| 18 |
+
$customerForm->setEntity($customer)
|
| 19 |
+
->setFormCode('adminhtml_customer')
|
| 20 |
+
->initDefaultValues();
|
| 21 |
+
|
| 22 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
| 23 |
+
'legend' => Mage::helper('customer')->__('Account Information')
|
| 24 |
+
));
|
| 25 |
+
|
| 26 |
+
$attributes = $customerForm->getAttributes();
|
| 27 |
+
foreach ($attributes as $attribute) {
|
| 28 |
+
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
|
| 29 |
+
$attribute->setFrontendLabel(Mage::helper('customer')->__($attribute->getFrontend()->getLabel()));
|
| 30 |
+
$attribute->unsIsVisible();
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
$disableAutoGroupChangeAttributeName = 'disable_auto_group_change';
|
| 34 |
+
$this->_setFieldset($attributes, $fieldset, array($disableAutoGroupChangeAttributeName,'credit_limit'));
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$form->getElement('group_id')->setRenderer($this->getLayout()
|
| 38 |
+
->createBlock('adminhtml/customer_edit_renderer_attribute_group')
|
| 39 |
+
->setDisableAutoGroupChangeAttribute($customerForm->getAttribute($disableAutoGroupChangeAttributeName))
|
| 40 |
+
->setDisableAutoGroupChangeAttributeValue($customer->getData($disableAutoGroupChangeAttributeName)));
|
| 41 |
+
|
| 42 |
+
if ($customer->getId()) {
|
| 43 |
+
$form->getElement('website_id')->setDisabled('disabled');
|
| 44 |
+
$form->getElement('created_in')->setDisabled('disabled');
|
| 45 |
+
} else {
|
| 46 |
+
$fieldset->removeField('created_in');
|
| 47 |
+
$form->getElement('website_id')->addClass('validate-website-has-store');
|
| 48 |
+
|
| 49 |
+
$websites = array();
|
| 50 |
+
foreach (Mage::app()->getWebsites(true) as $website) {
|
| 51 |
+
$websites[$website->getId()] = !is_null($website->getDefaultStore());
|
| 52 |
+
}
|
| 53 |
+
$prefix = $form->getHtmlIdPrefix();
|
| 54 |
+
|
| 55 |
+
$form->getElement('website_id')->setAfterElementHtml(
|
| 56 |
+
'<script type="text/javascript">'
|
| 57 |
+
. "
|
| 58 |
+
var {$prefix}_websites = " . Mage::helper('core')->jsonEncode($websites) .";
|
| 59 |
+
Validation.add(
|
| 60 |
+
'validate-website-has-store',
|
| 61 |
+
'" . Mage::helper('customer')->__('Please select a website which contains store view') . "',
|
| 62 |
+
function(v, elem){
|
| 63 |
+
return {$prefix}_websites[elem.value] == true;
|
| 64 |
+
}
|
| 65 |
+
);
|
| 66 |
+
Element.observe('{$prefix}website_id', 'change', function(){
|
| 67 |
+
Validation.validate($('{$prefix}website_id'))
|
| 68 |
+
}.bind($('{$prefix}website_id')));
|
| 69 |
+
"
|
| 70 |
+
. '</script>'
|
| 71 |
+
);
|
| 72 |
+
}
|
| 73 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
| 74 |
+
$form->getElement('website_id')->setRenderer($renderer);
|
| 75 |
+
|
| 76 |
+
// if (Mage::app()->isSingleStoreMode()) {
|
| 77 |
+
// $fieldset->removeField('website_id');
|
| 78 |
+
// $fieldset->addField('website_id', 'hidden', array(
|
| 79 |
+
// 'name' => 'website_id'
|
| 80 |
+
// ));
|
| 81 |
+
// $customer->setWebsiteId(Mage::app()->getStore(true)->getWebsiteId());
|
| 82 |
+
// }
|
| 83 |
+
|
| 84 |
+
$customerStoreId = null;
|
| 85 |
+
if ($customer->getId()) {
|
| 86 |
+
$customerStoreId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
$prefixElement = $form->getElement('prefix');
|
| 90 |
+
if ($prefixElement) {
|
| 91 |
+
$prefixOptions = $this->helper('customer')->getNamePrefixOptions($customerStoreId);
|
| 92 |
+
if (!empty($prefixOptions)) {
|
| 93 |
+
$fieldset->removeField($prefixElement->getId());
|
| 94 |
+
$prefixField = $fieldset->addField($prefixElement->getId(),
|
| 95 |
+
'select',
|
| 96 |
+
$prefixElement->getData(),
|
| 97 |
+
$form->getElement('group_id')->getId()
|
| 98 |
+
);
|
| 99 |
+
$prefixField->setValues($prefixOptions);
|
| 100 |
+
if ($customer->getId()) {
|
| 101 |
+
$prefixField->addElementValues($customer->getPrefix());
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
$suffixElement = $form->getElement('suffix');
|
| 108 |
+
if ($suffixElement) {
|
| 109 |
+
$suffixOptions = $this->helper('customer')->getNameSuffixOptions($customerStoreId);
|
| 110 |
+
if (!empty($suffixOptions)) {
|
| 111 |
+
$fieldset->removeField($suffixElement->getId());
|
| 112 |
+
$suffixField = $fieldset->addField($suffixElement->getId(),
|
| 113 |
+
'select',
|
| 114 |
+
$suffixElement->getData(),
|
| 115 |
+
$form->getElement('lastname')->getId()
|
| 116 |
+
);
|
| 117 |
+
$suffixField->setValues($suffixOptions);
|
| 118 |
+
if ($customer->getId()) {
|
| 119 |
+
$suffixField->addElementValues($customer->getSuffix());
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if ($customer->getId()) {
|
| 125 |
+
if (!$customer->isReadonly()) {
|
| 126 |
+
// Add password management fieldset
|
| 127 |
+
$newFieldset = $form->addFieldset(
|
| 128 |
+
'password_fieldset',
|
| 129 |
+
array('legend' => Mage::helper('customer')->__('Password Management'))
|
| 130 |
+
);
|
| 131 |
+
// New customer password
|
| 132 |
+
$field = $newFieldset->addField('new_password', 'text',
|
| 133 |
+
array(
|
| 134 |
+
'label' => Mage::helper('customer')->__('New Password'),
|
| 135 |
+
'name' => 'new_password',
|
| 136 |
+
'class' => 'validate-new-password'
|
| 137 |
+
)
|
| 138 |
+
);
|
| 139 |
+
$field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
|
| 140 |
+
|
| 141 |
+
// Prepare customer confirmation control (only for existing customers)
|
| 142 |
+
$confirmationKey = $customer->getConfirmation();
|
| 143 |
+
if ($confirmationKey || $customer->isConfirmationRequired()) {
|
| 144 |
+
$confirmationAttribute = $customer->getAttribute('confirmation');
|
| 145 |
+
if (!$confirmationKey) {
|
| 146 |
+
$confirmationKey = $customer->getRandomConfirmationKey();
|
| 147 |
+
}
|
| 148 |
+
$element = $fieldset->addField('confirmation', 'select', array(
|
| 149 |
+
'name' => 'confirmation',
|
| 150 |
+
'label' => Mage::helper('customer')->__($confirmationAttribute->getFrontendLabel()),
|
| 151 |
+
))->setEntityAttribute($confirmationAttribute)
|
| 152 |
+
->setValues(array('' => 'Confirmed', $confirmationKey => 'Not confirmed'));
|
| 153 |
+
|
| 154 |
+
// Prepare send welcome email checkbox if customer is not confirmed
|
| 155 |
+
// no need to add it, if website ID is empty
|
| 156 |
+
if ($customer->getConfirmation() && $customer->getWebsiteId()) {
|
| 157 |
+
$fieldset->addField('sendemail', 'checkbox', array(
|
| 158 |
+
'name' => 'sendemail',
|
| 159 |
+
'label' => Mage::helper('customer')->__('Send Welcome Email after Confirmation')
|
| 160 |
+
));
|
| 161 |
+
$customer->setData('sendemail', '1');
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
} else {
|
| 166 |
+
$newFieldset = $form->addFieldset(
|
| 167 |
+
'password_fieldset',
|
| 168 |
+
array('legend'=>Mage::helper('customer')->__('Password Management'))
|
| 169 |
+
);
|
| 170 |
+
$field = $newFieldset->addField('password', 'text',
|
| 171 |
+
array(
|
| 172 |
+
'label' => Mage::helper('customer')->__('Password'),
|
| 173 |
+
'class' => 'input-text required-entry validate-password',
|
| 174 |
+
'name' => 'password',
|
| 175 |
+
'required' => true
|
| 176 |
+
)
|
| 177 |
+
);
|
| 178 |
+
$field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
|
| 179 |
+
|
| 180 |
+
// Prepare send welcome email checkbox
|
| 181 |
+
$fieldset->addField('sendemail', 'checkbox', array(
|
| 182 |
+
'label' => Mage::helper('customer')->__('Send Welcome Email'),
|
| 183 |
+
'name' => 'sendemail',
|
| 184 |
+
'id' => 'sendemail',
|
| 185 |
+
));
|
| 186 |
+
$customer->setData('sendemail', '1');
|
| 187 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
| 188 |
+
$fieldset->addField('sendemail_store_id', 'select', array(
|
| 189 |
+
'label' => $this->helper('customer')->__('Send From'),
|
| 190 |
+
'name' => 'sendemail_store_id',
|
| 191 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
|
| 192 |
+
));
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Make sendemail and sendmail_store_id disabled if website_id has empty value
|
| 197 |
+
$isSingleMode = Mage::app()->isSingleStoreMode();
|
| 198 |
+
$sendEmailId = $isSingleMode ? 'sendemail' : 'sendemail_store_id';
|
| 199 |
+
$sendEmail = $form->getElement($sendEmailId);
|
| 200 |
+
|
| 201 |
+
$prefix = $form->getHtmlIdPrefix();
|
| 202 |
+
if ($sendEmail) {
|
| 203 |
+
$_disableStoreField = '';
|
| 204 |
+
if (!$isSingleMode) {
|
| 205 |
+
$_disableStoreField = "$('{$prefix}sendemail_store_id').disabled=(''==this.value || '0'==this.value);";
|
| 206 |
+
}
|
| 207 |
+
$sendEmail->setAfterElementHtml(
|
| 208 |
+
'<script type="text/javascript">'
|
| 209 |
+
. "
|
| 210 |
+
$('{$prefix}website_id').disableSendemail = function() {
|
| 211 |
+
$('{$prefix}sendemail').disabled = ('' == this.value || '0' == this.value);".
|
| 212 |
+
$_disableStoreField
|
| 213 |
+
."}.bind($('{$prefix}website_id'));
|
| 214 |
+
Event.observe('{$prefix}website_id', 'change', $('{$prefix}website_id').disableSendemail);
|
| 215 |
+
$('{$prefix}website_id').disableSendemail();
|
| 216 |
+
"
|
| 217 |
+
. '</script>'
|
| 218 |
+
);
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
if ($customer->isReadonly()) {
|
| 222 |
+
foreach ($customer->getAttributes() as $attribute) {
|
| 223 |
+
$element = $form->getElement($attribute->getAttributeCode());
|
| 224 |
+
if ($element) {
|
| 225 |
+
$element->setReadonly(true, true);
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
$form->setValues($customer->getData());
|
| 231 |
+
$this->setForm($form);
|
| 232 |
+
return $this;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
}
|
app/code/local/Inic/Creditpayment/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Checkout/Type/Multishipping.php
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Checkout
|
| 23 |
+
* @copyright Copyright (c) 2012 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 |
+
* Multishipping checkout model
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Checkout
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Inic_Creditpayment_Model_Checkout_Type_Multishipping extends Mage_Checkout_Model_Type_Multishipping
|
| 35 |
+
{
|
| 36 |
+
public function setPaymentMethod($payment)
|
| 37 |
+
{
|
| 38 |
+
if (!isset($payment['method'])) {
|
| 39 |
+
Mage::throwException(Mage::helper('checkout')->__('Payment method is not defined'));
|
| 40 |
+
}
|
| 41 |
+
$quote = $this->getQuote();
|
| 42 |
+
$_totalData = $quote->getData();
|
| 43 |
+
$_grand = $_totalData['base_grand_total'];
|
| 44 |
+
$customerSession = $this->getCustomerSession();
|
| 45 |
+
$customer = $customerSession->getCustomer();
|
| 46 |
+
$creditLimit = $customer->getCreditLimit();
|
| 47 |
+
|
| 48 |
+
if($payment['method']=="creditpayment" && $creditLimit < $_grand ){
|
| 49 |
+
Mage::throwException(Mage::helper('checkout')->__("You don't have sufficient credit."));
|
| 50 |
+
}
|
| 51 |
+
$quote->getPayment()->importData($payment);
|
| 52 |
+
// shipping totals may be affected by payment method
|
| 53 |
+
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
| 54 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
| 55 |
+
$quote->setTotalsCollectedFlag(false)->collectTotals();
|
| 56 |
+
}
|
| 57 |
+
$quote->save();
|
| 58 |
+
return $this;
|
| 59 |
+
}
|
| 60 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Checkout/Type/Onepage.php
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function savePayment($data)
|
| 7 |
+
{
|
| 8 |
+
if (empty($data)) {
|
| 9 |
+
return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data.'));
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
/* Added For Validation By IndiaNIC*/
|
| 13 |
+
$quote = $this->getQuote();
|
| 14 |
+
$_totalData = $quote->getData();
|
| 15 |
+
$_grand = $_totalData['base_grand_total'];
|
| 16 |
+
$customerSession = $this->getCustomerSession();
|
| 17 |
+
$customer = $customerSession->getCustomer();
|
| 18 |
+
$creditLimit = $customer->getCreditLimit();
|
| 19 |
+
|
| 20 |
+
if($data['method']=="creditpayment" && $creditLimit < $_grand ){
|
| 21 |
+
/* return array('error' => '-1', 'message' => Mage::helper('checkout')->__("You don't have sufficient credit balance. "));*/
|
| 22 |
+
//Mage::throwException
|
| 23 |
+
Mage::throwException(Mage::helper('checkout')->__("You don't have sufficient credit."));
|
| 24 |
+
}
|
| 25 |
+
/* Added For Validation By IndiaNIC*/
|
| 26 |
+
if ($quote->isVirtual()) {
|
| 27 |
+
$quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
| 28 |
+
} else {
|
| 29 |
+
$quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// shipping totals may be affected by payment method
|
| 33 |
+
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
| 34 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$payment = $quote->getPayment();
|
| 38 |
+
$payment->importData($data);
|
| 39 |
+
|
| 40 |
+
$quote->save();
|
| 41 |
+
|
| 42 |
+
$this->getCheckout()
|
| 43 |
+
->setStepData('payment', 'complete', true)
|
| 44 |
+
->setStepData('review', 'allow', true);
|
| 45 |
+
|
| 46 |
+
return array();
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Creditpayment.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Creditpayment extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
parent::_construct();
|
| 9 |
+
$this->_init('creditpayment/creditpayment');
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Customer.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Customer extends Mage_Customer_Model_Customer
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
/** added By IndiaNIC **/
|
| 7 |
+
public function getCreditLimit()
|
| 8 |
+
{
|
| 9 |
+
$creditori = $this->getData('credit_limit');
|
| 10 |
+
$credit_limit = round($creditori,2);
|
| 11 |
+
$this->setData('credit_limit',$credit_limit);
|
| 12 |
+
return $credit_limit;
|
| 13 |
+
}
|
| 14 |
+
/** added By IndiaNIC **/
|
| 15 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Method/Creditpayment.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Method_Creditpayment extends Mage_Payment_Model_Method_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_code = 'creditpayment';
|
| 6 |
+
protected $_isInitializeNeeded = true;
|
| 7 |
+
protected $_canUseInternal = true;
|
| 8 |
+
protected $_canUseForMultishipping = true;
|
| 9 |
+
|
| 10 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Mysql4/Creditpayment.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Mysql4_Creditpayment extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
// Note that the contactvalue_id refers to the key field in your database table.
|
| 9 |
+
$this->_init('creditpayment/creditpayment', 'id');
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
}
|
| 13 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Mysql4/Creditpayment/Collection.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Inic_Creditpayment_Model_Mysql4_Creditpayment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
parent::_construct();
|
| 9 |
+
$this->_init('creditpayment/creditpayment');
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/local/Inic/Creditpayment/Model/Observer.php
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Inic_Creditpayment_Model_Observer
|
| 3 |
+
{
|
| 4 |
+
public function saveCredit(Varien_Event_Observer $observer)
|
| 5 |
+
{
|
| 6 |
+
$order = $observer->getEvent()->getOrder();
|
| 7 |
+
$order_id = $observer->getEvent()->getOrder()->getId();
|
| 8 |
+
$payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
|
| 9 |
+
|
| 10 |
+
if ($payment_method_code == 'creditpayment') {
|
| 11 |
+
$customerId = $order->getCustomerId();
|
| 12 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 13 |
+
$Availablelimit = $customer->getCreditLimit();
|
| 14 |
+
$AppliedCredit = $order->getBaseGrandTotal();
|
| 15 |
+
$setUpdatedlimit = $Availablelimit - $AppliedCredit;
|
| 16 |
+
try{
|
| 17 |
+
$model=Mage::getModel('creditpayment/creditpayment');
|
| 18 |
+
$model->setOrderId($order_id);
|
| 19 |
+
$model->setCustomerId($customerId);
|
| 20 |
+
$model->setAppliedAmount($AppliedCredit);
|
| 21 |
+
$model->setCreatedTime(now());
|
| 22 |
+
$model->save();
|
| 23 |
+
|
| 24 |
+
$customer->setCreditLimit($setUpdatedlimit);
|
| 25 |
+
$customer->save();
|
| 26 |
+
}
|
| 27 |
+
catch(Exception $e){
|
| 28 |
+
Mage::getModel('core/session')->addError($e->getMessage());
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function revertCredit(Varien_Event_Observer $observer)
|
| 35 |
+
{
|
| 36 |
+
$creditMemo = $observer->getEvent()->getCreditmemo();
|
| 37 |
+
$order = $creditMemo->getOrder();
|
| 38 |
+
$order_id = $order->getId();
|
| 39 |
+
$payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
|
| 40 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
| 41 |
+
if($payment_method_code == 'creditpayment'){
|
| 42 |
+
$Availablelimit = $customer->getCreditLimit();
|
| 43 |
+
$Creditcollection = Mage::getModel('creditpayment/creditpayment')->getCollection()
|
| 44 |
+
->addFieldToFilter('customer_id',$customerId)
|
| 45 |
+
->addFieldToFilter('order_id',$order_id)
|
| 46 |
+
->getFirstItem();
|
| 47 |
+
$customerUpdatedlimit = $order->getBaseGrandTotal();
|
| 48 |
+
$setlimit = $Availablelimit + $customerUpdatedlimit;
|
| 49 |
+
$customer->setCreditLimit($setlimit);
|
| 50 |
+
$customer->save();
|
| 51 |
+
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
}
|
| 55 |
+
public function isAvailable(Varien_Event_Observer $observer)
|
| 56 |
+
{
|
| 57 |
+
$event = $observer->getEvent();
|
| 58 |
+
$method = $event->getMethodInstance();
|
| 59 |
+
$result = $event->getResult();
|
| 60 |
+
$quote = $event->getQuote();
|
| 61 |
+
if($method->getCode() == 'creditpayment' ){
|
| 62 |
+
$customerGroup = $quote->getCustomerGroupId();
|
| 63 |
+
$SelectedCustomerGroups = Mage::getStoreConfig('payment/creditpayment/specificcustomers');
|
| 64 |
+
$SelectedCustomerGroupsArray = explode(",", $SelectedCustomerGroups);
|
| 65 |
+
if($SelectedCustomerGroups != "" || $quote->getCustomerId() == " "){
|
| 66 |
+
if(!in_array($customerGroup, $SelectedCustomerGroupsArray)) {
|
| 67 |
+
$result->isAvailable = false;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
}
|
| 71 |
+
else{
|
| 72 |
+
if($result->isAvailable==1){
|
| 73 |
+
$result->isAvailable = true;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
public function implementOrderStatus($event)
|
| 80 |
+
{
|
| 81 |
+
$order = $event->getOrder();
|
| 82 |
+
$Orderstatus = Mage::getStoreConfig('payment/creditpayment/order_status');
|
| 83 |
+
|
| 84 |
+
if ($this->_getPaymentMethod($order) == 'creditpayment' && $Orderstatus == "processing" ) {
|
| 85 |
+
if ($order->canInvoice())
|
| 86 |
+
$this->_processOrderStatus($order);
|
| 87 |
+
}
|
| 88 |
+
return $this;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
private function _getPaymentMethod($order)
|
| 92 |
+
{
|
| 93 |
+
return $order->getPayment()->getMethodInstance()->getCode();
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
private function _processOrderStatus($order)
|
| 97 |
+
{
|
| 98 |
+
$invoice = $order->prepareInvoice();
|
| 99 |
+
$invoice->register();
|
| 100 |
+
Mage::getModel('core/resource_transaction')
|
| 101 |
+
->addObject($invoice)
|
| 102 |
+
->addObject($invoice->getOrder())
|
| 103 |
+
->save();
|
| 104 |
+
|
| 105 |
+
$invoice->sendEmail(true, '');
|
| 106 |
+
return true;
|
| 107 |
+
}
|
| 108 |
+
public function saveMultiCredit(Varien_Event_Observer $observer)
|
| 109 |
+
{
|
| 110 |
+
$orders = $observer->getEvent()->getOrders();
|
| 111 |
+
$Orderstatus = Mage::getStoreConfig('payment/creditpayment/order_status');
|
| 112 |
+
if(count($orders) > 0){
|
| 113 |
+
foreach($orders as $order){
|
| 114 |
+
$payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
|
| 115 |
+
if ($payment_method_code == 'creditpayment') {
|
| 116 |
+
$order_id= $order->getId();
|
| 117 |
+
$customerId = $order->getCustomerId();
|
| 118 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 119 |
+
$Availablelimit = $customer->getCreditLimit();
|
| 120 |
+
$AppliedCredit = $order->getBaseGrandTotal();
|
| 121 |
+
$setUpdatedlimit = $Availablelimit - $AppliedCredit;
|
| 122 |
+
try{
|
| 123 |
+
$model=Mage::getModel('creditpayment/creditpayment');
|
| 124 |
+
$model->setOrderId($order_id);
|
| 125 |
+
$model->setCustomerId($customerId);
|
| 126 |
+
$model->setAppliedAmount($AppliedCredit);
|
| 127 |
+
$model->setCreatedTime(now());
|
| 128 |
+
$model->save();
|
| 129 |
+
|
| 130 |
+
$customer->setCreditLimit($setUpdatedlimit);
|
| 131 |
+
$customer->save();
|
| 132 |
+
|
| 133 |
+
if ($order->canInvoice() && $Orderstatus == "processing"){
|
| 134 |
+
$invoice = $order->prepareInvoice();
|
| 135 |
+
$invoice->register();
|
| 136 |
+
Mage::getModel('core/resource_transaction')
|
| 137 |
+
->addObject($invoice)
|
| 138 |
+
->addObject($invoice->getOrder())
|
| 139 |
+
->save();
|
| 140 |
+
$invoice->sendEmail(true, '');
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
catch(Exception $e){
|
| 145 |
+
Mage::getModel('core/session')->addError($e->getMessage());
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
}
|
app/code/local/Inic/Creditpayment/controllers/Adminhtml/Sales/Order/CreateController.php
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
|
| 4 |
+
class Inic_Creditpayment_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController
|
| 5 |
+
{
|
| 6 |
+
/**
|
| 7 |
+
* Additional initialization
|
| 8 |
+
*
|
| 9 |
+
*/
|
| 10 |
+
protected function _construct()
|
| 11 |
+
{
|
| 12 |
+
$this->setUsedModuleName('Mage_Sales');
|
| 13 |
+
|
| 14 |
+
// During order creation in the backend admin has ability to add any products to order
|
| 15 |
+
Mage::helper('catalog/product')->setSkipSaleableCheck(true);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Retrieve session object
|
| 20 |
+
*
|
| 21 |
+
* @return Mage_Adminhtml_Model_Session_Quote
|
| 22 |
+
*/
|
| 23 |
+
protected function _getSession()
|
| 24 |
+
{
|
| 25 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Retrieve quote object
|
| 30 |
+
*
|
| 31 |
+
* @return Mage_Sales_Model_Quote
|
| 32 |
+
*/
|
| 33 |
+
protected function _getQuote()
|
| 34 |
+
{
|
| 35 |
+
return $this->_getSession()->getQuote();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Retrieve order create model
|
| 40 |
+
*
|
| 41 |
+
* @return Mage_Adminhtml_Model_Sales_Order_Create
|
| 42 |
+
*/
|
| 43 |
+
protected function _getOrderCreateModel()
|
| 44 |
+
{
|
| 45 |
+
return Mage::getSingleton('adminhtml/sales_order_create');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Retrieve gift message save model
|
| 50 |
+
*
|
| 51 |
+
* @return Mage_Adminhtml_Model_Giftmessage_Save
|
| 52 |
+
*/
|
| 53 |
+
protected function _getGiftmessageSaveModel()
|
| 54 |
+
{
|
| 55 |
+
return Mage::getSingleton('adminhtml/giftmessage_save');
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Initialize order creation session data
|
| 60 |
+
*
|
| 61 |
+
* @return Mage_Adminhtml_Sales_Order_CreateController
|
| 62 |
+
*/
|
| 63 |
+
protected function _initSession()
|
| 64 |
+
{
|
| 65 |
+
/**
|
| 66 |
+
* Identify customer
|
| 67 |
+
*/
|
| 68 |
+
if ($customerId = $this->getRequest()->getParam('customer_id')) {
|
| 69 |
+
$this->_getSession()->setCustomerId((int) $customerId);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Identify store
|
| 74 |
+
*/
|
| 75 |
+
if ($storeId = $this->getRequest()->getParam('store_id')) {
|
| 76 |
+
$this->_getSession()->setStoreId((int) $storeId);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Identify currency
|
| 81 |
+
*/
|
| 82 |
+
if ($currencyId = $this->getRequest()->getParam('currency_id')) {
|
| 83 |
+
$this->_getSession()->setCurrencyId((string) $currencyId);
|
| 84 |
+
$this->_getOrderCreateModel()->setRecollect(true);
|
| 85 |
+
}
|
| 86 |
+
return $this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Processing request data
|
| 91 |
+
*
|
| 92 |
+
* @return Mage_Adminhtml_Sales_Order_CreateController
|
| 93 |
+
*/
|
| 94 |
+
protected function _processData()
|
| 95 |
+
{
|
| 96 |
+
return $this->_processActionData();
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Process request data with additional logic for saving quote and creating order
|
| 101 |
+
*
|
| 102 |
+
* @param string $action
|
| 103 |
+
* @return Mage_Adminhtml_Sales_Order_CreateController
|
| 104 |
+
*/
|
| 105 |
+
protected function _processActionData($action = null)
|
| 106 |
+
{
|
| 107 |
+
$eventData = array(
|
| 108 |
+
'order_create_model' => $this->_getOrderCreateModel(),
|
| 109 |
+
'request_model' => $this->getRequest(),
|
| 110 |
+
'session' => $this->_getSession(),
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
Mage::dispatchEvent('adminhtml_sales_order_create_process_data_before', $eventData);
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Saving order data
|
| 117 |
+
*/
|
| 118 |
+
if ($data = $this->getRequest()->getPost('order')) {
|
| 119 |
+
$this->_getOrderCreateModel()->importPostData($data);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* Initialize catalog rule data
|
| 124 |
+
*/
|
| 125 |
+
$this->_getOrderCreateModel()->initRuleData();
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* init first billing address, need for virtual products
|
| 129 |
+
*/
|
| 130 |
+
$this->_getOrderCreateModel()->getBillingAddress();
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* Flag for using billing address for shipping
|
| 134 |
+
*/
|
| 135 |
+
if (!$this->_getOrderCreateModel()->getQuote()->isVirtual()) {
|
| 136 |
+
$syncFlag = $this->getRequest()->getPost('shipping_as_billing');
|
| 137 |
+
$shippingMethod = $this->_getOrderCreateModel()->getShippingAddress()->getShippingMethod();
|
| 138 |
+
if (is_null($syncFlag)
|
| 139 |
+
&& $this->_getOrderCreateModel()->getShippingAddress()->getSameAsBilling()
|
| 140 |
+
&& empty($shippingMethod)
|
| 141 |
+
) {
|
| 142 |
+
$this->_getOrderCreateModel()->setShippingAsBilling(1);
|
| 143 |
+
} else {
|
| 144 |
+
$this->_getOrderCreateModel()->setShippingAsBilling((int)$syncFlag);
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Change shipping address flag
|
| 150 |
+
*/
|
| 151 |
+
if (!$this->_getOrderCreateModel()->getQuote()->isVirtual() && $this->getRequest()->getPost('reset_shipping')) {
|
| 152 |
+
$this->_getOrderCreateModel()->resetShippingMethod(true);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Collecting shipping rates
|
| 157 |
+
*/
|
| 158 |
+
if (!$this->_getOrderCreateModel()->getQuote()->isVirtual() &&
|
| 159 |
+
$this->getRequest()->getPost('collect_shipping_rates')
|
| 160 |
+
) {
|
| 161 |
+
$this->_getOrderCreateModel()->collectShippingRates();
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Apply mass changes from sidebar
|
| 167 |
+
*/
|
| 168 |
+
if ($data = $this->getRequest()->getPost('sidebar')) {
|
| 169 |
+
$this->_getOrderCreateModel()->applySidebarData($data);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Adding product to quote from shopping cart, wishlist etc.
|
| 174 |
+
*/
|
| 175 |
+
if ($productId = (int) $this->getRequest()->getPost('add_product')) {
|
| 176 |
+
$this->_getOrderCreateModel()->addProduct($productId, $this->getRequest()->getPost());
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Adding products to quote from special grid
|
| 181 |
+
*/
|
| 182 |
+
if ($this->getRequest()->has('item') && !$this->getRequest()->getPost('update_items') && !($action == 'save')) {
|
| 183 |
+
$items = $this->getRequest()->getPost('item');
|
| 184 |
+
$items = $this->_processFiles($items);
|
| 185 |
+
$this->_getOrderCreateModel()->addProducts($items);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Update quote items
|
| 190 |
+
*/
|
| 191 |
+
if ($this->getRequest()->getPost('update_items')) {
|
| 192 |
+
$items = $this->getRequest()->getPost('item', array());
|
| 193 |
+
$items = $this->_processFiles($items);
|
| 194 |
+
$this->_getOrderCreateModel()->updateQuoteItems($items);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Remove quote item
|
| 199 |
+
*/
|
| 200 |
+
$removeItemId = (int) $this->getRequest()->getPost('remove_item');
|
| 201 |
+
$removeFrom = (string) $this->getRequest()->getPost('from');
|
| 202 |
+
if ($removeItemId && $removeFrom) {
|
| 203 |
+
$this->_getOrderCreateModel()->removeItem($removeItemId, $removeFrom);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Move quote item
|
| 208 |
+
*/
|
| 209 |
+
$moveItemId = (int) $this->getRequest()->getPost('move_item');
|
| 210 |
+
$moveTo = (string) $this->getRequest()->getPost('to');
|
| 211 |
+
if ($moveItemId && $moveTo) {
|
| 212 |
+
$this->_getOrderCreateModel()->moveQuoteItem($moveItemId, $moveTo);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/*if ($paymentData = $this->getRequest()->getPost('payment')) {
|
| 216 |
+
$this->_getOrderCreateModel()->setPaymentData($paymentData);
|
| 217 |
+
}*/
|
| 218 |
+
if ($paymentData = $this->getRequest()->getPost('payment')) {
|
| 219 |
+
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentData);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
$eventData = array(
|
| 223 |
+
'order_create_model' => $this->_getOrderCreateModel(),
|
| 224 |
+
'request' => $this->getRequest()->getPost(),
|
| 225 |
+
);
|
| 226 |
+
|
| 227 |
+
Mage::dispatchEvent('adminhtml_sales_order_create_process_data', $eventData);
|
| 228 |
+
|
| 229 |
+
$this->_getOrderCreateModel()
|
| 230 |
+
->saveQuote();
|
| 231 |
+
|
| 232 |
+
if ($paymentData = $this->getRequest()->getPost('payment')) {
|
| 233 |
+
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentData);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/**
|
| 237 |
+
* Saving of giftmessages
|
| 238 |
+
*/
|
| 239 |
+
$giftmessages = $this->getRequest()->getPost('giftmessage');
|
| 240 |
+
if ($giftmessages) {
|
| 241 |
+
$this->_getGiftmessageSaveModel()->setGiftmessages($giftmessages)
|
| 242 |
+
->saveAllInQuote();
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
/**
|
| 246 |
+
* Importing gift message allow items from specific product grid
|
| 247 |
+
*/
|
| 248 |
+
if ($data = $this->getRequest()->getPost('add_products')) {
|
| 249 |
+
$this->_getGiftmessageSaveModel()
|
| 250 |
+
->importAllowQuoteItemsFromProducts(Mage::helper('core')->jsonDecode($data));
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Importing gift message allow items on update quote items
|
| 255 |
+
*/
|
| 256 |
+
if ($this->getRequest()->getPost('update_items')) {
|
| 257 |
+
$items = $this->getRequest()->getPost('item', array());
|
| 258 |
+
$this->_getGiftmessageSaveModel()->importAllowQuoteItemsFromItems($items);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
$data = $this->getRequest()->getPost('order');
|
| 262 |
+
$couponCode = '';
|
| 263 |
+
if (isset($data) && isset($data['coupon']['code'])) {
|
| 264 |
+
$couponCode = trim($data['coupon']['code']);
|
| 265 |
+
}
|
| 266 |
+
if (!empty($couponCode)) {
|
| 267 |
+
if ($this->_getQuote()->getCouponCode() !== $couponCode) {
|
| 268 |
+
$this->_getSession()->addError(
|
| 269 |
+
$this->__('"%s" coupon code is not valid.', $this->_getHelper()->escapeHtml($couponCode)));
|
| 270 |
+
} else {
|
| 271 |
+
$this->_getSession()->addSuccess($this->__('The coupon code has been accepted.'));
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
return $this;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
/**
|
| 279 |
+
* Process buyRequest file options of items
|
| 280 |
+
*
|
| 281 |
+
* @param array $items
|
| 282 |
+
* @return array
|
| 283 |
+
*/
|
| 284 |
+
protected function _processFiles($items)
|
| 285 |
+
{
|
| 286 |
+
/* @var $productHelper Mage_Catalog_Helper_Product */
|
| 287 |
+
$productHelper = Mage::helper('catalog/product');
|
| 288 |
+
foreach ($items as $id => $item) {
|
| 289 |
+
$buyRequest = new Varien_Object($item);
|
| 290 |
+
$params = array('files_prefix' => 'item_' . $id . '_');
|
| 291 |
+
$buyRequest = $productHelper->addParamsToBuyRequest($buyRequest, $params);
|
| 292 |
+
if ($buyRequest->hasData()) {
|
| 293 |
+
$items[$id] = $buyRequest->toArray();
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
return $items;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* Index page
|
| 301 |
+
*/
|
| 302 |
+
public function indexAction()
|
| 303 |
+
{
|
| 304 |
+
$this->_title($this->__('Sales'))->_title($this->__('Orders'))->_title($this->__('New Order'));
|
| 305 |
+
$this->_initSession();
|
| 306 |
+
$this->loadLayout();
|
| 307 |
+
|
| 308 |
+
$this->_setActiveMenu('sales/order')
|
| 309 |
+
->renderLayout();
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
public function reorderAction()
|
| 314 |
+
{
|
| 315 |
+
// $this->_initSession();
|
| 316 |
+
$this->_getSession()->clear();
|
| 317 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
| 318 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 319 |
+
if (!Mage::helper('sales/reorder')->canReorder($order)) {
|
| 320 |
+
return $this->_forward('noRoute');
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
if ($order->getId()) {
|
| 324 |
+
$order->setReordered(true);
|
| 325 |
+
$this->_getSession()->setUseOldShippingMethod(true);
|
| 326 |
+
$this->_getOrderCreateModel()->initFromOrder($order);
|
| 327 |
+
|
| 328 |
+
$this->_redirect('*/*');
|
| 329 |
+
}
|
| 330 |
+
else {
|
| 331 |
+
$this->_redirect('*/sales_order/');
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
protected function _reloadQuote()
|
| 336 |
+
{
|
| 337 |
+
$id = $this->_getQuote()->getId();
|
| 338 |
+
$this->_getQuote()->load($id);
|
| 339 |
+
return $this;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
/**
|
| 343 |
+
* Loading page block
|
| 344 |
+
*/
|
| 345 |
+
public function loadBlockAction()
|
| 346 |
+
{
|
| 347 |
+
$request = $this->getRequest();
|
| 348 |
+
try {
|
| 349 |
+
$this->_initSession()
|
| 350 |
+
->_processData();
|
| 351 |
+
}
|
| 352 |
+
catch (Mage_Core_Exception $e){
|
| 353 |
+
$this->_reloadQuote();
|
| 354 |
+
$this->_getSession()->addError($e->getMessage());
|
| 355 |
+
}
|
| 356 |
+
catch (Exception $e){
|
| 357 |
+
$this->_reloadQuote();
|
| 358 |
+
$this->_getSession()->addException($e, $e->getMessage());
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
$asJson= $request->getParam('json');
|
| 363 |
+
$block = $request->getParam('block');
|
| 364 |
+
|
| 365 |
+
$update = $this->getLayout()->getUpdate();
|
| 366 |
+
if ($asJson) {
|
| 367 |
+
$update->addHandle('adminhtml_sales_order_create_load_block_json');
|
| 368 |
+
} else {
|
| 369 |
+
$update->addHandle('adminhtml_sales_order_create_load_block_plain');
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
if ($block) {
|
| 373 |
+
$blocks = explode(',', $block);
|
| 374 |
+
if ($asJson && !in_array('message', $blocks)) {
|
| 375 |
+
$blocks[] = 'message';
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
foreach ($blocks as $block) {
|
| 379 |
+
$update->addHandle('adminhtml_sales_order_create_load_block_' . $block);
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
$this->loadLayoutUpdates()->generateLayoutXml()->generateLayoutBlocks();
|
| 383 |
+
$result = $this->getLayout()->getBlock('content')->toHtml();
|
| 384 |
+
if ($request->getParam('as_js_varname')) {
|
| 385 |
+
Mage::getSingleton('adminhtml/session')->setUpdateResult($result);
|
| 386 |
+
$this->_redirect('*/*/showUpdateResult');
|
| 387 |
+
} else {
|
| 388 |
+
$this->getResponse()->setBody($result);
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
/**
|
| 393 |
+
* Adds configured product to quote
|
| 394 |
+
*/
|
| 395 |
+
public function addConfiguredAction()
|
| 396 |
+
{
|
| 397 |
+
$errorMessage = null;
|
| 398 |
+
try {
|
| 399 |
+
$this->_initSession()
|
| 400 |
+
->_processData();
|
| 401 |
+
}
|
| 402 |
+
catch (Exception $e){
|
| 403 |
+
$this->_reloadQuote();
|
| 404 |
+
$errorMessage = $e->getMessage();
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
// Form result for client javascript
|
| 408 |
+
$updateResult = new Varien_Object();
|
| 409 |
+
if ($errorMessage) {
|
| 410 |
+
$updateResult->setError(true);
|
| 411 |
+
$updateResult->setMessage($errorMessage);
|
| 412 |
+
} else {
|
| 413 |
+
$updateResult->setOk(true);
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
$updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
|
| 417 |
+
Mage::getSingleton('adminhtml/session')->setCompositeProductResult($updateResult);
|
| 418 |
+
$this->_redirect('*/catalog_product/showUpdateResult');
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
/**
|
| 422 |
+
* Start order create action
|
| 423 |
+
*/
|
| 424 |
+
public function startAction()
|
| 425 |
+
{
|
| 426 |
+
$this->_getSession()->clear();
|
| 427 |
+
$this->_redirect('*/*', array('customer_id' => $this->getRequest()->getParam('customer_id')));
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* Cancel order create
|
| 432 |
+
*/
|
| 433 |
+
public function cancelAction()
|
| 434 |
+
{
|
| 435 |
+
if ($orderId = $this->_getSession()->getReordered()) {
|
| 436 |
+
$this->_getSession()->clear();
|
| 437 |
+
$this->_redirect('*/sales_order/view', array(
|
| 438 |
+
'order_id'=>$orderId
|
| 439 |
+
));
|
| 440 |
+
} else {
|
| 441 |
+
$this->_getSession()->clear();
|
| 442 |
+
$this->_redirect('*/*');
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
/**
|
| 448 |
+
* Saving quote and create order Added By IndiaNIC
|
| 449 |
+
*/
|
| 450 |
+
public function saveAction()
|
| 451 |
+
{
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
try {
|
| 455 |
+
$this->_processActionData('save');
|
| 456 |
+
if ($paymentData = $this->getRequest()->getPost('payment')) {
|
| 457 |
+
$this->_getOrderCreateModel()->setPaymentData($paymentData);
|
| 458 |
+
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentData);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
$payment_Data = $this->getRequest()->getPost('payment');
|
| 462 |
+
if($payment_Data="creditpayment"){
|
| 463 |
+
|
| 464 |
+
$CreateQuate =$this->_getOrderCreateModel()->getQuote();
|
| 465 |
+
$grandTotal= $CreateQuate->getBaseGrandTotal();
|
| 466 |
+
$customer_id= $CreateQuate->getCustomerId();
|
| 467 |
+
$customerData = Mage::getModel('customer/customer')->load($customer_id);
|
| 468 |
+
$customerCreditLimit = $customerData->getCreditLimit();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
if($payment_Data['method'] =="creditpayment" && $customerCreditLimit < $grandTotal){
|
| 472 |
+
$error = "Customer don't have enough Credit";
|
| 473 |
+
Mage::throwException($error);
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
$order = $this->_getOrderCreateModel()
|
| 478 |
+
->setIsValidate(true)
|
| 479 |
+
->importPostData($this->getRequest()->getPost('order'))
|
| 480 |
+
->createOrder();
|
| 481 |
+
$order_id = $order->getId();
|
| 482 |
+
|
| 483 |
+
if($payment_Data =="creditpayment" && $customerCreditLimit >= $grandTotal)
|
| 484 |
+
{
|
| 485 |
+
|
| 486 |
+
$Availablelimit = $customerCreditLimit;
|
| 487 |
+
$AppliedCredit = $grandTotal;
|
| 488 |
+
$setUpdatedlimit = $Availablelimit - $AppliedCredit;
|
| 489 |
+
$model=Mage::getModel('creditpayment/creditpayment');
|
| 490 |
+
$model->setOrderId($order_id);
|
| 491 |
+
$model->setCustomerId($customer_id);
|
| 492 |
+
$model->setAppliedAmount($AppliedCredit);
|
| 493 |
+
$model->setCreatedTime(now());
|
| 494 |
+
$model->save();
|
| 495 |
+
|
| 496 |
+
$customerData->setCreditLimit($setUpdatedlimit);
|
| 497 |
+
$customerData->save();
|
| 498 |
+
|
| 499 |
+
}
|
| 500 |
+
/** set Order status to Processing & Automatically generate Invoice when order place **/
|
| 501 |
+
$Orderstatus = Mage::getStoreConfig('payment/creditpayment/order_status');
|
| 502 |
+
if($payment_Data =="creditpayment" && $Orderstatus == "processing"){
|
| 503 |
+
if ($order->canInvoice()){
|
| 504 |
+
$this->_processOrderStatus($order);
|
| 505 |
+
}
|
| 506 |
+
}
|
| 507 |
+
$this->_getSession()->clear();
|
| 508 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
|
| 509 |
+
|
| 510 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
| 511 |
+
} catch (Mage_Payment_Model_Info_Exception $e) {
|
| 512 |
+
$this->_getOrderCreateModel()->saveQuote();
|
| 513 |
+
$message = $e->getMessage();
|
| 514 |
+
if( !empty($message) ) {
|
| 515 |
+
$this->_getSession()->addError($message);
|
| 516 |
+
}
|
| 517 |
+
$this->_redirect('*/*/');
|
| 518 |
+
} catch (Mage_Core_Exception $e){
|
| 519 |
+
$message = $e->getMessage();
|
| 520 |
+
if( !empty($message) ) {
|
| 521 |
+
$this->_getSession()->addError($message);
|
| 522 |
+
}
|
| 523 |
+
$this->_redirect('*/*/');
|
| 524 |
+
}
|
| 525 |
+
catch (Exception $e){
|
| 526 |
+
$this->_getSession()->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
|
| 527 |
+
$this->_redirect('*/*/');
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
/**
|
| 532 |
+
* Acl check for admin
|
| 533 |
+
*
|
| 534 |
+
* @return bool
|
| 535 |
+
*/
|
| 536 |
+
protected function _isAllowed()
|
| 537 |
+
{
|
| 538 |
+
$action = strtolower($this->getRequest()->getActionName());
|
| 539 |
+
switch ($action) {
|
| 540 |
+
case 'index':
|
| 541 |
+
$aclResource = 'sales/order/actions/create';
|
| 542 |
+
break;
|
| 543 |
+
case 'reorder':
|
| 544 |
+
$aclResource = 'sales/order/actions/reorder';
|
| 545 |
+
break;
|
| 546 |
+
case 'cancel':
|
| 547 |
+
$aclResource = 'sales/order/actions/cancel';
|
| 548 |
+
break;
|
| 549 |
+
case 'save':
|
| 550 |
+
$aclResource = 'sales/order/actions/edit';
|
| 551 |
+
break;
|
| 552 |
+
default:
|
| 553 |
+
$aclResource = 'sales/order/actions';
|
| 554 |
+
break;
|
| 555 |
+
}
|
| 556 |
+
return Mage::getSingleton('admin/session')->isAllowed($aclResource);
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
/*
|
| 560 |
+
* Ajax handler to response configuration fieldset of composite product in order
|
| 561 |
+
*
|
| 562 |
+
* @return Mage_Adminhtml_Sales_Order_CreateController
|
| 563 |
+
*/
|
| 564 |
+
public function configureProductToAddAction()
|
| 565 |
+
{
|
| 566 |
+
// Prepare data
|
| 567 |
+
$productId = (int) $this->getRequest()->getParam('id');
|
| 568 |
+
|
| 569 |
+
$configureResult = new Varien_Object();
|
| 570 |
+
$configureResult->setOk(true);
|
| 571 |
+
$configureResult->setProductId($productId);
|
| 572 |
+
$sessionQuote = Mage::getSingleton('adminhtml/session_quote');
|
| 573 |
+
$configureResult->setCurrentStoreId($sessionQuote->getStore()->getId());
|
| 574 |
+
$configureResult->setCurrentCustomerId($sessionQuote->getCustomerId());
|
| 575 |
+
|
| 576 |
+
// Render page
|
| 577 |
+
/* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
|
| 578 |
+
$helper = Mage::helper('adminhtml/catalog_product_composite');
|
| 579 |
+
$helper->renderConfigureResult($this, $configureResult);
|
| 580 |
+
|
| 581 |
+
return $this;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
/*
|
| 585 |
+
* Ajax handler to response configuration fieldset of composite product in quote items
|
| 586 |
+
*
|
| 587 |
+
* @return Mage_Adminhtml_Sales_Order_CreateController
|
| 588 |
+
*/
|
| 589 |
+
public function configureQuoteItemsAction()
|
| 590 |
+
{
|
| 591 |
+
// Prepare data
|
| 592 |
+
$configureResult = new Varien_Object();
|
| 593 |
+
try {
|
| 594 |
+
$quoteItemId = (int) $this->getRequest()->getParam('id');
|
| 595 |
+
if (!$quoteItemId) {
|
| 596 |
+
Mage::throwException($this->__('Quote item id is not received.'));
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
$quoteItem = Mage::getModel('sales/quote_item')->load($quoteItemId);
|
| 600 |
+
if (!$quoteItem->getId()) {
|
| 601 |
+
Mage::throwException($this->__('Quote item is not loaded.'));
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
$configureResult->setOk(true);
|
| 605 |
+
$optionCollection = Mage::getModel('sales/quote_item_option')->getCollection()
|
| 606 |
+
->addItemFilter(array($quoteItemId));
|
| 607 |
+
$quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem));
|
| 608 |
+
|
| 609 |
+
$configureResult->setBuyRequest($quoteItem->getBuyRequest());
|
| 610 |
+
$configureResult->setCurrentStoreId($quoteItem->getStoreId());
|
| 611 |
+
$configureResult->setProductId($quoteItem->getProductId());
|
| 612 |
+
$sessionQuote = Mage::getSingleton('adminhtml/session_quote');
|
| 613 |
+
$configureResult->setCurrentCustomerId($sessionQuote->getCustomerId());
|
| 614 |
+
|
| 615 |
+
} catch (Exception $e) {
|
| 616 |
+
$configureResult->setError(true);
|
| 617 |
+
$configureResult->setMessage($e->getMessage());
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
// Render page
|
| 621 |
+
/* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
|
| 622 |
+
$helper = Mage::helper('adminhtml/catalog_product_composite');
|
| 623 |
+
$helper->renderConfigureResult($this, $configureResult);
|
| 624 |
+
|
| 625 |
+
return $this;
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* Show item update result from loadBlockAction
|
| 631 |
+
* to prevent popup alert with resend data question
|
| 632 |
+
*
|
| 633 |
+
*/
|
| 634 |
+
public function showUpdateResultAction()
|
| 635 |
+
{
|
| 636 |
+
$session = Mage::getSingleton('adminhtml/session');
|
| 637 |
+
if ($session->hasUpdateResult() && is_scalar($session->getUpdateResult())){
|
| 638 |
+
$this->getResponse()->setBody($session->getUpdateResult());
|
| 639 |
+
$session->unsUpdateResult();
|
| 640 |
+
} else {
|
| 641 |
+
$session->unsUpdateResult();
|
| 642 |
+
return false;
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/**
|
| 647 |
+
* Process data and display index page
|
| 648 |
+
*/
|
| 649 |
+
public function processDataAction()
|
| 650 |
+
{
|
| 651 |
+
$this->_initSession();
|
| 652 |
+
$this->_processData();
|
| 653 |
+
$this->_forward('index');
|
| 654 |
+
}
|
| 655 |
+
/*** Added By IndiaNIC For Save Order status Processing & T generate Invoice **/
|
| 656 |
+
private function _processOrderStatus($order)
|
| 657 |
+
{
|
| 658 |
+
$invoice = $order->prepareInvoice();
|
| 659 |
+
|
| 660 |
+
$invoice->register();
|
| 661 |
+
Mage::getModel('core/resource_transaction')
|
| 662 |
+
->addObject($invoice)
|
| 663 |
+
->addObject($invoice->getOrder())
|
| 664 |
+
->save();
|
| 665 |
+
|
| 666 |
+
$invoice->sendEmail(true, '');
|
| 667 |
+
return true;
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
}
|
app/code/local/Inic/Creditpayment/etc/config.xml
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Inic_Creditpayment>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Inic_Creditpayment>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<helpers>
|
| 10 |
+
<creditpayment>
|
| 11 |
+
<class>Inic_Creditpayment_Helper</class>
|
| 12 |
+
</creditpayment>
|
| 13 |
+
</helpers>
|
| 14 |
+
<models>
|
| 15 |
+
<creditpayment>
|
| 16 |
+
<class>Inic_Creditpayment_Model</class>
|
| 17 |
+
<resourceModel>creditpayment_mysql4</resourceModel>
|
| 18 |
+
</creditpayment>
|
| 19 |
+
<creditpayment_mysql4>
|
| 20 |
+
<class>Inic_Creditpayment_Model_Mysql4</class>
|
| 21 |
+
<entities>
|
| 22 |
+
<creditpayment>
|
| 23 |
+
<table>customers_credit_applied</table>
|
| 24 |
+
</creditpayment>
|
| 25 |
+
</entities>
|
| 26 |
+
</creditpayment_mysql4>
|
| 27 |
+
<checkout>
|
| 28 |
+
<rewrite>
|
| 29 |
+
<type_onepage>Inic_Creditpayment_Model_Checkout_Type_Onepage</type_onepage>
|
| 30 |
+
<type_multishipping>Inic_Creditpayment_Model_Checkout_Type_Multishipping</type_multishipping>
|
| 31 |
+
</rewrite>
|
| 32 |
+
</checkout>
|
| 33 |
+
<customer>
|
| 34 |
+
<rewrite>
|
| 35 |
+
<customer>Inic_Creditpayment_Model_Customer</customer>
|
| 36 |
+
</rewrite>
|
| 37 |
+
</customer>
|
| 38 |
+
</models>
|
| 39 |
+
<resources>
|
| 40 |
+
<creditpayment_setup>
|
| 41 |
+
<setup>
|
| 42 |
+
<module>Inic_Creditpayment</module>
|
| 43 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
| 44 |
+
</setup>
|
| 45 |
+
<connection>
|
| 46 |
+
<use>core_setup</use>
|
| 47 |
+
</connection>
|
| 48 |
+
</creditpayment_setup>
|
| 49 |
+
<creditpayment_write>
|
| 50 |
+
<connection>
|
| 51 |
+
<use>core_write</use>
|
| 52 |
+
</connection>
|
| 53 |
+
</creditpayment_write>
|
| 54 |
+
<creditpayment_read>
|
| 55 |
+
<connection>
|
| 56 |
+
<use>core_read</use>
|
| 57 |
+
</connection>
|
| 58 |
+
</creditpayment_read>
|
| 59 |
+
</resources>
|
| 60 |
+
<blocks>
|
| 61 |
+
<creditpayment>
|
| 62 |
+
<class>Inic_Creditpayment_Block</class>
|
| 63 |
+
</creditpayment>
|
| 64 |
+
<adminhtml>
|
| 65 |
+
<rewrite>
|
| 66 |
+
<customer_edit_tab_account>Inic_Creditpayment_Block_Adminhtml_Customer_Editcustomer</customer_edit_tab_account>
|
| 67 |
+
</rewrite>
|
| 68 |
+
</adminhtml>
|
| 69 |
+
</blocks>
|
| 70 |
+
</global>
|
| 71 |
+
<default>
|
| 72 |
+
<payment>
|
| 73 |
+
<creditpayment>
|
| 74 |
+
<specificcustomers>1,2,3,4</specificcustomers>
|
| 75 |
+
<active>0</active>
|
| 76 |
+
<model>creditpayment/method_creditpayment</model>
|
| 77 |
+
<order_status>pending</order_status>
|
| 78 |
+
<title>Credit Point Payment</title>
|
| 79 |
+
<allowspecific>0</allowspecific>
|
| 80 |
+
<group>offline</group>
|
| 81 |
+
</creditpayment>
|
| 82 |
+
</payment>
|
| 83 |
+
</default>
|
| 84 |
+
<frontend>
|
| 85 |
+
<events>
|
| 86 |
+
<checkout_type_onepage_save_order_after>
|
| 87 |
+
<observers>
|
| 88 |
+
<checkout_save_order_Credit>
|
| 89 |
+
<type>singleton</type>
|
| 90 |
+
<class>Inic_Creditpayment_Model_Observer</class>
|
| 91 |
+
<method>saveCredit</method>
|
| 92 |
+
</checkout_save_order_Credit>
|
| 93 |
+
</observers>
|
| 94 |
+
</checkout_type_onepage_save_order_after>
|
| 95 |
+
<checkout_submit_all_after>
|
| 96 |
+
<observers>
|
| 97 |
+
<checkout_save_multi_order_Credit>
|
| 98 |
+
<type>singleton</type>
|
| 99 |
+
<class>Inic_Creditpayment_Model_Observer</class>
|
| 100 |
+
<method>saveMultiCredit</method>
|
| 101 |
+
</checkout_save_multi_order_Credit>
|
| 102 |
+
</observers>
|
| 103 |
+
</checkout_submit_all_after>
|
| 104 |
+
<payment_method_is_active>
|
| 105 |
+
<observers>
|
| 106 |
+
<checkout_payment_available>
|
| 107 |
+
<type>singleton</type>
|
| 108 |
+
<class>Inic_Creditpayment_Model_Observer</class>
|
| 109 |
+
<method>isAvailable</method>
|
| 110 |
+
</checkout_payment_available>
|
| 111 |
+
</observers>
|
| 112 |
+
</payment_method_is_active>
|
| 113 |
+
<sales_order_place_after>
|
| 114 |
+
<observers>
|
| 115 |
+
<auto_invoice_order>
|
| 116 |
+
<type>singleton</type>
|
| 117 |
+
<class>Inic_Creditpayment_Model_Observer</class>
|
| 118 |
+
<method>implementOrderStatus</method>
|
| 119 |
+
</auto_invoice_order>
|
| 120 |
+
</observers>
|
| 121 |
+
</sales_order_place_after>
|
| 122 |
+
</events>
|
| 123 |
+
<layout>
|
| 124 |
+
<updates>
|
| 125 |
+
<creditpayment>
|
| 126 |
+
<file>creditpayment.xml</file>
|
| 127 |
+
</creditpayment>
|
| 128 |
+
</updates>
|
| 129 |
+
</layout>
|
| 130 |
+
</frontend>
|
| 131 |
+
<adminhtml>
|
| 132 |
+
<layout>
|
| 133 |
+
<updates>
|
| 134 |
+
<creditpayment>
|
| 135 |
+
<file>creditpayment.xml</file>
|
| 136 |
+
</creditpayment>
|
| 137 |
+
</updates>
|
| 138 |
+
</layout>
|
| 139 |
+
<events>
|
| 140 |
+
<sales_order_creditmemo_refund>
|
| 141 |
+
<observers>
|
| 142 |
+
<Inic_Creditpayment_Updated>
|
| 143 |
+
<type>singleton</type>
|
| 144 |
+
<class>Inic_Creditpayment_Model_Observer</class>
|
| 145 |
+
<method>revertCredit</method>
|
| 146 |
+
</Inic_Creditpayment_Updated>
|
| 147 |
+
</observers>
|
| 148 |
+
</sales_order_creditmemo_refund>
|
| 149 |
+
</events>
|
| 150 |
+
</adminhtml>
|
| 151 |
+
<admin>
|
| 152 |
+
<routers>
|
| 153 |
+
<adminhtml>
|
| 154 |
+
<args>
|
| 155 |
+
<modules>
|
| 156 |
+
<Inic_Creditpayment_Adminhtml before="Mage_Adminhtml">Inic_Creditpayment_Adminhtml</Inic_Creditpayment_Adminhtml>
|
| 157 |
+
</modules>
|
| 158 |
+
</args>
|
| 159 |
+
</adminhtml>
|
| 160 |
+
</routers>
|
| 161 |
+
</admin>
|
| 162 |
+
</config>
|
app/code/local/Inic/Creditpayment/etc/system.xml
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<creditpayment translate="label">
|
| 7 |
+
<label>Credit Point Payment</label>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>30</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>1</show_in_store>
|
| 13 |
+
<fields>
|
| 14 |
+
<active translate="label">
|
| 15 |
+
<label>Enabled</label>
|
| 16 |
+
<frontend_type>select</frontend_type>
|
| 17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
+
<sort_order>1</sort_order>
|
| 19 |
+
<show_in_default>1</show_in_default>
|
| 20 |
+
<show_in_website>1</show_in_website>
|
| 21 |
+
<show_in_store>0</show_in_store>
|
| 22 |
+
</active>
|
| 23 |
+
<specificcustomers translate="label">
|
| 24 |
+
<label>Enable For Customer Groups </label>
|
| 25 |
+
<frontend_type>multiselect</frontend_type>
|
| 26 |
+
<sort_order>3</sort_order>
|
| 27 |
+
<source_model>adminhtml/system_config_source_customer_group_multiselect</source_model>
|
| 28 |
+
<show_in_default>1</show_in_default>
|
| 29 |
+
<show_in_website>1</show_in_website>
|
| 30 |
+
<show_in_store>0</show_in_store>
|
| 31 |
+
</specificcustomers>
|
| 32 |
+
<order_status translate="label">
|
| 33 |
+
<label>New Order Status</label>
|
| 34 |
+
<frontend_type>select</frontend_type>
|
| 35 |
+
<source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
|
| 36 |
+
<sort_order>20</sort_order>
|
| 37 |
+
<show_in_default>1</show_in_default>
|
| 38 |
+
<show_in_website>1</show_in_website>
|
| 39 |
+
<show_in_store>0</show_in_store>
|
| 40 |
+
</order_status>
|
| 41 |
+
<sort_order translate="label">
|
| 42 |
+
<label>Sort Order</label>
|
| 43 |
+
<frontend_type>text</frontend_type>
|
| 44 |
+
<sort_order>100</sort_order>
|
| 45 |
+
<show_in_default>1</show_in_default>
|
| 46 |
+
<show_in_website>1</show_in_website>
|
| 47 |
+
<show_in_store>0</show_in_store>
|
| 48 |
+
<frontend_class>validate-number</frontend_class>
|
| 49 |
+
</sort_order>
|
| 50 |
+
<title translate="label">
|
| 51 |
+
<label>Title</label>
|
| 52 |
+
<frontend_type>text</frontend_type>
|
| 53 |
+
<sort_order>10</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</title>
|
| 58 |
+
<allowspecific translate="label">
|
| 59 |
+
<label>Payment from Applicable Countries</label>
|
| 60 |
+
<frontend_type>allowspecific</frontend_type>
|
| 61 |
+
<sort_order>50</sort_order>
|
| 62 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 63 |
+
<show_in_default>1</show_in_default>
|
| 64 |
+
<show_in_website>1</show_in_website>
|
| 65 |
+
<show_in_store>0</show_in_store>
|
| 66 |
+
</allowspecific>
|
| 67 |
+
<specificcountry translate="label">
|
| 68 |
+
<label>Payment from Specific Countries</label>
|
| 69 |
+
<frontend_type>multiselect</frontend_type>
|
| 70 |
+
<sort_order>51</sort_order>
|
| 71 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 72 |
+
<show_in_default>1</show_in_default>
|
| 73 |
+
<show_in_website>1</show_in_website>
|
| 74 |
+
<show_in_store>0</show_in_store>
|
| 75 |
+
<can_be_empty>1</can_be_empty>
|
| 76 |
+
</specificcountry>
|
| 77 |
+
|
| 78 |
+
<min_order_total translate="label">
|
| 79 |
+
<label>Minimum Order Total</label>
|
| 80 |
+
<frontend_type>text</frontend_type>
|
| 81 |
+
<sort_order>98</sort_order>
|
| 82 |
+
<show_in_default>1</show_in_default>
|
| 83 |
+
<show_in_website>1</show_in_website>
|
| 84 |
+
<show_in_store>0</show_in_store>
|
| 85 |
+
</min_order_total>
|
| 86 |
+
<max_order_total translate="label">
|
| 87 |
+
<label>Maximum Order Total</label>
|
| 88 |
+
<frontend_type>text</frontend_type>
|
| 89 |
+
<sort_order>99</sort_order>
|
| 90 |
+
<show_in_default>1</show_in_default>
|
| 91 |
+
<show_in_website>1</show_in_website>
|
| 92 |
+
<show_in_store>0</show_in_store>
|
| 93 |
+
</max_order_total>
|
| 94 |
+
<model>
|
| 95 |
+
</model>
|
| 96 |
+
</fields>
|
| 97 |
+
</creditpayment>
|
| 98 |
+
|
| 99 |
+
</groups>
|
| 100 |
+
</payment>
|
| 101 |
+
</sections>
|
| 102 |
+
</config>
|
app/code/local/Inic/Creditpayment/sql/creditpayment_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* @category Mage
|
| 5 |
+
* @package Inic_Creditpayment
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
$installer = $this;
|
| 9 |
+
|
| 10 |
+
$installer->startSetup();
|
| 11 |
+
|
| 12 |
+
$installer->addAttribute('customer', 'credit_limit', array(
|
| 13 |
+
'label' => 'Credit limit',
|
| 14 |
+
'visible' => 1,
|
| 15 |
+
'type' => 'decimal',
|
| 16 |
+
'required' => 0,
|
| 17 |
+
'position' => 1,
|
| 18 |
+
'sort_order' => 180
|
| 19 |
+
));
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
$installer->run("
|
| 23 |
+
-- DROP TABLE IF EXISTS {$this->getTable('customers_credit_applied')};
|
| 24 |
+
|
| 25 |
+
CREATE TABLE `{$this->getTable('customers_credit_applied')}` (
|
| 26 |
+
`id` INT(10) unsigned NOT NULL auto_increment,
|
| 27 |
+
`customer_id` INT(10) NOT NULL,
|
| 28 |
+
`order_id` INT(10) NOT NULL,
|
| 29 |
+
`applied_amount` DECIMAL(12,2) NOT NULL,
|
| 30 |
+
`created_time` datetime NULL,
|
| 31 |
+
PRIMARY KEY (`id`)
|
| 32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 33 |
+
|
| 34 |
+
");
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$customerattrubute = Mage::getModel('customer/attribute')->loadByCode('customer', 'credit_limit');
|
| 38 |
+
$forms=array('adminhtml_customer');
|
| 39 |
+
$customerattrubute->setData('used_in_forms', $forms);
|
| 40 |
+
$customerattrubute->save();
|
| 41 |
+
|
| 42 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/creditpayment.xml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<adminhtml_customer_edit>
|
| 4 |
+
<reference name="customer_edit_tabs">
|
| 5 |
+
<action method="addTab"><name>customer_edit_tab_credit</name><block>creditpayment/adminhtml_customer_edit_tab_credit</block></action>
|
| 6 |
+
</reference>
|
| 7 |
+
<reference name="js">
|
| 8 |
+
<block type="adminhtml/template" name="creditpayment.js" as="customer_js">
|
| 9 |
+
<action method="setTemplate" ifconfig="payment/creditpayment/active">
|
| 10 |
+
<template>creditpayment/js.phtml</template>
|
| 11 |
+
</action>
|
| 12 |
+
</block>
|
| 13 |
+
</reference>
|
| 14 |
+
</adminhtml_customer_edit>
|
| 15 |
+
</layout>
|
app/design/adminhtml/default/default/template/creditpayment/creditpayment.phtml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<div id="credit-data">
|
| 3 |
+
|
| 4 |
+
<div class="entry-edit">
|
| 5 |
+
<div class="entry-edit-head">
|
| 6 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Credit Tab</h4>
|
| 7 |
+
</div>
|
| 8 |
+
<div id="group_fields4" class="fieldset fieldset-wide">
|
| 9 |
+
<div class="hor-scroll">
|
| 10 |
+
|
| 11 |
+
<input type="hidden" value="<?php echo $this->selectedGroup()?>" name="credit_group" id="selected_group">
|
| 12 |
+
<table class="form-list credit-table" cellspacing="0">
|
| 13 |
+
<tbody>
|
| 14 |
+
|
| 15 |
+
<tr>
|
| 16 |
+
<td class="label"><label for="_accountcredit_limit"><?php echo $this->__('Credit limit')?></label></td>
|
| 17 |
+
<td class="value">
|
| 18 |
+
<input type="text" class=" input-text credit-limit" value="<?php echo $this->getCreditData()?>" name="account[credit_limit]" id="_accountcredit_limit">
|
| 19 |
+
</td>
|
| 20 |
+
</tr>
|
| 21 |
+
</tbody>
|
| 22 |
+
</table>
|
| 23 |
+
</div>
|
| 24 |
+
</div>
|
| 25 |
+
</div>
|
| 26 |
+
</div>
|
app/design/adminhtml/default/default/template/creditpayment/js.phtml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script type="text/javascript">
|
| 2 |
+
Array.prototype.has = function(needle) {
|
| 3 |
+
for (var i=0;i<this.length;i++) {
|
| 4 |
+
if(this[i] == needle){ return true; }
|
| 5 |
+
}
|
| 6 |
+
return false;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
var Tab_div = $$('.credit-limit').size();
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
Event.observe('_accountgroup_id', 'change', checkAvailbleCredit);
|
| 13 |
+
|
| 14 |
+
function checkAvailbleCredit(e)
|
| 15 |
+
{
|
| 16 |
+
var array = $('selected_group').value;
|
| 17 |
+
if(Tab_div == 0 || array== ""){
|
| 18 |
+
return;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var someArray = array.split(',');
|
| 22 |
+
var currentGroup = $('_accountgroup_id').value;
|
| 23 |
+
if(someArray.has(currentGroup) )
|
| 24 |
+
{
|
| 25 |
+
$('customer_info_tabs_customer_edit_tab_credit').style.display="block"
|
| 26 |
+
}
|
| 27 |
+
else{
|
| 28 |
+
$('customer_info_tabs_customer_edit_tab_credit').style.display="none"
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
</script>
|
app/design/frontend/base/default/layout/creditpayment.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<layout version="0.1.0">
|
| 4 |
+
<customer_account_index>
|
| 5 |
+
<reference name="customer_account_dashboard">
|
| 6 |
+
|
| 7 |
+
<action method="setTemplate"><template>creditpayment/customer/account/dashboard.phtml</template></action>
|
| 8 |
+
<reference name="customer_account_dashboard">
|
| 9 |
+
<block type="customer/account_dashboard" name="customer_account_dashboard_credit" as="credit" template="creditpayment/customer/creditpayment.phtml"/>
|
| 10 |
+
</reference>
|
| 11 |
+
|
| 12 |
+
</reference>
|
| 13 |
+
</customer_account_index>
|
| 14 |
+
</layout>
|
app/design/frontend/base/default/template/creditpayment/customer/account/dashboard.phtml
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<div class="dashboard">
|
| 28 |
+
<div class="page-title">
|
| 29 |
+
<h1><?php echo $this->__('My Dashboard') ?></h1>
|
| 30 |
+
</div>
|
| 31 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
| 32 |
+
<?php echo $this->getChildHtml('hello') ?>
|
| 33 |
+
<?php $customer = $this->getCustomer();
|
| 34 |
+
$customerGroup = $customer->getGroupId();
|
| 35 |
+
$SelectedCustomerGroups = Mage::getStoreConfig('payment/creditpayment/specificcustomers');
|
| 36 |
+
$SelectedCustomerGroupsArray = explode(",", $SelectedCustomerGroups);?>
|
| 37 |
+
<?php if(in_array($customerGroup, $SelectedCustomerGroupsArray)) :?>
|
| 38 |
+
<?php echo $this->getChildHtml('credit'); ?>
|
| 39 |
+
<?php endif;?>
|
| 40 |
+
|
| 41 |
+
<?php echo $this->getChildHtml('top') ?>
|
| 42 |
+
<div class="box-account box-info">
|
| 43 |
+
<div class="box-head">
|
| 44 |
+
<h2><?php echo $this->__('Account Information') ?></h2>
|
| 45 |
+
</div>
|
| 46 |
+
<?php /* Extensions placeholder */ ?>
|
| 47 |
+
<?php echo $this->getChildHtml('customer.account.dashboard.extra') ?>
|
| 48 |
+
<?php echo $this->getChildHtml('info') ?>
|
| 49 |
+
|
| 50 |
+
<?php echo $this->getChildHtml('address') ?>
|
| 51 |
+
</div>
|
| 52 |
+
<?php echo $this->getChildHtml('info1') ?>
|
| 53 |
+
<?php echo $this->getChildHtml('info2') ?>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
|
app/design/frontend/base/default/template/creditpayment/customer/creditpayment.phtml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="box-account">
|
| 2 |
+
<div class="box-head">
|
| 3 |
+
<h2><?php echo $this->__('Credit Limit')?></h2>
|
| 4 |
+
</div>
|
| 5 |
+
<div>
|
| 6 |
+
<?php
|
| 7 |
+
$currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
|
| 8 |
+
$CrditBalance = $currencySymbol.$this->getCustomer()->getCreditLimit();?> <?php echo $this->__('Your Credit balance is ').$CrditBalance;?>
|
| 9 |
+
|
| 10 |
+
</div>
|
| 11 |
+
|
| 12 |
+
</div>
|
| 13 |
+
|
app/etc/modules/Inic_Creditpayment.xml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* @category IndiaNic
|
| 7 |
+
* @package IndiaNic_CreditPoints
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Inic_Creditpayment>
|
| 13 |
+
<active>true</active>
|
| 14 |
+
<codePool>local</codePool>
|
| 15 |
+
</Inic_Creditpayment>
|
| 16 |
+
</modules>
|
| 17 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Inic_Creditpayment</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Admin can assign credits which are then redeemable at time of purchase towards the cost of your order. 
|
| 10 |
+
Credit points are an added bonus to our customers on the site and just one of the ways we thank you for being a loyal customer.</summary>
|
| 11 |
+
<description>Features
|
| 12 |
+
view credit balance at customer dashboard
|
| 13 |
+
Assign credits to customer from admin side 
|
| 14 |
+
Enable to specific Customer groups
|
| 15 |
+
Set New Order Status, pending or processing (if status is processing then it will generate invoice automatically)
|
| 16 |
+
select Countries to accept payments from.(Customer's country)
|
| 17 |
+
Set Minimum Order Total/Maximum Order Total to apply credits
|
| 18 |
+
Supports on refund and Credit memo
|
| 19 |
+
Supports on Order creation from admin side
|
| 20 |
+
Payment option works if total order amount is less than or equal to Credit available in account.</description>
|
| 21 |
+
<notes>Credit points are an added bonus to our customers on the site and just one of the ways we thank you for being a loyal customer.</notes>
|
| 22 |
+
<authors><author><name>indianic</name><user>indianic</user><email>enquiry@indianic.com</email></author></authors>
|
| 23 |
+
<date>2013-06-19</date>
|
| 24 |
+
<time>04:24:10</time>
|
| 25 |
+
<contents><target name="magelocal"><dir name="Inic"><dir name="Creditpayment"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Credit.php" hash="7817e2527a34a966a963fa164a1e1965"/></dir></dir><file name="Editcustomer.php" hash="42700c2ab0b7cd928b60b0998129aec7"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4fd596c9fa025252b88cb92a7feb9ac0"/></dir><dir name="Model"><dir name="Checkout"><dir name="Type"><file name="Multishipping.php" hash="ff1df095bcd7ebd99226b10f7802ba26"/><file name="Onepage.php" hash="dbbf8ad0a330efc05c5a6139dd84953e"/></dir></dir><file name="Creditpayment.php" hash="90ca96af5bf218912e9efc16be494a30"/><file name="Customer.php" hash="dade5ab5c0b46de0d195f20773f37014"/><dir name="Method"><file name="Creditpayment.php" hash="2581429356b3b430d1b950c81cbc90d5"/></dir><dir name="Mysql4"><dir name="Creditpayment"><file name="Collection.php" hash="2a99b21cc832446b91c8d53f39c5f5f6"/></dir><file name="Creditpayment.php" hash="6e0ae712783b4fa6081ebbf1933c098b"/></dir><file name="Observer.php" hash="c74abe7f3cd879049c8ec61112385dd7"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="CreateController.php" hash="1138f0ca790b63265f12572f89482c5e"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="4892ff9528cb24b1f3e8dbb40445e93e"/><file name="system.xml" hash="e3a18b665eeec23326f95768c82d865e"/></dir><dir name="sql"><dir name="creditpayment_setup"><file name="mysql4-install-0.1.0.php" hash="e10c250efd42691f723173074fee0149"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inic_Creditpayment.xml" hash="039e0c15a06b409001dacf20beff364d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="creditpayment.xml" hash="a7cdf1caf3e14e4655a32985d6edb132"/></dir><dir name="template"><dir name="creditpayment"><dir name="customer"><dir name="account"><file name="dashboard.phtml" hash="a50d7afced8b802771118adf457c89cb"/></dir><file name="creditpayment.phtml" hash="4b32d070a1b278f849236f067cad9bcd"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="creditpayment.xml" hash="295e7c2715b2b17ff9b85b824b995f58"/></dir><dir name="template"><dir name="creditpayment"><file name="creditpayment.phtml" hash="be77ae4bbea4212b89d12f32956fd296"/><file name="js.phtml" hash="bc073792a58bc2bcac3d511ccbe236c0"/></dir></dir></dir></dir></dir></target></contents>
|
| 26 |
+
<compatible/>
|
| 27 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 28 |
+
</package>
|
