$query_result1= DB::select(DB::raw("SELECT SalesMen.team, SUM(amount) AS Sale,salesmen.teamcolour as Colour
FROM dbo.sales AS sales
INNER JOIN dbo.SalesMen AS SalesMen ON sales.salesman = SalesMen.id
left JOIN dbo.tbl_user_sexe ON dbo.tbl_user_sexe.s_exe = salesmen.id
cross join universal.dbo.tbl_user
WHERE salesmen.enabled = 'yes' AND salesmen.team != 'NULL'
GROUP BY salesmen.team, salesmen.teamcolour"));
$query_result2= DB::select(DB::raw("SELECT salesmen.name, DATENAME(month, sales.docdate) AS Month, SUM(amount) AS Sale,salesmen.teamcolour as Colour
FROM dbo.sales AS sales
INNER JOIN dbo.SalesMen AS SalesMen ON sales.salesman = SalesMen.id
left JOIN dbo.tbl_user_sexe ON dbo.tbl_user_sexe.s_exe = salesmen.id
cross join universal.dbo.tbl_user
WHERE salesmen.enabled = 'yes' AND salesmen.team != 'NULL' and salesmen.team like '%" . $team . "%'
GROUP BY salesmen.team, salesmen.name, DATENAME(month, sales.docdate),salesmen.teamcolour"));
$query_result3 = DB::select(DB::raw("SELECT salesmen.name, DATENAME(month, sales.docdate) AS Month, SUM(amount) AS Sale,salesmen.teamcolour as Colour
FROM dbo.sales AS sales
INNER JOIN dbo.SalesMen AS SalesMen ON sales.salesman = SalesMen.id
left JOIN dbo.tbl_user_sexe ON dbo.tbl_user_sexe.s_exe = salesmen.id
cross join universal.dbo.tbl_user
WHERE salesmen.enabled = 'yes' AND salesmen.team != 'NULL' and salesmen.name like '%" . $name . "%'
GROUP BY DATENAME(month, sales.docdate),salesmen.teamcolour, salesmen.name"));
DrillDown::create(array(
"name"=>"saleDrillDown",
"title"=>"Team Sale Report",
"levels"=>array(
array(
"title"=>"All Month",
"content"=>function($params,$scope)
{
ColumnChart::create(array(
"dataSource"=>$query_result1,
"columns"=>array(
"team"=>array(
"label"=>"Team",
"type"=>"string",
),
"Sale"=>array(
"label"=>"Sale Amount",
"type"=>"number",
)
),
"clientEvents"=>array(
"itemSelect"=>"function(params){
saleDrillDown.next({team:params.selectedRow[0]});
}",
)
));
}
),
array(
"title"=>"Sales Man Sale Report",
"content" => function ($params, $scope) {
$team = $params["team"];
ColumnChart::create(array(
"dataSource"=>$query_result2,
"columns"=>array(
"name"=>array(
"label"=>"Name",
"type"=>"string",
),
"Sale"=>array(
"label"=>"Sale Amount",
"type"=>"number",
)
),
"clientEvents"=>array(
"itemSelect"=>"function(params){
saleDrillDown.next({name:params.selectedRow[0]});
}",
)
));
}
),
array(
"title"=>"Sales man Month Report",
"content"=>function($params,$scope)
{
$name = $params["name"];
ColumnChart::create(array(
"dataSource"=> $query_result3,
"columns"=>array(
"Month"=>array(
"label"=>"Month",
"type"=>"string",
),
"Sale"=>array(
"label"=>"Sale Amount",
"type"=>"number",
)
),
));
}
)
),
));