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 @@ /* @todo: make this a diff date. write date diff in js */ ?>