Completed
Push — master ( b0bf1d...042f37 )
by Andreas
14:04
created

org_openpsa_sales_viewer::_on_handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * @package org.openpsa.sales
4
 * @author The Midgard Project, http://www.midgard-project.org
5
 * @copyright The Midgard Project, http://www.midgard-project.org
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
/**
10
 * Sales viewer interface class.
11
 *
12
 * @package org.openpsa.sales
13
 */
14
class org_openpsa_sales_viewer extends midcom_baseclasses_components_viewer
15
{
16
    /**
17
     * Generic request startup work:
18
     *
19
     * - Add the LINK HTML HEAD elements
20
     */
21 13
    public function _on_handle($handler, array $args)
22
    {
23 13
        $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.sales/sales.css");
24
25 13
        midcom::get()->auth->require_valid_user();
26 13
    }
27
28
    public static function get_unit_options()
29
    {
30
        $unit_options = midcom_baseclasses_components_configuration::get('org.openpsa.products', 'config')->get('unit_options');
31
        $l10n = midcom::get()->i18n->get_l10n('org.openpsa.products');
32
        $options = [];
33
        foreach ($unit_options as $key => $name) {
34
            $options[$key] = $l10n->get($name);
35
        }
36
        return $options;
37
    }
38
39
    public static function get_unit_option($unit)
40
    {
41
        $unit_options = self::get_unit_options();
42
        if (array_key_exists($unit, $unit_options)) {
43
            return $unit_options[$unit];
44
        }
45
        return '';
46
    }
47
}
48