This commit is contained in:
Daniel Camargo 2013-08-12 15:28:26 -03:00
parent 0f52b6714e
commit 1abd760885
3 changed files with 66 additions and 24 deletions

View File

@ -3,7 +3,6 @@
class Controller_home_charts extends Crunchbutton_Controller_Account {
public function process( $info, $chart ){
$title = $info[ 'title' ];
$subTitle = $info['chart'][ 'title' ];
$type = $info['chart'][ 'type' ];
@ -11,10 +10,12 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
if( $_GET['filter'] ){
$filters = $info['chart'][ 'filters' ];
foreach( $filters as $filter ){
if( $filter[ 'type' ] == $_GET['filter'] ){
$method = $filter[ 'method' ];
$info[ 'filter' ] = $filter[ 'type' ];
if( $filters ){
foreach( $filters as $filter ){
if( $filter[ 'type' ] == $_GET['filter'] ){
$method = $filter[ 'method' ];
$info[ 'filter' ] = $filter[ 'type' ];
}
}
}
}

View File

@ -75,11 +75,34 @@ if( $isPopup ){
}
$applyCommunityFilter = false;
foreach ($ys as $k => $v) {
if( $_GET[ 'filter' ] && $_GET[ 'filter' ] == 'community' ){
if( $_GET[ 'community' ] && $_GET[ 'community' ] != '' && strtolower( $_GET[ 'community' ] ) != 'all' ){
if( strtolower( $_GET[ 'community' ] ) == strtolower( $k ) ){
$applyCommunityFilter = true;
}
}
}
}
// remove assoc vals and add proper keys
foreach ($ys as $k => $v) {
$ys[$k] = array_values($ys[$k]);
$visible = true;
if( $applyCommunityFilter && $_GET[ 'filter' ] && $_GET[ 'filter' ] == 'community' ){
if( $_GET[ 'community' ] && $_GET[ 'community' ] != '' && strtolower( $_GET[ 'community' ] ) != 'all' ){
if( strtolower( $_GET[ 'community' ] ) == strtolower( $k ) ){
$visible = true;
} else {
$visible = false;
}
}
}
$ys[$k] = [
'name' => $k,
'visible' => $visible,
'data' => $ys[$k]
];
}
@ -219,26 +242,26 @@ if( $isPopup ){
</tr>
</table>
<div class="row-fluid" style="padding:0 20px; font-size:11px;">
<div class="row-fluid" style="padding:0 20px; font-size:10px;">
<div class="span3" id="week-<?=$chartId?>">
<?php
if( $interval == 'week' ){
$_slider_to = $to;
$_slider_from = $from;
?>
Weeks <?php echo $from; ?> to <?php echo $to; ?> <br/>(total <?php echo $totalWeeks; ?>)
Weeks <?php echo $from; ?> to <?php echo $to; ?> (total <?php echo $totalWeeks; ?>)
<?php
} else if( $interval == 'month' ){
$_slider_to = $to_month;
$_slider_from = $from_month;
?>
Months <?php echo $from_month; ?> to <?php echo $to_month; ?> <br/>(total <?php echo $totalMonths; ?>)
Months <?php echo $from_month; ?> to <?php echo $to_month; ?> (total <?php echo $totalMonths; ?>)
<?php
} else if( $interval == 'day' ){
$_slider_to = $to_day;
$_slider_from = $from_day;
?>
Days <?php echo $from_day; ?> to <?php echo $to_day; ?> <br/>(total <?php echo $totalDays; ?>)
Days <?php echo $from_day; ?> to <?php echo $to_day; ?> (total <?php echo $totalDays; ?>)
<?php
} ?>
</div>

View File

@ -115,22 +115,35 @@
?>
<!-- Settings -->
<div class="row-fluid">
<div class="span3">
<ul class="padded separate-sections">
<li>
<span class="span7">
<label for="active-user">
<b>Active user (days)</b>
</label>
</span>
<span class="span4">
<input name="active-user-days" class="span12" id="active-user-days" type="number" placeholder="days" value="45">
</span>
<div class="clearfix"></div>
</li>
</ul>
<div class="span2">
<div>
<b>Active user (days)</b>
</div>
<div>
<input name="active-user-days" class="span12" id="active-user-days" type="number" placeholder="days" value="45">
</div>
</div>
<div class="span7">
<div class="span2">
<div>
<b>Community</b>
</div>
<div>
<?php
$communities = Restaurant::getCommunities();
?>
<select name="filter-by-community" id="filter-by-community">
<option value="">Ignore filter</option>
<option value="all">All</option>
<?php
foreach( $communities as $community ){
echo '<option value="' . $community . '">' . $community . '</option>';
}
?>
</select>
</div>
</div>
<div class="span6">
<div id="slider-master"></div>
<br />
<div id="slider-label"></div>
@ -305,6 +318,11 @@
}
}
if( $('#filter-by-community').val() != '' ){
params[ 'filter' ] = 'community';
params[ 'community' ] = $('#filter-by-community').val();
}
var strParams = "?";
for ( var key in params ) {
if ( strParams != "?" ) {