Merge branch 'master' of github.com:crunchbutton/crunchbutton
This commit is contained in:
commit
e5e9236f4b
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 );
|
||||
|
||||
@ -98,7 +98,6 @@ class Crunchbutton_Order extends Cana_Table {
|
||||
// delivery fee
|
||||
$this->delivery_fee = ($this->restaurant()->delivery_fee && $this->delivery_type == 'delivery') ? $this->restaurant()->delivery_fee : 0;
|
||||
|
||||
|
||||
// service fee for customer
|
||||
$this->service_fee = $this->restaurant()->fee_customer;
|
||||
$serviceFee = ($this->price + $this->delivery_fee) * Util::ceil(($this->service_fee/100),2);
|
||||
@ -217,6 +216,8 @@ class Crunchbutton_Order extends Cana_Table {
|
||||
}
|
||||
}
|
||||
|
||||
Log::debug(['giftcardValue'=> $this->giftcardValue]);
|
||||
|
||||
$res = $this->verifyPayment();
|
||||
|
||||
if ( $res !== true ) {
|
||||
@ -381,9 +382,11 @@ class Crunchbutton_Order extends Cana_Table {
|
||||
$chargedByCredit = Crunchbutton_Credit::calcDebitFromUserCredit( $final_price, $this->id_user, $this->id_restaurant, $this->id_order, true );
|
||||
$final_price = $final_price - $chargedByCredit;
|
||||
}
|
||||
Log::debug([ '$this->final_price' => $this->final_price, 'giftcardValue'=> $this->giftcardValue, 'final_price' => $final_price, ]);
|
||||
if( $final_price < 0 ){ $final_price = 0; }
|
||||
return Util::ceil( $final_price, 2 );
|
||||
}
|
||||
|
||||
return $final_price;
|
||||
}
|
||||
|
||||
@ -532,11 +535,14 @@ class Crunchbutton_Order extends Cana_Table {
|
||||
if ($search['restaurant']) {
|
||||
$query .= ' and `order`.id_restaurant="'.$search['restaurant'].'" ';
|
||||
}
|
||||
|
||||
/*
|
||||
if ($search['community']) {
|
||||
$query .= ' and `order`.id_community="'.$search['community'].'" ';
|
||||
}
|
||||
|
||||
*/
|
||||
if ($search['community']) {
|
||||
$query .= ' and `restaurant`.community="'.$search['community'].'" ';
|
||||
}
|
||||
if ($search['order']) {
|
||||
$query .= ' and `order`.id_order="'.$search['order'].'" ';
|
||||
}
|
||||
|
||||
@ -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/>
|
||||
|
||||
@ -88,8 +88,8 @@
|
||||
<span class="span8 pull-right">
|
||||
<select name="community" class="chzn-select">
|
||||
<option value="" selected>[ All ]</option>
|
||||
<? foreach (Community::q('select * from community order by name') as $community) : ?>
|
||||
<option value="<?=$community->id_community?>"><?=$community->name?></option>
|
||||
<? foreach (Restaurant::getCommunities() as $community) : ?>
|
||||
<option value="<?=$community?>"><?=$community?></option>
|
||||
<? endforeach ; ?>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
${{formatPrice(order.order.charged)}}
|
||||
|
||||
<div class="credit" ng-show="(order.order.credit && order.order.credit > 0)">( ${{parseFloat(order.order.final_price).toFixed(2)}} - ${{parseFloat(order.order.credit).toFixed(2)}} credit )</div>
|
||||
<div class="credit" ng-show="(order.order.credit && order.order.credit > 0)">( ${{order.order._final_price}} - ${{order.order._credit}} credit )</div>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
@ -1165,6 +1165,11 @@ var ADMIN = {
|
||||
UTIL.show_msg('Please wait the restaurant load!');
|
||||
return;
|
||||
}
|
||||
if( $('#restaurant-community').val() == '' ){
|
||||
alert( 'Please type the community name.' );
|
||||
$('#restaurant-community').focus();
|
||||
return;
|
||||
}
|
||||
validation_warnings = DOM_MAP.validate();
|
||||
if(validation_warnings.length) {
|
||||
console.log(validation_warnings);
|
||||
|
||||
@ -27,6 +27,7 @@ function AccountResetCtrl( $scope, $http, AccountResetService ) {
|
||||
|
||||
function GiftCardCtrl( $scope, $http, GiftCardService ) {
|
||||
$scope.giftcard = GiftCardService;
|
||||
$scope.giftcard.parseURLCode();
|
||||
$scope.giftcard.processModal();
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ NGApp.factory( 'GiftCardService', function( $http, $location, AccountModalServic
|
||||
service.modal.reset();
|
||||
setTimeout( function(){
|
||||
// Check if the user is logged in
|
||||
service.redeemed = service.account.isLogged();
|
||||
service.redeemed = ( App.config.user.id_user != '' );
|
||||
console.log('service.redeemed',service.redeemed);
|
||||
service.validate( function( data ){
|
||||
service.modal.intro = false;
|
||||
if( data.error ){
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
//OrderService Service
|
||||
NGApp.factory('OrderService', function ($http, $location, $rootScope, AccountService, CartService, LocationService, CreditService ) {
|
||||
NGApp.factory('OrderService', function ($http, $location, $rootScope, AccountService, CartService, LocationService, CreditService, GiftCardService ) {
|
||||
|
||||
var service = {};
|
||||
service.location = LocationService;
|
||||
service.account = AccountService;
|
||||
service.cart = CartService;
|
||||
service.giftcard = GiftCardService;
|
||||
service.credit = CreditService;
|
||||
service.restaurant = {};
|
||||
|
||||
@ -90,6 +91,11 @@ NGApp.factory('OrderService', function ($http, $location, $rootScope, AccountSer
|
||||
service.form.phone = App.phone.format(service.account.user.phone);
|
||||
service.form.address = service.account.user.address;
|
||||
service.form.notes = (service.account.user && service.account.user.presets && service.account.user.presets[service.restaurant.id_restaurant]) ? service.account.user.presets[service.restaurant.id_restaurant].notes : '';
|
||||
|
||||
if( service.giftcard.code ){
|
||||
service.form.notes = service.form.notes + ' ' + service.giftcard.code;
|
||||
}
|
||||
|
||||
// Credit card stuff
|
||||
service.form.cardNumber = service.account.user.card;
|
||||
service.form.cardMonth = service.account.user.card_exp_month;
|
||||
@ -821,6 +827,11 @@ NGApp.factory('OrderViewService', function ($routeParams, $location, $rootScope,
|
||||
});
|
||||
return;
|
||||
}
|
||||
service.order._final_price = parseFloat( service.order.final_price ).toFixed(2);
|
||||
if( service.order.credit ){
|
||||
service.order._credit = parseFloat( service.order.credit ).toFixed(2);
|
||||
}
|
||||
|
||||
service.facebook._order_uuid = service.order.uuid;
|
||||
service.facebook.preLoadOrderStatus();
|
||||
App.cache('Restaurant', service.order.id_restaurant, function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user