'{$first_month_day}' AND o.data_fechamento <= '{$now}' {$qry_filter_clients} {$qry_filter_areas} GROUP BY tr.rate ORDER BY quantidade DESC "; $sql = $conn->query($sql); $data = array(); if ($sql->rowCount()) { foreach ($sql->fetchAll(PDO::FETCH_ASSOC) as $row) { // $data[] = $row; $data[] = [ 'rate' => $rating_labels[$row['rate']], 'quantidade' => $row['quantidade'], 'classe' => $rating_classes[$row['rate']] ]; } } else { $data[] = array( "rate" => TRANS('NO_RECORDS_FOUND'), "quantidade" => 0 ); } $data[]['chart_title'] = TRANS('TICKETS_BY_RATE_CURR_MONTH', '', 1); // IMPORTANT, output to json echo json_encode($data); ?>