|
@@ -96,4 +96,57 @@ class UI {
|
|
|
<?php
|
|
<?php
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * $params - Array
|
|
|
|
|
+ * $params['caption'] (optional) -> <caption>...</caption>
|
|
|
|
|
+ * $params['cols'] (optional) -> cols, if not set read from first row
|
|
|
|
|
+ * $params['rows'] -> rows, if not set - empty table
|
|
|
|
|
+ * $params['rows'] -> rows, if not set - empty table
|
|
|
|
|
+ * $params['disable_lp'] -> disable lp. col
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function table($params) {
|
|
|
|
|
+ $cols = V::get('cols', array(), $params);
|
|
|
|
|
+ $rows = V::get('rows', array(), $params);
|
|
|
|
|
+ $caption = V::get('caption', '', $params);
|
|
|
|
|
+ $showLp = (!V::get('disable_lp', false, $params));
|
|
|
|
|
+ if (empty($cols) && !empty($rows)) {
|
|
|
|
|
+ $firstRow = array();
|
|
|
|
|
+ foreach ($rows as $row) {
|
|
|
|
|
+ $firstRow = $row;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ $cols = array_keys((array)$firstRow);
|
|
|
|
|
+ }
|
|
|
|
|
+ // if (empty($cols)) return;
|
|
|
|
|
+?>
|
|
|
|
|
+ <table class="table table-bordered table-hover">
|
|
|
|
|
+ <?php if ($caption) : ?>
|
|
|
|
|
+ <caption><?php echo $caption; ?></caption>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <?php if ($showLp) : ?>
|
|
|
|
|
+ <th style="padding:2px">Lp.</th>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+ <?php foreach ($cols as $colName) : ?>
|
|
|
|
|
+ <th style="padding:2px"><?php echo $colName; ?></th>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <?php $i = 0; foreach ($rows as $row) : $i++; ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <?php if ($showLp) : ?>
|
|
|
|
|
+ <td style="padding:2px; color:#ccc"><?php echo $i; ?></td>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+ <?php foreach ($cols as $colName) : ?>
|
|
|
|
|
+ <td style="padding:2px"><?php echo V::get($colName, '', $row); ?></td>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+<?php
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|