[go: up one dir, main page]

Menu

[95b4ce]: / prlBP.php  Maximize  Restore  History

Download this file

238 lines (209 with data), 8.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
include('includes/session.inc');
$Title = _('Basic Pay Section');
include('includes/header.inc');
if (isset($_GET['Bracket'])) {
$Bracket = $_GET['Bracket'];
} elseif (isset($_POST['Bracket'])) {
$Bracket = $_POST['Bracket'];
} else {
unset($Bracket);
$_POST["New"] = True;
}
echo '<p class="page_title_text noPrint" ><img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/payrol.png" title="' . $Title . '" alt="" />' . ' ' . $Title . '</p>';
if (isset($_POST['Submit'])) {
//initialise no input errors assumed initially before we test
$InputError = 0;
/* actions to take once the user has clicked the submit button
ie the page has called itself with some user input */
//first off validate inputs sensible
if (strlen($Bracket) == 0) {
$InputError = 1;
prnMsg(_('The Salary Bracket cannot be empty'), 'error');
}
if (!is_numeric($_POST['Bracket'])) /* Check if the bank code is numeric */ {
prnMsg(_('Salary Bracket must be numeric'), 'error');
$InputError = 1;
}
if ($InputError != 1) {
if (!isset($_POST["New"])) {
$SQL = "UPDATE prlbasicpaytable SET rangefrom='" . $_POST['RangeFr'] . "',
rangeto='" . $_POST['RangeTo'] . "',
salarycredit='" . $_POST['Credit'] . "',
employerbasicpay='" . $_POST['ERPH'] . "',
employeebasicpay='" . $_POST['EEPH'] . "',
total='" . $_POST['Total'] . "'
WHERE bracket='" . $Bracket . "'";
$ErrMsg = _('The Basic Pay could not be updated because');
$DbgMsg = _('The SQL that was used to update the Basic Pay but failed was');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg);
prnMsg(_('The Basic Pay master record for') . ' ' . $Bracket . ' ' . _('has been updated'), 'success');
} else { //its a new PhilHealth
$SQL = "INSERT INTO prlbasicpaytable ( bracket,
rangefrom,
rangeto,
salarycredit,
employerbasicpay,
employeebasicpay,
total
) VALUES (
'" . $Bracket . "',
'" . $_POST['RangeFr'] . "',
'" . $_POST['RangeTo'] . "',
'" . $_POST['Credit'] . "',
'" . $_POST['ERPH'] . "',
'" . $_POST['EEPH'] . "',
'" . $_POST['Total'] . "'
)";
$ErrMsg = _('The Basic Pay') . ' ' . $_POST['Credit'] . ' ' . _('could not be added because');
$DbgMsg = _('The SQL that was used to insert the Basic Pay but failed was');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg);
prnMsg(_('A new Basic Pay has been added to the database'), 'success');
}
unset($Bracket);
unset($_POST['RangeFr']);
unset($_POST['RangeTo']);
unset($_POST['Credit']);
unset($_POST['ERPH']);
unset($_POST['EEPH']);
unset($_POST['Total']);
} else {
prnMsg(_('Validation failed') . _('no updates or deletes took place'), 'warn');
}
} elseif (isset($_POST['delete']) AND $_POST['delete'] != '') {
//the link to delete a selected record was clicked instead of the submit button
$CancelDelete = 0;
// PREVENT DELETES IF DEPENDENT RECORDS IN 'SuppTrans' , PurchOrders, SupplierContacts
if ($CancelDelete == 0) {
$SQL = "DELETE FROM prlbasicpaytable WHERE bracket='$Bracket'";
$Result = DB_query($SQL);
prnMsg(_('The Basic Pay record for') . ' ' . $Bracket . ' ' . _('has been deleted'), 'success');
unset($Bracket);
unset($_SESSION['Bracket']);
} //end if Delete paypayperiod
}
/*If the page was called without $SupplierID passed to page then assume a new supplier is to be entered show a form with a Supplier Code field other wise the form showing the fields with the existing entries against the supplier will show for editing with only a hidden SupplierID field*/
//Bracket exists - either passed when calling the form or from the form itself
echo '<form method="post" class="noPrint" id="BasicPay" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if (!isset($_POST["New"]) and isset($Bracket)) {
$SQL = "SELECT bracket,
rangefrom,
rangeto,
salarycredit,
employerbasicpay,
employeebasicpay,
total
FROM prlbasicpaytable
WHERE bracket='" . $Bracket . "'";
$Result = DB_query($SQL);
$MyRow = DB_fetch_array($Result);
$_POST['RangeFr'] = $MyRow['rangefrom'];
$_POST['RangeTo'] = $MyRow['rangeto'];
$_POST['Credit'] = $MyRow['salarycredit'];
$_POST['ERPH'] = $MyRow['employerbasicpay'];
$_POST['EEPH'] = $MyRow['employeebasicpay'];
$_POST['Total'] = $MyRow['total'];
echo '<input type="hidden" name="Bracket" value="' . $Bracket . '" />';
echo '<table>';
echo '<tr>
<td>' . _('Basic Pay Code') . ':</td>
<td>' . $Bracket . '</td>
</tr>';
} else {
$_POST['RangeFr'] = 0;
$_POST['RangeTo'] = 0;
$_POST['Credit'] = 0;
$_POST['ERPH'] = 0;
$_POST['EEPH'] = 0;
$_POST['Total'] = 0;
$Bracket = '';
// its a new PhilHealth being added
echo '<input type="hidden" name="New" value="Yes">';
echo '<table>';
echo '<tr>
<td>' . _('Basic Pay Code') . ':</td>
<td><input type="text" name="Bracket" value="' . $Bracket . '" size="5" maxlength="4" /></td>
</tr>';
}
echo '<tr>
<td>' . _('Range From') . ':</td>
<td><input type="number" class="number" name="RangeFr" size="14" maxlength="12" value="' . $_POST['RangeFr'] . '" /></td>
</tr>
<tr>
<td>' . _('Range To') . ':</td>
<td><input type="number" class="number" name="RangeTo" size="14" maxlength="12" value="' . $_POST['RangeTo'] . '" /></td>
</tr>
<tr>
<td>' . _('Salary Base') . ':</td>
<td><input type="number" class="number" name="Credit" size="14" maxlength="12" value="' . $_POST['Credit'] . '" /></td>
</tr>
<tr>
<td>' . _('Employer Share') . ':</td>
<td><input type="number" class="number" name="ERPH" size="14" maxlength="12" value="' . $_POST['ERPH'] . '" /></td>
</tr>
<tr>
<td>' . _('Employee Share') . ':</td>
<td><input type="number" class="number" name="EEPH" size="14" maxlength="12" value="' . $_POST['EEPH'] . '" /></td>
</tr>
<tr>
<td>' . _('Total') . ':</td>
<td><input type="number" class="number" name="Total" size="14" maxlength="12" value="' . $_POST['Total'] . '" /></td>
</tr>
</table>';
if (isset($_POST["New"])) {
echo '<div class="centre">
<input type="submit" name="Submit" value="' . _('Add These New Basic Pay Details') . '" />
</div>';
} else {
echo '<div class="centre">
<input type="submit" name="Submit" value="' . _('Update Basic Pay') . '">
<input type="submit" name="delete" value="' . _('Delete Basic Pay') . '" confirm("' . _('Are you sure you wish to delete this Basic Pay?') . '");" />
</div>';
}
echo '</form>';
// end of main ifs
$SQL = "SELECT bracket,
rangefrom,
rangeto,
salarycredit,
employerbasicpay,
employeebasicpay,
total
FROM prlbasicpaytable
ORDER BY bracket";
$ErrMsg = _('Could not get Basic pay because');
$Result = DB_query($SQL, $ErrMsg);
echo '<table class="selection">
<tr>
<th>' . _('Salary Bracket') . '</th>
<th>' . _('Range From') . '</th>
<th>' . _('Range To') . '</th>
<th>' . _('Salary Base') . '</th>
<th>' . _('Employer Share') . '</th>
<th>' . _('Employee Share') . '</th>
<th>' . _('Total') . '</th>
</tr>';
$k = 0; //row colour counter
while ($MyRow = DB_fetch_array($Result)) {
if ($k == 1) {
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
echo '<tr class="OddTableRows">';
$k++;
}
echo '<td>' . $MyRow['bracket'] . '</td>
<td>' . $MyRow['rangefrom'] . '</td>
<td>' . $MyRow['rangeto'] . '</td>
<td>' . $MyRow['salarycredit'] . '</td>
<td>' . $MyRow['employerbasicpay'] . '</td>
<td>' . $MyRow['employeebasicpay'] . '</td>
<td>' . $MyRow['total'] . '</td>
<td><a href="' . $_SERVER['PHP_SELF'] . '?Bracket=' . $MyRow['bracket'] . '">' . _('Edit') . '</a></td>
<td><a href="' . $_SERVER['PHP_SELF'] . '?Bracket=' . $MyRow['bracket'] . '&delete=1">' . _('Delete') . '</a></td>
</tr>';
} //END WHILE LIST LOOP
echo '</table>';
include('includes/footer.inc');
?>