Completed
Push — master ( dfe00f...254490 )
by Daniel
04:49
created

Salariu::getValuesPrimary()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
rs 9.2
cc 3
eloc 18
nc 4
nop 5
1
<?php
2
3
/**
4
 *
5
 * The MIT License (MIT)
6
 *
7
 * Copyright (c) 2017 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\salariu\FormattingSalariu,
36
        \danielgp\salariu\Bonuses,
37
        \danielgp\salariu\ForeignCurrency,
38
        \danielgp\salariu\Taxation;
39
40
    public function __construct() {
41
        $configPath = 'Salariu' . DIRECTORY_SEPARATOR . 'config';
42
        $inElmnts   = $this->readTypeFromJsonFileUniversal($configPath, 'interfaceElements');
43
        $this->setPreliminarySettings($inElmnts);
44
        $this->establishLocalizationToDisplay();
45
        $this->setExchangeRateValues($inElmnts['Application'], $inElmnts['Relevant Currencies']);
46
        $dtR        = $this->dateRangesInScope();
47
        $ymValues   = $this->buildYMvalues($dtR);
48
        $arySts     = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute');
49
        echo '<div class="tabber" id="Salary">'
50
        . $this->setFormInput($dtR, $ymValues, $arySts)
51
        . $this->setFormOutput($arySts, $inElmnts['Short Labels'], $dtR)
52
        . '</div>';
53
        echo $this->setFooterHtml($inElmnts['Application']);
54
    }
55
56
    private function getOvertimes($aryStngs) {
57
        $pcToBoolean = [0 => true, 1 => false];
58
        $pcBoolean   = $pcToBoolean[$this->tCmnSuperGlobals->request->get('pc')];
59
        $ymVal       = (string) $this->tCmnSuperGlobals->request->get('ym');
60
        $snVal       = $this->tCmnSuperGlobals->request->get('sn');
61
        $mnth        = $this->setMonthlyAverageWorkingHours($ymVal, $aryStngs, $pcBoolean);
62
        return [
63
            'os175' => ceil($this->tCmnSuperGlobals->request->get('os175') * 1.75 * $snVal / $mnth),
64
            'os200' => ceil($this->tCmnSuperGlobals->request->get('os200') * 2 * $snVal / $mnth),
65
        ];
66
    }
67
68
    private function getValues($lngBase, $aStngs, $shLabels, $dtR) {
69
        $inDate             = $this->tCmnSuperGlobals->request->get('ym');
70
        $aReturn            = $this->getValuesPrimary($inDate, $lngBase, $aStngs, $shLabels, $dtR);
71
        $pdV                = [
72
            ($lngBase + $aReturn['ba']),
73
            $this->tCmnSuperGlobals->request->get('pi'),
74
        ];
75
        $aPd                = $aStngs['Personal Deduction'];
76
        $aReturn['pd']      = $this->setPersonalDeduction($inDate, $pdV[0], $pdV[1], $aPd);
77
        $aryDeductions      = [$this->txLvl['cas'], $this->txLvl['snt'], $this->txLvl['smj'], $aReturn['pd']];
78
        $aReturn['impozit'] = $this->getIncomeTaxValue($this->tCmnSuperGlobals, [
79
            'inDate'             => $inDate,
80
            'lngBase'            => $lngBase,
81
            'Food Tickets Value' => $aReturn['ba'],
82
            'Deductions'         => $aryDeductions,
83
            'Income Tax'         => $aStngs['Income Tax'],
84
        ]);
85
        return $aReturn;
86
    }
87
88
    private function getValuesPrimary($inDate, $lngBase, $aStngs, $shLbl, $dtR) {
89
        $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]);
90
        $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']], $aStngs[$shLbl['HFUL']]);
91
        $nMealDays        = $this->tCmnSuperGlobals->request->get('nDays');
92
        $unemploymentBase = $lngBase;
93
        $yearMonth        = $this->tCmnSuperGlobals->request->get('ym');
94
        if ($yearMonth < 20080101) {
95
            $unemploymentBase = $this->tCmnSuperGlobals->request->get('sn');
96
        }
97
        $this->setUnemploymentTax($inDate, $unemploymentBase, $yearMonth, $aStngs['Unemployment Tax'], $dtR);
98
        $bac = 0;
99
        if ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fc') {
100
            $nMealDays = 0;
101
            $bac       = $this->tCmnSuperGlobals->request->get('fc');
102
        }
103
        return [
104
            'b1'   => $this->tCmnSuperGlobals->request->get('fb') * pow(10, 4),
105
            'ba'   => $this->tCmnSuperGlobals->request->get('fb') * pow(10, 4) * $nMealDays,
106
            'bac'  => $bac * pow(10, 4),
107
            'gbns' => $this->tCmnSuperGlobals->request->get('gbns') * pow(10, 4),
108
        ];
109
    }
110
111
    private function getWorkingDays() {
112
        $components = [
113
            \DateTime::createFromFormat('Ymd', $this->tCmnSuperGlobals->request->get('ym')),
114
            $this->tCmnSuperGlobals->request->get('pc'),
115
        ];
116
        if ($components[0] === false) {
117
            $components[0] = new \DateTime('first day of this month');
118
        }
119
        $this->tCmnSuperGlobals->request->set('wkDays', $this->setWorkingDaysInMonth($components[0], $components[1]));
120
        $vDays = $this->tCmnSuperGlobals->request->get('wkDays') - $this->tCmnSuperGlobals->request->get('zfb');
121
        $this->tCmnSuperGlobals->request->set('nDays', max($vDays, 0));
122
    }
123
124
    private function setFormInput($dtR, $ymValues, $arySts) {
125
        $this->applyYMvalidations($this->tCmnSuperGlobals, $ymValues, $dtR);
126
        $minWage = $this->determineCrtMinWage($this->tCmnSuperGlobals, [
127
            'EMW'      => $arySts['Minimum Wage'],
128
            'YM range' => $dtR
129
        ]);
130
        $lngDate = $this->tCmnSuperGlobals->request->get('ym');
131
        $fbValue = $this->setFoodTicketsValue($dtR, $lngDate, $arySts['Meal Ticket Value']) / pow(10, 4);
132
        $fcValue = $this->setFoodTicketsValue($dtR, $lngDate, $arySts['Food Compensation Rule']);
133
        $this->processFormInputDefaults($this->tCmnSuperGlobals, [
134
            'VFR'               => $this->appFlags['VFR'],
135
            'Year Month Values' => $ymValues,
136
            'MW'                => $minWage,
137
            'YM range'          => $dtR,
138
            'fb'                => $fbValue,
139
            'fc'                => round(($minWage * $fcValue), 0),
140
        ]);
141
        $sReturn = $this->setFormInputElements($ymValues, $minWage) . $this->setFormInputBottom();
142
        $frm     = $this->setStringIntoTag($this->setStringIntoTag($sReturn, 'table'), 'form', [
143
            'method' => 'get',
144
            'action' => $this->tCmnSuperGlobals->getScriptName()
145
        ]);
146
        return $this->setFormInputIntoFieldSet($frm);
147
    }
148
149
    private function setFormInputBottom() {
150
        $xChoices  = [];
151
        $xCurrency = array_diff(array_keys($this->currencyDetails['CX']), ['RON']);
152
        $this->applyCurrencyValidations($this->tCmnSuperGlobals, $this->appFlags['DCTD'], $xCurrency);
153
        foreach ($xCurrency as $value) {
154
            $xChoices[$value] = $value . ' (' . $this->tApp->gettext('i18n_Form_Label_CurrencyName_' . $value) . ')';
155
        }
156
        $xSelect = $this->setArrayToSelect($xChoices, $this->tCmnSuperGlobals->request->get('xMoney'), 'xMoney[]', [
157
            'size' => 100,
158
            'multiselect',
159
        ]);
160
        $sRow    = $this->setFormRow($this->setLabel('xMoney'), $xSelect, 1);
161
        $btn     = $this->setStringIntoShortTag('input', [
162
            'type'  => 'submit',
163
            'id'    => 'submit',
164
            'value' => $this->tApp->gettext('i18n_Form_Button_Recalculate')
165
        ]);
166
        return $this->setFormRow('&nbsp;', $btn, 1) . $sRow . '</tbody>';
167
    }
168
169
    private function setFormInputElements($ymValues, $crtMinWage) {
170
        $sReturn   = [];
171
        $sReturn[] = '<thead><tr><th>' . $this->tApp->gettext('i18n_Form_Label_InputElements')
172
                . '</th><th>' . $this->tApp->gettext('i18n_Form_Label_InputValues') . '</th></tr></thead><tbody>';
173
        $sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM($ymValues), 1);
174
        if (!is_array($this->tCmnSuperGlobals->get('given_food_type'))) {
175
            $this->tCmnSuperGlobals->request->set('given_food_type', [0 => 'fb']);
176
        }
177
        $sReturn[] = $this->setFormRow('<input type="radio" name="given_food_type[]" value="fb" id="gft_fb"'
178
                . ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fb' ? ' checked' : '') . ' />'
179
                . '<label for="gft_fb">' . $this->setLabel('fb')
180
                . '</label>', $this->setFormInputText('fb', 5, 'RON'), 1);
181
        $sReturn[] = $this->setFormRow('<input type="radio" name="given_food_type[]" value="fc" id="gft_fc"'
182
                . ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fc' ? ' checked' : '') . ' />'
183
                . '<label for="gft_fc">' . $this->setLabel('fc')
184
                . '</label>', $this->setFormInputText('fc', 10, 'RON'), 1);
185
        $sReturn[] = $this->setFormRow($this->setLabel('sm'), $this->setFormInputText('sm', 10, 'RON', $crtMinWage), 1);
186
        $sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1);
187
        $sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 7, '%'), 1);
188
        $sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1);
189
        $sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1);
190
        $sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, 'ore'), 1);
191
        $sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, 'ore'), 1);
192
        $sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1);
193
        $sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1);
194
        $sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1);
195
        $sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, 'zile'), 1);
196
        $sReturn[] = $this->setFormRow($this->setLabel('zfs'), $this->setFormInputText('zfs', 2, 'zile'), 1);
197
        $sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1);
198
        $sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1);
199
        return implode($sReturn, '');
200
    }
201
202
    private function setFormInputIntoFieldSet($frm) {
203
        return '<div class="tabbertab" id="Input" title="' . $this->tApp->gettext('i18n_FieldsetLabel_Inputs') . '">'
204
                . $frm . '</div>';
205
    }
206
207
    private function setFormInputText($inName, $inSize, $inAfterLabel, $crtMinWage = 0) {
208
        $inputParameters = [
209
            'type'      => 'text',
210
            'name'      => $inName,
211
            'value'     => $this->tCmnSuperGlobals->request->get($inName),
212
            'size'      => $inSize,
213
            'maxlength' => $inSize,
214
        ];
215
        if (in_array($inName, ['fc', 'sm'])) {
216
            $inputParameters['readonly'] = 'readonly';
217
        }
218
        if (in_array($inName, ['sm'])) {
219
            $inputParameters['value'] = $crtMinWage;
220
            $this->tCmnSuperGlobals->request->set($inName, $crtMinWage);
221
        }
222
        return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel;
223
    }
224
225
    private function setFormOutput($aryStngs, $inElements, $dtR) {
226
        $sReturn     = [];
227
        $sReturn[]   = $this->setFormOutputHeader();
228
        $ovTimeVal   = $this->getOvertimes($aryStngs['Monthly Average Working Hours']);
229
        $additions   = $this->tCmnSuperGlobals->request->get('pb') + $ovTimeVal['os175'] + $ovTimeVal['os200'];
230
        $this->getWorkingDays();
231
        $bComponents = [
232
            'sc'   => $this->tCmnSuperGlobals->request->get('sc'),
233
            'sn'   => $this->tCmnSuperGlobals->request->get('sn'),
234
            'zile' => $this->tCmnSuperGlobals->request->get('wkDays'),
235
        ];
236
        $xDate       = '<span style="font-size:smaller;">' . date('d.m.Y', $this->currencyDetails['CXD']) . '</span>';
237
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('xrate@Date'), $xDate, pow(10, 4));
238
        $snValue     = $this->tCmnSuperGlobals->request->get('sn') * pow(10, 4);
239
        $amntLAA     = round(($this->tCmnSuperGlobals->request->get('zfs') / $bComponents['zile']) * $snValue, -4);
240
        $sReturn[]   = $this->setFormOutputBonuses($snValue, $bComponents['zile'], $amntLAA, $ovTimeVal);
241
        $brut        = ($bComponents['sn'] * (1 + $bComponents['sc'] / 100) + $additions) * pow(10, 4) - $amntLAA;
242
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('sb'), '&nbsp;', $brut);
243
        $brut2       = $brut + $this->tCmnSuperGlobals->request->get('afet') * pow(10, 4);
244
        $amnt        = $this->getValues($brut2, $aryStngs, $inElements, $dtR);
245
        $sReturn[]   = $this->setFormOutputTaxations($brut2, $amnt);
246
        $pnValue     = $this->tCmnSuperGlobals->request->get('pn') * pow(10, 4);
247
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('pn'), '&nbsp;', $pnValue);
248
        $retineri    = $this->txLvl['cas'] + $this->txLvl['smj'] + $this->txLvl['snt'] + $amnt['impozit'];
249
        $net         = $brut2 - $retineri + $this->tCmnSuperGlobals->request->get('pn') * pow(10, 4);
250
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('ns'), '&nbsp;', $net);
251
        $szamntValue = $this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4);
252
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('szamnt'), '&nbsp;', $szamntValue);
253
        $nsc         = $net - $this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4);
254
        $sReturn[]   = $this->setFrmRowTwoLbls($this->setLabel('nsc'), '&nbsp;', $nsc);
255
        $fBonus      = [
256
            'main'   => $this->setLabel('gb'),
257
            'value'  => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue'),
258
            'mtDays' => $this->tCmnSuperGlobals->request->get('nDays') . '&nbsp;/&nbsp;' . $bComponents['zile']
259
        ];
260
        switch ($this->tCmnSuperGlobals->get('given_food_type')[0]) {
261
            case 'fc':
262
                $fBonus['mtDays'] = '0&nbsp;/&nbsp;' . $bComponents['zile'];
263
                break;
264
        }
265
        $fBonusTxt  = sprintf($fBonus['main'], $fBonus['value']);
266
        $sReturn[]  = $this->setFrmRowTwoLbls($this->setLabel('fb'), '1', $amnt['b1']);
267
        $sReturn[]  = $this->setFrmRowTwoLbls($fBonusTxt, $fBonus['mtDays'], $amnt['ba']);
268
        $sReturn[]  = $this->setFrmRowTwoLbls($this->setLabel('fc'), '', $amnt['bac']);
269
        $sReturn[]  = $this->setFrmRowTwoLbls($this->setLabel('gbns'), '&nbsp;', $amnt['gbns']);
270
        $total      = array_sum([
271
            $net,
272
            $amnt['ba'],
273
            $amnt['bac'],
274
            $amnt['gbns'],
275
            -$this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4)
276
        ]);
277
        $sReturn[]  = $this->setFrmRowTwoLbls($this->setLabel('total'), '&nbsp;', $total);
278
        $tDate      = \DateTime::createFromFormat('Ymd', $this->tCmnSuperGlobals->request->get('ym'));
279
        $legentText = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results'), ''
280
                . strftime('%B', mktime(0, 0, 0, $tDate->format('n'), 1, $tDate->format('Y'))), $tDate->format('Y'));
281
        return '<div class="tabbertab tabbertabdefault" id="Output" title="' . $legentText . '">'
282
                . $this->setStringIntoTag(implode('', $sReturn), 'table') . '</tbody>' . '</div>';
283
    }
284
285
    private function setFormOutputBonuses($snValue, $wkDays, $amntLAA, $ovTimeVal) {
286
        $sRt      = [];
287
        $sMin     = $this->tCmnSuperGlobals->request->get('sm') * pow(10, 4);
288
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('sm'), '&nbsp;', $sMin);
289
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('sn'), '&nbsp;', $snValue);
290
        $scValue  = $this->tCmnSuperGlobals->request->get('sc');
291
        $prima    = $this->tCmnSuperGlobals->request->get('sn') * $scValue * 100;
292
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('sc'), $scValue . '%', $prima);
293
        $pbValue  = $this->tCmnSuperGlobals->request->get('pb') * pow(10, 4);
294
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('pb'), '&nbsp;', $pbValue);
295
        $ovTime   = [
296
            'o1' => $this->tCmnSuperGlobals->request->get('os175'),
297
            'o2' => $this->tCmnSuperGlobals->request->get('os200'),
298
        ];
299
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('ovAmount1'), '<span style="font-size:smaller;">'
300
                . $ovTime['o1'] . 'h&nbsp;x&nbsp;175%</span>', $ovTimeVal['os175'] * pow(10, 4));
301
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('ovAmount2'), '<span style="font-size:smaller;">'
302
                . $ovTime['o2'] . 'h&nbsp;x&nbsp;200%</span>', $ovTimeVal['os200'] * pow(10, 4));
303
        $fLeaveAA = $this->tCmnSuperGlobals->request->get('zfs') . '&nbsp;/&nbsp;' . $wkDays;
304
        $sRt[]    = $this->setFrmRowTwoLbls($this->setLabel('zfsa'), $fLeaveAA, $amntLAA);
305
        return implode('', $sRt);
306
    }
307
308
    private function setFormOutputHeader() {
309
        $sReturn               = [];
310
        $sReturn[]             = '<thead><tr><th>' . $this->tApp->gettext('i18n_Form_Label_ResultedElements') . '</th>';
311
        $sReturn[]             = '<th><i class="fa fa-map-signs floatRight" style="font-size:2em;">&nbsp;</i></th>';
312
        $this->appFlags['CTD'] = $this->manageCurrencyToDisplay($this->tCmnSuperGlobals);
313
        foreach ($this->appFlags['CTD'] as $key => $value) {
314
            $crtPcs    = [
315
                $this->tApp->gettext('i18n_Form_Label_XofficialCurrencyUsedFrom'),
316
                $this->tApp->gettext('i18n_Form_Label_CurrencyName_' . $key),
317
                $this->tApp->gettext('i18n_CountryName_' . strtoupper($value['country'])),
318
            ];
319
            $sReturn[] = '<th style="text-align:center;"><span class="flag-icon flag-icon-' . $value['country']
320
                    . '" style="font-size:2em;" title="' . sprintf($crtPcs[0], $crtPcs[1], $crtPcs[2])
321
                    . '">&nbsp;</span></th>';
322
        }
323
        return implode('', $sReturn) . '</tr></thead></tbody>';
324
    }
325
326
    private function setFormOutputTaxations($brut, $amnt) {
327
        $sRn              = [];
328
        $limitDisplayBase = false;
329 View Code Duplication
        if ($brut > $this->txLvl['casP_base']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
330
            $limitDisplayBase = true;
331
            $sRn[]            = $this->setFrmRowTwoLbls($this->setLabel('cas_base'), '', $this->txLvl['casP_base']);
332
        }
333
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('cas'), $this->txLvl['casP'] . '%', $this->txLvl['cas']);
334
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('somaj'), $this->txLvl['smjP'] . '%', $this->txLvl['smj']);
335 View Code Duplication
        if ($limitDisplayBase && array_key_exists('sntP_base', $this->txLvl)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
336
            $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('sntP_base'), '&nbsp;', $this->txLvl['sntP_base']);
337
        }
338
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('sanatate'), $this->txLvl['sntP'] . '%', $this->txLvl['snt']);
339
        $rst   = $brut - ($this->txLvl['cas'] + $this->txLvl['snt'] + $this->txLvl['smj']);
340
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('rst'), '&nbsp;', $rst);
341
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('pd'), '&nbsp;', $amnt['pd']);
342
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('impozit_base'), '&nbsp;', $this->txLvl['inTaxP_base']);
343
        $sRn[] = $this->setFrmRowTwoLbls($this->setLabel('impozit'), $this->txLvl['inTaxP'] . '%', $amnt['impozit']);
344
        return implode('', $sRn);
345
    }
346
347
    private function setFormRow($text, $value, $type = 'amount') {
348
        $defaultCellStyle = $this->setFormatRow($text, $value);
349
        switch ($type) {
350
            case 'amount':
351
                $value2show = $this->setFormRowAmount(($value / pow(10, 4)), $defaultCellStyle);
352
                break;
353
            case 'value':
354
                $value2show = $this->setStringIntoTag($value, 'td', array_merge($defaultCellStyle, [
355
                    'colspan' => count($this->currencyDetails['CX'])
356
                ]));
357
                break;
358
            default:
359
                $value2show = $this->setStringIntoTag($value, 'td');
360
                break;
361
        }
362
        return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr');
363
    }
364
365
    private function setFormRowAmount($value, $defaultCellStyle) {
366
        $cellValue                 = [];
367
        $defaultCellStyle['style'] .= 'text-align:right;';
368
        foreach ($this->appFlags['CTD'] as $key2 => $value2) {
369
            $fmt         = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY);
370
            $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']);
371
            $finalValue  = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2);
372
            $cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle);
373
        }
374
        return implode('', $cellValue);
375
    }
376
377
    private function setFrmRowTwoLbls($text1, $text2, $value) {
378
        return str_replace(':</td>', ':</td><td class="labelS" style="text-align:right;">'
379
                . $text2 . '</td>', $this->setFormRow($text1, $value, 'amount'));
380
    }
381
382
}
383