فهرست منبع

Poprawki do BiAuditGenerate

Mariusz Muszyński 7 سال پیش
والد
کامیت
f7cd9f1d54
1فایلهای تغییر یافته به همراه36 افزوده شده و 21 حذف شده
  1. 36 21
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php

+ 36 - 21
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -637,11 +637,11 @@ format: 'YYYY-MM-DD'
 			switch ($_subUrlAction) {
 				case "importToPracownicy":
 					if (in_array($this->SOURCE['TABLE'], ['BI_audit_KRS', 'BI_audit_MSIG'])) $this->importToPracownicySearch($this->SOURCE['ID']);
-					else throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate");
+					else throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate #1");
 					break;
 				case "showKrsForKrsPerson":
 					if (in_array($this->SOURCE['TABLE'], ['BI_audit_KRS_person'])) $this->showKrsForKrsPerson();
-					else throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate");
+					else throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate #2");
 					break;
 				case "operationalRaportNote":
 					$this->operationalRaportNote();
@@ -1282,19 +1282,20 @@ function validateCompany(source) {
 		return array_combine($keys, $array);
 	}
 
-	private function benford_getDetails($a = null, $b = null) {
+	private function benford_getDetails($groupField = null, $a = null, $b = null) {
                 try {
-			if (!($benford = V::get('benford', '', $_SESSION))) throw new Exception("Nieznany błąd wewnętrzny #1");
-			if (isset($benford[$this->SOURCE['TABLE']]['details'][$a][$b])) throw new Exception(@gzuncompress($benford[$this->SOURCE['TABLE']]['details'][$a][$b]));
-			if (!($benford = @unserialize(@gzuncompress($benford[$this->SOURCE['TABLE']]['data'])))) throw new Exception("Nieznany błąd wewnętrzny #2");
-			if (!isset($benford['conf']['groupField'])) throw new Exception("Nieznany błąd wewnętrzny #3");
-			if (!($groupField = $benford['conf']['groupField'])) throw new Exception("Nieznany błąd wewnętrzny #4");
-			if ($a === null) throw new Exception("Nieznany błąd wewnętrzny #5");
+			if ($groupField === null) throw new Exception("Nieznany błąd wewnętrzny #1");
+			if (!($benford = V::get('benford', '', $_SESSION))) throw new Exception("Nieznany błąd wewnętrzny #2");
+			if (isset($benford[$this->SOURCE['TABLE']]['details'][$groupField][$a][$b])) throw new Exception(@gzuncompress($benford[$this->SOURCE['TABLE']]['details'][$groupField][$a][$b]));
+			if (!($benford = @unserialize(@gzuncompress($benford[$this->SOURCE['TABLE']]['data'])))) throw new Exception("Nieznany błąd wewnętrzny #3");
+			if (!isset($benford['conf']['groupFields'])) throw new Exception("Nieznany błąd wewnętrzny #4");
+			if (!($groupFields = $benford['conf']['groupFields'])) throw new Exception("Nieznany błąd wewnętrzny #5");
+			if ($a === null) throw new Exception("Nieznany błąd wewnętrzny #6");
 			if ($b === null) {
-				if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #6");
+				if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #7");
 				$keys = $benford['firstStep'][$a]['keys'];
 			} else {
-				if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #7");
+				if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #8");
 				$keys = $benford['secondStep'][$a][$b]['keys'];
 			}
 
@@ -1309,7 +1310,13 @@ function validateCompany(source) {
 			} catch (Exception $e) {
 				throw new Exception("Nieznany błąd, prawdopodobnie błędna konfiguracja kolumny grupującej");
 			}
-			$showDetails = "<h4>Najczęściej występujące wartości kolumny {$groupField}</h4>";
+			$showDetails = '<h4>Najczęściej występujące wartości kolumny:</h4><form method="post"><select name="_groupField" class="form-control" onChange="showDetails2(this, ' . "{$a}, {$b}" . ')">';
+			foreach ($groupFields as $field) {
+				$selected = $field == $groupField ? ' selected' : '';
+				$showDetails .= "<option value={$field}{$selected}>{$field}</option>";
+			}
+			$showDetails .= "</select></form></br>";
+
 			if ($result) {
 				$showDetails .= "<table class=\"table table-bordered table-hover table-striped table-condensed\"><thead><tr style=\"font-weight:bold;\"><td>Wartość</td><td>Liczba wystąpień</td><td>Procent występowania</td></tr></thead><tbody>";
 				$showDetails .= implode('', array_map(function($v) use ($keys) {
@@ -1322,15 +1329,17 @@ function validateCompany(source) {
 		} catch (Exception $e) {
 			$showDetails = "<h4>{$e->getMessage()}</h4>";
 		}
-		$_SESSION['benford'][$this->SOURCE['TABLE']]['details'][$a][$b] = gzcompress($showDetails);
+		$_SESSION['benford'][$this->SOURCE['TABLE']]['details'][$groupField][$a][$b] = gzcompress($showDetails);
 		$showDetails .= '<button type="submit" class="btn btn-primary btn-sm" onClick="hideDetails()">Zamknij</button>';
 		return $showDetails;
 	}
 
 	private function benford_form($edit = false) {
 		if (!($valueField = V::get('_benfordValueField', '', $_GET))) throw new Exception ("Błąd konfiguracji UrlAction - brak parametru _benfordField (DANE )");
-		if (!($groupField = V::get('_benfordGroupField', '', $_GET))) throw new Exception("Brak konfiguracji kolumny grupującej");
+		if (!($groupFields = V::get('_benfordGroupField', '', $_GET))) throw new Exception("Brak konfiguracji kolumny grupującej");
 		if (!($namespace = V::get('_fromNamespace', '', $_GET))) throw new Exception("Błąd formularza");
+		$groupFields = explode(',', $groupFields);
+		$groupField = $groupFields[0];
 
 		Lib::loadClass('FeatureAttrSelected');
 		$count = FeatureAttrSelected::getTotalSelected($namespace);
@@ -1352,7 +1361,7 @@ function validateCompany(source) {
 			$benford['conf'] = [
 				'count' => count($values),
 				'valueField' => $valueField,
-				'groupField' => $groupField,
+				'groupFields' => $groupFields,
 			];
 			$_SESSION['benford'][$this->SOURCE['TABLE']] = ['data' => gzcompress(serialize($benford))];
 		} catch (Exception $e) {
@@ -1436,7 +1445,7 @@ function validateCompany(source) {
               <td style="text-align:right" class="step1-<?=$va['correct'] ? 'green' : 'red'?>"><?=$number_format(round($va['norm'] * 100, 3))?></td>
               <td style="text-align:right" class="step1-<?=$va['correct'] ? 'green' : 'red'?>"><?=$odchylenie?></td>
               <td <?=$va['correct'] ? 'class="step1-green">Tak' : 'class="step1-red" name="firstStepDesc" data-ka="' . $ka . '" nowrap>Nie (rozwiń)'?></td>
-              <td<?=$va['correct'] ? '>' : ' onClick="showDetails(' . $ka . ', null)"><span class="glyphicon glyphicon-search"></span>'?></td>
+              <td<?=$va['correct'] ? '>' : ' onClick="showDetails(' . "'{$groupField}', {$ka}" . ', null)"><span class="glyphicon glyphicon-search"></span>'?></td>
 <?php if($edit):?>
               <td<?=$va['correct'] ? '' : ' onClick="_click(\'checkFirstStep_' . $ka . '\')"'?>><input type="checkbox" <?=$va['correct'] ? 'disabled' : 'checked id="checkFirstStep_' . $ka . '" name="checkFirstStep[]" value="' . $ka . '" onClick="toggleCheckFirst(this)"'?>></td>
 <?php endif;?>
@@ -1458,7 +1467,7 @@ function validateCompany(source) {
               <td style="text-align:right" class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$number_format(round($vb['norm'] * 100, 3))?></td>
               <td style="text-align:right" class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$odchylenie?></td>
               <td class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$vb['correct'] ? 'Tak' : 'Nie'?></td>
-              <td<?=$vb['correct'] ? '>' : ' style="cursor:pointer;" onClick="showDetails(' . "{$ka}, {$kb}" . ')"><span class="glyphicon glyphicon-search"></span>'?></td>
+              <td<?=$vb['correct'] ? '>' : ' style="cursor:pointer;" onClick="showDetails(' . "'{$groupField}', {$ka}, {$kb}" . ')"><span class="glyphicon glyphicon-search"></span>'?></td>
 <?php if($edit):?>
               <td<?=$vb['correct'] ? '' : ' style="cursor:pointer;" onClick="_click(\'checkSecondStep_' . $ka . $kb . '\')"'?>><input type="checkbox"<?=$vb['correct'] ?: ' checked id="checkSecondStep_' . $ka . $kb . '" name="checkSecondStep[]" value="' . $ka . $kb . '" onClick="toggleCheckSecond(this)"'?> disabled></td>
 <?php endif;?>
@@ -1491,11 +1500,11 @@ td {font-size: 12px;}
 </style>
 <script language="JavaScript">
 <!--
-function showDetails(ka, kb) {
+function showDetails(groupField, ka, kb) {
   event.stopPropagation();
   document.getElementById('detailsMsg').innerHTML = "<h4>Proszę czekać...</h4>";
   document.getElementById('details').style.display = 'block';
-  var post = "_noMenu=1&action=getDetails&_ka=" + ka;
+  var post = "_noMenu=1&action=getDetails&_groupField=" + groupField + "&_ka=" + ka;
   if (kb !== null) post += "&_kb=" + kb;
   var xhttp = new XMLHttpRequest();
   xhttp.open("POST", '', true);
@@ -1507,6 +1516,11 @@ function showDetails(ka, kb) {
   }
   xhttp.send(post);
 }
+function showDetails2(node, ka, kb) {
+  var form = node.form;
+  var groupField = form['_groupField'].value;
+  showDetails(groupField, ka, kb);
+}
 function hideDetails() {
   document.getElementById('details').style.display = 'none';
 }
@@ -1613,7 +1627,7 @@ function toggleCheckSecond(check) {
 				'step' => V::get('step', '', $_POST),
 				'table' => $this->SOURCE['TABLE'],
 				'valueField' => $benford['conf']['valueField'],
-				'groupField' => $benford['conf']['groupField'],
+				'groupFields' => $benford['conf']['groupFields'],
 				'count' => $benford['conf']['count'],
 				'L_APPOITMENT_INFO' => V::get('L_APPOITMENT_INFO', '', $_POST),
 				'A_RECORD_CREATE_AUTHOR' => User::getName(),
@@ -1720,9 +1734,10 @@ function toggleCheckSecond(check) {
 					$this->benford_generate();
 					break;
 				case "getDetails":
+					$groupField = V::get('_groupField', null, $_POST);
 					$ka = V::get('_ka', null, $_POST, 'int');
 					$kb = V::get('_kb', null, $_POST, 'int');
-					echo $this->benford_getDetails($ka, $kb);
+					echo $this->benford_getDetails($groupField, $ka, $kb);
 					break;
 				default:
 					$this->benford_form(true);