panel_biall_net.php 5.1 KB

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