EquipmentRentalsForm   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 37 2
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: Equipment
15
 *
16
 * @category        Module
17
 * @package         equipment
18
 * @author          XOOPS Development Team <[email protected]> - <http://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;
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
//use Xmf\Module\Helper;
27
use Xmf\Module\Helper\Permission;
28
29
require_once __DIR__ . '/../../include/config.php';
30
31
$moduleDirName = basename(dirname(dirname(__DIR__)));
32
$moduleHelper  = Xmf\Module\Helper::getHelper($moduleDirName);
33
$permHelper    = new Permission($moduleDirName);
34
35
xoops_load('XoopsFormLoader');
36
37
/**
38
 * Class EquipmentRentalsForm
39
 */
40
class EquipmentRentalsForm extends XoopsThemeForm
41
{
42
    public $targetObject;
43
44
    /**
45
     * Constructor
46
     *
47
     * @param $target
48
     */
49
    public function __construct($target)
50
    {
51
//        global $moduleHelper;
52
        $this->targetObject = $target;
53
54
        $title = $this->targetObject->isNew() ? sprintf(AM_EQUIPMENT_RENTALS_ADD) : sprintf(AM_EQUIPMENT_RENTALS_EDIT);
55
        parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true);
56
        $this->setExtra('enctype="multipart/form-data"');
57
58
        //include ID field, it's needed so the module knows if it is a new form or an edited form
59
60
        $hidden = new XoopsFormHidden('id', $this->targetObject->getVar('id'));
61
        $this->addElement($hidden);
62
        unset($hidden);
63
64
        // Id
65
        $this->addElement(new XoopsFormLabel(AM_EQUIPMENT_RENTALS_ID, $this->targetObject->getVar('id'), 'id'));
66
        // Customerid
67
        $customerHandler    = xoops_getModuleHandler('customer', 'equipment');
68
        $customer_id_select = new XoopsFormSelect(AM_EQUIPMENT_RENTALS_CUSTOMERID, 'customerid', $this->targetObject->getVar('customerid'));
69
        $customer_id_select->addOptionArray($customerHandler->getList());
70
        $this->addElement($customer_id_select, false);
71
        // Equipmentid
72
        $equipmentHandler    = xoops_getModuleHandler('equipment', 'equipment');
73
        $equipment_id_select = new XoopsFormSelect(AM_EQUIPMENT_RENTALS_EQUIPMENTID, 'equipmentid', $this->targetObject->getVar('equipmentid'));
74
        $equipment_id_select->addOptionArray($equipmentHandler->getList());
75
        $this->addElement($equipment_id_select, false);
76
        // Quantity
77
        $this->addElement(new XoopsFormText(AM_EQUIPMENT_RENTALS_QUANTITY, 'quantity', 50, 255, $this->targetObject->getVar('quantity')), false);
78
        // Datefrom
79
        $this->addElement(new XoopsFormTextDateSelect(AM_EQUIPMENT_RENTALS_DATEFROM, 'datefrom', '', strtotime($this->targetObject->getVar('datefrom'))));
80
        // Dateto
81
        $this->addElement(new XoopsFormTextDateSelect(AM_EQUIPMENT_RENTALS_DATETO, 'dateto', '', strtotime($this->targetObject->getVar('dateto'))));
82
83
        $this->addElement(new XoopsFormHidden('op', 'save'));
84
        $this->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
85
    }
86
}
87