ViewFV.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. Lib::loadClass('RouteToolBase');
  3. Lib::loadClass('UI');
  4. Lib::loadClass('Response');
  5. Lib::loadClass('Theme');
  6. require_once dirname(__FILE__) . '/../auth.php'; // Theme_Auth_panel_biall_net
  7. // index.php?_route=UrlAction_ViewFV - uruchamia defaultAction
  8. class RouteTool_ViewFV extends RouteToolBase {
  9. function defaultAction() {
  10. try {
  11. $nr = V::get('nr', 0, $_GET, 'int'); // ID_BILLING_NUMBERS
  12. if (empty($nr)) throw new Exception("Brak nr faktury");
  13. $idUser = User::getID();
  14. $body = DB::getPDO(931)->fetchValue("
  15. select BODY_HTML
  16. from HIST_CONTACTS
  17. where ID_BILLING_USERS = :id_user
  18. and ID_BILLING_NUMBERS = :nr
  19. order by ID DESC
  20. limit 1
  21. ", [
  22. ':id_user' => $idUser,
  23. ':nr' => $nr,
  24. ]);
  25. // `- 7769215` dla dużych numerów - błędnie wprowadzonych np. 9880 klient(13374) BUG nr 8635412
  26. // 8635412 - BUG ID_BILLING_NUMBERS in HIST_CONTACTS
  27. // 866197 - correct ID_BILLING_NUMBERS
  28. // MAX BILLING_NUMBERS.ID = 874100
  29. if (empty($body)) {
  30. $body = DB::getPDO(931)->fetchValue("
  31. select BODY_HTML
  32. from HIST_CONTACTS
  33. where ID_BILLING_USERS = :id_user
  34. and ID_BILLING_NUMBERS = :nr
  35. order by ID DESC
  36. limit 1
  37. ", [
  38. ':id_user' => $idUser,
  39. ':nr' => $nr + 7769215,
  40. ]);
  41. }
  42. if (empty($body)) throw new Exception("Brak faktury");
  43. die($body);
  44. } catch (Exception $e) {
  45. UI::gora();
  46. Theme::top();
  47. echo UI::h('div', [ 'class' => "container" ], [
  48. UI::h('div', [ 'class' => 'alert alert-danger' ], $e->getMessage()),
  49. ]);
  50. UI::dol();
  51. }
  52. }
  53. }