|
|
@@ -1108,13 +1108,14 @@ function validateCompany(source) {
|
|
|
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 (!($groupField = V::get('_benfordGroupField', '', $_GET))) throw new Exception("Brak konfiguracji kolumny grupującej");
|
|
|
- if ($a === null) throw new Exception("Nieznany błąd wewnętrzny #3");
|
|
|
+ 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 ($b === null) {
|
|
|
- if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #4");
|
|
|
+ if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #6");
|
|
|
$keys = $benford['firstStep'][$a]['keys'];
|
|
|
} else {
|
|
|
- if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #5");
|
|
|
+ if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #7");
|
|
|
$keys = $benford['secondStep'][$a][$b]['keys'];
|
|
|
}
|
|
|
|
|
|
@@ -1149,6 +1150,7 @@ function validateCompany(source) {
|
|
|
|
|
|
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 (!($namespace = V::get('_fromNamespace', '', $_GET))) throw new Exception("Błąd formularza");
|
|
|
|
|
|
Lib::loadClass('FeatureAttrSelected');
|
|
|
@@ -1168,6 +1170,11 @@ function validateCompany(source) {
|
|
|
try {
|
|
|
$benfordObj = new Benford($values);
|
|
|
$benford = $benfordObj->getAllResult();
|
|
|
+ $benford['conf'] = [
|
|
|
+ 'count' => count($values),
|
|
|
+ 'valueField' => $valueField,
|
|
|
+ 'groupField' => $groupField,
|
|
|
+ ];
|
|
|
$_SESSION['benford'][$this->SOURCE['TABLE']] = ['data' => gzcompress(serialize($benford))];
|
|
|
} catch (Exception $e) {
|
|
|
die($e->getMessage());
|
|
|
@@ -1175,7 +1182,6 @@ function validateCompany(source) {
|
|
|
?>
|
|
|
<div class="container" style="margin-top:20px">
|
|
|
<form method="post">
|
|
|
- <input type="hidden" name="count" value="<?=count($values)?>">
|
|
|
<legend>
|
|
|
Analiza rozkładu Benford'a
|
|
|
<span class="pull-right">Tabela: <?=$this->SOURCE['TABLE']?></span>
|
|
|
@@ -1248,7 +1254,7 @@ function validateCompany(source) {
|
|
|
<td class="step1-<?=$va['correct'] ? 'green' : 'red'?>">I</td>
|
|
|
<td style="text-align:right" class="step1-<?=$va['correct'] ? 'green' : 'red'?>"><?=$va['count']?></td>
|
|
|
<td style="text-align:right" class="step1-<?=$va['correct'] ? 'green' : 'red'?>"><?=$number_format(round($va['value'] * 100, 3))?></td>
|
|
|
- <td style="text-align:right" class="step1-<?=$va['correct'] ? 'green' : 'red'?>"><?=$number_format(round(Benford::benford($ka) * 100, 3))?></td>
|
|
|
+ <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 . ', 0)"><span class="glyphicon glyphicon-search"></span>'?></td>
|
|
|
@@ -1270,7 +1276,7 @@ function validateCompany(source) {
|
|
|
<td class="step2-<?=$vb['correct'] ? 'green' : 'red'?>">II</td>
|
|
|
<td style="text-align:right" class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$vb['count']?></td>
|
|
|
<td style="text-align:right" class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$number_format(round($vb['value'] * 100, 3))?></td>
|
|
|
- <td style="text-align:right" class="step2-<?=$vb['correct'] ? 'green' : 'red'?>"><?=$number_format(round(Benford::benford($ka * 10 + $kb) * 100, 3))?></td>
|
|
|
+ <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>
|
|
|
@@ -1301,7 +1307,7 @@ function validateCompany(source) {
|
|
|
td {font-size: 12px;}
|
|
|
#benford ::selection {background: transparent;}
|
|
|
#details {display:none; position: fixed; left: 0; top: 0; width: 100%; height: 100%; text-align: center; z-index: 1000; background-color: rgba(0,0,0,0.5);}
|
|
|
-#details div {width: 500px; height: auto; margin: 100px auto; background: #fff; padding: 10px; text-align: center; overflow: hidden;}
|
|
|
+#details div {width: 500px; height: auto; margin: 100px auto; background: #fff; padding: 10px; text-align: center; overflow: hidden; border-radius: 10px; box-shadow: 10px 10px rgba(0,0,0,0.25);}
|
|
|
-->
|
|
|
</style>
|
|
|
<script language="JavaScript">
|
|
|
@@ -1428,7 +1434,13 @@ function toggleCheckSecond(check) {
|
|
|
'L_APPOITMENT_INFO' => V::get('L_APPOITMENT_INFO', '', $_POST),
|
|
|
'step' => V::get('step', '', $_POST),
|
|
|
'table' => $this->SOURCE['TABLE'],
|
|
|
- 'count' => V::get('count', '', $_POST),
|
|
|
+ 'valueField' => $benford['conf']['valueField'],
|
|
|
+ 'groupField' => $benford['conf']['groupField'],
|
|
|
+ 'count' => $benford['conf']['count'],
|
|
|
+ ];
|
|
|
+ $checked = [
|
|
|
+ 'firstStep' => V::get('checkFirstStep', [], $_POST),
|
|
|
+ 'secondStep' => V::get('checkSecondStep', [], $_POST),
|
|
|
];
|
|
|
|
|
|
$firstStep = [];
|
|
|
@@ -1438,8 +1450,10 @@ function toggleCheckSecond(check) {
|
|
|
$_firstStep = [
|
|
|
'@attributes' => ['leadingNumber' => $ka],
|
|
|
'count' => $va['count'],
|
|
|
- 'value' => $va['value'],
|
|
|
- 'correct' => $va['correct'] ? 'true' : 'false'
|
|
|
+ 'value' => (double) round($va['value'], 5),
|
|
|
+ 'norm' => (double) round($va['norm'], 5),
|
|
|
+ 'deviation' => (double) round($va['value'] / $va['norm'] - 1, 5),
|
|
|
+ 'correct' => $va['correct'] ? 'true' : 'false',
|
|
|
];
|
|
|
if ($array[$namespace]['step'] == 'second' && (!$va['correct'])) {
|
|
|
$secondStep = [];
|
|
|
@@ -1449,10 +1463,12 @@ function toggleCheckSecond(check) {
|
|
|
$_secondStep = [
|
|
|
'@attributes' => ['leadingNumber' => $ka.$kb],
|
|
|
'count' => $vb['count'],
|
|
|
- 'value' => $vb['value'],
|
|
|
- 'correct' => $vb['correct'] ? 'true' : 'false'
|
|
|
+ 'value' => (double) round($vb['value'], 5),
|
|
|
+ 'norm' => (double) round($vb['norm'], 5),
|
|
|
+ 'deviation' => (double) round($vb['value'] / $vb['norm'] - 1, 5),
|
|
|
+ 'correct' => $vb['correct'] ? 'true' : 'false',
|
|
|
];
|
|
|
- if (!$vb['correct']) {
|
|
|
+ if ((!$vb['correct']) && in_array($ka.$kb, $checked['secondStep'])) {
|
|
|
$objects = [];
|
|
|
foreach ($benford['secondStep'][$ka][$kb]['keys'] as $id) {
|
|
|
$object = DB::getPDO()->fetchFirst("select * from `{$this->SOURCE['TABLE']}` where `ID` = " . DB::getPDO()->quote($id));
|
|
|
@@ -1464,7 +1480,7 @@ function toggleCheckSecond(check) {
|
|
|
$secondStep[] = $_secondStep;
|
|
|
}
|
|
|
$_firstStep['secondStep'] = $secondStep;
|
|
|
- } elseif (!$va['correct']) {
|
|
|
+ } elseif ((!$va['correct']) && in_array($ka, $checked['firstStep'])) {
|
|
|
$objects = [];
|
|
|
foreach ($benford['firstStep'][$ka]['keys'] as $id) {
|
|
|
$object = DB::getPDO()->fetchFirst("select * from `{$this->SOURCE['TABLE']}` where `ID` = " . DB::getPDO()->quote($id));
|