Completed
Push — master ( b6c749...1fa67c )
by Daniel
03:02
created

Salariu::getValuesPrimary()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 2
eloc 19
nc 2
nop 3
1
<?php
2
3
/**
4
 *
5
 * The MIT License (MIT)
6
 *
7
 * Copyright (c) 2016 Daniel Popiniuc
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in all
17
 * copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
 * SOFTWARE.
26
 *
27
 */
28
29
namespace danielgp\salariu;
30
31
class Salariu
32
{
33
34
    use \danielgp\bank_holidays\Romanian,
35
        \danielgp\common_lib\CommonCode,
36
        \danielgp\salariu\Bonuses,
37
        \danielgp\salariu\ForeignCurrency,
38
        \danielgp\salariu\Taxation;
39
40
    private $appFlags;
41
    private $tApp = null;
42
43
    public function __construct()
44
    {
45
        $configPath        = 'Salariu' . DIRECTORY_SEPARATOR . 'config';
46
        $interfaceElements = $this->readTypeFromJsonFileUniversal($configPath, 'interfaceElements');
47
        $this->appFlags    = [
48
            'FI'   => $interfaceElements['Form Input'],
49
            'TCAS' => $interfaceElements['Table Cell Applied Style'],
50
            'TCSD' => $interfaceElements['Table Cell Style Definitions'],
51
        ];
52
        $this->initializeSprGlbAndSession();
53
        $this->handleLocalizationSalariu($interfaceElements['Application']);
54
        echo $this->setHeaderHtml();
55
        $this->processFormInputDefaults($interfaceElements['Default Values']);
56
        echo $this->setFormInput();
57
        $this->setExchangeRateValues($interfaceElements['Application'], $interfaceElements['Relevant Currencies']);
58
        echo $this->setFormOutput($configPath);
59
        echo $this->setFooterHtml($interfaceElements['Application']);
60
    }
61
62
    private function buildArrayOfFieldsStyled()
63
    {
64
        $sReturn = [];
65
        foreach ($this->appFlags['TCAS'] as $key => $value) {
66
            $sReturn[$this->tApp->gettext($key)] = $value;
67
        }
68
        return $sReturn;
69
    }
70
71
    private function buildStyleForCellFormat($styleId)
72
    {
73
        $sReturn = [];
74
        foreach ($this->appFlags['TCSD'][$styleId] as $key => $value) {
75
            $sReturn[] = $key . ':' . $value;
76
        }
77
        return implode(';', $sReturn) . ';';
78
    }
79
80
    private function getIncomeTaxValue($inDate, $lngBase, $vBA, $aryDeductions, $arySettings)
81
    {
82
        $rest = $lngBase - array_sum($aryDeductions);
83
        if ($inDate >= mktime(0, 0, 0, 7, 1, 2010)) {
84
            $rest += round($vBA, -4);
85
            if ($inDate >= mktime(0, 0, 0, 10, 1, 2010)) {
86
                $rest += round($this->tCmnSuperGlobals->get('gbns') * pow(10, 4), -4);
87
            }
88
        }
89
        $rest += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
90
        return $this->setIncomeTax($inDate, $rest, $arySettings['Income Tax']);
91
    }
92
93
    private function getOvertimes($aryStngs)
94
    {
95
        $pcToBoolean = [0 => true, 1 => false];
96
        $pcBoolean   = $pcToBoolean[$this->tCmnSuperGlobals->get('pc')];
97
        $ymVal       = $this->tCmnSuperGlobals->get('ym');
98
        $snVal       = $this->tCmnSuperGlobals->get('sn');
99
        $mnth        = $this->setMonthlyAverageWorkingHours($ymVal, $aryStngs, $pcBoolean);
100
        return [
101
            'os175' => ceil($this->tCmnSuperGlobals->get('os175') * 1.75 * $snVal / $mnth),
102
            'os200' => ceil($this->tCmnSuperGlobals->get('os200') * 2 * $snVal / $mnth),
103
        ];
104
    }
105
106
    private function getValues($lngBase, $aStngs)
107
    {
108
        $inDate             = $this->tCmnSuperGlobals->get('ym');
109
        $aReturn            = $this->getValuesPrimary($inDate, $lngBase, $aStngs);
110
        $pdVal              = [
111
            ($lngBase + $aReturn['ba']),
112
            $this->tCmnSuperGlobals->get('pi'),
113
            $aStngs['Personal Deduction'],
114
        ];
115
        $aReturn['pd']      = $this->setPersonalDeduction($inDate, $pdVal[1], $pdVal[2], $pdVal[3]);
116
        $aryDeductions      = [
117
            $aReturn['cas'],
118
            $aReturn['sanatate'],
119
            $aReturn['somaj'],
120
            $aReturn['pd'],
121
        ];
122
        $aReturn['impozit'] = $this->getIncomeTaxValue($inDate, $lngBase, $aReturn['ba'], $aryDeductions, $aStngs);
123
        return $aReturn;
124
    }
125
126
    private function getValuesPrimary($inDate, $lngBase, $aStngs)
127
    {
128
        $inDT             = new \DateTime(date('Y/m/d', $inDate));
129
        $wkDay            = $this->setWorkingDaysInMonth($inDT, $this->tCmnSuperGlobals->get('pc'));
130
        $nMealDays        = ($wkDay - $this->tCmnSuperGlobals->get('zfb'));
131
        $shLbl            = [
132
            'HFP'  => 'Health Fund Percentage',
133
            'HFUL' => 'Health Fund Upper Limit',
134
            'HTP'  => 'Health Tax Percentage',
135
            'MTV'  => 'Meal Ticket Value',
136
        ];
137
        $unemploymentBase = $lngBase;
138
        if ($this->tCmnSuperGlobals->get('ym') < mktime(0, 0, 0, 1, 1, 2008)) {
139
            $unemploymentBase = $this->tCmnSuperGlobals->get('sn');
140
        }
141
        return [
142
            'ba'       => $this->setFoodTicketsValue($inDate, $aStngs[$shLbl['MTV']]) * $nMealDays,
143
            'cas'      => $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]),
144
            'gbns'     => $this->tCmnSuperGlobals->get('gbns') * pow(10, 4),
145
            'sanatate' => $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']]),
146
            'somaj'    => $this->setUnemploymentTax($inDate, $unemploymentBase),
147
            'zile'     => $wkDay,
148
        ];
