瀏覽代碼

fixed code style in UserTest - Moje Testy

Piotr Labudda 8 年之前
父節點
當前提交
306008de4f
共有 1 個文件被更改,包括 137 次插入145 次删除
  1. 137 145
      SE/se-lib/Route/UserTest.php

+ 137 - 145
SE/se-lib/Route/UserTest.php

@@ -4,158 +4,150 @@ Lib::loadClass('RouteBase');
 
 class Route_UserTest extends RouteBase {
 
-  public function handleAuth() {
-		if (!User::logged()) {
-			User::authByRequest();
-		}
+	public function handleAuth() {
+		if (!User::logged()) User::authByRequest();
 	}
 
-  public function defaultAction() {
-    UI::gora();
-    UI::menu();
-    session_write_close();
-    try {
-      $procesMenu = ProcesMenu::getInstance();
-      // $procesMenu->menuAction();// like UI::menu() ?
-      $acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
-      $userTestStatsList = $acl->getItems();
-      UI::setTitle("Testy - Moje");
-      $this->userTestsView($userTestStatsList);
-    } catch (Exception $e) {
-      UI::alert('danger', $e->getMessage());
-    }
-    UI::dol();
-  }
-
-  public function adminUserTestAction() {// TODO: replace POST from admin menu to view another user tests
-    UI::gora();
-    UI::menu();
-    session_write_close();
-    try {
-      $idUser = V::get('_user_id', 0, $_REQUEST, 'int');
-      $user = [];// $user = Core_AclHelper::getAclByNamespace('default_db/ADMIN_USERS')->getItem($idUser);
-      $user['name'] = "TODO: user name({$idUser})";
-
-      $acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
-      $acl->setIdUser($idUser);
-      $userTestStatsList = $acl->getItems();
-      UI::setTitle("Testy - pracownika {$user['name']}");
-      $this->userTestsView($userTestStatsList);
-    } catch (Exception $e) {
-      UI::alert('danger', $e->getMessage());
-    }
-    UI::dol();
-  }
-
-  public function userTestsView($userTestStatsList) {
-    $activeFiltrProcessId = User::getAcl()->getPermsFiltrProcesId();
-    ?>
-    <style type="text/css">
-    .tbl-wyniki-testow {}
-     .tbl-wyniki-testow td {vertical-align:top;font-size:small;}
-     .tbl-wyniki-testow .proces-box {padding:0 6px;background:#f00;color:#fff;font-weight:bold;font-family:arial;text-decoration:none}
-     .tbl-wyniki-testow .proces-title {padding:0 3px;}
-     .tbl-wyniki-testow .wynik-cell .wyniki-cell-header {height:56px;overflow:hidden;}
+	public function defaultAction() {
+		UI::gora();
+		UI::menu();
+		session_write_close();
+		try {
+			$procesMenu = ProcesMenu::getInstance();
+			// $procesMenu->menuAction();// like UI::menu() ?
+			$acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
+			$userTestStatsList = $acl->getItems();
+			UI::setTitle("Testy - Moje");
+			$this->userTestsView($userTestStatsList);
+		} catch (Exception $e) {
+		  UI::alert('danger', $e->getMessage());
+		}
+		UI::dol();
+	}
 
-     .tbl-wyniki-testow .wynik-cell {padding:0 3px;}
-     .tbl-wyniki-testow .wynik-BRAK_TESTU .proces-box {background-color:silver;}
-     .tbl-wyniki-testow .wynik-BRAK_PYTAN .proces-box {background-color:#51B7D5;}
-     .tbl-wyniki-testow .wynik-DOBRY .proces-box {background-color:lightgreen;}
-     .tbl-wyniki-testow .wynik-DOSTATECZNY .proces-box {background-color:#FFFFB1; color:#777;}
-     .tbl-wyniki-testow .wynik-NIEDOSTATECZNY .proces-box {background-color:#FC5151;}
-     .tbl-wyniki-testow .wynik-IDEALNY .proces-box {background-color:gold;}
-     .tbl-wyniki-testow .wynik-NIEAKTUALNY .proces-box {background-color:silver;}
-    </style>
-    <?php
+	public function adminUserTestAction() {// TODO: replace POST from admin menu to view another user tests
+		UI::gora();
+		UI::menu();
+		session_write_close();
+		try {
+			$idUser = V::get('_user_id', 0, $_REQUEST, 'int');
+			$user = [];// $user = Core_AclHelper::getAclByNamespace('default_db/ADMIN_USERS')->getItem($idUser);
+			$user['name'] = "TODO: user name({$idUser})";
+
+			$acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
+			$acl->setIdUser($idUser);
+			$userTestStatsList = $acl->getItems();
+			UI::setTitle("Testy - pracownika {$user['name']}");
+			$this->userTestsView($userTestStatsList);
+		} catch (Exception $e) {
+			UI::alert('danger', $e->getMessage());
+		}
+		UI::dol();
+	}
 
-    $procesyInitList = [];
-    foreach ($userTestStatsList as $row) {
-      $procesyInitList[ $row['ID'] ] = $row['nazwa'];
-    }
+	public function userTestsView($userTestStatsList) {
+		$activeFiltrProcessId = User::getAcl()->getPermsFiltrProcesId();
+		echo UI::h('style', [ 'type' => "text/css" ], "
+		.tbl-wyniki-testow {}
+		 .tbl-wyniki-testow td {vertical-align:top;font-size:small;}
+		 .tbl-wyniki-testow .proces-box {padding:0 6px;background:#f00;color:#fff;font-weight:bold;font-family:arial;text-decoration:none}
+		 .tbl-wyniki-testow .proces-title {padding:0 3px;}
+		 .tbl-wyniki-testow .wynik-cell .wyniki-cell-header {height:56px;overflow:hidden;}
+
+		 .tbl-wyniki-testow .wynik-cell {padding:0 3px;}
+		 .tbl-wyniki-testow .wynik-BRAK_TESTU .proces-box {background-color:silver;}
+		 .tbl-wyniki-testow .wynik-BRAK_PYTAN .proces-box {background-color:#51B7D5;}
+		 .tbl-wyniki-testow .wynik-DOBRY .proces-box {background-color:lightgreen;}
+		 .tbl-wyniki-testow .wynik-DOSTATECZNY .proces-box {background-color:#FFFFB1; color:#777;}
+		 .tbl-wyniki-testow .wynik-NIEDOSTATECZNY .proces-box {background-color:#FC5151;}
+		 .tbl-wyniki-testow .wynik-IDEALNY .proces-box {background-color:gold;}
+		 .tbl-wyniki-testow .wynik-NIEAKTUALNY .proces-box {background-color:silver;}
+		");
+
+		$procesyInitList = [];
+		foreach ($userTestStatsList as $row) {
+			$procesyInitList[ $row['ID'] ] = $row['nazwa'];
+		}
 
-    $parentIdList = array_filter(
-      array_map(function ($row) {
-        return (int)$row['PARENT_ID'];
-      }, $userTestStatsList),
-      function ($id) { return $id > 0; }
-    );
+		$parentIdList = array_filter(
+			array_map(function ($row) {
+				return (int)$row['PARENT_ID'];
+			}, $userTestStatsList),
+			function ($id) { return $id > 0; }
+		);
 
-    $sqlProcesyInitIds = (!empty($parentIdList)) ? implode(",", $parentIdList) : '';
-    $parentProcessList = DB::getPDO()->fetchAll("
-      select p.ID, p.PARENT_ID, p.DESC as nazwa
+		$sqlProcesyInitIds = (!empty($parentIdList)) ? implode(",", $parentIdList) : '';
+		$parentProcessList = DB::getPDO()->fetchAll("
+			select p.ID, p.PARENT_ID, p.DESC as nazwa
 			from CRM_PROCES as p
 			where p.ID in({$sqlProcesyInitIds})
-    ");
-    foreach ($parentProcessList as $parentProcess) {
-      UI::startContainer(['class'=>"tbl-wyniki-testow page-header"]);
-      $linkProcessTree = "procesy5.php?task=CRM_PROCES&amp;filtr_id={$parentProcess['ID']}";
-      UI::tag('h3', [], "{$parentProcess['nazwa']} <small><a href=\"{$linkProcessTree}\">{{$parentProcess['ID']}}</a></small>");
-      UI::endContainer();
-
-      UI::startContainer(['class'=>"tbl-wyniki-testow"]);
-      UI::startTag('div', ['class'=>"row"]);
-      $i = 0;
-      foreach ($userTestStatsList as $testStats) {
-        if ($testStats['PARENT_ID'] != $parentProcess['ID']) continue;
-
-        UI::startTag('div', ['class'=>"col-md-3 wynik-cell wynik-{$testStats['wynik_teoretyczny']}"]);
-          UI::startTag('div', ['class'=>"panel panel-default"]);
-            UI::startTag('div', ['class'=>"panel-heading"]);
-              UI::tag('span', ['title'=>htmlspecialchars($testStats['nazwa']), 'data-toggle'=>"tooltip"], V::strShortUtf8($testStats['nazwa'], 80), " ");
-              $linkProcesView = "procesy5.php?task=PROCES_VIEW&id_proces={$testStats['ID']}";
-          	  UI::tag('a', ['href'=>$linkProcesView, 'title'=>"zobacz instrukcję do procesu {$testStats['ID']}", 'target'=>"_blank"], "{{$testStats['ID']}}");
-            UI::endTag('div');// .panel-heading
-            UI::startTag('div', ['class'=>"panel-body"]);
-              UI::startTag('ul', ['style' => "padding-left:20px"]);
-                UI::startTag('li');
-                  if ($activeFiltrProcessId == $testStats['ID']) {
-                    UI::tag('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'style'=>"font-weight:bold"], "Wyłącz filtr uprawnien dla", " ");
-                  } else {
-                    UI::tag('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces={$testStats['ID']}"], "Uruchom filtr uprawnien dla", " ");
-                  }
-                  echo "{$testStats['ID']}";
-                UI::endTag('li');
-
-                UI::startTag('li');
-                  UI::tag('a', ['href'=>"procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}"], "Wykonaj test teoretyczny dla", " ");
-                  echo "{$testStats['ID']}";
-                UI::endTag('li');
-
-                UI::startTag('li');
-                  echo "Test teoretyczny: ";
-                  UI::startTag('span', ['class'=>"proces-box"]);
-                    echo " {$testStats['wynik_teoretyczny']} ";
-                    if ($testStats['wynik_teoretyczny_value']) UI::tag('em', null, $testStats['wynik_teoretyczny_value']);
-                  UI::endTag('span');
-                UI::endTag('li');
-
-                UI::tag('li', ['class'=>"wynik-{$testStats['wynik_praktyczny']}"], "Test praktyczny: {$testStats['wynik_praktyczny']}");
-
-              UI::endTag('ul');
-
-              $tagFixTest = ($testStats['link_popraw_test'])
-                ? "<a class=\"btn btn-xs btn-primary\" href=\"{$testStats['link_popraw_test']}\">popraw</a>"
-                : '';
-              if ($testStats['wynik_unactual']) {
-      					UI::alert('danger', "
-                  <b>Uwaga! Test nieaktualny:</b>
-                  {$tagFixTest}
-                  <br>" . substr($testStats['last_test_end'], 0, 10) . " - zakończenie testu
-      						<br>" . substr($testStats['last_update_date'], 0, 10) . " - ostatnia zmiana w procesie
-                ");
-              }
-            UI::endTag('div');// .panel-body
-          UI::endTag('div');// .panel
-        UI::endTag('div');// .wynik-cell
-        if (++$i >= 4) {
-          $i = 0;
-          UI::endTag('div');// .row
-          UI::startTag('div', ['class'=>"row"]);
-        }
-      }
-      UI::endTag('div');// .row
-      UI::endContainer();
-    }
-  }
+		");
+		foreach ($parentProcessList as $parentProcess) {
+			echo UI::h('div', ['class'=>"container tbl-wyniki-testow page-header"], [
+				UI::h('h3', [], [
+					"{$parentProcess['nazwa']} ",
+					UI::h('small', [], [
+						UI::h('a', [ 'href' => "procesy5.php?task=CRM_PROCES&amp;filtr_id={$parentProcess['ID']}" ], "{{$parentProcess['ID']}}"),
+					]),
+				]),
+			]);
+
+			UI::startContainer(['class'=>"tbl-wyniki-testow"]);
+			UI::startTag('div', ['class'=>"row"]);
+			$i = 0;
+			foreach ($userTestStatsList as $testStats) {
+				if ($testStats['PARENT_ID'] != $parentProcess['ID']) continue;
+				echo UI::h('div', ['class'=>"col-md-3 wynik-cell wynik-{$testStats['wynik_teoretyczny']}"], [
+					UI::h('div', ['class'=>"panel panel-default"], [
+						UI::h('div', ['class'=>"panel-heading"], [
+							UI::h('span', ['title'=>htmlspecialchars($testStats['nazwa']), 'data-toggle'=>"tooltip"], V::strShortUtf8($testStats['nazwa'], 80)),
+							UI::h('a', ['href'=>"procesy5.php?task=PROCES_VIEW&id_proces={$testStats['ID']}", 'title'=>"zobacz instrukcję do procesu {$testStats['ID']}", 'target'=>"_blank"], "{{$testStats['ID']}}"),
+						]), // .panel-heading
+						UI::h('div', ['class'=>"panel-body"], [
+							UI::h('ul', ['style' => "padding-left:20px"], [
+								UI::h('li', [], [
+									($activeFiltrProcessId == $testStats['ID'])
+									?	UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'style'=>"font-weight:bold"], "Wyłącz filtr uprawnien dla")
+									:	UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces={$testStats['ID']}"], "Uruchom filtr uprawnien dla"),
+									" {$testStats['ID']}"
+								]),
+								UI::h('li', [], [
+									UI::h('a', ['href'=>"procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}"], "Wykonaj test teoretyczny dla"),
+									" {$testStats['ID']}",
+								]),
+								UI::h('li', [], [
+									"Test teoretyczny: ",
+									UI::h('span', ['class'=>"proces-box"], [
+										" {$testStats['wynik_teoretyczny']} ",
+										($testStats['wynik_teoretyczny_value'])
+										?	UI::h('em', null, $testStats['wynik_teoretyczny_value'])
+										:	'',
+									]),
+								]),
+								UI::h('li', ['class'=>"wynik-{$testStats['wynik_praktyczny']}"], "Test praktyczny: {$testStats['wynik_praktyczny']}"),
+							]),
+							($testStats['wynik_unactual'])
+							?	UI::h('div', [ 'class' => "alert alert-danger" ], [
+									"<b>Uwaga! Test nieaktualny: </b> ",
+									($testStats['link_popraw_test'])
+									?	" <a class=\"btn btn-xs btn-primary\" href=\"{$testStats['link_popraw_test']}\">popraw</a>"
+					                :	'',
+									"<br>" . substr($testStats['last_test_end'], 0, 10) . " - zakończenie testu",
+									"<br>" . substr($testStats['last_update_date'], 0, 10) . " - ostatnia zmiana w procesie",
+								])
+							: '',
+						]), // .panel-body
+					]), // .panel
+				]); // .wynik-cell
+				if (++$i >= 4) {
+					$i = 0;
+					UI::endTag('div');// .row
+					UI::startTag('div', ['class'=>"row"]);
+				}
+			}
+			UI::endTag('div');// .row
+			UI::endContainer();
+		}
+	}
 
 }