Completed
Push — master ( 1fa67c...2dbfbb )
by Daniel
03:46
created

Salariu::getValuesPrimary()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 12
nc 2
nop 5
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, $interfaceElements['Short Labels']);
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, $shLabels)
107
    {
108
        $inDate             = $this->tCmnSuperGlobals->get('ym');
109
        $inDT               = new \DateTime(date('Y/m/d', $inDate));
110
        $wkDay              = $this->setWorkingDaysInMonth($inDT, $this->tCmnSuperGlobals->get('pc'));
111
        $aReturn            = $this->getValuesPrimary($inDate, $wkDay, $lngBase, $aStngs, $shLabels);
112
        $pdV                = [
113
            ($lngBase + $aReturn['ba']),
114
            $this->tCmnSuperGlobals->get('pi'),
115
        ];
116
        $aReturn['pd']      = $this->setPersonalDeduction($inDate, $pdV[1], $pdV[2], $aStngs['Personal Deduction']);
117
        $aryDeductions      = [
118
            $aReturn['cas'],
119
            $aReturn['sanatate'],
120
            $aReturn['somaj'],
121
            $aReturn['pd'],
122
        ];
123
        $aReturn['impozit'] = $this->getIncomeTaxValue($inDate, $lngBase, $aReturn['ba'], $aryDeductions, $aStngs);
124
        return $aReturn;
125
    }
126
127
    private function getValuesPrimary($inDate, $wkDay, $lngBase, $aStngs, $shLbl)
128
    {
129
        $nMealDays        = ($wkDay - $this->tCmnSuperGlobals->get('zfb'));
130
        $unemploymentBase = $lngBase;
131
        if ($this->tCmnSuperGlobals->get('ym') < mktime(0, 0, 0, 1, 1, 2008)) {
132
            $unemploymentBase = $this->tCmnSuperGlobals->get('sn');
133
        }
134
        return [
135
            'ba'       => $this->setFoodTicketsValue($inDate, $aStngs[$shLbl['MTV']]) * $nMealDays,
136
            'cas'      => $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]),
137
            'gbns'     => $this->tCmnSuperGlobals->get('gbns') * pow(10, 4),
138
            'sanatate' => $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']]),
139
            'somaj'    => $this->setUnemploymentTax($inDate, $unemploymentBase),
140
            'zile'     => $wkDay,
141
        ];
142
    }
143
144
    private function handleLocalizationSalariu($appSettings)
145
    {
146
        $this->handleLocalizationSalariuInputsIntoSession($appSettings);
147
        $this->handleLocalizationSalariuSafe($appSettings);
148
        $localizationFile = 'Salariu/locale/' . $this->tCmnSession->get('lang') . '/LC_MESSAGES/salariu.mo';
149
        $translations     = new \Gettext\Translations;
150
        $translations->addFromMoFile($localizationFile);
151
        $this->tApp       = new \Gettext\Translator();
152
        $this->tApp->loadTranslations($translations);
153
    }
154
155
    private function handleLocalizationSalariuInputsIntoSession($appSettings)
156
    {
157
        if (is_null($this->tCmnSuperGlobals->get('lang')) && is_null($this->tCmnSession->get('lang'))) {
158
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
159
        } elseif (!is_null($this->tCmnSuperGlobals->get('lang'))) {
160
            $this->tCmnSession->set('lang', filter_var($this->tCmnSuperGlobals->get('lang'), FILTER_SANITIZE_STRING));
161
        }
162
    }
163
164
    /**
165
     * to avoid potential language injections from other applications that do not applies here
166
     */
167
    private function handleLocalizationSalariuSafe($appSettings)
168
    {
169
        if (!array_key_exists($this->tCmnSession->get('lang'), $appSettings['Available Languages'])) {
170
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
171
        }
172
    }
173
174
    private function processFormInputDefaults($inDefaultValues)
