1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| function calculTarif($datedebut, $duree){
list($date, $time) = explode(' ', $datedebut);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$matin = "07:30:00";
$soir = "20:00:00";
$timestampStart = mktime($hour, $minute, $second, $month, $day, $year);
$startDay = date("N", $timestampStart);
$timestampEnd = $timestampStart + ($duree*60);
$endDay = date("N", $timestampEnd);
$finheureshno = date("d-M-Y H:m:i", $timestampEnd);
list($date1, $time1) = explode(' ', $finheureshno);
$minuit = mktime(0, 0, 0, $month, $day, $year) + 86400 ;
if ((strtotime($matin) < strtotime($time)) && (strtotime($time) < strtotime($soir)) && (($startDay == 1) || ($startDay == 2) || ($startDay == 3) || ($startDay == 4) || ($startDay == 5))){
$debutpaye = mktime(20, 0, 0, $month, $day, $year);
$heureho = (strtotime($soir) - strtotime($time)) / 60;
$heureshno = $duree - $heureho;
}else{
$debutpaye = $timestampStart;
$heureshno = $duree;
}
if ((strtotime($matin) < strtotime($time1)) && (strtotime($time1) < strtotime($soir)) && (($startDay == 1) || ($startDay == 2) || ($startDay == 3) || ($startDay == 4) || ($startDay == 5))){
$finpaye = mktime(7, 30, 0, $month, $day, $year);
$heureho1 = (strtotime($time1) - strtotime($matin)) / 60;
$heureshno = $duree - $heureho1;
}else{
$finpaye = $timestampEnd;
$heureshno = $duree;
}
$diffDay1 = $minuit - $debutpaye;
$diffDay2 = $finpaye - $minuit;
$heuresDay1 = floor($diffDay1/3600);
$resteDay1 = ($diffDay1 % 3600)/60;
$heuresDay2 = floor($diffDay2/3600);
$resteDay2 = ($diffDay2 % 3600)/60;
$addition = $resteDay1 + $resteDay2;
if ($addition == 0){
$heureEntame = $addition;
}elseif (($addition < 60) && ($addition > 0) ){
$heureEntame = 60 - $addition;
}else{
$heureEntame = 120 - $addition;
}
$totalHeures = $heuresDay1 + $heuresDay2;
$prixPremiereHeure = 70;
$prixHeure = 35;
$prisheureDouble = 70;
$prixMinutePremiereHeure = 70/60;
$prixMinuteHeure = 35/60;
$prixMinuteHeureDouble = 70/60;
if (($heureshno%60)==0) {
$heuresComptees = ($heureshno/60);
}else{
$heuresComptees = ceil($heureshno/60);
}
if($heuresComptees > 4){
$tarif = $prixPremiereHeure + (3 * $prixHeure) + (ceil(($heuresComptees - 4)/2) * $prisheureDouble);
}
else{
$tarif = $prixPremiereHeure + (($heuresComptees - 1) * $prixHeure);
}
$tarifDay1 = ($prixHeure + ($heuresDay1 * $prixHeure) + ($resteDay1 * $prixMinuteHeure));
$tarifDay2 = (($heuresDay2 * $prixHeure) + ($resteDay2 * $prixMinuteHeure) + ($heureEntame * $prixMinuteHeure));
if ($startDay==$endDay){ //Pour OP dans la même journée
switch ($startDay) {
case 1:
case 2:
case 3:
case 4:
case 5:
$tarifOP = $tarif;
break;
case 6:
$tarifOP = $tarif * 1.2;
break;
case 7:
$tarifOP = $tarif * 1.5;
break;
}
}else{ //Pour OP à cheval sur 2 jours
if(($startDay == 1) || ($startDay == 2) || ($startDay == 3) || ($startDay == 4)){
$tarifOP = $tarif;
}elseif(($startDay == 5) && ($endDay == 6)){
$tarifOP = $tarifDay1 + ($tarifDay2 * 1.2);
}elseif(($startDay == 6) && ($endDay == 7)){
$tarifOP = ($tarifDay1 * 1.2) + ($tarifDay2 * 1.5);
}elseif(($startDay == 7) && ($endDay == 1)){
$tarifOP = ($tarifDay1 * 1.5) + $tarifDay2;
}
}
return ceil($tarifOP);
} |
Partager