Version Notes
Stable Releases.
Download this release
Release Info
| Developer | Hemant kumar sharma |
| Extension | Dextrous_Saveorder |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/Dextrous/Saveorder/Block/Adminhtml/Saveorder.php +23 -0
- app/code/local/Dextrous/Saveorder/Block/Adminhtml/Saveorder/Grid.php +97 -0
- app/code/local/Dextrous/Saveorder/Block/Sales/Order/Create.php +114 -0
- app/code/local/Dextrous/Saveorder/Helper/Data.php +5 -0
- app/code/local/Dextrous/Saveorder/Model/Mysql4/Saveorder.php +9 -0
- app/code/local/Dextrous/Saveorder/Model/Mysql4/Saveorder/Collection.php +9 -0
- app/code/local/Dextrous/Saveorder/Model/Saveorder.php +9 -0
- app/code/local/Dextrous/Saveorder/Model/Status.php +14 -0
- app/code/local/Dextrous/Saveorder/controllers/Adminhtml/SaveorderController.php +223 -0
- app/code/local/Dextrous/Saveorder/controllers/Sales/Order/EditController.php +33 -0
- app/code/local/Dextrous/Saveorder/etc/adminhtml.xml +32 -0
- app/code/local/Dextrous/Saveorder/etc/config.xml +88 -0
- app/code/local/Dextrous/Saveorder/sql/saveorder_setup/mysql4-install-0.1.0.php +14 -0
- app/design/adminhtml/default/default/layout/saveorder.xml +14 -0
- app/etc/modules/Dextrous_Saveorder.xml +9 -0
- js/saveorder/adminhtml/sales.js +1293 -0
- package.xml +22 -0
app/code/local/Dextrous/Saveorder/Block/Adminhtml/Saveorder.php
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Block_Adminhtml_Saveorder extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_controller = 'adminhtml_saveorder';
|
| 7 |
+
$this->_blockGroup = 'saveorder';
|
| 8 |
+
$this->_headerText = Mage::helper('saveorder')->__('Saved Order Manager');
|
| 9 |
+
$this->_addButtonLabel = Mage::helper('saveorder')->__('Add Item');
|
| 10 |
+
|
| 11 |
+
$this->_addButton('create_order_top_button', array(
|
| 12 |
+
'label' => Mage::helper('sales')->__('Create New Order'),
|
| 13 |
+
'onclick' => 'setLocation(\'' . $this->getcreateOrderUrl() . '\')',
|
| 14 |
+
), 0, 100, 'header', 'header');
|
| 15 |
+
parent::__construct();
|
| 16 |
+
$this->_removeButton('add');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function getcreateOrderUrl()
|
| 20 |
+
{
|
| 21 |
+
return $this->getUrl('adminhtml/sales_order_create/start');
|
| 22 |
+
}
|
| 23 |
+
}
|
app/code/local/Dextrous/Saveorder/Block/Adminhtml/Saveorder/Grid.php
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Block_Adminhtml_Saveorder_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
parent::__construct();
|
| 7 |
+
$this->setId('saveorderGrid');
|
| 8 |
+
$this->setDefaultSort('saveorder_id');
|
| 9 |
+
$this->setDefaultDir('ASC');
|
| 10 |
+
$this->setSaveParametersInSession(true);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
protected function _prepareCollection()
|
| 14 |
+
{
|
| 15 |
+
$collection = Mage::getModel('sales/quote')
|
| 16 |
+
->getCollection()
|
| 17 |
+
->addFieldToFilter('from_admin',1)
|
| 18 |
+
->load();
|
| 19 |
+
$this->setCollection($collection);
|
| 20 |
+
return parent::_prepareCollection();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
protected function _prepareColumns()
|
| 24 |
+
{
|
| 25 |
+
$this->addColumn('entity_id', array(
|
| 26 |
+
'header' => Mage::helper('saveorder')->__('ID'),
|
| 27 |
+
'align' =>'right',
|
| 28 |
+
'width' => '50px',
|
| 29 |
+
'index' => 'entity_id',
|
| 30 |
+
));
|
| 31 |
+
|
| 32 |
+
$this->addColumn('customer_firstname', array(
|
| 33 |
+
'header' => Mage::helper('saveorder')->__('Customer Name'),
|
| 34 |
+
'align' =>'left',
|
| 35 |
+
'index' => 'customer_firstname',
|
| 36 |
+
));
|
| 37 |
+
|
| 38 |
+
$this->addColumn('customer_email', array(
|
| 39 |
+
'header' => Mage::helper('saveorder')->__('Customer Email'),
|
| 40 |
+
'align' =>'left',
|
| 41 |
+
'index' => 'customer_email',
|
| 42 |
+
));
|
| 43 |
+
$this->addColumn('subtotal', array(
|
| 44 |
+
'header' => Mage::helper('saveorder')->__('Order Subtotal'),
|
| 45 |
+
'align' =>'left',
|
| 46 |
+
'index' => 'subtotal',
|
| 47 |
+
));
|
| 48 |
+
|
| 49 |
+
$this->addColumn('action',
|
| 50 |
+
array(
|
| 51 |
+
'header' => Mage::helper('saveorder')->__('Action'),
|
| 52 |
+
'width' => '100',
|
| 53 |
+
'type' => 'action',
|
| 54 |
+
'getter' => 'getId',
|
| 55 |
+
'actions' => array(
|
| 56 |
+
array(
|
| 57 |
+
'caption' => Mage::helper('saveorder')->__('Edit'),
|
| 58 |
+
'url' => array('base'=> '*/*/edit'),
|
| 59 |
+
'field' => 'id'
|
| 60 |
+
)
|
| 61 |
+
),
|
| 62 |
+
'filter' => false,
|
| 63 |
+
'sortable' => false,
|
| 64 |
+
'index' => 'stores',
|
| 65 |
+
'is_system' => true,
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('saveorder')->__('CSV'));
|
| 69 |
+
$this->addExportType('*/*/exportXml', Mage::helper('saveorder')->__('XML'));
|
| 70 |
+
|
| 71 |
+
return parent::_prepareColumns();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
protected function _prepareMassaction()
|
| 75 |
+
{
|
| 76 |
+
$this->setMassactionIdField('saveorder_id');
|
| 77 |
+
$this->getMassactionBlock()->setFormFieldName('saveorder');
|
| 78 |
+
|
| 79 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 80 |
+
'label' => Mage::helper('saveorder')->__('Delete'),
|
| 81 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 82 |
+
'confirm' => Mage::helper('saveorder')->__('Are you sure?')
|
| 83 |
+
));
|
| 84 |
+
$this->getMassactionBlock()->addItem('Submit Order', array(
|
| 85 |
+
'label' => Mage::helper('saveorder')->__('Submit Order'),
|
| 86 |
+
'url' => $this->getUrl('*/*/massSubmit'),
|
| 87 |
+
'confirm' => Mage::helper('saveorder')->__('Are you sure?')
|
| 88 |
+
));
|
| 89 |
+
return $this;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
public function getRowUrl($row)
|
| 93 |
+
{
|
| 94 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
}
|
app/code/local/Dextrous/Saveorder/Block/Sales/Order/Create.php
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Block_Sales_Order_Create extends Mage_Adminhtml_Block_Sales_Order_Create
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_objectId = 'order_id';
|
| 7 |
+
$this->_controller = 'sales_order';
|
| 8 |
+
$this->_mode = 'create';
|
| 9 |
+
|
| 10 |
+
parent::__construct();
|
| 11 |
+
|
| 12 |
+
$this->setId('sales_order_create');
|
| 13 |
+
|
| 14 |
+
$customerId = $this->_getSession()->getCustomerId();
|
| 15 |
+
$storeId = $this->_getSession()->getStoreId();
|
| 16 |
+
|
| 17 |
+
$this->_addButton('save_order', array(
|
| 18 |
+
'id' => 'save_order_top_button',
|
| 19 |
+
'label' => Mage::helper('sales')->__('Save Order'),
|
| 20 |
+
'onclick' => 'setLocation(\'' . $this->getSaveUrl() . '\')',
|
| 21 |
+
), 0, 100, 'header', 'header');
|
| 22 |
+
|
| 23 |
+
$this->_updateButton('save', 'label', Mage::helper('sales')->__('Submit Order'));
|
| 24 |
+
$this->_updateButton('save', 'onclick', "order.submit()");
|
| 25 |
+
$this->_updateButton('save', 'id', 'submit_order_top_button');
|
| 26 |
+
if (is_null($customerId) || !$storeId) {
|
| 27 |
+
$this->_updateButton('save', 'style', 'display:none');
|
| 28 |
+
$this->_updateButton('save_order', 'style', 'display:none');
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
$this->_updateButton('back', 'id', 'back_order_top_button');
|
| 32 |
+
$this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getBackUrl() . '\')');
|
| 33 |
+
|
| 34 |
+
$this->_updateButton('reset', 'id', 'reset_order_top_button');
|
| 35 |
+
|
| 36 |
+
if (is_null($customerId)) {
|
| 37 |
+
$this->_updateButton('reset', 'style', 'display:none');
|
| 38 |
+
} else {
|
| 39 |
+
$this->_updateButton('back', 'style', 'display:none');
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
$confirm = Mage::helper('sales')->__('Are you sure you want to cancel this order?');
|
| 43 |
+
$this->_updateButton('reset', 'label', Mage::helper('sales')->__('Cancel'));
|
| 44 |
+
$this->_updateButton('reset', 'class', 'cancel');
|
| 45 |
+
$this->_updateButton('reset', 'onclick', 'deleteConfirm(\''.$confirm.'\', \'' . $this->getCancelUrl() . '\')');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Prepare header html
|
| 50 |
+
*
|
| 51 |
+
* @return string
|
| 52 |
+
*/
|
| 53 |
+
public function getHeaderHtml()
|
| 54 |
+
{
|
| 55 |
+
$out = '<div id="order-header">'
|
| 56 |
+
. $this->getLayout()->createBlock('adminhtml/sales_order_create_header')->toHtml()
|
| 57 |
+
. '</div>';
|
| 58 |
+
return $out;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Prepare form html. Add block for configurable product modification interface
|
| 63 |
+
*
|
| 64 |
+
* @return string
|
| 65 |
+
*/
|
| 66 |
+
public function getFormHtml()
|
| 67 |
+
{
|
| 68 |
+
$html = parent::getFormHtml();
|
| 69 |
+
$html .= $this->getLayout()->createBlock('adminhtml/catalog_product_composite_configure')->toHtml();
|
| 70 |
+
return $html;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public function getHeaderWidth()
|
| 74 |
+
{
|
| 75 |
+
return 'width: 70%;';
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Retrieve quote session object
|
| 80 |
+
*
|
| 81 |
+
* @return Mage_Adminhtml_Model_Session_Quote
|
| 82 |
+
*/
|
| 83 |
+
protected function _getSession()
|
| 84 |
+
{
|
| 85 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
public function getCancelUrl()
|
| 89 |
+
{
|
| 90 |
+
if ($this->_getSession()->getOrder()->getId()) {
|
| 91 |
+
$url = $this->getUrl('*/sales_order/view', array(
|
| 92 |
+
'order_id' => Mage::getSingleton('adminhtml/session_quote')->getOrder()->getId()
|
| 93 |
+
));
|
| 94 |
+
} else {
|
| 95 |
+
$url = $this->getUrl('*/*/cancel');
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
return $url;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Get URL for back (reset) button
|
| 103 |
+
*
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
+
public function getBackUrl()
|
| 107 |
+
{
|
| 108 |
+
return $this->getUrl('*/' . $this->_controller . '/');
|
| 109 |
+
}
|
| 110 |
+
public function getSaveUrl()
|
| 111 |
+
{
|
| 112 |
+
return $this->getUrl('saveorder/adminhtml_saveorder/confirm');
|
| 113 |
+
}
|
| 114 |
+
}
|
app/code/local/Dextrous/Saveorder/Helper/Data.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
}
|
app/code/local/Dextrous/Saveorder/Model/Mysql4/Saveorder.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Model_Mysql4_Saveorder extends Mage_Core_Model_Mysql4_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
// Note that the saveorder_id refers to the key field in your database table.
|
| 7 |
+
$this->_init('saveorder/saveorder', 'saveorder_id');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Dextrous/Saveorder/Model/Mysql4/Saveorder/Collection.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Model_Mysql4_Saveorder_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
parent::_construct();
|
| 7 |
+
$this->_init('saveorder/saveorder');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Dextrous/Saveorder/Model/Saveorder.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Model_Saveorder extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
parent::_construct();
|
| 7 |
+
$this->_init('saveorder/saveorder');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Dextrous/Saveorder/Model/Status.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Model_Status extends Varien_Object
|
| 3 |
+
{
|
| 4 |
+
const STATUS_ENABLED = 1;
|
| 5 |
+
const STATUS_DISABLED = 2;
|
| 6 |
+
|
| 7 |
+
static public function getOptionArray()
|
| 8 |
+
{
|
| 9 |
+
return array(
|
| 10 |
+
self::STATUS_ENABLED => Mage::helper('saveorder')->__('Enabled'),
|
| 11 |
+
self::STATUS_DISABLED => Mage::helper('saveorder')->__('Disabled')
|
| 12 |
+
);
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/local/Dextrous/Saveorder/controllers/Adminhtml/SaveorderController.php
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Dextrous_Saveorder_Adminhtml_SaveorderController extends Mage_Adminhtml_Controller_action
|
| 3 |
+
{
|
| 4 |
+
protected function _getSession()
|
| 5 |
+
{
|
| 6 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
protected function _initAction() {
|
| 10 |
+
$this->loadLayout()
|
| 11 |
+
->_setActiveMenu('saveorder/items')
|
| 12 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 13 |
+
|
| 14 |
+
return $this;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function indexAction() {
|
| 18 |
+
$this->_initAction()
|
| 19 |
+
->renderLayout();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
public function editAction() {
|
| 23 |
+
$quoteId = $this->getRequest()->getParam('id');
|
| 24 |
+
if($quoteId){
|
| 25 |
+
try {
|
| 26 |
+
$orderId = $this->convertQuoteToOrder($quoteId);
|
| 27 |
+
$this->_redirect('adminhtml/sales_order_edit/start',array('order_id' => $orderId,'from'=>'saveorder'));
|
| 28 |
+
} catch (Exception $e) {
|
| 29 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 30 |
+
}
|
| 31 |
+
} else {
|
| 32 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('saveorder')->__('Item does not exist'));
|
| 33 |
+
$this->_redirect('*/*/');
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
public function massSubmitAction() {
|
| 38 |
+
$quoteIds = $this->getRequest()->getParam('saveorder');
|
| 39 |
+
if(!is_array($quoteIds)) {
|
| 40 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
| 41 |
+
} else {
|
| 42 |
+
try {
|
| 43 |
+
$orderIds = array();
|
| 44 |
+
foreach ($quoteIds as $quoteId)
|
| 45 |
+
{
|
| 46 |
+
$orderIds[] = $this->convertQuoteToOrder($quoteId);
|
| 47 |
+
|
| 48 |
+
}
|
| 49 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 50 |
+
Mage::helper('adminhtml')->__(
|
| 51 |
+
'Total of %d record(s) were successfully converted to order', count($orderIds)
|
| 52 |
+
)
|
| 53 |
+
);
|
| 54 |
+
} catch (Exception $e) {
|
| 55 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
$this->_redirect('*/*/index');
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
public function massDeleteAction() {
|
| 63 |
+
$quoteIds = $this->getRequest()->getParam('saveorder');
|
| 64 |
+
if(!is_array($quoteIds)) {
|
| 65 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
| 66 |
+
} else {
|
| 67 |
+
try {
|
| 68 |
+
foreach ($quoteIds as $quoteId) {
|
| 69 |
+
$collection = Mage::getModel('sales/quote')
|
| 70 |
+
->getCollection()
|
| 71 |
+
->addFieldToFilter('entity_id',$quoteId)
|
| 72 |
+
->addFieldToFilter('from_admin',1)
|
| 73 |
+
->load();
|
| 74 |
+
|
| 75 |
+
if(count($collection) > 0)
|
| 76 |
+
{
|
| 77 |
+
foreach($collection as $quoteObj)
|
| 78 |
+
{
|
| 79 |
+
$quoteObj->setData('from_admin',0);
|
| 80 |
+
$quoteObj->save();
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 85 |
+
Mage::helper('adminhtml')->__(
|
| 86 |
+
'Total of %d record(s) were successfully deleted', count($quoteIds)
|
| 87 |
+
)
|
| 88 |
+
);
|
| 89 |
+
} catch (Exception $e) {
|
| 90 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
$this->_redirect('*/*/index');
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
public function exportCsvAction()
|
| 97 |
+
{
|
| 98 |
+
$fileName = 'saveorder.csv';
|
| 99 |
+
$content = $this->getLayout()->createBlock('saveorder/adminhtml_saveorder_grid')
|
| 100 |
+
->getCsv();
|
| 101 |
+
|
| 102 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
public function exportXmlAction()
|
| 106 |
+
{
|
| 107 |
+
$fileName = 'saveorder.xml';
|
| 108 |
+
$content = $this->getLayout()->createBlock('saveorder/adminhtml_saveorder_grid')
|
| 109 |
+
->getXml();
|
| 110 |
+
|
| 111 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
| 115 |
+
{
|
| 116 |
+
$response = $this->getResponse();
|
| 117 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
| 118 |
+
$response->setHeader('Pragma', 'public', true);
|
| 119 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 120 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
| 121 |
+
$response->setHeader('Last-Modified', date('r'));
|
| 122 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
| 123 |
+
$response->setHeader('Content-Length', strlen($content));
|
| 124 |
+
$response->setHeader('Content-type', $contentType);
|
| 125 |
+
$response->setBody($content);
|
| 126 |
+
$response->sendResponse();
|
| 127 |
+
die;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
public function convertQuoteToOrder($quoteId)
|
| 131 |
+
{
|
| 132 |
+
$collection = Mage::getModel('sales/quote')
|
| 133 |
+
->getCollection()
|
| 134 |
+
->addFieldToFilter('entity_id',$quoteId)
|
| 135 |
+
->addFieldToFilter('from_admin',1)
|
| 136 |
+
->load();
|
| 137 |
+
|
| 138 |
+
if(count($collection) > 0)
|
| 139 |
+
{
|
| 140 |
+
try {
|
| 141 |
+
foreach($collection as $quoteObj)
|
| 142 |
+
{
|
| 143 |
+
$items = $quoteObj->getAllItems();
|
| 144 |
+
$quoteObj->collectTotals();
|
| 145 |
+
$quoteObj->reserveOrderId();
|
| 146 |
+
$quotePaymentObj = $quoteObj->getPayment();
|
| 147 |
+
|
| 148 |
+
$quoteObj->setPayment($quotePaymentObj);
|
| 149 |
+
$convertQuoteObj = Mage::getSingleton('sales/convert_quote');
|
| 150 |
+
$orderObj = $convertQuoteObj->addressToOrder($quoteObj->getShippingAddress());
|
| 151 |
+
$orderPaymentObj = $convertQuoteObj->paymentToOrderPayment($quotePaymentObj);
|
| 152 |
+
|
| 153 |
+
$orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getBillingAddress()));
|
| 154 |
+
$orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getShippingAddress()));
|
| 155 |
+
$orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($quoteObj->getPayment()));
|
| 156 |
+
|
| 157 |
+
foreach ($items as $item) {
|
| 158 |
+
//@var $item Mage_Sales_Model_Quote_Item
|
| 159 |
+
$orderItem = $convertQuoteObj->itemToOrderItem($item);
|
| 160 |
+
if ($item->getParentItem()) {
|
| 161 |
+
$orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
|
| 162 |
+
}
|
| 163 |
+
$orderObj->addItem($orderItem);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
$orderObj->setCanShipPartiallyItem(false);
|
| 167 |
+
|
| 168 |
+
$totalDue = $orderObj->getTotalDue();
|
| 169 |
+
$orderObj->place();
|
| 170 |
+
$orderObj->save();
|
| 171 |
+
$orderId = $orderObj->getId();
|
| 172 |
+
//$orderObj->sendNewOrderEmail();
|
| 173 |
+
if($orderId){
|
| 174 |
+
$quoteObj->setData('from_admin',0);
|
| 175 |
+
$quoteObj->save();
|
| 176 |
+
}
|
| 177 |
+
return $orderId;
|
| 178 |
+
}
|
| 179 |
+
} catch (Exception $e) {
|
| 180 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
}
|
| 184 |
+
return false;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
public function confirmAction()
|
| 188 |
+
{
|
| 189 |
+
$adminQuote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
| 190 |
+
$result = array();
|
| 191 |
+
if($adminQuote->getId())
|
| 192 |
+
{
|
| 193 |
+
try {
|
| 194 |
+
$payment = $adminQuote->getPayment();
|
| 195 |
+
$paymentMethod = $payment->getMethod();
|
| 196 |
+
if(!$paymentMethod || $paymentMethod == null){
|
| 197 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('payment method is not valid.'));
|
| 198 |
+
$this->_redirect('*/*/index');
|
| 199 |
+
}
|
| 200 |
+
else{
|
| 201 |
+
$adminQuote->setData('from_admin',1);
|
| 202 |
+
$adminQuote->save();
|
| 203 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been saved.'));
|
| 204 |
+
$this->_redirect('*/*/index');
|
| 205 |
+
}
|
| 206 |
+
}catch (Mage_Core_Exception $e){
|
| 207 |
+
$message = $e->getMessage();
|
| 208 |
+
if( !empty($message) ) {
|
| 209 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
| 210 |
+
}
|
| 211 |
+
$this->_redirect('*/*/index');
|
| 212 |
+
}
|
| 213 |
+
catch (Exception $e){
|
| 214 |
+
Mage::getSingleton('adminhtml/session')->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
|
| 215 |
+
$this->_redirect('*/*/index');
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
else
|
| 219 |
+
{
|
| 220 |
+
$this->_redirect('adminhtml/sales_order/index');
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
app/code/local/Dextrous/Saveorder/controllers/Sales/Order/EditController.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/EditController.php';
|
| 3 |
+
class Dextrous_Saveorder_Sales_Order_EditController extends Mage_Adminhtml_Sales_Order_EditController
|
| 4 |
+
{
|
| 5 |
+
public function startAction()
|
| 6 |
+
{
|
| 7 |
+
$this->_getSession()->clear();
|
| 8 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
| 9 |
+
$from = $this->getRequest()->getParam('from');
|
| 10 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 11 |
+
|
| 12 |
+
try {
|
| 13 |
+
if ($order->getId()) {
|
| 14 |
+
$this->_getSession()->setUseOldShippingMethod(true);
|
| 15 |
+
$this->_getOrderCreateModel()->initFromOrder($order);
|
| 16 |
+
if($from)
|
| 17 |
+
{
|
| 18 |
+
Mage::getModel('sales/order')->load($orderId)->delete();
|
| 19 |
+
}
|
| 20 |
+
$this->_redirect('*/*');
|
| 21 |
+
}
|
| 22 |
+
else {
|
| 23 |
+
$this->_redirect('*/sales_order/');
|
| 24 |
+
}
|
| 25 |
+
} catch (Mage_Core_Exception $e) {
|
| 26 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 27 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $orderId));
|
| 28 |
+
} catch (Exception $e) {
|
| 29 |
+
Mage::getSingleton('adminhtml/session')->addException($e, $e->getMessage());
|
| 30 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $orderId));
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|
app/code/local/Dextrous/Saveorder/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<config>
|
| 2 |
+
<menu>
|
| 3 |
+
<sales translate="title" module="sales">
|
| 4 |
+
<title>Sales</title>
|
| 5 |
+
<sort_order>20</sort_order>
|
| 6 |
+
<children>
|
| 7 |
+
<saveorder translate="title" module="saveorder">
|
| 8 |
+
<title>Saved Orders*</title>
|
| 9 |
+
<action>saveorder/adminhtml_saveorder</action>
|
| 10 |
+
<sort_order>15</sort_order>
|
| 11 |
+
</saveorder>
|
| 12 |
+
</children>
|
| 13 |
+
</sales>
|
| 14 |
+
</menu>
|
| 15 |
+
<acl>
|
| 16 |
+
<resources>
|
| 17 |
+
<admin>
|
| 18 |
+
<children>
|
| 19 |
+
<sales translate="title" module="sales">
|
| 20 |
+
<title>Sales</title>
|
| 21 |
+
<children>
|
| 22 |
+
<saveorder>
|
| 23 |
+
<title>Saveorder Module</title>
|
| 24 |
+
<sort_order>10</sort_order>
|
| 25 |
+
</saveorder>
|
| 26 |
+
</children>
|
| 27 |
+
</sales>
|
| 28 |
+
</children>
|
| 29 |
+
</admin>
|
| 30 |
+
</resources>
|
| 31 |
+
</acl>
|
| 32 |
+
</config>
|
app/code/local/Dextrous/Saveorder/etc/config.xml
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<config>
|
| 4 |
+
<modules>
|
| 5 |
+
<Dextrous_Saveorder>
|
| 6 |
+
<version>0.1.0</version>
|
| 7 |
+
</Dextrous_Saveorder>
|
| 8 |
+
</modules>
|
| 9 |
+
<admin>
|
| 10 |
+
<routers>
|
| 11 |
+
<saveorder>
|
| 12 |
+
<use>admin</use>
|
| 13 |
+
<args>
|
| 14 |
+
<module>Dextrous_Saveorder</module>
|
| 15 |
+
<frontName>saveorder</frontName>
|
| 16 |
+
</args>
|
| 17 |
+
</saveorder>
|
| 18 |
+
</routers>
|
| 19 |
+
</admin>
|
| 20 |
+
<adminhtml>
|
| 21 |
+
<layout>
|
| 22 |
+
<updates>
|
| 23 |
+
<saveorder>
|
| 24 |
+
<file>saveorder.xml</file>
|
| 25 |
+
</saveorder>
|
| 26 |
+
</updates>
|
| 27 |
+
</layout>
|
| 28 |
+
</adminhtml>
|
| 29 |
+
<global>
|
| 30 |
+
<rewrite>
|
| 31 |
+
<dextrous_saveorder_sales_order_edit>
|
| 32 |
+
<from><![CDATA[#^/admin/sales_order_edit#]]></from>
|
| 33 |
+
<to>/saveorder/sales_order_edit</to>
|
| 34 |
+
</dextrous_saveorder_sales_order_edit>
|
| 35 |
+
</rewrite>
|
| 36 |
+
<blocks>
|
| 37 |
+
<adminhtml>
|
| 38 |
+
<rewrite>
|
| 39 |
+
<sales_order_create>Dextrous_Saveorder_Block_Sales_Order_Create</sales_order_create>
|
| 40 |
+
</rewrite>
|
| 41 |
+
</adminhtml>
|
| 42 |
+
</blocks>
|
| 43 |
+
<models>
|
| 44 |
+
<saveorder>
|
| 45 |
+
<class>Dextrous_Saveorder_Model</class>
|
| 46 |
+
<resourceModel>saveorder_mysql4</resourceModel>
|
| 47 |
+
</saveorder>
|
| 48 |
+
<saveorder_mysql4>
|
| 49 |
+
<class>Dextrous_Saveorder_Model_Mysql4</class>
|
| 50 |
+
<entities>
|
| 51 |
+
<saveorder>
|
| 52 |
+
<table>saveorder</table>
|
| 53 |
+
</saveorder>
|
| 54 |
+
</entities>
|
| 55 |
+
</saveorder_mysql4>
|
| 56 |
+
</models>
|
| 57 |
+
<resources>
|
| 58 |
+
<saveorder_setup>
|
| 59 |
+
<setup>
|
| 60 |
+
<module>Dextrous_Saveorder</module>
|
| 61 |
+
</setup>
|
| 62 |
+
<connection>
|
| 63 |
+
<use>core_setup</use>
|
| 64 |
+
</connection>
|
| 65 |
+
</saveorder_setup>
|
| 66 |
+
<saveorder_write>
|
| 67 |
+
<connection>
|
| 68 |
+
<use>core_write</use>
|
| 69 |
+
</connection>
|
| 70 |
+
</saveorder_write>
|
| 71 |
+
<saveorder_read>
|
| 72 |
+
<connection>
|
| 73 |
+
<use>core_read</use>
|
| 74 |
+
</connection>
|
| 75 |
+
</saveorder_read>
|
| 76 |
+
</resources>
|
| 77 |
+
<blocks>
|
| 78 |
+
<saveorder>
|
| 79 |
+
<class>Dextrous_Saveorder_Block</class>
|
| 80 |
+
</saveorder>
|
| 81 |
+
</blocks>
|
| 82 |
+
<helpers>
|
| 83 |
+
<saveorder>
|
| 84 |
+
<class>Dextrous_Saveorder_Helper</class>
|
| 85 |
+
</saveorder>
|
| 86 |
+
</helpers>
|
| 87 |
+
</global>
|
| 88 |
+
</config>
|
app/code/local/Dextrous/Saveorder/sql/saveorder_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->getConnection()
|
| 7 |
+
->addColumn($this->getTable('sales_flat_quote'), 'from_admin', array(
|
| 8 |
+
'nullable' => false,
|
| 9 |
+
'length' => 5,
|
| 10 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
| 11 |
+
'comment'=> 'Created by Admin'
|
| 12 |
+
)
|
| 13 |
+
);
|
| 14 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/saveorder.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<saveorder_adminhtml_saveorder_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="saveorder/adminhtml_saveorder" name="saveorder" />
|
| 6 |
+
</reference>
|
| 7 |
+
</saveorder_adminhtml_saveorder_index>
|
| 8 |
+
<adminhtml_sales_order_create_index>
|
| 9 |
+
<reference name="head">
|
| 10 |
+
<action method="removeItem"><type>js</type><name>mage/adminhtml/sales.js</name></action>
|
| 11 |
+
<action method="addJs"><file>saveorder/adminhtml/sales.js</file></action>
|
| 12 |
+
</reference>
|
| 13 |
+
</adminhtml_sales_order_create_index>
|
| 14 |
+
</layout>
|
app/etc/modules/Dextrous_Saveorder.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Dextrous_Saveorder>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Dextrous_Saveorder>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
js/saveorder/adminhtml/sales.js
ADDED
|
@@ -0,0 +1,1293 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
*
|
| 6 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 7 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 8 |
+
* It is also available through the world-wide-web at this URL:
|
| 9 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 10 |
+
* If you did not receive a copy of the license and are unable to
|
| 11 |
+
* obtain it through the world-wide-web, please send an email
|
| 12 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 13 |
+
*
|
| 14 |
+
* DISCLAIMER
|
| 15 |
+
*
|
| 16 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 17 |
+
* versions in the future. If you wish to customize Magento for your
|
| 18 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 19 |
+
*
|
| 20 |
+
* @category Mage
|
| 21 |
+
* @package Mage_Adminhtml
|
| 22 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 24 |
+
*/
|
| 25 |
+
var AdminOrder = new Class.create();
|
| 26 |
+
AdminOrder.prototype = {
|
| 27 |
+
initialize : function(data){
|
| 28 |
+
if(!data) data = {};
|
| 29 |
+
this.loadBaseUrl = false;
|
| 30 |
+
this.customerId = data.customer_id ? data.customer_id : false;
|
| 31 |
+
this.storeId = data.store_id ? data.store_id : false;
|
| 32 |
+
this.currencyId = false;
|
| 33 |
+
this.currencySymbol = data.currency_symbol ? data.currency_symbol : '';
|
| 34 |
+
this.addresses = data.addresses ? data.addresses : $H({});
|
| 35 |
+
this.shippingAsBilling = data.shippingAsBilling ? data.shippingAsBilling : false;
|
| 36 |
+
this.gridProducts = $H({});
|
| 37 |
+
this.gridProductsGift = $H({});
|
| 38 |
+
this.billingAddressContainer = '';
|
| 39 |
+
this.shippingAddressContainer= '';
|
| 40 |
+
this.isShippingMethodReseted = data.shipping_method_reseted ? data.shipping_method_reseted : false;
|
| 41 |
+
this.overlayData = $H({});
|
| 42 |
+
this.giftMessageDataChanged = false;
|
| 43 |
+
this.productConfigureAddFields = {};
|
| 44 |
+
this.productPriceBase = {};
|
| 45 |
+
this.collectElementsValue = true;
|
| 46 |
+
Event.observe(window, 'load', (function(){
|
| 47 |
+
this.dataArea = new OrderFormArea('data', $(this.getAreaId('data')), this);
|
| 48 |
+
this.itemsArea = Object.extend(new OrderFormArea('items', $(this.getAreaId('items')), this), {
|
| 49 |
+
addControlButton: function(button){
|
| 50 |
+
var controlButtonArea = $(this.node).select('.form-buttons')[0];
|
| 51 |
+
if (typeof controlButtonArea != 'undefined') {
|
| 52 |
+
var buttons = controlButtonArea.childElements();
|
| 53 |
+
for (var i = 0; i < buttons.length; i++) {
|
| 54 |
+
if (buttons[i].innerHTML.include(button.label)) {
|
| 55 |
+
return ;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
button.insertIn(controlButtonArea, 'top');
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
var searchButton = new ControlButton(Translator.translate('Add Products')),
|
| 64 |
+
searchAreaId = this.getAreaId('search');
|
| 65 |
+
searchButton.onClick = function() {
|
| 66 |
+
$(searchAreaId).show();
|
| 67 |
+
var el = this;
|
| 68 |
+
window.setTimeout(function () {
|
| 69 |
+
el.remove();
|
| 70 |
+
}, 10);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
this.dataArea.onLoad = this.dataArea.onLoad.wrap(function(proceed) {
|
| 74 |
+
proceed();
|
| 75 |
+
this._parent.itemsArea.setNode($(this._parent.getAreaId('items')));
|
| 76 |
+
this._parent.itemsArea.onLoad();
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) {
|
| 80 |
+
proceed();
|
| 81 |
+
if (!$(searchAreaId).visible()) {
|
| 82 |
+
this.addControlButton(searchButton);
|
| 83 |
+
}
|
| 84 |
+
});
|
| 85 |
+
this.areasLoaded();
|
| 86 |
+
this.itemsArea.onLoad();
|
| 87 |
+
}).bind(this));
|
| 88 |
+
},
|
| 89 |
+
|
| 90 |
+
areasLoaded: function(){
|
| 91 |
+
},
|
| 92 |
+
|
| 93 |
+
itemsLoaded: function(){
|
| 94 |
+
},
|
| 95 |
+
|
| 96 |
+
dataLoaded: function(){
|
| 97 |
+
this.dataShow();
|
| 98 |
+
},
|
| 99 |
+
|
| 100 |
+
setLoadBaseUrl : function(url){
|
| 101 |
+
this.loadBaseUrl = url;
|
| 102 |
+
},
|
| 103 |
+
|
| 104 |
+
setAddresses : function(addresses){
|
| 105 |
+
this.addresses = addresses;
|
| 106 |
+
},
|
| 107 |
+
|
| 108 |
+
setCustomerId : function(id){
|
| 109 |
+
this.customerId = id;
|
| 110 |
+
this.loadArea('header', true);
|
| 111 |
+
$(this.getAreaId('header')).callback = 'setCustomerAfter';
|
| 112 |
+
$('back_order_top_button').hide();
|
| 113 |
+
$('reset_order_top_button').show();
|
| 114 |
+
},
|
| 115 |
+
|
| 116 |
+
setCustomerAfter : function () {
|
| 117 |
+
this.customerSelectorHide();
|
| 118 |
+
if (this.storeId) {
|
| 119 |
+
$(this.getAreaId('data')).callback = 'dataLoaded';
|
| 120 |
+
this.loadArea(['data'], true);
|
| 121 |
+
}
|
| 122 |
+
else {
|
| 123 |
+
this.storeSelectorShow();
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
|
| 127 |
+
setStoreId : function(id){
|
| 128 |
+
this.storeId = id;
|
| 129 |
+
this.storeSelectorHide();
|
| 130 |
+
this.sidebarShow();
|
| 131 |
+
//this.loadArea(['header', 'sidebar','data'], true);
|
| 132 |
+
this.dataShow();
|
| 133 |
+
this.loadArea(['header', 'data'], true);
|
| 134 |
+
},
|
| 135 |
+
|
| 136 |
+
setCurrencyId : function(id){
|
| 137 |
+
this.currencyId = id;
|
| 138 |
+
//this.loadArea(['sidebar', 'data'], true);
|
| 139 |
+
this.loadArea(['data'], true);
|
| 140 |
+
},
|
| 141 |
+
|
| 142 |
+
setCurrencySymbol : function(symbol){
|
| 143 |
+
this.currencySymbol = symbol;
|
| 144 |
+
},
|
| 145 |
+
|
| 146 |
+
selectAddress : function(el, container){
|
| 147 |
+
id = el.value;
|
| 148 |
+
if (id.length == 0) {
|
| 149 |
+
id = '0';
|
| 150 |
+
}
|
| 151 |
+
if(this.addresses[id]){
|
| 152 |
+
this.fillAddressFields(container, this.addresses[id]);
|
| 153 |
+
}
|
| 154 |
+
else{
|
| 155 |
+
this.fillAddressFields(container, {});
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
var data = this.serializeData(container);
|
| 159 |
+
data[el.name] = id;
|
| 160 |
+
if(this.isShippingField(container) && !this.isShippingMethodReseted){
|
| 161 |
+
this.resetShippingMethod(data);
|
| 162 |
+
}
|
| 163 |
+
else{
|
| 164 |
+
this.saveData(data);
|
| 165 |
+
}
|
| 166 |
+
},
|
| 167 |
+
|
| 168 |
+
isShippingField : function(fieldId){
|
| 169 |
+
if(this.shippingAsBilling){
|
| 170 |
+
return fieldId.include('billing');
|
| 171 |
+
}
|
| 172 |
+
return fieldId.include('shipping');
|
| 173 |
+
},
|
| 174 |
+
|
| 175 |
+
isBillingField : function(fieldId){
|
| 176 |
+
return fieldId.include('billing');
|
| 177 |
+
},
|
| 178 |
+
|
| 179 |
+
bindAddressFields : function(container) {
|
| 180 |
+
var fields = $(container).select('input', 'select', 'textarea');
|
| 181 |
+
for(var i=0;i<fields.length;i++){
|
| 182 |
+
Event.observe(fields[i], 'change', this.changeAddressField.bind(this));
|
| 183 |
+
}
|
| 184 |
+
},
|
| 185 |
+
|
| 186 |
+
changeAddressField : function(event){
|
| 187 |
+
var field = Event.element(event);
|
| 188 |
+
var re = /[^\[]*\[([^\]]*)_address\]\[([^\]]*)\](\[(\d)\])?/;
|
| 189 |
+
var matchRes = field.name.match(re);
|
| 190 |
+
|
| 191 |
+
if (!matchRes) {
|
| 192 |
+
return;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
var type = matchRes[1];
|
| 196 |
+
var name = matchRes[2];
|
| 197 |
+
var data;
|
| 198 |
+
|
| 199 |
+
if(this.isBillingField(field.id)){
|
| 200 |
+
data = this.serializeData(this.billingAddressContainer)
|
| 201 |
+
}
|
| 202 |
+
else{
|
| 203 |
+
data = this.serializeData(this.shippingAddressContainer)
|
| 204 |
+
}
|
| 205 |
+
data = data.toObject();
|
| 206 |
+
|
| 207 |
+
if( (type == 'billing' && this.shippingAsBilling && !this.isShippingMethodReseted)
|
| 208 |
+
|| (type == 'shipping' && !this.shippingAsBilling && !this.isShippingMethodReseted) ) {
|
| 209 |
+
data['reset_shipping'] = true;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
data['order['+type+'_address][customer_address_id]'] = $('order-'+type+'_address_customer_address_id').value;
|
| 213 |
+
|
| 214 |
+
if (type == 'billing' && this.shippingAsBilling) {
|
| 215 |
+
this.copyDataFromBillingToShipping(field);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
if (data['reset_shipping']) {
|
| 219 |
+
this.resetShippingMethod(data);
|
| 220 |
+
} else {
|
| 221 |
+
this.saveData(data);
|
| 222 |
+
if (!this.isShippingMethodReseted && (name == 'country_id' || name == 'customer_address_id')) {
|
| 223 |
+
this.loadArea(['shipping_method', 'billing_method', 'totals', 'items'], true, data);
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
},
|
| 227 |
+
|
| 228 |
+
copyDataFromBillingToShipping : function(field) {
|
| 229 |
+
var shippingId = $(field).identify().replace('-billing_', '-shipping_');
|
| 230 |
+
var inputField = $(shippingId);
|
| 231 |
+
if (inputField) {
|
| 232 |
+
inputField.setValue($(field).getValue());
|
| 233 |
+
if (inputField.changeUpdater) {
|
| 234 |
+
inputField.changeUpdater();
|
| 235 |
+
}
|
| 236 |
+
$(this.shippingAddressContainer).select('select').each(function(el){
|
| 237 |
+
el.disable();
|
| 238 |
+
});
|
| 239 |
+
}
|
| 240 |
+
},
|
| 241 |
+
|
| 242 |
+
fillAddressFields : function(container, data){
|
| 243 |
+
var regionIdElem = false;
|
| 244 |
+
var regionIdElemValue = false;
|
| 245 |
+
|
| 246 |
+
var fields = $(container).select('input', 'select', 'textarea');
|
| 247 |
+
var re = /[^\[]*\[[^\]]*\]\[([^\]]*)\](\[(\d)\])?/;
|
| 248 |
+
for(var i=0;i<fields.length;i++){
|
| 249 |
+
// skip input type file @Security error code: 1000
|
| 250 |
+
if (fields[i].tagName.toLowerCase() == 'input' && fields[i].type.toLowerCase() == 'file') {
|
| 251 |
+
continue;
|
| 252 |
+
}
|
| 253 |
+
var matchRes = fields[i].name.match(re);
|
| 254 |
+
if (matchRes === null) {
|
| 255 |
+
continue;
|
| 256 |
+
}
|
| 257 |
+
var name = matchRes[1];
|
| 258 |
+
var index = matchRes[3];
|
| 259 |
+
|
| 260 |
+
if (index){
|
| 261 |
+
// multiply line
|
| 262 |
+
if (data[name]){
|
| 263 |
+
var values = data[name].split("\n");
|
| 264 |
+
fields[i].value = values[index] ? values[index] : '';
|
| 265 |
+
} else {
|
| 266 |
+
fields[i].value = '';
|
| 267 |
+
}
|
| 268 |
+
} else if (fields[i].tagName.toLowerCase() == 'select' && fields[i].multiple) {
|
| 269 |
+
// multiselect
|
| 270 |
+
if (data[name]) {
|
| 271 |
+
values = [''];
|
| 272 |
+
if (Object.isString(data[name])) {
|
| 273 |
+
values = data[name].split(',');
|
| 274 |
+
} else if (Object.isArray(data[name])) {
|
| 275 |
+
values = data[name];
|
| 276 |
+
}
|
| 277 |
+
fields[i].setValue(values);
|
| 278 |
+
}
|
| 279 |
+
} else {
|
| 280 |
+
fields[i].setValue(data[name] ? data[name] : '');
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
if (fields[i].changeUpdater) fields[i].changeUpdater();
|
| 284 |
+
if (name == 'region' && data['region_id'] && !data['region']){
|
| 285 |
+
fields[i].value = data['region_id'];
|
| 286 |
+
}
|
| 287 |
+
}
|
| 288 |
+
},
|
| 289 |
+
|
| 290 |
+
disableShippingAddress : function(flag) {
|
| 291 |
+
this.shippingAsBilling = flag;
|
| 292 |
+
if ($('order-shipping_address_customer_address_id')) {
|
| 293 |
+
$('order-shipping_address_customer_address_id').disabled = flag;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
if ($(this.shippingAddressContainer)) {
|
| 297 |
+
var dataFields = $(this.shippingAddressContainer).select('input', 'select', 'textarea');
|
| 298 |
+
for (var i = 0; i < dataFields.length; i++) {
|
| 299 |
+
dataFields[i].disabled = flag;
|
| 300 |
+
}
|
| 301 |
+
var buttons = $(this.shippingAddressContainer).select('button');
|
| 302 |
+
// Add corresponding class to buttons while disabling them
|
| 303 |
+
for (i = 0; i < buttons.length; i++) {
|
| 304 |
+
buttons[i].disabled = flag;
|
| 305 |
+
if (flag) {
|
| 306 |
+
buttons[i].addClassName('disabled');
|
| 307 |
+
} else {
|
| 308 |
+
buttons[i].removeClassName('disabled');
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
},
|
| 313 |
+
|
| 314 |
+
turnOffShippingFields : function() {
|
| 315 |
+
if ($(this.shippingAddressContainer)) {
|
| 316 |
+
var dataFields = $(this.shippingAddressContainer).select('input', 'select', 'textarea', 'button');
|
| 317 |
+
for (var i = 0; i < dataFields.length; i++) {
|
| 318 |
+
dataFields[i].removeAttribute('name');
|
| 319 |
+
dataFields[i].removeAttribute('id');
|
| 320 |
+
dataFields[i].readOnly = true;
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
},
|
| 324 |
+
|
| 325 |
+
setShippingAsBilling : function(flag){
|
| 326 |
+
this.disableShippingAddress(flag);
|
| 327 |
+
if(flag){
|
| 328 |
+
var data = this.serializeData(this.billingAddressContainer);
|
| 329 |
+
}
|
| 330 |
+
else{
|
| 331 |
+
var data = this.serializeData(this.shippingAddressContainer);
|
| 332 |
+
}
|
| 333 |
+
data = data.toObject();
|
| 334 |
+
data['shipping_as_billing'] = flag ? 1 : 0;
|
| 335 |
+
data['reset_shipping'] = 1;
|
| 336 |
+
this.loadArea(['shipping_method', 'billing_method', 'shipping_address', 'totals', 'giftmessage'], true, data);
|
| 337 |
+
},
|
| 338 |
+
|
| 339 |
+
resetShippingMethod : function(data){
|
| 340 |
+
data['reset_shipping'] = 1;
|
| 341 |
+
this.isShippingMethodReseted = true;
|
| 342 |
+
this.loadArea(['shipping_method', 'billing_method', 'totals', 'giftmessage', 'items'], true, data);
|
| 343 |
+
},
|
| 344 |
+
|
| 345 |
+
loadShippingRates : function(){
|
| 346 |
+
this.isShippingMethodReseted = false;
|
| 347 |
+
this.loadArea(['shipping_method', 'totals'], true, {collect_shipping_rates: 1});
|
| 348 |
+
},
|
| 349 |
+
|
| 350 |
+
setShippingMethod : function(method){
|
| 351 |
+
var data = {};
|
| 352 |
+
data['order[shipping_method]'] = method;
|
| 353 |
+
this.loadArea(['shipping_method', 'totals', 'billing_method'], true, data);
|
| 354 |
+
},
|
| 355 |
+
|
| 356 |
+
switchPaymentMethod : function(method){
|
| 357 |
+
this.setPaymentMethod(method);
|
| 358 |
+
var data = {};
|
| 359 |
+
data['order[payment_method]'] = method;
|
| 360 |
+
this.loadArea(['card_validation'], true, data);
|
| 361 |
+
},
|
| 362 |
+
|
| 363 |
+
setPaymentMethod : function(method){
|
| 364 |
+
if (this.paymentMethod && $('payment_form_'+this.paymentMethod)) {
|
| 365 |
+
var form = 'payment_form_'+this.paymentMethod;
|
| 366 |
+
[form + '_before', form, form + '_after'].each(function(el) {
|
| 367 |
+
var block = $(el);
|
| 368 |
+
if (block) {
|
| 369 |
+
block.hide();
|
| 370 |
+
block.select('input', 'select', 'textarea').each(function(field) {
|
| 371 |
+
field.disabled = true;
|
| 372 |
+
});
|
| 373 |
+
}
|
| 374 |
+
});
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
if(!this.paymentMethod || method){
|
| 378 |
+
$('order-billing_method_form').select('input', 'select', 'textarea').each(function(elem){
|
| 379 |
+
if(elem.type != 'radio') elem.disabled = true;
|
| 380 |
+
})
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
if ($('payment_form_'+method)){
|
| 384 |
+
this.paymentMethod = method;
|
| 385 |
+
var form = 'payment_form_'+method;
|
| 386 |
+
[form + '_before', form, form + '_after'].each(function(el) {
|
| 387 |
+
var block = $(el);
|
| 388 |
+
if (block) {
|
| 389 |
+
block.show();
|
| 390 |
+
block.select('input', 'select', 'textarea').each(function(field) {
|
| 391 |
+
field.disabled = false;
|
| 392 |
+
if (!el.include('_before') && !el.include('_after') && !field.bindChange) {
|
| 393 |
+
field.bindChange = true;
|
| 394 |
+
field.paymentContainer = form; /** @deprecated after 1.4.0.0-rc1 */
|
| 395 |
+
field.method = method;
|
| 396 |
+
field.observe('change', this.changePaymentData.bind(this))
|
| 397 |
+
}
|
| 398 |
+
},this);
|
| 399 |
+
}
|
| 400 |
+
},this);
|
| 401 |
+
}
|
| 402 |
+
},
|
| 403 |
+
|
| 404 |
+
changePaymentData : function(event){
|
| 405 |
+
var elem = Event.element(event);
|
| 406 |
+
if(elem && elem.method){
|
| 407 |
+
var data = this.getPaymentData(elem.method);
|
| 408 |
+
if (data) {
|
| 409 |
+
this.loadArea(['card_validation'], true, data);
|
| 410 |
+
} else {
|
| 411 |
+
return;
|
| 412 |
+
}
|
| 413 |
+
}
|
| 414 |
+
},
|
| 415 |
+
|
| 416 |
+
getPaymentData : function(currentMethod){
|
| 417 |
+
if (typeof(currentMethod) == 'undefined') {
|
| 418 |
+
if (this.paymentMethod) {
|
| 419 |
+
currentMethod = this.paymentMethod;
|
| 420 |
+
} else {
|
| 421 |
+
return false;
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
var data = {};
|
| 425 |
+
var fields = $('payment_form_' + currentMethod).select('input', 'select');
|
| 426 |
+
for(var i=0;i<fields.length;i++){
|
| 427 |
+
data[fields[i].name] = fields[i].getValue();
|
| 428 |
+
}
|
| 429 |
+
if ((typeof data['payment[cc_type]']) != 'undefined' && (!data['payment[cc_type]'] || !data['payment[cc_number]'])) {
|
| 430 |
+
return false;
|
| 431 |
+
}
|
| 432 |
+
return data;
|
| 433 |
+
},
|
| 434 |
+
|
| 435 |
+
applyCoupon : function(code){
|
| 436 |
+
this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {'order[coupon][code]':code, reset_shipping: true});
|
| 437 |
+
},
|
| 438 |
+
|
| 439 |
+
addProduct : function(id){
|
| 440 |
+
this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {add_product:id, reset_shipping: true});
|
| 441 |
+
},
|
| 442 |
+
|
| 443 |
+
removeQuoteItem : function(id){
|
| 444 |
+
this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true,
|
| 445 |
+
{remove_item:id, from:'quote',reset_shipping: true});
|
| 446 |
+
},
|
| 447 |
+
|
| 448 |
+
moveQuoteItem : function(id, to){
|
| 449 |
+
this.loadArea(['sidebar_'+to, 'items', 'shipping_method', 'totals', 'billing_method'], this.getAreaId('items'),
|
| 450 |
+
{move_item:id, to:to, reset_shipping: true});
|
| 451 |
+
},
|
| 452 |
+
|
| 453 |
+
productGridShow : function(buttonElement){
|
| 454 |
+
this.productGridShowButton = buttonElement;
|
| 455 |
+
Element.hide(buttonElement);
|
| 456 |
+
this.showArea('search');
|
| 457 |
+
},
|
| 458 |
+
|
| 459 |
+
productGridRowInit : function(grid, row){
|
| 460 |
+
var checkbox = $(row).select('.checkbox')[0];
|
| 461 |
+
var inputs = $(row).select('.input-text');
|
| 462 |
+
if (checkbox && inputs.length > 0) {
|
| 463 |
+
checkbox.inputElements = inputs;
|
| 464 |
+
for (var i = 0; i < inputs.length; i++) {
|
| 465 |
+
var input = inputs[i];
|
| 466 |
+
input.checkboxElement = checkbox;
|
| 467 |
+
|
| 468 |
+
var product = this.gridProducts.get(checkbox.value);
|
| 469 |
+
if (product) {
|
| 470 |
+
var defaultValue = product[input.name];
|
| 471 |
+
if (defaultValue) {
|
| 472 |
+
if (input.name == 'giftmessage') {
|
| 473 |
+
input.checked = true;
|
| 474 |
+
} else {
|
| 475 |
+
input.value = defaultValue;
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
input.disabled = !checkbox.checked || input.hasClassName('input-inactive');
|
| 481 |
+
|
| 482 |
+
Event.observe(input,'keyup', this.productGridRowInputChange.bind(this));
|
| 483 |
+
Event.observe(input,'change',this.productGridRowInputChange.bind(this));
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
},
|
| 487 |
+
|
| 488 |
+
productGridRowInputChange : function(event){
|
| 489 |
+
var element = Event.element(event);
|
| 490 |
+
if (element && element.checkboxElement && element.checkboxElement.checked){
|
| 491 |
+
if (element.name!='giftmessage' || element.checked) {
|
| 492 |
+
this.gridProducts.get(element.checkboxElement.value)[element.name] = element.value;
|
| 493 |
+
} else if (element.name=='giftmessage' && this.gridProducts.get(element.checkboxElement.value)[element.name]) {
|
| 494 |
+
delete(this.gridProducts.get(element.checkboxElement.value)[element.name]);
|
| 495 |
+
}
|
| 496 |
+
}
|
| 497 |
+
},
|
| 498 |
+
|
| 499 |
+
productGridRowClick : function(grid, event){
|
| 500 |
+
var trElement = Event.findElement(event, 'tr');
|
| 501 |
+
var qtyElement = trElement.select('input[name="qty"]')[0];
|
| 502 |
+
var eventElement = Event.element(event);
|
| 503 |
+
var isInputCheckbox = eventElement.tagName == 'INPUT' && eventElement.type == 'checkbox';
|
| 504 |
+
var isInputQty = eventElement.tagName == 'INPUT' && eventElement.name == 'qty';
|
| 505 |
+
if (trElement && !isInputQty) {
|
| 506 |
+
var checkbox = Element.select(trElement, 'input[type="checkbox"]')[0];
|
| 507 |
+
var confLink = Element.select(trElement, 'a')[0];
|
| 508 |
+
var priceColl = Element.select(trElement, '.price')[0];
|
| 509 |
+
if (checkbox) {
|
| 510 |
+
// processing non composite product
|
| 511 |
+
if (confLink.readAttribute('disabled')) {
|
| 512 |
+
var checked = isInputCheckbox ? checkbox.checked : !checkbox.checked;
|
| 513 |
+
grid.setCheckboxChecked(checkbox, checked);
|
| 514 |
+
// processing composite product
|
| 515 |
+
} else if (isInputCheckbox && !checkbox.checked) {
|
| 516 |
+
grid.setCheckboxChecked(checkbox, false);
|
| 517 |
+
// processing composite product
|
| 518 |
+
} else if (!isInputCheckbox || (isInputCheckbox && checkbox.checked)) {
|
| 519 |
+
var listType = confLink.readAttribute('list_type');
|
| 520 |
+
var productId = confLink.readAttribute('product_id');
|
| 521 |
+
if (typeof this.productPriceBase[productId] == 'undefined') {
|
| 522 |
+
var priceBase = priceColl.innerHTML.match(/.*?([\d,]+\.?\d*)/);
|
| 523 |
+
if (!priceBase) {
|
| 524 |
+
this.productPriceBase[productId] = 0;
|
| 525 |
+
} else {
|
| 526 |
+
this.productPriceBase[productId] = parseFloat(priceBase[1].replace(/,/g,''));
|
| 527 |
+
}
|
| 528 |
+
}
|
| 529 |
+
productConfigure.setConfirmCallback(listType, function() {
|
| 530 |
+
// sync qty of popup and qty of grid
|
| 531 |
+
var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement();
|
| 532 |
+
if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) {
|
| 533 |
+
qtyElement.value = confirmedCurrentQty.value;
|
| 534 |
+
}
|
| 535 |
+
// calc and set product price
|
| 536 |
+
var productPrice = parseFloat(this._calcProductPrice() + this.productPriceBase[productId]);
|
| 537 |
+
priceColl.innerHTML = this.currencySymbol + productPrice.toFixed(2);
|
| 538 |
+
// and set checkbox checked
|
| 539 |
+
grid.setCheckboxChecked(checkbox, true);
|
| 540 |
+
}.bind(this));
|
| 541 |
+
productConfigure.setCancelCallback(listType, function() {
|
| 542 |
+
if (!$(productConfigure.confirmedCurrentId) || !$(productConfigure.confirmedCurrentId).innerHTML) {
|
| 543 |
+
grid.setCheckboxChecked(checkbox, false);
|
| 544 |
+
}
|
| 545 |
+
});
|
| 546 |
+
productConfigure.setShowWindowCallback(listType, function() {
|
| 547 |
+
// sync qty of grid and qty of popup
|
| 548 |
+
var formCurrentQty = productConfigure.getCurrentFormQtyElement();
|
| 549 |
+
if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) {
|
| 550 |
+
formCurrentQty.value = qtyElement.value;
|
| 551 |
+
}
|
| 552 |
+
}.bind(this));
|
| 553 |
+
productConfigure.showItemConfiguration(listType, productId);
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
}
|
| 557 |
+
},
|
| 558 |
+
|
| 559 |
+
/**
|
| 560 |
+
* Calc product price through its options
|
| 561 |
+
*/
|
| 562 |
+
_calcProductPrice: function () {
|
| 563 |
+
var productPrice = 0;
|
| 564 |
+
var getPriceFields = function (elms) {
|
| 565 |
+
var productPrice = 0;
|
| 566 |
+
var getPrice = function (elm) {
|
| 567 |
+
var optQty = 1;
|
| 568 |
+
if (elm.hasAttribute('qtyId')) {
|
| 569 |
+
if (!$(elm.getAttribute('qtyId')).value) {
|
| 570 |
+
return 0;
|
| 571 |
+
} else {
|
| 572 |
+
optQty = parseFloat($(elm.getAttribute('qtyId')).value);
|
| 573 |
+
}
|
| 574 |
+
}
|
| 575 |
+
if (elm.hasAttribute('price') && !elm.disabled) {
|
| 576 |
+
return parseFloat(elm.readAttribute('price')) * optQty;
|
| 577 |
+
}
|
| 578 |
+
return 0;
|
| 579 |
+
};
|
| 580 |
+
for(var i = 0; i < elms.length; i++) {
|
| 581 |
+
if (elms[i].type == 'select-one' || elms[i].type == 'select-multiple') {
|
| 582 |
+
for(var ii = 0; ii < elms[i].options.length; ii++) {
|
| 583 |
+
if (elms[i].options[ii].selected) {
|
| 584 |
+
productPrice += getPrice(elms[i].options[ii]);
|
| 585 |
+
}
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
else if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked)
|
| 589 |
+
|| ((elms[i].type == 'file' || elms[i].type == 'text' || elms[i].type == 'textarea' || elms[i].type == 'hidden')
|
| 590 |
+
&& Form.Element.getValue(elms[i]))
|
| 591 |
+
) {
|
| 592 |
+
productPrice += getPrice(elms[i]);
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
return productPrice;
|
| 596 |
+
}.bind(this);
|
| 597 |
+
productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('input'));
|
| 598 |
+
productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('select'));
|
| 599 |
+
productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('textarea'));
|
| 600 |
+
return productPrice;
|
| 601 |
+
},
|
| 602 |
+
|
| 603 |
+
productGridCheckboxCheck : function(grid, element, checked){
|
| 604 |
+
if (checked) {
|
| 605 |
+
if(element.inputElements) {
|
| 606 |
+
this.gridProducts.set(element.value, {});
|
| 607 |
+
var product = this.gridProducts.get(element.value);
|
| 608 |
+
for (var i = 0; i < element.inputElements.length; i++) {
|
| 609 |
+
var input = element.inputElements[i];
|
| 610 |
+
if (!input.hasClassName('input-inactive')) {
|
| 611 |
+
input.disabled = false;
|
| 612 |
+
if (input.name == 'qty' && !input.value) {
|
| 613 |
+
input.value = 1;
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
if (input.checked || input.name != 'giftmessage') {
|
| 618 |
+
product[input.name] = input.value;
|
| 619 |
+
} else if (product[input.name]) {
|
| 620 |
+
delete(product[input.name]);
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
} else {
|
| 625 |
+
if(element.inputElements){
|
| 626 |
+
for(var i = 0; i < element.inputElements.length; i++) {
|
| 627 |
+
element.inputElements[i].disabled = true;
|
| 628 |
+
}
|
| 629 |
+
}
|
| 630 |
+
this.gridProducts.unset(element.value);
|
| 631 |
+
}
|
| 632 |
+
grid.reloadParams = {'products[]':this.gridProducts.keys()};
|
| 633 |
+
},
|
| 634 |
+
|
| 635 |
+
/**
|
| 636 |
+
* Submit configured products to quote
|
| 637 |
+
*/
|
| 638 |
+
productGridAddSelected : function(){
|
| 639 |
+
if(this.productGridShowButton) Element.show(this.productGridShowButton);
|
| 640 |
+
var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage','billing_method'];
|
| 641 |
+
// prepare additional fields and filtered items of products
|
| 642 |
+
var fieldsPrepare = {};
|
| 643 |
+
var itemsFilter = [];
|
| 644 |
+
var products = this.gridProducts.toObject();
|
| 645 |
+
for (var productId in products) {
|
| 646 |
+
itemsFilter.push(productId);
|
| 647 |
+
var paramKey = 'item['+productId+']';
|
| 648 |
+
for (var productParamKey in products[productId]) {
|
| 649 |
+
paramKey += '['+productParamKey+']';
|
| 650 |
+
fieldsPrepare[paramKey] = products[productId][productParamKey];
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
this.productConfigureSubmit('product_to_add', area, fieldsPrepare, itemsFilter);
|
| 654 |
+
productConfigure.clean('quote_items');
|
| 655 |
+
this.hideArea('search');
|
| 656 |
+
this.gridProducts = $H({});
|
| 657 |
+
},
|
| 658 |
+
|
| 659 |
+
selectCustomer : function(grid, event){
|
| 660 |
+
var element = Event.findElement(event, 'tr');
|
| 661 |
+
if (element.title){
|
| 662 |
+
this.setCustomerId(element.title);
|
| 663 |
+
}
|
| 664 |
+
},
|
| 665 |
+
|
| 666 |
+
customerSelectorHide : function(){
|
| 667 |
+
this.hideArea('customer-selector');
|
| 668 |
+
},
|
| 669 |
+
|
| 670 |
+
customerSelectorShow : function(){
|
| 671 |
+
this.showArea('customer-selector');
|
| 672 |
+
},
|
| 673 |
+
|
| 674 |
+
storeSelectorHide : function(){
|
| 675 |
+
this.hideArea('store-selector');
|
| 676 |
+
},
|
| 677 |
+
|
| 678 |
+
storeSelectorShow : function(){
|
| 679 |
+
this.showArea('store-selector');
|
| 680 |
+
},
|
| 681 |
+
|
| 682 |
+
dataHide : function(){
|
| 683 |
+
this.hideArea('data');
|
| 684 |
+
},
|
| 685 |
+
|
| 686 |
+
dataShow : function(){
|
| 687 |
+
if ($('submit_order_top_button')) {
|
| 688 |
+
$('submit_order_top_button').show();
|
| 689 |
+
$('save_order_top_button').show();
|
| 690 |
+
}
|
| 691 |
+
this.showArea('data');
|
| 692 |
+
},
|
| 693 |
+
|
| 694 |
+
clearShoppingCart : function(confirmMessage){
|
| 695 |
+
if (confirm(confirmMessage)) {
|
| 696 |
+
this.collectElementsValue = false;
|
| 697 |
+
order.sidebarApplyChanges({'sidebar[empty_customer_cart]': 1});
|
| 698 |
+
}
|
| 699 |
+
},
|
| 700 |
+
|
| 701 |
+
sidebarApplyChanges : function(auxiliaryParams) {
|
| 702 |
+
if ($(this.getAreaId('sidebar'))) {
|
| 703 |
+
var data = {};
|
| 704 |
+
if (this.collectElementsValue) {
|
| 705 |
+
var elems = $(this.getAreaId('sidebar')).select('input');
|
| 706 |
+
for (var i=0; i < elems.length; i++) {
|
| 707 |
+
if (elems[i].getValue()) {
|
| 708 |
+
data[elems[i].name] = elems[i].getValue();
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
}
|
| 712 |
+
if (auxiliaryParams instanceof Object) {
|
| 713 |
+
for (var paramName in auxiliaryParams) {
|
| 714 |
+
data[paramName] = String(auxiliaryParams[paramName]);
|
| 715 |
+
}
|
| 716 |
+
}
|
| 717 |
+
data.reset_shipping = true;
|
| 718 |
+
this.loadArea(['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true, data);
|
| 719 |
+
}
|
| 720 |
+
},
|
| 721 |
+
|
| 722 |
+
sidebarHide : function(){
|
| 723 |
+
if(this.storeId === false && $('page:left') && $('page:container')){
|
| 724 |
+
$('page:left').hide();
|
| 725 |
+
$('page:container').removeClassName('container');
|
| 726 |
+
$('page:container').addClassName('container-collapsed');
|
| 727 |
+
}
|
| 728 |
+
},
|
| 729 |
+
|
| 730 |
+
sidebarShow : function(){
|
| 731 |
+
if($('page:left') && $('page:container')){
|
| 732 |
+
$('page:left').show();
|
| 733 |
+
$('page:container').removeClassName('container-collapsed');
|
| 734 |
+
$('page:container').addClassName('container');
|
| 735 |
+
}
|
| 736 |
+
},
|
| 737 |
+
|
| 738 |
+
/**
|
| 739 |
+
* Show configuration of product and add handlers on submit form
|
| 740 |
+
*
|
| 741 |
+
* @param productId
|
| 742 |
+
*/
|
| 743 |
+
sidebarConfigureProduct: function (listType, productId, itemId) {
|
| 744 |
+
// create additional fields
|
| 745 |
+
var params = {};
|
| 746 |
+
params.reset_shipping = true;
|
| 747 |
+
params.add_product = productId;
|
| 748 |
+
this.prepareParams(params);
|
| 749 |
+
for (var i in params) {
|
| 750 |
+
if (params[i] === null) {
|
| 751 |
+
unset(params[i]);
|
| 752 |
+
} else if (typeof(params[i]) == 'boolean') {
|
| 753 |
+
params[i] = params[i] ? 1 : 0;
|
| 754 |
+
}
|
| 755 |
+
}
|
| 756 |
+
var fields = [];
|
| 757 |
+
for (var name in params) {
|
| 758 |
+
fields.push(new Element('input', {type: 'hidden', name: name, value: params[name]}));
|
| 759 |
+
}
|
| 760 |
+
// add additional fields before triggered submit
|
| 761 |
+
productConfigure.setBeforeSubmitCallback(listType, function() {
|
| 762 |
+
productConfigure.addFields(fields);
|
| 763 |
+
}.bind(this));
|
| 764 |
+
// response handler
|
| 765 |
+
productConfigure.setOnLoadIFrameCallback(listType, function(response) {
|
| 766 |
+
if (!response.ok) {
|
| 767 |
+
return;
|
| 768 |
+
}
|
| 769 |
+
this.loadArea(['items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true);
|
| 770 |
+
}.bind(this));
|
| 771 |
+
// show item configuration
|
| 772 |
+
itemId = itemId ? itemId : productId;
|
| 773 |
+
productConfigure.showItemConfiguration(listType, itemId);
|
| 774 |
+
return false;
|
| 775 |
+
},
|
| 776 |
+
|
| 777 |
+
removeSidebarItem : function(id, from){
|
| 778 |
+
this.loadArea(['sidebar_'+from], 'sidebar_data_'+from, {remove_item:id, from:from});
|
| 779 |
+
},
|
| 780 |
+
|
| 781 |
+
itemsUpdate : function(){
|
| 782 |
+
var area = ['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'];
|
| 783 |
+
// prepare additional fields
|
| 784 |
+
var fieldsPrepare = {update_items: 1};
|
| 785 |
+
var info = $('order-items_grid').select('input', 'select', 'textarea');
|
| 786 |
+
for(var i=0; i<info.length; i++){
|
| 787 |
+
if(!info[i].disabled && (info[i].type != 'checkbox' || info[i].checked)) {
|
| 788 |
+
fieldsPrepare[info[i].name] = info[i].getValue();
|
| 789 |
+
}
|
| 790 |
+
}
|
| 791 |
+
fieldsPrepare = Object.extend(fieldsPrepare, this.productConfigureAddFields);
|
| 792 |
+
this.productConfigureSubmit('quote_items', area, fieldsPrepare);
|
| 793 |
+
this.orderItemChanged = false;
|
| 794 |
+
},
|
| 795 |
+
|
| 796 |
+
itemsOnchangeBind : function(){
|
| 797 |
+
var elems = $('order-items_grid').select('input', 'select', 'textarea');
|
| 798 |
+
for(var i=0; i<elems.length; i++){
|
| 799 |
+
if(!elems[i].bindOnchange){
|
| 800 |
+
elems[i].bindOnchange = true;
|
| 801 |
+
elems[i].observe('change', this.itemChange.bind(this))
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
},
|
| 805 |
+
|
| 806 |
+
itemChange : function(event){
|
| 807 |
+
this.giftmessageOnItemChange(event);
|
| 808 |
+
this.orderItemChanged = true;
|
| 809 |
+
},
|
| 810 |
+
|
| 811 |
+
/**
|
| 812 |
+
* Submit batch of configured products
|
| 813 |
+
*
|
| 814 |
+
* @param listType
|
| 815 |
+
* @param area
|
| 816 |
+
* @param fieldsPrepare
|
| 817 |
+
* @param itemsFilter
|
| 818 |
+
*/
|
| 819 |
+
productConfigureSubmit : function(listType, area, fieldsPrepare, itemsFilter) {
|
| 820 |
+
// prepare loading areas and build url
|
| 821 |
+
area = this.prepareArea(area);
|
| 822 |
+
this.loadingAreas = area;
|
| 823 |
+
var url = this.loadBaseUrl + 'block/' + area + '?isAjax=true';
|
| 824 |
+
|
| 825 |
+
// prepare additional fields
|
| 826 |
+
fieldsPrepare = this.prepareParams(fieldsPrepare);
|
| 827 |
+
fieldsPrepare.reset_shipping = 1;
|
| 828 |
+
fieldsPrepare.json = 1;
|
| 829 |
+
|
| 830 |
+
// create fields
|
| 831 |
+
var fields = [];
|
| 832 |
+
for (var name in fieldsPrepare) {
|
| 833 |
+
fields.push(new Element('input', {type: 'hidden', name: name, value: fieldsPrepare[name]}));
|
| 834 |
+
}
|
| 835 |
+
productConfigure.addFields(fields);
|
| 836 |
+
|
| 837 |
+
// filter items
|
| 838 |
+
if (itemsFilter) {
|
| 839 |
+
productConfigure.addItemsFilter(listType, itemsFilter);
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
// prepare and do submit
|
| 843 |
+
productConfigure.addListType(listType, {urlSubmit: url});
|
| 844 |
+
productConfigure.setOnLoadIFrameCallback(listType, function(response){
|
| 845 |
+
this.loadAreaResponseHandler(response);
|
| 846 |
+
}.bind(this));
|
| 847 |
+
productConfigure.submit(listType);
|
| 848 |
+
// clean
|
| 849 |
+
this.productConfigureAddFields = {};
|
| 850 |
+
},
|
| 851 |
+
|
| 852 |
+
/**
|
| 853 |
+
* Show configuration of quote item
|
| 854 |
+
*
|
| 855 |
+
* @param itemId
|
| 856 |
+
*/
|
| 857 |
+
showQuoteItemConfiguration: function(itemId){
|
| 858 |
+
var listType = 'quote_items';
|
| 859 |
+
var qtyElement = $('order-items_grid').select('input[name="item\['+itemId+'\]\[qty\]"]')[0];
|
| 860 |
+
productConfigure.setConfirmCallback(listType, function() {
|
| 861 |
+
// sync qty of popup and qty of grid
|
| 862 |
+
var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement();
|
| 863 |
+
if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) {
|
| 864 |
+
qtyElement.value = confirmedCurrentQty.value;
|
| 865 |
+
}
|
| 866 |
+
this.productConfigureAddFields['item['+itemId+'][configured]'] = 1;
|
| 867 |
+
|
| 868 |
+
}.bind(this));
|
| 869 |
+
productConfigure.setShowWindowCallback(listType, function() {
|
| 870 |
+
// sync qty of grid and qty of popup
|
| 871 |
+
var formCurrentQty = productConfigure.getCurrentFormQtyElement();
|
| 872 |
+
if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) {
|
| 873 |
+
formCurrentQty.value = qtyElement.value;
|
| 874 |
+
}
|
| 875 |
+
}.bind(this));
|
| 876 |
+
productConfigure.showItemConfiguration(listType, itemId);
|
| 877 |
+
},
|
| 878 |
+
|
| 879 |
+
accountFieldsBind : function(container){
|
| 880 |
+
if($(container)){
|
| 881 |
+
var fields = $(container).select('input', 'select', 'textarea');
|
| 882 |
+
for(var i=0; i<fields.length; i++){
|
| 883 |
+
if(fields[i].id == 'group_id'){
|
| 884 |
+
fields[i].observe('change', this.accountGroupChange.bind(this))
|
| 885 |
+
}
|
| 886 |
+
else{
|
| 887 |
+
fields[i].observe('change', this.accountFieldChange.bind(this))
|
| 888 |
+
}
|
| 889 |
+
}
|
| 890 |
+
}
|
| 891 |
+
},
|
| 892 |
+
|
| 893 |
+
accountGroupChange : function(){
|
| 894 |
+
this.loadArea(['data'], true, this.serializeData('order-form_account').toObject());
|
| 895 |
+
},
|
| 896 |
+
|
| 897 |
+
accountFieldChange : function(){
|
| 898 |
+
this.saveData(this.serializeData('order-form_account'));
|
| 899 |
+
},
|
| 900 |
+
|
| 901 |
+
commentFieldsBind : function(container){
|
| 902 |
+
if($(container)){
|
| 903 |
+
var fields = $(container).select('input', 'textarea');
|
| 904 |
+
for(var i=0; i<fields.length; i++)
|
| 905 |
+
fields[i].observe('change', this.commentFieldChange.bind(this))
|
| 906 |
+
}
|
| 907 |
+
},
|
| 908 |
+
|
| 909 |
+
commentFieldChange : function(){
|
| 910 |
+
this.saveData(this.serializeData('order-comment'));
|
| 911 |
+
},
|
| 912 |
+
|
| 913 |
+
giftmessageFieldsBind : function(container){
|
| 914 |
+
if($(container)){
|
| 915 |
+
var fields = $(container).select('input', 'textarea');
|
| 916 |
+
for(var i=0; i<fields.length; i++)
|
| 917 |
+
fields[i].observe('change', this.giftmessageFieldChange.bind(this))
|
| 918 |
+
}
|
| 919 |
+
},
|
| 920 |
+
|
| 921 |
+
giftmessageFieldChange : function(){
|
| 922 |
+
this.giftMessageDataChanged = true;
|
| 923 |
+
},
|
| 924 |
+
|
| 925 |
+
giftmessageOnItemChange : function(event) {
|
| 926 |
+
var element = Event.element(event);
|
| 927 |
+
if(element.name.indexOf("giftmessage") != -1 && element.type == "checkbox" && !element.checked) {
|
| 928 |
+
var messages = $("order-giftmessage").select('textarea');
|
| 929 |
+
var name;
|
| 930 |
+
for(var i=0; i<messages.length; i++) {
|
| 931 |
+
name = messages[i].id.split("_");
|
| 932 |
+
if(name.length < 2) continue;
|
| 933 |
+
if (element.name.indexOf("[" + name[1] + "]") != -1 && messages[i].value != "") {
|
| 934 |
+
alert("First, clean the Message field in Gift Message form");
|
| 935 |
+
element.checked = true;
|
| 936 |
+
}
|
| 937 |
+
}
|
| 938 |
+
}
|
| 939 |
+
},
|
| 940 |
+
|
| 941 |
+
loadArea : function(area, indicator, params){
|
| 942 |
+
var url = this.loadBaseUrl;
|
| 943 |
+
if (area) {
|
| 944 |
+
area = this.prepareArea(area);
|
| 945 |
+
url += 'block/' + area;
|
| 946 |
+
}
|
| 947 |
+
if (indicator === true) indicator = 'html-body';
|
| 948 |
+
params = this.prepareParams(params);
|
| 949 |
+
params.json = true;
|
| 950 |
+
if (!this.loadingAreas) this.loadingAreas = [];
|
| 951 |
+
if (indicator) {
|
| 952 |
+
this.loadingAreas = area;
|
| 953 |
+
new Ajax.Request(url, {
|
| 954 |
+
parameters:params,
|
| 955 |
+
loaderArea: indicator,
|
| 956 |
+
onSuccess: function(transport) {
|
| 957 |
+
var response = transport.responseText.evalJSON();
|
| 958 |
+
this.loadAreaResponseHandler(response);
|
| 959 |
+
}.bind(this)
|
| 960 |
+
});
|
| 961 |
+
}
|
| 962 |
+
else {
|
| 963 |
+
new Ajax.Request(url, {parameters:params,loaderArea: indicator});
|
| 964 |
+
}
|
| 965 |
+
if (typeof productConfigure != 'undefined' && area instanceof Array && area.indexOf('items') != -1) {
|
| 966 |
+
productConfigure.clean('quote_items');
|
| 967 |
+
}
|
| 968 |
+
},
|
| 969 |
+
|
| 970 |
+
loadAreaResponseHandler : function (response){
|
| 971 |
+
if (response.error) {
|
| 972 |
+
alert(response.message);
|
| 973 |
+
}
|
| 974 |
+
if(response.ajaxExpired && response.ajaxRedirect) {
|
| 975 |
+
setLocation(response.ajaxRedirect);
|
| 976 |
+
}
|
| 977 |
+
if(!this.loadingAreas){
|
| 978 |
+
this.loadingAreas = [];
|
| 979 |
+
}
|
| 980 |
+
if(typeof this.loadingAreas == 'string'){
|
| 981 |
+
this.loadingAreas = [this.loadingAreas];
|
| 982 |
+
}
|
| 983 |
+
if(this.loadingAreas.indexOf('message') == -1) {
|
| 984 |
+
this.loadingAreas.push('message');
|
| 985 |
+
}
|
| 986 |
+
|
| 987 |
+
for(var i=0; i<this.loadingAreas.length; i++){
|
| 988 |
+
var id = this.loadingAreas[i];
|
| 989 |
+
if($(this.getAreaId(id))){
|
| 990 |
+
if ('message' != id || response[id]) {
|
| 991 |
+
var wrapper = new Element('div');
|
| 992 |
+
wrapper.update(response[id] ? response[id] : '');
|
| 993 |
+
$(this.getAreaId(id)).update(Prototype.Browser.IE ? wrapper.outerHTML : wrapper);
|
| 994 |
+
}
|
| 995 |
+
if ($(this.getAreaId(id)).callback) {
|
| 996 |
+
this[$(this.getAreaId(id)).callback]();
|
| 997 |
+
}
|
| 998 |
+
}
|
| 999 |
+
}
|
| 1000 |
+
},
|
| 1001 |
+
|
| 1002 |
+
prepareArea : function(area){
|
| 1003 |
+
if (this.giftMessageDataChanged) {
|
| 1004 |
+
return area.without('giftmessage');
|
| 1005 |
+
}
|
| 1006 |
+
return area;
|
| 1007 |
+
},
|
| 1008 |
+
|
| 1009 |
+
saveData : function(data){
|
| 1010 |
+
this.loadArea(false, false, data);
|
| 1011 |
+
},
|
| 1012 |
+
|
| 1013 |
+
showArea : function(area){
|
| 1014 |
+
var id = this.getAreaId(area);
|
| 1015 |
+
if($(id)) {
|
| 1016 |
+
$(id).show();
|
| 1017 |
+
this.areaOverlay();
|
| 1018 |
+
}
|
| 1019 |
+
},
|
| 1020 |
+
|
| 1021 |
+
hideArea : function(area){
|
| 1022 |
+
var id = this.getAreaId(area);
|
| 1023 |
+
if($(id)) {
|
| 1024 |
+
$(id).hide();
|
| 1025 |
+
this.areaOverlay();
|
| 1026 |
+
}
|
| 1027 |
+
},
|
| 1028 |
+
|
| 1029 |
+
areaOverlay : function()
|
| 1030 |
+
{
|
| 1031 |
+
$H(order.overlayData).each(function(e){
|
| 1032 |
+
e.value.fx();
|
| 1033 |
+
});
|
| 1034 |
+
},
|
| 1035 |
+
|
| 1036 |
+
getAreaId : function(area){
|
| 1037 |
+
return 'order-'+area;
|
| 1038 |
+
},
|
| 1039 |
+
|
| 1040 |
+
prepareParams : function(params){
|
| 1041 |
+
if (!params) {
|
| 1042 |
+
params = {};
|
| 1043 |
+
}
|
| 1044 |
+
if (!params.customer_id) {
|
| 1045 |
+
params.customer_id = this.customerId;
|
| 1046 |
+
}
|
| 1047 |
+
if (!params.store_id) {
|
| 1048 |
+
params.store_id = this.storeId;
|
| 1049 |
+
}
|
| 1050 |
+
if (!params.currency_id) {
|
| 1051 |
+
params.currency_id = this.currencyId;
|
| 1052 |
+
}
|
| 1053 |
+
if (!params.form_key) {
|
| 1054 |
+
params.form_key = FORM_KEY;
|
| 1055 |
+
}
|
| 1056 |
+
var data = this.serializeData('order-billing_method');
|
| 1057 |
+
if (data) {
|
| 1058 |
+
data.each(function(value) {
|
| 1059 |
+
params[value[0]] = value[1];
|
| 1060 |
+
});
|
| 1061 |
+
}
|
| 1062 |
+
return params;
|
| 1063 |
+
},
|
| 1064 |
+
|
| 1065 |
+
serializeData : function(container){
|
| 1066 |
+
var fields = $(container).select('input', 'select', 'textarea');
|
| 1067 |
+
var data = Form.serializeElements(fields, true);
|
| 1068 |
+
|
| 1069 |
+
return $H(data);
|
| 1070 |
+
},
|
| 1071 |
+
|
| 1072 |
+
toggleCustomPrice: function(checkbox, elemId, tierBlock) {
|
| 1073 |
+
if (checkbox.checked) {
|
| 1074 |
+
$(elemId).disabled = false;
|
| 1075 |
+
$(elemId).show();
|
| 1076 |
+
if($(tierBlock)) $(tierBlock).hide();
|
| 1077 |
+
}
|
| 1078 |
+
else {
|
| 1079 |
+
$(elemId).disabled = true;
|
| 1080 |
+
$(elemId).hide();
|
| 1081 |
+
if($(tierBlock)) $(tierBlock).show();
|
| 1082 |
+
}
|
| 1083 |
+
},
|
| 1084 |
+
|
| 1085 |
+
submit : function()
|
| 1086 |
+
{
|
| 1087 |
+
if (this.orderItemChanged) {
|
| 1088 |
+
if (confirm('You have item changes')) {
|
| 1089 |
+
if (editForm.submit()) {
|
| 1090 |
+
disableElements('save');
|
| 1091 |
+
}
|
| 1092 |
+
} else {
|
| 1093 |
+
this.itemsUpdate();
|
| 1094 |
+
}
|
| 1095 |
+
} else {
|
| 1096 |
+
if (editForm.submit()) {
|
| 1097 |
+
disableElements('save');
|
| 1098 |
+
}
|
| 1099 |
+
}
|
| 1100 |
+
},
|
| 1101 |
+
|
| 1102 |
+
overlay : function(elId, show, observe)
|
| 1103 |
+
{
|
| 1104 |
+
if (typeof(show) == 'undefined') { show = true; }
|
| 1105 |
+
|
| 1106 |
+
var orderObj = this;
|
| 1107 |
+
var obj = this.overlayData.get(elId)
|
| 1108 |
+
if (!obj) {
|
| 1109 |
+
obj = {
|
| 1110 |
+
show: show,
|
| 1111 |
+
el: elId,
|
| 1112 |
+
order: orderObj,
|
| 1113 |
+
fx: function(event) {
|
| 1114 |
+
this.order.processOverlay(this.el, this.show);
|
| 1115 |
+
}
|
| 1116 |
+
}
|
| 1117 |
+
obj.bfx = obj.fx.bindAsEventListener(obj);
|
| 1118 |
+
this.overlayData.set(elId, obj);
|
| 1119 |
+
}
|
| 1120 |
+
else {
|
| 1121 |
+
obj.show = show;
|
| 1122 |
+
Event.stopObserving(window, 'resize', obj.bfx);
|
| 1123 |
+
}
|
| 1124 |
+
|
| 1125 |
+
Event.observe(window, 'resize', obj.bfx);
|
| 1126 |
+
|
| 1127 |
+
this.processOverlay(elId, show);
|
| 1128 |
+
},
|
| 1129 |
+
|
| 1130 |
+
processOverlay : function(elId, show)
|
| 1131 |
+
{
|
| 1132 |
+
var el = $(elId);
|
| 1133 |
+
|
| 1134 |
+
if (!el) {
|
| 1135 |
+
return false;
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
var parentEl = el.up(1);
|
| 1139 |
+
if (show) {
|
| 1140 |
+
parentEl.removeClassName('ignore-validate');
|
| 1141 |
+
}
|
| 1142 |
+
else {
|
| 1143 |
+
parentEl.addClassName('ignore-validate');
|
| 1144 |
+
}
|
| 1145 |
+
|
| 1146 |
+
if (Prototype.Browser.IE) {
|
| 1147 |
+
parentEl.select('select').each(function (elem) {
|
| 1148 |
+
if (show) {
|
| 1149 |
+
elem.needShowOnSuccess = false;
|
| 1150 |
+
elem.style.visibility = '';
|
| 1151 |
+
} else {
|
| 1152 |
+
elem.style.visibility = 'hidden';
|
| 1153 |
+
elem.needShowOnSuccess = true;
|
| 1154 |
+
}
|
| 1155 |
+
});
|
| 1156 |
+
}
|
| 1157 |
+
|
| 1158 |
+
parentEl.setStyle({position: 'relative'});
|
| 1159 |
+
el.setStyle({
|
| 1160 |
+
display: show ? 'none' : '',
|
| 1161 |
+
position: 'absolute',
|
| 1162 |
+
backgroundColor: '#999999',
|
| 1163 |
+
opacity: 0.8,
|
| 1164 |
+
width: parentEl.getWidth() + 'px',
|
| 1165 |
+
height: parentEl.getHeight() + 'px',
|
| 1166 |
+
top: 0,
|
| 1167 |
+
left: 0
|
| 1168 |
+
});
|
| 1169 |
+
},
|
| 1170 |
+
|
| 1171 |
+
validateVat: function(parameters)
|
| 1172 |
+
{
|
| 1173 |
+
var params = {
|
| 1174 |
+
country: $(parameters.countryElementId).value,
|
| 1175 |
+
vat: $(parameters.vatElementId).value
|
| 1176 |
+
};
|
| 1177 |
+
|
| 1178 |
+
if (this.storeId !== false) {
|
| 1179 |
+
params.store_id = this.storeId;
|
| 1180 |
+
}
|
| 1181 |
+
|
| 1182 |
+
var currentCustomerGroupId = $(parameters.groupIdHtmlId).value;
|
| 1183 |
+
|
| 1184 |
+
new Ajax.Request(parameters.validateUrl, {
|
| 1185 |
+
parameters: params,
|
| 1186 |
+
onSuccess: function(response) {
|
| 1187 |
+
var message = '';
|
| 1188 |
+
var groupChangeRequired = false;
|
| 1189 |
+
try {
|
| 1190 |
+
response = response.responseText.evalJSON();
|
| 1191 |
+
|
| 1192 |
+
if (true === response.valid) {
|
| 1193 |
+
message = parameters.vatValidMessage;
|
| 1194 |
+
if (currentCustomerGroupId != response.group) {
|
| 1195 |
+
message = parameters.vatValidAndGroupChangeMessage;
|
| 1196 |
+
groupChangeRequired = true;
|
| 1197 |
+
}
|
| 1198 |
+
} else if (response.success) {
|
| 1199 |
+
message = parameters.vatInvalidMessage.replace(/%s/, params.vat);
|
| 1200 |
+
groupChangeRequired = true;
|
| 1201 |
+
} else {
|
| 1202 |
+
message = parameters.vatValidationFailedMessage;
|
| 1203 |
+
groupChangeRequired = true;
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
} catch (e) {
|
| 1207 |
+
message = parameters.vatErrorMessage;
|
| 1208 |
+
}
|
| 1209 |
+
if (!groupChangeRequired) {
|
| 1210 |
+
alert(message);
|
| 1211 |
+
}
|
| 1212 |
+
else {
|
| 1213 |
+
this.processCustomerGroupChange(parameters.groupIdHtmlId, message, response.group);
|
| 1214 |
+
}
|
| 1215 |
+
}.bind(this)
|
| 1216 |
+
});
|
| 1217 |
+
},
|
| 1218 |
+
|
| 1219 |
+
processCustomerGroupChange: function(groupIdHtmlId, message, groupId)
|
| 1220 |
+
{
|
| 1221 |
+
var currentCustomerGroupId = $(groupIdHtmlId).value;
|
| 1222 |
+
var currentCustomerGroupTitle = $$('#' + groupIdHtmlId + ' > option[value=' + currentCustomerGroupId + ']')[0].text;
|
| 1223 |
+
var customerGroupOption = $$('#' + groupIdHtmlId + ' > option[value=' + groupId + ']')[0];
|
| 1224 |
+
var confirmText = message.replace(/%s/, customerGroupOption.text);
|
| 1225 |
+
confirmText = confirmText.replace(/%s/, currentCustomerGroupTitle);
|
| 1226 |
+
if (confirm(confirmText)) {
|
| 1227 |
+
$$('#' + groupIdHtmlId + ' option').each(function(o) {
|
| 1228 |
+
o.selected = o.readAttribute('value') == groupId;
|
| 1229 |
+
});
|
| 1230 |
+
this.accountGroupChange();
|
| 1231 |
+
}
|
| 1232 |
+
}
|
| 1233 |
+
};
|
| 1234 |
+
|
| 1235 |
+
var OrderFormArea = Class.create();
|
| 1236 |
+
OrderFormArea.prototype = {
|
| 1237 |
+
_name: null,
|
| 1238 |
+
_node: null,
|
| 1239 |
+
_parent: null,
|
| 1240 |
+
_callbackName: null,
|
| 1241 |
+
|
| 1242 |
+
initialize: function(name, node, parent){
|
| 1243 |
+
this._name = name;
|
| 1244 |
+
this._parent = parent;
|
| 1245 |
+
this._callbackName = node.callback;
|
| 1246 |
+
if (typeof this._callbackName == 'undefined') {
|
| 1247 |
+
this._callbackName = name + 'Loaded';
|
| 1248 |
+
node.callback = this._callbackName;
|
| 1249 |
+
}
|
| 1250 |
+
parent[this._callbackName] = parent[this._callbackName].wrap((function (proceed){
|
| 1251 |
+
proceed();
|
| 1252 |
+
this.onLoad();
|
| 1253 |
+
}).bind(this));
|
| 1254 |
+
|
| 1255 |
+
this.setNode(node);
|
| 1256 |
+
},
|
| 1257 |
+
|
| 1258 |
+
setNode: function(node){
|
| 1259 |
+
if (!node.callback) {
|
| 1260 |
+
node.callback = this._callbackName;
|
| 1261 |
+
}
|
| 1262 |
+
this.node = node;
|
| 1263 |
+
},
|
| 1264 |
+
|
| 1265 |
+
onLoad: function(){
|
| 1266 |
+
}
|
| 1267 |
+
};
|
| 1268 |
+
|
| 1269 |
+
var ControlButton = Class.create();
|
| 1270 |
+
ControlButton.prototype = {
|
| 1271 |
+
_label: '',
|
| 1272 |
+
_node: null,
|
| 1273 |
+
|
| 1274 |
+
initialize: function(label){
|
| 1275 |
+
this._label = label;
|
| 1276 |
+
this._node = new Element('button', {
|
| 1277 |
+
'class': 'scalable add',
|
| 1278 |
+
'type': 'button'
|
| 1279 |
+
});
|
| 1280 |
+
},
|
| 1281 |
+
|
| 1282 |
+
onClick: function(){
|
| 1283 |
+
},
|
| 1284 |
+
|
| 1285 |
+
insertIn: function(element, position){
|
| 1286 |
+
var node = Object.extend(this._node),
|
| 1287 |
+
content = {};
|
| 1288 |
+
node.observe('click', this.onClick);
|
| 1289 |
+
node.update('<span>' + this._label + '</span>');
|
| 1290 |
+
content[position] = node;
|
| 1291 |
+
Element.insert(element, content);
|
| 1292 |
+
}
|
| 1293 |
+
};
|
package.xml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Dextrous_Saveorder</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>Open Software License (OSL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension enables the feature to save an order in admin like frontend cart in magento.</summary>
|
| 10 |
+
<description>Extension enables the feature to save an order in admin like frontend cart in magento.
|
| 11 |
+

|
| 12 |
+
When admin create an order in admin for any customer but not want to place order now then extension provides facility to save current order and he can place it after whenever he want. Admin can also update this order many times.
|
| 13 |
+

|
| 14 |
+
Admin can manage saved order navigate to "Sales->Saved Orders".</description>
|
| 15 |
+
<notes>Stable Releases.</notes>
|
| 16 |
+
<authors><author><name>Hemant kumar sharma</name><user>hemantkr</user><email>hemant7677@gmail.com</email></author></authors>
|
| 17 |
+
<date>2014-11-03</date>
|
| 18 |
+
<time>10:17:59</time>
|
| 19 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Dextrous_Saveorder.xml" hash="5bce465d1c83a51a88df758cde6fd174"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="saveorder.xml" hash="64f0f43277a908bb463c1bb9e2f0648e"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Dextrous"><dir name="Saveorder"><dir name="Block"><dir name="Adminhtml"><dir name="Saveorder"><file name="Grid.php" hash="408db646829ebc1e71b96791ba9682b5"/></dir><file name="Saveorder.php" hash="b9ccd14d4f6c3a9961554190e643d424"/></dir><dir name="Sales"><dir name="Order"><file name="Create.php" hash="7ba9c12f8dbe63a356424aefbbef0a10"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="3dfb8221b5504d521cdc227d50c9c239"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Saveorder"><file name="Collection.php" hash="6e0b13bd5959d9df7da41f6bad8fcd3d"/></dir><file name="Saveorder.php" hash="ee7687d83799b32a2db92a763cd29715"/></dir><file name="Saveorder.php" hash="799ac4f5b2c516cdca17e7bcc4bcd466"/><file name="Status.php" hash="ae735f2057909ee925bb74e33bf79039"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SaveorderController.php" hash="9f3831401085693ce6fbbe7f7e5fbf39"/></dir><dir name="Sales"><dir name="Order"><file name="EditController.php" hash="bf24bfe5c03625e01c4e645a1f106c89"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f5ed47b86cd96d17e395cae8466caebb"/><file name="config.xml" hash="27be629c89e5d239fef2b52c444a6554"/></dir><dir name="sql"><dir name="saveorder_setup"><file name="mysql4-install-0.1.0.php" hash="0e385d982477811b930f27e9acfae40f"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="saveorder"><dir name="adminhtml"><file name="sales.js" hash="fec50c5de5ea34fa50a818fe398ee7e6"/></dir></dir></dir></target></contents>
|
| 20 |
+
<compatible/>
|
| 21 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 22 |
+
</package>
|
