Przeglądaj źródła

+ GrafikRozlicz test

Piotr Labudda 6 lat temu
rodzic
commit
3bb55fa02c
1 zmienionych plików z 53 dodań i 0 usunięć
  1. 53 0
      SE/se-lib/Route/UrlAction/GrafikRozlicz.php

+ 53 - 0
SE/se-lib/Route/UrlAction/GrafikRozlicz.php

@@ -0,0 +1,53 @@
+<?php
+
+Lib::loadClass('RouteBase');
+Lib::loadClass('UI');
+
+class Route_UrlAction_GrafikRozlicz extends RouteBase {
+
+	function defaultAction() { UI::layout([ $this, 'defaultView' ]); }
+	function defaultView() {
+		$rows = DB::getPDO()->fetchAll("
+			select 
+				g.DATE
+				, g.L_APPOITMENT_USER
+				, g.WORKER_COMMENT
+				--	, g.*
+			from GRAFIK_PRACY g
+			where g.L_APPOITMENT_USER in ( 'sokol', 'm.kwiatkowski', 'kacper.klimanski' )
+				and g.DATE like '2019-10-%'
+				and g.WORKER_COMMENT != ''
+		");
+		$rozliczList = array_reduce($rows, function ($ret, $item) {
+			$splitTasks = explode("\n", $item['WORKER_COMMENT']);
+			foreach ($splitTasks as $commentLine) {
+				$commentLine = trim($commentLine);
+				if (empty($commentLine)) continue;
+				$ret[] = array_merge($item, [
+					'WORKER_COMMENT' => $commentLine,
+				]);
+			}
+			return $ret;
+		}, []);
+		// UI::table([
+		// 	'rows' => $rows,
+		// ]);
+		// UI::table([
+		// 	'rows' => $rozliczList,
+		// ]);
+		$rozliczByDayList = array_reduce($rozliczList, function ($ret, $item) {
+			$day = $item['DATE'];
+			if (array_key_exists($ret, $day)) $ret[$day] = [];
+			$ret[$day][] = $item;
+			return $ret;
+		}, []); // [ day => [] ]
+		ksort($rozliczByDayList);
+		echo UI::h('div', [], array_map(function ($item, $day) {
+			return UI::h('div', [], [
+				UI::h('h3', [], "Dzień: {$day}"),
+				UI::hTable([ 'rows' => $item ]),
+			]);
+		}, $rozliczByDayList, array_keys($rozliczByDayList)));
+	}
+
+}