partial #1540
This commit is contained in:
parent
496137ee36
commit
411101ca68
57
db/migrate/000126_chart.sql
Normal file
57
db/migrate/000126_chart.sql
Normal file
@ -0,0 +1,57 @@
|
||||
CREATE TABLE `chart` (
|
||||
`id_chart` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`permalink` varchar(255) DEFAULT NULL,
|
||||
`description` text,
|
||||
PRIMARY KEY (`id_chart`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
/* INSERT THE CHARTS */
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 1, 'churn-rate-per-active-user-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 2, 'churn-rate-per-active-user-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 3, 'churn-rate-per-active-user-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 4, 'churn-rate-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 5, 'churn-rate-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 6, 'churn-rate-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 7, 'gift-cards-created-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 8, 'gift-cards-created-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 9, 'gift-cards-created-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 10, 'gift-cards-redeemed-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 11, 'gift-cards-redeemed-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 12, 'gift-cards-redeemed-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 13, 'gross-revenue-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 14, 'gross-revenue-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 15, 'gross-revenue-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 16, 'orders-by-weekday-by-community', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 17, 'orders-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 18, 'orders-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 19, 'orders-per-restaurant-by-community', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 20, 'orders-per-user-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 21, 'orders-per-user-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 22, 'orders-per-user-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 23, 'orders-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 24, 'orders-repeat-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 25, 'orders-repeat-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 26, 'orders-repeat-per-active-user-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 27, 'orders-repeat-per-active-user-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 28, 'orders-repeat-per-active-user-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 29, 'orders-repeat-vs-news-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 30, 'orders-repeat-vs-news-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 31, 'orders-repeat-vs-news-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 32, 'orders-repeat-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 33, 'orders-track-frequece', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 34, 'users-active-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 35, 'users-active-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 36, 'users-active-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 37, 'users-new-per-active-users-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 38, 'users-new-per-active-users-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 39, 'users-new-per-active-users-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 40, 'users-new-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 41, 'users-new-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 42, 'users-new-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 43, 'users-reclaimed-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 44, 'users-reclaimed-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 45, 'users-reclaimed-per-week', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 46, 'users-track-frequece', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 47, 'users-unique-per-day', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 48, 'users-unique-per-month', '');
|
||||
INSERT INTO `chart` (`id_chart`, `permalink`, `description`) VALUES( 49, 'users-unique-per-week', '');
|
||||
@ -33,18 +33,20 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
||||
$this->chart->processInterval( $info[ 'chart' ][ 'interval' ] );
|
||||
$chart->processInterval( $info[ 'chart' ][ 'interval' ] );
|
||||
|
||||
$description = $this->chart->getChartDescription( $this->chartId );
|
||||
|
||||
switch ( $type ) {
|
||||
case 'column':
|
||||
$params = array_merge( $chart->$method( true ), $info );
|
||||
$this->renderColumn( $params, $chart->getGroupedCharts( $info ) );
|
||||
$this->renderColumn( $params, $chart->getGroupedCharts( $info ), $description );
|
||||
break;
|
||||
case 'area':
|
||||
$params = array_merge( $chart->$method( true ), $info );
|
||||
$this->renderArea( $params, $chart->getGroupedCharts( $info ) );
|
||||
$this->renderArea( $params, $chart->getGroupedCharts( $info ), $description );
|
||||
break;
|
||||
case 'pie_communities':
|
||||
$params = array_merge( $chart->$method( true ), $info );
|
||||
$this->renderPieCommunities( $params, $chart->getGroupedCharts( $info ) );
|
||||
$this->renderPieCommunities( $params, $chart->getGroupedCharts( $info ), $description );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -92,11 +94,9 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
||||
$info = $chart->getChartInfo( $this->chartId );
|
||||
if( $info ){ $this->process( $info, $chart ); exit; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function renderPieCommunities( $params, $groups ){
|
||||
private function renderPieCommunities( $params, $groups, $description ){
|
||||
c::view()->display('charts/pie_communities', ['set' => [
|
||||
'chartId' => $this->chartId,
|
||||
'data' => $params[ 'data' ],
|
||||
@ -104,11 +104,12 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
||||
'number' => $this->number,
|
||||
'unit' => $params[ 'unity' ],
|
||||
'groups' => $groups,
|
||||
'divId' => $this->divId
|
||||
'divId' => $this->divId,
|
||||
'description' => $description
|
||||
]]);
|
||||
}
|
||||
|
||||
private function renderArea( $params, $groups ){
|
||||
private function renderArea( $params, $groups, $description ){
|
||||
|
||||
$title = $params[ 'title' ] . ' : ' . $groups[ $this->chartId ][ 'title' ];
|
||||
|
||||
@ -135,11 +136,12 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
||||
'info' => $params,
|
||||
'hideGroups' => $params[ 'hideGroups' ],
|
||||
'hideSlider' => $params[ 'hideSlider' ],
|
||||
'divId' => $this->divId
|
||||
'divId' => $this->divId,
|
||||
'description' => $description
|
||||
]]);
|
||||
}
|
||||
|
||||
private function renderColumn( $params, $groups ){
|
||||
private function renderColumn( $params, $groups, $description ){
|
||||
|
||||
$title = $params[ 'title' ] . ' : ' . $groups[ $this->chartId ][ 'title' ];
|
||||
|
||||
@ -164,7 +166,8 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
|
||||
'title' => $title,
|
||||
'groups' => $groups,
|
||||
'info' => $params,
|
||||
'divId' => $this->divId
|
||||
'divId' => $this->divId,
|
||||
'description' => $description
|
||||
]]);
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,17 @@ class Crunchbutton_Chart extends Cana_Model {
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function getAllCharts(){
|
||||
$charts = [];
|
||||
foreach( $this->groups as $id_group => $group ){
|
||||
$_charts = $group[ 'charts' ];
|
||||
foreach ( $_charts as $id_chart => $chart ) {
|
||||
$charts[] = $id_chart;
|
||||
}
|
||||
}
|
||||
return $charts;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
||||
$this->chartId = c::getPagePiece( 2 );
|
||||
@ -174,6 +185,12 @@ class Crunchbutton_Chart extends Cana_Model {
|
||||
}
|
||||
}
|
||||
|
||||
public function getChartDescription( $permalink ){
|
||||
$query = "SELECT * FROM chart WHERE permalink = '{$permalink}'";
|
||||
$result = c::db()->get( $query );
|
||||
return $result->_items[0]->description;
|
||||
}
|
||||
|
||||
public function weeks(){
|
||||
$query = "SELECT COUNT( DISTINCT( YEARWEEK( date ) ) ) AS weeks FROM `order`";
|
||||
$result = c::db()->get( $query );
|
||||
|
||||
@ -93,7 +93,9 @@
|
||||
|
||||
<?php if( $hasResults ){ ?>
|
||||
<div id="chart-<?=$chartId?>" style="min-width: 100%; height:250px; margin: 0 auto"></div>
|
||||
|
||||
<center>
|
||||
<?php echo $description; ?>
|
||||
</center>
|
||||
<div id="options-<?=$divId?>" style="height:95px;background:#F5F5F5;width:98%;overflow-x:auto;overflow-y:hidden;<?php if( $hideSlider ) { echo 'display:none;'; } ?>">
|
||||
|
||||
<br/>
|
||||
|
||||
@ -128,7 +128,9 @@ if( $isPopup ){
|
||||
</div>
|
||||
<?php if( $hasResults ){ ?>
|
||||
<div id="chart-<?=$chartId?>" style="min-width: 100%; <?php if( $isPopup ){ echo 'height:90%;'; }else{ echo 'height:250px;'; } ?> margin: 0 auto"></div>
|
||||
|
||||
<center>
|
||||
<?php echo $description; ?>
|
||||
</center>
|
||||
<div id="options-<?=$divId?>" style="height:95px;background:#F5F5F5;width:98%;overflow-x:auto;overflow-y:hidden;<?php if( $isPopup ){ echo 'display:none'; } ?>">
|
||||
<table>
|
||||
<tr>
|
||||
@ -273,6 +275,7 @@ if( $isPopup ){
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if( $hasResults ){ ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -83,6 +83,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="chart-<?=$chartId?>" style="min-width: 100%; height:250px; margin: 0 auto"></div>
|
||||
<center>
|
||||
<?php echo $description; ?>
|
||||
</center>
|
||||
</div>
|
||||
<hr />
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -19,6 +19,9 @@
|
||||
<h5 style="text-align:center;"><?php echo $group; ?></h5>
|
||||
</div>
|
||||
<div id="chart-<?=$chartId?><?php echo $count; ?>" style="min-width: 100%; height:250px; margin: 0 auto"></div>
|
||||
<center>
|
||||
<?php echo $description; ?>
|
||||
</center>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user