diff --git a/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css b/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css new file mode 100644 index 0000000..bbd9acd --- /dev/null +++ b/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css @@ -0,0 +1,15 @@ +.delivery-process { + background-color: #777; + color: white; + cursor: pointer; + padding: 18px; + width: 100%; + border: none; + text-align: left; + outline: none; + font-size: 15px; + } + + .delivery-process:hover { + background-color: #555; + } \ No newline at end of file diff --git a/backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js b/backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js new file mode 100644 index 0000000..12e8a2f --- /dev/null +++ b/backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js @@ -0,0 +1,23 @@ +jQuery(document).ready(function($) { + + $('#delivery-process-selector').change(function(e){ + e.preventDefault(); + + var data = { + action: 'wiaas_create_order_delivery_process', + _ajax_nonce: $('#wiaas_create_order_delivery_process_nonce').val(), + order: $('#wiaas_order_id').val(), + form: e.target.value + + }; + + // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php + $.post(ajaxurl, data, function(response) { + if (response.success){ + location.reload(); + }else{ + alert(response.data[0].message); + } + }); + }); +}); \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php index af25908..0218ec9 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php @@ -5,6 +5,16 @@ class Wiaas_Admin_Delivery_Process { public static function init() { require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-flow.php'; require_once dirname( __FILE__ ) . '/delivery-process/wiaas-admin-delivery-process-ajax.php'; + + add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 ); + } + + public static function enqueue_scripts() { + $plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) ); + + wp_enqueue_script( 'wiaas_delivery_process', $plugin_url . '/assets/js/wiaas-admin-delivery-process.js' ); + + wp_enqueue_style( 'wiaas_admin_delivery_process', $plugin_url . '/assets/css/wiaas-admin-delivery-process.css' ); } } diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php index 158ab18..efe7acd 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-flow.php @@ -3,37 +3,33 @@ class Wiaas_Admin_Order_Process_Flow { public static function init() { - add_action('add_meta_boxes', array(__CLASS__, 'create_custom_meta_box'), 100); add_action('woocommerce_admin_order_data_after_order_details', array(__CLASS__, 'add_custom_fields_after_order_details'), 10, 1 ); + add_action('add_meta_boxes', array(__CLASS__, 'create_process_flow_meta_box'), 100); + add_action('gravityflow_entry_detail', array(__CLASS__, 'add_delivery_dates_box'), 11, 3); } - public static function create_custom_meta_box() { - add_meta_box( + public static function create_process_flow_meta_box(){ + add_meta_box( 'order_process_flow_meta_box', __('Order Process Flow', 'cmb'), 'Wiaas_Admin_Order_Process_Flow::add_process_flow_meta_box', 'shop_order', 'normal', - 'default' - ); - - add_meta_box( - 'order_delivery_dates_meta_box', - __('Delivery dates', 'cmb'), - 'Wiaas_Admin_Order_Process_Flow::add_delivery_dates_meta_box', - 'shop_order', - 'normal', - 'default' + 'high' ); } - public static function add_custom_fields_after_order_details($order){ - $global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id); - - $order_id = $order->id; - require 'views/html-order-global-delivery-date.php'; + public static function add_delivery_dates_box($form, $entry, $current_step){ + $order_id = $entry['wiaas_delivery_order_id']; + + $suppliers = Wiaas_Order::get_suppliers($order_id); + $final_estimated_date = Wiaas_Order::get_final_estimated_date($order_id); + $final_confirmed_date = Wiaas_Order::get_final_confirmed_date($order_id); + $earliest_installation_date = Wiaas_Order::get_earliest_installation_date($order_id); + + require 'views/html-order-delivery-dates.php'; } - + public static function add_process_flow_meta_box(){ global $post; @@ -43,27 +39,35 @@ class Wiaas_Admin_Order_Process_Flow { if ($process === NULL){ $list_of_delivery_processes = Wiaas_Delivery_Process::get_available_delivery_processes(); - require 'views/html-order-select-delivery-process.php'; - }else{ - $title = $process['name']; - $steps = $process['steps']; + + echo '
+

Please select a process for the order:

+
+ +
'; + wp_nonce_field( 'wiaas_create_order_delivery_process', 'wiaas_create_order_delivery_process_nonce' ); + echo ''; + + }else{ + $workflow_url = ""; + + echo '
+ Go to process flow +
'; } } - public static function add_delivery_dates_meta_box(){ - global $post; - - $order_id = $post->ID; - - $suppliers = Wiaas_Order::get_suppliers($order_id); - $final_estimated_date = Wiaas_Order::get_final_estimated_date($order_id); - $final_confirmed_date = Wiaas_Order::get_final_confirmed_date($order_id); - $earliest_installation_date = Wiaas_Order::get_earliest_installation_date($order_id); - - require 'views/html-order-delivery-dates.php'; + public static function add_custom_fields_after_order_details($order){ + $global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id); + $order_id = $order->id; + require 'views/html-order-global-delivery-date.php'; } } diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-dates.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-dates.php index 90b6429..a03f7d1 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-dates.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-dates.php @@ -4,8 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) { } ?> - -
+
@@ -67,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) { ?> - + @@ -75,7 +74,7 @@ if ( ! defined( 'ABSPATH' ) ) { - + @@ -100,7 +99,7 @@ function onEstimatedDeliveryDateChange(supplierID, date) { }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - $.post(ajaxurl, data, function(response) { + jQuery.post(ajaxurl, data, function(response) { if (response.success){ location.reload(); }else{ @@ -125,7 +124,7 @@ function onConfirmedDeliveryDateChange(supplierID, date) { }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - $.post(ajaxurl, data, function(response) { + jQuery.post(ajaxurl, data, function(response) { if (response.success){ location.reload(); }else{ @@ -145,7 +144,7 @@ function addAdditionalTrackingInfo(e){ }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - $.post(ajaxurl, data, function(response) { + jQuery.post(ajaxurl, data, function(response) { if (response.success){ location.reload(); }else{ @@ -170,7 +169,7 @@ function saveTrackingInfo(e, supplierID, index){ }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - $.post(ajaxurl, data, function(response) { + jQuery.post(ajaxurl, data, function(response) { if (response.success){ location.reload(); }else{ @@ -190,7 +189,7 @@ function deleteTrackingInfo(e, supplierID, index){ }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - $.post(ajaxurl, data, function(response) { + jQuery.post(ajaxurl, data, function(response) { if (response.success){ location.reload(); }else{ diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php deleted file mode 100644 index b0b31ec..0000000 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php +++ /dev/null @@ -1,65 +0,0 @@ - - - - -
-

-
- $step){ - $count = $index + 1; - echo ''; - echo '
'; - echo $step['full_desc']; - echo '
'; - } - ?> -
- - \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php deleted file mode 100644 index 4969d8c..0000000 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php +++ /dev/null @@ -1,65 +0,0 @@ - - - - -
-

Please select a process for the order:

-
- -
- - \ No newline at end of file
Suppliers

Final dates :

Final dates :


Earliest installation date :

Earliest installation date :