Esempio n. 1
0
 static function data_output($columns, $data, $db, $home)
 {
     $out = array();
     for ($i = 0, $ien = count($data); $i < $ien; $i++) {
         $row = array();
         for ($j = 0, $jen = count($columns); $j < $jen; $j++) {
             $column = $columns[$j];
             // Is there a formatter?
             if (isset($column['formatter'])) {
                 $row[$column['dt']] = $column['formatter']($data[$i][$column['db']], $data[$i]);
             } else {
                 //var_dump($columns[$j]);
                 /// Buat Format Numeric
                 if (is_numeric($data[$i][$columns[$j]['db']])) {
                     $row[$column['dt']] = number_format($data[$i][$columns[$j]['db']]);
                 } else {
                     $row[$column['dt']] = $data[$i][$columns[$j]['db']];
                 }
                 ///////////////// Sebagai Pengganti Join table ( Karena join table terlalu Mainstrum ) ////////////
                 if ($columns[$j]['join']['table'] != NULL) {
                     $value = $data[$i][$columns[$j]['db']];
                     $row[$column['dt']] = self::select($db, $columns[$j]['join']['table'], $columns[$j]['join']['field'], $data[$i][$columns[$j]['db']]);
                 }
                 /////////////////////// End Join Table
                 if ($columns[$j]['tipe'] == 'date') {
                     $plg = new plugin();
                     $row[$column['dt']] = $plg->tanggal2($data[$i][$columns[$j]['db']]);
                 }
                 if ($columns[$j]['tipe'] == 'file') {
                     $row[$column['dt']] = "<a href='" . $home . $data[$i][$columns[$j]['db']] . "' target='_blank'>Download</a>";
                 }
                 if ($columns[$j]['tipe'] == 'bool') {
                     if ($data[$i][$columns[$j]['db']] == 0) {
                         $row[$column['dt']] = "<i class='fa fa-times'></i> Salah";
                     } else {
                         $row[$column['dt']] = "<i class='fa fa-check'></i> Benar";
                     }
                 }
             }
         }
         $out[] = $row;
     }
     return $out;
 }