summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Object/ReportParameter.php
blob: 0b70710d48ce9962eb807d8b693fdc6049d3d4da (plain)
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
<?php

/**
 * Description of ExecutionParameters
 *
 * @author andrew
 */
class SSRS_Object_ReportParameter extends SSRS_Object_Abstract {

    public function __construct($name, $value) {
        $this->name = $name;
        $this->value = $value;
    }

    public $name;
    public $value;

    public function getDefaultValue() {
        $default = null;

        if (key_exists('DefaultValues', $this->data)) {
            $default = $this->data['DefaultValues']->Value;
        }

        return in_array($default, $this->getValidValues()) ? $default : null;
    }

    public function getValidValues() {
        $data = array();

        if (key_exists('ValidValues', $this->data)) {
            $data = array();

            if (is_object($this->data['ValidValues']->ValidValue)) {
                $data[$this->data['ValidValues']->ValidValue->Label] = $this->data['ValidValues']->ValidValue->Value;
            } else {
                foreach ($this->data['ValidValues']->ValidValue AS $value) {
                    $data[$value->Label] = $value->Value;
                }
            }

            if (!empty($this->data['AllowBlank'])) {
                $data['AllowBlank'] = '';
            }
        }

        return $data;
    }

    public function hasDependencies() {
        return (isset($this->data['Dependencies']->Dependency)
                && !empty($this->data['Dependencies']->Dependency));
    }

    public function getDependencies() {
        return (array) $this->data['Dependencies']->Dependency;
    }

    public function hasOutstandingDependencies() {
        return ($this->getState() == 'HasOutstandingDependencies');
    }

    public function getState() {
        return key_exists('State', $this->data) ? $this->data['State'] : null;
    }

    public function isMultiValue() {
        return !empty($this->data['MultiValue']);
    }

}