WorkorderForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 45 3
1
<?php namespace XoopsModules\Cardealer\Form;
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 Xmf\Request;
26
use XoopsModules\Cardealer;
27
28
require dirname(dirname(__DIR__)) . '/include/common.php';
29
30
$moduleDirName = basename(dirname(dirname(__DIR__)));
31
$helper        = Cardealer\Helper::getInstance();
32
$permHelper    = new \Xmf\Module\Helper\Permission();
33
34
xoops_load('XoopsFormLoader');
35
36
/**
37
 * Class WorkorderForm
38
 */
39
class WorkorderForm extends \XoopsThemeForm
40
{
41
    public $targetObject;
42
43
    /**
44
     * Constructor
45
     *
46
     * @param $target
47
     */
48
    public function __construct($target)
49
    {
50
        global $helper;
51
        $this->targetObject = $target;
52
53
        $title = $this->targetObject->isNew() ? sprintf(AM_CARDEALER_WORKORDER_ADD) : sprintf(AM_CARDEALER_WORKORDER_EDIT);
54
        parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true);
55
        $this->setExtra('enctype="multipart/form-data"');
56
57
        //include ID field, it's needed so the module knows if it is a new form or an edited form
58
59
        $hidden = new \XoopsFormHidden('id', $this->targetObject->getVar('id'));
60
        $this->addElement($hidden);
61
        unset($hidden);
62
63
        // Id
64
        $this->addElement(new \XoopsFormLabel(AM_CARDEALER_WORKORDER_ID, $this->targetObject->getVar('id'), 'id'));
65
        // Custnum
66
        $db = \XoopsDatabaseFactory::getDatabaseConnection();
67
        /** @var \XoopsPersistableObjectHandler $customerHandler */
68
        $customerHandler = new cardealer\CustomerHandler($db);
69
70
        $customer_id_select = new \XoopsFormSelect(AM_CARDEALER_WORKORDER_CUSTNUM, 'custnum', $this->targetObject->getVar('custnum'));
71
        $customer_id_select->addOptionArray($customerHandler->getList());
72
        $this->addElement($customer_id_select, false);
73
        // Carnum
74
        $db = \XoopsDatabaseFactory::getDatabaseConnection();
75
        /** @var \XoopsPersistableObjectHandler $vehicleHandler */
76
        $vehicleHandler = new cardealer\VehicleHandler($db);
77
78
        $vehicle_id_select = new \XoopsFormSelect(AM_CARDEALER_WORKORDER_CARNUM, 'carnum', $this->targetObject->getVar('carnum'));
79
        $vehicle_id_select->addOptionArray($vehicleHandler->getList());
80
        $this->addElement($vehicle_id_select, false);
81
        // Cost
82
        $this->addElement(new \XoopsFormText(AM_CARDEALER_WORKORDER_COST, 'cost', 50, 255, $this->targetObject->getVar('cost')), false);
83
        // Orderdate
84
        $this->addElement(new \XoopsFormTextDateSelect(AM_CARDEALER_WORKORDER_ORDERDATE, 'orderdate', '', strtotime($this->targetObject->getVar('orderdate'))));
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormTextDateSelect::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
        $this->addElement(new \XoopsFormTextDateSelect(AM_CARDEALER_WORKORDER_ORDERDATE, 'orderdate', /** @scrutinizer ignore-type */ '', strtotime($this->targetObject->getVar('orderdate'))));
Loading history...
85
        // Status
86
        $status       = $this->targetObject->isNew() ? 0 : $this->targetObject->getVar('status');
87
        $check_status = new \XoopsFormCheckBox(AM_CARDEALER_WORKORDER_STATUS, 'status', $status);
88
        $check_status->addOption(1, ' ');
89
        $this->addElement($check_status);
90
91
        $this->addElement(new \XoopsFormHidden('op', 'save'));
92
        $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
93
    }
94
}
95