Exemplo n.º 1
0
 /** Method that fetches entrants from database for JQuery Data Table
  * @param string $column Column name of the data to be fetched
  * @param string $condition Additional condition e.g category_id > 9
  * @param string $sort column name to be used as sort parameter
  * @return JSON JSON encoded entrant details
  */
 public function fetchForJQDT($draw, $totalData, $totalFiltered, $customSql = "", $column = "*", $condition = "", $sort = "id")
 {
     $sql = "SELECT {$column} FROM " . self::$tableName . " ORDER BY {$sort}";
     if (!empty($condition)) {
         $sql = "SELECT {$column} FROM " . self::$tableName . " WHERE {$condition} ORDER BY {$sort}";
     }
     if ($customSql != "") {
         $sql = $customSql;
     }
     $data = self::$dbObj->fetchAssoc($sql);
     $result = array();
     if (count($data) > 0) {
         foreach ($data as $r) {
             $actionButtons = '<div style="white-space:nowrap"> <button data-id="' . $r['id'] . '" data-email="' . $r['email'] . '" class="btn btn-danger btn-sm delete-entrant" title="Delete"><i class="btn-icon-only icon-trash"> </i></button> </div>';
             //'<button data-email="'.$r['email'].'" data-id="'.$r['id'].'" class="btn btn-success btn-sm message-entrant"  title="Send Message"><i class="btn-icon-only icon-envelope"> </i></button> ';
             $multiActionBox = '<input type="checkbox" class="multi-action-box" data-id="' . $r['id'] . '" />';
             $result[] = array(utf8_encode($multiActionBox), utf8_encode($actionButtons), $r['id'], utf8_encode(Contest::getName(self::$dbObj, $r['contest'])), utf8_encode($r['email']), utf8_encode(str_replace(",", ", ", $r['friends'])), utf8_encode($r['names']), utf8_encode($r['time_entered']), utf8_encode($r['point']));
         }
         $json = array("status" => 1, "draw" => intval($draw), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => $result);
     } else {
         $json = array("status" => 2, "msg" => "Necessary parameters not set. Or empty result. " . mysqli_error(self::$dbObj->connection), "draw" => intval($draw), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => false);
     }
     self::$dbObj->close();
     header('Content-type: application/json');
     return json_encode($json);
 }