vendredi 10 février 2017

getting correct count of days from periods

Vote count: 0

I have 3 periods in database:
vacation from 2017-01-09 to 2017-01-13
vacation cancellation from 2017-01-10 to 2017-01-13
and absence from 2017-01-10 to 2017-01-19

So as an example worker went to vacation and got sick.4 of 5 days were canceled from vacation and added in absence period.

Question is how to get total of vacation(in this case left 1) and absence (working days)? This is what i got:

$result_ats = mysqli_query($conn,"SELECT * FROM absence WHERE workerID = '".$row['userID']."'");

if (mysqli_num_rows($result_ats)>0){

    $row_ats = mysqli_fetch_array($result_ats);

    if (!$data[$i]){
        $data[$i]=substr($row_ats['recordExplainCode'], 0, 2);
    }
    ++$prombutne[$row['userID']][$row_ats['recordExplainCode']];
}   

$array_tabelCode contains all "recordExplainCode" (VAC,canc_VAC,ABS)
foreach($array_tabelCode AS $tabelCode){

    if ($prombutne[$row['userID']][$tabelCode]>0){
        echo ' · '.$prombutne[$row['userID']][$recordExplainCode].' ';
    }
}

asked 28 secs ago

Let's block ads! (Why?)



getting correct count of days from periods

Aucun commentaire:

Enregistrer un commentaire