Skip to content

Commit 371397e

Browse files
committed
Added currency maintenace in pay grades
1 parent e9cc246 commit 371397e

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

HRPayGrades.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@
2727
$InputError = 1;
2828
prnMsg(__('The grade title must not be empty'), 'error');
2929
}
30+
if (empty($_POST['CurrencyCode'])) {
31+
$InputError = 1;
32+
prnMsg(__('Please select a currency code'), 'error');
33+
}
3034

3135
if ($InputError != 1) {
36+
$CurrencyCode = DB_escape_string($_POST['CurrencyCode']);
3237
if (isset($_POST['GradeID']) && $_POST['GradeID'] > 0) {
3338
// Update existing grade
3439
$SQL = "UPDATE hrpaygrades SET
3540
paygradecode = '" . $_POST['GradeCode'] . "',
3641
paygradename = '" . $_POST['GradeTitle'] . "',
42+
currencycode = '" . $CurrencyCode . "',
3743
minsalary = " . filter_var($_POST['MinAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
3844
midsalary = " . filter_var($_POST['MidAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
3945
maxsalary = " . filter_var($_POST['MaxAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
@@ -47,12 +53,13 @@
4753
} else {
4854
// Insert new grade
4955
$SQL = "INSERT INTO hrpaygrades (
50-
paygradecode, paygradename,
56+
paygradecode, paygradename, currencycode,
5157
minsalary, midsalary, maxsalary,
5258
active
5359
) VALUES (
5460
'" . $_POST['GradeCode'] . "',
5561
'" . $_POST['GradeTitle'] . "',
62+
'" . $CurrencyCode . "',
5663
" . filter_var($_POST['MinAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
5764
" . filter_var($_POST['MidAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
5865
" . filter_var($_POST['MaxAnnualSalary'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . ",
@@ -135,6 +142,7 @@
135142
$GradeID = isset($_GET['edit']) ? (int)$_GET['edit'] : 0;
136143
$GradeCode = '';
137144
$GradeTitle = '';
145+
$CurrencyCode = $_SESSION['CompanyRecord']['currencydefault'];
138146
$MinAnnualSalary = 0;
139147
$MidAnnualSalary = 0;
140148
$MaxAnnualSalary = 0;
@@ -147,6 +155,7 @@
147155
$Row = DB_fetch_array($Result);
148156
$GradeCode = $Row['paygradecode'];
149157
$GradeTitle = $Row['paygradename'];
158+
$CurrencyCode = $Row['currencycode'];
150159
$MinAnnualSalary = $Row['minsalary'];
151160
$MidAnnualSalary = $Row['midsalary'];
152161
$MaxAnnualSalary = $Row['maxsalary'];
@@ -173,6 +182,21 @@
173182
<input type="text" name="GradeTitle" value="' . $GradeTitle . '" size="50" maxlength="100" required="required" />
174183
</field>
175184
185+
<field>
186+
<label for="CurrencyCode">' . __('Currency') . ':</label>
187+
<select name="CurrencyCode" required="required">';
188+
189+
$SQL = "SELECT currabrev, currency FROM currencies ORDER BY currency";
190+
$Result = DB_query($SQL);
191+
while ($CurrencyRow = DB_fetch_array($Result)) {
192+
echo '<option value="' . htmlspecialchars($CurrencyRow['currabrev'], ENT_QUOTES, 'UTF-8') . '"' .
193+
($CurrencyCode == $CurrencyRow['currabrev'] ? ' selected="selected"' : '') .
194+
'>' . htmlspecialchars($CurrencyRow['currency'], ENT_QUOTES, 'UTF-8') . ' (' . htmlspecialchars($CurrencyRow['currabrev'], ENT_QUOTES, 'UTF-8') . ')</option>';
195+
}
196+
197+
echo '</select>
198+
</field>
199+
176200
<field>
177201
<label for="MinAnnualSalary">' . __('Minimum Annual Salary') . ':</label>
178202
<input type="number" name="MinAnnualSalary" value="' . $MinAnnualSalary . '" step="0.01" />
@@ -208,6 +232,7 @@
208232
<tr>
209233
<th>' . __('Grade Code') . '</th>
210234
<th>' . __('Grade Title') . '</th>
235+
<th>' . __('Currency') . '</th>
211236
<th>' . __('Min Salary') . '</th>
212237
<th>' . __('Mid Salary') . '</th>
213238
<th>' . __('Max Salary') . '</th>
@@ -219,6 +244,7 @@
219244
echo '<tr class="striped_row">
220245
<td>' . $Row['paygradecode'] . '</td>
221246
<td>' . $Row['paygradename'] . '</td>
247+
<td>' . htmlspecialchars((string)$Row['currencycode'], ENT_QUOTES, 'UTF-8') . '</td>
222248
<td class="number">' . locale_number_format($Row['minsalary'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
223249
<td class="number">' . locale_number_format($Row['midsalary'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
224250
<td class="number">' . locale_number_format($Row['maxsalary'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>

0 commit comments

Comments
 (0)