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:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * or OpenGPL v3 license (GNU Public License V3.0)
  9:  * that is bundled with this package in the file LICENSE.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * http://opensource.org/licenses/osl-3.0.php
 12:  * or
 13:  * http://www.gnu.org/licenses/gpl-3.0.txt
 14:  * If you did not receive a copy of the license and are unable to
 15:  * obtain it through the world-wide-web, please send an email
 16:  * to info@e-abi.ee so we can send you a copy immediately.
 17:  *
 18:  * DISCLAIMER
 19:  *
 20:  * Do not edit or add to this file if you wish to upgrade this module to newer
 21:  * versions in the future.
 22:  *
 23:  * @category   Eabi
 24:  * @package    Eabi_Dpd
 25:  * @copyright  Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
 26:  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 27:  * @license    http://www.gnu.org/licenses/gpl-3.0.txt  GNU Public License V3.0
 28:  * @author     Matis Halmann
 29:  * 
 30:  
 31:  */
 32: 
 33: /**
 34:  * <p>Renders yes/no select box with licensing information</p>
 35:  *
 36:  * @author Matis
 37:  */
 38: class Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_License extends Mage_Adminhtml_Block_System_Config_Form_Field {
 39: 
 40:     protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 41:         /*
 42:          * structure
 43:          * array()
 44:          * 
 45:          *
 46:          */
 47:         $stores = Mage::app()->getStores();
 48:         $urls = array();
 49:         foreach ($stores as $store) {
 50:             /* @var $store Mage_Core_Model_Store */
 51:             try {
 52:                 $url = Zend_Uri_Http::fromString($store->getBaseUrl())->getHost();
 53:                 if (!in_array($url, $urls)) {
 54:                     $urls[] = $url;
 55:                 }
 56:             } catch (Exception $ex) {
 57:                 //do nothing or log
 58:                 Mage::log(sprintf('Invalid base url %s for store id %s', $store->getBaseUrl(), $store->getId()), Zend_Log::WARN);
 59: 
 60:             }
 61:         }
 62:         $date = new Zend_Date(time(), Zend_Date::TIMESTAMP);
 63:         $timezone = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
 64:         $date->setTimezone($timezone);
 65:         
 66:         
 67:         $license = array(
 68:             'urls' => $urls,
 69:             'countries' => array(
 70:                 'EE' => array('Y', 'Y', 'Y'),
 71:                 'LV' => array('T', 'T', 'T'),
 72:                 'LT' => array('T', 'N', 'N'),
 73:             ),
 74:             'date' => $date->get(Zend_Date::ISO_8601),
 75:             'sku' => '010125',
 76:             'token' => '12346789',
 77:         );
 78: //        $this->_getOfficeHelper()->setCarrierLicense('eabiomnivaterminal', $license);
 79:         $l = $this->_getOfficeHelper()->getCarrierLicense('eabiomnivaterminal');
 80: //        $license = false;
 81:         $inputData = array(
 82:             "countryName" => Mage::getStoreConfig('general/country/default'), 
 83:             "stateOrProvinceName" => 'N/A',
 84:             "localityName" => 'N/A',
 85:             "organizationName" => 'N/A',
 86:             "organizationalUnitName" => implode(',', $urls),
 87:             "commonName" => 'Aktsiamaailm LLC',
 88:             "emailAddress" => Mage::getStoreConfig('trans_email/ident_general/email'),
 89:         );
 90:         $keys = $this->_getKeypairHelper()->generateKeyPair($inputData);
 91:         
 92:         $text = 'Change license';
 93:         if (!$license) {
 94:             $text = 'Register license';
 95:         }
 96: //        $this->_getEabi()->setConfigData('carriers/eabiomnivaterminal/test', Mage::helper('core')->encrypt('onukala_onukala_onukala_onukala_onukala_onukala_onukala_onukala_onukala'));
 97: 
 98:         return $element->getElementHtml().'<br/>' . '<pre>'.htmlspecialchars(print_r(Mage::getStoreConfig('carriers/eabiomnivaterminal/test'), true), ENT_COMPAT | ENT_HTML401 | ENT_IGNORE).'</pre>'
 99:             . <<<HTML
100:                 <ul class="eabi_postoffice_license">
101:                     <li><strong>{$this->_getOfficeHelper()->__('Basic license')}</strong> {$this->_getBasicLicense($license)}</li>
102:                     <li><strong>{$this->_getOfficeHelper()->__('Automatic data sending')}</strong>{$this->_getDatasendLicense($license)}</li>
103:                     <li><strong>{$this->_getOfficeHelper()->__('Cash on delivery')}</strong>{$this->_getCodLicense($license)}</li>
104:                     <li><strong>{$this->_getOfficeHelper()->__('Allowed for URL-s')}</strong>{$this->_getUrlsLicense($license)}</li>
105:                     <li><strong>&nbsp;</strong><span class="change-license"><a href="">{$this->_getOfficeHelper()->__($text)}</a></span></li>
106:                 </ul>
107: HTML;
108:     }
109:     
110:     protected function _getUrlsLicense($input) {
111:         $urls = $input['urls'];
112:         if (!count($urls)) {
113:             return '<span class="no-license">'.$this->_getOfficeHelper()->__('not-licensed').'</span>';
114:         }
115:         return '<span class="countries">' .implode(', ', $urls).'</span>';
116:     }
117:     protected function _getBasicLicense($input) {
118:         $result = $this->_getGenericLicense($input, 0);
119:         return $result;
120:     }
121:     
122:     protected function _getDatasendLicense($input) {
123:         $result = $this->_getGenericLicense($input, 1);
124:         return $result;
125:     }
126:     
127:     protected function _getCodLicense($input) {
128:         $result = $this->_getGenericLicense($input, 2);
129:         return $result;
130:     }
131:     
132:     private function _getGenericLicense($input, $index) {
133:         $result = array();
134:         $isTimedOut = false;
135:         foreach ($input['countries'] as $countryCode => $data) {
136:             $test = $data[$index];
137:             if ($test == 'Y') {
138:                 $result[] = $this->_getCountryName($countryCode);
139:             } else if ($test == 'T' && !$isTimedOut) {
140:                 $result[] = $this->_getCountryName($countryCode) . '-' . $this->_getOfficeHelper()->__('demo');
141:             }
142:         }
143:         if (!count($result)) {
144:             return '<span class="no-license">'.$this->_getOfficeHelper()->__('not-licensed').'</span>';
145:         }
146:         return '<span class="countries">' .implode(', ', $result).'</span>';
147:     }
148:     
149:     private function _getCountryName($code) {
150:         return Mage::app()->getLocale()->getCountryTranslation($code);
151:     }
152: 
153: 
154:     private function _toJson($input) {
155:         return json_encode($input);
156:     }
157:     
158:     /**
159:      * 
160:      * @return Eabi_Postoffice_Helper_Data
161:      */
162:     protected function _getOfficeHelper() {
163:         return Mage::helper('eabi_postoffice');
164:     }
165:     
166:     /**
167:      * 
168:      * @return Eabi_Livehandler_Helper_Keypair
169:      */
170:     protected function _getKeypairHelper() {
171:         return Mage::helper('eabi/keypair');
172:     }
173:     
174:     
175:     /**
176:      * 
177:      * @return Eabi_Livehandler_Helper_Data
178:      */
179:     protected function _getEabi() {
180:         return Mage::helper('eabi');
181:     }
182: 
183: }
184: 
185: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0