|
|
@@ -84,6 +84,17 @@ class DBG {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function tableInFrame($label, $table, $className, $functionName, $lineNumber) {
|
|
|
+?>
|
|
|
+<div class="container" style="margin-top:10px; margin-bottom:10px; background:#ddd">
|
|
|
+ <h3 style="margin:10px 0"><?php echo "{$label} <small>({$className}::{$functionName}:{$lineNumber}):</small>"; ?></h3>
|
|
|
+ <div style="max-height:300px;overflow:scroll;border:1px solid #ddd; background:#fff">
|
|
|
+ <?php self::table($label, $table, $className, $functionName, $lineNumber); ?>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+<?php
|
|
|
+ }
|
|
|
+
|
|
|
public static function table($label, $rows, $className, $functionName, $lineNumber) {
|
|
|
$params = array();
|
|
|
$params['caption'] = "{$label} ({$className}::{$functionName}:{$lineNumber}):";
|
|
|
@@ -91,6 +102,99 @@ class DBG {
|
|
|
UI::table($params);
|
|
|
}
|
|
|
|
|
|
+ public static function diffTable($label, $table, $params = array(), $className, $functionName, $lineNumber) {
|
|
|
+ $cols = array();
|
|
|
+ if (is_array($table) && !empty($table)) {
|
|
|
+ $firstRow = array();
|
|
|
+ foreach ($table as $row) {
|
|
|
+ $firstRow = $row;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (is_array($firstRow)) {
|
|
|
+ $cols = array_keys($firstRow);
|
|
|
+ }
|
|
|
+ else if (is_object($firstRow)) {
|
|
|
+ $cols = array_keys((array)$firstRow);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;// bad table item type
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $diffPrefix = V::get('diff_prefix', 'diff_', $params);
|
|
|
+ $diffTblOnePrefix = V::get('diff_tbl_one', '', $params);
|
|
|
+ $diffTblTwoPrefix = V::get('diff_tbl_two', '', $params);
|
|
|
+ $diffColsSplit = array();
|
|
|
+ {
|
|
|
+ $diffPrefixLen = strlen($diffPrefix);
|
|
|
+ foreach ($cols as $colName) {
|
|
|
+ if ($diffPrefix == substr($colName, 0, $diffPrefixLen)) {
|
|
|
+ $diffColsSplit[substr($colName, $diffPrefixLen)] = array();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //self::_(true, true, "diffColsSplit.1", $diffColsSplit, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ foreach ($cols as $colName) {
|
|
|
+ $exp = explode("_", $colName, 2);
|
|
|
+ if (2 != count($exp)) continue;
|
|
|
+ if (array_key_exists($exp[1], $diffColsSplit)) {
|
|
|
+ $prefix = "{$exp[0]}_";
|
|
|
+ $diffColsSplit[$exp[1]][] = $prefix;
|
|
|
+ if ($prefix != $diffPrefix) {
|
|
|
+ if (null == $diffTblOnePrefix) $diffTblOnePrefix = $prefix;
|
|
|
+ else if (null == $diffTblTwoPrefix) $diffTblTwoPrefix = $prefix;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //elf::_(true, true, "diffColsSplit.2", $diffColsSplit, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ if (null == $diffTblOnePrefix && null == $diffTblTwoPrefix) echo "Error prefix for tables not set!";
|
|
|
+
|
|
|
+ $notDiffCols = array();
|
|
|
+ foreach ($cols as $colName) {
|
|
|
+ if ("{$diffPrefix}" != substr($colName, 0, $diffPrefixLen)
|
|
|
+ && "{$diffTblOnePrefix}" != substr($colName, 0, strlen($diffTblOnePrefix))
|
|
|
+ && "{$diffTblTwoPrefix}" != substr($colName, 0, strlen($diffTblTwoPrefix))
|
|
|
+ )
|
|
|
+ $notDiffCols[] = $colName;
|
|
|
+ }
|
|
|
+ //self::_(true, true, "notDiffCols", $notDiffCols, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ }
|
|
|
+?>
|
|
|
+<table class="table table-bordered table-hover">
|
|
|
+ <caption><?php echo "{$label} ({$className}::{$functionName}:{$lineNumber}):"; ?></caption>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th style="padding:2px;">Lp.</th>
|
|
|
+ <?php foreach ($notDiffCols as $colName) : ?>
|
|
|
+ <th style="padding:2px;"><?php echo $colName; ?></th>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ <?php foreach ($diffColsSplit as $colName => $prefixes) : ?>
|
|
|
+ <th style="padding:2px;"><?php echo $colName; ?></th>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <?php $i = 0; foreach ($table as $row) : $i++; ?>
|
|
|
+ <tr>
|
|
|
+ <td style="padding:2px;"><?php echo $i; ?></td>
|
|
|
+ <?php foreach ($notDiffCols as $colName) : ?>
|
|
|
+ <td style="padding:2px;"><?php echo V::get($colName, '', $row); ?></td>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ <?php foreach ($diffColsSplit as $colName => $prefixes) : ?>
|
|
|
+ <?php $isDiff = ('1' == V::get("{$diffPrefix}{$colName}", '', $row)); ?>
|
|
|
+ <?php $stl = ($isDiff)? 'border:2px solid #F2DEDE;color:#a94442;' : 'border:2px solid #DFF0D8;color:#3c763d;'; ?>
|
|
|
+ <td style="padding:2px;<?php echo $stl; ?>;font-family:monospace;white-space:nowrap;">
|
|
|
+ <span style="color:#666"><?php echo str_pad($diffTblOnePrefix, 4, ".", STR_PAD_LEFT); ?>: </span>"<?php echo V::get("{$diffTblOnePrefix}{$colName}", '', $row); ?>"
|
|
|
+ <div style="border-top:1px solid #fff">
|
|
|
+ <span style="color:#666"><?php echo str_pad($diffTblTwoPrefix, 4, ".", STR_PAD_LEFT); ?>: </span>"<?php echo V::get("{$diffTblTwoPrefix}{$colName}", '', $row); ?>"
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </tr>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </tbody>
|
|
|
+</table>
|
|
|
+<?php
|
|
|
+ }
|
|
|
+
|
|
|
public static function nicePrint($variable, $varName) {
|
|
|
$col = ['green'=>'#96c178', 'red'=>'#de6b74', 'blue'=>'#55b5c1', 'bg-dark'=>'#282c34', 'white'=>'#abb2bf', 'orange'=>'#d19a66', 'violet'=>'#c476db'];
|
|
|
$cnt = '';
|