Mage_Adminhtml_Block_Sales_Items_Abstract Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Sales_Items_Abstract:

Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Sales_Items_Renderer_Configurable Mage_Adminhtml_Block_Sales_Items_Renderer_Default Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items Mage_Adminhtml_Block_Sales_Order_Creditmemo_View_Items Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items Mage_Adminhtml_Block_Sales_Order_Shipment_View_Items Mage_Adminhtml_Block_Sales_Order_View_Items Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default

List of all members.

Public Member Functions

 addItemRender ($type, $block, $template)
 addColumnRender ($column, $block, $template, $type=null)
 getItemRenderer ($type)
 getColumnRenderer ($column, $compositePart='')
 getItemHtml (Varien_Object $item)
 getColumnHtml (Varien_Object $item, $column, $field=null)
 getCreditmemo ()
 getOrder ()
 getPriceDataObject ()
 displayPriceAttribute ($code, $strong=false, $separator= '< br/>')
 displayPrices ($basePrice, $price, $strong=false, $separator= '< br/>')
 displayPriceInclTax (Varien_Object $item)
 displaySubtotalInclTax ($item)
 displayTaxCalculation (Varien_Object $item)
 displayTaxPercent (Varien_Object $item)
 canCreateShipment ()
 canEditQty ()
 canCapture ()
 formatPrice ($price)
 getSource ()
 getInvoice ()
 canReturnToStock ()
 canShipPartially ($order=null)
 canShipPartiallyItem ($order=null)
 isShipmentRegular ()

Protected Member Functions

 _construct ()

Protected Attributes

 $_itemRenders = array()
 $_columnRenders = array()


Detailed Description

Definition at line 35 of file Abstract.php.


Member Function Documentation

_construct (  )  [protected]

Init block

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 61 of file Abstract.php.

00062     {
00063         $this->addColumnRender('qty', 'adminhtml/sales_items_column_qty', 'sales/items/column/qty.phtml');
00064         $this->addColumnRender('name', 'adminhtml/sales_items_column_name', 'sales/items/column/name.phtml');
00065         parent::_construct();
00066     }

addColumnRender ( column,
block,
template,
type = null 
)

Add column renderer

Parameters:
string $column
string $block
string $template
Returns:
Mage_Adminhtml_Block_Sales_Items_Abstract

Definition at line 94 of file Abstract.php.

00095     {
00096         if (!is_null($type)) {
00097             $column .= '_' . $type;
00098         }
00099         $this->_columnRenders[$column] = array(
00100             'block'     => $block,
00101             'template'  => $template,
00102             'renderer'  => null
00103         );
00104         return $this;
00105     }

addItemRender ( type,
block,
template 
)

Add item renderer

Parameters:
string $type
string $block
string $template
Returns:
Mage_Adminhtml_Block_Sales_Items_Abstract

Definition at line 76 of file Abstract.php.

00077     {
00078         $this->_itemRenders[$type] = array(
00079             'block'     => $block,
00080             'template'  => $template,
00081             'renderer'  => null
00082         );
00083         return $this;
00084     }

canCapture (  ) 

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items.

Definition at line 410 of file Abstract.php.

00411     {
00412         if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/capture')) {
00413             return $this->getInvoice()->canCapture();
00414         }
00415         return false;
00416     }

canCreateShipment (  ) 

INVOICES Check shipment availability for current invoice

Returns:
bool

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items.

Definition at line 378 of file Abstract.php.

00379     {
00380         foreach ($this->getInvoice()->getAllItems() as $item) {
00381             if ($item->getOrderItem()->getQtyToShip()) {
00382                 return true;
00383             }
00384         }
00385         return false;
00386     }

canEditQty (  ) 

Check availability to edit quantity of item

Returns:
boolean

Disable editing of quantity of item if creating of shipment forced and ship partially disabled for order

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items, and Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items.

Definition at line 393 of file Abstract.php.

00394     {
00395         /**
00396          * Disable editing of quantity of item if creating of shipment forced
00397          * and ship partially disabled for order
00398          */
00399         if ($this->getOrder()->getForcedDoShipmentWithInvoice()
00400             && ($this->canShipPartially($this->getOrder()) || $this->canShipPartiallyItem($this->getOrder()))
00401         ) {
00402             return false;
00403         }
00404         if ($this->getOrder()->getPayment()->canCapture()) {
00405             return $this->getOrder()->getPayment()->canCapturePartial();
00406         }
00407         return true;
00408     }

canReturnToStock (  ) 

CREDITMEMO

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items.

Definition at line 447 of file Abstract.php.

00447                                        {
00448         $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT);
00449         if (Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) {
00450             return true;
00451         } else {
00452             return false;
00453         }
00454     }

canShipPartially ( order = null  ) 

Return true if can ship partially

Parameters:
Mage_Sales_Model_Order|null $order
Returns:
boolean

Definition at line 462 of file Abstract.php.

