Browse Source

+ fv list; fix admin level

Piotr Labudda 4 years ago
parent
commit
0270e48c22
4 changed files with 74 additions and 16 deletions
  1. 2 2
      auth.php
  2. 42 5
      theme/panel_biall_net.php
  3. 29 8
      theme/view/home.php
  4. 1 1
      tools/RemindPasswd.php

+ 2 - 2
auth.php

@@ -46,11 +46,11 @@ class Theme_Auth_panel_biall_net { // TODO: implements AuthBaseInterface {
 			'ADM_NAME' => implode(" ", [ $item['P_NAME'], $item['P_NAME_SECOND'] ]), // ADM_NAME
 			'ADM_TECH_WORKER' => "", // ADM_TECH_WORKER
 			'ADM_COMPANY' => $item['BILLING_OWNER'], // ADM_COMPANY
-			'ADM_ADMIN_LEVEL' => "", // ADM_ADMIN_LEVEL
+			'ADM_ADMIN_LEVEL' => 5, // ADM_ADMIN_LEVEL // > 5 will show msg for Kandydat
 			'ADM_PHONE' => "", // ADM_PHONE
 			'ADM_ADMIN_EXPIRE' => "", // ADM_ADMIN_EXPIRE
 			'ADM_ADMIN_DESC' => "", // ADM_ADMIN_DESC
-			'EMPLOYEE_TYPE' => "", // EMPLOYEE_TYPE
+			'EMPLOYEE_TYPE' => "Klient", // EMPLOYEE_TYPE // [ 'Pracownik','Kandydat','Partner','Anonymous','Kontakt','Skrypt' ]
 		];
 	}
 

+ 42 - 5
theme/panel_biall_net.php

@@ -68,12 +68,49 @@ class Theme_panel_biall_net extends ThemeDefault {
 			extract($data);
 		}
 
-		$saldo = -123.456;
-		$nr_konta = "123455789 TODO";
-		// // USERS2_WINDYKACJA_STATUS.ACCOUNT_NUMBER
-		// ACCOUNT_NUMBER = Windykacja_FunkcjeL1::bankowy_make_nrach($company['NR_RACH_MASS_PAY'], $user->ID_BILLING_USERS, 0);
-		// // BILLING_OWNER.NR_RACH_MASS_PAY
+		if (!User::logged()) {
+			UI::alert('danger', "Brak dostępu");
+			return;
+		}
+
 
+		Lib::loadClass('Windykacja_StatsModel');
+		Lib::loadClass('Windykacja_FunkcjeL1');
+		$billDocs = Windykacja_StatsModel::getBillDocsByDate(User::getID());
+		$billDocs->sort_docs();
+		$billDocs->set_saldo_for_all_docs();
+		$billDocs->set_paid_status_for_all(); // Windykacja_BillingDoc._paid_status: 1 (Opłacona) | 0 (Nieopłacona)
+		$listBillDocs = $billDocs->get_docs(); // [ day => [ Windykacja_EventDoc, ... ], ... ]
+
+		$fvList = array_reduce($listBillDocs, function ($ret, $dayDocList) {
+			foreach ($dayDocList as $billDoc) {
+				if ('FVAT' == $billDoc->_type) {
+					// $nr = "Faktura Vat Nr " . $billDoc->get('NUMBER') . " / " . $billDoc->get('ID_BILLING_PREFIXES');
+					$nr = "Nr " . $billDoc->get('NUMBER') . " / " . $billDoc->get('ID_BILLING_PREFIXES');
+					array_unshift($ret, [
+						'NUMER FAKTURY' => $nr,
+						'DATA WYSTAWIENIA' => $billDoc->get('BILL_DATE'),
+						'STATUS' => ($billDoc->_paid_status) ? "Opłacona" : "Nieopłacona",
+						'WARTOŚĆ BRUTTO' => $billDoc->get('WARTOSC'),
+						'AKCJA' => "",
+
+						'_data' => $billDoc,
+					]);
+				} else if ('KORV' == $billDoc->_type) {
+					// DBG::nicePrint($billDoc, "TODO: DOC KORV"); // how to print?
+				} else { // skip
+					// DBG::nicePrint($billDoc, "TODO: DOC TYPE '{$billDoc->_type}'?");
+				}
+			}
+			return $ret;
+		}, []);
+
+		// DBG::nicePrint($billDocs, '$billDocs');
+		// DBG::nicePrint($listBillDocs, '$listBillDocs');
+		// DBG::nicePrint($fvList, '$fvList');
+		$company = Windykacja_StatsModel::getOwnerCompany(User::getID());
+		$saldo = $billDocs->get_saldo();
+		$nr_konta = Windykacja_FunkcjeL1::bankowy_make_nrach($company['NR_RACH_MASS_PAY'], User::getID(), 0);
 
 		include dirname(__FILE__) . '/view/home.php';
 	}

+ 29 - 8
theme/view/home.php

@@ -4,12 +4,33 @@
 </div>
 
 <div class="container">
-    <p>TODO: Faktury
-        <br>- NUMER FAKTURY
-        <br>- DATA WYSTAWIENIA
-        <br>- STATUS
-        <br>- WARTOŚĆ NETTO
-        <br>- WARTOŚĆ BRUTTO
-        <br>- AKCJA
-    </p>
+    <table class="table table-hover">
+        <thead>
+            <tr>
+                <th>NUMER FAKTURY</th>
+                <th>DATA WYSTAWIENIA</th>
+                <th>STATUS</th>
+                <th>WARTOŚĆ BRUTTO</th>
+                <th> </th>
+            </tr>
+        </thead>
+        <?php if (empty($fvList)) : ?>
+            <tbody>
+                <td colspan="5" style="padding:24px; text-align:center">
+                    Brak danych
+                </td>
+            </tbody>
+        <?php else : ?>
+            <?= UI::h('tbody', [], array_map(function ($fv) {
+                return UI::h('tr', [], [
+                    UI::h('td', [], $fv['NUMER FAKTURY']),
+                    UI::h('td', [], $fv['DATA WYSTAWIENIA']),
+                    UI::h('td', [], $fv['STATUS']),
+                    UI::h('td', [], $fv['WARTOŚĆ BRUTTO']),
+                    UI::h('td', [], $fv['AKCJA']),
+                ]);
+            }, $fvList)); ?>
+
+        <?php endif; ?>
+    </table>
 </div>

+ 1 - 1
tools/RemindPasswd.php

@@ -131,7 +131,7 @@ class RouteTool_RemindPasswd extends RouteToolBase {
 
 	function defaultAction() {
 		UI::gora();
-		Theme::top();
+		// Theme::top();
 		echo '<h1>ReminPasswd Tool</h1>';
 		// UI::inlineJS(__FILE__ . '.example.js', [
 		// 	'URL_TEST_AJAX_ACTION' => $this->getLink('testAjax'),