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
|
|
|
{ |
42
|
|
|
$configPath = 'static' . DIRECTORY_SEPARATOR . 'config'; |
43
|
|
|
$inElmnts = $this->readTypeFromJsonFileUniversal($configPath, 'interfaceElements'); |
44
|
|
|
$this->setPreliminarySettings($inElmnts); |
45
|
|
|
$this->establishLocalizationToDisplay(); |
46
|
|
|
$this->setExchangeRateValues($inElmnts['Application'], $inElmnts['Relevant Currencies']); |
47
|
|
|
$dtR = $this->dateRangesInScope(); |
48
|
|
|
$ymValues = $this->buildYMvalues($dtR); |
49
|
|
|
$arySts = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute'); |
50
|
|
|
echo '<div class="tabber" id="Salary">' |
51
|
|
|
. $this->setFormInput($dtR, $ymValues, $arySts) |
52
|
|
|
. $this->setFormOutput($arySts, $inElmnts['Short Labels'], $dtR) |
53
|
|
|
. '</div>'; |
54
|
|
|
echo $this->setFooterHtml($inElmnts['Application']); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private function getOvertimes($aryStngs) |
58
|
|
|
{ |
59
|
|
|
$pcToBoolean = [0 => true, 1 => false]; |
60
|
|
|
$pcBoolean = $pcToBoolean[$this->tCmnSuperGlobals->request->get('pc')]; |
61
|
|
|
$ymVal = (string) $this->tCmnSuperGlobals->request->get('ym'); |
62
|
|
|
$snVal = $this->tCmnSuperGlobals->request->get('sn'); |
63
|
|
|
$mnth = $this->setMonthlyAverageWorkingHours($ymVal, $aryStngs, $pcBoolean); |
64
|
|
|
return [ |
65
|
|
|
'os175' => ceil($this->tCmnSuperGlobals->request->get('os175') * 1.75 * $snVal / $mnth), |
66
|
|
|
'os200' => ceil($this->tCmnSuperGlobals->request->get('os200') * 2 * $snVal / $mnth), |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
private function getValues($lngBase, $aStngs, $shLabels, $dtR) |
71
|
|
|
{ |
72
|
|
|
$inDate = $this->tCmnSuperGlobals->request->get('ym'); |
73
|
|
|
$aReturn = $this->getValuesPrimary($inDate, $lngBase, $aStngs, $shLabels, $dtR); |
74
|
|
|
$pdV = [ |
75
|
|
|
($lngBase + $aReturn['ba']), |
76
|
|
|
$this->tCmnSuperGlobals->request->get('pi'), |
77
|
|
|
]; |
78
|
|
|
$aPd = $aStngs['Personal Deduction']; |
79
|
|
|
$aReturn['pd'] = $this->setPersonalDeduction($inDate, $pdV[0], $pdV[1], $aPd); |
80
|
|
|
$aryDeductions = [$this->txLvl['cas'], $this->txLvl['snt'], $this->txLvl['smj'], $aReturn['pd']]; |
81
|
|
|
$aReturn['impozit'] = $this->getIncomeTaxValue($this->tCmnSuperGlobals, [ |
82
|
|
|
'inDate' => $inDate, |
83
|
|
|
'lngBase' => $lngBase, |
84
|
|
|
'Food Tickets Value' => $aReturn['ba'], |
85
|
|
|
'Deductions' => $aryDeductions, |
86
|
|
|
'Income Tax' => $aStngs['Income Tax'], |
87
|
|
|
]); |
88
|
|
|
return $aReturn; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
private function getValuesPrimary($inDate, $lngBase, $aStngs, $shLbl, $dtR) |
92
|
|
|
{ |
93
|
|
|
$this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]); |
94
|
|
|
$this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']], $aStngs[$shLbl['HFUL']]); |
95
|
|
|
$nMealDays = $this->tCmnSuperGlobals->request->get('nDays'); |
96
|
|
|
$unemploymentBase = $lngBase; |
97
|
|
|
$yearMonth = $this->tCmnSuperGlobals->request->get('ym'); |
98
|
|
|
if ($yearMonth < 20080101) { |
99
|
|
|
$unemploymentBase = $this->tCmnSuperGlobals->request->get('sn'); |
100
|
|
|
} |
101
|
|
|
$this->setUnemploymentTax($inDate, $unemploymentBase, $yearMonth, $aStngs['Unemployment Tax'], $dtR); |
102
|
|
|
$bac = 0; |
103
|
|
|
if ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fc') { |
104
|
|
|
$nMealDays = 0; |
105
|
|
|
$bac = $this->tCmnSuperGlobals->request->get('fc'); |
106
|
|
|
} |
107
|
|
|
return [ |
108
|
|
|
'b1' => $this->tCmnSuperGlobals->request->get('fb') * pow(10, 4), |
109
|
|
|
'ba' => $this->tCmnSuperGlobals->request->get('fb') * pow(10, 4) * $nMealDays, |
110
|
|
|
'bac' => $bac * pow(10, 4), |
111
|
|
|
'gbns' => $this->tCmnSuperGlobals->request->get('gbns') * pow(10, 4), |
112
|
|
|
]; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
private function getWorkingDays() |
116
|
|
|
{ |
117
|
|
|
$components = [ |
118
|
|
|
\DateTime::createFromFormat('Ymd', $this->tCmnSuperGlobals->request->get('ym')), |
119
|
|
|
$this->tCmnSuperGlobals->request->get('pc'), |
120
|
|
|
]; |
121
|
|
|
if ($components[0] === false) { |
122
|
|
|
$components[0] = new \DateTime('first day of this month'); |
123
|
|
|
} |
124
|
|
|
$this->tCmnSuperGlobals->request->set('wkDays', $this->setWorkingDaysInMonth($components[0], $components[1])); |
125
|
|
|
$vDays = $this->tCmnSuperGlobals->request->get('wkDays') - $this->tCmnSuperGlobals->request->get('zfb'); |
126
|
|
|
$this->tCmnSuperGlobals->request->set('nDays', max($vDays, 0)); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
private function setFormInput($dtR, $ymValues, $arySts) |
130
|
|
|
{ |
131
|
|
|
$this->applyYMvalidations($this->tCmnSuperGlobals, $ymValues, $dtR); |
132
|
|
|
$minWage = $this->determineCrtMinWage($this->tCmnSuperGlobals, [ |
133
|
|
|
'EMW' => $arySts['Minimum Wage'], |
134
|
|
|
'YM range' => $dtR |
135
|
|
|
]); |
136
|
|
|
$lngDate = $this->tCmnSuperGlobals->request->get('ym'); |
137
|
|
|
$fbValue = $this->setFoodTicketsValue($dtR, $lngDate, $arySts['Meal Ticket Value']) / pow(10, 4); |
138
|
|
|
$fcValue = $this->setFoodTicketsValue($dtR, $lngDate, $arySts['Food Compensation Rule']); |
139
|
|
|
$this->processFormInputDefaults($this->tCmnSuperGlobals, [ |
140
|
|
|
'VFR' => $this->appFlags['VFR'], |
141
|
|
|
'Year Month Values' => $ymValues, |
142
|
|
|
'MW' => $minWage, |
143
|
|
|
'YM range' => $dtR, |
144
|
|
|
'fb' => $fbValue, |
145
|
|
|
'fc' => round(($minWage * $fcValue), 0), |
146
|
|
|
]); |
147
|
|
|
$sReturn = $this->setFormInputElements($ymValues, $minWage) . $this->setFormInputBottom(); |
148
|
|
|
$frm = $this->setStringIntoTag($this->setStringIntoTag($sReturn, 'table'), 'form', [ |
149
|
|
|
'method' => 'get', |
150
|
|
|
'action' => $this->tCmnSuperGlobals->getScriptName() |
151
|
|
|
]); |
152
|
|
|
return $this->setFormInputIntoFieldSet($frm); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
private function setFormInputBottom() |
156
|
|
|
{ |
157
|
|
|
$xChoices = []; |
158
|
|
|
$xCurrency = array_diff(array_keys($this->currencyDetails['CX']), ['RON']); |
159
|
|
|
$this->applyCurrencyValidations($this->tCmnSuperGlobals, $this->appFlags['DCTD'], $xCurrency); |
160
|
|
|
foreach ($xCurrency as $value) { |
161
|
|
|
$xChoices[$value] = $value . ' (' . $this->tApp->gettext('i18n_Form_Label_CurrencyName_' . $value) . ')'; |
162
|
|
|
} |
163
|
|
|
$xSelect = $this->setArrayToSelect($xChoices, $this->tCmnSuperGlobals->request->get('xMoney'), 'xMoney[]', [ |
164
|
|
|
'size' => 100, |
165
|
|
|
'multiselect', |
166
|
|
|
]); |
167
|
|
|
$sRow = $this->setFormRow($this->setLabel('xMoney'), $xSelect, 1); |
168
|
|
|
$btn = $this->setStringIntoShortTag('input', [ |
169
|
|
|
'type' => 'submit', |
170
|
|
|
'id' => 'submit', |
171
|
|
|
'value' => $this->tApp->gettext('i18n_Form_Button_Recalculate') |
172
|
|
|
]); |
173
|
|
|
return $this->setFormRow(' ', $btn, 1) . $sRow . '</tbody>'; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
private function setFormInputElements($ymValues, $crtMinWage) |
177
|
|
|
{ |
178
|
|
|
$sReturn = []; |
179
|
|
|
$sReturn[] = '<thead><tr><th>' . $this->tApp->gettext('i18n_Form_Label_InputElements') |
180
|
|
|
. '</th><th>' . $this->tApp->gettext('i18n_Form_Label_InputValues') . '</th></tr></thead><tbody>'; |
181
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM($ymValues), 1); |
182
|
|
|
if (!is_array($this->tCmnSuperGlobals->get('given_food_type'))) { |
183
|
|
|
$this->tCmnSuperGlobals->request->set('given_food_type', [0 => 'fb']); |
184
|
|
|
} |
185
|
|
|
$sReturn[] = $this->setFormRow('<input type="radio" name="given_food_type[]" value="fb" id="gft_fb"' |
186
|
|
|
. ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fb' ? ' checked' : '') . ' />' |
187
|
|
|
. '<label for="gft_fb">' . $this->setLabel('fb') |
188
|
|
|
. '</label>', $this->setFormInputText('fb', 5, 'RON'), 1); |
189
|
|
|
$sReturn[] = $this->setFormRow('<input type="radio" name="given_food_type[]" value="fc" id="gft_fc"' |
190
|
|
|
. ($this->tCmnSuperGlobals->get('given_food_type')[0] === 'fc' ? ' checked' : '') . ' />' |
191
|
|
|
. '<label for="gft_fc">' . $this->setLabel('fc') |
192
|
|
|
. '</label>', $this->setFormInputText('fc', 10, 'RON'), 1); |
193
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('sm'), $this->setFormInputText('sm', 10, 'RON', $crtMinWage), 1); |
194
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1); |
195
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 7, '%'), 1); |
196
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1); |
197
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1); |
198
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, 'ore'), 1); |
199
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, 'ore'), 1); |
200
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1); |
201
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1); |
202
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1); |
203
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, 'zile'), 1); |
204
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('zfs'), $this->setFormInputText('zfs', 2, 'zile'), 1); |
205
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1); |
206
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1); |
207
|
|
|
return implode($sReturn, ''); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
private function setFormInputIntoFieldSet($frm) |
211
|
|
|
{ |
212
|
|
|
return '<div class="tabbertab" id="Input" title="' . $this->tApp->gettext('i18n_FieldsetLabel_Inputs') . '">' |
213
|
|
|
. $frm . '</div>'; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
private function setFormInputText($inName, $inSize, $inAfterLabel, $crtMinWage = 0) |
217
|
|
|
{ |
218
|
|
|
$inputParameters = [ |
219
|
|
|
'type' => 'text', |
220
|
|
|
'name' => $inName, |
221
|
|
|
'value' => $this->tCmnSuperGlobals->request->get($inName), |
222
|
|
|
'size' => $inSize, |
223
|
|
|
'maxlength' => $inSize, |
224
|
|
|
]; |
225
|
|
|
if (in_array($inName, ['fc', 'sm'])) { |
226
|
|
|
$inputParameters['readonly'] = 'readonly'; |
227
|
|
|
} |
228
|
|
|
if (in_array($inName, ['sm'])) { |
229
|
|
|
$inputParameters['value'] = $crtMinWage; |
230
|
|
|
$this->tCmnSuperGlobals->request->set($inName, $crtMinWage); |
231
|
|
|
} |
232
|
|
|
return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
private function setFormOutput($aryStngs, $inElements, $dtR) |
236
|
|
|
{ |
237
|
|
|
$sReturn = []; |
238
|
|
|
$sReturn[] = $this->setFormOutputHeader(); |
239
|
|
|
$ovTimeVal = $this->getOvertimes($aryStngs['Monthly Average Working Hours']); |
240
|
|
|
$additions = $this->tCmnSuperGlobals->request->get('pb') + $ovTimeVal['os175'] + $ovTimeVal['os200']; |
241
|
|
|
$this->getWorkingDays(); |
242
|
|
|
$bComponents = [ |
243
|
|
|
'sc' => $this->tCmnSuperGlobals->request->get('sc'), |
244
|
|
|
'sn' => $this->tCmnSuperGlobals->request->get('sn'), |
245
|
|
|
'zile' => $this->tCmnSuperGlobals->request->get('wkDays'), |
246
|
|
|
]; |
247
|
|
|
$xDate = '<span style="font-size:smaller;">' . date('d.m.Y', $this->currencyDetails['CXD']) . '</span>'; |
248
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('xrate@Date'), $xDate, pow(10, 4)); |
249
|
|
|
$snValue = $this->tCmnSuperGlobals->request->get('sn') * pow(10, 4); |
250
|
|
|
$amntLAA = round(($this->tCmnSuperGlobals->request->get('zfs') / $bComponents['zile']) * $snValue, -4); |
251
|
|
|
$sReturn[] = $this->setFormOutputBonuses($snValue, $bComponents['zile'], $amntLAA, $ovTimeVal); |
252
|
|
|
$brut = ($bComponents['sn'] * (1 + $bComponents['sc'] / 100) + $additions) * pow(10, 4) - $amntLAA; |
253
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('sb'), ' ', $brut); |
254
|
|
|
$brut2 = $brut + $this->tCmnSuperGlobals->request->get('afet') * pow(10, 4); |
255
|
|
|
$amnt = $this->getValues($brut2, $aryStngs, $inElements, $dtR); |
256
|
|
|
$sReturn[] = $this->setFormOutputTaxations($brut2, $amnt); |
257
|
|
|
$pnValue = $this->tCmnSuperGlobals->request->get('pn') * pow(10, 4); |
258
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('pn'), ' ', $pnValue); |
259
|
|
|
$retineri = $this->txLvl['cas'] + $this->txLvl['smj'] + $this->txLvl['snt'] + $amnt['impozit']; |
260
|
|
|
$net = $brut2 - $retineri + $this->tCmnSuperGlobals->request->get('pn') * pow(10, 4); |
261
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('ns'), ' ', $net); |
262
|
|
|
$szamntValue = $this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4); |
263
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('szamnt'), ' ', $szamntValue); |
264
|
|
|
$nsc = $net - $this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4); |
265
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('nsc'), ' ', $nsc); |
266
|
|
|
$fBonus = [ |
267
|
|
|
'main' => $this->setLabel('gb'), |
268
|
|
|
'value' => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue'), |
269
|
|
|
'mtDays' => $this->tCmnSuperGlobals->request->get('nDays') . ' / ' . $bComponents['zile'] |
270
|
|
|
]; |
271
|
|
|
switch ($this->tCmnSuperGlobals->get('given_food_type')[0]) { |
272
|
|
|
case 'fc': |
273
|
|
|
$fBonus['mtDays'] = '0 / ' . $bComponents['zile']; |
274
|
|
|
break; |
275
|
|
|
} |
276
|
|
|
$fBonusTxt = sprintf($fBonus['main'], $fBonus['value']); |
277
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('fb'), '1', $amnt['b1']); |
278
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($fBonusTxt, $fBonus['mtDays'], $amnt['ba']); |
279
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('fc'), '', $amnt['bac']); |
280
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('gbns'), ' ', $amnt['gbns']); |
281
|
|
|
$total = array_sum([ |
282
|
|
|
$net, |
283
|
|
|
$amnt['ba'], |
284
|
|
|
$amnt['bac'], |
285
|
|
|
$amnt['gbns'], |
286
|
|
|
-$this->tCmnSuperGlobals->request->get('szamnt') * pow(10, 4) |
287
|
|
|
]); |
288
|
|
|
$sReturn[] = $this->setFrmRowTwoLbls($this->setLabel('total'), ' ', $total); |
289
|
|
|
$tDate = \DateTime::createFromFormat('Ymd', $this->tCmnSuperGlobals->request->get('ym')); |
290
|
|
|
$legentText = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results'), '' |
291
|
|
|
. strftime('%B', mktime(0, 0, 0, $tDate->format('n'), 1, $tDate->format('Y'))), $tDate->format('Y')); |
292
|
|
|
return '<div class="tabbertab tabbertabdefault" id="Output" title="' . $legentText . '">' |
293
|
|
|
. $this->setStringIntoTag(implode('', $sReturn), 'table') . '</tbody>' . '</div>'; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
private function setFormOutputBonuses($snValue, $wkDays, $amntLAA, $ovTimeVal) |
297
|
|
|
{ |
298
|
|
|
$sRt = []; |
299
|
|
|
$sMin = $this->tCmnSuperGlobals->request->get('sm') * pow(10, 4); |
300
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('sm'), ' ', $sMin); |
301
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('sn'), ' ', $snValue); |
302
|
|
|
$scValue = $this->tCmnSuperGlobals->request->get('sc'); |
303
|
|
|
$prima = $this->tCmnSuperGlobals->request->get('sn') * $scValue * 100; |
304
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('sc'), $scValue . '%', $prima); |
305
|
|
|
$pbValue = $this->tCmnSuperGlobals->request->get('pb') * pow(10, 4); |
306
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('pb'), ' ', $pbValue); |
307
|
|
|
$ovTime = [ |
308
|
|
|
'o1' => $this->tCmnSuperGlobals->request->get('os175'), |
309
|
|
|
'o2' => $this->tCmnSuperGlobals->request->get('os200'), |
310
|
|
|
]; |
311
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('ovAmount1'), '<span style="font-size:smaller;">' |
312
|
|
|
. $ovTime['o1'] . 'h x 175%</span>', $ovTimeVal['os175'] * pow(10, 4)); |
313
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('ovAmount2'), '<span style="font-size:smaller;">' |
314
|
|
|
. $ovTime['o2'] . 'h x 200%</span>', $ovTimeVal['os200'] * pow(10, 4)); |
315
|
|
|
$fLeaveAA = $this->tCmnSuperGlobals->request->get('zfs') . ' / ' . $wkDays; |
316
|
|
|
$sRt[] = $this->setFrmRowTwoLbls($this->setLabel('zfsa'), $fLeaveAA, $amntLAA); |
317
|
|
|
return implode('', $sRt); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
private function setFormOutputHeader() |
321
|
|
|
{ |
322
|
|
|
$sReturn = []; |
323
|
|
|
$sReturn[] = '<thead><tr><th>' . $this->tApp->gettext('i18n_Form_Label_ResultedElements') . '</th>'; |
324
|
|
|
$sReturn[] = '<th><i class="fa fa-map-signs floatRight" style="font-size:2em;"> </i></th>'; |
325
|
|
|
$this->appFlags['CTD'] = $this->manageCurrencyToDisplay($this->tCmnSuperGlobals); |
326
|
|
|
foreach ($this->appFlags['CTD'] as $key => $value) { |
327
|
|
|
$crtPcs = [ |
328
|
|
|
$this->tApp->gettext('i18n_Form_Label_XofficialCurrencyUsedFrom'), |
329
|
|
|
$this->tApp->gettext('i18n_Form_Label_CurrencyName_' . $key), |
330
|
|
|
$this->tApp->gettext('i18n_CountryName_' . strtoupper($value['country'])), |
331
|
|
|
]; |
332
|
|
|
$sReturn[] = '<th style="text-align:center;"><span class="flag-icon flag-icon-' . $value['country'] |
333
|
|
|
. '" style="font-size:2em;" title="' . sprintf($crtPcs[0], $crtPcs[1], $crtPcs[2]) |
334
|
|
|
. '"> </span></th>'; |
335
|
|
|
} |
336
|
|
|
return implode('', $sReturn) . '</tr></thead></tbody>'; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
private function setFormOutputTaxations($brut, $amnt) |
340
|
|
|
{ |
341
|
|
|
$sRn = []; |
342
|
|
|
$limitDisplayBase = false; |
343
|
|
View Code Duplication |
if ($brut > $this->txLvl['casP_base']) { |
|
|
|
|
344
|
|
|
$limitDisplayBase = true; |
345
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('cas_base'), '', $this->txLvl['casP_base']); |
346
|
|
|
} |
347
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('cas'), $this->txLvl['casP'] . '%', $this->txLvl['cas']); |
348
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('somaj'), $this->txLvl['smjP'] . '%', $this->txLvl['smj']); |
349
|
|
View Code Duplication |
if ($limitDisplayBase && array_key_exists('sntP_base', $this->txLvl)) { |
|
|
|
|
350
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('sntP_base'), ' ', $this->txLvl['sntP_base']); |
351
|
|
|
} |
352
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('sanatate'), $this->txLvl['sntP'] . '%', $this->txLvl['snt']); |
353
|
|
|
$rst = $brut - ($this->txLvl['cas'] + $this->txLvl['snt'] + $this->txLvl['smj']); |
354
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('rst'), ' ', $rst); |
355
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('pd'), ' ', $amnt['pd']); |
356
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('impozit_base'), ' ', $this->txLvl['inTaxP_base']); |
357
|
|
|
$sRn[] = $this->setFrmRowTwoLbls($this->setLabel('impozit'), $this->txLvl['inTaxP'] . '%', $amnt['impozit']); |
358
|
|
|
return implode('', $sRn); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
private function setFormRow($text, $value, $type = 'amount') |
362
|
|
|
{ |
363
|
|
|
$defaultCellStyle = $this->setFormatRow($text, $value); |
364
|
|
|
switch ($type) { |
365
|
|
|
case 'amount': |
366
|
|
|
$value2show = $this->setFormRowAmount(($value / pow(10, 4)), $defaultCellStyle); |
367
|
|
|
break; |
368
|
|
|
case 'value': |
369
|
|
|
$value2show = $this->setStringIntoTag($value, 'td', array_merge($defaultCellStyle, [ |
370
|
|
|
'colspan' => count($this->currencyDetails['CX']) |
371
|
|
|
])); |
372
|
|
|
break; |
373
|
|
|
default: |
374
|
|
|
$value2show = $this->setStringIntoTag($value, 'td'); |
375
|
|
|
break; |
376
|
|
|
} |
377
|
|
|
return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr'); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
private function setFormRowAmount($value, $defaultCellStyle) |
381
|
|
|
{ |
382
|
|
|
$cellValue = []; |
383
|
|
|
$defaultCellStyle['style'] .= 'text-align:right;'; |
384
|
|
|
foreach ($this->appFlags['CTD'] as $key2 => $value2) { |
385
|
|
|
$fmt = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY); |
386
|
|
|
$fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']); |
387
|
|
|
$finalValue = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2); |
388
|
|
|
$cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle); |
389
|
|
|
} |
390
|
|
|
return implode('', $cellValue); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
private function setFrmRowTwoLbls($text1, $text2, $value) |
394
|
|
|
{ |
395
|
|
|
return str_replace(':</td>', ':</td><td class="labelS" style="text-align:right;">' |
396
|
|
|
. $text2 . '</td>', $this->setFormRow($text1, $value, 'amount')); |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
|
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.