Example #1
0
 /**
  * Creates the table
  *     
  * @param  Tableman $ref
  * @param  Config   $conf
  * @config config, headers, extra_classes
  * @usage  https://github.com/mechanicious/tableman/wiki/Bs3Table-Extension-Usage
  * @return string
  */
 public function make(Tableman &$ref, Config $conf)
 {
     $items = $ref->getColumns();
     $columnNames = $ref->getColumnHeaders();
     $rows = $ref->getRows();
     $table = new BootstrapTable();
     $table->setConfig($conf->get('config'));
     $table->setHeader($conf->get('header'));
     $table->setTableExtraClasses($conf->get('extra_classes'));
     $limit = $conf->get('limit');
     array_walk($rows, function ($row, $rowIndex) use(&$table, &$columnNames, $limit) {
         if (!is_null($limit) && $rowIndex > $limit) {
             return;
         }
         // Flatten I mean from boundary: array('columnName' => 'rowData'), to: array('rowData').
         foreach ($columnNames as $columnName) {
             $flattenRows = array();
             foreach ($row as $columnHeader => $cell) {
                 $mockedRow = array();
                 if (isset($row[$columnName])) {
                     // If this is false then data got somehow mixed up
                     $mockedRow[] = array($row[$columnName]);
                 }
             }
             $flattenRows[] = $row;
         }
         $table->addRows(array_flatten($flattenRows));
     });
     // __toString do the work!
     return (string) $table;
 }
Example #2
0
<h3>Lista ordini</h3>
{{-- messaggi vari --}}
<?php 
$message = Session::get('message');
?>
@if( isset($message) )
<div class="alert alert-success">{{$message}}</div>
@endif
@if($errors && ! $errors->isEmpty() )
@foreach($errors->all() as $error)
<div class="alert alert-danger">{{$error}}</div>
@endforeach
@endif
{{-- Lists orders --}}
<ul class="list-group">
@if(! empty($orders))
<?php 
$table = new BootstrapTable();
$table->setConfig(["table-striped" => true]);
$table->setHeader(["Utente", "Data ordine", "Importo totale", ""]);
foreach ($orders as $order) {
    $table->addRows([$order->author_email, $order->date, $order->total_price, link_to_action('Palmabit\\Catalog\\Controllers\\OrderController@show', 'dettaglio', ['id' => $order->id])]);
}
echo $table;
echo $orders->getLinks();
?>
    @else
    <h5>Non ho trovato ordini.</h5>
    @endif
</ul>
@stop