175
    {
176
        if (is_null($this->tCmnSuperGlobals->get('ym'))) {
177
            $this->tCmnSuperGlobals->request->set('ym', mktime(0, 0, 0, date('m'), 1, date('Y')));
178
        }
179
        foreach ($inDefaultValues as $key => $value) {
180
            if (is_null($this->tCmnSuperGlobals->get($key))) {
181
                $this->tCmnSuperGlobals->request->set($key, $value);
182
            }
183
        }
184
    }
185
186
    private function setFooterHtml($appSettings)
187
    {
188
        $sReturn = $this->setUpperRightBoxLanguages($appSettings['Available Languages'])
189
            . '<div class="resetOnly author">&copy; ' . date('Y') . ' '
190
            . $appSettings['Copyright Holder'] . '</div>'
191
            . '<hr/>'
192
            . '<div class="disclaimer">'
193
            . $this->tApp->gettext('i18n_Disclaimer')
194
            . '</div>';
195
        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...
196
    }
197
198
    private function setFormInput()
199
    {
200
        $sReturn     = $this->setFormInputElements();
201
        $btn         = $this->setStringIntoShortTag('input', [
202
            'type'  => 'submit',
203
            'id'    => 'submit',
204
            'value' => $this->setLabel('bc')
205
        ]);
206
        $sReturn[]   = $this->setFormRow($this->setLabel('fd'), $btn, 1);
207
        $frm         = $this->setStringIntoTag($this->setStringIntoTag(implode('', $sReturn), 'table'), 'form', [
208
            'method' => 'get',
209
            'action' => $this->tCmnSuperGlobals->getScriptName()
210
        ]);
211
        $aryFieldSet = [
212
            $this->setStringIntoTag($this->tApp->gettext('i18n_FieldsetLabel_Inputs'), 'legend'),
213
            $frm
214
        ];
215
        return $this->setStringIntoTag(implode('', $aryFieldSet), 'fieldset', ['style' => 'float: left;']);
216
    }
217
218
    private function setFormInputElements()
219
    {
220
        $sReturn   = [];
221
        $sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM(), 1);
222
        $sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1);
223
        $sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 2, '%'), 1);
224
        $sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1);
225
        $sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1);
226
        $sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, ''), 1);
227
        $sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, ''), 1);
228
        $sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1);
229
        $sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1);
230
        $sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1);
231
        $sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, ''), 1);
232
        $sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1);
233
        $sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1);
234
        return $sReturn;
235
    }
236
237
    private function setFormInputSelectPC()
238
    {
239
        $choices = [
240
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceNo'),
241
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceYes'),
242
        ];
243
        return $this->setArrayToSelect($choices, $this->tCmnSuperGlobals->get('pc'), 'pc', ['size' => 1]);
244
    }
245
246
    private function setFormInputSelectPI()
247
    {
248
        $temp2 = [];
249
        for ($counter = 0; $counter <= 4; $counter++) {
250
            $temp2[$counter] = $counter . ($counter == 4 ? '+' : '');
251
        }
252
        return $this->setArrayToSelect($temp2, $this->tCmnSuperGlobals->get('pi'), 'pi', ['size' => 1]);
253
    }
254
255
    private function setFormInputSelectYM()
256
    {
257
        $temp = [];
258
        for ($counter = date('Y'); $counter >= 2001; $counter--) {
259
            for ($counter2 = 12; $counter2 >= 1; $counter2--) {
260
                $crtDate = mktime(0, 0, 0, $counter2, 1, $counter);
261
                if ($crtDate <= mktime(0, 0, 0, date('m'), 1, date('Y'))) {
262
                    $temp[$crtDate] = strftime('%Y, %m (%B)', $crtDate);
263
                }
264
            }
265
        }
266
        return $this->setArrayToSelect($temp, $this->tCmnSuperGlobals->get('ym'), 'ym', ['size' => 1]);
267
    }
268
269
    private function setFormInputText($inName, $inSize, $inAfterLabel)
