Ejemplo n.º 1
0
 * 
 */
require "JoraniAPI.php";
$nb_of_days = 1;
//Number of days to be added to the credit
$leave_type = 1;
//Id of the leave type for seniority leave (see list of leave types into the web ui)
$condition = ' - 1 year';
//Condition for date hired ' - 365 day'
//Current yearly period
$startdate = date('Y') . '-01-01';
$enddate = date('Y') . '-12-31';
//Connect to the REST API
$api = new JoraniAPI('http://localhost/jorani/', 'testclient', 'testpass');
//Get the list of employees
$employees = $api->getEmployeesList();
//echo "Employees  = " . var_dump($employees) . PHP_EOL;
//Iterate on the employees list (datehired > $condition)
$last_year = new DateTime(date('Y-m-d', strtotime(date("Y-m-d", time()) . $condition)));
//TODO : get the label of Seniority Leave ?
foreach ($employees as $employee) {
    $datehired = new DateTime($employee->datehired);
    if ($datehired < $last_year) {
        echo "senior employee  = " . $employee->id . PHP_EOL;
        //Check if we already credited seniority entitled days for the current period
        $entitled_days = $api->getEntitledDaysEmployeeList($employee->id);
        echo "entitled days  = " . var_dump($entitled_days) . PHP_EOL;
        $found = FALSE;
        foreach ($entitled_days as $credit) {
            echo "Test 1  = " . ($credit->startdate == $startdate) . PHP_EOL;
            echo "Test 2  = " . ($credit->enddate == $enddate) . PHP_EOL;