1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Epesi\Core\System; |
4
|
|
|
|
5
|
|
|
use Epesi\Core\System\Seeds\Form; |
6
|
|
|
use atk4\ui\jsExpression; |
7
|
|
|
use atk4\ui\Wizard; |
8
|
|
|
use Illuminate\Support\Facades\Artisan; |
9
|
|
|
use Epesi\Core\System\Integration\Modules\Concerns\HasAdminMode; |
10
|
|
|
use Illuminate\Support\Facades\App; |
11
|
|
|
use Epesi\Core\System\Integration\Modules\ModuleManager; |
12
|
|
|
|
13
|
|
|
class SystemInstallWizard extends Wizard |
14
|
|
|
{ |
15
|
|
|
use HasAdminMode; |
16
|
|
|
|
17
|
|
|
public function init() |
18
|
|
|
{ |
19
|
|
|
parent::init(); |
20
|
|
|
|
21
|
|
|
$this->setAdminMode()->performInstallationSteps(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function performInstallationSteps() |
25
|
|
|
{ |
26
|
|
|
$this->addStep(__('Welcome'), [__CLASS__, 'stepWelcome']); |
27
|
|
|
|
28
|
|
|
$this->addStep([__('License'), 'icon'=>'id card', 'description'=>__('Accept license conditions')], [__CLASS__, 'stepLicense']); |
29
|
|
|
|
30
|
|
|
$this->addStep([__('Database'), 'icon'=>'database', 'description'=>__('Database connection settings')], [__CLASS__, 'stepDatabase']); |
31
|
|
|
|
32
|
|
|
$this->addStep([__('Environment'), 'icon'=>'configure', 'description'=>__('Check environment')], [__CLASS__, 'stepEnvironment']); |
33
|
|
|
|
34
|
|
|
$this->addFinish([__CLASS__, 'stepInstallationCompleted']); |
35
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function addRequiredNote() |
39
|
|
|
{ |
40
|
|
|
$this->add(['View', __('denotes required field'), 'class' => ['required-note']])->setStyle(['float' => 'right']); |
41
|
|
|
|
42
|
|
|
eval_css(' |
43
|
|
|
.required-note::before { |
44
|
|
|
margin: 0 .2em 0 0; |
45
|
|
|
content: \'*\'; |
46
|
|
|
color: #db2828; |
47
|
|
|
} |
48
|
|
|
'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function setForm($form) |
52
|
|
|
{ |
53
|
|
|
$this->buttonNext->on('click', $form->js()->submit()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public static function stepWelcome($wizard) |
57
|
|
|
{ |
58
|
|
|
$columns = $wizard->add('Columns'); |
59
|
|
|
|
60
|
|
|
$column = $columns->addColumn(); |
61
|
|
|
$column->add(['Message', __('Thank you for downloading EPESI!')])->text |
62
|
|
|
->addParagraph(__('This wizard will guide you though the process of setting up your new CRM / ERP installation')) |
63
|
|
|
->addParagraph(__('Select the installation language and click NEXT button to proceed to next step')); |
64
|
|
|
|
65
|
|
|
$column = $columns->addColumn(); |
66
|
|
|
|
67
|
|
|
if (! function_exists('locale_get_display_language')) { |
68
|
|
|
$column->addClass('middle aligned'); |
69
|
|
|
$column->add(['Label', __('Install php-intl extension to enable language selection!'), 'class' => ['red']]); |
70
|
|
|
|
71
|
|
|
return; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
$systemLanguages = app()->make(\JoeDixon\Translation\Drivers\Translation::class)->allLanguages()->toArray(); |
75
|
|
|
|
76
|
|
|
$values = array_intersect_key(self::getDisplayLanguages(), $systemLanguages); |
77
|
|
|
|
78
|
|
|
$form = $column->add(new Form()); |
79
|
|
|
|
80
|
|
|
$form->addField('language', ['DropDown', 'values' => $values, 'caption' => __('Select Language'), 'iconLeft' => 'globe'], ['required'=>true])->set($wizard->recall('language', 'en')); |
81
|
|
|
|
82
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
83
|
|
|
$wizard->memorize('language', $form->model['language']); |
84
|
|
|
|
85
|
|
|
App::setLocale($form->model['language']); |
86
|
|
|
|
87
|
|
|
return $wizard->jsNext(); |
88
|
|
|
}); |
89
|
|
|
|
90
|
|
|
$wizard->setForm($form); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public static function stepLicense($wizard) |
94
|
|
|
{ |
95
|
|
|
$columns = $wizard->add('Columns'); |
96
|
|
|
$column = $columns->addColumn(); |
97
|
|
|
|
98
|
|
|
$license = $column->add(['View', 'defaultTemplate' => 'license.html'])->setStyle(['max-height' => '500px', 'overflow' => 'auto', 'padding' => '5px']); |
99
|
|
|
|
100
|
|
|
$license->js(true)->niceScroll(); |
101
|
|
|
|
102
|
|
|
$license->template->setHTML('epesi', config('epesi.app.title')); |
103
|
|
|
|
104
|
|
|
$license->template->setHTML('copyright', config('epesi.app.copyright')); |
105
|
|
|
|
106
|
|
|
$column = $columns->addColumn(); |
107
|
|
|
|
108
|
|
|
$form = $column->add(new Form()); |
109
|
|
|
$form->addField('copyright', ['Checkbox', 'caption' => __('I will not remove the Copyright notice as required by the MIT license.')], ['required'=>true]); |
110
|
|
|
$form->addField('logo', ['Checkbox', 'caption' => __('I will not remove ":epesi powered" logo and the link from the application login screen or the toolbar.', ['epesi' => config('epesi.app.title')])], ['required'=>true]); |
111
|
|
|
$form->addField('support', ['Checkbox', 'caption' => __('I will not remove "Support -> About" credit page from the application menu.')], ['required'=>true]); |
112
|
|
|
$form->addField('store', ['Checkbox', 'caption' => __('I will not remove or rename ":epesi Store" links from the application.', ['epesi' => config('epesi.app.title')])], ['required'=>true]); |
113
|
|
|
|
114
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
|
|
|
|
115
|
|
|
return $wizard->jsNext(); |
116
|
|
|
}); |
117
|
|
|
|
118
|
|
|
$wizard->setForm($form); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public static function stepDatabase($wizard) |
122
|
|
|
{ |
123
|
|
|
$wizard->addRequiredNote(); |
124
|
|
|
|
125
|
|
|
$form = $wizard->add('Form'); |
126
|
|
|
|
127
|
|
|
$form->addField('host', __('Database Host'), ['required'=>true])->placeholder = __('e.g. localhost'); |
128
|
|
|
$form->addField('port', __('Database Port')); |
129
|
|
|
|
130
|
|
|
$form->addField('driver', ['DropDown', 'values' => [ |
131
|
|
|
'mysql' => 'MySQL', |
132
|
|
|
'postgre' => 'PostgeSQL', |
133
|
|
|
], 'caption' => __('Database Engine')], ['required'=>true]); |
134
|
|
|
|
135
|
|
|
$form->addField('database', __('Database Name')); |
136
|
|
|
$form->addField('username', __('Database Server User'), ['required'=>true]); |
137
|
|
|
$form->addField('password', ['Password', 'caption' => __('Database Server Password')], ['required'=>true]); |
138
|
|
|
|
139
|
|
|
$form->addField('create', ['Checkbox', 'caption' => __('Create New Database')])->on('change', new jsExpression('if ($(event.target).is(":checked")) alert([])', [__('WARNING: Make sure you have CREATE access level to do this!')])); |
140
|
|
|
|
141
|
|
|
foreach ($wizard->recall('connection', []) as $name => $value) { |
142
|
|
|
if (! $field = $form->fields[$name]?? null) continue; |
143
|
|
|
|
144
|
|
|
$field->set($value); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
148
|
|
|
$connection = $form->model->get(); |
149
|
|
|
|
150
|
|
|
$wizard->memorize('connection', $connection); |
151
|
|
|
|
152
|
|
|
Artisan::call('epesi:database-connection', ['--connection' => $connection]); |
153
|
|
|
|
154
|
|
|
if ($connection['create']) { |
155
|
|
|
Artisan::call('epesi:database-create', ['name' => $connection['database'], '--connection' => $connection]); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
ModuleManager::clearCache(); |
159
|
|
|
|
160
|
|
|
Artisan::call('config:clear'); |
161
|
|
|
Artisan::call('cache:clear'); |
162
|
|
|
|
163
|
|
|
return $wizard->jsNext(); |
164
|
|
|
}); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public static function stepEnvironment($wizard) |
168
|
|
|
{ |
169
|
|
|
Artisan::call('migrate'); |
170
|
|
|
|
171
|
|
|
ob_start(); |
172
|
|
|
ModuleManager::install('system'); |
173
|
|
|
ob_end_clean(); |
174
|
|
|
|
175
|
|
|
$wizard->add(new SystemEnvironmentOverview()); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public static function stepInstallationCompleted($wizard) |
179
|
|
|
{ |
180
|
|
|
$wizard->add(['Header', __(':epesi was successfully installed!', ['epesi' => config('epesi.app.title')]), 'huge centered']); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
public static function getDisplayLanguages() { |
184
|
|
|
return [ |
185
|
|
|
'aa' => __('Afar'), |
186
|
|
|
'ab' => __('Abkhazian'), |
187
|
|
|
'ae' => __('Avestan'), |
188
|
|
|
'af' => __('Afrikaans'), |
189
|
|
|
'ak' => __('Akan'), |
190
|
|
|
'am' => __('Amharic'), |
191
|
|
|
'an' => __('Aragonese'), |
192
|
|
|
'ar' => __('Arabic'), |
193
|
|
|
'as' => __('Assamese'), |
194
|
|
|
'av' => __('Avaric'), |
195
|
|
|
'ay' => __('Aymara'), |
196
|
|
|
'az' => __('Azerbaijani'), |
197
|
|
|
'ba' => __('Bashkir'), |
198
|
|
|
'be' => __('Belarusian'), |
199
|
|
|
'bg' => __('Bulgarian'), |
200
|
|
|
'bh' => __('Bihari'), |
201
|
|
|
'bi' => __('Bislama'), |
202
|
|
|
'bm' => __('Bambara'), |
203
|
|
|
'bn' => __('Bengali'), |
204
|
|
|
'bo' => __('Tibetan'), |
205
|
|
|
'br' => __('Breton'), |
206
|
|
|
'bs' => __('Bosnian'), |
207
|
|
|
'ca' => __('Catalan'), |
208
|
|
|
'ce' => __('Chechen'), |
209
|
|
|
'ch' => __('Chamorro'), |
210
|
|
|
'co' => __('Corsican'), |
211
|
|
|
'cr' => __('Cree'), |
212
|
|
|
'cs' => __('Czech'), |
213
|
|
|
'cu' => __('Church Slavic'), |
214
|
|
|
'cv' => __('Chuvash'), |
215
|
|
|
'cy' => __('Welsh'), |
216
|
|
|
'da' => __('Danish'), |
217
|
|
|
'de' => __('German'), |
218
|
|
|
'dv' => __('Divehi'), |
219
|
|
|
'dz' => __('Dzongkha'), |
220
|
|
|
'ee' => __('Ewe'), |
221
|
|
|
'el' => __('Greek'), |
222
|
|
|
'en' => __('English'), |
223
|
|
|
'eo' => __('Esperanto'), |
224
|
|
|
'es' => __('Spanish'), |
225
|
|
|
'et' => __('Estonian'), |
226
|
|
|
'eu' => __('Basque'), |
227
|
|
|
'fa' => __('Persian'), |
228
|
|
|
'ff' => __('Fulah'), |
229
|
|
|
'fi' => __('Finnish'), |
230
|
|
|
'fj' => __('Fijian'), |
231
|
|
|
'fo' => __('Faroese'), |
232
|
|
|
'fr' => __('French'), |
233
|
|
|
'fy' => __('Western Frisian'), |
234
|
|
|
'ga' => __('Irish'), |
235
|
|
|
'gd' => __('Scottish Gaelic'), |
236
|
|
|
'gl' => __('Galician'), |
237
|
|
|
'gn' => __('Guarani'), |
238
|
|
|
'gu' => __('Gujarati'), |
239
|
|
|
'gv' => __('Manx'), |
240
|
|
|
'ha' => __('Hausa'), |
241
|
|
|
'he' => __('Hebrew'), |
242
|
|
|
'hi' => __('Hindi'), |
243
|
|
|
'ho' => __('Hiri Motu'), |
244
|
|
|
'hr' => __('Croatian'), |
245
|
|
|
'ht' => __('Haitian'), |
246
|
|
|
'hu' => __('Hungarian'), |
247
|
|
|
'hy' => __('Armenian'), |
248
|
|
|
'hz' => __('Herero'), |
249
|
|
|
'ia' => __('Interlingua (International Auxiliary Language Association)'), |
250
|
|
|
'id' => __('Indonesian'), |
251
|
|
|
'ie' => __('Interlingue'), |
252
|
|
|
'ig' => __('Igbo'), |
253
|
|
|
'ii' => __('Sichuan Yi'), |
254
|
|
|
'ik' => __('Inupiaq'), |
255
|
|
|
'io' => __('Ido'), |
256
|
|
|
'is' => __('Icelandic'), |
257
|
|
|
'it' => __('Italian'), |
258
|
|
|
'iu' => __('Inuktitut'), |
259
|
|
|
'ja' => __('Japanese'), |
260
|
|
|
'jv' => __('Javanese'), |
261
|
|
|
'ka' => __('Georgian'), |
262
|
|
|
'kg' => __('Kongo'), |
263
|
|
|
'ki' => __('Kikuyu'), |
264
|
|
|
'kj' => __('Kwanyama'), |
265
|
|
|
'kk' => __('Kazakh'), |
266
|
|
|
'kl' => __('Kalaallisut'), |
267
|
|
|
'km' => __('Khmer'), |
268
|
|
|
'kn' => __('Kannada'), |
269
|
|
|
'ko' => __('Korean'), |
270
|
|
|
'kr' => __('Kanuri'), |
271
|
|
|
'ks' => __('Kashmiri'), |
272
|
|
|
'ku' => __('Kurdish'), |
273
|
|
|
'kv' => __('Komi'), |
274
|
|
|
'kw' => __('Cornish'), |
275
|
|
|
'ky' => __('Kirghiz'), |
276
|
|
|
'la' => __('Latin'), |
277
|
|
|
'lb' => __('Luxembourgish'), |
278
|
|
|
'lg' => __('Ganda'), |
279
|
|
|
'li' => __('Limburgish'), |
280
|
|
|
'ln' => __('Lingala'), |
281
|
|
|
'lo' => __('Lao'), |
282
|
|
|
'lt' => __('Lithuanian'), |
283
|
|
|
'lu' => __('Luba-Katanga'), |
284
|
|
|
'lv' => __('Latvian'), |
285
|
|
|
'mg' => __('Malagasy'), |
286
|
|
|
'mh' => __('Marshallese'), |
287
|
|
|
'mi' => __('Maori'), |
288
|
|
|
'mk' => __('Macedonian'), |
289
|
|
|
'ml' => __('Malayalam'), |
290
|
|
|
'mn' => __('Mongolian'), |
291
|
|
|
'mr' => __('Marathi'), |
292
|
|
|
'ms' => __('Malay'), |
293
|
|
|
'mt' => __('Maltese'), |
294
|
|
|
'my' => __('Burmese'), |
295
|
|
|
'na' => __('Nauru'), |
296
|
|
|
'nb' => __('Norwegian Bokmal'), |
297
|
|
|
'nd' => __('North Ndebele'), |
298
|
|
|
'ne' => __('Nepali'), |
299
|
|
|
'ng' => __('Ndonga'), |
300
|
|
|
'nl' => __('Dutch'), |
301
|
|
|
'nn' => __('Norwegian Nynorsk'), |
302
|
|
|
'no' => __('Norwegian'), |
303
|
|
|
'nr' => __('South Ndebele'), |
304
|
|
|
'nv' => __('Navajo'), |
305
|
|
|
'ny' => __('Chichewa'), |
306
|
|
|
'oc' => __('Occitan'), |
307
|
|
|
'oj' => __('Ojibwa'), |
308
|
|
|
'om' => __('Oromo'), |
309
|
|
|
'or' => __('Oriya'), |
310
|
|
|
'os' => __('Ossetian'), |
311
|
|
|
'pa' => __('Panjabi'), |
312
|
|
|
'pi' => __('Pali'), |
313
|
|
|
'pl' => __('Polish'), |
314
|
|
|
'ps' => __('Pashto'), |
315
|
|
|
'pt' => __('Portuguese'), |
316
|
|
|
'qu' => __('Quechua'), |
317
|
|
|
'rm' => __('Raeto-Romance'), |
318
|
|
|
'rn' => __('Kirundi'), |
319
|
|
|
'ro' => __('Romanian'), |
320
|
|
|
'ru' => __('Russian'), |
321
|
|
|
'rw' => __('Kinyarwanda'), |
322
|
|
|
'sa' => __('Sanskrit'), |
323
|
|
|
'sc' => __('Sardinian'), |
324
|
|
|
'sd' => __('Sindhi'), |
325
|
|
|
'se' => __('Northern Sami'), |
326
|
|
|
'sg' => __('Sango'), |
327
|
|
|
'si' => __('Sinhala'), |
328
|
|
|
'sk' => __('Slovak'), |
329
|
|
|
'sl' => __('Slovenian'), |
330
|
|
|
'sm' => __('Samoan'), |
331
|
|
|
'sn' => __('Shona'), |
332
|
|
|
'so' => __('Somali'), |
333
|
|
|
'sq' => __('Albanian'), |
334
|
|
|
'sr' => __('Serbian'), |
335
|
|
|
'ss' => __('Swati'), |
336
|
|
|
'st' => __('Southern Sotho'), |
337
|
|
|
'su' => __('Sundanese'), |
338
|
|
|
'sv' => __('Swedish'), |
339
|
|
|
'sw' => __('Swahili'), |
340
|
|
|
'ta' => __('Tamil'), |
341
|
|
|
'te' => __('Telugu'), |
342
|
|
|
'tg' => __('Tajik'), |
343
|
|
|
'th' => __('Thai'), |
344
|
|
|
'ti' => __('Tigrinya'), |
345
|
|
|
'tk' => __('Turkmen'), |
346
|
|
|
'tl' => __('Tagalog'), |
347
|
|
|
'tn' => __('Tswana'), |
348
|
|
|
'to' => __('Tonga'), |
349
|
|
|
'tr' => __('Turkish'), |
350
|
|
|
'ts' => __('Tsonga'), |
351
|
|
|
'tt' => __('Tatar'), |
352
|
|
|
'tw' => __('Twi'), |
353
|
|
|
'ty' => __('Tahitian'), |
354
|
|
|
'ug' => __('Uighur'), |
355
|
|
|
'uk' => __('Ukrainian'), |
356
|
|
|
'ur' => __('Urdu'), |
357
|
|
|
'uz' => __('Uzbek'), |
358
|
|
|
've' => __('Venda'), |
359
|
|
|
'vi' => __('Vietnamese'), |
360
|
|
|
'vo' => __('Volapuk'), |
361
|
|
|
'wa' => __('Walloon'), |
362
|
|
|
'wo' => __('Wolof'), |
363
|
|
|
'xh' => __('Xhosa'), |
364
|
|
|
'yi' => __('Yiddish'), |
365
|
|
|
'yo' => __('Yoruba'), |
366
|
|
|
'za' => __('Zhuang'), |
367
|
|
|
'zh' => __('Chinese'), |
368
|
|
|
'zu' => __('Zulu') |
369
|
|
|
]; |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.