270
    {
271
        $inputParameters = [
272
            'type'      => 'text',
273
            'name'      => $inName,
274
            'value'     => $this->tCmnSuperGlobals->get($inName),
275
            'size'      => $inSize,
276
            'maxlength' => $inSize,
277
        ];
278
        return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel;
279
    }
280
281
    private function setFormOutput($configPath, $shLabels)
282
    {
283
        $aryStngs    = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute');
284
        $sReturn     = [];
285
        $ovTimeVal   = $this->getOvertimes($aryStngs['Monthly Average Working Hours']);
286
        $additions   = $this->tCmnSuperGlobals->get('pb') + $ovTimeVal['os175'] + $ovTimeVal['os200'];
287
        $bComponents = [
288
            'sc' => $this->tCmnSuperGlobals->get('sc'),
289
            'sn' => $this->tCmnSuperGlobals->get('sn'),
290
        ];
291
        $brut        = ($bComponents['sn'] * (1 + $bComponents['sc'] / 100) + $additions) * pow(10, 4);
292
        $text        = $this->tApp->gettext('i18n_Form_Label_ExchangeRateAtDate');
293
        $xRate       = str_replace('%1', date('d.m.Y', $this->currencyDetails['CXD']), $text);
294
        $sReturn[]   = $this->setFormRow($xRate, 10000000);
295
        $text        = $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary');
296
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('sn') * 10000);
297
        $prima       = $this->tCmnSuperGlobals->get('sn') * $this->tCmnSuperGlobals->get('sc') * 100;
298
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_CumulatedAddedValue'), $prima);
299
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalBruttoAmount');
300
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pb') * 10000);
301
        $ovTime      = [
302
            'm' => $this->tApp->gettext('i18n_Form_Label_OvertimeAmount'),
303
            1   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice1'),
304
            2   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice2'),
305
        ];
306
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[1], '175%'), ($ovTimeVal['os175'] * pow(10, 4)));
307
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[2], '200%'), ($ovTimeVal['os200'] * pow(10, 4)));
308
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_BruttoSalary'), $brut);
309
        $brut        += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
310
        $amount      = $this->getValues($brut, $aryStngs, $shLabels);
311
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PensionFund'), $amount['cas']);
312
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_UnemploymentTax'), $amount['somaj']);
313
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_HealthTax'), $amount['sanatate']);
314
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PersonalDeduction'), $amount['pd']);
315
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_ExciseTax'), $amount['impozit']);
316
        $retineri    = $amount['cas'] + $amount['somaj'] + $amount['sanatate'] + $amount['impozit'];
317
        $net         = $brut - $retineri + $this->tCmnSuperGlobals->get('pn') * 10000;
318
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalNettoAmount');
319
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pn') * 10000);
320
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_NettoSalary'), $net);
321
        $text        = $this->tApp->gettext('i18n_Form_Label_SeisureAmout');
322
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('szamnt') * 10000);
323
        $text        = $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash');
324
        $sReturn[]   = $this->setFormRow($text, ($net - $this->tCmnSuperGlobals->get('szamnt') * 10000));
325
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_WorkingDays'), $amount['zile'], 'value');
326
        $fBonus      = [
327
            'main'   => $this->tApp->gettext('i18n_Form_Label_FoodBonuses'),
328
            'no'     => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceNo'),
329
            'value'  => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue'),
330
            'mtDays' => ($amount['zile'] - $this->tCmnSuperGlobals->get('zfb'))
331
        ];
332
        $fBonusTxt   = sprintf($fBonus['main'], $fBonus['value'], $fBonus['no'], $fBonus['mtDays']);
333
        $sReturn[]   = $this->setFormRow($fBonusTxt, $amount['ba']);
334
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_FoodBonusesValue'), $amount['gbns']);
335
        $total       = ($net + $amount['ba'] + $amount['gbns'] - $this->tCmnSuperGlobals->get('szamnt') * 10000);
336
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_Total'), $total);
337
        setlocale(LC_TIME, explode('_', $this->tCmnSession->get('lang'))[0]);
