panel_biall_net.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. Lib::loadClass('Router');
  3. class Theme_panel_biall_net extends ThemeDefault {
  4. // function head() { // echo 'html tag inside <head>'
  5. // }
  6. function top() { // first tag after body: top menu or header
  7. include dirname(__FILE__) . '/view/top.php';
  8. }
  9. function footer() { // before </body>
  10. include dirname(__FILE__) . '/view/footer.php';
  11. }
  12. function login($data) {
  13. if (is_array($data) && !empty($data)) {
  14. extract($data);
  15. }
  16. $remindPasswdLink = Router::getRoute('UrlAction_RemindPasswd')->getLink();
  17. include dirname(__FILE__) . '/view/login.php';
  18. }
  19. function remind($data) {
  20. if (is_array($data) && !empty($data)) {
  21. extract($data);
  22. }
  23. $loginLink = Request::getPathUri();
  24. include dirname(__FILE__) . '/view/remind.php';
  25. }
  26. function remindSent($data = []) {
  27. if (is_array($data) && !empty($data)) {
  28. extract($data);
  29. }
  30. include dirname(__FILE__) . '/view/remindSent.php';
  31. }
  32. function remindSetNewPassword($data = []) {
  33. if (is_array($data) && !empty($data)) {
  34. extract($data);
  35. }
  36. $loginLink = Request::getPathUri();
  37. include dirname(__FILE__) . '/view/remindSetNewPass.php';
  38. }
  39. function remindNewPasswordSet($data) {
  40. if (is_array($data) && !empty($data)) {
  41. extract($data);
  42. }
  43. $loginLink = Request::getPathUri();
  44. include dirname(__FILE__) . '/view/remindNewPassSetConfirm.php';
  45. }
  46. function logout($data) {
  47. if (is_array($data) && !empty($data)) {
  48. extract($data);
  49. }
  50. include dirname(__FILE__) . '/view/logout.php';
  51. }
  52. function home($data) { // TODO: home page view
  53. // trigger_error(date("Y-m-d H:i:s") . "\t" . "panel_bn/home uid(".User::getID().") ses: { ID: {$_SESSION['ID']}, ADM_NAME: {$_SESSION['ADM_NAME']} }", E_USER_NOTICE);
  54. if (is_array($data) && !empty($data)) {
  55. extract($data);
  56. }
  57. if (!User::logged()) {
  58. UI::alert('danger', "Brak dostępu");
  59. return;
  60. }
  61. Lib::loadClass('Windykacja_StatsModel');
  62. Lib::loadClass('Windykacja_FunkcjeL1');
  63. $billDocs = Windykacja_StatsModel::getBillDocsByDate(User::getID());
  64. $billDocs->sort_docs();
  65. $billDocs->set_saldo_for_all_docs();
  66. $billDocs->set_paid_status_for_all(); // Windykacja_BillingDoc._paid_status: 1 (Opłacona) | 0 (Nieopłacona)
  67. $listBillDocs = $billDocs->get_docs(); // [ day => [ Windykacja_EventDoc, ... ], ... ]
  68. $fvList = array_reduce($listBillDocs, function ($ret, $dayDocList) {
  69. foreach ($dayDocList as $billDoc) {
  70. if ('FVAT' == $billDoc->_type) {
  71. // $nr = "Faktura Vat Nr " . $billDoc->get('NUMBER') . " / " . $billDoc->get('ID_BILLING_PREFIXES');
  72. $nr = "Nr " . $billDoc->get('NUMBER') . " / " . $billDoc->get('ID_BILLING_PREFIXES');
  73. array_unshift($ret, [
  74. 'NUMER FAKTURY' => $nr,
  75. 'DATA WYSTAWIENIA' => $billDoc->get('BILL_DATE'),
  76. 'STATUS' => ($billDoc->_paid_status) ? "Opłacona" : "Nieopłacona",
  77. 'WARTOŚĆ BRUTTO' => $billDoc->get('WARTOSC'),
  78. 'AKCJA' => UI::h('a', [
  79. 'href' => Router::getRoute('UrlAction_ViewFV')->getLink('', [ 'nr' => $billDoc->get('ID_BILLING_NUMBERS') ]),
  80. 'target' => "_blank",
  81. 'class' => "",
  82. ], "Podglgąd"),
  83. '_data' => $billDoc,
  84. ]);
  85. } else if ('KORV' == $billDoc->_type) {
  86. // DBG::nicePrint($billDoc, "TODO: DOC KORV"); // how to print?
  87. } else { // skip
  88. // DBG::nicePrint($billDoc, "TODO: DOC TYPE '{$billDoc->_type}'?");
  89. }
  90. }
  91. return $ret;
  92. }, []);
  93. // DBG::nicePrint($billDocs, '$billDocs');
  94. // DBG::nicePrint($listBillDocs, '$listBillDocs');
  95. // DBG::nicePrint($fvList, '$fvList');
  96. $company = Windykacja_StatsModel::getOwnerCompany(User::getID());
  97. $saldo = $billDocs->get_saldo();
  98. $nr_konta = Windykacja_FunkcjeL1::bankowy_make_nrach($company['NR_RACH_MASS_PAY'], User::getID(), 0);
  99. if (!empty($_SESSION['PANEL_BN_USERS'])) {
  100. $idUser = User::getID();
  101. // echo UI::h('pre', [], var_export($_SESSION['PANEL_BN_USERS'], true));
  102. echo UI::h('form', [ 'method' => "POST" ], [
  103. UI::h('div', [ 'class' => "row" ], [
  104. UI::h('div', [ 'class' => "col-md-offset-3 col-md-6" ], [
  105. UI::h('div', [ 'class' => "form-group" ], [
  106. UI::h('label', [ 'class' => "label-control" ], "Klient"),
  107. UI::h('select', [ 'name' => "id", 'class' => "form-control", 'onChange' => "this.form.submit()" ], array_map(function ($item) use ($idUser) {
  108. // 'ID' => '13684',
  109. // 'LOGIN' => 'paulina.kinowska@wp.pl',
  110. // 'P_NAME' => 'Paulina',
  111. // 'P_NAME_SECOND' => 'Kinowska',
  112. // 'BILLING_OWNER' => '3',
  113. return UI::h('option', array_merge(
  114. [ 'value' => $item['ID'] ],
  115. ($idUser == $item['ID']) ? [ 'selected' => "selected" ] : []
  116. ), $item['P_NAME'] . " " . $item['P_NAME_SECOND']);
  117. }, $_SESSION['PANEL_BN_USERS'])),
  118. UI::h('input', [ 'type' => "hidden", 'name' => "_route", 'value' => "UrlAction_ChangeUser" ]),
  119. UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => "_changeUser" ]),
  120. ]),
  121. ]),
  122. ]),
  123. ]);
  124. }
  125. include dirname(__FILE__) . '/view/home.php';
  126. }
  127. }