|
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 ServiceForm |
|
38
|
|
|
*/ |
|
39
|
|
|
class ServiceForm 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_SERVICE_ADD) : sprintf(AM_CARDEALER_SERVICE_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('itemnum', $this->targetObject->getVar('itemnum')); |
|
60
|
|
|
$this->addElement($hidden); |
|
61
|
|
|
unset($hidden); |
|
62
|
|
|
|
|
63
|
|
|
// Itemnum |
|
64
|
|
|
$this->addElement(new \XoopsFormLabel(AM_CARDEALER_SERVICE_ITEMNUM, $this->targetObject->getVar('itemnum'), 'itemnum')); |
|
65
|
|
|
// Labor |
|
66
|
|
|
$this->addElement(new \XoopsFormText(AM_CARDEALER_SERVICE_LABOR, 'labor', 50, 255, $this->targetObject->getVar('labor')), false); |
|
67
|
|
|
// Title |
|
68
|
|
|
$this->addElement(new \XoopsFormText(AM_CARDEALER_SERVICE_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false); |
|
69
|
|
|
// Description |
|
70
|
|
|
if (class_exists('XoopsFormEditor')) { |
|
71
|
|
|
$editorOptions = []; |
|
72
|
|
|
$editorOptions['name'] = 'description'; |
|
73
|
|
|
$editorOptions['value'] = $this->targetObject->getVar('description', 'e'); |
|
74
|
|
|
$editorOptions['rows'] = 5; |
|
75
|
|
|
$editorOptions['cols'] = 40; |
|
76
|
|
|
$editorOptions['width'] = '100%'; |
|
77
|
|
|
$editorOptions['height'] = '400px'; |
|
78
|
|
|
|
|
79
|
|
|
if ($helper->isUserAdmin()) { |
|
80
|
|
|
$descEditor = new \XoopsFormEditor(AM_CARDEALER_SERVICE_DESCRIPTION, $helper->getConfig('cardealerEditorAdmin'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
81
|
|
|
} else { |
|
82
|
|
|
$descEditor = new \XoopsFormEditor(AM_CARDEALER_SERVICE_DESCRIPTION, $helper->getConfig('cardealerEditorUser'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
83
|
|
|
} |
|
84
|
|
|
} else { |
|
85
|
|
|
$descEditor = new \XoopsFormDhtmlTextArea(AM_CARDEALER_SERVICE_DESCRIPTION, 'description', $this->targetObject->getVar('description', 'e'), '100%', '100%'); |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
$this->addElement($descEditor); |
|
88
|
|
|
|
|
89
|
|
|
$this->addElement(new \XoopsFormHidden('op', 'save')); |
|
90
|
|
|
$this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|