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 a108d4d..877c5b2 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 @@ -90,7 +90,7 @@ class Wiaas_Admin_Order_Process_Flow { $order_id = $entry['wiaas_delivery_order_id']; - $suppliers = wiaas_get_order_delivery_suppliers($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); @@ -102,6 +102,24 @@ class Wiaas_Admin_Order_Process_Flow { $admin_action = rgpost( 'wiaas_delivery_process_navigation_action' ); + if ($admin_action === 'complete') { + + $api = new Gravity_Flow_API( $form['id'] ); + + $current_step = $api->get_current_step($entry); + + if ( $current_step ) { + $current_step->purge_assignees(); + $current_step->update_step_status( 'complete' ); + } + + $api->process_workflow($entry['id']); + + $feedback = esc_html__( 'Workflow Complete', 'wiaas' ); + + return $feedback; + } + list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 ); if ( $base_admin_action == 'send_to_step' ) { @@ -162,11 +180,12 @@ class Wiaas_Admin_Order_Process_Flow { class="button button-primary wiaas_delivery_step_nav" - style="float:right; margin-left: 20px;" value="NEXT STEP"> + style="float:right; margin-left: 20px;" + value="" + > get_items('line_item'); foreach($items as $item) { - if (! empty($item['wiaas_supplier_organization_id']) && - empty($suppliers_info[$item['wiaas_supplier_organization_id']]) ) { + $supplier_organization_id = $item['wiaas_supplier_organization_id']; + + if (! empty($supplier_organization_id) && $item['wiaas_category'] !== 'installation' && + empty($suppliers_info[$supplier_organization_id]) ) { - $supplier_organization_id = $item['wiaas_supplier_organization_id']; $suppliers_info[$supplier_organization_id] = array( 'id' => $supplier_organization_id, 'estimated_delivery_date' => null, @@ -491,9 +501,23 @@ class Wiaas_Cart { $suppliers_info[$supplier_organization_id][$key] = $info; } } + + if (! empty($supplier_organization_id) && $item['wiaas_category'] === 'installation' && + empty($installation_suppliers_info[$supplier_organization_id]) ) { + + $installation_suppliers_info[$supplier_organization_id] = array( + 'id' => $supplier_organization_id, + ); + + $supplier_organization_info = wiaas_get_organization_info($supplier_organization_id); + foreach ($supplier_organization_info as $key => $info) { + $installation_suppliers_info[$supplier_organization_id][$key] = $info; + } + } } - $order->add_meta_data('_wiaas_suppliers', $suppliers_info, true); + $order->add_meta_data('_wiaas_delivery_suppliers', $suppliers_info, true); + $order->add_meta_data('_wiaas_installation_suppliers', $installation_suppliers_info, true); // add additional date fields to order $order->add_meta_data('_wiaas_estimated_delivery_date', null, true); 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 5ba59d4..b1cd25d 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -85,10 +85,10 @@ class Wiaas_Delivery_Process { * @param $form */ public static function maybe_complete_parent_order($entry_id, $form) { + $entry = GFAPI::get_entry($entry_id); - $order_field = GFCommon::get_fields_by_type($form, 'wiaas_order')[0]; - $order_id = empty($order_field) ? null : absint($entry[$order_field->id]); + $order_id = $entry['wiaas_delivery_order_id']; if (!isset($order_id)) { return; @@ -97,7 +97,7 @@ class Wiaas_Delivery_Process { $process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true); // order process entry completed, so complete order - if (absint($process_entry_id) === $entry_id) { + if (absint($process_entry_id) === absint($entry_id)) { $order = wc_get_order($order_id); $order->update_status('completed', 'Completed order delivery process.', true); } diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-order.php b/backend/app/plugins/wiaas/includes/class-wiaas-order.php index 537ac33..718acb2 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-order.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-order.php @@ -61,7 +61,7 @@ class Wiaas_Order { ); $order = wc_get_order($order_id); - $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->update_meta_data('_wiaas_delivery_suppliers', $suppliers); $order->save_meta_data(); return true; } @@ -79,7 +79,7 @@ class Wiaas_Order { $order = wc_get_order($order_id); - $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->update_meta_data('_wiaas_delivery_suppliers', $suppliers); $order->save_meta_data(); return true; } @@ -95,7 +95,7 @@ class Wiaas_Order { unset($suppliers[$key]['tracking_info'][$tracking_index]); $order = wc_get_order($order_id); - $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->update_meta_data('_wiaas_delivery_suppliers', $suppliers); $order->save_meta_data(); return true; } @@ -105,7 +105,7 @@ class Wiaas_Order { } public static function save_estimated_date($order_id, $supplier_id, $date){ - $suppliers = wiaas_get_order_delivery_suppliers($order_id); + $suppliers = self::get_suppliers($order_id); $updated = false; foreach($suppliers as $key => $supplier){ if ($supplier['id'] === $supplier_id){ @@ -120,7 +120,7 @@ class Wiaas_Order { $order = wc_get_order($order_id); - $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->update_meta_data('_wiaas_delivery_suppliers', $suppliers); self::_update_max_and_earliest_dates($order, $suppliers); $order->save_meta_data(); @@ -129,7 +129,7 @@ class Wiaas_Order { public static function save_confirmed_date($order_id, $supplier_id, $date){ - $suppliers = wiaas_get_order_delivery_suppliers($order_id); + $suppliers = self::get_suppliers($order_id); $updated = false; foreach($suppliers as $key => $supplier){ @@ -148,7 +148,7 @@ class Wiaas_Order { $order = wc_get_order($order_id); - $order->update_meta_data('_wiaas_suppliers', $suppliers); + $order->update_meta_data('_wiaas_delivery_suppliers', $suppliers); self::_update_max_and_earliest_dates($order, $suppliers); $order->save_meta_data(); @@ -201,7 +201,7 @@ class Wiaas_Order { */ public static function get_suppliers($order_id){ $order = wc_get_order($order_id); - return $order->get_meta('_wiaas_suppliers'); + return $order->get_meta('_wiaas_delivery_suppliers'); } /** diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery-process-sample-form.json b/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery-process-sample-form.json index 2a74d6e..9228c21 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery-process-sample-form.json +++ b/backend/app/plugins/wiaas/includes/db-updates/data/delivery-forms/delivery-process-sample-form.json @@ -1,233 +1 @@ -{ - "0": { - "title": "DELIVERY PROCESS EXAMPLE: Copy and set to active to create new delivery process", - "description": "", - "labelPlacement": "top_label", - "descriptionPlacement": "below", - "button": { - "type": "text", - "text": "Submit", - "imageUrl": "" - }, - "fields": [ - { - "type": "wiaas_order", - "id": 1, - "label": "Order number", - "adminLabel": "", - "isRequired": false, - "size": "medium", - "errorMessage": "", - "visibility": "visible", - "inputs": null, - "formId": 24, - "description": "", - "allowsPrepopulate": false, - "inputMask": false, - "inputMaskValue": "", - "inputType": "", - "labelPlacement": "", - "descriptionPlacement": "", - "subLabelPlacement": "", - "placeholder": "", - "cssClass": "", - "inputName": "", - "noDuplicates": false, - "defaultValue": "", - "choices": "", - "conditionalLogic": "", - "enableCalculation": false, - "numberFormat": "decimal_dot", - "rangeMin": "", - "rangeMax": "", - "productField": "", - "multipleFiles": false, - "maxFiles": "", - "calculationFormula": "", - "calculationRounding": "", - "disableQuantity": false, - "displayAllCategories": false, - "useRichTextEditor": false, - "displayOnly": "", - "enablePrice": "" - } - ], - "version": "2.3.2", - "id": 24, - "useCurrentUserAsAuthor": true, - "postContentTemplateEnabled": false, - "postTitleTemplateEnabled": false, - "postTitleTemplate": "", - "postContentTemplate": "", - "lastPageButton": null, - "pagination": null, - "firstPageCssClass": null, - "wiaas_delivery_process": { - "delivery_form_type": "process", - "delivery_country": "se" - }, - "notifications": [ - { - "id": "5bdb1c7c26952", - "to": "{admin_email}", - "name": "Admin Notification", - "event": "form_submission", - "toType": "email", - "subject": "New submission from {form_title}", - "message": "{all_fields}" - } - ], - "confirmations": [ - { - "id": "5bdb1c7c26da9", - "name": "Default Confirmation", - "isDefault": true, - "type": "message", - "message": "Thanks for contacting us! We will get in touch with you shortly.", - "url": "", - "pageId": "", - "queryString": "" - } - ], - "feeds": { - "gravityflow": [ - { - "id": "83", - "form_id": "24", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Delivery Step Placeholder (Change this to start creating workflow)", - "description": "", - "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": "", - "destination_complete": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - }, - { - "id": "84", - "form_id": "24", - "is_active": "1", - "feed_order": "0", - "meta": { - "step_name": "Complete", - "description": "", - "step_type": "approval", - "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", - "type": "select", - "assignees": [ - "role|administrator" - ], - "routing": [ - { - "assignee": "user_id|1", - "fieldId": "0", - "operator": "is", - "value": "", - "type": "" - } - ], - "assignee_policy": "all", - "instructionsEnable": "0", - "instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button", - "display_fields_mode": "all_fields", - "assignee_notification_enabled": "0", - "assignee_notification_from_name": "", - "assignee_notification_from_email": "{admin_email}", - "assignee_notification_reply_to": "", - "assignee_notification_bcc": "", - "assignee_notification_subject": "", - "assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.", - "assignee_notification_disable_autoformat": "0", - "resend_assignee_emailEnable": "0", - "resend_assignee_emailValue": "7", - "resend_assignee_email_repeatEnable": "0", - "resend_assignee_email_repeatValue": "3", - "rejection_notification_enabled": "0", - "rejection_notification_type": "select", - "rejection_notification_routing": [ - { - "assignee": "user_id|1", - "fieldId": "0", - "operator": "is", - "value": "", - "type": "" - } - ], - "rejection_notification_from_name": "", - "rejection_notification_from_email": "{admin_email}", - "rejection_notification_reply_to": "", - "rejection_notification_bcc": "", - "rejection_notification_subject": "", - "rejection_notification_message": "Entry {entry_id} has been rejected", - "rejection_notification_disable_autoformat": "0", - "approval_notification_enabled": "0", - "approval_notification_type": "select", - "approval_notification_routing": [ - { - "assignee": "user_id|1", - "fieldId": "0", - "operator": "is", - "value": "", - "type": "" - } - ], - "approval_notification_from_name": "", - "approval_notification_from_email": "{admin_email}", - "approval_notification_reply_to": "", - "approval_notification_bcc": "", - "approval_notification_subject": "", - "approval_notification_message": "Entry {entry_id} has been approved", - "approval_notification_disable_autoformat": "0", - "note_mode": "not_required", - "expiration": "0", - "expiration_type": "delay", - "expiration_date": "", - "expiration_delay_offset": "", - "expiration_delay_unit": "hours", - "expiration_date_field_offset": "0", - "expiration_date_field_offset_unit": "hours", - "expiration_date_field_before_after": "after", - "status_expiration": "rejected", - "destination_expired": "next", - "destination_rejected": "complete", - "destination_approved": "next" - }, - "addon_slug": "gravityflow", - "event_type": null - } - ] - } - }, - "version": "2.3.2" -} \ No newline at end of file +{"0":{"title":"DELIVERY PROCESS EXAMPLE: Copy and set to active to create new delivery process","description":"","labelPlacement":"top_label","descriptionPlacement":"below","button":{"type":"text","text":"Submit","imageUrl":""},"fields":[{"type":"wiaas_order","id":1,"label":"Order number","adminLabel":"","isRequired":false,"size":"medium","errorMessage":"","visibility":"visible","inputs":null,"formId":36,"description":"","allowsPrepopulate":false,"inputMask":false,"inputMaskValue":"","inputType":"","labelPlacement":"","descriptionPlacement":"","subLabelPlacement":"","placeholder":"","cssClass":"","inputName":"","noDuplicates":false,"defaultValue":"","choices":"","conditionalLogic":"","enableCalculation":false,"numberFormat":"decimal_dot","rangeMin":"","rangeMax":"","productField":"","multipleFiles":false,"maxFiles":"","calculationFormula":"","calculationRounding":"","disableQuantity":false,"displayAllCategories":false,"useRichTextEditor":false,"displayOnly":"","enablePrice":""}],"version":"2.3.2","id":36,"useCurrentUserAsAuthor":true,"postContentTemplateEnabled":false,"postTitleTemplateEnabled":false,"postTitleTemplate":"","postContentTemplate":"","lastPageButton":null,"pagination":null,"firstPageCssClass":null,"wiaas_delivery_process":{"delivery_form_type":"process","delivery_country":"se"},"is_active":"1","date_created":"2018-11-02 10:15:28","is_trash":"0","confirmations":[{"id":"5bdb1c7c26da9","name":"Default Confirmation","isDefault":true,"type":"message","message":"Thanks for contacting us! We will get in touch with you shortly.","url":"","pageId":"","queryString":""}],"notifications":[{"id":"5bdb1c7c26952","to":"{admin_email}","name":"Admin Notification","event":"form_submission","toType":"email","subject":"New submission from {form_title}","message":"{all_fields}"}],"feeds":{"gravityflow":[{"id":"120","form_id":"36","is_active":"1","feed_order":"0","meta":{"step_name":"Delivery Step Placeholder (Use Delivery Step type to create process workflow steps)","description":"","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":"","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/delivery-process/class-wiaas-delivery-process-step.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php index 5c15849..6edcc9e 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php @@ -62,22 +62,16 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step { public function start() { - $complete = parent::start(); + parent::start(); - if ($complete) { + $this->update_step_status('pending'); - $this->update_step_status('complete'); - } else { - - $this->update_step_status('pending'); - } - - return $complete; + return false; } public function evaluate_status() { - return 'pending'; + return $this->get_status(); } public function get_status_label($status) { diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle-document.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle-document.php index dfefebe..5611ed0 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle-document.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle-document.php @@ -32,6 +32,19 @@ class Wiaas_Field_Order_Bundle_Document extends GF_Field_FileUpload { return 'fileupload'; } + public function add_button( $field_groups ) { + $field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups); + + return parent::add_button( $field_groups ); + } + + public function get_form_editor_button() { + return array( + 'group' => 'wiaas_order_fields', + 'text' => $this->get_form_editor_field_title(), + ); + } + public function get_form_editor_field_title() { return esc_attr__( 'Bundle Document', 'wiaas' ); } diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle.php index 0d4ab92..418708b 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-bundle.php @@ -8,6 +8,19 @@ class Wiaas_Field_Order_Bundle extends GF_Field_Text { return esc_attr__( 'Bundle', 'wiaas' ); } + public function add_button( $field_groups ) { + $field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups); + + return parent::add_button( $field_groups ); + } + + public function get_form_editor_button() { + return array( + 'group' => 'wiaas_order_fields', + 'text' => $this->get_form_editor_field_title(), + ); + } + public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) { return $this->get_bundle_display_name($value); } diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-document.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-document.php index a0cde76..f15ca11 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-document.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-document.php @@ -36,6 +36,19 @@ class Wiaas_Field_Order_Document extends GF_Field_FileUpload { return esc_attr__( 'Order Document', 'wiaas' ); } + public function add_button( $field_groups ) { + $field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups); + + return parent::add_button( $field_groups ); + } + + public function get_form_editor_button() { + return array( + 'group' => 'wiaas_order_fields', + 'text' => $this->get_form_editor_field_title(), + ); + } + public function get_download_url( $file, $force_download = false ) { $upload_root = GFFormsModel::get_upload_url( $this->formId ); diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-installation-select.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-installation-select.php index 689ed9f..f19967a 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-installation-select.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-installation-select.php @@ -13,6 +13,19 @@ class Wiaas_Order_Installation_Select extends GF_Field_Select { return 'workflow_assignee_select'; } + public function add_button( $field_groups ) { + $field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups); + + return parent::add_button( $field_groups ); + } + + public function get_form_editor_button() { + return array( + 'group' => 'wiaas_order_fields', + 'text' => $this->get_form_editor_field_title(), + ); + } + public function get_field_input( $form, $value = '', $entry = null ) { if ( empty($entry) ) { diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-number.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-number.php index fed0ead..e3d3f4f 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-number.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-field-order-number.php @@ -36,6 +36,19 @@ class Wiaas_Field_Order_Number extends GF_Field_Number { return esc_attr__( 'Order Number', 'wiaas' ); } + public function add_button( $field_groups ) { + $field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups); + + return parent::add_button( $field_groups ); + } + + public function get_form_editor_button() { + return array( + 'group' => 'wiaas_order_fields', + 'text' => $this->get_form_editor_field_title(), + ); + } + public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) { return "#100000$value"; diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-order-fields.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-order-fields.php index af92e20..52a77b0 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-order-fields.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-order-fields.php @@ -13,6 +13,29 @@ class Wiaas_Order_Fields { add_filter('gform_fileupload_entry_value_file_path', array( __CLASS__, 'display_order_document_fields' ), 999, 2); } + /** + * Adds the Order Fields group to the form editor. + * + * @param array $field_groups The properties for the field groups. + * + * @return array + */ + public static function maybe_add_order_field_group( $field_groups ) { + foreach ( $field_groups as $field_group ) { + if ( $field_group['name'] == 'wiaas_order_fields' ) { + return $field_groups; + } + } + + $field_groups[] = array( + 'name' => 'wiaas_order_fields', + 'label' => __( 'Order Fields', 'wiaas' ), + 'fields' => array() + ); + + return $field_groups; + } + public static function display_order_document_fields($file_path, $field) { diff --git a/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php b/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php index 0d71cbc..6522ced 100644 --- a/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php +++ b/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php @@ -42,13 +42,22 @@ function wiaas_get_order_procurement_info($order_id) { $order_items = $order->get_items(); - $order_suppliers_info = $order->get_meta('_wiaas_suppliers'); + $order_suppliers_info = array(); + $order_delivery_suppliers_info = $order->get_meta('_wiaas_delivery_suppliers'); + $order_installation_suppliers_info = $order->get_meta('_wiaas_installation_suppliers'); + + foreach ($order_delivery_suppliers_info as $id => $order_delivery_supplier_info) { + $order_suppliers_info[$id] = $order_delivery_supplier_info; + } + foreach ($order_installation_suppliers_info as $id => $order_installation_supplier_info) { + $order_suppliers_info[$id] = $order_installation_supplier_info; + } $data = array(); foreach ($order_items as $order_item_id => $order_item) { - $category = $order_item['_wiaas_category']; + $category = $order_item['wiaas_category']; $supplier_organization_id = $order_item['wiaas_supplier_organization_id']; $supplier_info = $order_suppliers_info[$supplier_organization_id]; @@ -80,35 +89,4 @@ function wiaas_get_order_procurement_info($order_id) { } return $data; -} - -/** - * Retrieve delivery supplier organizations for order which does not include installation providers - * - * @param int $order_id - * - * @return array - */ -function wiaas_get_order_delivery_suppliers($order_id) { - - $order = wc_get_order($order_id); - - $supplier_organizations = $order->get_meta('_wiaas_suppliers', true); - - $delivery_supplier_organizations = array(); - - $order_items = $order->get_items(); - - foreach ($order_items as $order_item_id => $order_item) { - - $supplier_organization_id = $order_item['wiaas_supplier_organization_id']; - - if (! empty($supplier_organization_id) && $order_item['wiaas_category'] !== 'installation' && - empty($delivery_supplier_organizations[$supplier_organization_id])) { - - $delivery_supplier_organizations[$supplier_organization_id] = $supplier_organizations[$supplier_organization_id]; - } - } - - return $delivery_supplier_organizations; } \ No newline at end of file diff --git a/frontend/src/containers/cart/components/CartUploadDocument.jsx b/frontend/src/containers/cart/components/CartUploadDocument.jsx index 4ad72e3..7d87618 100644 --- a/frontend/src/containers/cart/components/CartUploadDocument.jsx +++ b/frontend/src/containers/cart/components/CartUploadDocument.jsx @@ -61,7 +61,7 @@ class CartUploadDocument extends Component { {this.uploadFile(cartItem.key, idDocumentType, acceptedFiles, rejectedFiles, packages)}}> { uploadedDocument diff --git a/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx b/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx index 300e20c..3c459a3 100644 --- a/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx +++ b/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx @@ -135,7 +135,7 @@ class CustomerAcceptance extends Component { {this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}
diff --git a/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx b/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx index cc5a4af..6ec53ee 100644 --- a/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx +++ b/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx @@ -67,7 +67,7 @@ class ValidateQuestionnaireItem extends Component { {this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
{orderTexts.labels.SELECT_OR_DROP}