partial #1472
This commit is contained in:
parent
577a972957
commit
374f6c6c00
@ -131,6 +131,11 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
|||||||
$chart = new Crunchbutton_Chart_Order();
|
$chart = new Crunchbutton_Chart_Order();
|
||||||
$this->renderColumn( $chart->repeatByActiveuserByWeek( true ), $chart->getGroupedCharts() );
|
$this->renderColumn( $chart->repeatByActiveuserByWeek( true ), $chart->getGroupedCharts() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'orders-per-restaurant-by-community':
|
||||||
|
$chart = new Crunchbutton_Chart_Order();
|
||||||
|
$this->renderPieCommunities( $chart->perRestaurantPerCommunity( true ), $chart->getGroupedCharts() );
|
||||||
|
break;
|
||||||
|
|
||||||
/* Churn */
|
/* Churn */
|
||||||
|
|
||||||
@ -211,6 +216,18 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderPieCommunities( $params, $groups ){
|
||||||
|
c::view()->display('charts/pie_communities', ['set' => [
|
||||||
|
'chartId' => $this->chartId,
|
||||||
|
'data' => $params[ 'data' ],
|
||||||
|
'title' => $this->title,
|
||||||
|
'number' => $this->number,
|
||||||
|
'unit' => $params[ 'unity' ],
|
||||||
|
'groups' => $groups,
|
||||||
|
'divId' => $this->divId
|
||||||
|
]]);
|
||||||
|
}
|
||||||
|
|
||||||
private function renderArea( $params, $groups ){
|
private function renderArea( $params, $groups ){
|
||||||
c::view()->display('charts/area', ['set' => [
|
c::view()->display('charts/area', ['set' => [
|
||||||
'chartId' => $this->chartId,
|
'chartId' => $this->chartId,
|
||||||
|
|||||||
@ -33,17 +33,14 @@ class Controller_home extends Crunchbutton_Controller_Account {
|
|||||||
c::view()->data = $data;
|
c::view()->data = $data;
|
||||||
|
|
||||||
$graphs = array(
|
$graphs = array(
|
||||||
|
|
||||||
'' => array(
|
'' => array(
|
||||||
|
// Groups
|
||||||
// Groups
|
array( 'divId' => 'chart-orders', 'title-group' => 'Orders', 'chart-url' => 'orders-per-week' ),
|
||||||
array( 'divId' => 'chart-orders', 'title-group' => 'Orders', 'chart-url' => 'orders-per-week' ),
|
array( 'divId' => 'chart-users', 'title-group' => 'Users', 'chart-url' => 'users-new-per-day' ),
|
||||||
array( 'divId' => 'chart-users', 'title-group' => 'Users', 'chart-url' => 'users-new-per-day' ),
|
array( 'divId' => 'chart-gross', 'title-group' => 'Gross Revenue', 'chart-url' => 'gross-revenue-per-week' ),
|
||||||
array( 'divId' => 'chart-gross', 'title-group' => 'Gross Revenue', 'chart-url' => 'gross-revenue-per-week' ),
|
array( 'divId' => 'chart-churn', 'title-group' => 'Churn Rate', 'chart-url' => 'churn-rate-per-week' ),
|
||||||
array( 'divId' => 'chart-churn', 'title-group' => 'Churn Rate', 'chart-url' => 'churn-rate-per-week' ),
|
array( 'divId' => 'chart-gift-cards', 'title-group' => 'Gift Cards', 'chart-url' => 'gift-cards-created-per-day' ),
|
||||||
array( 'divId' => 'chart-gift-cards', 'title-group' => 'Gift Cards', 'chart-url' => 'gift-cards-created-per-day' ),
|
)
|
||||||
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
c::view()->graphs = $graphs;
|
c::view()->graphs = $graphs;
|
||||||
|
|||||||
@ -132,6 +132,19 @@ class Crunchbutton_Chart extends Cana_Model {
|
|||||||
return sizeof( $months );
|
return sizeof( $months );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allCommunities(){
|
||||||
|
$query = "SELECT DISTINCT( r.community ) AS community FROM restaurant r WHERE r.community IS NOT NULL ORDER BY r.community ASC";
|
||||||
|
$results = c::db()->get( $query );
|
||||||
|
$communities = array();
|
||||||
|
foreach ( $results as $result ) {
|
||||||
|
if( !$result->community ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$communities[] = $result->community;
|
||||||
|
}
|
||||||
|
return $communities;
|
||||||
|
}
|
||||||
|
|
||||||
public function allDays(){
|
public function allDays(){
|
||||||
$query = "SELECT DISTINCT( DATE_FORMAT( o.date ,'%Y-%m-%d') ) day FROM `order` o WHERE o.date IS NOT NULL ORDER BY day ASC";
|
$query = "SELECT DISTINCT( DATE_FORMAT( o.date ,'%Y-%m-%d') ) day FROM `order` o WHERE o.date IS NOT NULL ORDER BY day ASC";
|
||||||
$results = c::db()->get( $query );
|
$results = c::db()->get( $query );
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class Crunchbutton_Chart_Order extends Crunchbutton_Chart {
|
|||||||
'orders-per-week-by-community' => 'Orders per Week by Community',
|
'orders-per-week-by-community' => 'Orders per Week by Community',
|
||||||
'orders-repeat-per-active-user' => 'Repeat Orders per Active User',
|
'orders-repeat-per-active-user' => 'Repeat Orders per Active User',
|
||||||
'orders-by-weekday-by-community' => 'Orders by Weekday by Community',
|
'orders-by-weekday-by-community' => 'Orders by Weekday by Community',
|
||||||
|
'orders-per-restaurant-by-community' => 'Orders per Restaurant by Community',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -98,7 +99,6 @@ class Crunchbutton_Chart_Order extends Crunchbutton_Chart {
|
|||||||
{$this->queryExcludeUsers}
|
{$this->queryExcludeUsers}
|
||||||
GROUP BY YEARWEEK(date), r.community
|
GROUP BY YEARWEEK(date), r.community
|
||||||
ORDER BY YEARWEEK(date) DESC";
|
ORDER BY YEARWEEK(date) DESC";
|
||||||
|
|
||||||
$parsedData = $this->parseDataWeeksGroup( $query, $this->description );
|
$parsedData = $this->parseDataWeeksGroup( $query, $this->description );
|
||||||
if( $render ){
|
if( $render ){
|
||||||
return array( 'data' => $parsedData, 'unit' => $this->unity );
|
return array( 'data' => $parsedData, 'unit' => $this->unity );
|
||||||
@ -106,6 +106,32 @@ class Crunchbutton_Chart_Order extends Crunchbutton_Chart {
|
|||||||
return $parsedData;
|
return $parsedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function perRestaurantPerCommunity( $render = false ){
|
||||||
|
|
||||||
|
$query = "SELECT
|
||||||
|
r.name AS Restaurant,
|
||||||
|
orders.orders AS Total,
|
||||||
|
r.community AS 'Group'
|
||||||
|
FROM
|
||||||
|
(SELECT count(*) AS orders,
|
||||||
|
o.id_restaurant
|
||||||
|
FROM `order` o
|
||||||
|
-- WHERE o.date BETWEEN CURDATE() - INTERVAL 60 DAY AND CURDATE()
|
||||||
|
GROUP BY o.id_restaurant) orders
|
||||||
|
INNER JOIN restaurant r ON r.id_restaurant = orders.id_restaurant";
|
||||||
|
|
||||||
|
$data = c::db()->get( $query );
|
||||||
|
$groups = [];
|
||||||
|
foreach( $data as $item ){
|
||||||
|
$groups[ $item->Group ][] = array( 'Restaurant' => $item->Restaurant, 'Orders' => $item->Total );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $render ){
|
||||||
|
return array( 'data' => $groups, 'unit' => $this->unity );
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
public function byUsersPerMonth( $render = false ){
|
public function byUsersPerMonth( $render = false ){
|
||||||
|
|
||||||
$query = "SELECT DATE_FORMAT( o.date ,'%Y-%m') AS Month,
|
$query = "SELECT DATE_FORMAT( o.date ,'%Y-%m') AS Month,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class Crunchbutton_Chart_Revenue extends Crunchbutton_Chart {
|
|||||||
'group1' => array(
|
'group1' => array(
|
||||||
'gross-revenue-per-week' => 'Gross Revenue per Week',
|
'gross-revenue-per-week' => 'Gross Revenue per Week',
|
||||||
'gross-revenue-per-month' => 'Gross Revenue per Month',
|
'gross-revenue-per-month' => 'Gross Revenue per Month',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class Crunchbutton_Chart_User extends Crunchbutton_Chart {
|
|||||||
'users-new-per-week-by-community' => 'New Users per Week by Community',
|
'users-new-per-week-by-community' => 'New Users per Week by Community',
|
||||||
'users-new-per-active-users-by-community' => 'New Users per Active Users By Community',
|
'users-new-per-active-users-by-community' => 'New Users per Active Users By Community',
|
||||||
'users-unique-per-week-by-community' => 'Unique Users per Week by Community',
|
'users-unique-per-week-by-community' => 'Unique Users per Week by Community',
|
||||||
'users-reclaimed-per-week' => 'Reclaimed Users per Week',
|
'users-reclaimed-per-week' => 'Reclaimed Users per Week'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,6 @@
|
|||||||
'ys' => array_values($ys)
|
'ys' => array_values($ys)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
@ -103,6 +102,8 @@
|
|||||||
<?php if( $hasResults ){ ?>
|
<?php if( $hasResults ){ ?>
|
||||||
<div id="chart-<?=$chartId?>" style="min-width: 100%; height:300px; margin: 0 auto"></div>
|
<div id="chart-<?=$chartId?>" style="min-width: 100%; height:300px; margin: 0 auto"></div>
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span3" id="week-<?=$chartId?>">
|
<div class="span3" id="week-<?=$chartId?>">
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
75
include/views/default/cockpit/charts/pie_communities.phtml
Normal file
75
include/views/default/cockpit/charts/pie_communities.phtml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<div class="row-fluid">
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
|
<h4 style="text-align:center;">Orders by Restaurant</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if( $groups ){ ?>
|
||||||
|
<span class="pull-right">
|
||||||
|
<select class="charts-select" id="select-<?=$chartId?>" data-divId="<?php echo $divId; ?>" onchange="loadSubChart( this.id )">
|
||||||
|
<?php foreach ( $groups as $key => $value ) {
|
||||||
|
$selected = ( $key == $chartId ) ? 'selected="selected"' : '';
|
||||||
|
?>
|
||||||
|
<option <?php echo $selected; ?> value="<?php echo $key; ?>"><?php echo $value; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?
|
||||||
|
$count = 1;
|
||||||
|
foreach( $data as $group => $restaurants ){
|
||||||
|
// $restaurants
|
||||||
|
$info = '';
|
||||||
|
foreach( $restaurants as $restaurant ){
|
||||||
|
$info .= '["' . $restaurant['Restaurant'] . '",' . $restaurant['Orders'] . '],';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="span12">
|
||||||
|
<h5 style="text-align:center;"><?php echo $group; ?></h5>
|
||||||
|
</div>
|
||||||
|
<div id="chart-<?=$chartId?><?php echo $count; ?>" style="min-width: 100%; height:300px; margin: 0 auto"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var data = <?=json_encode($jsData, JSON_NUMERIC_CHECK)?>;
|
||||||
|
$('#chart-<?=$chartId?><?php echo $count; ?>').highcharts({
|
||||||
|
chart: {
|
||||||
|
plotBackgroundColor: null,
|
||||||
|
plotBorderWidth: null,
|
||||||
|
plotShadow: false,
|
||||||
|
backgroundColor:'rgba(255, 255, 255, 0.1)'
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
text: ''
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
pointFormat: '{series.name}: <b>{point.y}</b> ({point.percentage:.1f}%)'
|
||||||
|
},
|
||||||
|
plotOptions: {
|
||||||
|
pie: {
|
||||||
|
allowPointSelect: true,
|
||||||
|
cursor: 'pointer',
|
||||||
|
dataLabels: {
|
||||||
|
enabled: true,
|
||||||
|
color: '#000000',
|
||||||
|
connectorColor: '#000000',
|
||||||
|
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
series: [{
|
||||||
|
type: 'pie',
|
||||||
|
name: 'Orders',
|
||||||
|
data: [<?php echo $info; ?>]
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -908,7 +908,6 @@ input:disabled {
|
|||||||
height: 450px;
|
height: 450px;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
#admin-dish-lightning-modal{
|
#admin-dish-lightning-modal{
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border: 1px solid #CCC;
|
border: 1px solid #CCC;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user