From 46e2259359e166222ba414e8326b3a8a0aec4f34 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Wed, 31 Oct 2018 21:31:44 +0100 Subject: [PATCH 01/24] increase quantity limit in cart --- frontend/src/constants/cartConstants.js | 2 +- frontend/src/constants/coMarketConstants.js | 2 +- frontend/src/containers/cart/components/CartItem.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/constants/cartConstants.js b/frontend/src/constants/cartConstants.js index 2a3acb8..b4b6801 100644 --- a/frontend/src/constants/cartConstants.js +++ b/frontend/src/constants/cartConstants.js @@ -65,7 +65,7 @@ export const cartMessages = { QUANTITY_UPDATED: "Quantity has been updated for the package!", INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact Co-Market!", PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!", - INVALID_QUANTITY: "The quantity can be a number between 1 and 100!", + INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!", CART_EMPTY: "You must have at least one package in the cart!", NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info", INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!", diff --git a/frontend/src/constants/coMarketConstants.js b/frontend/src/constants/coMarketConstants.js index cb7fccc..55bdf3f 100644 --- a/frontend/src/constants/coMarketConstants.js +++ b/frontend/src/constants/coMarketConstants.js @@ -32,7 +32,7 @@ export const coMarketMessages = { QUANTITY_UPDATED: "Quantity has been updated for the package!", INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact the Co-Market!", PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!", - INVALID_QUANTITY: "The quantity can be a number between 1 and 100!", + INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!", CART_EMPTY: "You must have at least one package in the cart!", NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info", INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!", diff --git a/frontend/src/containers/cart/components/CartItem.jsx b/frontend/src/containers/cart/components/CartItem.jsx index 9618061..6eca641 100644 --- a/frontend/src/containers/cart/components/CartItem.jsx +++ b/frontend/src/containers/cart/components/CartItem.jsx @@ -35,7 +35,7 @@ class CartItem extends Component { } isQuantityValid(quantity) { - return quantity > 0 && quantity <= 100; + return quantity > 0 && quantity <= 65000; } updateQuantity(cartItem, quantity) { From 1a33593cbe2ce6efa8df4e03a3320900458d276a Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 1 Nov 2018 00:28:33 +0100 Subject: [PATCH 02/24] add more validation --- backend/app/plugins/wiaas/includes/class-wiaas-cart.php | 4 ++++ frontend/src/containers/cart/components/CartItem.jsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 98c75f4..f2f3098 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -248,6 +248,10 @@ class Wiaas_Cart { * @return bool */ public static function update_package_quantity($package_cart_item_key, $new_quantity) { + if ($new_quantity > 65000){ + return false; + } + $cart_item = WC()->cart->get_cart_item($package_cart_item_key); if (!$cart_item) { diff --git a/frontend/src/containers/cart/components/CartItem.jsx b/frontend/src/containers/cart/components/CartItem.jsx index 6eca641..b0736b7 100644 --- a/frontend/src/containers/cart/components/CartItem.jsx +++ b/frontend/src/containers/cart/components/CartItem.jsx @@ -40,8 +40,8 @@ class CartItem extends Component { updateQuantity(cartItem, quantity) { if(quantity) { - this.setState({itemQuantity: quantity}); if(this.isQuantityValid(quantity)) { + this.setState({itemQuantity: quantity}); this.sumPrices(cartItem, quantity); this.props.dispatch(updateQuantity(cartItem, quantity)); } else { From 00076b89fd5179de11105119f1b356eddfa52350 Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Fri, 2 Nov 2018 11:26:41 +0100 Subject: [PATCH 03/24] Disabled processing order email for customer --- .../app/plugins/wiaas/includes/class-wiaas-db-update.php | 3 ++- .../includes/db-updates/wiaas-db-update-general.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php index da8e8af..85844f8 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php @@ -23,7 +23,8 @@ class Wiaas_DB_Update { '20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields', '20181019064450' => 'wiaas_db_update_add_bundle_properties_ui_field', '20191020014650' => 'wiaas_create_organization_roles_capabilities', - '20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities' + '20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities', + '20191102112451' => 'wiaas_disable_processing_order_email_delivery' ); public static function execute() { diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php index a5af42b..b30421a 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php +++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php @@ -129,4 +129,13 @@ function wiaas_create_organization_roles_capabilities() { foreach ($roles as $role) { Groups_Capability::create( array( 'capability' => 'wiaas_' . $role )); } +} + +function wiaas_disable_processing_order_email_delivery() { + update_option( 'woocommerce_customer_processing_order_settings', array( + 'enabled' => 'no', + 'subject' => '', + 'heading' => '', + 'mail_type' => 'html' + ) ); } \ No newline at end of file From 69c74d93404dc718a0a1600eef8d5de435b2cbf7 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 21 Oct 2018 16:39:58 +0200 Subject: [PATCH 04/24] order delivery process --- ...ass-wiaas-admin-order-delivery-process.php | 11 ++++ ...iaas-admin-order-delivery-process-flow.php | 60 +++++++++++++++++ .../views/html-order-process-flow.php | 65 +++++++++++++++++++ .../html-order-select-delivery-process.php | 62 ++++++++++++++++++ .../wiaas/includes/class-wiaas-admin.php | 2 + .../includes/class-wiaas-delivery-process.php | 33 ++++++++-- 6 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-order-delivery-process-flow.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php new file mode 100644 index 0000000..3648dae --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php @@ -0,0 +1,11 @@ +ID; + + $process = Wiaas_Delivery_Process::get_order_delivery_process($order_id); + + 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']; + + require 'views/html-order-process-flow.php'; + } + + } + + public static function add_delivery_dates_meta_box(){ + // global $post; + + // $order_id = $post->ID; + + // $suppliers = Wiaas_Order::get_suppliers($order_id); + + // require 'views/html-order-delivery-dates.php'; + + } +} + +Wiaas_Admin_Order_Process_Flow::init(); \ No newline at end of file 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 new file mode 100644 index 0000000..b0b31ec --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php @@ -0,0 +1,65 @@ + + + + +
+

+
+ $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 new file mode 100644 index 0000000..48cedc8 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php @@ -0,0 +1,62 @@ + + + + +
+

Please select a process for the order:

+
+ $process){ + echo ''; + } + ?> +
+ + \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-admin.php b/backend/app/plugins/wiaas/includes/class-wiaas-admin.php index 497a74b..67bcd13 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-admin.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-admin.php @@ -20,6 +20,8 @@ class Wiaas_Admin { require_once dirname(__FILE__) . '/admin/class-wiaas-admin-documents.php'; // Admin organization interface require_once dirname(__FILE__) . '/admin/class-wiaas-admin-organization.php'; + // Admin order delivery process + require_once dirname(__FILE__) . '/admin/class-wiaas-admin-order-delivery-process.php'; require_once dirname(__FILE__) . '/admin/class-wiaas-admin-cl.php'; diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php index 34b58c3..328a2d0 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -19,8 +19,6 @@ class Wiaas_Delivery_Process { } private static function _init_hooks() { - add_action('woocommerce_new_order', array( __CLASS__, 'create_delivery_process_for_order' )); - add_filter( 'gform_entry_meta', array(__CLASS__, 'extend_gravity_form_entry_meta'), 10, 2 ); add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_process_step'), 5, 3 ); @@ -80,7 +78,25 @@ class Wiaas_Delivery_Process { $order = wc_get_order($order_id); $order->update_status('completed', 'Completed order delivery process.', true); } - } + } + + /** + * List available delivery processes + * + * @return array + */ + public static function get_available_delivery_processes(){ + $forms = GFFormsModel::search_forms( self::$process_form_title_prefix, true ); + $result = array(); + foreach($forms as $form){ + $result[] = array( + 'title' => str_replace(self::$process_form_title_prefix, '', $form->title), + 'id' => $form->id + ); + } + + return $result; + } /** * Retrieves delivery process instance for order @@ -92,7 +108,7 @@ class Wiaas_Delivery_Process { public static function get_order_delivery_process($order_id) { $process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id'); - if (!isset($process_entry_id)) { + if (empty($process_entry_id)) { return null; } @@ -132,13 +148,13 @@ class Wiaas_Delivery_Process { } /** - * Automatically create delivery process instance when order is created + * create delivery process instance * @param $order_id */ - public static function create_delivery_process_for_order($order_id) { + public static function create_delivery_process_for_order($order_id, $form_id) { $process_form = null; $forms = GFFormsModel::search_forms( self::$process_form_title_prefix, true ); - $process_form = $forms[0]; + $process_form = GFFormsModel::get_form($form_id); if(isset($process_form)) { $order = wc_get_order( $order_id ); $new_process_entry = array( @@ -150,7 +166,10 @@ class Wiaas_Delivery_Process { add_post_meta($order_id, 'wiaas_delivery_process_id', $process_form->id); add_post_meta($order_id, 'wiaas_delivery_process_entry_id', $process_entry_id); + + return true; } + return false; } /** From b91341c5dfc165c3105760d13b63a9e9f56e2e82 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 21 Oct 2018 16:43:52 +0200 Subject: [PATCH 05/24] add missing file --- ...iaas-admin-order-delivery-process-ajax.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php new file mode 100644 index 0000000..31e0337 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php @@ -0,0 +1,22 @@ + Date: Sun, 21 Oct 2018 16:54:50 +0200 Subject: [PATCH 06/24] add delivery process --- ...ry_process_smartoffice_implementation.json | 377 ++++++++++++++++++ .../db-updates/wiaas-db-update-general.php | 3 +- 2 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json b/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json new file mode 100644 index 0000000..b31a722 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json @@ -0,0 +1,377 @@ +{ + "0": { + "title": "DELIVERY PROCESS: SmartOffice implementation", + "description": " SmartOffice implementation", + "labelPlacement": "top_label", + "descriptionPlacement": "below", + "button": { + "type": "text", + "text": "Submit", + "imageUrl": "" + }, + "fields": [ + { + "type": "number", + "id": 1, + "label": "order-id", + "adminLabel": "order-id", + "isRequired": false, + "size": "medium", + "errorMessage": "", + "visibility": "visible", + "inputs": null, + "numberFormat": "decimal_dot", + "formId": 6, + "description": "", + "allowsPrepopulate": true, + "inputMask": false, + "inputMaskValue": "", + "inputType": "", + "labelPlacement": "", + "descriptionPlacement": "", + "subLabelPlacement": "", + "placeholder": "", + "cssClass": "", + "inputName": "order-id", + "noDuplicates": false, + "defaultValue": "", + "choices": "", + "conditionalLogic": "", + "enableCalculation": false, + "rangeMin": "", + "rangeMax": "", + "productField": "", + "multipleFiles": false, + "maxFiles": "", + "calculationFormula": "", + "calculationRounding": "", + "disableQuantity": false, + "displayAllCategories": false, + "useRichTextEditor": false, + "displayOnly": "", + "enablePrice": "" + }, + { + "type": "workflow_user", + "id": 2, + "label": "customer-id", + "adminLabel": "customer-id", + "isRequired": false, + "size": "medium", + "errorMessage": "", + "visibility": "visible", + "inputs": null, + "choices": [ + { + "value": 2, + "text": "BIlal Catic" + }, + { + "value": 3, + "text": "CL CL" + }, + { + "value": 5, + "text": "wdw wfd" + }, + { + "value": 4, + "text": "wdwCL CL" + }, + { + "value": 1, + "text": "wpUser" + } + ], + "formId": 6, + "description": "", + "allowsPrepopulate": true, + "inputMask": false, + "inputMaskValue": "", + "inputType": "", + "labelPlacement": "", + "descriptionPlacement": "", + "subLabelPlacement": "", + "placeholder": "", + "cssClass": "", + "inputName": "customer-id", + "noDuplicates": false, + "defaultValue": "", + "conditionalLogic": "", + "failed_validation": "", + "productField": "", + "multipleFiles": false, + "maxFiles": "", + "calculationFormula": "", + "calculationRounding": "", + "enableCalculation": "", + "disableQuantity": false, + "displayAllCategories": false, + "useRichTextEditor": false, + "displayOnly": "", + "enablePrice": "", + "gravityflowUsersRoleFilter": "" + } + ], + "version": "2.3.2", + "id": 6, + "useCurrentUserAsAuthor": true, + "postContentTemplateEnabled": false, + "postTitleTemplateEnabled": false, + "postTitleTemplate": "", + "postContentTemplate": "", + "lastPageButton": null, + "pagination": null, + "firstPageCssClass": null, + "is_active": "1", + "date_created": "2018-10-17 10:18:04", + "is_trash": "0", + "notifications": [ + { + "id": "5b5f7ae4baced", + "to": "{admin_email}", + "name": "Admin Notification", + "event": "form_submission", + "toType": "email", + "subject": "New submission from {form_title}", + "message": "{all_fields}", + "isActive": false + } + ], + "confirmations": [ + { + "id": "5b5f7ae4bb79e", + "name": "Default Confirmation", + "isDefault": true, + "type": "message", + "message": "Thanks for contacting us! We will get in touch with you shortly.", + "url": "", + "pageId": "", + "queryString": "" + } + ], + "subLabelPlacement": "below", + "cssClass": "", + "enableHoneypot": false, + "enableAnimation": false, + "save": { + "enabled": false, + "button": { + "type": "link", + "text": "Save and Continue Later" + } + }, + "limitEntries": false, + "limitEntriesCount": "", + "limitEntriesPeriod": "", + "limitEntriesMessage": "", + "scheduleForm": false, + "scheduleStart": "", + "scheduleStartHour": "", + "scheduleStartMinute": "", + "scheduleStartAmpm": "", + "scheduleEnd": "", + "scheduleEndHour": "", + "scheduleEndMinute": "", + "scheduleEndAmpm": "", + "schedulePendingMessage": "", + "scheduleMessage": "", + "requireLogin": false, + "requireLoginMessage": "", + "feeds": { + "gravityflow": [ + { + "id": "13", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Validate customer configuration information", + "description": "Validate customer configuration information", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "instructionsEnable": "0", + "instructionsValue": "", + "target_form_id": 3, + "store_new_entry_idEnable": "1", + "new_entry_id_field": "6", + "destination_complete": "next" + }, + "addon_slug": "gravityflow", + "event_type": null + }, + { + "id": "14", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Wait for installation to be scheduled and confirmed", + "description": "Wait for installation to be scheduled and confirmed", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "instructionsEnable": "0", + "instructionsValue": "", + "target_form_id": 4, + "store_new_entry_idEnable": "0", + "new_entry_id_field": "", + "destination_complete": "next" + }, + "addon_slug": "gravityflow", + "event_type": null + }, + { + "id": "15", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Installation", + "description": " Installation", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "instructionsEnable": "0", + "instructionsValue": "", + "target_form_id": 4, + "store_new_entry_idEnable": "0", + "new_entry_id_field": "", + "destination_complete": "next" + }, + "addon_slug": "gravityflow", + "event_type": null + }, + { + "id": "16", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Customer acceptance", + "description": "Customer acceptance", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "target_form_id": 1, + "store_new_entry_idEnable": "1", + "new_entry_id_field": "7", + "destination_complete": "next" + }, + "addon_slug": "gravityflow", + "event_type": null + }, + { + "id": "17", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Customer training", + "description": "Customer training", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "instructionsEnable": "0", + "instructionsValue": "", + "target_form_id": 4, + "store_new_entry_idEnable": "0", + "new_entry_id_field": "", + "destination_complete": "next", + "feedName": " - Copy 1" + }, + "addon_slug": "gravityflow", + "event_type": null + }, + { + "id": "18", + "form_id": "6", + "is_active": "1", + "feed_order": "0", + "meta": { + "step_name": "Finalise implementation phase", + "description": "Finalise implementation phase", + "step_type": "wiaas_delivery_step", + "step_highlight": "0", + "step_highlight_type": "color", + "step_highlight_color": "#dd3333", + "feed_condition_conditional_logic": "0", + "feed_condition_conditional_logic_object": [], + "scheduled": "0", + "schedule_type": "delay", + "schedule_date": "", + "schedule_delay_offset": "", + "schedule_delay_unit": "hours", + "schedule_date_field_offset": "0", + "schedule_date_field_offset_unit": "hours", + "schedule_date_field_before_after": "after", + "instructionsEnable": "0", + "instructionsValue": "", + "is_visible_to_customer": "1", + "target_form_id": "4", + "destination_complete": "next" + }, + "addon_slug": "gravityflow", + "event_type": null + } + ] + } + }, + "version": "2.3.2" +} \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php index b30421a..5c6086e 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php +++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php @@ -30,7 +30,8 @@ function wiaas_db_update_add_delivery_process_forms() { $action_type_forms_ids_mappings = array(); $process_forms_files = array( - 'delivery_process_normal_delivery_form' + 'delivery_process_normal_delivery_form', + 'delivery_process_smartoffice_implementation' ); $created_forms = array(); From 9aa3b3d04406e398b6c2f8d5a738805bc7ac3d58 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 21 Oct 2018 17:16:47 +0200 Subject: [PATCH 07/24] temporarily remove additional delivery process --- ...ry_process_smartoffice_implementation.json | 377 ------------------ .../db-updates/wiaas-db-update-general.php | 3 +- 2 files changed, 1 insertion(+), 379 deletions(-) delete mode 100644 backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json b/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json deleted file mode 100644 index b31a722..0000000 --- a/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery_process_smartoffice_implementation.json +++ /dev/null @@ -1,377 +0,0 @@ -{ - "0": { - "title": "DELIVERY PROCESS: SmartOffice implementation", - "description": " SmartOffice implementation", - "labelPlacement": "top_label", - "descriptionPlacement": "below", - "button": { - "type": "text", - "text": "Submit", - "imageUrl": "" - }, - "fields": [ - { - "type": "number", - "id": 1, - "label": "order-id", - "adminLabel": "order-id", - "isRequired": false, - "size": "medium", - "errorMessage": "", - "visibility": "visible", - "inputs": null, - "numberFormat": "decimal_dot", - "formId": 6, - "description": "", - "allowsPrepopulate": true, - "inputMask": false, - "inputMaskValue": "", - "inputType": "", - "labelPlacement": "", - "descriptionPlacement": "", - "subLabelPlacement": "", - "placeholder": "", - "cssClass": "", - "inputName": "order-id", - "noDuplicates": false, - "defaultValue": "", - "choices": "", - "conditionalLogic": "", - "enableCalculation": false, - "rangeMin": "", - "rangeMax": "", - "productField": "", - "multipleFiles": false, - "maxFiles": "", - "calculationFormula": "", - "calculationRounding": "", - "disableQuantity": false, - "displayAllCategories": false, - "useRichTextEditor": false, - "displayOnly": "", - "enablePrice": "" - }, - { - "type": "workflow_user", - "id": 2, - "label": "customer-id", - "adminLabel": "customer-id", - "isRequired": false, - "size": "medium", - "errorMessage": "", - "visibility": "visible", - "inputs": null, - "choices": [ - { - "value": 2, - "text": "BIlal Catic" - }, - { - "value": 3, - "text": "CL CL" - }, - { - "value": 5, - "text": "wdw wfd" - }, - { - "value": 4, - "text": "wdwCL CL" - }, - { - "value": 1, - "text": "wpUser" - } - ], - "formId": 6, - "description": "", - "allowsPrepopulate": true, - "inputMask": false, - "inputMaskValue": "", - "inputType": "", - "labelPlacement": "", - "descriptionPlacement": "", - "subLabelPlacement": "", - "placeholder": "", - "cssClass": "", - "inputName": "customer-id", - "noDuplicates": false, - "defaultValue": "", - "conditionalLogic": "", - "failed_validation": "", - "productField": "", - "multipleFiles": false, - "maxFiles": "", - "calculationFormula": "", - "calculationRounding": "", - "enableCalculation": "", - "disableQuantity": false, - "displayAllCategories": false, - "useRichTextEditor": false, - "displayOnly": "", - "enablePrice": "", - "gravityflowUsersRoleFilter": "" - } - ], - "version": "2.3.2", - "id": 6, - "useCurrentUserAsAuthor": true, - "postContentTemplateEnabled": false, - "postTitleTemplateEnabled": false, - "postTitleTemplate": "", - "postContentTemplate": "", - "lastPageButton": null, - "pagination": null, - "firstPageCssClass": null, - "is_active": "1", - "date_created": "2018-10-17 10:18:04", - "is_trash": "0", - "notifications": [ - { - "id": "5b5f7ae4baced", - "to": "{admin_email}", - "name": "Admin Notification", - "event": "form_submission", - "toType": "email", - "subject": "New submission from {form_title}", - "message": "{all_fields}", - "isActive": false - } - ], - "confirmations": [ - { - "id": "5b5f7ae4bb79e", - "name": "Default Confirmation", - "isDefault": true, - "type": "message", - "message": "Thanks for contacting us! We will get in touch with you shortly.", - "url": "", - "pageId": "", - "queryString": "" - } - ], - "subLabelPlacement": "below", - "cssClass": "", - "enableHoneypot": false, - "enableAnimation": false, - "save": { - "enabled": false, - "button": { - "type": "link", - "text": "Save and Continue Later" - } - }, - "limitEntries": false, - "limitEntriesCount": "", - "limitEntriesPeriod": "", - "limitEntriesMessage": "", - "scheduleForm": false, - "scheduleStart": "", - "scheduleStartHour": "", - "scheduleStartMinute": "", - "scheduleStartAmpm": "", - "scheduleEnd": "", - "scheduleEndHour": "", - "scheduleEndMinute": "", - "scheduleEndAmpm": "", - "schedulePendingMessage": "", - "scheduleMessage": "", - "requireLogin": false, - "requireLoginMessage": "", - "feeds": { - "gravityflow": [ - { - "id": "13", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Validate customer configuration information", - "description": "Validate customer configuration information", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "instructionsEnable": "0", - "instructionsValue": "", - "target_form_id": 3, - "store_new_entry_idEnable": "1", - "new_entry_id_field": "6", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "14", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Wait for installation to be scheduled and confirmed", - "description": "Wait for installation to be scheduled and confirmed", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "instructionsEnable": "0", - "instructionsValue": "", - "target_form_id": 4, - "store_new_entry_idEnable": "0", - "new_entry_id_field": "", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "15", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Installation", - "description": " Installation", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "instructionsEnable": "0", - "instructionsValue": "", - "target_form_id": 4, - "store_new_entry_idEnable": "0", - "new_entry_id_field": "", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "16", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Customer acceptance", - "description": "Customer acceptance", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "target_form_id": 1, - "store_new_entry_idEnable": "1", - "new_entry_id_field": "7", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "17", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Customer training", - "description": "Customer training", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "instructionsEnable": "0", - "instructionsValue": "", - "target_form_id": 4, - "store_new_entry_idEnable": "0", - "new_entry_id_field": "", - "destination_complete": "next", - "feedName": " - Copy 1" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "18", - "form_id": "6", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Finalise implementation phase", - "description": "Finalise implementation phase", - "step_type": "wiaas_delivery_step", - "step_highlight": "0", - "step_highlight_type": "color", - "step_highlight_color": "#dd3333", - "feed_condition_conditional_logic": "0", - "feed_condition_conditional_logic_object": [], - "scheduled": "0", - "schedule_type": "delay", - "schedule_date": "", - "schedule_delay_offset": "", - "schedule_delay_unit": "hours", - "schedule_date_field_offset": "0", - "schedule_date_field_offset_unit": "hours", - "schedule_date_field_before_after": "after", - "instructionsEnable": "0", - "instructionsValue": "", - "is_visible_to_customer": "1", - "target_form_id": "4", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - } - ] - } - }, - "version": "2.3.2" -} \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php index 5c6086e..b30421a 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php +++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php @@ -30,8 +30,7 @@ function wiaas_db_update_add_delivery_process_forms() { $action_type_forms_ids_mappings = array(); $process_forms_files = array( - 'delivery_process_normal_delivery_form', - 'delivery_process_smartoffice_implementation' + 'delivery_process_normal_delivery_form' ); $created_forms = array(); From 1f03563d2e085a88452503ecf101a288d0e7bbb8 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 25 Oct 2018 15:16:41 +0200 Subject: [PATCH 08/24] replace buttons with dropdown --- .../views/html-order-select-delivery-process.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 index 48cedc8..4969d8c 100644 --- 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 @@ -26,24 +26,27 @@ if ( ! defined( 'ABSPATH' ) ) {

Please select a process for the order:


+
\ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php new file mode 100644 index 0000000..dc8d28a --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php @@ -0,0 +1,38 @@ + + +

+ + +

+ + \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php index 31e0337..71ec01e 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-order-delivery-process-ajax.php @@ -1,6 +1,12 @@ get_meta('_wiaas_order_additional_days_prior_installation'); + } + + public static function add_additional_tracking_info($order_id, $supplier_id){ + $suppliers = self::get_suppliers($order_id); + foreach($suppliers as $key => $supplier){ + if ($supplier['id'] === $supplier_id){ + $suppliers[$key]['tracking_info'][] = array( + 'number' => '', + 'url' => '' + ); + + //not working + //$order = wc_get_order($order_id); + //$order->update_meta_data('_wiaas_suppliers', $suppliers); + return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + } + } + + return false; + } + + public static function save_tracking_info($order_id, $supplier_id, $tracking_index, $tracking_num, $tracking_url){ + $suppliers = self::get_suppliers($order_id); + foreach($suppliers as $key => $supplier){ + if ($supplier['id'] === $supplier_id){ + $suppliers[$key]['tracking_info'][$tracking_index]['number'] = $tracking_num; + $suppliers[$key]['tracking_info'][$tracking_index]['url'] = $tracking_url; + + //not working + //$order = wc_get_order($order_id); + //$order->update_meta_data('_wiaas_suppliers', $suppliers); + return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + } + } + + return false; + } + + public static function delete_tracking_info($order_id, $supplier_id, $tracking_index){ + $suppliers = self::get_suppliers($order_id); + foreach($suppliers as $key => $supplier){ + if ($supplier['id'] === $supplier_id){ + unset($suppliers[$key]['tracking_info'][$tracking_index]); + + //not working + //$order = wc_get_order($order_id); + //$order->update_meta_data('_wiaas_suppliers', $suppliers); + return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + } + } + + return false; + } + + public static function save_estimated_date($order_id, $supplier_id, $date){ + $suppliers = self::get_suppliers($order_id); + $result = false; + + foreach($suppliers as $key => $supplier){ + if ($supplier['id'] === $supplier_id){ + $suppliers[$key]['estimated_date'] = $date; + } + } + + $result = update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + self::_update_max_and_earliest_dates($order_id); + //Not working + //$order = wc_get_order($order_id); + //$order->update_meta_data('_wiaas_suppliers', $suppliers); + + return $result; + } + + public static function save_confirmed_date($order_id, $supplier_id, $date){ + $suppliers = self::get_suppliers($order_id); + $result = false; + foreach($suppliers as $key => $supplier){ + if ($supplier['id'] === $supplier_id){ + $suppliers[$key]['confirmed_date'] = $date; + if (!$suppliers[$key]['estimated_date']){ + $suppliers[$key]['estimated_date'] = $date; + } + } + } + + + $result = update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + self::_update_max_and_earliest_dates($order_id); + //Not working + //$order = wc_get_order($order_id); + //$order->update_meta_data('_wiaas_suppliers', $suppliers); + return $result; + } + + public static function get_global_estimated_date($order_id){ + $order = wc_get_order($order_id); + if (!$order){ + return NULL; + } + + return $order->get_meta('_wiaas_global_estimated_delivery_date') ?: NULL; + } + + public static function save_global_estimated_date($order_id, $date){ + return update_post_meta($order_id, '_wiaas_global_estimated_delivery_date', $date); + } + + public static function get_final_estimated_date($order_id){ + $order = wc_get_order($order_id); + if (!$order){ + return 0; + } + + return $order->get_meta('_wiaas_final_estimated_delivery_date') ?: 0; + } + + public static function get_final_confirmed_date($order_id){ + $order = wc_get_order($order_id); + if (!$order){ + return 0; + } + + return $order->get_meta('_wiaas_final_confirmed_delivery_date') ?: 0; + } + + public static function get_earliest_installation_date($order_id){ + $order = wc_get_order($order_id); + if (!$order){ + return 0; + } + + return $order->get_meta('_wiaas_earliest_installation_date') ?: 0; + } + + + /** + * Get suppliers related to order + */ + public static function get_suppliers($order_id){ + $order = wc_get_order($order_id); + return $order->get_meta('_wiaas_suppliers'); + } + /** * Update `shop_order` post type settings before creation to enable better order management for wiaas * @@ -190,12 +336,68 @@ class Wiaas_Order { public static function get_order_tender($order_id) { return get_post_meta($order_id, '_wiaas_tender', true); - } + } /** * PRIVATE */ + private static function _update_max_and_earliest_dates($order_id){ + $suppliers = self::get_suppliers($order_id); + + $max_estimated_date = 0; + $max_confirmed_date = 0; + $earliest_installation_date = 0; + $missing_estimated = false; + $missing_confirmed = false; + $no_earliest = false; + + foreach($suppliers as $supplier){ + if (!$supplier['estimated_date']){ + $missing_estimated = true; + } + if (!$supplier['confirmed_date']){ + $missing_confirmed = true; + } + + if ($supplier['estimated_date'] > $max_estimated_date){ + $max_estimated_date = $supplier['estimated_date']; + } + if ($supplier['confirmed_date'] > $max_confirmed_date){ + $max_confirmed_date = $supplier['confirmed_date']; + } + + if (!$no_earliest){ + $supplier_date = $supplier['estimated_date']; + if ($supplier['confirmed_date'] > $supplier_date){ + $supplier_date = $supplier['confirmed_date']; + } + if ($supplier_date > 0){ + if ($supplier_date > $earliest_installation_date){ + $earliest_installation_date = $supplier_date; + } + }else{ + $no_earliest = true; + $earliest_installation_date = 0; + } + } + } + + if ($missing_estimated && $missing_confirmed){ + $no_earliest = true; + $earliest_installation_date = 0; + } + + if (!$no_earliest){ + $earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order_id) . ' days', $earliest_installation_date); + } + + update_post_meta($order_id, '_wiaas_final_confirmed_delivery_date', $max_confirmed_date); + update_post_meta($order_id, '_wiaas_final_estimated_delivery_date', $max_estimated_date); + update_post_meta($order_id, '_wiaas_earliest_installation_date', $earliest_installation_date); + + } + /** * Append specific wiaas order details, like reference * @param $data diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-product.php b/backend/app/plugins/wiaas/includes/class-wiaas-product.php index 9bddd4a..ba44118 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-product.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-product.php @@ -70,6 +70,10 @@ class Wiaas_Product { return $args; } + + public static function get_supplier_id($product_id){ + return get_field('supplier', $product_id) ?: NULL; + } } Wiaas_Product::init(); \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-user.php b/backend/app/plugins/wiaas/includes/class-wiaas-user.php index 5aaa4c2..6158bb5 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-user.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-user.php @@ -10,6 +10,7 @@ class Wiaas_User { public static function init() { include_once dirname( __FILE__ ) . '/class-wiaas-countries.php'; include_once dirname( __FILE__ ) . '/user/class-wiaas-customer.php'; + include_once dirname( __FILE__ ) . '/user/class-wiaas-supplier.php'; add_action('init', array(__CLASS__, 'load_user_organization')); add_action('plugins_loaded', array(__CLASS__, 'remove_default_user_groups'), 30); diff --git a/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php b/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php new file mode 100644 index 0000000..b328f36 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php @@ -0,0 +1,14 @@ + Date: Wed, 31 Oct 2018 12:53:34 +0100 Subject: [PATCH 13/24] change style --- .../delivery-process/views/html-order-delivery-dates.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 55d3431..574903a 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 @@ -8,10 +8,13 @@ if ( ! defined( 'ABSPATH' ) ) {
- - - + + + + + + Date: Thu, 1 Nov 2018 00:55:01 +0100 Subject: [PATCH 14/24] use existing function to get supplier name --- .../plugins/wiaas/includes/class-wiaas-cart.php | 2 +- .../wiaas/includes/user/class-wiaas-supplier.php | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 140b43a..35eae1e 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -440,7 +440,7 @@ class Wiaas_Cart { if ($product->is_type('simple') && !Wiaas_Product_Category::is_installation($product)){ $supplier_id = Wiaas_Product::get_supplier_id($product->id); - $supplier_name = Wiaas_Supplier::get_name($supplier_id); + $supplier_name = wiaas_get_organization_name($supplier_id); $suppliers[] = array( 'id' => $supplier_id, 'name' => $supplier_name, diff --git a/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php b/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php deleted file mode 100644 index b328f36..0000000 --- a/backend/app/plugins/wiaas/includes/user/class-wiaas-supplier.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Thu, 1 Nov 2018 00:55:14 +0100 Subject: [PATCH 15/24] rename files and classes --- ...process.php => class-wiaas-admin-delivery-process.php} | 8 ++++---- ...ow.php => class-wiaas-admin-delivery-process-flow.php} | 0 ...ess-ajax.php => wiaas-admin-delivery-process-ajax.php} | 0 backend/app/plugins/wiaas/includes/class-wiaas-admin.php | 2 +- backend/app/plugins/wiaas/includes/class-wiaas-user.php | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) rename backend/app/plugins/wiaas/includes/admin/{class-wiaas-admin-order-delivery-process.php => class-wiaas-admin-delivery-process.php} (50%) rename backend/app/plugins/wiaas/includes/admin/delivery-process/{class-wiaas-admin-order-delivery-process-flow.php => class-wiaas-admin-delivery-process-flow.php} (100%) rename backend/app/plugins/wiaas/includes/admin/delivery-process/{wiaas-admin-order-delivery-process-ajax.php => wiaas-admin-delivery-process-ajax.php} (100%) diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php similarity index 50% rename from backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php rename to backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php index 3648dae..af25908 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-order-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php @@ -1,11 +1,11 @@ Date: Thu, 1 Nov 2018 19:39:19 +0100 Subject: [PATCH 16/24] use order update meta --- .../wiaas/includes/class-wiaas-order.php | 79 ++++++++++--------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-order.php b/backend/app/plugins/wiaas/includes/class-wiaas-order.php index d4669dc..423f939 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-order.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-order.php @@ -58,10 +58,10 @@ class Wiaas_Order { 'url' => '' ); - //not working - //$order = wc_get_order($order_id); - //$order->update_meta_data('_wiaas_suppliers', $suppliers); - return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + $order = wc_get_order($order_id); + $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->save_meta_data(); + return true; } } @@ -75,10 +75,11 @@ class Wiaas_Order { $suppliers[$key]['tracking_info'][$tracking_index]['number'] = $tracking_num; $suppliers[$key]['tracking_info'][$tracking_index]['url'] = $tracking_url; - //not working - //$order = wc_get_order($order_id); - //$order->update_meta_data('_wiaas_suppliers', $suppliers); - return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + + $order = wc_get_order($order_id); + $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->save_meta_data(); + return true; } } @@ -91,10 +92,10 @@ class Wiaas_Order { if ($supplier['id'] === $supplier_id){ unset($suppliers[$key]['tracking_info'][$tracking_index]); - //not working - //$order = wc_get_order($order_id); - //$order->update_meta_data('_wiaas_suppliers', $suppliers); - return update_post_meta($order_id, '_wiaas_suppliers', $suppliers); + $order = wc_get_order($order_id); + $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->save_meta_data(); + return true; } } @@ -103,42 +104,51 @@ class Wiaas_Order { public static function save_estimated_date($order_id, $supplier_id, $date){ $suppliers = self::get_suppliers($order_id); - $result = false; - + $updated = false; foreach($suppliers as $key => $supplier){ if ($supplier['id'] === $supplier_id){ $suppliers[$key]['estimated_date'] = $date; + $updated = true; } } - - $result = update_post_meta($order_id, '_wiaas_suppliers', $suppliers); - self::_update_max_and_earliest_dates($order_id); - //Not working - //$order = wc_get_order($order_id); - //$order->update_meta_data('_wiaas_suppliers', $suppliers); - return $result; + if (!$updated){ + return false; + } + + $order = wc_get_order($order_id); + + $order->update_meta_data('_wiaas_suppliers', $suppliers); + self::_update_max_and_earliest_dates($order, $suppliers); + + $order->save_meta_data(); + return true; } public static function save_confirmed_date($order_id, $supplier_id, $date){ $suppliers = self::get_suppliers($order_id); - $result = false; + $updated = false; foreach($suppliers as $key => $supplier){ if ($supplier['id'] === $supplier_id){ $suppliers[$key]['confirmed_date'] = $date; + $updated = true; if (!$suppliers[$key]['estimated_date']){ $suppliers[$key]['estimated_date'] = $date; } } } + if (!$updated){ + return false; + } + + $order = wc_get_order($order_id); - $result = update_post_meta($order_id, '_wiaas_suppliers', $suppliers); - self::_update_max_and_earliest_dates($order_id); - //Not working - //$order = wc_get_order($order_id); - //$order->update_meta_data('_wiaas_suppliers', $suppliers); - return $result; + $order->update_meta_data('_wiaas_suppliers', $suppliers); + self::_update_max_and_earliest_dates($order, $suppliers); + + $order->save_meta_data(); + return true; } public static function get_global_estimated_date($order_id){ @@ -342,9 +352,7 @@ class Wiaas_Order { * PRIVATE */ - private static function _update_max_and_earliest_dates($order_id){ - $suppliers = self::get_suppliers($order_id); - + private static function _update_max_and_earliest_dates($order, $suppliers){ $max_estimated_date = 0; $max_confirmed_date = 0; $earliest_installation_date = 0; @@ -389,13 +397,12 @@ class Wiaas_Order { } if (!$no_earliest){ - $earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order_id) . ' days', $earliest_installation_date); + $earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order->id) . ' days', $earliest_installation_date); } - update_post_meta($order_id, '_wiaas_final_confirmed_delivery_date', $max_confirmed_date); - update_post_meta($order_id, '_wiaas_final_estimated_delivery_date', $max_estimated_date); - update_post_meta($order_id, '_wiaas_earliest_installation_date', $earliest_installation_date); - + $order->update_meta_data('_wiaas_final_confirmed_delivery_date', $max_confirmed_date); + $order->update_meta_data('_wiaas_final_estimated_delivery_date', $max_estimated_date); + $order->update_meta_data('_wiaas_earliest_installation_date', $earliest_installation_date); } /** From 3af91a71d7fee4a905aca0421abe5110fbd7fa7e Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 1 Nov 2018 19:54:30 +0100 Subject: [PATCH 17/24] use acf field for additional days prior installation --- .../admin/class-wiaas-admin-package.php | 1 - ...s-wiaas-admin-package-delivery-options.php | 43 ------------------- .../views/html-package-delivery-options.php | 16 ------- .../wiaas/includes/class-wiaas-package.php | 15 +------ .../wiaas-ui-field-bundle-properties.json | 21 +++++++++ 5 files changed, 22 insertions(+), 74 deletions(-) delete mode 100644 backend/app/plugins/wiaas/includes/admin/package/class-wiaas-admin-package-delivery-options.php delete mode 100644 backend/app/plugins/wiaas/includes/admin/package/views/html-package-delivery-options.php diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-package.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-package.php index 1b168b8..d94b2fd 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-package.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-package.php @@ -10,7 +10,6 @@ class Wiaas_Admin_Package { require_once dirname( __FILE__ ) . '/package/class-wiaas-admin-linked-packages.php'; require_once dirname( __FILE__ ) . '/package/class-wiaas-admin-package-types.php'; - require_once dirname( __FILE__ ) . '/package/class-wiaas-admin-package-delivery-options.php'; add_action( 'manage_product_posts_columns', array( __CLASS__, 'manage_list_table_products_columns' ), 999, 2 ); add_action( 'woocommerce_product_data_tabs', array( __CLASS__, 'package_data_tabs' ), 999); diff --git a/backend/app/plugins/wiaas/includes/admin/package/class-wiaas-admin-package-delivery-options.php b/backend/app/plugins/wiaas/includes/admin/package/class-wiaas-admin-package-delivery-options.php deleted file mode 100644 index 4c8ff5b..0000000 --- a/backend/app/plugins/wiaas/includes/admin/package/class-wiaas-admin-package-delivery-options.php +++ /dev/null @@ -1,43 +0,0 @@ -ID ); - - include 'views/html-package-delivery-options.php'; - } - - /** - * Saves posted wiaas package type data - * @param $package_id - */ - public static function process_meta_box($package_id) { - - if (isset($_POST['wiaas_additional_days'])){ - Wiaas_Package::save_earliest_installation_additional_days($package_id, $_POST['wiaas_additional_days']); - } - } -} - -Wiaas_Admin_Package_Delivery_Options::init(); \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/admin/package/views/html-package-delivery-options.php b/backend/app/plugins/wiaas/includes/admin/package/views/html-package-delivery-options.php deleted file mode 100644 index 1308d17..0000000 --- a/backend/app/plugins/wiaas/includes/admin/package/views/html-package-delivery-options.php +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-package.php b/backend/app/plugins/wiaas/includes/class-wiaas-package.php index 41ccd43..e1527b0 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-package.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-package.php @@ -49,20 +49,7 @@ class Wiaas_Package { } public static function get_earliest_installation_additional_days($package_id){ - $additional_days = get_post_meta($package_id, '_wiaas_additional_days_prior_installation', true); - if ($additional_days === ''){ - //Value was not set before, default to 5 - add_post_meta($package_id, '_wiaas_additional_days_prior_installation', 5, true); - return 5; - } - return $additional_days; - } - - public static function save_earliest_installation_additional_days($package_id, $additional_days){ - if (intval($additional_days) < 0){ - return false; - } - return update_post_meta($package_id, '_wiaas_additional_days_prior_installation', intval($additional_days)); + return get_post_meta($package_id, 'additional_days_prior_earliest_installation', true); } /** diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json index 6eaf16d..d5de4dc 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json +++ b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json @@ -46,6 +46,27 @@ "load_terms": 1, "return_format": "id", "multiple": 0 + }, + { + "key": "field_5bdb1512ab14f", + "label": "Additional days prior earliest installation", + "name": "additional_days_prior_earliest_installation", + "type": "number", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": 5, + "placeholder": "", + "prepend": "", + "append": "", + "min": 0, + "max": "", + "step": "" } ], "location": [ From f8e3cc587579a40702e9cf294d41b428f085a517 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 1 Nov 2018 19:57:14 +0100 Subject: [PATCH 18/24] move formatting to view --- ...lass-wiaas-admin-delivery-process-flow.php | 19 ------------------- .../views/html-order-delivery-dates.php | 6 +++--- 2 files changed, 3 insertions(+), 22 deletions(-) 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 0ab60e8..1598770 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 @@ -63,25 +63,6 @@ class Wiaas_Admin_Order_Process_Flow { $final_confirmed_date = Wiaas_Order::get_final_confirmed_date($order_id); $earliest_installation_date = Wiaas_Order::get_earliest_installation_date($order_id); - - if ($final_estimated_date === 0){ - $final_estimated_date = '-'; - }else{ - $final_estimated_date = date('Y-m-d', $final_estimated_date); - } - - if ($final_confirmed_date === 0){ - $final_confirmed_date = '-'; - }else{ - $final_confirmed_date = date('Y-m-d', $final_confirmed_date); - } - - if ($earliest_installation_date === 0){ - $earliest_installation_date = '-'; - }else{ - $earliest_installation_date = date('Y-m-d', $earliest_installation_date); - } - require 'views/html-order-delivery-dates.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 574903a..90b6429 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 @@ -68,15 +68,15 @@ if ( ! defined( 'ABSPATH' ) ) { - - + + - +
SuppliersEstimated dateConfirmed dateSuppliersEstimated dateConfirmed date

Final dates :


Earliest installation date :

From c08c393b2deb9f02c5663707b20b96f756571b26 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 1 Nov 2018 20:19:35 +0100 Subject: [PATCH 19/24] use taxonomy for supplier id --- backend/app/plugins/wiaas/includes/class-wiaas-product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-product.php b/backend/app/plugins/wiaas/includes/class-wiaas-product.php index ba44118..73f5a82 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-product.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-product.php @@ -72,7 +72,7 @@ class Wiaas_Product { } public static function get_supplier_id($product_id){ - return get_field('supplier', $product_id) ?: NULL; + return wp_get_post_terms($product_id, 'supplier', array('fields' => 'ids'))[0]; } } From a059f4b83d1010f67b09a5b62dd6631bc536c356 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 2 Nov 2018 04:09:53 +0100 Subject: [PATCH 20/24] save items related to supplier in supplier list --- .../wiaas/includes/class-wiaas-cart.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 35eae1e..b18881c 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -441,18 +441,22 @@ class Wiaas_Cart { if ($product->is_type('simple') && !Wiaas_Product_Category::is_installation($product)){ $supplier_id = Wiaas_Product::get_supplier_id($product->id); $supplier_name = wiaas_get_organization_name($supplier_id); - $suppliers[] = array( - 'id' => $supplier_id, - 'name' => $supplier_name, - 'estimated_date' => NULL, - 'confirmed_date' => NULL, - 'tracking_info' => array() - ); + if (!isset($suppliers[$supplier_id])){ + $suppliers[$supplier_id] = array( + 'id' => $supplier_id, + 'name' => $supplier_name, + 'estimated_date' => NULL, + 'confirmed_date' => NULL, + 'tracking_info' => array(), + 'items' => array($product->id) + ); + }else{ + $suppliers[$supplier_id]['items'][] = $product->id; + } } } - $filtered_suppliers = array_unique($suppliers, SORT_REGULAR); - $order->add_meta_data('_wiaas_suppliers', $filtered_suppliers, true); + $order->add_meta_data('_wiaas_suppliers', $suppliers, true); // add additional date fields to order $order->add_meta_data('_wiaas_global_estimated_delivery_date', NULL, true); From 2a3f2f8245258ea13ef451da519382a704878115 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 2 Nov 2018 11:21:19 +0100 Subject: [PATCH 21/24] fix formatting --- .../class-wiaas-admin-delivery-process-flow.php | 1 - .../delivery-process/views/html-order-global-delivery-date.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) 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 1598770..158ab18 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 @@ -29,7 +29,6 @@ class Wiaas_Admin_Order_Process_Flow { public static function add_custom_fields_after_order_details($order){ $global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id); - $formated_global_estimated_delivery_date = $global_estimated_delivery_date ? date("Y-m-d", $global_estimated_delivery_date) : ""; $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-global-delivery-date.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php index dc8d28a..ecfaeaf 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php @@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {

" onChange="onGlobalEstimatedDeliveryDateChange(this.value)"/>

From 93e17817dcda6e9fbdc787e3c6fd746c69bc7bdb Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sat, 3 Nov 2018 05:15:38 +0100 Subject: [PATCH 22/24] move date selection to workflow --- .../css/wiaas-admin-delivery-process.css | 15 ++++ .../assets/js/wiaas-admin-delivery-process.js | 23 ++++++ .../class-wiaas-admin-delivery-process.php | 10 +++ ...lass-wiaas-admin-delivery-process-flow.php | 74 ++++++++++--------- .../views/html-order-delivery-dates.php | 17 ++--- .../views/html-order-process-flow.php | 65 ---------------- .../html-order-select-delivery-process.php | 65 ---------------- 7 files changed, 95 insertions(+), 174 deletions(-) create mode 100644 backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css create mode 100644 backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js delete mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-process-flow.php delete mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-select-delivery-process.php 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 ''; } } - 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 From 01b35dbac590cd593a1d837fe0598f77994ac454 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sat, 3 Nov 2018 05:29:37 +0100 Subject: [PATCH 23/24] rename --- .../class-wiaas-admin-delivery-process-flow.php | 6 +++--- ...-delivery-date.php => html-order-delivery-date.php} | 10 +++++----- ...tes.php => html-order-suppliers-delivery-dates.php} | 0 .../wiaas-admin-delivery-process-ajax.php | 8 ++++---- .../app/plugins/wiaas/includes/class-wiaas-cart.php | 2 +- .../app/plugins/wiaas/includes/class-wiaas-order.php | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) rename backend/app/plugins/wiaas/includes/admin/delivery-process/views/{html-order-global-delivery-date.php => html-order-delivery-date.php} (70%) rename backend/app/plugins/wiaas/includes/admin/delivery-process/views/{html-order-delivery-dates.php => html-order-suppliers-delivery-dates.php} (100%) 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 efe7acd..bb43021 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 @@ -27,7 +27,7 @@ class Wiaas_Admin_Order_Process_Flow { $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'; + require 'views/html-order-suppliers-delivery-dates.php'; } public static function add_process_flow_meta_box(){ @@ -64,10 +64,10 @@ class Wiaas_Admin_Order_Process_Flow { } public static function add_custom_fields_after_order_details($order){ - $global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id); + $order_estimated_delivery_date = Wiaas_Order::get_order_estimated_date($order->id); $order_id = $order->id; - require 'views/html-order-global-delivery-date.php'; + require 'views/html-order-delivery-date.php'; } } diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php similarity index 70% rename from backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php rename to backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php index ecfaeaf..10f6ec7 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-global-delivery-date.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php @@ -7,12 +7,12 @@ if ( ! defined( 'ABSPATH' ) ) {

" - onChange="onGlobalEstimatedDeliveryDateChange(this.value)"/> + type="date" value="" + onChange="onOrderEstimatedDeliveryDateChange(this.value)"/>

Suppliers

Final dates :

Final dates :


Earliest installation date :

Earliest installation date :