26
26
use NextDom \Helpers \AuthentificationHelper ;
27
27
use NextDom \Helpers \NextDomHelper ;
28
28
use NextDom \Helpers \Utils ;
29
+ use NextDom \Managers \CmdManager ;
29
30
use NextDom \Managers \EqLogicManager ;
30
31
use NextDom \Managers \JeeObjectManager ;
31
32
use NextDom \Model \Entity \Cmd ;
33
+ use NextDom \Model \Entity \EqLogic ;
32
34
33
35
/**
34
36
* Class EqLogicAjax
@@ -52,7 +54,7 @@ public function getEqLogicObject()
52
54
foreach ($ linkedObject ->getEqLogic () as $ eqLogic ) {
53
55
if ($ eqLogic ->isVisible ()) {
54
56
$ info_eqLogic = [];
55
- $ info_eqLogic [Common ::ID ] = $ eqLogic ->getId ();
57
+ $ info_eqLogic [AjaxParams ::ID ] = $ eqLogic ->getId ();
56
58
$ info_eqLogic [Common::TYPE ] = $ eqLogic ->getEqType_name ();
57
59
$ info_eqLogic [Common::OBJECT_ID ] = $ eqLogic ->getObject_id ();
58
60
$ info_eqLogic [Common::HTML ] = $ eqLogic ->toHtml (Utils::init (AjaxParams::VERSION ));
@@ -84,7 +86,7 @@ public function toHtml()
84
86
throw new CoreException (__ ('Pas de version indiqué pour le rendu HTML ' ));
85
87
}
86
88
$ result [$ eqLogic ->getId ()] = [
87
- Common ::ID => $ eqLogic ->getId (),
89
+ AjaxParams ::ID => $ eqLogic ->getId (),
88
90
Common::TYPE => $ eqLogic ->getEqType_name (),
89
91
Common::OBJECT_ID => $ eqLogic ->getObject_id (),
90
92
Common::HTML => $ eqLogic ->toHtml ($ eqLogicData [AjaxParams::VERSION ]),
@@ -97,7 +99,7 @@ public function toHtml()
97
99
throw new CoreException (__ ('Eqlogic inconnu. Vérifiez l \'ID ' ));
98
100
}
99
101
$ eqLogicInfo = [];
100
- $ eqLogicInfo [Common ::ID ] = $ eqLogic ->getId ();
102
+ $ eqLogicInfo [AjaxParams ::ID ] = $ eqLogic ->getId ();
101
103
$ eqLogicInfo [Common::TYPE ] = $ eqLogic ->getEqType_name ();
102
104
$ eqLogicInfo [Common::OBJECT_ID ] = $ eqLogic ->getObject_id ();
103
105
$ eqLogicInfo [Common::HTML ] = $ eqLogic ->toHtml (Utils::init (AjaxParams::VERSION ));
@@ -114,7 +116,7 @@ public function htmlAlert()
114
116
}
115
117
$ result [$ eqLogic ->getId ()] = [
116
118
Common::HTML => $ eqLogic ->toHtml (Utils::init (AjaxParams::VERSION )),
117
- Common ::ID => $ eqLogic ->getId (),
119
+ AjaxParams ::ID => $ eqLogic ->getId (),
118
120
Common::TYPE => $ eqLogic ->getEqType_name (),
119
121
Common::OBJECT_ID => $ eqLogic ->getObject_id (),
120
122
];
@@ -145,7 +147,7 @@ public function htmlBattery()
145
147
foreach ($ list as $ eqLogic ) {
146
148
$ result [] = [
147
149
Common::HTML => $ eqLogic ->batteryWidget (Utils::init (AjaxParams::VERSION )),
148
- Common ::ID => $ eqLogic ->getId (),
150
+ AjaxParams ::ID => $ eqLogic ->getId (),
149
151
Common::TYPE => $ eqLogic ->getEqType_name (),
150
152
Common::OBJECT_ID => $ eqLogic ->getObject_id (),
151
153
];
@@ -197,7 +199,7 @@ public function listByTypeAndCmdType()
197
199
$ eqLogicList = EqLogicManager::listByTypeAndCmdType (Utils::init (AjaxParams::TYPE ), Utils::init (AjaxParams::TYPE_CMD ), Utils::init (AjaxParams::SUB_TYPE_CMD ));
198
200
$ result = [];
199
201
foreach ($ eqLogicList as $ eqLogic ) {
200
- $ eqLogic = EqLogicManager::byId ($ eqLogic [Common ::ID ]);
202
+ $ eqLogic = EqLogicManager::byId ($ eqLogic [AjaxParams ::ID ]);
201
203
$ info [NextDomObj::EQLOGIC ] = Utils::o2a ($ eqLogic );
202
204
$ info [NextDomObj::OBJECT ] = ['name ' => 'Aucun ' ];
203
205
if (is_object ($ eqLogic )) {
@@ -230,10 +232,10 @@ public function setOrder()
230
232
{
231
233
$ eqLogics = json_decode (Utils::init ('eqLogics ' ), true );
232
234
foreach ($ eqLogics as $ eqLogic_json ) {
233
- if (!isset ($ eqLogic_json [Common ::ID ]) || trim ($ eqLogic_json [Common ::ID ]) == '' ) {
235
+ if (!isset ($ eqLogic_json [AjaxParams ::ID ]) || trim ($ eqLogic_json [AjaxParams ::ID ]) == '' ) {
234
236
continue ;
235
237
}
236
- $ eqLogic = EqLogicManager::byId ($ eqLogic_json [Common ::ID ]);
238
+ $ eqLogic = EqLogicManager::byId ($ eqLogic_json [AjaxParams ::ID ]);
237
239
if (!is_object ($ eqLogic )) {
238
240
continue ;
239
241
}
@@ -297,9 +299,9 @@ public function simpleSave()
297
299
{
298
300
AuthentificationHelper::isConnectedAsAdminOrFail ();
299
301
$ eqLogicSave = json_decode (Utils::init (NextDomObj::EQLOGIC ), true );
300
- $ eqLogic = EqLogicManager::byId ($ eqLogicSave [Common ::ID ]);
302
+ $ eqLogic = EqLogicManager::byId ($ eqLogicSave [AjaxParams ::ID ]);
301
303
if (!is_object ($ eqLogic )) {
302
- throw new CoreException (__ ('EqLogic inconnu. Vérifiez l \'ID ' ) . $ eqLogicSave [Common ::ID ]);
304
+ throw new CoreException (__ ('EqLogic inconnu. Vérifiez l \'ID ' ) . $ eqLogicSave [AjaxParams ::ID ]);
303
305
}
304
306
305
307
if (!$ eqLogic ->hasRight (ActionRight::WRITE )) {
@@ -355,22 +357,22 @@ public function get()
355
357
public function save ()
356
358
{
357
359
AuthentificationHelper::isConnectedAsAdminOrFail ();
358
-
359
360
$ eqLogicsSave = json_decode (Utils::init (NextDomObj::EQLOGIC ), true );
360
361
361
362
foreach ($ eqLogicsSave as $ eqLogicSave ) {
362
363
try {
363
364
if (!is_array ($ eqLogicSave )) {
364
365
throw new CoreException (__ ('Informations reçues incorrectes ' ));
365
366
}
366
- $ typeEqLogic = Utils::init (AjaxParams::TYPE );
367
+ $ typeEqLogic = Utils::initStr (AjaxParams::TYPE );
367
368
$ typeCmd = $ typeEqLogic . NextDomObj::CMD ;
368
369
if ($ typeEqLogic == '' || !class_exists ($ typeEqLogic ) || !class_exists ($ typeCmd )) {
369
370
throw new CoreException (__ ('Type incorrect, (classe commande inexistante) ' ) . $ typeCmd );
370
371
}
372
+ /** @var EqLogic $eqLogic */
371
373
$ eqLogic = null ;
372
- if (isset ($ eqLogicSave [Common ::ID ])) {
373
- $ eqLogic = $ typeEqLogic ::byId ($ eqLogicSave [Common ::ID ]);
374
+ if (isset ($ eqLogicSave [AjaxParams ::ID ])) {
375
+ $ eqLogic = $ typeEqLogic ::byId ($ eqLogicSave [AjaxParams ::ID ]);
374
376
}
375
377
if (!is_object ($ eqLogic )) {
376
378
$ eqLogic = new $ typeEqLogic ();
@@ -385,16 +387,16 @@ public function save()
385
387
}
386
388
$ eqLogicSave = NextDomHelper::fromHumanReadable ($ eqLogicSave );
387
389
Utils::a2o ($ eqLogic , $ eqLogicSave );
388
- $ dbList = $ typeCmd ::byEqLogicId ($ eqLogic ->getId ());
390
+ $ dbList = CmdManager ::byEqLogicId ($ eqLogic ->getId ());
389
391
$ eqLogic ->save ();
390
392
$ enableList = [];
391
393
392
394
if (isset ($ eqLogicSave [NextDomObj::CMD ])) {
393
395
$ cmd_order = 0 ;
394
396
foreach ($ eqLogicSave [NextDomObj::CMD ] as $ cmd_info ) {
395
397
$ cmd = null ;
396
- if (isset ($ cmd_info [Common ::ID ])) {
397
- $ cmd = $ typeCmd ::byId ($ cmd_info [Common ::ID ]);
398
+ if (isset ($ cmd_info [AjaxParams ::ID ])) {
399
+ $ cmd = CmdManager ::byId ($ cmd_info [AjaxParams ::ID ]);
398
400
}
399
401
if (!is_object ($ cmd )) {
400
402
$ cmd = new $ typeCmd ();
@@ -415,6 +417,7 @@ public function save()
415
417
if (method_exists ($ eqLogic , 'postAjax ' )) {
416
418
$ eqLogic ->postAjax ();
417
419
}
420
+ $ this ->ajax ->success (Utils::o2a ($ eqLogic ));
418
421
} catch (\Exception $ e ) {
419
422
if (strpos ($ e ->getMessage (), '[MySQL] Error code : 23000 ' ) !== false ) {
420
423
if ($ e ->getTrace ()[2 ]['class ' ] == NextDomObj::EQLOGIC ) {
@@ -426,7 +429,6 @@ public function save()
426
429
throw new CoreException ($ e ->getMessage ());
427
430
}
428
431
}
429
- $ this ->ajax ->success (Utils::o2a ($ eqLogic ));
430
432
}
431
433
$ this ->ajax ->success (null );
432
434
}
0 commit comments