149
    }
150
151
    private function handleLocalizationSalariu($appSettings)
152
    {
153
        $this->handleLocalizationSalariuInputsIntoSession($appSettings);
154
        $this->handleLocalizationSalariuSafe($appSettings);
155
        $localizationFile = 'Salariu/locale/' . $this->tCmnSession->get('lang') . '/LC_MESSAGES/salariu.mo';
156
        $translations     = new \Gettext\Translations;
157
        $translations->addFromMoFile($localizationFile);
158
        $this->tApp       = new \Gettext\Translator();
159
        $this->tApp->loadTranslations($translations);
160
    }
161
162
    private function handleLocalizationSalariuInputsIntoSession($appSettings)
163
    {
164
        if (is_null($this->tCmnSuperGlobals->get('lang')) && is_null($this->tCmnSession->get('lang'))) {
165
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
166
        } elseif (!is_null($this->tCmnSuperGlobals->get('lang'))) {
167
            $this->tCmnSession->set('lang', filter_var($this->tCmnSuperGlobals->get('lang'), FILTER_SANITIZE_STRING));
168
        }
169
    }
170
171
    /**
172
     * to avoid potential language injections from other applications that do not applies here
173
     */
174
    private function handleLocalizationSalariuSafe($appSettings)
175
    {
176
        if (!array_key_exists($this->tCmnSession->get('lang'), $appSettings['Available Languages'])) {
177
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
178
        }
179
    }
180
181
    private function processFormInputDefaults($inDefaultValues)
