This commit is contained in:
Daniel Camargo 2014-03-20 11:17:41 -03:00
commit 3d257c9ff2
8 changed files with 165 additions and 70 deletions

View File

@ -206,6 +206,11 @@ class Controller_drivers_shift extends Crunchbutton_Controller_Account {
}
c::view()->week = $week;
c::view()->year = $year;
if( $_REQUEST[ 'ajax' ] ){
c::view()->ajax = true;
c::view()->layout( 'layout/ajax' );
}
c::view()->display( 'drivers/shift/community/index' );
}
}

View File

@ -82,6 +82,9 @@
?>
<li <?php echo $active; ?>><a href="#drivers" data-toggle="tab"><i class="icon-road"></i> <span>Drivers</span></a></li>
<?php } ?>
<?php if( c::env() == 'beta' || c::env() == 'local' ){ ?>
<li><a href="#shifts" data-toggle="tab"><i class="icon-truck"></i> <span>Shifts</span></a></li>
<?php } ?>
<li><a href="#more" data-toggle="tab"><i class="icon-cog"></i> <span>More actions</span></a></li>
</ul>
</div>
@ -113,6 +116,12 @@
<a href="/drivers/schedule"> <i class="icon-calendar"></i> Schedule</a>
<?php } ?>
</div>
<div class="tab-pane" id="shifts">
<div class="row-fluid">
<div id="shifts-content"></div>
</div>
</div>
</div>
</div>
</div>
@ -131,6 +140,7 @@
</div>
</div>
<script type="text/javascript">
var community = { id_community : '<?php echo $community[ 'community' ]->id_community; ?>' };
var _id_restaurant = false;
@ -146,9 +156,33 @@ $( document ).ready( function(){
community.restaurants();
community.drivers();
<?php
$year = date( 'Y', strtotime( '- 1 day' ) );
$week = date( 'W', strtotime( '- 1 day' ) );
$day = new DateTime( date( 'Y-m-d', strtotime( $year . 'W' . $week . 1 ) ), new DateTimeZone( c::config()->timezone ) );
$day->modify( '+ 1 week' );
$week = $day->format( 'W' );
?>
<?php if( c::env() == 'beta' || c::env() == 'local' ){ ?>
community.shifts( '/drivers/shift/community/<?php echo $community[ 'community' ]->id_community; ?>/<?php echo $year; ?>/<?php echo $week; ?>?ajax=1' );
<?php } ?>
} );
community.shifts = function( url ){
$.ajax( {
url: url,
complete: function(content) {
$('#shifts-content').html( content.responseText );
$( '.shift-previous, .shift-next' ).click( function(e) {
e.preventDefault();
var url = $( this ).attr( 'href' ) + '?ajax=1';
community.shifts( url );
} );
}
} );
};
community.drivers = function(){
$.ajax( {
url: '/community/' + community.id_community + '/drivers',

View File

@ -120,5 +120,4 @@ $shift = $this->shift;
</div>
</div>
</div>
</div>
<script type="text/javascript" src="/assets/js/admin.shift.js"></script>
</div>

View File

@ -10,7 +10,11 @@
$week = $this->week;
$segments = $this->segments;
$ajax = ( $this->ajax ) ? true : false;
?>
<?php if( !$ajax ) { ?>
<div class="container-fluid padded">
<div class="row-fluid">
<div class="box">
@ -30,34 +34,38 @@
</div>
</div>
</div>
<?php } ?>
<?php if( $id_community ) { ?>
<div class="row-fluid">
<?php if( !$ajax ) { ?>
<div class="box">
<div class="box-header">
<div class="row-fluid">
<div class="span2 padded">
<a href="/drivers/shift/community/<?php echo $id_community ?>/<?php echo $this->weekPrev; ?>"><i class="icon icon-angle-left"></i> previous</a>
</div>
<div class="span8 padded" style="text-align:center;">
<div class="span12 padded" style="text-align:center;">
<strong>Shift for week <?php echo $this->week; ?> / <?php echo $this->year; ?></strong>
</div>
<div class="span2 padded" style="text-align:right;">
<a href="/drivers/shift/community/<?php echo $id_community ?>/<?php echo $this->weekNext; ?>">next <i class="icon icon-angle-right"></i></a>
</div>
</div>
</div>
<?php } ?>
<div class="box-content">
<form class="form-horizontal">
<div class="padded">
<div>
<div class="row-fluid">
<center>
<h4>
From <?php echo $this->from->format('M jS Y') ?> to <?php echo $this->to->format('M jS Y'); ?>
</h4>
</center>
<hr/>
<div class="span2 padded">
<a class="shift-previous" href="/drivers/shift/community/<?php echo $id_community ?>/<?php echo $this->weekPrev; ?>"><strong><i class="icon icon-angle-left"></i> previous</strong></a>
</div>
<div class="span8 padded" style="text-align:center;">
<h4>
From <?php echo $this->from->format('M jS Y') ?> to <?php echo $this->to->format('M jS Y'); ?>
</h4>
</div>
<div class="span2 padded" style="text-align:right;">
<a class="shift-next" href="/drivers/shift/community/<?php echo $id_community ?>/<?php echo $this->weekNext; ?>"><strong>next <i class="icon icon-angle-right"></i></strong></a>
</div>
</div>
<hr/>
<table width="100%">
<tr>
<?php foreach( $this->days as $day ) {
@ -104,10 +112,11 @@
<?php } ?>
</tr>
</table>
</form>
<div class="divider"></div>
</div>
<?php if( !$ajax ) { ?>
</div>
<?php } ?>
<div class="padded">
@ -145,6 +154,11 @@
$( document ).ready( function(){
shift.community.year = '<?php echo $this->year; ?>';
shift.community.week = '<?php echo $this->week; ?>';
<?php if( $ajax ) { ?>
shift.community.ajax = true;
shift.community.url = '/drivers/shift/community/<?php echo $id_community ?>/<?php echo $this->year; ?>/<?php echo $this->week; ?>?ajax=1';
<?php } ?>
shift.community.init();
} );
</script>

View File

@ -222,8 +222,41 @@
</li>
<? endif ; ?>
<?php if( c::env() == 'beta' || c::env() == 'local' ){ ?>
<!-- Just temporary -->
<? if ( c::admin()->permission()->check( [ 'global','drivers-page'] ) ) : ?>
<li class="dark-nav">
<span class="glow"></span>
<a class="accordion-toggle collapsed" href="#admin-nav-drivers-new" data-toggle="collapse" >
<i class="icon-road icon-2x"></i>
<span>Drivers (NEW)<i class="icon-caret-down"></i></span>
</a>
<ul id="admin-nav-drivers-new" class="collapse">
<li class="">
<a href="/drivers/shift/community">
<i class="icon-truck"></i> Community shifts
</a>
</li>
<li class="">
<a href="/drivers/shift/summary">
<i class="icon-file-alt"></i> Summary
</a>
</li>
<li class="">
<a href="/drivers/shift/schedule/driver">
<i class="icon-calendar"></i> Schedule - for drivers
</a>
</li>
</ul>
</li>
<? endif ; ?>
<!-- -->
<?php } ?>

View File

@ -76,7 +76,7 @@
<div class="order-item-block">
<div class="order-icon"><i class="icon-timer"></i></div>
<div class="order-info">
<?php
<?
if( $this->order->restaurant()->delivery_estimated_time ){
$this->order->date()->modify('+'.$this->order->restaurant()->delivery_estimated_time.' minutes')->format('h:i A');
}
@ -91,13 +91,13 @@
<div class="order-item-block-big">
<div class="order-info order-info-small">
<?php echo $this->order->driverInstructionsPaymentStatus(); ?>
<? echo $this->order->driverInstructionsPaymentStatus(); ?>
</div>
</div>
<div class="order-item-block-big">
<div class="order-info order-info-small">
<?php echo $this->order->driverInstructionsFoodStatus(); ?>
<? echo $this->order->driverInstructionsFoodStatus(); ?>
</div>
</div>
@ -145,7 +145,7 @@
<br><br>
<div class="divider dots"></div>
<br><br>
<?php
<?
$isDriverCockpit = true;
$delivery_service_markup = ( $this->order->delivery_service_markup ) ? $this->order->delivery_service_markup : 0;
$order = $this->order;
@ -154,12 +154,12 @@
<thead style="font-weight:bold">
<td class="topitem">Qty</td>
<td class="topitem">Item</td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td class="topitem" nowrap="nowrap">Customer Price</td>
<td class="topitem" style="width:80px;font-size:12px;color:#666;">Store Price</td>
<?php } else { ?>
<? } else { ?>
<td class="topitem">Price</td>
<?php } ?>
<? } ?>
</thead>
<? foreach ($order->dishes() as $dish) : ?>
<tr>
@ -261,7 +261,7 @@
<?=$food?>
</td>
<td style="width: 1%;" class="fooditem">
$<?php
$<?
if( $isRestaurant ){
echo number_format( $regular_price, 2 );
} else {
@ -269,11 +269,11 @@
}
?>
</td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td class="fooditem" style="font-size:12px;color:#666;">
$<?php echo number_format( $regular_price, 2 ); ?>
$<? echo number_format( $regular_price, 2 ); ?>
</td>
<?php } ?>
<? } ?>
</tr>
<? endforeach ; ?>
@ -281,7 +281,7 @@
<td></td>
<td style="text-align:right">Subtotal</td>
<td>
$<?php
$<?
if( $isRestaurant ){
// legacy
if( intval( $delivery_service_markup ) > 0 && !$order->price_plus_delivery_markup ){
@ -298,9 +298,9 @@
}
?>
</td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$<?php
$<?
// legacy
if( intval( $delivery_service_markup ) > 0 && !$order->price_plus_delivery_markup ){
echo number_format( $order->price - $order->delivery_service_markup_value, 2);
@ -309,22 +309,22 @@
}
?>
</td>
<?php } ?>
<? } ?>
</tr>
<? if ( $order->pay_type == 'card' && $order->tip ) : ?>
<tr>
<td></td>
<td style="text-align:right">Tip <?php if( $order->tip_type != Crunchbutton_Order::TIP_NUMBER ) { echo $order->tip . '%'; } ?></td>
<td style="text-align:right">Tip <? if( $order->tip_type != Crunchbutton_Order::TIP_NUMBER ) { echo $order->tip . '%'; } ?></td>
<td>$<?=$order->tip()?></td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
<?php if( intval( $delivery_service_markup ) > 0 ) { ?>
$<?php echo number_format( 0, 2 ); ?>
<?php } else { ?>
<? if( intval( $delivery_service_markup ) > 0 ) { ?>
$<? echo number_format( 0, 2 ); ?>
<? } else { ?>
$<?=$order->tip()?>
<?php } ?>
<? } ?>
</td>
<?php } ?>
<? } ?>
</tr>
<? endif ; ?>
<? if ( $order->restaurant()->delivery_fee ) : ?>
@ -332,11 +332,11 @@
<td></td>
<td style="text-align:right">Delivery Fee</td>
<td>$<?=$order->deliveryFee()?></td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$<?=$order->deliveryFee()?>
&mdash;
</td>
<?php } ?>
<? } ?>
</tr>
<? endif ; ?>
@ -345,11 +345,11 @@
<td></td>
<td style="text-align:right">Service Fee</td>
<td>$<?=$order->serviceFee()?></td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$$<?=$order->serviceFee()?>
</td>
<?php } ?>
<? } ?>
</tr>
<? endif ; ?>
@ -357,7 +357,7 @@
<td></td>
<td style="text-align:right">Tax</td>
<td>
$<?php
$<?
$tax = $order->tax();
if( $isRestaurant ){
echo number_format( $tax, 2 );
@ -366,18 +366,18 @@
}
?>
</td>
<?php if( $isDriverCockpit ) { ?>
<? if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$<?php echo number_format( $tax, 2 ); ?>
$<? echo number_format( $tax, 2 ); ?>
</td>
<?php } ?>
<? } ?>
</tr>
<tr style="font-weight:bold;">
<td></td>
<td style="text-align:right">Total</td>
<td>
$<?php
$<?
if( $isRestaurant ){
// legacy
if( intval( $delivery_service_markup ) > 0 && !$order->final_price_plus_delivery_markup ){
@ -394,34 +394,34 @@
}
?>
</td>
<?php if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$<?php
<? if( $isDriverCockpit ) { ?>
<td style="font-size:14px;color:#666;">
$<?
// legacy
if( intval( $delivery_service_markup ) > 0 && !$order->final_price_plus_delivery_markup ){
echo number_format( $order->final_price - $order->delivery_service_markup_value, 2);
echo number_format( $order->final_price - $order->delivery_service_markup_value - $order->restaurant()->delivery_fee, 2);
} else {
echo number_format( $order->final_price, 2 );
echo number_format( $order->final_price - $order->restaurant()->delivery_fee, 2 );
}
?>
</td>
<?php } ?>
<? } ?>
</tr>
<?php /* Just the user and CB will see this info about gift card. See #1006. */ ?>
<?php if( $user && $order->chargedByCredit() > 0 ) { ?>
<? /* Just the user and CB will see this info about gift card. See #1006. */ ?>
<? if( $user && $order->chargedByCredit() > 0 ) { ?>
<tr style="font-weight:bold;">
<td></td>
<td style="text-align:right"><?php if( $order->pay_type == 'card' ) { ?>Gift Card <?php } else { ?> Already Paid by Gift Card <?php } ?></td>
<td style="text-align:right"><? if( $order->pay_type == 'card' ) { ?>Gift Card <? } else { ?> Already Paid by Gift Card <? } ?></td>
<td>$<?=number_format($order->chargedByCredit(),2)?></td>
</tr>
<tr style="font-weight:bold;">
<td></td>
<td style="text-align:right"><?php if( $order->pay_type == 'card' ) { ?>Total Charged <?php } else { ?> Total Owed <?php } ?></td>
<td style="text-align:right"><? if( $order->pay_type == 'card' ) { ?>Total Charged <? } else { ?> Total Owed <? } ?></td>
<td>$<?=number_format($order->charged(),2)?></td>
</tr>
<?php } ?>
<? } ?>
<? if ($order->pay_type == 'card' && $order->tip == 0) : ?>
<tr>

