1
13693261870
2022-09-16 06df9667ad1465622bf0e423dc3840ef9f93c725
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
class TestAction {
    function doEcho($data){
        return $data;
    }
 
    function multiply($num){
        if(!is_numeric($num)){
            throw new Exception('Call to multiply with a value that is not a number');
        }
        return $num*8;
    }
 
    function getTree($id){
        $out = array();
        if($id == "root"){
            for($i = 1; $i <= 5; ++$i){
                array_push($out, array(
                    'id'=>'n' . $i,
                    'text'=>'Node ' . $i,
                    'leaf'=>false
                ));
            }
        }else if(strlen($id) == 2){
            $num = substr($id, 1);
            for($i = 1; $i <= 5; ++$i){
                array_push($out, array(
                    'id'=>$id . $i,
                    'text'=>'Node ' . $num . '.' . $i,
                    'leaf'=>true
                ));
            }
        }
        return $out;
    }
    
    function getGrid($params){
        $sort = $params->sort[0];
        $field = $sort->property;
        $direction = $sort->direction;
        
        /*
         * Here we would apply a proper sort from the DB, but since
         * it's such a small dataset we will just sort by hand here.
         */
         
        if ($field == 'name') {
            $data = array(array(
                'name'=>'ABC Accounting',
                'turnover'=>50000
            ), array(
                'name'=>'Ezy Video Rental',
                'turnover'=>106300
            ), array(
                'name'=>'Greens Fruit Grocery',
                'turnover'=>120000
            ), array(
                'name'=>'Icecream Express',
                'turnover'=>73000
            ), array(
                'name'=>'Ripped Gym',
                'turnover'=>88400
            ), array(
                'name'=>'Smith Auto Mechanic',
                'turnover'=>222980
            ));
        } else {
            $data = array(array(
                'name'=>'ABC Accounting',
                'turnover'=>50000
            ), array(
                'name'=>'Icecream Express',
                'turnover'=>73000
            ), array(
                'name'=>'Ripped Gym',
                'turnover'=>88400
            ), array(
                'name'=>'Ezy Video Rental',
                'turnover'=>106300
            ), array(
                'name'=>'Greens Fruit Grocery',
                'turnover'=>120000
            ), array(
                'name'=>'Smith Auto Mechanic',
                'turnover'=>222980
            ));
        }
        if ($direction == 'DESC') {
            $data = array_reverse($data);
        }
        return $data;
    }
    
    function showDetails($data){
        $first = $data->firstName;
        $last = $data->lastName; 
        $age = $data->age;
        return "Hi $first $last, you are $age years old.";
    }
}