182
    {
183
        if (is_null($this->tCmnSuperGlobals->get('ym'))) {
184
            $this->tCmnSuperGlobals->request->set('ym', mktime(0, 0, 0, date('m'), 1, date('Y')));
185
        }
186
        foreach ($inDefaultValues as $key => $value) {
187
            if (is_null($this->tCmnSuperGlobals->get($key))) {
188
                $this->tCmnSuperGlobals->request->set($key, $value);
189
            }
190
        }
191
    }
192
193
    private function setFooterHtml($appSettings)
194
    {
195
        $sReturn = $this->setUpperRightBoxLanguages($appSettings['Available Languages'])
196
            . '<div class="resetOnly author">&copy; ' . date('Y') . ' '
197
            . $appSettings['Copyright Holder'] . '</div>'
198
            . '<hr/>'
199
            . '<div class="disclaimer">'
200
            . $this->tApp->gettext('i18n_Disclaimer')
201
            . '</div>';
202
        return $this->setFooterCommon($sReturn);
0 ignored issues
show
Documentation introduced by
$sReturn is of type string, but the function expects a array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
203
    }
204
205
    private function setFormInput()
206
    {
207
        $sReturn     = $this->setFormInputElements();
208
        $btn         = $this->setStringIntoShortTag('input', [
209
            'type'  => 'submit',
210
            'id'    => 'submit',
211
            'value' => $this->setLabel('bc')
212
        ]);
213
        $sReturn[]   = $this->setFormRow($this->setLabel('fd'), $btn, 1);
214
        $frm         = $this->setStringIntoTag($this->setStringIntoTag(implode('', $sReturn), 'table'), 'form', [
215
            'method' => 'get',
216
            'action' => $this->tCmnSuperGlobals->getScriptName()
217
        ]);
218
        $aryFieldSet = [
219
            $this->setStringIntoTag($this->tApp->gettext('i18n_FieldsetLabel_Inputs'), 'legend'),
220
            $frm
221
        ];
222
        return $this->setStringIntoTag(implode('', $aryFieldSet), 'fieldset', ['style' => 'float: left;']);
223
    }
224
225
    private function setFormInputElements()
226
    {
227
        $sReturn   = [];
228
        $sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM(), 1);
229
        $sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1);
230
        $sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 2, '%'), 1);
231
        $sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1);
232
        $sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1);
233
        $sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, ''), 1);
234
        $sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, ''), 1);
235
        $sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1);
236
        $sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1);
237
        $sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1);
238
        $sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, ''), 1);
239
        $sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1);
240
        $sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1);
241
        return $sReturn;
242
    }
243
244
    private function setFormInputSelectPC()
245
    {
246
        $choices = [
247
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceNo'),
248
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceYes'),
249
        ];
250
        return $this->setArrayToSelect($choices, $this->tCmnSuperGlobals->get('pc'), 'pc', ['size' => 1]);
251
    }
252
253
    private function setFormInputSelectPI()
254
    {
255
        $temp2 = [];
256
        for ($counter = 0; $counter <= 4; $counter++) {
257
            $temp2[$counter] = $counter . ($counter == 4 ? '+' : '');
258
        }
259
        return $this->setArrayToSelect($temp2, $this->tCmnSuperGlobals->get('pi'), 'pi', ['size' => 1]);
260
    }
261
262
    private function setFormInputSelectYM()
263
    {
264
        $temp = [];
265
        for ($counter = date('Y'); $counter >= 2001; $counter--) {
266
            for ($counter2 = 12; $counter2 >= 1; $counter2--) {
267
                $crtDate = mktime(0, 0, 0, $counter2, 1, $counter);
268
                if ($crtDate <= mktime(0, 0, 0, date('m'), 1, date('Y'))) {
269
                    $temp[$crtDate] = strftime('%Y, %m (%B)', $crtDate);
270
                }
271
            }
272
        }
273
        return $this->setArrayToSelect($temp, $this->tCmnSuperGlobals->get('ym'), 'ym', ['size' => 1]);
274
    }
275
276
    private function setFormInputText($inName, $inSize, $inAfterLabel)
