diff --git a/include/controllers/default/cockpit2/api/driverorders/index.php b/include/controllers/default/cockpit2/api/driverorders/index.php index 159ee4922..c89d5445a 100644 --- a/include/controllers/default/cockpit2/api/driverorders/index.php +++ b/include/controllers/default/cockpit2/api/driverorders/index.php @@ -67,7 +67,5 @@ class Controller_api_driverorders extends Crunchbutton_Controller_RestAccount { echo json_encode($exports); } - -// if( !$justMineOrders || ( $justMineOrders && $order->lastStatus[ 'id_admin' ] == c::admin()->id_admin ) ){ } } \ No newline at end of file diff --git a/include/controllers/default/cockpit2/api/drivershifts/index.php b/include/controllers/default/cockpit2/api/drivershifts/index.php new file mode 100644 index 000000000..3589a99a3 --- /dev/null +++ b/include/controllers/default/cockpit2/api/drivershifts/index.php @@ -0,0 +1,34 @@ +communitiesHeDeliveriesFor(); + $_communities = []; + foreach( $communities as $community ){ + $_communities[] = $community->id_community; + } + // get the shifts for the next 7 days + $shifts = Crunchbutton_Community_Shift::nextShiftsByCommunities( $_communities ); + $export = []; + foreach ( $shifts as $shift ) { + $drivers = $shift->getDrivers(); + $mine = 0; + $_drivers = []; + foreach ( $drivers as $driver ) { + if( $driver->id_admin == c::admin()->id_admin ){ + $mine = 1; + } + $_drivers[] = [ 'name' => $driver->name, 'phone' => $driver->phone() ]; + } + $export[] = Model::toModel( [ + 'id_community_shift' => $shift->id_community_shift, + 'community' => $shift->community()->name, + 'date' => [ 'day' => $shift->dateStart()->format( 'D, M jS' ), 'start_end' => $shift->startEndToString(), 'timezone' => $shift->timezoneAbbr() ], + 'drivers' => $_drivers, + 'mine' => $mine + ] ); + } + echo json_encode( $export ); + } +} \ No newline at end of file diff --git a/include/controllers/default/quick/home/index.php b/include/controllers/default/quick/home/index.php index cdc088301..622410d40 100644 --- a/include/controllers/default/quick/home/index.php +++ b/include/controllers/default/quick/home/index.php @@ -79,7 +79,6 @@ class Controller_home extends Crunchbutton_Controller_Account { } public function getOrdersList( $all = false ){ - $hours = 12; $orders = Order::deliveryOrders( $hours ); diff --git a/include/library/Crunchbutton/Community/Shift.php b/include/library/Crunchbutton/Community/Shift.php index d31d1524d..0fe40023f 100644 --- a/include/library/Crunchbutton/Community/Shift.php +++ b/include/library/Crunchbutton/Community/Shift.php @@ -64,9 +64,14 @@ class Crunchbutton_Community_Shift extends Cana_Table { public function nextShiftsByCommunities( $communities ){ if( count( $communities ) > 0 ){ $now = new DateTime( 'now', new DateTimeZone( c::config()->timezone ) ); + $now_formated = $now->format( 'Y-m-d' ); + $now->modify( '+ 7 days' ); + $next_days_formated = $now->format( 'Y-m-d' ); $query = 'SELECT cs.* FROM community_shift cs WHERE cs.id_community IN( ' . join( ',', $communities ) . ' ) AND - DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) >= "' . $now->format( 'Y-m-d' ) . '" ORDER BY cs.date_start ASC LIMIT 20'; + DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) >= "' . $now_formated . '" AND + DATE_FORMAT( cs.date_start, "%Y-%m-%d" ) <= "' . $next_days_formated . '" + ORDER BY cs.date_start ASC'; return Crunchbutton_Community_Shift::q( $query ); } return false; diff --git a/include/views/default/cockpit2/bundle/js.phtml b/include/views/default/cockpit2/bundle/js.phtml index 027ca4ee2..7c710b17c 100644 --- a/include/views/default/cockpit2/bundle/js.phtml +++ b/include/views/default/cockpit2/bundle/js.phtml @@ -40,3 +40,4 @@ + \ No newline at end of file diff --git a/include/views/default/cockpit2/frontend/drivers-orders.phtml b/include/views/default/cockpit2/frontend/drivers-orders.phtml index 5fb42746c..3b5360162 100644 --- a/include/views/default/cockpit2/frontend/drivers-orders.phtml +++ b/include/views/default/cockpit2/frontend/drivers-orders.phtml @@ -9,7 +9,7 @@
Last Updated: {{newDriverOrders.time.getTime() | date: 'hh:mm a'}}
-
+
@@ -19,7 +19,7 @@
-
+
diff --git a/include/views/default/cockpit2/frontend/drivers-shifts.phtml b/include/views/default/cockpit2/frontend/drivers-shifts.phtml index 0de16e0b1..efdcf29da 100644 --- a/include/views/default/cockpit2/frontend/drivers-shifts.phtml +++ b/include/views/default/cockpit2/frontend/drivers-shifts.phtml @@ -1,4 +1,45 @@
+
+ +
+ + +
+
-shifts \ No newline at end of file +
+ +
+ +
+ +
{{shift.date.day}}
+
{{shift.date.start_end}}
+
{{shift.date.timezone}}
+
{{shift.community}}
+ +
+
+
+
{{driver.name}}
+
{{driver.phone}}
+
+ +
+
+
+ No drivers +
+ +
+
+
+ +
+ You currently have no orders to deliver. +
+ +
+ +
diff --git a/www/assets/cockpit/js/controllers.js b/www/assets/cockpit/js/controllers.js index 779961f73..8e14084c7 100644 --- a/www/assets/cockpit/js/controllers.js +++ b/www/assets/cockpit/js/controllers.js @@ -4,14 +4,10 @@ NGApp.controller('DefaultCtrl', function ($scope, $http, $location, MainNavigati } }); -NGApp.controller('MainHeaderCtrl', function ( $scope, $rootScope) { - -}); +NGApp.controller('MainHeaderCtrl', function ( $scope, $rootScope) {} ); NGApp.controller('SideMenuCtrl', function ($scope) { - $scope.setupPermissions = function() { - - } + $scope.setupPermissions = function() {} }); NGApp.controller('LoginCtrl', function($scope, AccountService) { @@ -24,12 +20,10 @@ NGApp.controller('LoginCtrl', function($scope, AccountService) { } }); -NGApp.controller('DriversOrderCtrl', function ($http, $scope, $rootScope, DriverOrders) { - -}); +NGApp.controller('DriversOrderCtrl', function ( $http, $scope, $rootScope, DriverOrders ) {} ); -NGApp.controller('DriversOrdersCtrl', function ($http, $scope, $rootScope, DriverOrdersService, AccountService ) { +NGApp.controller('DriversOrdersCtrl', function ( $scope, $rootScope, DriverOrdersService, AccountService ) { // The scope just need the account's user object $scope.account = { user : AccountService.user } ; @@ -87,6 +81,28 @@ NGApp.controller('DriversOrdersCtrl', function ($http, $scope, $rootScope, Drive } ); -NGApp.controller('DriversShiftsCtrl', function ($http, $scope, $rootScope) { +NGApp.controller( 'DriversShiftsCtrl', function ( $scope, $rootScope, DriverShiftsService ) { -}); \ No newline at end of file + $scope.show = { all : true }; + + $scope.filterShifts = function( shift ){ + if( $scope.show.all ){ + return true; + } else { + if( shift.mine ){ + return true; + } + } + return false; + } + // List + $scope.list = function(){ + DriverShiftsService.list( function( data ){ + $scope.drivershifts = data; + } ); + } + + // Load the shifts + $scope.list(); + +} ); \ No newline at end of file diff --git a/www/assets/cockpit/js/service.driverorders.js b/www/assets/cockpit/js/service.driverorders.js index 5ed3969c5..1302a915a 100644 --- a/www/assets/cockpit/js/service.driverorders.js +++ b/www/assets/cockpit/js/service.driverorders.js @@ -1,4 +1,3 @@ -// DriverOrdersService service NGApp.factory( 'DriverOrdersService', function( $rootScope, $resource ) { var service = {}; @@ -47,4 +46,4 @@ NGApp.factory( 'DriverOrdersService', function( $rootScope, $resource ) { } return service; -} ); +} ); \ No newline at end of file diff --git a/www/assets/cockpit/js/service.drivershifts.js b/www/assets/cockpit/js/service.drivershifts.js new file mode 100644 index 000000000..9a0466b91 --- /dev/null +++ b/www/assets/cockpit/js/service.drivershifts.js @@ -0,0 +1,13 @@ +NGApp.factory( 'DriverShiftsService', function( $rootScope, $resource ) { + + var service = {}; + + // Create a private resource 'shifts' + var shifts = $resource( App.service + 'drivershifts', {}, {} ); + + service.list = function( callback ){ + shifts.query( {}, function( data ){ callback( data ); } ); + } + + return service; +} ); \ No newline at end of file diff --git a/www/assets/cockpit/scss/cockpit.scss b/www/assets/cockpit/scss/cockpit.scss index fc845b302..723f0c05f 100644 --- a/www/assets/cockpit/scss/cockpit.scss +++ b/www/assets/cockpit/scss/cockpit.scss @@ -693,11 +693,10 @@ input { overflow: hidden; } -.box-with-shadown{ +.list-box{ background: #FFF; padding: 15px; margin-bottom: 15px; - box-shadow: 0px 3px 2px #AAB2BD; } /* drivers order list page */ @@ -755,15 +754,16 @@ input { .drivers-order-list .item .info .customer{ font-size:1em; } -.drivers-order-list-filter{ + +.list-filter{ margin: 0 0 1em 0; } - .drivers-order-list-filter .button{ + .list-filter .button{ display: table; float: left; width: 100px; margin-right: 1em; } - .drivers-order-list-filter .button.inactive{ + .list-filter .button.inactive{ opacity: 0.5; } \ No newline at end of file