SalesAdminOld::Reports()   C
last analyzed

Complexity

Conditions 7
Paths 4

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 14
nc 4
nop 0
1
<?php
2
/**
3
 * @author Nicolaas [at] sunnysideup.co.nz
4
 */
5
class SalesAdminOld extends ReportAdmin
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    public static $url_segment = 'salesold';
8
9
    public static $url_rule = '/$Action/$ID';
10
11
    public static $menu_title = 'Sales';
12
13
    public static $template_path = null; // defaults to (project)/templates/email
14
15
    public function init()
16
    {
17
        parent::init();
18
        //generic requirements
19
        Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js");
20
        Requirements::javascript(THIRDPARTY_DIR."/jquery-livequery/jquery.livequery.js");
21
        Requirements::javascript(THIRDPARTY_DIR."/jquery-form/jquery.form.js");
22
23
24
        //payment requirements
25
        Requirements::javascript("ecommercextras/javascript/PaymentsReport.js");
26
        Requirements::customScript('var PaymentsReportURL = "'.Director::baseURL()."PaymentsReport_Handler".'/";', 'PaymentsReport_Handler_Base_URL');
0 ignored issues
show
Documentation introduced by
'var PaymentsReportURL =...Report_Handler' . '/";' is of type string, but the function expects a object<The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'PaymentsReport_Handler_Base_URL' is of type string, but the function expects a object<Use>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
        $list = singleton('Payment')->dbObject('Status')->enumValues();
28
        $js = '';
29
        foreach ($list as $key => $value) {
30
            if ($key && $value) {
31
                $js .= 'PaymentsReport.addStatus("'.$value.'");';
32
            }
33
        }
34
        Requirements::customScript($js, "PaymentsReport_Handler_PaymentStatusList");
0 ignored issues
show
Documentation introduced by
$js is of type string, but the function expects a object<The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'PaymentsReport_Handler_PaymentStatusList' is of type string, but the function expects a object<Use>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
36
        //sales report
37
        Requirements::javascript("ecommercextras/javascript/SalesReport.js");
38
        Requirements::customScript('var SalesReportURL = "'.Director::baseURL()."SalesReport_Handler".'/";', 'SalesReport_Handler_Base_URL');
0 ignored issues
show
Documentation introduced by
'var SalesReportURL = "'...Report_Handler' . '/";' is of type string, but the function expects a object<The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'SalesReport_Handler_Base_URL' is of type string, but the function expects a object<Use>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
        $list = OrderDecorator::get_order_status_options();
40
        $js = '';
41
        foreach ($list as $key => $value) {
42
            if ($key && $value) {
43
                $js .= 'SalesReport.addStatus("'.$value.'");';
44
            }
45
        }
46
        Requirements::customScript($js, "SalesReport_Handler_OrderStatusList");
0 ignored issues
show
Documentation introduced by
$js is of type string, but the function expects a object<The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'SalesReport_Handler_OrderStatusList' is of type string, but the function expects a object<Use>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
    }
48
49
    /**
50
     * Does the parent permission checks, but also
51
     * makes sure that instantiatable subclasses of
52
     * {@link Report} exist. By default, the CMS doesn't
53
     * include any Reports, so there's no point in showing
54
     *
55
     * @param Member $member
56
     * @return boolean
57
     */
58
59
60
    /**
61
     * Return a DataObjectSet of SSReport subclasses
62
     * that are available for use.
63
     *
64
     * @return DataObjectSet
65
     */
66
    public function Reports()
67
    {
68
        $processedReports = array();
69
        $subClasses = ClassInfo::subclassesFor('SalesReport');
70
71
        if ($subClasses) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $subClasses of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
72
            foreach ($subClasses as $subClass) {
73
                if ($subClass != 'SalesReport') {
74
                    $processedReports[] = new $subClass();
75
                }
76
            }
77
        }
78
        $subClasses = ClassInfo::subclassesFor('PaymentsReport');
79
80
        if ($subClasses) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $subClasses of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
81
            foreach ($subClasses as $subClass) {
82
                if ($subClass != "PaymentsReport") {
83
                    $processedReports[] = new $subClass();
84
                }
85
            }
86
        }
87
88
        $reports = new DataObjectSet($processedReports);
89
90
        return $reports;
91
    }
92
}
93