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>Renders button at the Magento Administrators Sales Order Grid, which allows to send parcel data to remote server for carriers which support this feature.</p>
 36:  * <p>Button is displayed when order shipping method supports automatic parcel data sending and parcel data is not already sent.</p>
 37:  * <p>Does nothing when Eabi_Postoffice module is not installed</p>
 38:  *
 39:  * @author Matis
 40:  */
 41: class Eabi_Livehandler_Model_Action_Postoffice_Send extends Eabi_Livehandler_Model_Action_Abstract {
 42:     /**
 43:      * <p>Unique code relative to eabi_livehandler/action</p>
 44:      * @var string
 45:      */
 46:     protected $_code = 'postoffice_send';
 47:     protected $_label;
 48:     private static $_module_exists;
 49:     
 50:     public function __construct() {
 51:         if (self::$_module_exists === null) {
 52:             $modulesArray = (array)Mage::getConfig()->getNode('modules')->children();
 53:             self::$_module_exists = isset($modulesArray['Eabi_Postoffice']);
 54:         }
 55:         
 56:     }
 57: 
 58: 
 59: 
 60: 
 61:     /**
 62:      * @param Mage_Sales_Model_Order $order
 63:      * @return boolean
 64:      */
 65:     public function canDisplay(Mage_Sales_Model_Order $order) {
 66:         if (self::$_module_exists) {
 67:             $this->_label = $this->_getOfficeHelper()->__('Send shipping data to server');
 68:             if ($this->_getOfficeHelper()->isDataSent($order->getIncrementId()) === false) {
 69:                 $barcode = $this->_getOfficeHelper()->getBarcode($order->getIncrementId());
 70:                 if (is_string($barcode)) {
 71:                     return false;
 72:                 }
 73: 
 74:                 return true;
 75:             }
 76:         }
 77:         return false;
 78:     }
 79: 
 80:     /**
 81:      * <p>Calls out automatic data send action for selected order and returns the result.</p>
 82:      * <p>Does not support custom POST params</p>
 83:      * @param Mage_Sales_Model_Order $order current order
 84:      * @param array $params supplied POST params
 85:      * @return boolean|array
 86:      */
 87:     public function performDesiredAction(Mage_Sales_Model_Order $order, array $params) {
 88:         
 89:         //get the carrier
 90:         $shippingMethod = $order->getShippingMethod();
 91:         $paymentMethod = $order->getPayment();
 92:         $errors = array();
 93:         //get the shipping code from the order and call the module from it.
 94:         $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
 95:         $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode, $order->getStoreId());
 96:         
 97:         if (!($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)){
 98:             $errors[] = $this->_getOfficeHelper()->__('This carrier is not subclass of Eabi_Postoffice_Model_Carrier_Abstract');
 99:         }
100:         $shippingMethodModel->setStoreId($order->getStoreId());
101:         
102:         //determine if auto send is available
103:         if (!count($errors) && !$shippingMethodModel->isAutoSendAvailable()) {
104:             $errors[] = $this->_getOfficeHelper()->__('Automatic data sending is not available for the selected carrier');
105:         }
106:         
107:         if (!method_exists($this->_getOfficeHelper(), 'canSendData')) {
108:             //old version of eabi_postoffice package, they have no canSendData function
109:             if (!count($errors) && round($order->getTotalDue(), 2) > 0 && (!$shippingMethodModel->getConfigData('enable_cod') ||
110:                     (!count($errors) && $shippingMethodModel->getConfigData('enable_cod') && $paymentMethod->getMethod() != 'eabicodpayment'))) {
111:                 $errors[] = $this->_getOfficeHelper()->__('This order has not yet been fully paid');
112:             }
113:         } else {
114:             if (!$this->_getOfficeHelper()->canSendData($order)) {
115:                 $errors[] = $this->_getOfficeHelper()->__('This order has not yet been fully paid');
116:             }
117:         }
118: 
119: 
120: 
121: 
122:         if (!count($errors) && ($order->isCanceled() || $order->getIsVirtual())) {
123:             $errors[] = $this->_getOfficeHelper()->__('This order cannot be shipped');
124:         }
125:         
126:         
127:         //send the data
128:         $messages = array();
129:         if (!count($errors)) {
130:             $this->_getOfficeHelper()->sendManualOrderData($order->getIncrementId(), $shippingMethodModel->getConfigData('senddata_event'));
131:             $messages[] = $this->_getOfficeHelper()->__('Data sent to server, please verify the status from the order comments');
132:             
133:         }
134:         
135:         
136:         $result = array(
137:             'messages' => $messages,
138:             'errors' => $errors,
139:             'needs_reload' => false,
140:             'is_action_error' => false,
141:         );
142:         return $result;
143:     }
144:     
145:     /**
146:      * 
147:      * @return Eabi_Postoffice_Helper_Data
148:      */
149:     protected function _getOfficeHelper() {
150:         return Mage::helper('eabi_postoffice');
151:     }
152:     
153: }
154: 
155: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0