338
        $crtMonth    = strftime('%B', $this->tCmnSuperGlobals->get('ym'));
339
        $legend      = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results')
340
            . '', $crtMonth, date('Y', $this->tCmnSuperGlobals->get('ym')));
341
        return $this->setStringIntoTag(implode('', [
342
                $this->setStringIntoTag($legend, 'legend'),
343
                $this->setStringIntoTag(implode('', $sReturn), 'table')
344
                ]), 'fieldset', ['style' => 'float: left;']);
345
    }
346
347
    private function setFormRow($text, $value, $type = 'amount')
348
    {
349
        $defaultCellStyle = $this->setFormatRow($text, $value);
350
        switch ($type) {
351
            case 'amount':
352
                $value2show = $this->setFormRowAmount(($value / pow(10, 4)), $defaultCellStyle);
353
                break;
354
            case 'value':
355
                $value2show = $this->setStringIntoTag($value, 'td', array_merge($defaultCellStyle, [
356
                    'colspan' => count($this->currencyDetails['CX'])
357
                ]));
358
                break;
359
            default:
360
                $value2show = $this->setStringIntoTag($value, 'td');
361
                break;
362
        }
363
        return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr');
364
    }
365
366
    private function setFormRowAmount($value, $defaultCellStyle)
367
    {
368
        $cellValue                 = [];
369
        $defaultCellStyle['style'] .= 'text-align:right;';
370
        foreach ($this->currencyDetails['CX'] as $key2 => $value2) {
371
            $fmt         = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY);
372
            $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']);
373
            $finalValue  = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2);
374
            $cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle);
375
        }
376
        return implode('', $cellValue);
377
    }
378
379
    private function setFormatRow($text, $value)
380
    {
381
        $defaultCellStyle = [
382
            'class' => 'labelS',
383
            'style' => 'color:#000;',
384
        ];
385
        $fieldsStyled     = $this->buildArrayOfFieldsStyled();
386
        if (array_key_exists($text, $fieldsStyled)) {
387
            $defaultCellStyle['style'] = $this->buildStyleForCellFormat($fieldsStyled[$text]);
388
        }
389
        if ((is_numeric($value)) && ($value == 0)) {
390
            $defaultCellStyle['style'] = 'color:#666;';
391
        }
392
        return $defaultCellStyle;
393
    }
394
395
    private function setHeaderHtml()
396
    {
397
        $headerParameters = [
398
            'lang'  => str_replace('_', '-', $this->tCmnSession->get('lang')),
399
            'title' => $this->tApp->gettext('i18n_ApplicationName'),
400
            'css'   => [
401
                'vendor/components/flag-icon-css/css/flag-icon.min.css',
402
                'Salariu/css/salariu.css',
403
            ],
404
        ];
405
        return $this->setHeaderCommon($headerParameters)
406
            . '<h1>' . $this->tApp->gettext('i18n_ApplicationName') . '</h1>';
407
    }
408
409
    private function setLabel($labelId)
410
    {
411
        $labelInfo = $this->appFlags['FI'][$labelId]['Label'];
412
        $sReturn   = '';
413
        if (is_array($labelInfo)) {
414
            if (count($labelInfo) == 3) {
415
                $pieces  = [
416
                    $this->tApp->gettext($labelInfo[0]),
417
                    $this->tApp->gettext($labelInfo[1]),
418
                ];
419
                $sReturn = sprintf($pieces[0], $pieces[1], $labelInfo[2]);
420
            }
421
        } elseif (is_string($labelInfo)) {
422
            $sReturn = $this->tApp->gettext($labelInfo);
423
        }
424
        return $this->setLabelSuffix($sReturn);
425
    }
426
427
    private function setLabelSuffix($text)
428
    {
429
        $suffix = '';
430
        if (!in_array($text, ['', '&nbsp;']) && (strpos($text, '<input') === false) && (substr($text, -1) !== '!')) {
431
            $suffix = ':';
432
        }
433
        return $text . $suffix;
434
    }
435
}
436