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 class Mage_Adminhtml_Block_Sales_Order_Creditmemo_View extends Mage_Adminhtml_Block_Widget_Form_Container
00035 {
00036
00037 public function __construct()
00038 {
00039 $this->_objectId = 'creditmemo_id';
00040 $this->_controller = 'sales_order_creditmemo';
00041 $this->_mode = 'view';
00042
00043 parent::__construct();
00044
00045 $this->_removeButton('save');
00046 $this->_removeButton('reset');
00047 $this->_removeButton('delete');
00048
00049 if ($this->getCreditmemo()->canCancel()) {
00050 $this->_addButton('cancel', array(
00051 'label' => Mage::helper('sales')->__('Cancel'),
00052 'class' => 'delete',
00053 'onclick' => 'setLocation(\''.$this->getCancelUrl().'\')'
00054 )
00055 );
00056 }
00057
00058 if ($this->getCreditmemo()->canRefund()) {
00059 $this->_addButton('refund', array(
00060 'label' => Mage::helper('sales')->__('Refund'),
00061 'class' => 'save',
00062 'onclick' => 'setLocation(\''.$this->getRefundUrl().'\')'
00063 )
00064 );
00065 }
00066
00067 if ($this->getCreditmemo()->canVoid()) {
00068 $this->_addButton('void', array(
00069 'label' => Mage::helper('sales')->__('Void'),
00070 'class' => 'save',
00071 'onclick' => 'setLocation(\''.$this->getVoidUrl().'\')'
00072 )
00073 );
00074 }
00075
00076 if ($this->getCreditmemo()->getId()) {
00077 $this->_addButton('print', array(
00078 'label' => Mage::helper('sales')->__('Print'),
00079 'class' => 'save',
00080 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
00081 )
00082 );
00083 }
00084 }
00085
00086
00087
00088
00089
00090
00091 public function getCreditmemo()
00092 {
00093 return Mage::registry('current_creditmemo');
00094 }
00095
00096 public function getHeaderText()
00097 {
00098 if ($this->getCreditmemo()->getEmailSent()) {
00099 $emailSent = Mage::helper('sales')->__('Credit Memo email sent');
00100 }
00101 else {
00102 $emailSent = Mage::helper('sales')->__('Credit Memo email not sent');
00103 }
00104
00105 $header = Mage::helper('sales')->__('Credit Memo #%s | Date %s | Status %s (%s)',
00106 $this->getCreditmemo()->getIncrementId(),
00107 $this->formatDate($this->getCreditmemo()->getCreatedAtDate(), 'medium', true),
00108 $this->getCreditmemo()->getStateName(),
00109 $emailSent
00110 );
00111 return $header;
00112 }
00113
00114 public function getBackUrl()
00115 {
00116 return $this->getUrl(
00117 '*/sales_order/view',
00118 array(
00119 'order_id' => $this->getCreditmemo()->getOrderId(),
00120 'active_tab'=> 'order_creditmemos'
00121 ));
00122 }
00123
00124 public function getCaptureUrl()
00125 {
00126 return $this->getUrl('*
00127
00128
00129
00130
00131 */void', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
00132 }
00133
00134 public function getCancelUrl()
00135 {
00136 return $this->getUrl('*
00137
00138
00139
00140
00141 */print', array(
00142 'invoice_id' => $this->getCreditmemo()->getId()
00143 ));
00144 }
00145
00146 public function updateBackButtonUrl($flag)
00147 {
00148 if ($flag) {
00149 return $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')');
00150 }
00151 return $this;
00152 }
00153 }