In Adminhtml (Sales->Order->view ) i have add the fieldset, this shows the content correctly.
When i am using the submitAndReloadArea
the value have submited and saved successfully but the value retrieve i got the below error,
Fatal error: Call to a member function toHtml() on a non-object in /var/www/html/emsstore/app/code/local/Mage/Adminhtml/controllers/Sales/OrderController.php on line 783
Below are my files
i got error in $response = $this->getLayout()->getBlock('order_pickstatus')->toHtml();
this code which is in OrderController.php
.
OrderController.php
class Mage_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Controller_Action
{
.....
.....
public function changePickstatusAction()
{
try {
$id = $this->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($id);
$response = false;
$data = $this->getRequest()->getPost('pickup_status');
$order->setpickup_status($data);
$order->save();
$response = $this->getLayout()->getBlock('order_pickstatus')->toHtml();
}
catch (Mage_Core_Exception $e) {
$response = array(
'error' => true,
'message' => $e->getMessage(),
);
$response = Mage::helper('core')->jsonEncode($response);
}
catch (Exception $e) {
$response = array(
'error' => true,
'message' => $this->__('Cannot add order history.')
);
$response = Mage::helper('core')->jsonEncode($response);
}
$this->getResponse()->setBody($response);
}
}
app/design/adminhtml/default/default/layout/sales.xml
<adminhtml_sales_order_changepickstatus>
<block type="adminhtml/sales_order_view_pickstatus" name="order_pickstatus" template="sales/order/view/pickstatus.phtml" output="toHtml"></block>
</adminhtml_sales_order_changepickstatus>
<adminhtml_sales_order_view>
.......
<reference name="left">
<block type="adminhtml/sales_order_view_tabs" name="sales_order_tabs">
<block type="adminhtml/sales_order_view_tab_info" name="order_tab_info" template="sales/order/view/tab/info.phtml">
.....
<block type="adminhtml/sales_order_view_pickstatus" name="order_pickstatus" template="sales/order/view/pickstatus.phtml"></block>
...
</block>
</reference>
</adminhtml_sales_order_view>
template file, app/design/adminhtml/default/default/template/sales/order/view/pickstatus.phtml
<div id="order_pickstatus_block">
<div id="pickstatus_form" class="order-pickstatus-form">
<span class="field-row">
<label class="normal" for="pickup_status"><?php echo Mage::helper('sales')->__('Status') ?></label>
<select name="pickup_status" id="pickup_status">
<option value="">--Select Status--</option>
<option value="notdelivered">Not Delivered</option>
<option value="delivered">Delivered</option>
</select>
</span>
<div class="f-right">
<?php echo $this->getChildHtml('submit_button') ?>
</div>
<div class="clear"></div>
</div>
<div class="divider"></div>
</div>
Block file
class Mage_Adminhtml_Block_Sales_Order_View_Pickstatus extends Mage_Adminhtml_Block_Template
{
protected function _prepareLayout()
{
$onclick = "submitAndReloadArea($('order_pickstatus_block').parentNode, '".$this->getSubmitUrl()."')";
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('sales')->__('Submit Status'),
'class' => 'save',
'onclick' => $onclick
));
$this->setChild('submit_button', $button);
return parent::_prepareLayout();
}
public function getOrder()
{
return Mage::registry('sales_order');
}
public function getSubmitUrl()
{
return $this->getUrl('*/*/changePickstatus', array('order_id'=>$this->getOrder()->getId()));
}
public function getPickstatus()
{
return $this->getOrder()->getPickup_status();
}
}
what is wrong in my code.
Anything more to config?
thanks in advance.