View File

@ -197,7 +197,7 @@ if( $version == 'customer' ){
<td>$<?=$order->deliveryFee()?></td>
<?php if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
$<?=$order->deliveryFee()?>
&mdash;
</td>
<?php } ?>
</tr>
@ -258,13 +258,13 @@ if( $version == 'customer' ){
?>
</td>
<?php if( $isDriverCockpit ) { ?>
<td style="font-size:12px;color:#666;">
<td style="font-size:14px;color:#666;">
$<?php
// legacy
if( intval( $delivery_service_markup ) > 0 && !$order->final_price_plus_delivery_markup ){
echo number_format( $order->final_price - $order->delivery_service_markup_value, 2);
echo number_format( $order->final_price - $order->delivery_service_markup_value - $order->restaurant()->delivery_fee, 2);
} else {
echo number_format( $order->final_price, 2 );
echo number_format( $order->final_price - $order->restaurant()->delivery_fee, 2 );
}
?>
</td>

View File

@ -50,6 +50,16 @@ shift.community.toggleTimezone = function(){
$( '.' + shift.community.tz + '-timezone' ).show();
};
shift.community.reload = function(){
console.log('shift.community.ajax',shift.community.ajax);
if( shift.community.ajax ){
$( '#modal-hours' ).modal( 'hide' );
community.shifts( shift.community.url );
} else {
location.reload();
}
}
shift.community.copyAll = function( id_community, week, year ){
if( confirm( 'Confirm copy? This will remove all the hours from this week ' + week + '/' + year + '!' ) ){
$.ajax( {
@ -59,7 +69,7 @@ shift.community.copyAll = function( id_community, week, year ){
dataType: 'json',
} ).done( function( data ) {
if( data.success ){
location.reload();
shift.community.reload();
} else {
alert( 'Ops, error! ' + data.error );
}
@ -77,7 +87,7 @@ shift.community.remove = function(){
dataType: 'json',
} ).done( function( data ) {
if( data.success ){
location.reload();
shift.community.reload();
} else {
alert( 'Ops, error! ' + data.error );
}
@ -106,7 +116,7 @@ shift.community.edit = function(){
dataType: 'json',
} ).done( function( data ) {
if( data.success ){
location.reload();
shift.community.reload();
} else {
alert( 'Ops, error! ' + data.error );
}
@ -140,7 +150,7 @@ shift.community.add = function(){
dataType: 'json',
} ).done( function( data ) {
if( data.success ){
location.reload();
shift.community.reload();
} else {
alert( 'Ops, error! ' + data.error );
}