diff --git a/db/migrate/000126_chart.sql b/db/migrate/000126_chart.sql new file mode 100644 index 000000000..e2c3311ed --- /dev/null +++ b/db/migrate/000126_chart.sql @@ -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', ''); \ No newline at end of file diff --git a/include/controllers/default/cockpit/home/charts.php b/include/controllers/default/cockpit/home/charts.php index b7ab32ccd..e0eaf329a 100644 --- a/include/controllers/default/cockpit/home/charts.php +++ b/include/controllers/default/cockpit/home/charts.php @@ -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 ]]); } } \ No newline at end of file diff --git a/include/library/Crunchbutton/Chart.php b/include/library/Crunchbutton/Chart.php index b17413b2e..f6e1fb61a 100644 --- a/include/library/Crunchbutton/Chart.php +++ b/include/library/Crunchbutton/Chart.php @@ -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 ); diff --git a/include/views/default/cockpit/charts/area.phtml b/include/views/default/cockpit/charts/area.phtml index f4e58748d..a44afc736 100644 --- a/include/views/default/cockpit/charts/area.phtml +++ b/include/views/default/cockpit/charts/area.phtml @@ -93,7 +93,9 @@
- +
+ +

diff --git a/include/views/default/cockpit/charts/column.phtml b/include/views/default/cockpit/charts/column.phtml index 0e565a63c..cb8216440 100644 --- a/include/views/default/cockpit/charts/column.phtml +++ b/include/views/default/cockpit/charts/column.phtml @@ -128,7 +128,9 @@ if( $isPopup ){
- +
+ +
@@ -273,6 +275,7 @@ if( $isPopup ){ } ?> +