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_Invoice_Create_Items extends Mage_Adminhtml_Block_Sales_Items_Abstract
00036 {
00037 protected $_disableSubmitButton = false;
00038
00039
00040
00041
00042
00043
00044 protected function _beforeToHtml()
00045 {
00046 $onclick = "submitAndReloadArea($('invoice_item_container'),'".$this->getUpdateUrl()."')";
00047 $this->setChild(
00048 'update_button',
00049 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00050 'class' => 'update-button',
00051 'label' => Mage::helper('sales')->__('Update Qty\'s'),
00052 'onclick' => $onclick,
00053 ))
00054 );
00055 $this->_disableSubmitButton = true;
00056 $_submitButtonClass = ' disabled';
00057 foreach ($this->getInvoice()->getAllItems() as $item) {
00058 if ($item->getQty() || $this->getSource()->getData('base_grand_total')) {
00059 $this->_disableSubmitButton = false;
00060 $_submitButtonClass = '';
00061 break;
00062 }
00063 }
00064 $_submitLabel = $this->getOrder()->getForcedDoShipmentWithInvoice()?'Submit Invoice and Shipment':'Submit Invoice';
00065 $this->setChild(
00066 'submit_button',
00067 $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00068 'label' => Mage::helper('sales')->__('%s', $_submitLabel),
00069 'class' => 'save submit-button' . $_submitButtonClass,
00070 'onclick' => '$(\'edit_form\').submit()',
00071 'disabled' => $this->_disableSubmitButton
00072 ))
00073 );
00074
00075 return parent::_prepareLayout();
00076 }
00077
00078
00079
00080
00081
00082
00083 public function getDisableSubmitButton()
00084 {
00085 return $this->_disableSubmitButton;
00086 }
00087
00088
00089
00090
00091
00092
00093 public function getOrder()
00094 {
00095 return $this->getInvoice()->getOrder();
00096 }
00097
00098
00099
00100
00101
00102
00103 public function getSource()
00104 {
00105 return $this->getInvoice();
00106 }
00107
00108
00109
00110
00111
00112
00113 public function getInvoice()
00114 {
00115 return Mage::registry('current_invoice');
00116 }
00117
00118
00119
00120
00121
00122
00123 public function getOrderTotalData()
00124 {
00125 return array();
00126 }
00127
00128
00129
00130
00131
00132
00133 public function getOrderTotalbarData()
00134 {
00135 $totalbarData = array();
00136 $this->setPriceDataObject($this->getInvoice());
00137 $totalbarData[] = array(Mage::helper('sales')->__('Paid Amount'), $this->displayPriceAttribute('amount_paid'), false);
00138 $totalbarData[] = array(Mage::helper('sales')->__('Refund Amount'), $this->displayPriceAttribute('amount_refunded'), false);
00139 $totalbarData[] = array(Mage::helper('sales')->__('Shipping Amount'), $this->displayPriceAttribute('shipping_captured'), false);
00140 $totalbarData[] = array(Mage::helper('sales')->__('Shipping Refund'), $this->displayPriceAttribute('shipping_refunded'), false);
00141 $totalbarData[] = array(Mage::helper('sales')->__('Order Grand Total'), $this->displayPriceAttribute('grand_total'), true);
00142
00143 return $totalbarData;
00144 }
00145
00146 public function formatPrice($price)
00147 {
00148 return $this->getInvoice()->getOrder()->formatPrice($price);
00149 }
00150
00151 public function getUpdateButtonHtml()
00152 {
00153 return $this->getChildHtml('update_button');
00154 }
00155
00156 public function getUpdateUrl()
00157 {
00158 return $this->getUrl('*/*/updateQty', array('order_id'=>$this->getInvoice()->getOrderId()));
00159 }
00160
00161
00162
00163
00164
00165
00166 public function canCreateShipment()
00167 {
00168 foreach ($this->getInvoice()->getAllItems() as $item) {
00169 if ($item->getOrderItem()->getQtyToShip()) {
00170 return true;
00171 }
00172 }
00173 return false;
00174 }
00175
00176 public function canEditQty()
00177 {
00178 if ($this->getInvoice()->getOrder()->getPayment()->canCapture()) {
00179 return $this->getInvoice()->getOrder()->getPayment()->canCapturePartial();
00180 }
00181 return true;
00182 }
00183
00184 public function canCapture()
00185 {
00186 if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/capture')) {
00187 return $this->getInvoice()->canCapture();
00188 }
00189 return false;
00190 }
00191
00192 public function canSendInvoiceEmail()
00193 {
00194 return Mage::helper('sales')->canSendNewInvoiceEmail($this->getOrder()->getStore()->getId());
00195 }
00196 }