//Description of the credit line $description = 'Credit line added by robot - ' . date("D M d, Y G:i"); //Define entitlment period //CURRENT_PERIOD The entitlement can be taken only during the current yearly period (recommended) //'FROM_MONTH The entitlement can be taken from the current month to the end of yearly period //CURRENT_MONTH The entitlement can be taken only during the current month //CURRENT_YEAR The entitlement can be taken only during the current year $period = JoraniAPI::CURRENT_PERIOD; //--------------------------------------------------------------------------------------------------------------------------------------------------- // End of configuration //--------------------------------------------------------------------------------------------------------------------------------------------------- //Connect to the REST API $api = new JoraniAPI($url, $user, $password); //Get the list of employee ids and add the entitled days foreach ($employee_ids as $employee_id) { $employee = $api->getEmployees($employee_id); $contract = $api->getContracts($employee->contract); $startdate = $api->getStartDate($contract, $period); $enddate = $api->getEndDate($contract, $period); if ($employee->active == 1) { $api->addEntitledDaysEmployee($employee->id, $startdate, $enddate, $days, $type, $description); echo 'Added ' . $days . ' day(s) to employee #' . $employee->id . PHP_EOL; } else { echo 'No credit to inactiveemployee #' . $employee->id . PHP_EOL; } } //Get the list of contract ids and add the entitled days foreach ($contract_ids as $contract_id) { $contract = $api->getContracts($contract_id); $startdate = $api->getStartDate($contract, $period); $enddate = $api->getEndDate($contract, $period);
$description = 'Seniority bonus added by robot - ' . date("D M d, Y G:i"); //Define entitlment period //CURRENT_YEAR The entitlement can be taken only during the current year (most current case) //CURRENT_PERIOD The entitlement can be taken only during the current yearly period //'FROM_MONTH The entitlement can be taken from the current month to the end of yearly period //CURRENT_MONTH The entitlement can be taken only during the current month $period = JoraniAPI::CURRENT_YEAR; //--------------------------------------------------------------------------------------------------------------------------------------------------- // End of configuration //--------------------------------------------------------------------------------------------------------------------------------------------------- //Connect to the REST API $api = new JoraniAPI($url, $user, $password); //Iterate on the employees list (datehired > $condition). Most of the time, last year. $floorDate = new DateTime(date('Y-m-d', strtotime(date("Y-m-d", time()) . $condition))); //Get the list of employees $employees = $api->getEmployees(); foreach ($employees as $employee) { $datehired = new DateTime($employee->datehired); if ($datehired < $floorDate) { echo "senior employee #" . $employee->id . PHP_EOL; //Check if we already credited seniority entitled days for the current period $entitled_days = $api->getEntitledDaysListForEmployee($employee->id); $contract = $api->getContracts($employee->contract); $startdate = $api->getStartDate($contract, $period); $enddate = $api->getEndDate($contract, $period); $hasSeniority = $api->hasEntitlementInPeriod($employee->id, $type, $startdate, $enddate); if (!$hasSeniority) { echo "The employee has no seniority bonus." . PHP_EOL; if ($employee->active == 1) { $api->addEntitledDaysEmployee($employee->id, $startdate, $enddate, $days, $type, $description); echo 'Added ' . $days . ' day(s) to employee #' . $employee->id . PHP_EOL;