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_Invoice_View extends Mage_Adminhtml_Block_Widget_Form_Container
00035 {
00036 public function __construct()
00037 {
00038 $this->_objectId = 'invoice_id';
00039 $this->_controller = 'sales_order_invoice';
00040 $this->_mode = 'view';
00041
00042 parent::__construct();
00043
00044 $this->_removeButton('save');
00045 $this->_removeButton('reset');
00046 $this->_removeButton('delete');
00047
00048 if ($this->getInvoice()->canCancel()) {
00049 $this->_addButton('cancel', array(
00050 'label' => Mage::helper('sales')->__('Cancel'),
00051 'class' => 'delete',
00052 'onclick' => 'setLocation(\''.$this->getCancelUrl().'\')'
00053 )
00054 );
00055 }
00056
00057 if ($this->getInvoice()->getOrder()->canCreditmemo()) {
00058 if ($this->getInvoice()->getOrder()->getPayment()->canRefundPartialPerInvoice()
00059 || !$this->getInvoice()->getIsUsedForRefund())
00060 {
00061 $this->_addButton('capture', array(
00062 'label' => Mage::helper('sales')->__('Credit Memo'),
00063 'class' => 'save',
00064 'onclick' => 'setLocation(\''.$this->getCreditMemoUrl().'\')'
00065 )
00066 );
00067 }
00068 }
00069
00070 if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/capture')
00071 && $this->getInvoice()->canCapture()) {
00072 $this->_addButton('capture', array(
00073 'label' => Mage::helper('sales')->__('Capture'),
00074 'class' => 'save',
00075 'onclick' => 'setLocation(\''.$this->getCaptureUrl().'\')'
00076 )
00077 );
00078 }
00079
00080 if ($this->getInvoice()->canVoid()) {
00081 $this->_addButton('void', array(
00082 'label' => Mage::helper('sales')->__('Void'),
00083 'class' => 'save',
00084 'onclick' => 'setLocation(\''.$this->getVoidUrl().'\')'
00085 )
00086 );
00087 }
00088
00089 if ($this->getInvoice()->getId()) {
00090 $this->_addButton('print', array(
00091 'label' => Mage::helper('sales')->__('Print'),
00092 'class' => 'save',
00093 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
00094 )
00095 );
00096 }
00097 }
00098
00099
00100
00101
00102
00103
00104 public function getInvoice()
00105 {
00106 return Mage::registry('current_invoice');
00107 }
00108
00109 public function getHeaderText()
00110 {
00111 if ($this->getInvoice()->getEmailSent()) {
00112 $emailSent = Mage::helper('sales')->__('Invoice email sent');
00113 }
00114 else {
00115 $emailSent = Mage::helper('sales')->__('Invoice email not sent');
00116 }
00117
00118 $header = Mage::helper('sales')->__('Invoice #%s | %s (%s)',
00119 $this->getInvoice()->getIncrementId(),
00120 $this->getInvoice()->getStateName(),
00121 $emailSent
00122 );
00123 /*$header = Mage::helper('sales')->__('Invoice #%s | Order Date: %s | Customer Name: %s',
00124 $this->getInvoice()->getIncrementId(),
00125 $this->formatDate($this->getInvoice()->getOrder()->getCreatedAt(), 'medium', true),
00126 $this->getInvoice()->getOrder()->getCustomerName()
00127 );*/
00128 return $header;
00129 }
00130
00131 public function getBackUrl()
00132 {
00133 return $this->getUrl(
00134 '*/sales_order/view',
00135 array(
00136 'order_id' => $this->getInvoice()->getOrderId(),
00137 'active_tab'=> 'order_invoices'
00138 ));
00139 }
00140
00141 public function getCaptureUrl()
00142 {
00143 return $this->getUrl('*
00144
00145
00146
00147
00148 */void', array('invoice_id'=>$this->getInvoice()->getId()));
00149 }
00150
00151 public function getCancelUrl()
00152 {
00153 return $this->getUrl('*
00154
00155
00156
00157
00158 sales_order_creditmemo/start', array(
00159 'order_id' => $this->getInvoice()->getOrder()->getId(),
00160 'invoice_id'=> $this->getInvoice()->getId(),
00161 ));
00162 }
00163
00164 public function getPrintUrl()
00165 {
00166 return $this->getUrl('*
00167
00168
00169
00170
00171
00172
00173
00174 sales_invoice/') . '\')');
00175 }
00176 return $this;
00177 }
00178 }