ソースを参照

BiAuditGenerate w BI_audit_ENERGA_PRACOWNICY - niedokończone

Mariusz Muszyński 8 年 前
コミット
5f6b4dfc58
1 ファイル変更116 行追加15 行削除
  1. 116 15
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php

+ 116 - 15
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -11,6 +11,7 @@ Lib::loadClass('Core_AclSimpleSchemaBase');
 class Route_UrlAction_BiAuditGenerate extends RouteBase {
 
 	private $powiazanie = null;
+	private $SOURCE = null;
 	private $REFERER;
 
 	public function handleAuth() {
@@ -60,7 +61,7 @@ class Route_UrlAction_BiAuditGenerate extends RouteBase {
             </tr>
           </thead>
           <tbody>
-	
+
 <?php
 		$acl = Core_AclHelper::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
 		$queryFeatures = $acl->buildQuery(['limit' => 0]);
@@ -181,20 +182,115 @@ function toggle(source) {
 		echo "Statystyki znalezionych powiązań [TODO]";
 	}
 
-	private function powiazania($ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA) {
+	private function showPowiazaniaList() {
+		if (!$this->SOURCE['ID']) throw new Exception("Błąd danych");
+		elseif ($this->SOURCE['TABLE'] != 'BI_audit_ENERGA_PRACOWNICY') throw new Exception("Błąd danych");
+		echo "test";
+
+		$query = "select * from `{$this->SOURCE['TABLE']}` where ID = '{$this->SOURCE['ID']}'";
+		$pracownik = DB::getPDO()->fetchFirst($query);
+		if (!$pracownik) throw new Exception("Błąd danych");
+?>
+<div class="container" style="margin-top:20px">
+  <form class="form-horizontal" method="post">
+    <legend>
+      Lista wygenerowanych powiązań :: <?=($pracownik['imiona'] . " " . $pracownik['nazwisko'])?>
+      <span class="pull-right"># <?=$pracownik['ID']?></span>
+    </legend>
+    <div class="form-group">
+      <div class="col-sm-12">
+        <h4>Lista wygenerowanych powiązań, w których znajduje się pracownik</h4>
+        <table class="table table-bordered table-hover table-striped" height=5>
+          <thead>
+            <tr style="text-align:center; background-color:lightgray">
+              <td width=1>ID</td>
+              <td>Adnotacje</td>
+              <td>Głębokość analizy</td>
+              <td>Status raportu</td>
+              <td>Status raportu - informacje</td>
+              <td>Indywidualny raport</td>
+            </tr>
+          </thead>
+          <tbody>
+
+<?php
+		$refPowiazaniaToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
+			'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
+		$query = "select `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`.*
+from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`
+join `{$refPowiazaniaToPracownicy}` on `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`.`ID` = `{$refPowiazaniaToPracownicy}`.`PRIMARY_KEY`
+where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
+		$result = DB::getPDO()->fetchAll($query);
+
+		if (!$result) echo '<tr><td align="center" colspan="6">Brak znalezionych powiązań</td></tr>';
+		else {
+	                foreach ($result as $row) {
+				$query = "select count(*) from `{$refPowiazaniaToPracownicy}` where `PRIMARY_KEY` = '{$row['ID']}'";
+				$count = DB::getPDO()->fetchValue($query);
+?>
+            <tr>
+              <td align="right"><?=$row['ID']?></td>
+              <td><?=$row['L_APPOITMENT_INFO']?></td>
+              <td><?=$row['BI_analiza_depth']?></td>
+              <td><?=$row['FILE_STATUS']?></td>
+              <td><?=$row['FILE_STATUS_info']?></td>
+              <td><?=($count > 1 ? 'Nie' : 'Tak')?></td>
+            </tr>
+<?php
+			}
+?>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+    </div>
+    <div class="form-group">
+      <div class="col-sm-12">
+        <h4>Dodaj nowe zadanie generowania powiazań dla tego pracownika</h4>
+        <div class="containter" style="text-align:center">
+          TODO
+        </div>
+      </div>
+    </div>
+<!--    <div class="form-group">
+      <div class="col-sm-12">
+        <div class="containter" style="text-align:center">
+          <button type="submit" class="btn btn-primary" name="action" value="initialize">Generuj</button>
+          <a href="<?=$this->REFERER?>" class="btn btn-default">Powrót</a>
+        </div>
+      </div>
+    </div>-->
+    <input type="hidden" name="REFERER" value="<?=$this->REFERER?>"/>
+  </form>
+</div>
+
+<?php
+		}
+	}
+
+	private function powiazania() {
 		try {
-			$powiazania = DB::getPDO()->fetchall("select * from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA}'");
-			if (!$powiazania) throw new Exception("Błąd danych");
-			$this->powiazanie = $powiazania[0];
-			switch ($this->powiazanie['FILE_STATUS']) {
-				case "NONE":
-					$this->initializePowiazania();
+			if (!$this->SOURCE) throw new Exception("Błąd danych");
+			elseif (!(isset($this->SOURCE['TABLE']) && isset($this->SOURCE['ID']))) throw new Exception("Błąd danych");
+			switch ($this->SOURCE['TABLE']) {
+				case "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA":
+					$powiazania = DB::getPDO()->fetchall("select * from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$this->SOURCE['ID']}'");
+					if (!$powiazania) throw new Exception("Błąd danych");
+					$this->powiazanie = $powiazania[0];
+					switch ($this->powiazanie['FILE_STATUS']) {
+						case "NONE":
+							$this->initializePowiazania();
+							break;
+						case "GENERATED":
+							$this->showPowiazania();
+							break;
+						default: throw new Exception("Błędny status rekordu");
+					}
 					break;
-				case "GENERATED":
-					$this->showPowiazania();
+				case "BI_audit_ENERGA_PRACOWNICY":
+					$this->showPowiazaniaList();
 					break;
-				default:
-					throw new Exception("Błędny status rekordu");
+				default: throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate");
 			}
 		} catch (Exception $e) {
 			SE_Layout::alert('danger',$e->getMessage());
@@ -215,7 +311,12 @@ function toggle(source) {
 			unset($_SESSION['REFERER']);
 		} elseif (V::get('REFERER', '', $_POST) != '') $this->REFERER = V::get('REFERER', '', $_POST);
 		else $this->REFERER=$_SERVER['HTTP_REFERER'];
-		if (V::get('ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 0, $_GET, 'int') > 0) $this->powiazania(V::get('ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 0, $_GET, 'int'));
+		if (($ID = V::get('ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA';
+		elseif (($ID = V::get('ID_BI_audit_ENERGA_PRACOWNICY', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_PRACOWNICY';
+		if ($this->SOURCE) {
+			$this->SOURCE['ID'] = $ID;
+			$this->powiazania();
+		}
 		else SE_Layout::alert('danger','Błąd parametru');
 		SE_Layout::dol();
 	}
@@ -685,7 +786,7 @@ SQL;
 	}
 }
 
-                
+
 class BiAuditRelations {
 	private $RELATIONS_ID = [];
 
@@ -795,7 +896,7 @@ class BiAuditPowiazania {
 
 		$refPowiazaniaToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
 			'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
-		$query = "select `all`.ID as ID from BI_audit_ALL `all` join `{$refPowiazaniaToPracownicy}` ref 
+		$query = "select `all`.ID as ID from BI_audit_ALL `all` join `{$refPowiazaniaToPracownicy}` ref
 			on `all`.REMOTE_TABLE = 'BI_audit_ENERGA_PRACOWNICY' and `all`.REMOTE_ID = ref.REMOTE_PRIMARY_KEY and ref.PRIMARY_KEY = '{$ID}'";
 		$result = DB::getPDO()->fetchAll($query);
 		foreach ($result as $row) $this->findPowiazania($row['ID']);