1 | <?php |
||||||
2 | namespace Alixar\Controllers; |
||||||
3 | |||||||
4 | use Alxarafe\Helpers\Skin; |
||||||
5 | use Alixar\Base\AlixarController; |
||||||
6 | use Alixar\Views\CategoriesView; |
||||||
7 | use Alixar\Views\CategoriesIndexView; |
||||||
8 | use Alixar\Helpers\Globals; |
||||||
9 | use Alixar\Helpers\AlDolUtils; |
||||||
10 | |||||||
11 | class AlCategories extends AlixarController |
||||||
12 | { |
||||||
13 | |||||||
14 | public $action; |
||||||
15 | public $cancel; |
||||||
16 | public $origin; |
||||||
17 | public $catorigin; |
||||||
18 | public $type; |
||||||
19 | public $urlfrom; |
||||||
20 | public $backtopage; |
||||||
21 | public $id; |
||||||
22 | public $socid; |
||||||
23 | public $label; |
||||||
24 | public $description; |
||||||
25 | public $color; |
||||||
26 | public $visible; |
||||||
27 | public $parent; |
||||||
28 | public $object; |
||||||
29 | public $catname; |
||||||
30 | |||||||
31 | public function __construct() |
||||||
32 | { |
||||||
33 | parent::__construct(); |
||||||
34 | } |
||||||
35 | |||||||
36 | function getVars() |
||||||
37 | { |
||||||
38 | |||||||
39 | $this->action = AlDolUtils::GETPOST('action', 'alpha'); |
||||||
0 ignored issues
–
show
|
|||||||
40 | $this->cancel = AlDolUtils::GETPOST('cancel', 'alpha'); |
||||||
41 | $this->origin = AlDolUtils::GETPOST('origin', 'alpha'); |
||||||
42 | $this->catorigin = AlDolUtils::GETPOST('catorigin', 'int'); |
||||||
43 | $this->type = AlDolUtils::GETPOST('type', 'alpha'); |
||||||
44 | $this->urlfrom = AlDolUtils::GETPOST('urlfrom', 'alpha'); |
||||||
45 | $this->backtopage = AlDolUtils::GETPOST('backtopage', 'alpha'); |
||||||
46 | |||||||
47 | $this->id = AlDolUtils::GETPOST('id', 'int'); |
||||||
48 | $this->socid = AlDolUtils::GETPOST('socid', 'int'); |
||||||
49 | $this->label = AlDolUtils::GETPOST('label'); |
||||||
50 | $this->description = AlDolUtils::GETPOST('description'); |
||||||
51 | $this->color = AlDolUtils::GETPOST('color'); |
||||||
52 | $this->visible = AlDolUtils::GETPOST('visible'); |
||||||
53 | $this->parent = AlDolUtils::GETPOST('parent'); |
||||||
54 | $this->catname = AlDolUtils::GETPOST('catname', 'alpha'); |
||||||
55 | } |
||||||
56 | |||||||
57 | function index(): void |
||||||
58 | { |
||||||
59 | parent::index(); |
||||||
60 | |||||||
61 | // Load translation files required by the page |
||||||
62 | Globals::$langs->load("categories"); |
||||||
63 | |||||||
64 | // Security check |
||||||
65 | $this->socid = AlDolUtils::GETPOST('socid', 'int'); |
||||||
66 | if (!Globals::$user->rights->categorie->lire) { |
||||||
67 | accessforbidden(); |
||||||
68 | } |
||||||
69 | |||||||
70 | $this->getVars(); |
||||||
71 | |||||||
72 | Skin::$view = new CategoriesIndexView($this); |
||||||
73 | } |
||||||
74 | |||||||
75 | function main() |
||||||
76 | { |
||||||
77 | Skin::$view = new CategoriesView($this); |
||||||
78 | if ($this->origin) { |
||||||
79 | if ($this->type == AlCategorie::TYPE_PRODUCT) { |
||||||
80 | $idProdOrigin = $this->origin; |
||||||
81 | } |
||||||
82 | if ($this->type == AlCategorie::TYPE_SUPPLIER) { |
||||||
83 | $idSupplierOrigin = $this->origin; |
||||||
84 | } |
||||||
85 | if ($this->type == AlCategorie::TYPE_CUSTOMER) { |
||||||
86 | $idCompanyOrigin = $this->origin; |
||||||
87 | } |
||||||
88 | if ($this->type == AlCategorie::TYPE_MEMBER) { |
||||||
89 | $idMemberOrigin = $this->origin; |
||||||
90 | } |
||||||
91 | if ($this->type == AlCategorie::TYPE_CONTACT) { |
||||||
92 | $idContactOrigin = $this->origin; |
||||||
93 | } |
||||||
94 | if ($this->type == AlCategorie::TYPE_PROJECT) { |
||||||
95 | $idProjectOrigin = $this->origin; |
||||||
96 | } |
||||||
97 | } |
||||||
98 | |||||||
99 | if ($this->catorigin && $this->type == AlCategorie::TYPE_PRODUCT) { |
||||||
100 | $idCatOrigin = $this->catorigin; |
||||||
101 | } |
||||||
102 | |||||||
103 | $this->object = new AlCategorie(); |
||||||
104 | |||||||
105 | $extrafields = new AlExtraFields(); |
||||||
106 | $extralabels = $extrafields->fetch_name_optionals_label($this->object->table_element); |
||||||
107 | |||||||
108 | // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array |
||||||
109 | Globals::$hookManager->initHooks(array('categorycard')); |
||||||
110 | |||||||
111 | |||||||
112 | /* |
||||||
113 | * Actions |
||||||
114 | */ |
||||||
115 | |||||||
116 | // Add action |
||||||
117 | if ($this->action == 'add' && Globals::$user->rights->categorie->creer) { |
||||||
118 | // Action ajout d'une categorie |
||||||
119 | if ($this->cancel) { |
||||||
120 | if ($this->urlfrom) { |
||||||
121 | header("Location: " . $urlfrom); |
||||||
122 | exit; |
||||||
123 | } |
||||||
124 | if ($idProdOrigin) { |
||||||
125 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idProdOrigin . '&type=' . $this->type); |
||||||
126 | exit; |
||||||
127 | } |
||||||
128 | if ($idCompanyOrigin) { |
||||||
129 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idCompanyOrigin . '&type=' . $this->type); |
||||||
130 | exit; |
||||||
131 | } |
||||||
132 | if ($idSupplierOrigin) { |
||||||
133 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idSupplierOrigin . '&type=' . $this->type); |
||||||
134 | exit; |
||||||
135 | } |
||||||
136 | if ($idMemberOrigin) { |
||||||
137 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idMemberOrigin . '&type=' . $this->type); |
||||||
138 | exit; |
||||||
139 | } |
||||||
140 | if ($idContactOrigin) { |
||||||
141 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idContactOrigin . '&type=' . $this->type); |
||||||
142 | exit; |
||||||
143 | } |
||||||
144 | if ($idProjectOrigin) { |
||||||
145 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idProjectOrigin . '&type=' . $this->type); |
||||||
146 | exit; |
||||||
147 | } |
||||||
148 | header("Location: " . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $this->type); |
||||||
149 | exit; |
||||||
150 | } |
||||||
151 | |||||||
152 | $object->label = $this->label; |
||||||
153 | $object->color = $this->color; |
||||||
154 | $object->description = AlDolUtils::dol_htmlcleanlastbr($this->description); |
||||||
0 ignored issues
–
show
The method
dol_htmlcleanlastbr() does not exist on Alixar\Helpers\AlDolUtils .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
155 | $object->socid = ($this->socid ? $this->socid : 'null'); |
||||||
156 | $object->visible = $this->visible; |
||||||
157 | $object->type = $this->type; |
||||||
158 | |||||||
159 | if ($parent != "-1") { |
||||||
160 | $object->fk_parent = $parent; |
||||||
161 | } |
||||||
162 | |||||||
163 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
||||||
164 | if ($ret < 0) { |
||||||
165 | $error++; |
||||||
166 | } |
||||||
167 | |||||||
168 | if (!$object->label) { |
||||||
169 | $error++; |
||||||
170 | setEventMessages(Globals::$langs->trans("ErrorFieldRequired", Globals::$langs->transnoentities("Ref")), null, 'errors'); |
||||||
171 | $this->action = 'create'; |
||||||
172 | } |
||||||
173 | |||||||
174 | // Create category in database |
||||||
175 | if (!$error) { |
||||||
176 | $result = $object->create($user); |
||||||
177 | if ($result > 0) { |
||||||
178 | $this->action = 'confirmed'; |
||||||
179 | $_POST["addcat"] = ''; |
||||||
180 | } else { |
||||||
181 | setEventMessages($object->error, $object->errors, 'errors'); |
||||||
182 | } |
||||||
183 | } |
||||||
184 | } |
||||||
185 | |||||||
186 | // Confirm action |
||||||
187 | if (($this->action == 'add' || $this->action == 'confirmed') && Globals::$user->rights->categorie->creer) { |
||||||
188 | // Action confirmation de creation categorie |
||||||
189 | if ($this->action == 'confirmed') { |
||||||
190 | if ($urlfrom) { |
||||||
191 | header("Location: " . $urlfrom); |
||||||
192 | exit; |
||||||
193 | } |
||||||
194 | if ($backtopage) { |
||||||
195 | header("Location: " . $backtopage); |
||||||
196 | exit; |
||||||
197 | } |
||||||
198 | if ($idProdOrigin) { |
||||||
199 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idProdOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
200 | exit; |
||||||
201 | } |
||||||
202 | if ($idCompanyOrigin) { |
||||||
203 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idCompanyOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
204 | exit; |
||||||
205 | } |
||||||
206 | if ($idSupplierOrigin) { |
||||||
207 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idSupplierOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
208 | exit; |
||||||
209 | } |
||||||
210 | if ($idMemberOrigin) { |
||||||
211 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idMemberOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
212 | exit; |
||||||
213 | } |
||||||
214 | if ($idContactOrigin) { |
||||||
215 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idContactOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
216 | exit; |
||||||
217 | } |
||||||
218 | if ($idProjectOrigin) { |
||||||
219 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idProjectOrigin . '&type=' . $this->type . '&mesg=' . urlencode(Globals::$langs->trans("CatCreated"))); |
||||||
220 | exit; |
||||||
221 | } |
||||||
222 | |||||||
223 | header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $result . '&type=' . $this->type); |
||||||
224 | exit; |
||||||
225 | } |
||||||
226 | } |
||||||
227 | } |
||||||
228 | } |
||||||
229 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.