|
|
@@ -1293,12 +1293,13 @@ function validateCompany(source) {
|
|
|
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 (!($valueField = $benford['conf']['valueField'])) throw new Exception("Nieznany błąd wewnętrzny #6");
|
|
|
+ if ($a === null) throw new Exception("Nieznany błąd wewnętrzny #7");
|
|
|
if ($b === null) {
|
|
|
- if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #7");
|
|
|
+ if (!isset($benford['firstStep'][$a]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #8");
|
|
|
$keys = $benford['firstStep'][$a]['keys'];
|
|
|
} else {
|
|
|
- if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #8");
|
|
|
+ if (!isset($benford['secondStep'][$a][$b]['keys'])) throw new Exception("Nieznany błąd wewnętrzny #9");
|
|
|
$keys = $benford['secondStep'][$a][$b]['keys'];
|
|
|
}
|
|
|
|
|
|
@@ -1307,7 +1308,7 @@ function validateCompany(source) {
|
|
|
foreach (array_chunk($keys, 100) as $ids) {
|
|
|
DB::getPDO()->query("insert into `{$tempTable}` values (" . implode('),(', $ids) . ")");
|
|
|
}
|
|
|
- $query = "select `table`.`{$groupField}` as `field`, count(*) as `count` from `{$this->SOURCE['TABLE']}` `table` join `{$tempTable}` `temp` on `table`.`ID` = `temp`.`ID` where coalesce(`table`.`{$groupField}`,'') != '' group by `table`.`{$groupField}` having `count` > 1 order by `count` desc limit 10";
|
|
|
+ $query = "select `table`.`{$groupField}` as `field`, count(*) as `count`, sum(`table`.`{$valueField}`) as `sum` from `{$this->SOURCE['TABLE']}` `table` join `{$tempTable}` `temp` on `table`.`ID` = `temp`.`ID` where coalesce(`table`.`{$groupField}`,'') != '' group by `table`.`{$groupField}` having `count` > 1 order by `count` desc limit 10";
|
|
|
try {
|
|
|
$result = DB::getPDO()->fetchAll($query);
|
|
|
} catch (Exception $e) {
|
|
|
@@ -1321,9 +1322,9 @@ function validateCompany(source) {
|
|
|
$showDetails .= "</select></form></br>";
|
|
|
|
|
|
if ($result) {
|
|
|
- $showDetails .= "<table name=\"3NWK\" 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 .= "<table name=\"NWK3\" 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><td>Suma kwot</td></tr></thead><tbody>";
|
|
|
$showDetails .= implode('', array_map(function($v) use ($keys) {
|
|
|
- return "<tr><td>{$v['field']}</td><td>{$v['count']}</td><td>" . number_format(round($v['count'] / count($keys) * 100, 3), 3, ',', '') . "</td></tr>";
|
|
|
+ return "<tr><td>{$v['field']}</td><td>{$v['count']}</td><td>" . number_format(round($v['count'] / count($keys) * 100, 3), 3, ',', '') . '</td><td style="text-align: right;">' . number_format(round($v['sum'], 2), 2, ',', '.') . '</td></tr>';
|
|
|
}, $result));
|
|
|
$showDetails .= "</tbody></table>";
|
|
|
} else {
|