00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items extends Mage_Adminhtml_Block_Sales_Items_Abstract
00036 {
00037
00038
00039
00040
00041
00042 protected function _prepareLayout()
00043 {
00044 $onclick = "submitAndReloadArea($('creditmemo_item_container'),'".$this->getUpdateUrl()."')";
00045 $this->setChild(
00046 'update_button',
00047 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00048 'label' => Mage::helper('sales')->__('Update Qty\'s'),
00049 'class' => 'update-button',
00050 'onclick' => $onclick,
00051 ))
00052 );
00053
00054 if ($this->getCreditmemo()->canRefund()) {
00055 if ($this->getCreditmemo()->getInvoice()) {
00056 $this->setChild(
00057 'submit_button',
00058 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00059 'label' => Mage::helper('sales')->__('Refund'),
00060 'class' => 'save submit-button',
00061 'onclick' => 'editForm.submit()',
00062 ))
00063 );
00064 }
00065
00066 if ($this->getCreditmemo()->canRefund()) {
00067 $this->setChild(
00068 'submit_offline',
00069 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00070 'label' => Mage::helper('sales')->__('Refund Offline'),
00071 'class' => 'save submit-button',
00072 'onclick' => 'editForm.submit()',
00073 ))
00074 );
00075 }
00076
00077 }
00078 else {
00079 $this->setChild(
00080 'submit_button',
00081 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00082 'label' => Mage::helper('sales')->__('Refund'),
00083 'class' => 'save submit-button',
00084 'onclick' => 'editForm.submit()',
00085 ))
00086 );
00087 }
00088
00089 return parent::_prepareLayout();
00090 }
00091
00092
00093
00094
00095
00096
00097 public function getOrder()
00098 {
00099 return $this->getCreditmemo()->getOrder();
00100 }
00101
00102
00103
00104
00105
00106
00107 public function getSource()
00108 {
00109 return $this->getCreditmemo();
00110 }
00111
00112
00113
00114
00115
00116
00117 public function getOrderTotalData()
00118 {
00119 return array();
00120 }
00121
00122
00123
00124
00125
00126
00127 public function getOrderTotalbarData()
00128 {
00129 $totalbarData = array();
00130 $this->setPriceDataObject($this->getOrder());
00131 $totalbarData[] = array(Mage::helper('sales')->__('Paid Amount'), $this->displayPriceAttribute('total_invoiced'), false);
00132 $totalbarData[] = array(Mage::helper('sales')->__('Refund Amount'), $this->displayPriceAttribute('total_refunded'), false);
00133 $totalbarData[] = array(Mage::helper('sales')->__('Shipping Amount'), $this->displayPriceAttribute('shipping_invoiced'), false);
00134 $totalbarData[] = array(Mage::helper('sales')->__('Shipping Refund'), $this->displayPriceAttribute('shipping_refunded'), false);
00135 $totalbarData[] = array(Mage::helper('sales')->__('Order Grand Total'), $this->displayPriceAttribute('grand_total'), true);
00136
00137 return $totalbarData;
00138 }
00139
00140
00141
00142
00143
00144
00145 public function getCreditmemo()
00146 {
00147 return Mage::registry('current_creditmemo');
00148 }
00149
00150 public function canEditQty()
00151 {
00152 if ($this->getCreditmemo()->getOrder()->getPayment()->canCapture()) {
00153 return $this->getCreditmemo()->getOrder()->getPayment()->canCapturePartial();
00154 }
00155 return true;
00156 }
00157
00158 public function getUpdateButtonHtml()
00159 {
00160 return $this->getChildHtml('update_button');
00161 }
00162
00163 public function getUpdateUrl()
00164 {
00165 return $this->getUrl('*/*/updateQty', array(
00166 'order_id'=>$this->getCreditmemo()->getOrderId(),
00167 'invoice_id'=>$this->getRequest()->getParam('invoice_id', null),
00168 ));
00169 }
00170
00171 public function canReturnToStock() {
00172
00173 $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT);
00174 if (Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) {
00175 return true;
00176 } else {
00177 return false;
00178 }
00179 }
00180
00181 public function canSendCreditmemoEmail()
00182 {
00183 return Mage::helper('sales')->canSendNewCreditmemoEmail($this->getOrder()->getStore()->getId());
00184 }
00185 }