Mygento_Payture_Block_Info::getOrder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/**
4
 *
5
 *
6
 * @category Mygento
7
 * @package Mygento_Payture
8
 * @copyright Copyright © 2016 NKS LLC. (http://www.mygento.ru)
9
 */
10
class Mygento_Payture_Block_Info extends Mage_Payment_Block_Info
11
{
12
13
    public function getOid()
14
    {
15
        $info = $this->getInfo();
16
        if ($info instanceof Mage_Sales_Model_Order_Payment) {
17
            $order = $info->getOrder();
18
            //$id=$order->getData('increment_id');
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
            //$order=Mage::getSingleton('sales/order')->loadByIncrementId($id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
20
            return $order->getId();
21
        }
22
        return false;
23
    }
24
25
    public function getPaylink()
26
    {
27
        return Mage::helper('payture')->getLink($this->getOid());
28
    }
29
30
    public function isPaid()
31
    {
32
        $order = Mage::getModel('sales/order')->load($this->getOid());
33
        if (!$order->hasInvoices()) {
34
            return false;
35
        }
36
        return true;
37
    }
38
39
    protected function _construct()
40
    {
41
        parent::_construct();
42
        $this->setTemplate('mygento/payture/info.phtml');
43
    }
44
45
    public function getOrder()
46
    {
47
        $info = $this->getInfo();
48
        if ($info instanceof Mage_Sales_Model_Order_Payment) {
49
            return $info->getOrder();
50
        }
51
    }
52
53
    public function getTotalSum()
54
    {
55
        $info = $this->getInfo();
56
        if ($info instanceof Mage_Sales_Model_Order_Payment) {
57
            $order = $info->getOrder();
58
            return round($order->getGrandTotal(), 2);
59
        }
60
    }
61
62
    public function getRefundlink()
63
    {
64
        return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/refund/", array('_secure' => true, 'order' => $this->getOid()));
65
    }
66
67
    public function getUnblockTransactionlink()
68
    {
69
        return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/cancel/", array('_secure' => true, 'order' => $this->getOid()));
70
    }
71
72
    public function getAcceptTransactionlink()
73
    {
74
        return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/complete/", array('_secure' => true, 'order' => $this->getOid()));
75
    }
76
77 View Code Duplication
    public function getState()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
    {
79
        $collection = Mage::getModel('payture/keys')->getCollection();
80
        $collection->addFieldToFilter('orderid', $this->getOid());
81
        if (count($collection) == 0) {
82
            return false;
83
        }
84
        $item = $collection->getFirstItem();
85
        return $item->getState();
86
    }
87
88
    public function getPaytureName()
89
    {
90
        return $this->escapeHtml(Mage::getStoreConfig('payment/payture/title'));
91
    }
92
}
93