From 9f699e023d284889ef9e438ff59f724a3bc83564 Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Thu, 17 Apr 2014 09:51:26 -0300 Subject: [PATCH] Change 1st driver phone call to a text message #2812 --- .../Crunchbutton/Admin/Notification.php | 27 +++++++++++----- .../Crunchbutton/Admin/Notification/Log.php | 2 +- .../views/default/cockpit/layout/core.phtml | 31 +++++++++++-------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/include/library/Crunchbutton/Admin/Notification.php b/include/library/Crunchbutton/Admin/Notification.php index 3ad9ce42c..95a632a6f 100644 --- a/include/library/Crunchbutton/Admin/Notification.php +++ b/include/library/Crunchbutton/Admin/Notification.php @@ -94,24 +94,35 @@ class Crunchbutton_Admin_Notification extends Cana_Table { } $driverAlreadyNotified = []; - + $driversAlreadyReminded = []; $drivers = Crunchbutton_Community_Shift::driversCouldDeliveryOrder( $order->id_order ); if( $drivers ){ foreach( $drivers as $driver ){ $driverAlreadyNotified[] = $driver->id_admin; foreach( $driver->activeNotifications() as $adminNotification ){ - $adminNotification->send( $order ); - $hasDriversWorking = true; - $message = '#'.$order->id_order.' sending ** NEW ** notification to ' . $driver->name . ' # ' . $adminNotification->value; - Log::debug( [ 'order' => $order->id_order, 'action' => $message, 'type' => 'delivery-driver' ] ); - echo $message."\n"; + // first notification + if( $attempts == 0 ){ + $adminNotification->send( $order ); + $message = '#'.$order->id_order.' sending ** NEW ** notification to ' . $driver->name . ' # ' . $adminNotification->value . ' attempt: ' . $attempts; + Log::debug( [ 'order' => $order->id_order, 'action' => $message, 'type' => 'delivery-driver' ] ); + echo $message."\n"; + } else { + // next notifications + if( !$driversAlreadyReminded[ $driver->id_admin ] ){ + $adminNotification->send( $order ); + $message = '#'.$order->id_order.' sending ** NEW ** notification to ' . $driver->name . ' - attempt: ' . $attempts; + Log::debug( [ 'order' => $order->id_order, 'action' => $message, 'type' => 'delivery-driver' ] ); + echo $message."\n"; + } + } + $driversAlreadyReminded[ $driver->id_admin ] = true; + $hasDriversWorking = true; } } } - + // Send notification to drivers - Working Hours legacy $driversAlreadyReminded = []; - // Send notification to drivers - legacy if( count( $driversToNotify ) > 0 ){ foreach( $driversToNotify as $driver ){ if( $driver->isWorking() ){ diff --git a/include/library/Crunchbutton/Admin/Notification/Log.php b/include/library/Crunchbutton/Admin/Notification/Log.php index ca3b4001b..c32a9fc8e 100644 --- a/include/library/Crunchbutton/Admin/Notification/Log.php +++ b/include/library/Crunchbutton/Admin/Notification/Log.php @@ -44,7 +44,7 @@ class Crunchbutton_Admin_Notification_Log extends Cana_Table { $description = 'Notification #' . ( $attempts + 1 ); if( $attempts == 0 ){ - $description .= ' regular notification'; + $description .= ' First txt message'; } if( $attempts == 1 ){ diff --git a/include/views/default/cockpit/layout/core.phtml b/include/views/default/cockpit/layout/core.phtml index b1125ec09..2d5981c62 100644 --- a/include/views/default/cockpit/layout/core.phtml +++ b/include/views/default/cockpit/layout/core.phtml @@ -194,13 +194,7 @@ - permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?> -
  • - - Working hours - -
  • - + permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?>
  • @@ -223,11 +217,6 @@ Summary
  • -
  • - - Status - -
  • permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) || c::admin()->isDriver() ) { ?> @@ -238,6 +227,22 @@ + permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) || c::admin()->isDriver() ) { ?> +
  • + + Status + +
  • + + + + permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?> +
  • + + Working hours deprecated + +
  • +