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\Taxation; |
38
|
|
|
|
39
|
|
|
private $appFlags; |
40
|
|
|
private $tApp = null; |
41
|
|
|
|
42
|
|
|
public function __construct() |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$interfaceElements = $this->readSettingsFromJsonFile('interfaceElements'); |
45
|
|
|
$this->handleLocalizationSalariu($interfaceElements['Application']); |
46
|
|
|
echo $this->setHeaderHtml(); |
47
|
|
|
$this->appFlags['FI'] = $interfaceElements['Form Input']; |
48
|
|
|
echo $this->setFormInput(); |
49
|
|
|
if (isset($_REQUEST['ym'])) { |
50
|
|
|
$this->refreshExchangeRatesFile($interfaceElements['Application']); |
51
|
|
|
$this->setCurrencyExchangeVariables($interfaceElements['Relevant Currencies']); |
52
|
|
|
$this->getExchangeRates($interfaceElements['Application']); |
53
|
|
|
$aryStngs = $this->readSettingsFromJsonFile('valuesToCompute'); |
54
|
|
|
echo $this->setFormOutput($aryStngs); |
55
|
|
|
} |
56
|
|
|
echo $this->setFooterHtml($interfaceElements['Application']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private function getExchangeRates($appSettings) |
60
|
|
|
{ |
61
|
|
|
$xml = new \XMLReader(); |
62
|
|
|
if ($xml->open($appSettings['Exchange Rate Local'], 'UTF-8')) { |
63
|
|
|
$krncy = array_keys($this->appFlags['currency_exchanges']); |
64
|
|
|
while ($xml->read()) { |
65
|
|
|
if ($xml->nodeType == \XMLReader::ELEMENT) { |
66
|
|
|
switch ($xml->localName) { |
67
|
|
|
case 'Cube': |
68
|
|
|
$this->appFlags['currency_exchange_rate_date'] = strtotime($xml->getAttribute('date')); |
69
|
|
|
break; |
70
|
|
|
case 'Rate': |
71
|
|
|
if (in_array($xml->getAttribute('currency'), $krncy)) { |
72
|
|
|
$cncy = $xml->getAttribute('currency'); |
73
|
|
|
$cVal = $xml->readInnerXml(); |
74
|
|
|
if (!is_null($xml->getAttribute('multiplier'))) { |
75
|
|
|
$cVal = $cVal / $xml->getAttribute('multiplier'); |
76
|
|
|
} |
77
|
|
|
$this->appFlags['currency_exchange_rate_value'][$cncy] = $cVal; |
78
|
|
|
} |
79
|
|
|
break; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
$xml->close(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
private function getOvertimes($aryStngs) |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
$pcToBoolean = [0 => true, 1 => false]; |
90
|
|
|
$mnth = $this->setMonthlyAverageWorkingHours($_REQUEST['ym'], $aryStngs, $pcToBoolean[$_REQUEST['pc']]); |
91
|
|
|
return [ |
92
|
|
|
'os175' => ceil($_REQUEST['os175'] * 1.75 * $_REQUEST['sn'] / $mnth), |
93
|
|
|
'os200' => ceil($_REQUEST['os200'] * 2 * $_REQUEST['sn'] / $mnth), |
94
|
|
|
]; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
private function getValues($lngBase, $aStngs) |
|
|
|
|
98
|
|
|
{ |
99
|
|
|
$inDate = $_REQUEST['ym']; |
100
|
|
|
$wkDay = $this->setWorkingDaysInMonth($inDate, $_REQUEST['pc']); |
101
|
|
|
$nMealDays = ($wkDay - $_REQUEST['zfb']); |
102
|
|
|
$shLbl = [ |
103
|
|
|
'HFP' => 'Health Fund Percentage', |
104
|
|
|
'HFUL' => 'Health Fund Upper Limit', |
105
|
|
|
'HTP' => 'Health Tax Percentage', |
106
|
|
|
'IT' => 'Income Tax', |
107
|
|
|
'MTV' => 'Meal Ticket Value', |
108
|
|
|
]; |
109
|
|
|
$unemploymentBase = $lngBase; |
110
|
|
|
if ($_REQUEST['ym'] < mktime(0, 0, 0, 1, 1, 2008)) { |
111
|
|
|
$unemploymentBase = $_REQUEST['sn']; |
112
|
|
|
} |
113
|
|
|
$aReturn = [ |
114
|
|
|
'ba' => $this->setFoodTicketsValue($inDate, $aStngs[$shLbl['MTV']]) * $nMealDays, |
115
|
|
|
'cas' => $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]), |
116
|
|
|
'sanatate' => $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']]), |
117
|
|
|
'somaj' => $this->setUnemploymentTax($inDate, $unemploymentBase), |
118
|
|
|
]; |
119
|
|
|
$pdVal = [ |
120
|
|
|
$inDate, |
121
|
|
|
($lngBase + $aReturn['ba']), |
122
|
|
|
$_REQUEST['pi'], |
123
|
|
|
$aStngs['Personal Deduction'], |
124
|
|
|
]; |
125
|
|
|
$aReturn['pd'] = $this->setPersonalDeduction($pdVal[0], $pdVal[1], $pdVal[2], $pdVal[3]); |
126
|
|
|
$restArrayToDeduct = [ |
127
|
|
|
$aReturn['cas'], |
128
|
|
|
$aReturn['sanatate'], |
129
|
|
|
$aReturn['somaj'], |
130
|
|
|
$aReturn['pd'], |
131
|
|
|
]; |
132
|
|
|
$rest = $lngBase - array_sum($restArrayToDeduct); |
133
|
|
|
if ($inDate >= mktime(0, 0, 0, 7, 1, 2010)) { |
134
|
|
|
$rest += round($aReturn['ba'], -4); |
135
|
|
|
if ($inDate >= mktime(0, 0, 0, 10, 1, 2010)) { |
136
|
|
|
$aReturn['gbns'] = $_REQUEST['gbns'] * pow(10, 4); |
137
|
|
|
$rest += round($aReturn['gbns'], -4); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
$rest += $_REQUEST['afet'] * pow(10, 4); |
141
|
|
|
$aReturn['impozit'] = $this->setIncomeTax($inDate, $rest, $aStngs[$shLbl['IT']]); |
142
|
|
|
$aReturn['zile'] = $this->setWorkingDaysInMonth($inDate, $_REQUEST['pc']); |
143
|
|
|
return $aReturn; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
private function handleLocalizationSalariu($appSettings) |
|
|
|
|
147
|
|
|
{ |
148
|
|
|
if (isset($_GET['lang'])) { |
149
|
|
|
$_SESSION['lang'] = filter_var($_GET['lang'], FILTER_SANITIZE_STRING); |
150
|
|
|
} elseif (!isset($_SESSION['lang'])) { |
151
|
|
|
$_SESSION['lang'] = $appSettings['Default Language']; |
152
|
|
|
} |
153
|
|
|
/* to avoid potential language injections from other applications that do not applies here */ |
154
|
|
|
if (!in_array($_SESSION['lang'], array_keys($appSettings['Available Languages']))) { |
155
|
|
|
$_SESSION['lang'] = $appSettings['Default Language']; |
156
|
|
|
} |
157
|
|
|
$localizationFile = 'Salariu/locale/' . $_SESSION['lang'] . '/LC_MESSAGES/salariu.mo'; |
158
|
|
|
$translations = new \Gettext\Translations; |
159
|
|
|
$translations->addFromMoFile($localizationFile); |
160
|
|
|
$this->tApp = new \Gettext\Translator(); |
161
|
|
|
$this->tApp->loadTranslations($translations); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
private function refreshExchangeRatesFile($appSettings) |
165
|
|
|
{ |
166
|
|
|
if ((filemtime($appSettings['Exchange Rate Local']) + 90 * 24 * 60 * 60) < time()) { |
167
|
|
|
$fCntnt = file_get_contents($appSettings['Exchange Rate Source']); |
168
|
|
|
if ($fCntnt !== false) { |
169
|
|
|
file_put_contents($appSettings['Exchange Rate Local'], $fCntnt); |
170
|
|
|
chmod($appSettings['Exchange Rate Local'], 0666); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
private function setCurrencyExchangeVariables($aryRelevantCurrencies) |
176
|
|
|
{ |
177
|
|
|
$this->appFlags['currency_exchanges'] = $aryRelevantCurrencies; |
178
|
|
|
$this->appFlags['currency_exchange_rate_date'] = strtotime('now'); |
179
|
|
|
$krncy = array_keys($this->appFlags['currency_exchanges']); |
180
|
|
|
foreach ($krncy as $value) { |
181
|
|
|
$this->appFlags['currency_exchange_rate_value'][$value] = 1; |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
private function setFooterHtml($appSettings) |
186
|
|
|
{ |
187
|
|
|
$sReturn = $this->setUpperRightBoxLanguages($appSettings['Available Languages']) |
188
|
|
|
. '<div class="resetOnly author">© ' . date('Y') . ' ' |
189
|
|
|
. $appSettings['Copyright Holder'] . '</div>' |
190
|
|
|
. '<hr/>' |
191
|
|
|
. '<div class="disclaimer">' |
192
|
|
|
. $this->tApp->gettext('i18n_Disclaimer') |
193
|
|
|
. '</div>'; |
194
|
|
|
return $this->setFooterCommon($sReturn); |
|
|
|
|
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
private function setFormInput() |
|
|
|
|
198
|
|
|
{ |
199
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM(), 1); |
|
|
|
|
200
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1); |
201
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 2, '%'), 1); |
202
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1); |
203
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1); |
204
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, ''), 1); |
205
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, ''), 1); |
206
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1); |
207
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1); |
208
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 2, ''), 1); |
209
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, ''), 1); |
210
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 2, ''), 1); |
211
|
|
|
$sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 2, ''), 1); |
212
|
|
|
$label = $this->tApp->gettext('i18n_Form_Disclaimer'); |
213
|
|
|
$hiddenField = $this->setStringIntoShortTag('input', [ |
214
|
|
|
'type' => 'hidden', |
215
|
|
|
'name' => 'action', |
216
|
|
|
'value' => $_SERVER['SERVER_NAME'] |
217
|
|
|
]); |
218
|
|
|
$sReturn[] = $this->setStringIntoTag($this->setStringIntoTag($label . $hiddenField, 'td', [ |
219
|
|
|
'colspan' => 2, |
220
|
|
|
'style' => 'color: red;' |
221
|
|
|
]), 'tr'); |
222
|
|
|
$resetBtn = $this->setStringIntoShortTag('input', [ |
223
|
|
|
'type' => 'reset', |
224
|
|
|
'id' => 'reset', |
225
|
|
|
'value' => $this->tApp->gettext('i18n_Form_Button_Reset'), |
226
|
|
|
'style' => 'color:#000;' |
227
|
|
|
]); |
228
|
|
|
$submitBtnTxt = $this->tApp->gettext('i18n_Form_Button_Calculate'); |
229
|
|
|
if (isset($_REQUEST['ym'])) { |
230
|
|
|
$resetBtn = ''; |
231
|
|
|
$submitBtnTxt = $this->tApp->gettext('i18n_Form_Button_Recalculate'); |
232
|
|
|
} |
233
|
|
|
$sReturn[] = $this->setFormRow($resetBtn, $this->setStringIntoShortTag('input', [ |
234
|
|
|
'type' => 'submit', |
235
|
|
|
'id' => 'submit', |
236
|
|
|
'value' => $submitBtnTxt |
237
|
|
|
]), 1); |
238
|
|
|
$frm = $this->setStringIntoTag($this->setStringIntoTag(implode('', $sReturn), 'table'), 'form', [ |
239
|
|
|
'method' => 'get', |
240
|
|
|
'action' => $_SERVER['SCRIPT_NAME'] |
241
|
|
|
]); |
242
|
|
|
return $this->setStringIntoTag(implode('', [ |
243
|
|
|
$this->setStringIntoTag($this->tApp->gettext('i18n_FieldsetLabel_Inputs'), 'legend'), |
244
|
|
|
$frm |
245
|
|
|
]), 'fieldset', ['style' => 'float: left;']); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
private function setFormInputSelectPC() |
|
|
|
|
249
|
|
|
{ |
250
|
|
|
$choices = [ |
251
|
|
|
$this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceNo'), |
252
|
|
|
$this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceYes'), |
253
|
|
|
]; |
254
|
|
|
return $this->setArrayToSelect($choices, $_REQUEST['pc'], 'pc', ['size' => 1]); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
private function setFormInputSelectPI() |
|
|
|
|
258
|
|
|
{ |
259
|
|
|
$temp2 = []; |
260
|
|
|
for ($counter = 0; $counter <= 4; $counter++) { |
261
|
|
|
$temp2[$counter] = $counter . ($counter == 4 ? '+' : ''); |
262
|
|
|
} |
263
|
|
|
return $this->setArrayToSelect($temp2, $_REQUEST['pi'], 'pi', ['size' => 1]); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
private function setFormInputSelectYM() |
|
|
|
|
267
|
|
|
{ |
268
|
|
|
$temp = []; |
269
|
|
|
for ($counter = date('Y'); $counter >= 2001; $counter--) { |
270
|
|
|
for ($counter2 = 12; $counter2 >= 1; $counter2--) { |
271
|
|
|
$crtDate = mktime(0, 0, 0, $counter2, 1, $counter); |
272
|
|
|
if ($crtDate <= mktime(0, 0, 0, date('m'), 1, date('Y'))) { |
273
|
|
|
$temp[$crtDate] = strftime('%Y, %m (%B)', $crtDate); |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
} |
277
|
|
|
return $this->setArrayToSelect($temp, $_REQUEST['ym'], 'ym', ['size' => 1]); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
private function setFormInputText($inName, $inSize, $inAfterLabel) |
|
|
|
|
281
|
|
|
{ |
282
|
|
|
$inputParameters = [ |
283
|
|
|
'type' => 'text', |
284
|
|
|
'name' => $inName, |
285
|
|
|
'value' => $_REQUEST[$inName], |
286
|
|
|
'size' => $inSize, |
287
|
|
|
'maxlength' => $inSize, |
288
|
|
|
]; |
289
|
|
|
return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
private function setFormOutput($aryStngs) |
|
|
|
|
293
|
|
|
{ |
294
|
|
|
$overtime = $this->getOvertimes($aryStngs['Monthly Average Working Hours']); |
295
|
|
|
$additions = $_REQUEST['pb'] + $overtime['os175'] + $overtime['os200']; |
296
|
|
|
$brut = ($_REQUEST['sn'] * (1 + $_REQUEST['sc'] / 100) + $additions) * pow(10, 4); |
297
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_ExchangeRateAtDate'); |
298
|
|
|
$xRate = str_replace('%1', date('d.m.Y', $this->appFlags['currency_exchange_rate_date']), $text); |
299
|
|
|
$sReturn[] = $this->setFormRow($xRate, 1000000); |
|
|
|
|
300
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary'); |
301
|
|
|
$sReturn[] = $this->setFormRow($text, $_REQUEST['sn'] * 10000); |
302
|
|
|
$prima = $_REQUEST['sn'] * $_REQUEST['sc'] * 100; |
303
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_CumulatedAddedValue'), $prima); |
304
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_AdditionalBruttoAmount'); |
305
|
|
|
$sReturn[] = $this->setFormRow($text, $_REQUEST['pb'] * 10000); |
306
|
|
|
$ovTime = [ |
307
|
|
|
'main' => $this->tApp->gettext('i18n_Form_Label_OvertimeAmount'), |
308
|
|
|
1 => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice1'), |
309
|
|
|
2 => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice2'), |
310
|
|
|
]; |
311
|
|
|
$sReturn[] = $this->setFormRow(sprintf($ovTime['main'], $ovTime[1], '175%'), ($overtime['os175'] * pow(10, 4))); |
312
|
|
|
$sReturn[] = $this->setFormRow(sprintf($ovTime['main'], $ovTime[2], '200%'), ($overtime['os200'] * pow(10, 4))); |
313
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_BruttoSalary'), $brut); |
314
|
|
|
$brut += $_REQUEST['afet'] * pow(10, 4); |
315
|
|
|
$amount = $this->getValues($brut, $aryStngs); |
316
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PensionFund'), $amount['cas']); |
317
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_UnemploymentTax'), $amount['somaj']); |
318
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_HealthTax'), $amount['sanatate']); |
319
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PersonalDeduction'), $amount['pd']); |
320
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_ExciseTax'), $amount['impozit']); |
321
|
|
|
$retineri = $amount['cas'] + $amount['somaj'] + $amount['sanatate'] + $amount['impozit']; |
322
|
|
|
$net = $brut - $retineri + $_REQUEST['pn'] * 10000; |
323
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_AdditionalNettoAmount'); |
324
|
|
|
$sReturn[] = $this->setFormRow($text, $_REQUEST['pn'] * 10000); |
325
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_NettoSalary'), $net); |
326
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_SeisureAmout'); |
327
|
|
|
$sReturn[] = $this->setFormRow($text, $_REQUEST['szamnt'] * 10000); |
328
|
|
|
$text = $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash'); |
329
|
|
|
$sReturn[] = $this->setFormRow($text, ($net - $_REQUEST['szamnt'] * 10000)); |
330
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_WorkingDays'), $amount['zile'], 'value'); |
331
|
|
|
$fBonus = [ |
332
|
|
|
'main' => $this->tApp->gettext('i18n_Form_Label_FoodBonuses'), |
333
|
|
|
'no' => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceNo'), |
334
|
|
|
'value' => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue') |
335
|
|
|
]; |
336
|
|
|
$fBonusTxt = sprintf($fBonus['main'], $fBonus['value'], $fBonus['no'], ($amount['zile'] - $_REQUEST['zfb'])); |
337
|
|
|
$sReturn[] = $this->setFormRow($fBonusTxt, $amount['ba']); |
338
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_FoodBonusesValue'), $amount['gbns']); |
339
|
|
|
$total = ($net + $amount['ba'] + $amount['gbns'] - $_REQUEST['szamnt'] * 10000); |
340
|
|
|
$sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_Total'), $total); |
341
|
|
|
setlocale(LC_TIME, explode('_', $_SESSION['lang'])[0]); |
342
|
|
|
$crtMonth = strftime('%B', $_REQUEST['ym']); |
343
|
|
|
$legend = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results'), $crtMonth, date('Y', $_REQUEST['ym'])); |
344
|
|
|
return $this->setStringIntoTag(implode('', [ |
345
|
|
|
$this->setStringIntoTag($legend, 'legend'), |
346
|
|
|
$this->setStringIntoTag(implode('', $sReturn), 'table') |
347
|
|
|
]), 'fieldset', ['style' => 'float: left;']); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
private function setFormRow($text, $value, $type = 'amount') |
351
|
|
|
{ |
352
|
|
|
$a = ''; |
353
|
|
|
$defaultCellStyle = ['class' => 'labelS']; |
354
|
|
|
switch ($text) { |
355
|
|
|
case $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary'): |
356
|
|
|
case $this->tApp->gettext('i18n_Form_Label_BruttoSalary'): |
357
|
|
|
case $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash'): |
358
|
|
|
$defaultCellStyle = array_merge($defaultCellStyle, [ |
359
|
|
|
'style' => 'color:#000000;font-weight:bold;' |
360
|
|
|
]); |
361
|
|
|
break; |
362
|
|
|
case $this->tApp->gettext('i18n_Form_Label_SeisureAmout'): |
363
|
|
|
case $this->tApp->gettext('i18n_Form_Label_PensionFund'): |
364
|
|
|
case $this->tApp->gettext('i18n_Form_Label_HealthTax'): |
365
|
|
|
case $this->tApp->gettext('i18n_Form_Label_UnemploymentTax'): |
366
|
|
|
case $this->tApp->gettext('i18n_Form_Label_ExciseTax'): |
367
|
|
|
$defaultCellStyle = array_merge($defaultCellStyle, [ |
368
|
|
|
'style' => 'color:#ff9900;' |
369
|
|
|
]); |
370
|
|
|
break; |
371
|
|
|
case $this->tApp->gettext('i18n_Form_Label_Total'): |
372
|
|
|
$defaultCellStyle = array_merge($defaultCellStyle, [ |
373
|
|
|
'style' => 'font-weight:bold;color:#009933;font-size:larger;' |
374
|
|
|
]); |
375
|
|
|
break; |
376
|
|
|
} |
377
|
|
|
$defaultCellStyle['style'] = ''; |
378
|
|
|
if ((is_numeric($value)) && ($value == 0)) { |
379
|
|
|
if (isset($defaultCellStyle['style'])) { |
380
|
|
|
$defaultCellStyle['style'] = 'color:#666;'; |
381
|
|
|
} else { |
382
|
|
|
$defaultCellStyle = array_merge($defaultCellStyle, [ |
383
|
|
|
'style' => 'color:#666;' |
384
|
|
|
]); |
385
|
|
|
} |
386
|
|
|
} |
387
|
|
|
switch ($type) { |
388
|
|
|
case 'amount': |
389
|
|
|
$value = $value / pow(10, 4); |
390
|
|
|
$defaultCellStyle2['style'] = $defaultCellStyle['style'] . 'text-align:right;'; |
|
|
|
|
391
|
|
|
$cellValue = []; |
392
|
|
|
foreach ($this->appFlags['currency_exchanges'] as $key2 => $value2) { |
393
|
|
|
$fmt = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY); |
394
|
|
|
$fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']); |
395
|
|
|
$x = $this->appFlags['currency_exchange_rate_value'][$key2]; |
396
|
|
|
$finalValue = $fmt->formatCurrency($value / $x, $key2); |
397
|
|
|
$cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle2); |
398
|
|
|
} |
399
|
|
|
$value2show = implode('', $cellValue); |
400
|
|
|
break; |
401
|
|
|
case 'value': |
402
|
|
|
$defaultCellStyle2 = array_merge($defaultCellStyle, [ |
403
|
|
|
'colspan' => count($this->appFlags['currency_exchanges']) |
404
|
|
|
]); |
405
|
|
|
$value2show = $this->setStringIntoTag($value . $a, 'td', $defaultCellStyle2); |
406
|
|
|
break; |
407
|
|
|
default: |
408
|
|
|
$value2show = $this->setStringIntoTag($value, 'td'); |
409
|
|
|
break; |
410
|
|
|
} |
411
|
|
|
if (!in_array($text, ['', ' ']) && (strpos($text, '<input') === false)) { |
412
|
|
|
$text .= ':'; |
413
|
|
|
} |
414
|
|
|
return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr'); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
private function setHeaderHtml() |
|
|
|
|
418
|
|
|
{ |
419
|
|
|
$headerParameters = [ |
420
|
|
|
'lang' => str_replace('_', '-', $_SESSION['lang']), |
421
|
|
|
'title' => $this->tApp->gettext('i18n_ApplicationName'), |
422
|
|
|
'css' => [ |
423
|
|
|
'vendor/components/flag-icon-css/css/flag-icon.min.css', |
424
|
|
|
'Salariu/css/salariu.css', |
425
|
|
|
], |
426
|
|
|
]; |
427
|
|
|
return $this->setHeaderCommon($headerParameters) |
428
|
|
|
. '<h1>' . $this->tApp->gettext('i18n_ApplicationName') . '</h1>'; |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
private function setLabel($labelId) |
432
|
|
|
{ |
433
|
|
|
$labelInfo = $this->appFlags['FI'][$labelId]['Label']; |
434
|
|
|
if (is_array($labelInfo)) { |
435
|
|
|
if (count($labelInfo) == 3) { |
436
|
|
|
$pieces = [ |
437
|
|
|
$this->tApp->gettext($labelInfo[0]), |
438
|
|
|
$this->tApp->gettext($labelInfo[1]), |
439
|
|
|
]; |
440
|
|
|
$sReturn = sprintf($pieces[0], $pieces[1], $labelInfo[2]); |
441
|
|
|
} |
442
|
|
|
} elseif (is_string($labelInfo)) { |
443
|
|
|
$sReturn = $this->tApp->gettext($labelInfo); |
444
|
|
|
} |
445
|
|
|
return $sReturn; |
|
|
|
|
446
|
|
|
} |
447
|
|
|
} |
448
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: