1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sales
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Sales module base helper
29: *
30: * @category Mage
31: * @package Mage_Sales
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Sales_Helper_Data extends Mage_Core_Helper_Data
35: {
36: /**
37: * Maximum available number
38: */
39: const MAXIMUM_AVAILABLE_NUMBER = 99999999;
40:
41: /**
42: * Check quote amount
43: *
44: * @param Mage_Sales_Model_Quote $quote
45: * @param decimal $amount
46: * @return Mage_Sales_Helper_Data
47: */
48: public function checkQuoteAmount(Mage_Sales_Model_Quote $quote, $amount)
49: {
50: if (!$quote->getHasError() && ($amount>=self::MAXIMUM_AVAILABLE_NUMBER)) {
51: $quote->setHasError(true);
52: $quote->addMessage(
53: $this->__('Items maximum quantity or price do not allow checkout.')
54: );
55: }
56: return $this;
57: }
58:
59: /**
60: * Check allow to send new order confirmation email
61: *
62: * @param mixed $store
63: * @return bool
64: */
65: public function canSendNewOrderConfirmationEmail($store = null)
66: {
67: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, $store);
68: }
69:
70: /**
71: * Check allow to send new order email
72: *
73: * @param mixed $store
74: * @return bool
75: */
76: public function canSendNewOrderEmail($store = null)
77: {
78: return $this->canSendNewOrderConfirmationEmail($store);
79: }
80:
81: /**
82: * Check allow to send order comment email
83: *
84: * @param mixed $store
85: * @return bool
86: */
87: public function canSendOrderCommentEmail($store = null)
88: {
89: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order::XML_PATH_UPDATE_EMAIL_ENABLED, $store);
90: }
91:
92: /**
93: * Check allow to send new shipment email
94: *
95: * @param mixed $store
96: * @return bool
97: */
98: public function canSendNewShipmentEmail($store = null)
99: {
100: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Shipment::XML_PATH_EMAIL_ENABLED, $store);
101: }
102:
103: /**
104: * Check allow to send shipment comment email
105: *
106: * @param mixed $store
107: * @return bool
108: */
109: public function canSendShipmentCommentEmail($store = null)
110: {
111: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Shipment::XML_PATH_UPDATE_EMAIL_ENABLED, $store);
112: }
113:
114: /**
115: * Check allow to send new invoice email
116: *
117: * @param mixed $store
118: * @return bool
119: */
120: public function canSendNewInvoiceEmail($store = null)
121: {
122: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_ENABLED, $store);
123: }
124:
125: /**
126: * Check allow to send invoice comment email
127: *
128: * @param mixed $store
129: * @return bool
130: */
131: public function canSendInvoiceCommentEmail($store = null)
132: {
133: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Invoice::XML_PATH_UPDATE_EMAIL_ENABLED, $store);
134: }
135:
136: /**
137: * Check allow to send new creditmemo email
138: *
139: * @param mixed $store
140: * @return bool
141: */
142: public function canSendNewCreditmemoEmail($store = null)
143: {
144: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Creditmemo::XML_PATH_EMAIL_ENABLED, $store);
145: }
146:
147: /**
148: * Check allow to send creditmemo comment email
149: *
150: * @param mixed $store
151: * @return bool
152: */
153: public function canSendCreditmemoCommentEmail($store = null)
154: {
155: return Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Creditmemo::XML_PATH_UPDATE_EMAIL_ENABLED, $store);
156: }
157:
158: /**
159: * Get old field map
160: *
161: * @param string $entityId
162: * @return array
163: */
164: public function getOldFieldMap($entityId)
165: {
166: $node = Mage::getConfig()->getNode('global/sales/old_fields_map/' . $entityId);
167: if ($node === false) {
168: return array();
169: }
170: return (array) $node;
171: }
172: }
173: