updated version 1.0.3
This commit is contained in:
@@ -54,14 +54,37 @@ class DashboardController extends Controller {
|
||||
*/
|
||||
public function ChartData()
|
||||
{
|
||||
$ticketlist = DB::table('tickets')
|
||||
->select(DB::raw('MONTH(updated_at) as month'),
|
||||
DB::raw('count(*) as tickets'))
|
||||
->groupBy('month')
|
||||
->orderBy('month', 'asc')
|
||||
->get();
|
||||
|
||||
return $ticketlist;
|
||||
$date2 = strtotime(Date('Y-m-d'));
|
||||
$date3 = Date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
|
||||
|
||||
$return = "";
|
||||
$last = "";
|
||||
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
|
||||
$thisDate = date( 'Y-m-d', $i );
|
||||
|
||||
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
|
||||
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities',$value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return,',');
|
||||
|
||||
return '['.$last.']';
|
||||
|
||||
// $ticketlist = DB::table('tickets')
|
||||
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
|
||||
// DB::raw('count(*) as totaltickets'))
|
||||
// ->groupBy('month')
|
||||
// ->orderBy('month', 'asc')
|
||||
// ->get();
|
||||
|
||||
// return $ticketlist;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user