00463     {
00464         if (is_null($order) || !$order instanceof Mage_Sales_Model_Order) {
00465             $order = Mage::registry('current_shipment')->getOrder();
00466         }
00467         $value = $order->getCanShipPartially();
00468         if (!is_null($value) && !$value) {
00469             return false;
00470         }
00471         return true;
00472     }

canShipPartiallyItem ( order = null  ) 

Return true if can ship items partially

Parameters:
Mage_Sales_Model_Order|null $order
Returns:
boolean

Definition at line 480 of file Abstract.php.

00481     {
00482         if (is_null($order) || !$order instanceof Mage_Sales_Model_Order) {
00483             $order = Mage::registry('current_shipment')->getOrder();
00484         }
00485         $value = $order->getCanShipPartiallyItem();
00486         if (!is_null($value) && !$value) {
00487             return false;
00488         }
00489         return true;
00490     }

displayPriceAttribute ( code,
strong = false,
separator = '<br />' 
)

Retrieve price attribute html content

Parameters:
string $code
bool $strong
string $separator
Returns:
string

Definition at line 261 of file Abstract.php.

00262     {
00263         return $this->displayPrices(
00264             $this->getPriceDataObject()->getData('base_'.$code),
00265             $this->getPriceDataObject()->getData($code),
00266             $strong,
00267             $separator
00268         );
00269     }

displayPriceInclTax ( Varien_Object item  ) 

Retrieve include tax html formated content

Parameters:
Varien_Object $item
Returns:
string

Definition at line 303 of file Abstract.php.

00304     {
00305         $qty = ($item->getQtyOrdered() ? $item->getQtyOrdered() : ($item->getQty() ? $item->getQty() : 1));
00306         $baseTax = ($item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0));
00307         $tax = ($item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0));
00308 
00309         return $this->displayPrices(
00310             $this->getOrder()->getStore()->roundPrice($item->getBasePrice()+$baseTax/$qty),
00311             $this->getOrder()->getStore()->roundPrice($item->getPrice()+$tax/$qty)
00312         );
00313     }

displayPrices ( basePrice,
price,
strong = false,
separator = '<br />' 
)

Retrieve price formated html content

Parameters:
float $basePrice
float $price
bool $strong
string $separator
Returns:
string

Definition at line 280 of file Abstract.php.

00281     {
00282         if ($this->getOrder()->isCurrencyDifferent()) {
00283             $res = '';
00284             $res.= $this->getOrder()->formatBasePrice($basePrice);
00285             $res.= $separator;
00286             $res.= $this->getOrder()->formatPrice($price, true);
00287         }
00288         else {
00289             $res = $this->getOrder()->formatPrice($price);
00290             if ($strong) {
00291                 $res = '<strong>'.$res.'</strong>';
00292             }
00293         }
00294         return $res;
00295     }

displaySubtotalInclTax ( item  ) 

Retrieve subtotal price include tax html formated content

Parameters:
Varien_Object $item
Returns:
string

Definition at line 321 of file Abstract.php.

00322     {
00323         $baseTax = ($item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0));
00324         $tax = ($item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0));
00325 
00326         return $this->displayPrices(
00327             $item->getBaseRowTotal()+$baseTax,
00328             $item->getRowTotal()+$tax
00329         );
00330     }

displayTaxCalculation ( Varien_Object item  ) 

Retrieve tax calculation html content

Parameters:
Varien_Object $item
Returns:
string

Definition at line 338 of file Abstract.php.

00339     {
00340         if ($item->getTaxPercent() && $item->getTaxString() == '') {
00341             $percents = array($item->getTaxPercent());
00342         } else if ($item->getTaxString()) {
00343             $percents = explode(Mage_Tax_Model_Config::CALCULATION_STRING_SEPARATOR, $item->getTaxString());
00344         } else {
00345             return '0%';
00346         }
00347 
00348         foreach ($percents as &$percent) {
00349             $percent = sprintf('%.2f%%', $percent);
00350         }
00351         return implode(' + ', $percents);
00352     }

displayTaxPercent ( Varien_Object item  ) 

Retrieve tax with persent html content

Parameters:
Varien_Object $item
Returns:
string

Definition at line 360 of file Abstract.php.

00361     {
00362         if ($item->getTaxPercent()) {
00363             return sprintf('%s%%', $item->getTaxPercent() + 0);
00364         } else {
00365             return '0%';
00366         }
00367     }

formatPrice ( price  ) 

getColumnHtml ( Varien_Object item,
column,
field = null 
)

Retrieve rendered column html content

Parameters:
Varien_Object $item
string $column the column key
string $field the custom item field
Returns:
string

Definition at line 180 of file Abstract.php.

00181     {
00182         if ($item->getOrderItem()) {
00183             $block = $this->getColumnRenderer($column, $item->getOrderItem()->getProductType());
00184         } else {
00185             $block = $this->getColumnRenderer($column, $item->getProductType());
00186         }
00187 
00188         if ($block) {
00189             $block->setItem($item);
00190             if (!is_null($field)) {
00191                 $block->setField($field);
00192             }
00193             return $block->toHtml();
00194         }
00195         return '&nbsp;';
00196     }

