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_Catalog_Product_Helper_Form_Price extends Varien_Data_Form_Element_Text
00035 {
00036
00037 public function __construct($attributes=array())
00038 {
00039 parent::__construct($attributes);
00040 $this->addClass('validate-zero-or-greater');
00041 }
00042
00043 public function getAfterElementHtml()
00044 {
00045 $html = parent::getAfterElementHtml();
00046
00047
00048
00049 $addJsObserver = false;
00050 if ($attribute = $this->getEntityAttribute()) {
00051 if (!($storeId = $attribute->getStoreId())) {
00052 $storeId = $this->getForm()->getDataObject()->getStoreId();
00053 }
00054 $store = Mage::app()->getStore($storeId);
00055 $html.= '<strong>['.(string)$store->getBaseCurrencyCode().']</strong>';
00056 if (Mage::helper('tax')->priceIncludesTax()) {
00057 if ($attribute->getAttributeCode()!=='cost') {
00058 $addJsObserver = true;
00059 $html.= ' <strong>['.Mage::helper('tax')->__('Inc. Tax').'<span id="dynamic-tax-'.$attribute->getAttributeCode().'"></span>]</strong>';
00060 }
00061 }
00062 }
00063 if ($addJsObserver) {
00064 $html .= $this->_getTaxObservingCode($attribute);
00065 }
00066
00067 return $html;
00068 }
00069
00070 protected function _getTaxObservingCode($attribute)
00071 {
00072 $spanId = "dynamic-tax-{$attribute->getAttributeCode()}";
00073
00074 $html = "<script>if (dynamicTaxes == undefined) var dynamicTaxes = new Array(); dynamicTaxes[dynamicTaxes.length]='{$attribute->getAttributeCode()}'</script>";
00075 return $html;
00076 }
00077
00078 public function getEscapedValue($index=null)
00079 {
00080 $value = $this->getValue();
00081
00082 if (!is_numeric($value)) {
00083 return null;
00084 }
00085
00086 return number_format($value, 2, null, '');
00087 }
00088
00089 }
00090