Overview

Namespaces

  • None
  • PHP

Classes

  • Eabi_DpdEE_Block_Adminhtml_Config_Form_Field_Country
  • Eabi_DpdEE_Block_Info_Payment
  • Eabi_DpdEE_Block_Invoice
  • Eabi_DpdEE_Block_Order_Courier
  • Eabi_DpdEE_Helper_Data
  • Eabi_DpdEE_Model_Api
  • Eabi_DpdEE_Model_Button_Courier
  • Eabi_DpdEE_Model_Config
  • Eabi_DpdEE_Model_Flat
  • Eabi_DpdEE_Model_Observer
  • Eabi_DpdEE_Model_Payment_Processor
  • Eabi_DpdEE_Model_Post
  • Eabi_DpdEE_Model_Source_Label_Position
  • Eabi_DpdEE_Model_Source_Service
  • Eabi_Livehandler_Adminhtml_LivehandlerController
  • Eabi_Livehandler_Adminhtml_RemoveController
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Button
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Livehandler_Block_Email
  • Eabi_LiveHandler_Block_Footer
  • Eabi_Livehandler_Helper_Data
  • Eabi_Livehandler_Helper_Keypair
  • Eabi_Livehandler_IndexController
  • Eabi_Livehandler_Model_Abstract
  • Eabi_Livehandler_Model_Action_Abstract
  • Eabi_Livehandler_Model_Action_Postoffice_Print
  • Eabi_Livehandler_Model_Action_Postoffice_Send
  • Eabi_Livehandler_Model_Adminhtml_Gridmanager
  • Eabi_Livehandler_Model_Directory_Collection
  • Eabi_Livehandler_Model_Entry
  • Eabi_Livehandler_Model_File_Object
  • Eabi_Livehandler_Model_Mysql4_Entry
  • Eabi_Livehandler_Model_Mysql4_Entry_Collection
  • Eabi_Livehandler_Model_Ordergrid
  • Eabi_Livehandler_Model_System_Config_Backend_Button
  • Eabi_Postoffice_Adminhtml_PostofficeController
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_License
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Postoffice_Block_Config_Rebuildbutton
  • Eabi_Postoffice_Helper_Countrycode
  • Eabi_Postoffice_Helper_Data
  • Eabi_Postoffice_IndexController
  • Eabi_Postoffice_Model_Carrier_Abstract
  • Eabi_Postoffice_Model_Carrier_Result
  • Eabi_Postoffice_Model_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule_Collection
  • Eabi_Postoffice_Model_Mysql4_Office
  • Eabi_Postoffice_Model_Mysql4_Office_Collection
  • Eabi_Postoffice_Model_Observer
  • Eabi_Postoffice_Model_Office
  • Eabi_Postoffice_Model_Orderview
  • Eabi_Postoffice_Model_Source_Sendevent
  • Eabi_Postoffice_Model_Updater
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /*
  4:   
  5:  *
  6:  * NOTICE OF LICENSE
  7:  *
  8:  * This source file is subject to the Open Software License (OSL 3.0)
  9:  * or OpenGPL v3 license (GNU Public License V3.0)
 10:  * that is bundled with this package in the file LICENSE.txt.
 11:  * It is also available through the world-wide-web at this URL:
 12:  * http://opensource.org/licenses/osl-3.0.php
 13:  * or
 14:  * http://www.gnu.org/licenses/gpl-3.0.txt
 15:  * If you did not receive a copy of the license and are unable to
 16:  * obtain it through the world-wide-web, please send an email
 17:  * to info@e-abi.ee so we can send you a copy immediately.
 18:  *
 19:  * DISCLAIMER
 20:  *
 21:  * Do not edit or add to this file if you wish to upgrade this module to newer
 22:  * versions in the future.
 23:  *
 24:  * @category   Eabi
 25:  * @package    Eabi_Dpd
 26:  * @copyright  Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
 27:  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 28:  * @license    http://www.gnu.org/licenses/gpl-3.0.txt  GNU Public License V3.0
 29:  * @author     Matis Halmann
 30:  * 
 31: 
 32:  */
 33: 
 34: /**
 35:  * <p>Displays list of countries at the shipping modules configuration field.</p>
 36:  * <p>Number of countries are unlimited and if more than one of the same country exist in the list, then last country declaration overrrides previous one.</p>
 37:  * <p>Each country declaration contains following:</p>
 38:  * <ul>
 39:      <li>Base shipping price</li>
 40:      <li>Additional price for each Kilogram. (data is taken from products weight field)</li>
 41:      <li>Free shipping starts from price (Without VAT). Free shipping is disabled when this field is left empty.</li>
 42:      <li>Cash on Delivery fee. Cash on delivery is disabled, when field is left empty.</li>
 43:  </ul>
 44:  *
 45:  * @author Matis
 46:  */
 47: class Eabi_DpdEE_Block_Adminhtml_Config_Form_Field_Country extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
 48:     
 49:     public function __construct() {
 50: 
 51:         $this->addColumn('country_id', array(
 52:             'label' => $this->_getDpdHelper()->__('Country'),
 53:             'style' => 'width:120px',
 54:             'type' => 'select',
 55:             'source_model' => 'adminhtml/system_config_source_country',
 56: /*            'class' => 'validate-code',*/
 57:         ));
 58:         $this->addColumn('base_price', array(
 59:             'label' => $this->_getDpdHelper()->__('Base shipping price'),
 60:             'style' => 'width:120px',
 61:             'class' => 'validate-number',
 62:         ));
 63:         $this->addColumn('kg_price', array(
 64:             'label' => $this->_getDpdHelper()->__('Price per additional 10kg over base 10kg'),
 65:             'style' => 'width:120px',
 66:             'class' => 'validate-number',
 67:         ));
 68:         $this->addColumn('free_shipping_from', array(
 69:             'label' => $this->_getDpdHelper()->__('Free shipping from price'),
 70:             'style' => 'width:120px',
 71:         ));
 72:         $this->addColumn('cod_fee', array(
 73:             'label' => $this->_getDpdHelper()->__('Cash on delivery fee'),
 74:             'style' => 'width:120px',
 75:         ));
 76:         $this->_addAfter = false;
 77:         $this->_addButtonLabel = $this->_getDpdHelper()->__('Add shipping country');
 78:         parent::__construct();
 79:         
 80:     }
 81:     
 82:     
 83:     
 84:     /**
 85:      * Add a column to array-grid
 86:      *
 87:      * @param string $name
 88:      * @param array $params
 89:      */
 90:     public function addColumn($name, $params) {
 91:         $this->_columns[$name] = array(
 92:             'label'     => empty($params['label']) ? 'Column' : $params['label'],
 93:             'size'      => empty($params['size'])  ? false    : $params['size'],
 94:             'style'     => empty($params['style'])  ? null    : $params['style'],
 95:             'class'     => empty($params['class'])  ? null    : $params['class'],
 96:             'type'     => empty($params['type'])  ? null    : $params['type'],
 97:             'source_model'     => empty($params['source_model'])  ? null    : $params['source_model'],
 98:             'renderer'  => false,
 99:         );
100:         if ((!empty($params['renderer'])) && ($params['renderer'] instanceof Mage_Core_Block_Abstract)) {
101:             $this->_columns[$name]['renderer'] = $params['renderer'];
102:         }
103:     }
104:     
105:     
106:     
107:     /**
108:      * Since select menus are not supported and renderer does not work when single quotes are included in the select value list
109:      * then we need to override this method to support select dropdowns
110:      *
111:      * @param string $columnName
112:      * @return string
113:      */
114:     protected function _renderCellTemplate($columnName) {
115:         if (empty($this->_columns[$columnName])) {
116:             throw new Exception('Wrong column name specified.');
117:         }
118:         $column     = $this->_columns[$columnName];
119:         $inputName  = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
120: 
121:         if ($column['renderer']) {
122:             return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)
123:                 ->toHtml();
124:         }
125:         
126:         if (isset($column['type']) && $column['type']) {
127:             if ($column['type'] == 'select') {
128:                 $html = '<select name="' . $inputName . '"   value="#{' . $columnName . '}" ' .
129:                         ($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
130:                         (isset($column['class']) ? $column['class'] : 'input-text') . '"' .
131:                         (isset($column['style']) ? ' style="' . $column['style'] . '"' : '') . '/>';
132:                 
133:                 $options = Mage::getModel($column['source_model'])->toOptionArray();
134:                 foreach ($options as $option) {
135:                     $html .= '<option value="' . htmlspecialchars($option['value']);
136:                     $html .= '" ';
137:                     $html .= '>';
138:                     $html .= htmlspecialchars($option['label'], ENT_QUOTES, 'UTF-8');
139:                     $html .= '</option>';
140:                 }
141:                 $html .= '</select>';
142:                 
143:                 
144:                 return $html;
145:             }
146:         }
147: 
148:         return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
149:             ($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
150:             (isset($column['class']) ? $column['class'] : 'input-text') . '"'.
151:             (isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
152:     }
153:     
154:     
155:     
156:     /**
157:      * Because JS Prototype Template engine does not support html select value updates, then we need to override
158:      * toHtml method in order to set select values manually after page load.
159:      *
160:      * @return string
161:      */
162:     protected function _toHtml() {
163:         $this->setHtmlId('_'.  uniqid());
164:         if (!$this->_isPreparedToRender) {
165:             $this->_prepareToRender();
166:             $this->_isPreparedToRender = true;
167:         }
168:         if (empty($this->_columns)) {
169:             throw new Exception('At least one column must be defined.');
170:         }
171:         return parent::_toHtml().<<<JS
172: <script type="text/javascript">
173:     // <![CDATA[
174:     document.observe('dom:loaded', function() {
175:         $$('#grid{$this->getHtmlId()} select').each(function(iterator) {
176:             iterator.setValue(iterator.readAttribute('value'));
177:         });
178:     });
179:     // ]]>
180: </script>
181: JS;
182:     }
183:     
184:     
185:     
186:     
187:     /**
188:      * 
189:      * @return Eabi_DpdEE_Helper_Data
190:      */
191:     protected function _getDpdHelper() {
192:         return Mage::helper('eabi_dpdee');
193:     }
194:     
195:     
196: }
197: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0