editCardealerWorkorder()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 28
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 20
nc 6
nop 1
dl 0
loc 28
rs 9.6
c 1
b 0
f 0
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * Module: cardealer
15
 *
16
 * @category        Module
17
 * @package         cardealer
18
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GPL 2.0 or later
21
 * @link            https://xoops.org/
22
 * @since           1.0.0
23
 */
24
25
use XoopsModules\Cardealer;
26
27
//require dirname(__DIR__) . '/class/utility.php';
28
/**
29
 * @param $options
30
 *
31
 * @return array
32
 */
33
function showCardealerWorkorder($options)
34
{
35
36
    $block          = [];
37
    $blockType      = $options[0];
38
    $workorderCount = $options[1];
39
    //$titleLenght = $options[2];
40
41
    /** @var \XoopsPersistableObjectHandler $workorderHandler */
42
    $workorderHandler = new Cardealer\WorkorderHandler($GLOBALS['xoopsDB']);
43
    $criteria         = new \CriteriaCompo();
44
    array_shift($options);
45
    array_shift($options);
46
    array_shift($options);
47
    if ($blockType) {
48
        $criteria->add(new \Criteria('id', 0, '!='));
49
        $criteria->setSort('id');
50
        $criteria->setOrder('ASC');
51
    }
52
53
    $criteria->setLimit($workorderCount);
54
    $workorderArray = $workorderHandler->getAll($criteria);
55
    foreach (array_keys($workorderArray) as $i) {
56
    }
57
58
    return $block;
59
}
60
61
/**
62
 * @param $options
63
 *
64
 * @return string
65
 */
66
function editCardealerWorkorder($options)
67
{
68
69
    $form = MB_CARDEALER_DISPLAY;
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_DISPLAY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
70
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "' />";
71
    $form .= "<input name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' type='text' />&nbsp;<br>";
72
    $form .= MB_CARDEALER_TITLELENGTH . " : <input name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' type='text' /><br><br>";
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_TITLELENGTH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
73
74
    /** @var \XoopsPersistableObjectHandler $workorderHandler */
75
    $workorderHandler = new Cardealer\WorkorderHandler($GLOBALS['xoopsDB']);
76
77
    $criteria = new \CriteriaCompo();
78
    array_shift($options);
79
    array_shift($options);
80
    array_shift($options);
81
    $criteria->add(new Criteria('id', 0, '!='));
82
    $criteria->setSort('id');
83
    $criteria->setOrder('ASC');
84
    $workorderArray = $workorderHandler->getAll($criteria);
85
    $form           .= MB_CARDEALER_CATTODISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>";
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_CATTODISPLAY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
86
    $form           .= "<option value='0' " . (false === in_array(0, $options) ? '' : "selected='selected'") . '>' . MB_CARDEALER_ALLCAT . '</option>';
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_ALLCAT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
87
    foreach (array_keys($workorderArray) as $i) {
88
        $id   = $workorderArray[$i]->getVar('id');
89
        $form .= "<option value='" . $id . "' " . (false === in_array($id, $options) ? '' : "selected='selected'") . '>' . $workorderArray[$i]->getVar('custnum') . '</option>';
90
    }
91
    $form .= '</select>';
92
93
    return $form;
94
}
95