277
    {
278
        $inputParameters = [
279
            'type'      => 'text',
280
            'name'      => $inName,
281
            'value'     => $this->tCmnSuperGlobals->get($inName),
282
            'size'      => $inSize,
283
            'maxlength' => $inSize,
284
        ];
285
        return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel;
286
    }
287
288
    private function setFormOutput($configPath)
289
    {
290
        $aryStngs    = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute');
291
        $sReturn     = [];
292
        $ovTimeVal   = $this->getOvertimes($aryStngs['Monthly Average Working Hours']);
293
        $additions   = $this->tCmnSuperGlobals->get('pb') + $ovTimeVal['os175'] + $ovTimeVal['os200'];
294
        $bComponents = [
295
            'sc' => $this->tCmnSuperGlobals->get('sc'),
296
            'sn' => $this->tCmnSuperGlobals->get('sn'),
297
        ];
298
        $brut        = ($bComponents['sn'] * (1 + $bComponents['sc'] / 100) + $additions) * pow(10, 4);
299
        $text        = $this->tApp->gettext('i18n_Form_Label_ExchangeRateAtDate');
300
        $xRate       = str_replace('%1', date('d.m.Y', $this->currencyDetails['CXD']), $text);
301
        $sReturn[]   = $this->setFormRow($xRate, 10000000);
302
        $text        = $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary');
303
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('sn') * 10000);
304
        $prima       = $this->tCmnSuperGlobals->get('sn') * $this->tCmnSuperGlobals->get('sc') * 100;
305
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_CumulatedAddedValue'), $prima);
306
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalBruttoAmount');
307
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pb') * 10000);
308
        $ovTime      = [
309
            'm' => $this->tApp->gettext('i18n_Form_Label_OvertimeAmount'),
310
            1   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice1'),
311
            2   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice2'),
312
        ];
313
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[1], '175%'), ($ovTimeVal['os175'] * pow(10, 4)));
314
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[2], '200%'), ($ovTimeVal['os200'] * pow(10, 4)));
315
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_BruttoSalary'), $brut);
316
        $brut        += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
317
        $amount      = $this->getValues($brut, $aryStngs);
318
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PensionFund'), $amount['cas']);
319
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_UnemploymentTax'), $amount['somaj']);
320
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_HealthTax'), $amount['sanatate']);
321
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PersonalDeduction'), $amount['pd']);
322
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_ExciseTax'), $amount['impozit']);
323
        $retineri    = $amount['cas'] + $amount['somaj'] + $amount['sanatate'] + $amount['impozit'];
324
        $net         = $brut - $retineri + $this->tCmnSuperGlobals->get('pn') * 10000;
325
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalNettoAmount');
326
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pn') * 10000);
327
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_NettoSalary'), $net);
328
        $text        = $this->tApp->gettext('i18n_Form_Label_SeisureAmout');
329
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('szamnt') * 10000);
330
        $text        = $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash');
331
        $sReturn[]   = $this->setFormRow($text, ($net - $this->tCmnSuperGlobals->get('szamnt') * 10000));
332
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_WorkingDays'), $amount['zile'], 'value');
333
        $fBonus      = [
334
            'main'   => $this->tApp->gettext('i18n_Form_Label_FoodBonuses'),
335
            'no'     => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceNo'),
336
            'value'  => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue'),
337
            'mtDays' => ($amount['zile'] - $this->tCmnSuperGlobals->get('zfb'))
338
        ];
339
        $fBonusTxt   = sprintf($fBonus['main'], $fBonus['value'], $fBonus['no'], $fBonus['mtDays']);
340
        $sReturn[]   = $this->setFormRow($fBonusTxt, $amount['ba']);
341
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_FoodBonusesValue'), $amount['gbns']);
342
        $total       = ($net + $amount['ba'] + $amount['gbns'] - $this->tCmnSuperGlobals->get('szamnt') * 10000);
343
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_Total'), $total);
344
        setlocale(LC_TIME, explode('_', $this->tCmnSession->get('lang'))[0]);
