1<?php
2
3/**
4 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
5 * all the essential functionalities required for any enterprise.
6 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
7 *
8 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
9 * the GNU General Public License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with this program;
17 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA  02110-1301, USA
19 */
20class RegistrationEmployeeTerminationEventProcessor extends AbstractRegistrationEventProcessor
21{
22
23    public function getEventType()
24    {
25        return RegistrationEventQueue::INACTIVE_EMPLOYEE_COUNT;
26    }
27
28    public function getEventData()
29    {
30        $registrationData = $this->getRegistrationEventGeneralData();
31        $totalEmployeeCount = $this->getEmployeeCount(true);
32        $activeEmployeeCOunt = $this->getEmployeeCount();
33        $employeeCount = $totalEmployeeCount - $activeEmployeeCOunt;
34        $registrationData['employee_count'] = $employeeCount;
35        return $registrationData;
36    }
37
38    public function getEventToBeSavedOrNot()
39    {
40        $totalEmployeeCount = $this->getEmployeeCount(true);
41        $activeEmployeeCOunt = $this->getEmployeeCount();
42        $employeeCount = $totalEmployeeCount - $activeEmployeeCOunt;
43        if ($employeeCount % RegistrationEventQueue::EMPLOYEE_COUNT_CHANGE_TRACKER_SIZE == 0) {
44            return true;
45        }
46        return false;
47    }
48
49    public function getEmployeeCount($includeTerminated = false) {
50        return $this->getEmployeeDao()->getEmployeeCount($includeTerminated);
51    }
52}
53