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_Adminhtml
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: * Adminhtml sales order create payment method form block
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Sales_Order_Create_Billing_Method_Form extends Mage_Payment_Block_Form_Container
35: {
36: /**
37: * Check payment method model
38: *
39: * @return bool
40: */
41: protected function _canUseMethod($method)
42: {
43: if (!$method->canUseInternal()) {
44: return false;
45: }
46: return parent::_canUseMethod($method);
47: }
48:
49: /**
50: * Check existing of payment methods
51: *
52: * @return bool
53: */
54: public function hasMethods()
55: {
56: $methods = $this->getMethods();
57: if (is_array($methods) && count($methods)) {
58: return true;
59: }
60: return false;
61: }
62:
63: /**
64: * Get current payment method code or the only available, if there is only one method
65: *
66: * @return string|false
67: */
68: public function getSelectedMethodCode()
69: {
70: // One available method. Return this method as selected, because no other variant is possible.
71: $methods = $this->getMethods();
72: if (count($methods) == 1) {
73: foreach ($methods as $method) {
74: return $method->getCode();
75: }
76: }
77:
78: // Several methods. If user has selected some method - then return it.
79: $currentMethodCode = $this->getQuote()->getPayment()->getMethod();
80: if ($currentMethodCode) {
81: return $currentMethodCode;
82: }
83:
84: // Several methods, but no preference for one of them.
85: return false;
86: }
87:
88: /**
89: * Enter description here...
90: *
91: * @return Mage_Sales_Model_Quote
92: */
93: public function getQuote()
94: {
95: return Mage::getSingleton('adminhtml/session_quote')->getQuote();
96: }
97:
98: /*
99: * Whether switch/solo card type available
100: */
101: public function hasSsCardType()
102: {
103: $availableTypes = explode(',', $this->getQuote()->getPayment()->getMethod()->getConfigData('cctypes'));
104: $ssPresenations = array_intersect(array('SS', 'SM', 'SO'), $availableTypes);
105: if ($availableTypes && count($ssPresenations) > 0) {
106: return true;
107: }
108: return false;
109: }
110:
111: }
112: