Advertisement
Guest User

Untitled

a guest
May 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. function costCalc($date,$days,$aid,$adults,$children) {
  2. if(time("U")> strtotime($date)){
  3. echo "INVALID DATE";
  4. return;
  5. }
  6. if($days>14||$days<1){
  7. echo 'INVALID NUMBER OF DAYS';
  8. return;
  9. }
  10. if($adults>10||$adults<1){
  11. echo 'INVALID NUMBER OF ADULTS';
  12. return;
  13. }
  14. if($children>10||$children<0){
  15. echo 'INVALID NUMBER OF CHILDREN';
  16. return;
  17. }
  18. if($adults>1){
  19. $extra=$children*5+($adults-2)*10;
  20. }
  21. if($adults==1&&$children<2){
  22. $extra=0;
  23. }
  24. if($adults==1&&$children>1){
  25. $extra=($children-1)*5+($adults-1)*10;
  26. }
  27. switch($aid) {
  28. case 'US':
  29. $cost = $days*(35.25+$extra);
  30. echo number_format((float)$cost, 2, '.', '');
  31. return;
  32. case 'PS':
  33. $cost = $days*(50.25+$extra);
  34. echo number_format((float)$cost, 2, '.', '');
  35. return;
  36. case 'UM':
  37. $cost = $days*(40.50+$extra);
  38. echo number_format((float)$cost, 2, '.', '');
  39. return;
  40. case 'PM':
  41. $cost = $days*(60.50+$extra);
  42. echo number_format((float)$cost, 2, '.', '');
  43. return;
  44. case 'C':
  45. $cost = $days*(100);
  46. echo number_format((float)$cost, 2, '.', '');
  47. return;
  48. default:
  49. return 'INVALID PRODUCT CODE';
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement