|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Settings Comarch save action file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Settings.Action |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright YetiForce S.A. |
|
8
|
|
|
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
9
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Settings Comarch save action class. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Settings_Comarch_SaveAjax_Action extends Settings_Vtiger_Save_Action |
|
16
|
|
|
{ |
|
17
|
|
|
/** {@inheritdoc} */ |
|
18
|
|
|
public function __construct() |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct(); |
|
21
|
|
|
$this->exposeMethod('save'); |
|
22
|
|
|
$this->exposeMethod('reload'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Save function. |
|
27
|
|
|
* |
|
28
|
|
|
* @param App\Request $request |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
public function save(App\Request $request): void |
|
33
|
|
|
{ |
|
34
|
|
|
if ($request->isEmpty('record')) { |
|
35
|
|
|
$recordModel = Settings_Comarch_Record_Model::getCleanInstance(); |
|
36
|
|
|
} else { |
|
37
|
|
|
$recordModel = Settings_Comarch_Record_Model::getInstanceById($request->getInteger('record')); |
|
38
|
|
|
} |
|
39
|
|
|
$recordModel->setDataFromRequest($request); |
|
40
|
|
|
$recordModel->save(); |
|
41
|
|
|
|
|
42
|
|
|
$response = new Vtiger_Response(); |
|
43
|
|
|
$response->setResult([ |
|
44
|
|
|
'url' => 'index.php?parent=Settings&module=Comarch&view=EditConfigModal&record=' . $recordModel->getId() |
|
45
|
|
|
]); |
|
46
|
|
|
$response->emit(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Restart synchronization function. |
|
51
|
|
|
* |
|
52
|
|
|
* @param App\Request $request |
|
53
|
|
|
* |
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
|
|
public function reload(App\Request $request): void |
|
57
|
|
|
{ |
|
58
|
|
|
try { |
|
59
|
|
|
\App\Integrations\Comarch\Config::reload($request->getInteger('record')); |
|
60
|
|
|
$result = [ |
|
61
|
|
|
'success' => true, |
|
62
|
|
|
'message' => \App\Language::translate('LBL_RELOAD_MESSAGE', $request->getModule(false)) |
|
63
|
|
|
]; |
|
64
|
|
|
} catch (\App\Exceptions\AppException $e) { |
|
65
|
|
|
$result = ['success' => false, 'message' => $e->getDisplayMessage()]; |
|
66
|
|
|
} |
|
67
|
|
|
$response = new Vtiger_Response(); |
|
68
|
|
|
$response->setResult($result); |
|
69
|
|
|
$response->emit(); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|