public function getEmployees() { if ($this->validateAdmin()) { echo json_encode(Employee::GetAllEmployees()); } else { echo 0; } }
public static function EmployeeRegister() { $collection = Employee::GetAllEmployees(); echo ' <div class="logo"> <h5 style="margin-bottom:-15px;margin-top:0px;font-size:14px;">Date: ' . date('d/m/Y') . '</h5> <h4>ALL EMPLOYEES</h4>'; echo '</div> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>NAME</td> <td>TELEPHONE</td> <td>GENDER</td> <td>DEPARTMENT</td> <td>POSITION</td> <td>SALARY</td> </tr> </thead> <tbody>'; foreach ($collection as $model) { echo '<tr> <td>' . $model->name . '</td> <td>' . $model->telephone . '</td> <td>' . $model->gender . '</td> <td>' . $model->department . '</td> <td>' . $model->position . '</td> <td><script>document.writeln((' . $model->salary->amount . ').formatMoney(2, \'.\', \',\'));</script></td> </tr>'; } echo '</tbody> </table>'; }
public static function CommitPayroll($month) { $payroll = new Payroll($month); $employees = Employee::GetAllEmployees(); foreach ($employees as $employee) { $slip = new PaySlip($employee, $month); try { $d = explode('/', $month); $ustamp = $d[1] . $d[0] . '31239999' + 1; $lstamp = $d[1] . $d[0] . '00999999' + 1; self::PostSalary($employee->id, $employee->salary->amount, $month); self::RecoverAdvance($employee->id, $month); //stamp >= '.$lstamp.' AND stamp <= '.$ustamp.' $sql = 'SELECT * FROM payroll_entries WHERE party_id = ' . $employee->id . ' AND status <> 2 AND type <> "Salary Payment" ORDER BY type ASC, id DESC'; $entries = DatabaseHandler::GetAll($sql); foreach ($entries as $entry) { if ($entry['type'] != 'Basic Salary') { $slip->includeEntry($entry['type'], $entry['effect'], $entry['amount']); } $sql = 'UPDATE payroll_entries SET status = 2, month = "' . $month . '" WHERE id = ' . $entry['id']; DatabaseHandler::Execute($sql); } } catch (Exception $e) { //Logger::Log('Payroll', 'Failed', 'Allowance for employee id: '.$employee->id.' for '.$month.'could not be posted'); return false; } $slip->compile(); $slip->commit(); $payroll->addPayslip($slip); } $payroll->setStatus('COMMITED'); return $payroll; }