getColumnRenderer ( column,
compositePart = '' 
)

Retrieve column renderer block

Parameters:
string $column
string $compositePart
Returns:
Mage_Core_Block_Abstract

Definition at line 136 of file Abstract.php.

00137     {
00138         if (isset($this->_columnRenders[$column . '_' . $compositePart])) {
00139             $column .= '_' . $compositePart;
00140         }
00141         if (!isset($this->_columnRenders[$column])) {
00142             return false;
00143         }
00144         if (is_null($this->_columnRenders[$column]['renderer'])) {
00145             $this->_columnRenders[$column]['renderer'] = $this->getLayout()
00146                 ->createBlock($this->_columnRenders[$column]['block'])
00147                 ->setTemplate($this->_columnRenders[$column]['template'])
00148                 ->setRenderedBlock($this);
00149         }
00150         return $this->_columnRenders[$column]['renderer'];
00151     }

getCreditmemo (  ) 

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items, and Mage_Adminhtml_Block_Sales_Order_Creditmemo_View_Items.

Definition at line 198 of file Abstract.php.

00199     {
00200         return Mage::registry('current_creditmemo');
00201     }

getInvoice (  ) 

Retrieve invoice model instance

Returns:
Mage_Sales_Model_Invoice

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items, and Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items.

Definition at line 438 of file Abstract.php.

00439     {
00440         return Mage::registry('current_invoice');
00441     }

getItemHtml ( Varien_Object item  ) 

Retrieve rendered item html content

Parameters:
Varien_Object $item
Returns:
string

Definition at line 159 of file Abstract.php.

00160     {
00161         if ($item->getOrderItem()) {
00162             $type = $item->getOrderItem()->getProductType();
00163         } else {
00164             $type = $item->getProductType();
00165         }
00166 
00167         return $this->getItemRenderer($type)
00168             ->setItem($item)
00169             ->toHtml();
00170     }

getItemRenderer ( type  ) 

Retrieve item renderer block

Parameters:
string $type
Returns:
Mage_Core_Block_Abstract

Definition at line 113 of file Abstract.php.

00114     {
00115         if (!isset($this->_itemRenders[$type])) {
00116             $type = 'default';
00117         }
00118         if (is_null($this->_itemRenders[$type]['renderer'])) {
00119             $this->_itemRenders[$type]['renderer'] = $this->getLayout()
00120                 ->createBlock($this->_itemRenders[$type]['block'])
00121                 ->setTemplate($this->_itemRenders[$type]['template']);
00122             foreach ($this->_columnRenders as $columnType=>$renderer) {
00123                 $this->_itemRenders[$type]['renderer']->addColumnRender($columnType, $renderer['block'], $renderer['template']);
00124             }
00125         }
00126         return $this->_itemRenders[$type]['renderer'];
00127     }

getOrder (  ) 

######################### SALES ################################## Retrieve available order

Returns:
Mage_Sales_Model_Order

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items, Mage_Adminhtml_Block_Sales_Order_Creditmemo_View_Items, Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items, Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items, Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items, and Mage_Adminhtml_Block_Sales_Order_Shipment_View_Items.

Definition at line 212 of file Abstract.php.

00213     {
00214         if ($this->hasOrder()) {
00215             return $this->getData('order');
00216         }
00217         if (Mage::registry('current_order')) {
00218             return Mage::registry('current_order');
00219         }
00220         if (Mage::registry('order')) {
00221             return Mage::registry('order');
00222         }
00223         if ($this->getInvoice())
00224         {
00225             return $this->getInvoice()->getOrder();
00226         }
00227         if ($this->getCreditmemo())
00228         {
00229             return $this->getCreditmemo()->getOrder();
00230         }
00231         if ($this->getItem()->getOrder())
00232         {
00233             return $this->getItem()->getOrder();
00234         }
00235 
00236         Mage::throwException(Mage::helper('sales')->__('Can\'t get order instance'));
00237     }

getPriceDataObject (  ) 

Retrieve price data object

Returns:
Mage_Sales_Model_Order

Definition at line 244 of file Abstract.php.

00245     {
00246         $obj = $this->getData('price_data_object');
00247         if (is_null($obj)) {
00248             return $this->getOrder();
00249         }
00250         return $obj;
00251     }

getSource (  ) 

isShipmentRegular (  ) 

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items.

Definition at line 492 of file Abstract.php.

00493     {
00494         if (!$this->canShipPartiallyItem() || !$this->canShipPartially()) {
00495             return false;
00496         }
00497         return true;
00498     }


Member Data Documentation

$_columnRenders = array() [protected]

Definition at line 55 of file Abstract.php.

$_itemRenders = array() [protected]

Definition at line 45 of file Abstract.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:58 2009 for Magento by  doxygen 1.5.8