345
        $crtMonth    = strftime('%B', $this->tCmnSuperGlobals->get('ym'));
346
        $legend      = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results')
347
            . '', $crtMonth, date('Y', $this->tCmnSuperGlobals->get('ym')));
348
        return $this->setStringIntoTag(implode('', [
349
                $this->setStringIntoTag($legend, 'legend'),
350
                $this->setStringIntoTag(implode('', $sReturn), 'table')
351
                ]), 'fieldset', ['style' => 'float: left;']);
352
    }
353
354
    private function setFormRow($text, $value, $type = 'amount')
355
    {
356
        $defaultCellStyle = $this->setFormatRow($text, $value);
357
        switch ($type) {
358
            case 'amount':
359
                $value2show = $this->setFormRowAmount(($value / pow(10, 4)), $defaultCellStyle);
360
                break;
361
            case 'value':
362
                $value2show = $this->setStringIntoTag($value, 'td', array_merge($defaultCellStyle, [
363
                    'colspan' => count($this->currencyDetails['CX'])
364
                ]));
365
                break;
366
            default:
367
                $value2show = $this->setStringIntoTag($value, 'td');
368
                break;
369
        }
370
        return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr');
371
    }
372
373
    private function setFormRowAmount($value, $defaultCellStyle)
374
    {
375
        $cellValue                 = [];
376
        $defaultCellStyle['style'] .= 'text-align:right;';
377
        foreach ($this->currencyDetails['CX'] as $key2 => $value2) {
378
            $fmt         = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY);
379
            $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']);
380
            $finalValue  = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2);
381
            $cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle);
382
        }
383
        return implode('', $cellValue);
384
    }
385
386
    private function setFormatRow($text, $value)
387
    {
388
        $defaultCellStyle = [
389
            'class' => 'labelS',
390
            'style' => 'color:#000;',
391
        ];
392
        $fieldsStyled     = $this->buildArrayOfFieldsStyled();
393
        if (array_key_exists($text, $fieldsStyled)) {
394
            $defaultCellStyle['style'] = $this->buildStyleForCellFormat($fieldsStyled[$text]);
395
        }
396
        if ((is_numeric($value)) && ($value == 0)) {
397
            $defaultCellStyle['style'] = 'color:#666;';
398
        }
399
        return $defaultCellStyle;
400
    }
401
402
    private function setHeaderHtml()
403
    {
404
        $headerParameters = [
405
            'lang'  => str_replace('_', '-', $this->tCmnSession->get('lang')),
406
            'title' => $this->tApp->gettext('i18n_ApplicationName'),
407
            'css'   => [
408
                'vendor/components/flag-icon-css/css/flag-icon.min.css',
409
                'Salariu/css/salariu.css',
410
            ],
411
        ];
412
        return $this->setHeaderCommon($headerParameters)
413
            . '<h1>' . $this->tApp->gettext('i18n_ApplicationName') . '</h1>';
414
    }
415
416
    private function setLabel($labelId)
417
    {
418
        $labelInfo = $this->appFlags['FI'][$labelId]['Label'];
419
        $sReturn   = '';
420
        if (is_array($labelInfo)) {
421
            if (count($labelInfo) == 3) {
422
                $pieces  = [
423
                    $this->tApp->gettext($labelInfo[0]),
424
                    $this->tApp->gettext($labelInfo[1]),
425
                ];
426
                $sReturn = sprintf($pieces[0], $pieces[1], $labelInfo[2]);
427
            }
428
        } elseif (is_string($labelInfo)) {
429
            $sReturn = $this->tApp->gettext($labelInfo);
430
        }
431
        return $this->setLabelSuffix($sReturn);
432
    }
433
434
    private function setLabelSuffix($text)
435
    {
436
        $suffix = '';
437
        if (!in_array($text, ['', '&nbsp;']) && (strpos($text, '<input') === false) && (substr($text, -1) !== '!')) {
438
            $suffix = ':';
439
        }
440
        return $text . $suffix;
441
    }
442
}
443