editCardealerCustomer()   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
/**
28
 * @param $options
29
 *
30
 * @return array
31
 */
32
function showCardealerCustomer($options)
33
{
34
35
    $block         = [];
36
    $blockType     = $options[0];
37
    $customerCount = $options[1];
38
39
    /** @var \XoopsPersistableObjectHandler $customerHandler */
40
    $customerHandler = new Cardealer\CustomerHandler($GLOBALS['xoopsDB']);
41
    $criteria        = new \CriteriaCompo();
42
    array_shift($options);
43
    array_shift($options);
44
    array_shift($options);
45
    if ($blockType) {
46
        $criteria->add(new \Criteria('custnum', 0, '!='));
47
        $criteria->setSort('custnum');
48
        $criteria->setOrder('ASC');
49
    }
50
51
    $criteria->setLimit($customerCount);
52
    $customerArray = $customerHandler->getAll($criteria);
53
    foreach (array_keys($customerArray) as $i) {
54
    }
55
56
    return $block;
57
}
58
59
/**
60
 * @param $options
61
 *
62
 * @return string
63
 */
64
function editCardealerCustomer($options)
65
{
66
67
    $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...
68
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "' />";
69
    $form .= "<input name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' type='text' />&nbsp;<br>";
70
    $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...
71
72
    /** @var \XoopsPersistableObjectHandler $customerHandler */
73
    $customerHandler = new Cardealer\CustomerHandler($GLOBALS['xoopsDB']);
74
75
    $criteria = new \CriteriaCompo();
76
    array_shift($options);
77
    array_shift($options);
78
    array_shift($options);
79
    $criteria->add(new Criteria('custnum', 0, '!='));
80
    $criteria->setSort('custnum');
81
    $criteria->setOrder('ASC');
82
    $customerArray = $customerHandler->getAll($criteria);
83
    $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...
84
    $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...
85
    foreach (array_keys($customerArray) as $i) {
86
        $custnum = $customerArray[$i]->getVar('custnum');
87
        $form    .= "<option value='" . $custnum . "' " . (false === in_array($custnum, $options) ? '' : "selected='selected'") . '>' . $customerArray[$i]->getVar('custname') . '</option>';
88
    }
89
    $form .= '</select>';
90
91
    return $form;
92
}
93