HTML :
Today's Sell
Current Week Sell
Current Month's Sell
Last Months Sell
ANGULAR JS:
$interval( function(){
$http.get(base_url + 'view/dashboard_counter_basic.php')
.then(function (response) {
console.log(response.data);
if (response.data.status === 'ok') {
//console.log(response.data.data.UserCounter.uCounter);
$scope.UserCounter=response.data.data.UserCounter.uCounter;
$scope.ProductCounter=response.data.data.ProductCounter.pCounter;
$scope.AdminCouter=response.data.data.AdminCouter.aCounter;
$scope.LogTime=response.data.data.LogTime;
$scope.today=response.data.data.today;
$scope.week=response.data.data.week;
$scope.curmonth=response.data.data.curmonth;
$scope.lastmonth=response.data.data.LastMonth;
/*console.log(JSON.stringify($scope.today));
console.log(JSON.stringify($scope.week));
console.log(JSON.stringify($scope.curmonth));
console.log(JSON.stringify($scope.lastmonth));*/
Highcharts.chart('todayData', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title:'',
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Sale',
colorByPoint: true,
data: $scope.today
}]
});
Highcharts.chart('weekData', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title:'',
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Sale',
colorByPoint: true,
data: $scope.week
}]
});
Highcharts.chart('curmonthData', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title:'',
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Sale',
colorByPoint: true,
data: $scope.curmonth
}]
});
Highcharts.chart('lastmonthData', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title:'',
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Sale',
colorByPoint: true,
data: $scope.lastonth
}]
});
}
});
var config = {
headers: {
'Content-Type': 'application/json; charset=UTF-8;'
}
}
$http.post(base_url + 'report/productSelling.php', datasell, config)
.then(function (response) {
console.log(response.data);
if (response.data.status === 'ok') {
//console.log(response.data.QtyWise);
$scope.priceWise=response.data.priceWise;
$scope.QtyWise=response.data.QtyWise;
}
});
},50000);
PHP SERVER DATA:
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
require_once "../config.php";
$UserQuery = "SELECT count(user_id) as uCounter FROM user where status=1";
$UserResult = $con->query($UserQuery);
$objUser = mysqli_fetch_assoc($UserResult);
$ProductQuery = "SELECT count(product_id) as pCounter FROM product where status=1";
$ProductResult = $con->query($ProductQuery);
$objProduct = mysqli_fetch_assoc($ProductResult);
$AdminQuery = "SELECT count(admin_id) as aCounter FROM admin where loggedin=1";
$AdminResult = $con->query($AdminQuery);
$objAdmin = mysqli_fetch_assoc($AdminResult);
$AdminDisplayQuery = "SELECT first_name,last_login,loggedin FROM admin where status=1";
$AdminDisplayResult = $con->query($AdminDisplayQuery);
while($row=mysqli_fetch_object($AdminDisplayResult)){
$adata[]=$row;
}
/*start counter*/
$todata=[];
$weekdata=[];
$cmdata=[];
$lmdata=[];
$todayQuery = "SELECT
IF(sle.telecaller_id=0, 'Online', rle.role_name) AS name
, COUNT(1) / t.cnt * 100 AS y
FROM sale sle
left join role rle on rle.role_id=sle.telecaller_id
CROSS JOIN (SELECT COUNT(1) AS cnt FROM sale where DATE(date_added) = '".DATE('Y-m-d')."') t
WHERE
sle.status=1 and DATE(sle.date_added) = '".DATE('Y-m-d')."'
GROUP
BY sle.telecaller_id";
$todayResult = $con->query($todayQuery);
while($torow=mysqli_fetch_object($todayResult)){
$todata[]=array("name"=>$torow->name,"y"=>(int)$torow->y);
}
$weekQuery = "SELECT
IF(sle.telecaller_id=0, 'Online', rle.role_name) AS name
, cast(COUNT(1) / t.cnt * 100 as unsigned) AS y
FROM sale sle
left join role rle on rle.role_id=sle.telecaller_id
CROSS JOIN (SELECT COUNT(1) AS cnt FROM sale where DATE(date_added) > (NOW() - INTERVAL 7 DAY)) t
WHERE
sle.status=1 and DATE(sle.date_added) > (NOW() - INTERVAL 7 DAY)
GROUP
BY sle.telecaller_id";
$weekResult = $con->query($weekQuery);
while($weekrow=mysqli_fetch_object($weekResult)){
$weekdata[]=array("name"=>$weekrow->name,"y"=>(int)$weekrow->y);
}
$cmQuery = "SELECT
IF(sle.telecaller_id=0, 'Online', rle.role_name) AS name
, cast(COUNT(1) / t.cnt * 100 as unsigned) AS y
FROM sale sle
left join role rle on rle.role_id=sle.telecaller_id
CROSS JOIN (SELECT COUNT(1) AS cnt FROM sale where MONTH(date_added) = MONTH(CURRENT_DATE())) t
WHERE
sle.status=1 and MONTH(sle.date_added) = MONTH(CURRENT_DATE())
GROUP
BY sle.telecaller_id";
$cmResult = $con->query($cmQuery);
while($cmrow=mysqli_fetch_object($cmResult)){
$cmdata[]=array("name"=>$cmrow->name,"y"=>(int)$cmrow->y);
}
$lmQuery = "SELECT
IF(sle.telecaller_id=0, 'Online', rle.role_name) AS name
, cast(COUNT(1) / t.cnt * 100 as unsigned) AS y
FROM sale sle
left join role rle on rle.role_id=sle.telecaller_id
CROSS JOIN (SELECT COUNT(1) AS cnt FROM sale where MONTH(date_added) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)) t
WHERE
sle.status=1 and MONTH(sle.date_added) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
GROUP
BY sle.telecaller_id
";
$lmResult = $con->query($lmQuery);
while($lmrow=mysqli_fetch_object($lmResult)){
$lmdata[]=array("name"=>$lmrow->name,"y"=>(int)$lmrow->y);
}
/*end counter*/
$out=array("status"=>"ok","data"=>array(
"UserCounter"=>$objUser,
"ProductCounter"=>$objProduct,
"AdminCouter"=>$objAdmin,
"LogTime"=>$adata,
"today"=>$todata,
"week"=>$weekdata,
"curmonth"=>$cmdata,
"LastMonth"=>$lmdata));
echo json_encode($out);
?>
No comments:
Post a Comment
Dharamart.blogspot.in