index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. if (cfr('GARAGE')) {
  3. $garage = new Garage();
  4. show_window('', $garage->renderControls());
  5. //creating new driver
  6. if (ubRouting::checkPost($garage::PROUTE_NEWDRIVER)) {
  7. $garage->createDriver(ubRouting::post($garage::PROUTE_NEWDRIVER));
  8. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_DRIVERS . '=true');
  9. }
  10. //creating new car
  11. if (ubRouting::checkPost(array($garage::PROUTE_NEWCAR, $garage::PROUTE_CARVENDOR, $garage::PROUTE_CARMODEL))) {
  12. $garage->createCar();
  13. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_CARS . '=true');
  14. }
  15. //deleting driver
  16. if (ubRouting::checkGet($garage::ROUTE_DRIVERDEL)) {
  17. $garage->deleteDriver(ubRouting::get($garage::ROUTE_DRIVERDEL));
  18. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_DRIVERS . '=true');
  19. }
  20. //editing driver
  21. if (ubRouting::checkPost($garage::PROUTE_DRIVEREDIT)) {
  22. $garage->setDriverCar(ubRouting::post($garage::PROUTE_DRIVEREDIT), ubRouting::post($garage::PROUTE_DRIVERCAR));
  23. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_DRIVERS . '=true');
  24. }
  25. //deleting car
  26. if (ubRouting::checkGet($garage::ROUTE_CARDEL)) {
  27. $carDeletionResult = $garage->deleteCar(ubRouting::get($garage::ROUTE_CARDEL));
  28. if (!$carDeletionResult) {
  29. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_CARS . '=true');
  30. } else {
  31. show_error($carDeletionResult);
  32. show_window('', wf_BackLink($garage::URL_ME . '&' . $garage::ROUTE_CARS . '=true'));
  33. }
  34. }
  35. //creating new mileage record
  36. if (ubRouting::checkPost(array($garage::PROUTE_MILEAGECAR, $garage::PROUTE_MILEAGEKM))) {
  37. $mileageCreateResult = $garage->createMileage(ubRouting::post($garage::PROUTE_MILEAGECAR), ubRouting::post($garage::PROUTE_MILEAGEKM), true);
  38. if (empty($mileageCreateResult)) {
  39. ubRouting::nav($garage::URL_ME . '&' . $garage::ROUTE_MILEAGE . '=true');
  40. } else {
  41. show_error($mileageCreateResult);
  42. show_window('', wf_BackLink($garage::URL_ME . '&' . $garage::ROUTE_MILEAGE . '=true'));
  43. }
  44. }
  45. //rendering cars list
  46. if (ubRouting::checkGet($garage::ROUTE_CARS)) {
  47. show_window(__('Available cars'), $garage->renderCarsList());
  48. }
  49. //rendering drivers list
  50. if (ubRouting::checkGet($garage::ROUTE_DRIVERS)) {
  51. show_window(__('Existing drivers'), $garage->renderDriversList());
  52. }
  53. //rendering mileage stats
  54. if (ubRouting::checkGet($garage::ROUTE_MILEAGE)) {
  55. show_window(__('Mileage'), 'TODO');
  56. deb($garage->renderMileageCreateForm());
  57. }
  58. } else {
  59. show_error(__('Access denied'));
  60. }