From 35854d136789a533ad62481f8acd378d4eda6bdd Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Wed, 21 Nov 2018 12:25:34 +0100 Subject: [PATCH 01/37] add phone number field --- .../admin/class-wiaas-admin-user-profile.php | 32 +++++++++++++++++++ .../wiaas/includes/class-wiaas-admin.php | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php new file mode 100644 index 0000000..a4b6d1a --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php @@ -0,0 +1,32 @@ +add('phone_error', __( 'ERROR: Enter valid phone number.', 'crf' )); + }; + + } + + + function modify_user_contact_methods($user_contact){ + $user_contact['phone'] = __( 'Phone number' ); + + return $user_contact; + } + + +} + +Wiaas_Admin_Profile::init(); \ 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 6d5021e..5c5ef1f 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-admin.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-admin.php @@ -28,6 +28,8 @@ class Wiaas_Admin { require_once dirname(__FILE__) . '/admin/class-wiaas-admin-supplier.php'; + require_once dirname(__FILE__) . '/admin/class-wiaas-admin-user-profile.php'; + add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 ); } From 68c760a42695b3298d13d6d63283c661781c6807 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Wed, 21 Nov 2018 12:25:47 +0100 Subject: [PATCH 02/37] validate phone number from frontend --- .../plugins/wiaas/includes/api/class-wiaas-rest-customer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php index 79bffe7..c040a2d 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php @@ -148,6 +148,10 @@ class Wiaas_REST_Customer_API { return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); } + if (!preg_match('/^[\d +]*$/', $phone)){ + return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); + }; + if (!Wiaas_Customer::update_customer_profile_info($customer_id, $first_name, $last_name, $phone)){ return wiaas_api_notice('PROFILE_NOT_CHANGED', 'warning', Wiaas_Customer::get_customer_info($customer_id)); } From 8d954469ee81e1e9967ced7189fedd80f796e9de Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 22 Nov 2018 11:27:30 +0100 Subject: [PATCH 03/37] use woocommerce validation --- .../includes/admin/class-wiaas-admin-user-profile.php | 7 +++---- .../wiaas/includes/api/class-wiaas-rest-customer.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php index a4b6d1a..ba5b7b5 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php @@ -9,18 +9,17 @@ class Wiaas_Admin_Profile { } - function crf_user_profile_update_errors( $errors, $update, $user ) { + public static function crf_user_profile_update_errors( $errors, $update, $user ) { $phone = $_POST['phone']; - if (!preg_match('/^[\d +]*$/', $phone)){ + if (!WC_Validation::is_phone($phone)){ $errors->add('phone_error', __( 'ERROR: Enter valid phone number.', 'crf' )); }; } - - function modify_user_contact_methods($user_contact){ + public static function modify_user_contact_methods($user_contact){ $user_contact['phone'] = __( 'Phone number' ); return $user_contact; diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php index c040a2d..0507578 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php @@ -148,7 +148,7 @@ class Wiaas_REST_Customer_API { return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); } - if (!preg_match('/^[\d +]*$/', $phone)){ + if (!WC_Validation::is_phone($phone)){ return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); }; From 217dfb188973b77ae57c19d0f6435b45c0035965 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 22 Nov 2018 12:08:41 +0100 Subject: [PATCH 04/37] add validation functions class --- .../admin/class-wiaas-admin-user-profile.php | 2 +- .../includes/api/class-wiaas-rest-customer.php | 2 +- .../includes/class-wiaas-validation-functions.php | 13 +++++++++++++ backend/app/plugins/wiaas/wiaas.php | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php index ba5b7b5..59fc0df 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php @@ -13,7 +13,7 @@ class Wiaas_Admin_Profile { $phone = $_POST['phone']; - if (!WC_Validation::is_phone($phone)){ + if (!Wiaas_Validation_Functions::is_phone($phone)){ $errors->add('phone_error', __( 'ERROR: Enter valid phone number.', 'crf' )); }; diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php index 0507578..60c3594 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php @@ -148,7 +148,7 @@ class Wiaas_REST_Customer_API { return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); } - if (!WC_Validation::is_phone($phone)){ + if (!Wiaas_Validation_Functions::is_phone($phone)){ return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); }; diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php b/backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php new file mode 100644 index 0000000..9988b67 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php @@ -0,0 +1,13 @@ + Date: Thu, 22 Nov 2018 13:22:05 +0100 Subject: [PATCH 05/37] Rename class --- .../wiaas/includes/admin/class-wiaas-admin-user-profile.php | 2 +- .../plugins/wiaas/includes/api/class-wiaas-rest-customer.php | 2 +- ...as-validation-functions.php => class-wiaas-validation.php} | 4 ++-- backend/app/plugins/wiaas/wiaas.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename backend/app/plugins/wiaas/includes/{class-wiaas-validation-functions.php => class-wiaas-validation.php} (67%) diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php index 59fc0df..44d92a0 100644 --- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-user-profile.php @@ -13,7 +13,7 @@ class Wiaas_Admin_Profile { $phone = $_POST['phone']; - if (!Wiaas_Validation_Functions::is_phone($phone)){ + if (!Wiaas_Validation::is_phone($phone)){ $errors->add('phone_error', __( 'ERROR: Enter valid phone number.', 'crf' )); }; diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php index 60c3594..2c57629 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php @@ -148,7 +148,7 @@ class Wiaas_REST_Customer_API { return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); } - if (!Wiaas_Validation_Functions::is_phone($phone)){ + if (!Wiaas_Validation::is_phone($phone)){ return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id)); }; diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php b/backend/app/plugins/wiaas/includes/class-wiaas-validation.php similarity index 67% rename from backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php rename to backend/app/plugins/wiaas/includes/class-wiaas-validation.php index 9988b67..e9771c2 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-validation-functions.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-validation.php @@ -3,9 +3,9 @@ defined( 'ABSPATH' ) || exit; /** - * Class Wiaas_Validation_Functions + * Class Wiaas_Validation */ -class Wiaas_Validation_Functions { +class Wiaas_Validation { public static function is_phone($phone){ return WC_Validation::is_phone($phone); diff --git a/backend/app/plugins/wiaas/wiaas.php b/backend/app/plugins/wiaas/wiaas.php index b2d0fe1..582e624 100644 --- a/backend/app/plugins/wiaas/wiaas.php +++ b/backend/app/plugins/wiaas/wiaas.php @@ -59,7 +59,7 @@ include_once WIAAS_DIR . '/includes/class-wiass-templates.php'; include_once WIAAS_DIR . '/includes/wiaas-class-measurement-units.php'; -include_once WIAAS_DIR . '/includes/class-wiaas-validation-functions.php'; +include_once WIAAS_DIR . '/includes/class-wiaas-validation.php'; function wiaas_redirect_to_login() { wp_safe_redirect(get_site_url('', 'wp-login.php')); From 798ad205347f350b4ef3aef4765e8df2303a8de0 Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Tue, 27 Nov 2018 00:57:35 +0100 Subject: [PATCH 06/37] Show countries for delivery process forms. Refactor countries. --- .../admin/class-wiaas-admin-countries.php | 71 +++ .../class-wiaas-admin-delivery-process.php | 1 + ...lass-wiaas-admin-delivery-process-list.php | 168 ++++++ ...ass-wiaas-admin-delivery-process-order.php | 6 +- .../api/class-wiaas-rest-user-api.php | 2 +- .../wiaas/includes/class-wiaas-admin.php | 2 + .../wiaas/includes/class-wiaas-cart.php | 2 + .../wiaas/includes/class-wiaas-countries.php | 165 ++++-- .../wiaas/includes/class-wiaas-db-update.php | 21 +- .../wiaas/includes/class-wiaas-order.php | 17 +- .../data/wiaas-ui-field-country-settings.json | 501 ++++++++++++++++++ .../db-updates/wiaas-db-update-general.php | 98 ++++ .../db-updates/wiaas-db-update-ui-fields.php | 9 + .../class-wiaas-delivery-process-addon.php | 18 +- .../includes/user/class-wiaas-customer.php | 16 +- .../api/test-wiaas-rest-user-api.php | 4 +- frontend/src/helpers/AddressHelper.js | 4 +- frontend/src/helpers/CountryHelper.js | 4 +- 18 files changed, 1035 insertions(+), 74 deletions(-) create mode 100644 backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-countries.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php create mode 100644 backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-country-settings.json diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-countries.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-countries.php new file mode 100644 index 0000000..342f59f --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-countries.php @@ -0,0 +1,71 @@ +'. $code . ''; + } + + if ($column === 'wiaas_vat') { + + $vat = get_term_meta($id, '_wiaas_country_vat', true); + $columns .= ''. $vat . ''; + } + + if ($column === 'wiaas_currency') { + + $currency = get_term_meta($id, '_wiaas_country_currency', true); + $columns .= ''. $currency . ''; + } + + return $columns; + } + + public static function populate_country_codes($field) { + $countries_list = Wiaas_Countries::get_country_choices(); + + $countries_choices = array(); + foreach ($countries_list as $code => $name) { + + $countries_choices[$code] = $code . ' - ' . $name; + } + + $field['choices'] = $countries_choices; + + return $field; + } + + public static function populate_country_currencies($field) { + + $field['choices'] = Wiaas_Countries::get_currency_choices(); + + return $field; + } +} + +Wiaas_Admin_Countries::init(); 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 981a56e..6f99af4 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 @@ -7,6 +7,7 @@ class Wiaas_Admin_Delivery_Process { require_once dirname( __FILE__ ) . '/delivery-process/wiaas-admin-delivery-process-ajax.php'; require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-flow.php'; require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-order.php'; + require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-list.php'; add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 ); } diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php new file mode 100644 index 0000000..c7f4bfb --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php @@ -0,0 +1,168 @@ +id ); + + $title = strtolower($form_details['title']); + + $delivery_settings = rgar($form_details, 'wiaas_delivery_process'); + $country_code = ! empty($delivery_settings) ? $delivery_settings['delivery_country'] : ''; + $country_name = Wiaas_Countries::get_available_country_name_by_code($country_code); + $country_name = strtolower($country_name); + + if (strpos($title, $search_query) !== false || strpos($country_code, $search_query) !== false || + strpos($country_name, $search_query) !== false) { + $filtered_forms[] = $form; + } + } + + return $filtered_forms; + } + + return $forms; + } + + /** + * Remove unused actions and add workflow action for delivery forms list + * + * @param array $actions + * @param int $form_id + * + * @return mixed + */ + public static function filter_gform_form_actions($actions, $form_id) { + + $form_details = GFAPI::get_form($form_id); + $delivery_settings = rgar($form_details, 'wiaas_delivery_process'); + + if (empty($delivery_settings)) { + + return $actions; + } + + $type = $delivery_settings['delivery_form_type']; + + $is_action = $type === 'action'; + + if (!$is_action) { + + unset($actions['entries']); + } + + unset($actions['entries']); + unset($actions['preview']); + unset($actions['edit']); + + $actions['wiaas_workflow'] = array( + 'label' => __( 'Workflow', 'wiaas' ), + 'short_label' => esc_html__( 'Workflow', 'wiaas' ), + 'title' => __( 'Edit workflow', 'wiaas' ), + 'url' => '?page=gf_edit_forms&view=settings&id=' . $form_id . '&subview=gravityflow', + 'priority' => 1000, + ); + + return $actions; + } + + /** + * Render country column for delivery process forms list + * + * @param mixed $form + */ + public static function render_gform_form_list_wiaas_country_column($form) { + + $form_details = GFAPI::get_form($form->id); + $delivery_settings = rgar($form_details, 'wiaas_delivery_process'); + + $country_code = ! empty($delivery_settings) ? $delivery_settings['delivery_country'] : ''; + + $country_name = Wiaas_Countries::get_available_country_name_by_code($country_code); + + echo '' . esc_html_e($country_name) . ''; + } + + /** + * Render actions column for delivery process forms list + * @param mixed $form + */ + public static function render_gform_form_list_wiaas_actions_column($form) { + + $form_details = GFAPI::get_form($form->id); + $delivery_settings = rgar($form_details, 'wiaas_delivery_process'); + + $form_type = ! empty($delivery_settings) ? $delivery_settings['delivery_form_type'] : ''; + + ?> + Workflow + + | + Change Country + get_currency()) - ); + $list_of_delivery_processes = Wiaas_Delivery_Process::get_available_process_list_for_country($country_code); ?>
diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-user-api.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-user-api.php index 2b8cf3e..44bad74 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-user-api.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-user-api.php @@ -43,7 +43,7 @@ class Wiass_REST_User_API { } public static function get_countries(){ - $countries = Wiaas_Countries::get_list_of_countries(); + $countries = Wiaas_Countries::get_available_countries(); return rest_ensure_response($countries); } diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-admin.php b/backend/app/plugins/wiaas/includes/class-wiaas-admin.php index 5c5ef1f..45cb271 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-admin.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-admin.php @@ -30,6 +30,8 @@ class Wiaas_Admin { require_once dirname(__FILE__) . '/admin/class-wiaas-admin-user-profile.php'; + require_once dirname(__FILE__) . '/admin/class-wiaas-admin-countries.php'; + add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 ); } diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 4549663..3f3e766 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -492,6 +492,8 @@ class Wiaas_Cart { $country = get_user_meta(get_current_user_id(), '_wiaas_cart_items_country', true); $currency = empty($country) ? get_woocommerce_currency() : $country['currency']; + $order->add_meta_data('_wiaas_country_code', $country['code']); + $order->set_currency($currency); // get order commercial lead diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-countries.php b/backend/app/plugins/wiaas/includes/class-wiaas-countries.php index a88c14f..bf67897 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-countries.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-countries.php @@ -12,28 +12,19 @@ if ( ! defined( 'ABSPATH' ) ) { class Wiaas_Countries { /** - * Available countries for wiaas + * Default available countries for wiaas * @var array */ - private static $available_countries = array( - 'Sweden' => array( - 'id' => 1, - 'name' => 'Sweden', - 'code' => 'se', + private static $default_countries = array( + 'se' => array( 'vat' => 9 , 'currency' => 'SEK' ), - 'Denmark' => array( - 'id' => 2, - 'name' => 'Denmark', - 'code' => 'dk', + 'dk' => array( 'vat' => 9 , 'currency' => 'DKK' ), - 'Finland' => array( - 'id' => 3, - 'name' => 'Finland', - 'code' => 'fi', + 'fi' => array( 'vat' => 9 , 'currency' => 'EUR' ), @@ -44,31 +35,97 @@ class Wiaas_Countries { add_action('woocommerce_after_register_taxonomy', array(__CLASS__, 'register_product_countries_taxonomy')); } - public static function get_list_of_countries(){ - $result = []; - foreach(self::$available_countries as $country){ - array_push($result, array( - 'country_id' => $country['id'], - 'country_name' => $country['name'] - )); + /** + * Retrieve all possible country choices + * + * @return array + */ + public static function get_country_choices() { + $countries = new WC_Countries(); + $choices = array(); + + foreach ($countries->get_countries() as $code => $name) { + $choices[strtolower($code)] = $name; } - return $result; + + return $choices; } - public static function get_country_name_by_id($id){ - foreach(self::$available_countries as $country){ - if ($country['id'] == $id) return $country['name']; - } - return ''; + /** + * Retrieve all possible currency choices + * + * @return array + */ + public static function get_currency_choices() { + return get_woocommerce_currencies(); } - public static function get_country_code_by_currency($currency) { + /** + * Retrieve list of available countries setup by administrator + * + * @return array + */ + public static function get_available_countries() { + $available_countries = []; - foreach (self::$available_countries as $country) { + $available_country_terms = get_terms(array( + 'taxonomy' => 'product_country', + 'hide_empty' => false, + )); - if ($country['currency'] === $currency) { + foreach($available_country_terms as $country_term) { + $code = get_term_meta($country_term->term_id, '_wiaas_country_code', true); + $currency = get_term_meta($country_term->term_id, '_wiaas_country_currency', true); + $vat = get_term_meta($country_term->term_id, '_wiaas_country_vat', true); - return $country['code']; + $available_countries[] = array( + 'id' => $country_term->term_id, + 'name' => $country_term->name, + 'code' => $code, + 'currency' => $currency, + 'vat' => $vat + ); + } + + return $available_countries; + } + + /** + * Retrieve country name by code for available country + * + * @param string $code + * + * @return string|null + */ + public static function get_available_country_name_by_code($code) { + $available_countries = self::get_available_countries(); + + foreach ($available_countries as $available_country) { + + if ($available_country['code'] === $code) { + + return $available_country['name']; + } + } + + return null; + } + + /** + * Retrieve country code by currency for available country + * + * @param string $currency + * + * @return string|null + */ + public static function get_available_country_code_by_currency($currency) { + $available_countries = self::get_available_countries(); + + foreach ($available_countries as $available_country) { + + if ($available_country['currency'] === $currency) { + + return $available_country['code']; } } @@ -106,8 +163,27 @@ class Wiaas_Countries { register_taxonomy( 'product_country', array( 'product' ), $args ); - foreach (self::$available_countries as $available_country) { - wp_insert_term($available_country['name'], 'product_country'); + $choices = self::get_country_choices(); + + foreach (self::$default_countries as $code => $info) { + + $name = $choices[$code]; + + if (has_term($name)) { + // bail out + return; + } + + $name = $choices[$code]; + $result = wp_insert_term($name, 'product_country'); + + if (is_wp_error($result)) { + continue; + } + + update_term_meta($result->term_id, '_wiaas_country_code', $code); + update_term_meta($result->term_id, '_wiaas_country_currency', $info['currency']); + update_term_meta($result->term_id, '_wiaas_country_vat', $info['vat']); } } @@ -128,10 +204,25 @@ class Wiaas_Countries { * @return array|null */ public static function get_product_country($product) { - $product_country = get_the_terms($product->get_id(), 'product_country'); - return is_array($product_country) && isset($product_country[0]) ? - self::$available_countries[$product_country[0]->name] : - null; + $country_terms = get_the_terms($product->get_id(), 'product_country'); + + if (is_wp_error($country_terms) || empty($country_terms) || empty($country_terms[0])) { + return null; + } + + $country_term = $country_terms[0]; + + $code = get_term_meta($country_term->term_id, '_wiaas_country_code', true); + $currency = get_term_meta($country_term->term_id, '_wiaas_country_currency', true); + $vat = get_term_meta($country_term->term_id, '_wiaas_country_vat', true); + + return array( + 'id' => $country_term->term_id, + 'name' => $country_term->name, + 'code' => $code, + 'currency' => $currency, + 'vat' => $vat + ); } /** 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 73c78cd..94bfa13 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php @@ -18,15 +18,18 @@ class Wiaas_DB_Update { '20181018044450' => 'wiaas_db_setup_create_customer_commercial_lead_table', '20181018054450' => 'wiaas_db_update_update_commercial_lead_capabilities', '20181018064450' => 'wiaas_db_update_add_organization_info_ui_fields', - '20191019014550' => 'wiaas_db_update_add_general_ui_fields', - '20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields', - '20191020014650' => 'wiaas_create_organization_roles_capabilities', - '20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities', - '20191102112451' => 'wiaas_disable_processing_order_email_delivery', - '20191131172850' => 'wiaas_db_update_update_delivery_forms', - '20191131182856' => 'wiaas_db_update_enable_workflow_inbox_for_roles', - '20191201133550' => 'wiaas_db_update_add_bundle_properties_ui_field', - '20191202133553' => 'wiaas_db_update_add_installation_date_delivery_action_form' + '20181019014550' => 'wiaas_db_update_add_general_ui_fields', + '20181019014650' => 'wiaas_db_update_add_product_properties_ui_fields', + '20181020014650' => 'wiaas_create_organization_roles_capabilities', + '20181021162450' => 'wiaas_db_update_update_supplier_order_capabilities', + '20181102112451' => 'wiaas_disable_processing_order_email_delivery', + '20181103172850' => 'wiaas_db_update_update_delivery_forms', + '20181104182856' => 'wiaas_db_update_enable_workflow_inbox_for_roles', + '20181105133550' => 'wiaas_db_update_add_bundle_properties_ui_field', + '20181106133553' => 'wiaas_db_update_add_installation_date_delivery_action_form', + '20181125133553' => 'wiaas_db_update_add_country_settings_ui_fields', + '20181125143553' => 'wiaas_db_migration_fix_user_profile_addresses', // remove after migration + '20181125153553' => 'wiaas_db_migration_fix_countries' // remove after migration ); public static function execute() { diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-order.php b/backend/app/plugins/wiaas/includes/class-wiaas-order.php index ec34773..f5042b9 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-order.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-order.php @@ -400,7 +400,22 @@ class Wiaas_Order { public static function get_order_tender($order_id) { return get_post_meta($order_id, '_wiaas_tender', true); - } + } + + public static function get_order_country_code($order_id) { + + $order = wc_get_order($order_id); + + $code = $order->get_meta('_wiaas_country_code'); + + if (empty($code)) { + $code = Wiaas_Countries::get_available_country_code_by_currency($order->get_currency()); + $order->add_meta_data('_wiaas_country_code', $code); + $order->save_meta_data(); + } + + return $code; + } /** * PRIVATE diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-country-settings.json b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-country-settings.json new file mode 100644 index 0000000..cf148aa --- /dev/null +++ b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-country-settings.json @@ -0,0 +1,501 @@ +[ + { + "key": "group_5bdad38fcebee", + "title": "Country settings", + "fields": [ + { + "key": "field_5bdad398384e1", + "label": "Code", + "name": "_wiaas_country_code", + "type": "select", + "instructions": "", + "required": 1, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "ax": "ax - Åland Islands", + "af": "af - Afghanistan", + "al": "al - Albania", + "dz": "dz - Algeria", + "as": "as - American Samoa", + "ad": "ad - Andorra", + "ao": "ao - Angola", + "ai": "ai - Anguilla", + "aq": "aq - Antarctica", + "ag": "ag - Antigua and Barbuda", + "ar": "ar - Argentina", + "am": "am - Armenia", + "aw": "aw - Aruba", + "au": "au - Australia", + "at": "at - Austria", + "az": "az - Azerbaijan", + "bs": "bs - Bahamas", + "bh": "bh - Bahrain", + "bd": "bd - Bangladesh", + "bb": "bb - Barbados", + "by": "by - Belarus", + "pw": "pw - Belau", + "be": "be - Belgium", + "bz": "bz - Belize", + "bj": "bj - Benin", + "bm": "bm - Bermuda", + "bt": "bt - Bhutan", + "bo": "bo - Bolivia", + "bq": "bq - Bonaire, Saint Eustatius and Saba", + "ba": "ba - Bosnia and Herzegovina", + "bw": "bw - Botswana", + "bv": "bv - Bouvet Island", + "br": "br - Brazil", + "io": "io - British Indian Ocean Territory", + "vg": "vg - British Virgin Islands", + "bn": "bn - Brunei", + "bg": "bg - Bulgaria", + "bf": "bf - Burkina Faso", + "bi": "bi - Burundi", + "kh": "kh - Cambodia", + "cm": "cm - Cameroon", + "ca": "ca - Canada", + "cv": "cv - Cape Verde", + "ky": "ky - Cayman Islands", + "cf": "cf - Central African Republic", + "td": "td - Chad", + "cl": "cl - Chile", + "cn": "cn - China", + "cx": "cx - Christmas Island", + "cc": "cc - Cocos (Keeling) Islands", + "co": "co - Colombia", + "km": "km - Comoros", + "cg": "cg - Congo (Brazzaville)", + "cd": "cd - Congo (Kinshasa)", + "ck": "ck - Cook Islands", + "cr": "cr - Costa Rica", + "hr": "hr - Croatia", + "cu": "cu - Cuba", + "cw": "cw - Curaçao", + "cy": "cy - Cyprus", + "cz": "cz - Czech Republic", + "dk": "dk - Denmark", + "dj": "dj - Djibouti", + "dm": "dm - Dominica", + "do": "do - Dominican Republic", + "ec": "ec - Ecuador", + "eg": "eg - Egypt", + "sv": "sv - El Salvador", + "gq": "gq - Equatorial Guinea", + "er": "er - Eritrea", + "ee": "ee - Estonia", + "et": "et - Ethiopia", + "fk": "fk - Falkland Islands", + "fo": "fo - Faroe Islands", + "fj": "fj - Fiji", + "fi": "fi - Finland", + "fr": "fr - France", + "gf": "gf - French Guiana", + "pf": "pf - French Polynesia", + "tf": "tf - French Southern Territories", + "ga": "ga - Gabon", + "gm": "gm - Gambia", + "ge": "ge - Georgia", + "de": "de - Germany", + "gh": "gh - Ghana", + "gi": "gi - Gibraltar", + "gr": "gr - Greece", + "gl": "gl - Greenland", + "gd": "gd - Grenada", + "gp": "gp - Guadeloupe", + "gu": "gu - Guam", + "gt": "gt - Guatemala", + "gg": "gg - Guernsey", + "gn": "gn - Guinea", + "gw": "gw - Guinea-Bissau", + "gy": "gy - Guyana", + "ht": "ht - Haiti", + "hm": "hm - Heard Island and McDonald Islands", + "hn": "hn - Honduras", + "hk": "hk - Hong Kong", + "hu": "hu - Hungary", + "is": "is - Iceland", + "in": "in - India", + "id": "id - Indonesia", + "ir": "ir - Iran", + "iq": "iq - Iraq", + "ie": "ie - Ireland", + "im": "im - Isle of Man", + "il": "il - Israel", + "it": "it - Italy", + "ci": "ci - Ivory Coast", + "jm": "jm - Jamaica", + "jp": "jp - Japan", + "je": "je - Jersey", + "jo": "jo - Jordan", + "kz": "kz - Kazakhstan", + "ke": "ke - Kenya", + "ki": "ki - Kiribati", + "kw": "kw - Kuwait", + "kg": "kg - Kyrgyzstan", + "la": "la - Laos", + "lv": "lv - Latvia", + "lb": "lb - Lebanon", + "ls": "ls - Lesotho", + "lr": "lr - Liberia", + "ly": "ly - Libya", + "li": "li - Liechtenstein", + "lt": "lt - Lithuania", + "lu": "lu - Luxembourg", + "mo": "mo - Macao S.A.R., China", + "mk": "mk - Macedonia", + "mg": "mg - Madagascar", + "mw": "mw - Malawi", + "my": "my - Malaysia", + "mv": "mv - Maldives", + "ml": "ml - Mali", + "mt": "mt - Malta", + "mh": "mh - Marshall Islands", + "mq": "mq - Martinique", + "mr": "mr - Mauritania", + "mu": "mu - Mauritius", + "yt": "yt - Mayotte", + "mx": "mx - Mexico", + "fm": "fm - Micronesia", + "md": "md - Moldova", + "mc": "mc - Monaco", + "mn": "mn - Mongolia", + "me": "me - Montenegro", + "ms": "ms - Montserrat", + "ma": "ma - Morocco", + "mz": "mz - Mozambique", + "mm": "mm - Myanmar", + "na": "na - Namibia", + "nr": "nr - Nauru", + "np": "np - Nepal", + "nl": "nl - Netherlands", + "nc": "nc - New Caledonia", + "nz": "nz - New Zealand", + "ni": "ni - Nicaragua", + "ne": "ne - Niger", + "ng": "ng - Nigeria", + "nu": "nu - Niue", + "nf": "nf - Norfolk Island", + "kp": "kp - North Korea", + "mp": "mp - Northern Mariana Islands", + "no": "no - Norway", + "om": "om - Oman", + "pk": "pk - Pakistan", + "ps": "ps - Palestinian Territory", + "pa": "pa - Panama", + "pg": "pg - Papua New Guinea", + "py": "py - Paraguay", + "pe": "pe - Peru", + "ph": "ph - Philippines", + "pn": "pn - Pitcairn", + "pl": "pl - Poland", + "pt": "pt - Portugal", + "pr": "pr - Puerto Rico", + "qa": "qa - Qatar", + "re": "re - Reunion", + "ro": "ro - Romania", + "ru": "ru - Russia", + "rw": "rw - Rwanda", + "st": "st - São Tomé and Príncipe", + "bl": "bl - Saint Barthélemy", + "sh": "sh - Saint Helena", + "kn": "kn - Saint Kitts and Nevis", + "lc": "lc - Saint Lucia", + "sx": "sx - Saint Martin (Dutch part)", + "mf": "mf - Saint Martin (French part)", + "pm": "pm - Saint Pierre and Miquelon", + "vc": "vc - Saint Vincent and the Grenadines", + "ws": "ws - Samoa", + "sm": "sm - San Marino", + "sa": "sa - Saudi Arabia", + "sn": "sn - Senegal", + "rs": "rs - Serbia", + "sc": "sc - Seychelles", + "sl": "sl - Sierra Leone", + "sg": "sg - Singapore", + "sk": "sk - Slovakia", + "si": "si - Slovenia", + "sb": "sb - Solomon Islands", + "so": "so - Somalia", + "za": "za - South Africa", + "gs": "gs - South Georgia\/Sandwich Islands", + "kr": "kr - South Korea", + "ss": "ss - South Sudan", + "es": "es - Spain", + "lk": "lk - Sri Lanka", + "sd": "sd - Sudan", + "sr": "sr - Suriname", + "sj": "sj - Svalbard and Jan Mayen", + "sz": "sz - Swaziland", + "se": "se - Sweden", + "ch": "ch - Switzerland", + "sy": "sy - Syria", + "tw": "tw - Taiwan", + "tj": "tj - Tajikistan", + "tz": "tz - Tanzania", + "th": "th - Thailand", + "tl": "tl - Timor-Leste", + "tg": "tg - Togo", + "tk": "tk - Tokelau", + "to": "to - Tonga", + "tt": "tt - Trinidad and Tobago", + "tn": "tn - Tunisia", + "tr": "tr - Turkey", + "tm": "tm - Turkmenistan", + "tc": "tc - Turks and Caicos Islands", + "tv": "tv - Tuvalu", + "ug": "ug - Uganda", + "ua": "ua - Ukraine", + "ae": "ae - United Arab Emirates", + "gb": "gb - United Kingdom (UK)", + "us": "us - United States (US)", + "um": "um - United States (US) Minor Outlying Islands", + "vi": "vi - United States (US) Virgin Islands", + "uy": "uy - Uruguay", + "uz": "uz - Uzbekistan", + "vu": "vu - Vanuatu", + "va": "va - Vatican", + "ve": "ve - Venezuela", + "vn": "vn - Vietnam", + "wf": "wf - Wallis and Futuna", + "eh": "eh - Western Sahara", + "ye": "ye - Yemen", + "zm": "zm - Zambia", + "zw": "zw - Zimbabwe" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 1, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5bfc4b4fa5992", + "label": "Currency", + "name": "_wiaas_country_currency", + "type": "select", + "instructions": "", + "required": 1, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "AED": "United Arab Emirates dirham", + "AFN": "Afghan afghani", + "ALL": "Albanian lek", + "AMD": "Armenian dram", + "ANG": "Netherlands Antillean guilder", + "AOA": "Angolan kwanza", + "ARS": "Argentine peso", + "AUD": "Australian dollar", + "AWG": "Aruban florin", + "AZN": "Azerbaijani manat", + "BAM": "Bosnia and Herzegovina convertible mark", + "BBD": "Barbadian dollar", + "BDT": "Bangladeshi taka", + "BGN": "Bulgarian lev", + "BHD": "Bahraini dinar", + "BIF": "Burundian franc", + "BMD": "Bermudian dollar", + "BND": "Brunei dollar", + "BOB": "Bolivian boliviano", + "BRL": "Brazilian real", + "BSD": "Bahamian dollar", + "BTC": "Bitcoin", + "BTN": "Bhutanese ngultrum", + "BWP": "Botswana pula", + "BYR": "Belarusian ruble (old)", + "BYN": "Belarusian ruble", + "BZD": "Belize dollar", + "CAD": "Canadian dollar", + "CDF": "Congolese franc", + "CHF": "Swiss franc", + "CLP": "Chilean peso", + "CNY": "Chinese yuan", + "COP": "Colombian peso", + "CRC": "Costa Rican colón", + "CUC": "Cuban convertible peso", + "CUP": "Cuban peso", + "CVE": "Cape Verdean escudo", + "CZK": "Czech koruna", + "DJF": "Djiboutian franc", + "DKK": "Danish krone", + "DOP": "Dominican peso", + "DZD": "Algerian dinar", + "EGP": "Egyptian pound", + "ERN": "Eritrean nakfa", + "ETB": "Ethiopian birr", + "EUR": "Euro", + "FJD": "Fijian dollar", + "FKP": "Falkland Islands pound", + "GBP": "Pound sterling", + "GEL": "Georgian lari", + "GGP": "Guernsey pound", + "GHS": "Ghana cedi", + "GIP": "Gibraltar pound", + "GMD": "Gambian dalasi", + "GNF": "Guinean franc", + "GTQ": "Guatemalan quetzal", + "GYD": "Guyanese dollar", + "HKD": "Hong Kong dollar", + "HNL": "Honduran lempira", + "HRK": "Croatian kuna", + "HTG": "Haitian gourde", + "HUF": "Hungarian forint", + "IDR": "Indonesian rupiah", + "ILS": "Israeli new shekel", + "IMP": "Manx pound", + "INR": "Indian rupee", + "IQD": "Iraqi dinar", + "IRR": "Iranian rial", + "IRT": "Iranian toman", + "ISK": "Icelandic króna", + "JEP": "Jersey pound", + "JMD": "Jamaican dollar", + "JOD": "Jordanian dinar", + "JPY": "Japanese yen", + "KES": "Kenyan shilling", + "KGS": "Kyrgyzstani som", + "KHR": "Cambodian riel", + "KMF": "Comorian franc", + "KPW": "North Korean won", + "KRW": "South Korean won", + "KWD": "Kuwaiti dinar", + "KYD": "Cayman Islands dollar", + "KZT": "Kazakhstani tenge", + "LAK": "Lao kip", + "LBP": "Lebanese pound", + "LKR": "Sri Lankan rupee", + "LRD": "Liberian dollar", + "LSL": "Lesotho loti", + "LYD": "Libyan dinar", + "MAD": "Moroccan dirham", + "MDL": "Moldovan leu", + "MGA": "Malagasy ariary", + "MKD": "Macedonian denar", + "MMK": "Burmese kyat", + "MNT": "Mongolian tögrög", + "MOP": "Macanese pataca", + "MRO": "Mauritanian ouguiya", + "MUR": "Mauritian rupee", + "MVR": "Maldivian rufiyaa", + "MWK": "Malawian kwacha", + "MXN": "Mexican peso", + "MYR": "Malaysian ringgit", + "MZN": "Mozambican metical", + "NAD": "Namibian dollar", + "NGN": "Nigerian naira", + "NIO": "Nicaraguan córdoba", + "NOK": "Norwegian krone", + "NPR": "Nepalese rupee", + "NZD": "New Zealand dollar", + "OMR": "Omani rial", + "PAB": "Panamanian balboa", + "PEN": "Peruvian nuevo sol", + "PGK": "Papua New Guinean kina", + "PHP": "Philippine peso", + "PKR": "Pakistani rupee", + "PLN": "Polish złoty", + "PRB": "Transnistrian ruble", + "PYG": "Paraguayan guaraní", + "QAR": "Qatari riyal", + "RON": "Romanian leu", + "RSD": "Serbian dinar", + "RUB": "Russian ruble", + "RWF": "Rwandan franc", + "SAR": "Saudi riyal", + "SBD": "Solomon Islands dollar", + "SCR": "Seychellois rupee", + "SDG": "Sudanese pound", + "SEK": "Swedish krona", + "SGD": "Singapore dollar", + "SHP": "Saint Helena pound", + "SLL": "Sierra Leonean leone", + "SOS": "Somali shilling", + "SRD": "Surinamese dollar", + "SSP": "South Sudanese pound", + "STD": "São Tomé and Príncipe dobra", + "SYP": "Syrian pound", + "SZL": "Swazi lilangeni", + "THB": "Thai baht", + "TJS": "Tajikistani somoni", + "TMT": "Turkmenistan manat", + "TND": "Tunisian dinar", + "TOP": "Tongan paʻanga", + "TRY": "Turkish lira", + "TTD": "Trinidad and Tobago dollar", + "TWD": "New Taiwan dollar", + "TZS": "Tanzanian shilling", + "UAH": "Ukrainian hryvnia", + "UGX": "Ugandan shilling", + "USD": "United States (US) dollar", + "UYU": "Uruguayan peso", + "UZS": "Uzbekistani som", + "VEF": "Venezuelan bolívar", + "VND": "Vietnamese đồng", + "VUV": "Vanuatu vatu", + "WST": "Samoan tālā", + "XAF": "Central African CFA franc", + "XCD": "East Caribbean dollar", + "XOF": "West African CFA franc", + "XPF": "CFP franc", + "YER": "Yemeni rial", + "ZAR": "South African rand", + "ZMW": "Zambian kwacha" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 1, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5bfc4b00ff8ad", + "label": "VAT", + "name": "_wiaas_country_vat", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + } + ], + "location": [ + [ + { + "param": "taxonomy", + "operator": "==", + "value": "product_country" + } + ] + ], + "menu_order": 0, + "position": "side", + "style": "default", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": 1, + "description": "" + } +] \ 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 0a5bd98..0179cf9 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 @@ -132,4 +132,102 @@ function wiaas_db_update_add_installation_date_delivery_action_form() { $action_form_id = GFAPI::add_form($action_form_meta); do_action('gform_forms_post_import', array( GFAPI::get_form($action_form_id) )); +} + +// TODO: Remove after migration has been completed +function wiaas_db_migration_fix_user_profile_addresses() { + + $users = get_users(); + + foreach ($users as $user) { + + $billing_addresses = Wiaas_Customer::get_customer_billing_addresses($user->ID); + + if (! empty($billing_addresses)) { + + foreach ($billing_addresses as $index => $billing_address) { + + switch ($billing_address['id_country_selected']) { + + case 1: + $billing_address['country_code'] = 'se'; + break; + case 2: + $billing_address['country_code'] = 'dk'; + break; + case 3: + $billing_address['country_code'] = 'fi'; + break; + } + unset($billing_address['id_country_selected']); + $billing_addresses[$index] = $billing_address; + } + + update_user_meta( $user->ID, 'billing_addresses', $billing_addresses); + } + + $profile_addresses = Wiaas_Customer::get_customer_profile_addresses($user->ID); + + if (! empty($profile_addresses)) { + + foreach ($profile_addresses as $index => $profile_address) { + + switch ($profile_address['id_country_selected']) { + + case 1: + $profile_address['country_code'] = 'se'; + break; + case 2: + $profile_address['country_code'] = 'dk'; + break; + case 3: + $profile_address['country_code'] = 'fi'; + break; + } + unset($profile_address['id_country_selected']); + $profile_addresses[$index] = $profile_address; + } + + update_user_meta( $user->ID, 'profile_addresses', $profile_addresses); + } + + } +} + +// TODO: Remove after migration has been completed +function wiaas_db_migration_fix_countries() { + + $available_country_terms = get_terms(array( + 'taxonomy' => 'product_country', + 'hide_empty' => false, + )); + + foreach($available_country_terms as $country_term) { + + $code = ''; $currency = ''; $vat = ''; + + switch ($country_term->name) { + + case 'Sweden': + $code = 'se'; + $currency = 'SEK'; + $vat = 9; + break; + case 'Denmark': + $code = 'dk'; + $currency = 'DKK'; + $vat = 9; + break; + case 'Finland': + $code = 'fi'; + $currency = 'EUR'; + $vat = 9; + break; + } + + update_term_meta($country_term->term_id, '_wiaas_country_code', $code); + update_term_meta($country_term->term_id, '_wiaas_country_currency', $currency); + update_term_meta($country_term->term_id, '_wiaas_country_vat', $vat); + } + } \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-ui-fields.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-ui-fields.php index cdc5177..f958784 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-ui-fields.php +++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-ui-fields.php @@ -45,6 +45,15 @@ function wiaas_db_update_add_product_properties_ui_fields() { _wiaas_import_field_group($ui_json); } +function wiaas_db_update_add_country_settings_ui_fields() { + + $ui_json = file_get_contents( dirname( __FILE__ ) . '/data/wiaas-ui-field-country-settings.json' ); + + $ui_json = json_decode( $ui_json, true ); + + _wiaas_import_field_group($ui_json); +} + // private helper function diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-addon.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-addon.php index ecf4024..690385e 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-addon.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-addon.php @@ -11,9 +11,9 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension { protected $_slug = 'wiaas_delivery_process'; - protected $_title = 'Delivery Process'; + protected $_title = 'Delivery Settings'; - protected $_short_title = 'Delivery Process'; + protected $_short_title = 'Delivery Settings'; public static function get_instance() { @@ -125,7 +125,7 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension { $tabs[] = array( 'name' => $this->_slug, - 'label' => esc_html__( 'Delivery Process', 'wiaas' ), + 'label' => esc_html__( 'Delivery Settings', 'wiaas' ), 'query' => array( 'fid' => null ) ); @@ -218,14 +218,16 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension { return; } + $countries = Wiaas_Countries::get_available_countries(); + + $countries_choices = array(); + foreach ($countries as $country) { + $countries_choices[] = array( 'value' => $country['code'] , 'label' => $country['name'] ); + } $this->settings_select(array( 'name' => 'delivery_country', - 'choices' => array( - array( 'value' => 'se', 'label' => 'Sweden' ), - array( 'value' => 'dk', 'label' => 'Denmark' ), - array( 'value' => 'fi', 'label' => 'Finland' ) - ), + 'choices' => $countries_choices, 'after_select' => '

Choose country for which this process is defined.

' )); } diff --git a/backend/app/plugins/wiaas/includes/user/class-wiaas-customer.php b/backend/app/plugins/wiaas/includes/user/class-wiaas-customer.php index d3bde33..b8cbf53 100644 --- a/backend/app/plugins/wiaas/includes/user/class-wiaas-customer.php +++ b/backend/app/plugins/wiaas/includes/user/class-wiaas-customer.php @@ -133,9 +133,9 @@ class Wiaas_Customer { if ($new_address->id){ $updated = array( 'id' => $new_address->id, - 'country_name' => Wiaas_Countries::get_country_name_by_id($new_address->id_country_selected), + 'country_name' => Wiaas_Countries::get_available_country_name_by_code($new_address->country_code), 'delivery_mail' => $new_address->delivery_mail, - 'id_country_selected' => $new_address->id_country_selected, + 'country_code' => $new_address->country_code, 'city' => $new_address->city, 'detailed_address' => $new_address->detailed_address, 'zip_code' => $new_address->zip_code, @@ -152,9 +152,9 @@ class Wiaas_Customer { }else{ $new_billing_address = array( 'id' => time(), - 'country_name' => Wiaas_Countries::get_country_name_by_id($new_address->id_country_selected), + 'country_name' => Wiaas_Countries::get_available_country_name_by_code($new_address->country_code), 'delivery_mail' => $new_address->delivery_mail, - 'id_country_selected' => $new_address->id_country_selected, + 'country_code' => $new_address->country_code, 'city' => $new_address->city, 'detailed_address' => $new_address->detailed_address, 'zip_code' => $new_address->zip_code, @@ -178,9 +178,9 @@ class Wiaas_Customer { if ($new_address->id){ $updated = array( 'id' => $new_address->id, - 'country_name' => Wiaas_Countries::get_country_name_by_id($new_address->id_country_selected), + 'country_name' => Wiaas_Countries::get_available_country_name_by_code($new_address->country_code), 'delivery_mail' => $new_address->delivery_mail, - 'id_country_selected' => $new_address->id_country_selected, + 'country_code' => $new_address->country_code, 'city' => $new_address->city, 'detailed_address' => $new_address->detailed_address, 'zip_code' => $new_address->zip_code, @@ -197,9 +197,9 @@ class Wiaas_Customer { }else{ $new_delivery_address = array( 'id' => time(), - 'country_name' => Wiaas_Countries::get_country_name_by_id($new_address->id_country_selected), + 'country_name' => Wiaas_Countries::get_available_country_name_by_code($new_address->country_code), 'delivery_mail' => $new_address->delivery_mail, - 'id_country_selected' => $new_address->id_country_selected, + 'country_code' => $new_address->country_code, 'city' => $new_address->city, 'detailed_address' => $new_address->detailed_address, 'zip_code' => $new_address->zip_code, diff --git a/backend/app/plugins/wiaas/tests/unit-tests/api/test-wiaas-rest-user-api.php b/backend/app/plugins/wiaas/tests/unit-tests/api/test-wiaas-rest-user-api.php index 6f8176a..57704a3 100644 --- a/backend/app/plugins/wiaas/tests/unit-tests/api/test-wiaas-rest-user-api.php +++ b/backend/app/plugins/wiaas/tests/unit-tests/api/test-wiaas-rest-user-api.php @@ -102,7 +102,7 @@ class Wiass_REST_User_Api_Test extends Wiaas_Unit_Test_Case { $country = $data[0]; $this->assertNotNull($country); $this->assertTrue(is_array($country)); - $this->assertArrayHasKey('country_id', $country); - $this->assertArrayHasKey('country_name', $country); + $this->assertArrayHasKey('code', $country); + $this->assertArrayHasKey('name', $country); } } diff --git a/frontend/src/helpers/AddressHelper.js b/frontend/src/helpers/AddressHelper.js index abd9fac..2f65f03 100644 --- a/frontend/src/helpers/AddressHelper.js +++ b/frontend/src/helpers/AddressHelper.js @@ -3,7 +3,7 @@ export const fromWiaasAddress = (address) => { id: address.id, countryName: address.country_name, deliveryMail: address.delivery_mail, - idCountrySelected: address.id_country_selected, + idCountrySelected: address.country_code, city: address.city, detailedAddress: address.detailed_address, zipCode: address.zip_code, @@ -18,7 +18,7 @@ export const toWiaasAddress = (address) => { id: address.id, country_name: address.countryName, delivery_mail: address.deliveryMail, - id_country_selected: address.idCountrySelected, + country_code: address.idCountrySelected, city: address.city, detailed_address: address.detailedAddress, zip_code: address.zipCode, diff --git a/frontend/src/helpers/CountryHelper.js b/frontend/src/helpers/CountryHelper.js index e1c2ca6..7d708c2 100644 --- a/frontend/src/helpers/CountryHelper.js +++ b/frontend/src/helpers/CountryHelper.js @@ -1,6 +1,6 @@ export const fromWiaasCountryList = (countryList) => { return { - idCountry: countryList.country_id, - countryName: countryList.country_name + idCountry: countryList.code, + countryName: countryList.name } } \ No newline at end of file From 95d162578f226a57aa49064fdda022e5d3e60f6c Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Tue, 27 Nov 2018 01:47:01 +0100 Subject: [PATCH 07/37] Add timestamp script to composer --- backend/composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/composer.json b/backend/composer.json index dcb40e3..156fdc4 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -106,6 +106,9 @@ "wp wc update", "wp wc pb update", "wp wiaas update-db" + ], + "timestamp": [ + "php -r \"print date('YmdHis') . PHP_EOL;\" " ] } } From 2b688e8a5e4e002599331ab11d306bea81fe585d Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Tue, 27 Nov 2018 11:22:01 +0100 Subject: [PATCH 08/37] Remove unused code --- ...class-wiaas-admin-delivery-process-list.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php index c7f4bfb..596c8a5 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/class-wiaas-admin-delivery-process-list.php @@ -90,24 +90,6 @@ class Wiaas_Admin_Delivery_Process_List { * @return mixed */ public static function filter_gform_form_actions($actions, $form_id) { - - $form_details = GFAPI::get_form($form_id); - $delivery_settings = rgar($form_details, 'wiaas_delivery_process'); - - if (empty($delivery_settings)) { - - return $actions; - } - - $type = $delivery_settings['delivery_form_type']; - - $is_action = $type === 'action'; - - if (!$is_action) { - - unset($actions['entries']); - } - unset($actions['entries']); unset($actions['preview']); unset($actions['edit']); From 71d615907d9f9028d1e53d61444349308ffe880a Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Thu, 29 Nov 2018 11:13:15 +0100 Subject: [PATCH 09/37] Dashboards widgets --- .../wiaas/assets/css/datatables.min.css | 1 + .../assets/css/wiaas-admin-dashboard.css | 25 ++ .../css/wiaas-admin-delivery-process.css | 41 ++ .../plugins/wiaas/assets/css/wiaas-admin.css | 37 ++ .../plugins/wiaas/assets/images/sort_asc.png | Bin 0 -> 160 bytes .../plugins/wiaas/assets/images/sort_both.png | Bin 0 -> 201 bytes .../plugins/wiaas/assets/images/sort_desc.png | Bin 0 -> 158 bytes .../plugins/wiaas/assets/js/datatables.min.js | 180 ++++++++ .../wiaas/assets/js/wiaas-admin-dashboard.js | 14 + .../assets/js/wiaas-admin-delivery-process.js | 30 ++ .../admin-cl/class-wiaas-admin-cl-orders.php | 5 +- .../class-wiaas-admin-supplier-orders.php | 11 +- .../admin/class-wiaas-admin-dashboard.php | 172 +++++++ .../class-wiaas-admin-delivery-process.php | 4 +- ...lass-wiaas-admin-delivery-process-flow.php | 421 ++---------------- ...ass-wiaas-admin-delivery-process-order.php | 7 +- .../html-admin-delivery-process-page.php | 146 ++++++ .../html-delivery-process-navigation.php | 48 ++ .../html-delivery-process-step-action.php | 77 ++++ .../views/html-delivery-process-step.php | 67 +++ .../views/html-order-notes.php | 53 +++ .../html-order-suppliers-delivery-dates.php | 68 ++- .../wiaas-admin-delivery-process-ajax.php | 33 ++ .../wiaas/includes/class-wiaas-admin.php | 8 + .../includes/class-wiaas-delivery-process.php | 117 +++++ 25 files changed, 1139 insertions(+), 426 deletions(-) create mode 100644 backend/app/plugins/wiaas/assets/css/datatables.min.css create mode 100644 backend/app/plugins/wiaas/assets/css/wiaas-admin-dashboard.css create mode 100644 backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css create mode 100644 backend/app/plugins/wiaas/assets/css/wiaas-admin.css create mode 100644 backend/app/plugins/wiaas/assets/images/sort_asc.png create mode 100644 backend/app/plugins/wiaas/assets/images/sort_both.png create mode 100644 backend/app/plugins/wiaas/assets/images/sort_desc.png create mode 100644 backend/app/plugins/wiaas/assets/js/datatables.min.js create mode 100644 backend/app/plugins/wiaas/assets/js/wiaas-admin-dashboard.js create mode 100644 backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-dashboard.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-admin-delivery-process-page.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-navigation.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step-action.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step.php create mode 100644 backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-notes.php diff --git a/backend/app/plugins/wiaas/assets/css/datatables.min.css b/backend/app/plugins/wiaas/assets/css/datatables.min.css new file mode 100644 index 0000000..6565b40 --- /dev/null +++ b/backend/app/plugins/wiaas/assets/css/datatables.min.css @@ -0,0 +1 @@ +table.dataTable{width:100%;margin:0 auto;clear:both;border-collapse:separate;border-spacing:0}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th,table.dataTable thead td{padding:10px 18px;border-bottom:1px solid #111}table.dataTable thead th:active,table.dataTable thead td:active{outline:none}table.dataTable tfoot th,table.dataTable tfoot td{padding:10px 18px 6px 18px;border-top:1px solid #111}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc_disabled{cursor:pointer;*cursor:hand;background-repeat:no-repeat;background-position:center right}table.dataTable thead .sorting{background-image:url("../images/sort_both.png")}table.dataTable thead .sorting_asc{background-image:url("../images/sort_asc.png")}table.dataTable thead .sorting_desc{background-image:url("../images/sort_desc.png")}table.dataTable thead .sorting_asc_disabled{background-image:url("../images/sort_asc_disabled.png")}table.dataTable thead .sorting_desc_disabled{background-image:url("../images/sort_desc_disabled.png")}table.dataTable tbody tr{background-color:#ffffff}table.dataTable tbody tr.selected{background-color:#B0BED9}table.dataTable tbody th,table.dataTable tbody td{padding:8px 10px}table.dataTable.row-border tbody th,table.dataTable.row-border tbody td,table.dataTable.display tbody th,table.dataTable.display tbody td{border-top:1px solid #ddd}table.dataTable.row-border tbody tr:first-child th,table.dataTable.row-border tbody tr:first-child td,table.dataTable.display tbody tr:first-child th,table.dataTable.display tbody tr:first-child td{border-top:none}table.dataTable.cell-border tbody th,table.dataTable.cell-border tbody td{border-top:1px solid #ddd;border-right:1px solid #ddd}table.dataTable.cell-border tbody tr th:first-child,table.dataTable.cell-border tbody tr td:first-child{border-left:1px solid #ddd}table.dataTable.cell-border tbody tr:first-child th,table.dataTable.cell-border tbody tr:first-child td{border-top:none}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background-color:#f9f9f9}table.dataTable.stripe tbody tr.odd.selected,table.dataTable.display tbody tr.odd.selected{background-color:#acbad4}table.dataTable.hover tbody tr:hover,table.dataTable.display tbody tr:hover{background-color:#f6f6f6}table.dataTable.hover tbody tr:hover.selected,table.dataTable.display tbody tr:hover.selected{background-color:#aab7d1}table.dataTable.order-column tbody tr>.sorting_1,table.dataTable.order-column tbody tr>.sorting_2,table.dataTable.order-column tbody tr>.sorting_3,table.dataTable.display tbody tr>.sorting_1,table.dataTable.display tbody tr>.sorting_2,table.dataTable.display tbody tr>.sorting_3{background-color:#fafafa}table.dataTable.order-column tbody tr.selected>.sorting_1,table.dataTable.order-column tbody tr.selected>.sorting_2,table.dataTable.order-column tbody tr.selected>.sorting_3,table.dataTable.display tbody tr.selected>.sorting_1,table.dataTable.display tbody tr.selected>.sorting_2,table.dataTable.display tbody tr.selected>.sorting_3{background-color:#acbad5}table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{background-color:#f1f1f1}table.dataTable.display tbody tr.odd>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd>.sorting_2{background-color:#f3f3f3}table.dataTable.display tbody tr.odd>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd>.sorting_3{background-color:whitesmoke}table.dataTable.display tbody tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{background-color:#fafafa}table.dataTable.display tbody tr.even>.sorting_2,table.dataTable.order-column.stripe tbody tr.even>.sorting_2{background-color:#fcfcfc}table.dataTable.display tbody tr.even>.sorting_3,table.dataTable.order-column.stripe tbody tr.even>.sorting_3{background-color:#fefefe}table.dataTable.display tbody tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody tr:hover>.sorting_1,table.dataTable.order-column.hover tbody tr:hover>.sorting_1{background-color:#eaeaea}table.dataTable.display tbody tr:hover>.sorting_2,table.dataTable.order-column.hover tbody tr:hover>.sorting_2{background-color:#ececec}table.dataTable.display tbody tr:hover>.sorting_3,table.dataTable.order-column.hover tbody tr:hover>.sorting_3{background-color:#efefef}table.dataTable.display tbody tr:hover.selected>.sorting_1,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody tr:hover.selected>.sorting_2,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody tr:hover.selected>.sorting_3,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_3{background-color:#a5b2cb}table.dataTable.no-footer{border-bottom:1px solid #111}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}table.dataTable.compact thead th,table.dataTable.compact thead td{padding:4px 17px 4px 4px}table.dataTable.compact tfoot th,table.dataTable.compact tfoot td{padding:4px}table.dataTable.compact tbody th,table.dataTable.compact tbody td{padding:4px}table.dataTable th.dt-left,table.dataTable td.dt-left{text-align:left}table.dataTable th.dt-center,table.dataTable td.dt-center,table.dataTable td.dataTables_empty{text-align:center}table.dataTable th.dt-right,table.dataTable td.dt-right{text-align:right}table.dataTable th.dt-justify,table.dataTable td.dt-justify{text-align:justify}table.dataTable th.dt-nowrap,table.dataTable td.dt-nowrap{white-space:nowrap}table.dataTable thead th.dt-head-left,table.dataTable thead td.dt-head-left,table.dataTable tfoot th.dt-head-left,table.dataTable tfoot td.dt-head-left{text-align:left}table.dataTable thead th.dt-head-center,table.dataTable thead td.dt-head-center,table.dataTable tfoot th.dt-head-center,table.dataTable tfoot td.dt-head-center{text-align:center}table.dataTable thead th.dt-head-right,table.dataTable thead td.dt-head-right,table.dataTable tfoot th.dt-head-right,table.dataTable tfoot td.dt-head-right{text-align:right}table.dataTable thead th.dt-head-justify,table.dataTable thead td.dt-head-justify,table.dataTable tfoot th.dt-head-justify,table.dataTable tfoot td.dt-head-justify{text-align:justify}table.dataTable thead th.dt-head-nowrap,table.dataTable thead td.dt-head-nowrap,table.dataTable tfoot th.dt-head-nowrap,table.dataTable tfoot td.dt-head-nowrap{white-space:nowrap}table.dataTable tbody th.dt-body-left,table.dataTable tbody td.dt-body-left{text-align:left}table.dataTable tbody th.dt-body-center,table.dataTable tbody td.dt-body-center{text-align:center}table.dataTable tbody th.dt-body-right,table.dataTable tbody td.dt-body-right{text-align:right}table.dataTable tbody th.dt-body-justify,table.dataTable tbody td.dt-body-justify{text-align:justify}table.dataTable tbody th.dt-body-nowrap,table.dataTable tbody td.dt-body-nowrap{white-space:nowrap}table.dataTable,table.dataTable th,table.dataTable td{box-sizing:content-box}.dataTables_wrapper{position:relative;clear:both;*zoom:1;zoom:1}.dataTables_wrapper .dataTables_length{float:left}.dataTables_wrapper .dataTables_filter{float:right;text-align:right}.dataTables_wrapper .dataTables_filter input{margin-left:0.5em}.dataTables_wrapper .dataTables_info{clear:both;float:left;padding-top:0.755em}.dataTables_wrapper .dataTables_paginate{float:right;text-align:right;padding-top:0.25em}.dataTables_wrapper .dataTables_paginate .paginate_button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:0.5em 1em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;color:#333 !important;border:1px solid transparent;border-radius:2px}.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{color:#333 !important;border:1px solid #979797;background-color:white;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(100%, #dcdcdc));background:-webkit-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-moz-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-ms-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:-o-linear-gradient(top, #fff 0%, #dcdcdc 100%);background:linear-gradient(to bottom, #fff 0%, #dcdcdc 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active{cursor:default;color:#666 !important;border:1px solid transparent;background:transparent;box-shadow:none}.dataTables_wrapper .dataTables_paginate .paginate_button:hover{color:white !important;border:1px solid #111;background-color:#585858;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #585858), color-stop(100%, #111));background:-webkit-linear-gradient(top, #585858 0%, #111 100%);background:-moz-linear-gradient(top, #585858 0%, #111 100%);background:-ms-linear-gradient(top, #585858 0%, #111 100%);background:-o-linear-gradient(top, #585858 0%, #111 100%);background:linear-gradient(to bottom, #585858 0%, #111 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button:active{outline:none;background-color:#2b2b2b;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #2b2b2b), color-stop(100%, #0c0c0c));background:-webkit-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-moz-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-ms-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-o-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);box-shadow:inset 0 0 3px #111}.dataTables_wrapper .dataTables_paginate .ellipsis{padding:0 1em}.dataTables_wrapper .dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:20px;text-align:center;font-size:1.2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0)));background:-webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%)}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:#333}.dataTables_wrapper .dataTables_scroll{clear:both}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td{vertical-align:middle}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td>div.dataTables_sizing{height:0;overflow:hidden;margin:0 !important;padding:0 !important}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:1px solid #111}.dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable,.dataTables_wrapper.no-footer div.dataTables_scrollBody>table{border-bottom:none}.dataTables_wrapper:after{visibility:hidden;display:block;content:"";clear:both;height:0}@media screen and (max-width: 767px){.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate{float:none;text-align:center}.dataTables_wrapper .dataTables_paginate{margin-top:0.5em}}@media screen and (max-width: 640px){.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter{float:none;text-align:center}.dataTables_wrapper .dataTables_filter{margin-top:0.5em}} diff --git a/backend/app/plugins/wiaas/assets/css/wiaas-admin-dashboard.css b/backend/app/plugins/wiaas/assets/css/wiaas-admin-dashboard.css new file mode 100644 index 0000000..20d54dc --- /dev/null +++ b/backend/app/plugins/wiaas/assets/css/wiaas-admin-dashboard.css @@ -0,0 +1,25 @@ +.wiaas-dashboard-table { + width: 100%; +} + +.wiaas-dashboard-table thead td { + padding: .5em 1em +} + +.wiaas-dashboard-table tbody td { + border-top: 1px solid #f5f5f5; + vertical-align: middle; + padding: 1em +} + +.wiaas-dashboard-table-empty { + width: 100%; +} + +.wiaas-dashboard-table-empty p { + text-align: center; +} + +time.wiaas-order-date { + color: #999; +} \ No newline at end of file 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..cee3766 --- /dev/null +++ b/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css @@ -0,0 +1,41 @@ +#wiaas_delivery_process_order_notes .note_content { + background: #a7cedc; + padding: 10px; + position: relative; +} + +#wiaas_delivery_process_order_notes .note_content:after { + content: ''; + display: block; + position: absolute; + bottom: -10px; + left: 20px; + width: 0; + height: 0; + border-width: 10px 10px 0 0; + border-style: solid; + border-color: #a7cedc transparent; +} + +#wiaas_delivery_process_order_notes .note_content p { + margin: 0; + padding: 0; + word-wrap: break-word; +} + +#wiaas_delivery_process_order_notes p.meta { + padding: 10px; + color: #999; + margin: 0; + font-size: 11px; +} + +#wiaas_delivery_process_order_notes .add-note { + border-top: 1px solid #ddd; + padding: 10px 10px 0; +} + +#wiaas_delivery_process_order_notes .add-note textarea { + width: 100%; + height: 50px; +} \ No newline at end of file diff --git a/backend/app/plugins/wiaas/assets/css/wiaas-admin.css b/backend/app/plugins/wiaas/assets/css/wiaas-admin.css new file mode 100644 index 0000000..c384947 --- /dev/null +++ b/backend/app/plugins/wiaas/assets/css/wiaas-admin.css @@ -0,0 +1,37 @@ +mark.wiaas-order-status { + display: inline-flex; + padding: 0 1em; + line-height: 2.5em; + color: #777; + background: #e5e5e5; + border-radius: 4px; + border-bottom: 1px solid rgba(0, 0, 0, .05); + margin: -.5em 0; + cursor: inherit !important; + font-size: 13px; +} + +mark.wiaas-order-status-completed { + background: #c8d7e1; + color: #2e4453 +} + +mark.wiaas-order-status-on-hold { + background: #f8dda7; + color: #94660c +} + +mark.wiaas-order-status-failed { + background: #eba3a3; + color: #761919 +} + +mark.wiaas-order-status-processing { + background: #c6e1c6; + color: #5b841b +} + +mark.wiaas-order-status-trash { + background: #eba3a3; + color: #761919 +} \ No newline at end of file diff --git a/backend/app/plugins/wiaas/assets/images/sort_asc.png b/backend/app/plugins/wiaas/assets/images/sort_asc.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ba61a8055fcb18273f2468d335572204667b1f GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3I*bWaz@5R22v2@;zYta_*?F5u6Q zWR@in#&u+WgT?Hi<}D3B3}GOXuX|8Oj3tosHiJ3*4TN zC7>_x-r1O=t(?KoTC+`+>7&2GzdqLHBg&F)2Q?&EGZ+}|Rpsc~9`m>jw35No)z4*} HQ$iB}HK{Sd literal 0 HcmV?d00001 diff --git a/backend/app/plugins/wiaas/assets/images/sort_both.png b/backend/app/plugins/wiaas/assets/images/sort_both.png new file mode 100644 index 0000000000000000000000000000000000000000..af5bc7c5a10b9d6d57cb641aeec752428a07f0ca GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S0wixl{&NRX6FglULp08Bycxyy87-Q;~nRxO8@-UU*I^KVWyN+&SiMHu5xDOu|HNvwzODfTdXjhVyNu1 z#7^XbGKZ7LW3XeONb$RKLeE*WhqbYpIXPIqK@r4)v+qN8um%99%MPpS9d#7Ed7SL@Bp00i_>zopr0H-Zb Aj{pDw literal 0 HcmV?d00001 diff --git a/backend/app/plugins/wiaas/assets/images/sort_desc.png b/backend/app/plugins/wiaas/assets/images/sort_desc.png new file mode 100644 index 0000000000000000000000000000000000000000..0e156deb5f61d18f9e2ec5da4f6a8c94a5b4fb41 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3I*R8JSj5R22v2@yo z(czD9$NuDl3Ljm9c#_#4$vXUz=f1~&WY3aa=h!;z7fOEN>ySP9QA=6C-^Dmb&tuM= z4Z&=WZU;2WF>e%GI&mWJk^K!jrbro{W;-I>FeCfLGJl3}+Z^2)3Kw?+EoAU?^>bP0 Hl+XkKC^").css({position:"fixed",top:0,left:-1*h(E).scrollLeft(),height:1,width:1, +overflow:"hidden"}).append(h("
").css({position:"absolute",top:1,left:1,width:100,overflow:"scroll"}).append(h("
").css({width:"100%",height:10}))).appendTo("body"),d=c.children(),e=d.children();b.barWidth=d[0].offsetWidth-d[0].clientWidth;b.bScrollOversize=100===e[0].offsetWidth&&100!==d[0].clientWidth;b.bScrollbarLeft=1!==Math.round(e.offset().left);b.bBounding=c[0].getBoundingClientRect().width?!0:!1;c.remove()}h.extend(a.oBrowser,n.__browser);a.oScroll.iBarWidth=n.__browser.barWidth} +function hb(a,b,c,d,e,f){var g,j=!1;c!==k&&(g=c,j=!0);for(;d!==e;)a.hasOwnProperty(d)&&(g=j?b(g,a[d],d,a):a[d],j=!0,d+=f);return g}function Ea(a,b){var c=n.defaults.column,d=a.aoColumns.length,c=h.extend({},n.models.oColumn,c,{nTh:b?b:H.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols;c[d]=h.extend({},n.models.oSearch,c[d]);ka(a,d,h(b).data())}function ka(a,b,c){var b=a.aoColumns[b], +d=a.oClasses,e=h(b.nTh);if(!b.sWidthOrig){b.sWidthOrig=e.attr("width")||null;var f=(e.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);f&&(b.sWidthOrig=f[1])}c!==k&&null!==c&&(fb(c),J(n.defaults.column,c),c.mDataProp!==k&&!c.mData&&(c.mData=c.mDataProp),c.sType&&(b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),c.sClass&&e.addClass(c.sClass),h.extend(b,c),F(b,c,"sWidth","sWidthOrig"),c.iDataSort!==k&&(b.aDataSort=[c.iDataSort]),F(b,c,"aDataSort"));var g=b.mData,j=S(g),i=b.mRender? +S(b.mRender):null,c=function(a){return"string"===typeof a&&-1!==a.indexOf("@")};b._bAttrSrc=h.isPlainObject(g)&&(c(g.sort)||c(g.type)||c(g.filter));b._setter=null;b.fnGetData=function(a,b,c){var d=j(a,b,k,c);return i&&b?i(d,b,a,c):d};b.fnSetData=function(a,b,c){return N(g)(a,b,c)};"number"!==typeof g&&(a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,e.addClass(d.sSortableNone));a=-1!==h.inArray("asc",b.asSorting);c=-1!==h.inArray("desc",b.asSorting);!b.bSortable||!a&&!c?(b.sSortingClass=d.sSortableNone, +b.sSortingClassJUI=""):a&&!c?(b.sSortingClass=d.sSortableAsc,b.sSortingClassJUI=d.sSortJUIAscAllowed):!a&&c?(b.sSortingClass=d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI)}function $(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Fa(a);for(var c=0,d=b.length;cq[f])d(l.length+q[f],m);else if("string"=== +typeof q[f]){j=0;for(i=l.length;jb&&a[e]--; -1!=d&&c===k&&a.splice(d, +1)}function da(a,b,c,d){var e=a.aoData[b],f,g=function(c,d){for(;c.childNodes.length;)c.removeChild(c.firstChild);c.innerHTML=B(a,b,d,"display")};if("dom"===c||(!c||"auto"===c)&&"dom"===e.src)e._aData=Ia(a,e,d,d===k?k:e._aData).data;else{var j=e.anCells;if(j)if(d!==k)g(j[d],d);else{c=0;for(f=j.length;c").appendTo(g));b=0;for(c=l.length;btr").attr("role","row");h(g).find(">tr>th, >tr>td").addClass(m.sHeaderTH);h(j).find(">tr>th, >tr>td").addClass(m.sFooterTH);if(null!==j){a=a.aoFooter[0];b=0;for(c=a.length;b=a.fnRecordsDisplay()?0:g,a.iInitDisplayStart=-1);var g=a._iDisplayStart,m=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(j){if(!a.bDestroying&&!lb(a))return}else a.iDraw++;if(0!==i.length){f=j?a.aoData.length:m;for(j=j?0:g;j",{"class":e?d[0]:""}).append(h("",{valign:"top",colSpan:V(a),"class":a.oClasses.sRowEmpty}).html(c))[0];r(a,"aoHeaderCallback","header",[h(a.nTHead).children("tr")[0],Ka(a),g,m,i]);r(a,"aoFooterCallback","footer",[h(a.nTFoot).children("tr")[0],Ka(a),g,m,i]);d=h(a.nTBody);d.children().detach(); +d.append(h(b));r(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function T(a,b){var c=a.oFeatures,d=c.bFilter;c.bSort&&mb(a);d?ga(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;P(a);a._drawHold=!1}function nb(a){var b=a.oClasses,c=h(a.nTable),c=h("
").insertBefore(c),d=a.oFeatures,e=h("
",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore= +a.nTable.nextSibling;for(var f=a.sDom.split(""),g,j,i,m,l,q,k=0;k")[0];m=f[k+1];if("'"==m||'"'==m){l="";for(q=2;f[k+q]!=m;)l+=f[k+q],q++;"H"==l?l=b.sJUIHeader:"F"==l&&(l=b.sJUIFooter);-1!=l.indexOf(".")?(m=l.split("."),i.id=m[0].substr(1,m[0].length-1),i.className=m[1]):"#"==l.charAt(0)?i.id=l.substr(1,l.length-1):i.className=l;k+=q}e.append(i);e=h(i)}else if(">"==j)e=e.parent();else if("l"==j&&d.bPaginate&&d.bLengthChange)g=ob(a);else if("f"==j&& +d.bFilter)g=pb(a);else if("r"==j&&d.bProcessing)g=qb(a);else if("t"==j)g=rb(a);else if("i"==j&&d.bInfo)g=sb(a);else if("p"==j&&d.bPaginate)g=tb(a);else if(0!==n.ext.feature.length){i=n.ext.feature;q=0;for(m=i.length;q',j=d.sSearch,j=j.match(/_INPUT_/)?j.replace("_INPUT_", +g):j+g,b=h("
",{id:!f.f?c+"_filter":null,"class":b.sFilter}).append(h("
").addClass(b.sLength);a.aanFeatures.l||(i[0].id=c+"_length");i.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",e[0].outerHTML));h("select",i).val(a._iDisplayLength).on("change.DT",function(){Ra(a,h(this).val());P(a)});h(a.nTable).on("length.dt.DT",function(b,c,d){a=== +c&&h("select",i).val(d)});return i[0]}function tb(a){var b=a.sPaginationType,c=n.ext.pager[b],d="function"===typeof c,e=function(a){P(a)},b=h("
").addClass(a.oClasses.sPaging+b)[0],f=a.aanFeatures;d||c.fnInit(a,b,e);f.p||(b.id=a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(a){if(d){var b=a._iDisplayStart,i=a._iDisplayLength,h=a.fnRecordsDisplay(),l=-1===i,b=l?0:Math.ceil(b/i),i=l?1:Math.ceil(h/i),h=c(b,i),k,l=0;for(k=f.p.length;lf&&(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0>d&&(d=0)):"next"==b?d+e",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]} +function C(a,b){a.oFeatures.bProcessing&&h(a.aanFeatures.r).css("display",b?"block":"none");r(a,null,"processing",[a,b])}function rb(a){var b=h(a.nTable);b.attr("role","grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,f=a.oClasses,g=b.children("caption"),j=g.length?g[0]._captionSide:null,i=h(b[0].cloneNode(!1)),m=h(b[0].cloneNode(!1)),l=b.children("tfoot");l.length||(l=null);i=h("
",{"class":f.sScrollWrapper}).append(h("
",{"class":f.sScrollHead}).css({overflow:"hidden", +position:"relative",border:0,width:d?!d?null:v(d):"100%"}).append(h("
",{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner||"100%"}).append(i.removeAttr("id").css("margin-left",0).append("top"===j?g:null).append(b.children("thead"))))).append(h("
",{"class":f.sScrollBody}).css({position:"relative",overflow:"auto",width:!d?null:v(d)}).append(b));l&&i.append(h("
",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:d?!d?null:v(d):"100%"}).append(h("
", +{"class":f.sScrollFootInner}).append(m.removeAttr("id").css("margin-left",0).append("bottom"===j?g:null).append(b.children("tfoot")))));var b=i.children(),k=b[0],f=b[1],t=l?b[2]:null;if(d)h(f).on("scroll.DT",function(){var a=this.scrollLeft;k.scrollLeft=a;l&&(t.scrollLeft=a)});h(f).css(e&&c.bCollapse?"max-height":"height",e);a.nScrollHead=k;a.nScrollBody=f;a.nScrollFoot=t;a.aoDrawCallback.push({fn:la,sName:"scrolling"});return i[0]}function la(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY,b=b.iBarWidth, +f=h(a.nScrollHead),g=f[0].style,j=f.children("div"),i=j[0].style,m=j.children("table"),j=a.nScrollBody,l=h(j),q=j.style,t=h(a.nScrollFoot).children("div"),n=t.children("table"),o=h(a.nTHead),p=h(a.nTable),s=p[0],r=s.style,u=a.nTFoot?h(a.nTFoot):null,x=a.oBrowser,U=x.bScrollOversize,Xb=D(a.aoColumns,"nTh"),Q,L,R,w,Ua=[],y=[],z=[],A=[],B,C=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};L=j.scrollHeight>j.clientHeight;if(a.scrollBarVis!== +L&&a.scrollBarVis!==k)a.scrollBarVis=L,$(a);else{a.scrollBarVis=L;p.children("thead, tfoot").remove();u&&(R=u.clone().prependTo(p),Q=u.find("tr"),R=R.find("tr"));w=o.clone().prependTo(p);o=o.find("tr");L=w.find("tr");w.find("th, td").removeAttr("tabindex");c||(q.width="100%",f[0].style.width="100%");h.each(ra(a,w),function(b,c){B=aa(a,b);c.style.width=a.aoColumns[B].sWidth});u&&I(function(a){a.style.width=""},R);f=p.outerWidth();if(""===c){r.width="100%";if(U&&(p.find("tbody").height()>j.offsetHeight|| +"scroll"==l.css("overflow-y")))r.width=v(p.outerWidth()-b);f=p.outerWidth()}else""!==d&&(r.width=v(d),f=p.outerWidth());I(C,L);I(function(a){z.push(a.innerHTML);Ua.push(v(h(a).css("width")))},L);I(function(a,b){if(h.inArray(a,Xb)!==-1)a.style.width=Ua[b]},o);h(L).height(0);u&&(I(C,R),I(function(a){A.push(a.innerHTML);y.push(v(h(a).css("width")))},R),I(function(a,b){a.style.width=y[b]},Q),h(R).height(0));I(function(a,b){a.innerHTML='
'+z[b]+"
";a.childNodes[0].style.height= +"0";a.childNodes[0].style.overflow="hidden";a.style.width=Ua[b]},L);u&&I(function(a,b){a.innerHTML='
'+A[b]+"
";a.childNodes[0].style.height="0";a.childNodes[0].style.overflow="hidden";a.style.width=y[b]},R);if(p.outerWidth()j.offsetHeight||"scroll"==l.css("overflow-y")?f+b:f;if(U&&(j.scrollHeight>j.offsetHeight||"scroll"==l.css("overflow-y")))r.width=v(Q-b);(""===c||""!==d)&&K(a,1,"Possible column misalignment",6)}else Q="100%";q.width=v(Q); +g.width=v(Q);u&&(a.nScrollFoot.style.width=v(Q));!e&&U&&(q.height=v(s.offsetHeight+b));c=p.outerWidth();m[0].style.width=v(c);i.width=v(c);d=p.height()>j.clientHeight||"scroll"==l.css("overflow-y");e="padding"+(x.bScrollbarLeft?"Left":"Right");i[e]=d?b+"px":"0px";u&&(n[0].style.width=v(c),t[0].style.width=v(c),t[0].style[e]=d?b+"px":"0px");p.children("colgroup").insertBefore(p.children("thead"));l.scroll();if((a.bSorted||a.bFiltered)&&!a._drawHold)j.scrollTop=0}}function I(a,b,c){for(var d=0,e=0, +f=b.length,g,j;e").appendTo(j.find("tbody"));j.find("thead, tfoot").remove();j.append(h(a.nTHead).clone()).append(h(a.nTFoot).clone());j.find("tfoot th, tfoot td").css("width","");m=ra(a,j.find("thead")[0]);for(n=0;n").css({width:o.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(a.aoData.length)for(n=0;n").css(f||e?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(j).appendTo(k);f&&g?j.width(g):f?(j.css("width","auto"),j.removeAttr("width"),j.width()").css("width",v(a)).appendTo(b||H.body),d=c[0].offsetWidth;c.remove();return d}function Fb(a, +b){var c=Gb(a,b);if(0>c)return null;var d=a.aoData[c];return!d.nTr?h("").html(B(a,c,b,"display"))[0]:d.anCells[b]}function Gb(a,b){for(var c,d=-1,e=-1,f=0,g=a.aoData.length;fd&&(d=c.length,e=f);return e}function v(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function X(a){var b,c,d=[],e=a.aoColumns,f,g,j,i;b=a.aaSortingFixed;c=h.isPlainObject(b);var m=[];f=function(a){a.length&& +!h.isArray(a[0])?m.push(a):h.merge(m,a)};h.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;ae?1:0,0!==c)return"asc"===j.dir?c:-c;c=d[a];e=d[b];return ce?1:0}):i.sort(function(a,b){var c,g,j,i,k=h.length,n=f[a]._aSortData,o=f[b]._aSortData;for(j=0;jg?1:0})}a.bSorted=!0}function Ib(a){for(var b,c,d=a.aoColumns,e=X(a),a=a.oLanguage.oAria,f=0,g=d.length;f/g,"");var i=c.nTh;i.removeAttribute("aria-sort");c.bSortable&&(0e?e+1:3));e=0;for(f=d.length;ee?e+1:3))}a.aLastSort=d}function Hb(a,b){var c=a.aoColumns[b],d=n.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,ba(a,b)));for(var f,g=n.ext.type.order[c.sType+"-pre"],j=0,i=a.aoData.length;j=f.length?[0,c[1]]:c)}));b.search!==k&&h.extend(a.oPreviousSearch,Bb(b.search));if(b.columns){d=0;for(e=b.columns.length;d=c&&(b=c-d);b-=b%d;if(-1===d||0>b)b=0;a._iDisplayStart=b}function Na(a,b){var c=a.renderer,d=n.ext.renderer[b];return h.isPlainObject(c)&&c[b]?d[c[b]]||d._:"string"=== +typeof c?d[c]||d._:d._}function y(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function ia(a,b){var c=[],c=Kb.numbers_length,d=Math.floor(c/2);b<=c?c=Y(0,b):a<=d?(c=Y(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-d?c=Y(b-(c-2),b):(c=Y(a-d+2,a+d-1),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function Da(a){h.each({num:function(b){return za(b,a)},"num-fmt":function(b){return za(b,a,Ya)},"html-num":function(b){return za(b, +a,Aa)},"html-num-fmt":function(b){return za(b,a,Aa,Ya)}},function(b,c){x.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(x.type.search[b+a]=x.type.search.html)})}function Lb(a){return function(){var b=[ya(this[n.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return n.ext.internal[a].apply(this,b)}}var n=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new s(ya(this[x.iApiIndex])):new s(this)}; +this.fnAddData=function(a,b){var c=this.api(!0),d=h.isArray(a)&&(h.isArray(a[0])||h.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===k||b)&&c.draw();return d.flatten().toArray()};this.fnAdjustColumnSizing=function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],d=c.oScroll;a===k||a?b.draw(!1):(""!==d.sX||""!==d.sY)&&la(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===k||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a, +b,c){var d=this.api(!0),a=d.rows(a),e=a.settings()[0],h=e.aoData[a[0][0]];a.remove();b&&b.call(this,e,h);(c===k||c)&&d.draw();return h};this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(a)};this.fnFilter=function(a,b,c,d,e,h){e=this.api(!0);null===b||b===k?e.search(a,c,d,h):e.column(b).search(a,c,d,h);e.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==k){var d=a.nodeName?a.nodeName.toLowerCase():"";return b!==k||"td"==d||"th"==d?c.cell(a,b).data(): +c.row(a).data()||null}return c.data().toArray()};this.fnGetNodes=function(a){var b=this.api(!0);return a!==k?b.row(a).node():b.rows().nodes().flatten().toArray()};this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase();return"TR"==c?b.row(a).index():"TD"==c||"TH"==c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]}; +this.fnPageChange=function(a,b){var c=this.api(!0).page(a);(b===k||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===k||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return ya(this[x.iApiIndex])};this.fnSort=function(a){this.api(!0).order(a).draw()};this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,d,e){var h=this.api(!0);c===k||null===c?h.row(b).data(a):h.cell(b,c).data(a);(e===k||e)&&h.columns.adjust(); +(d===k||d)&&h.draw();return 0};this.fnVersionCheck=x.fnVersionCheck;var b=this,c=a===k,d=this.length;c&&(a={});this.oApi=this.internal=x.internal;for(var e in n.ext.internal)e&&(this[e]=Lb(e));this.each(function(){var e={},g=1").appendTo(q)); +p.nTHead=b[0];b=q.children("tbody");b.length===0&&(b=h("").appendTo(q));p.nTBody=b[0];b=q.children("tfoot");if(b.length===0&&a.length>0&&(p.oScroll.sX!==""||p.oScroll.sY!==""))b=h("").appendTo(q);if(b.length===0||b.children().length===0)q.addClass(u.sNoFooter);else if(b.length>0){p.nTFoot=b[0];ea(p.aoFooter,p.nTFoot)}if(g.aaData)for(j=0;j/g,Zb=/^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/,$b=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"),Ya=/[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi,M=function(a){return!a||!0===a||"-"===a?!0:!1},Nb=function(a){var b=parseInt(a,10);return!isNaN(b)&& +isFinite(a)?b:null},Ob=function(a,b){Za[b]||(Za[b]=RegExp(Qa(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Za[b],"."):a},$a=function(a,b,c){var d="string"===typeof a;if(M(a))return!0;b&&d&&(a=Ob(a,b));c&&d&&(a=a.replace(Ya,""));return!isNaN(parseFloat(a))&&isFinite(a)},Pb=function(a,b,c){return M(a)?!0:!(M(a)||"string"===typeof a)?null:$a(a.replace(Aa,""),b,c)?!0:null},D=function(a,b,c){var d=[],e=0,f=a.length;if(c!==k)for(;ea.length)){b=a.slice().sort();for(var c=b[0],d=1,e=b.length;d")[0],Wb=va.textContent!==k,Yb= +/<.*?>/g,Oa=n.util.throttle,Rb=[],w=Array.prototype,ac=function(a){var b,c,d=n.settings,e=h.map(d,function(a){return a.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase())return b=h.inArray(a,e),-1!==b?[d[b]]:null;if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?c=h(a):a instanceof h&&(c=a)}else return[];if(c)return c.map(function(){b=h.inArray(this,e);return-1!==b?d[b]:null}).toArray()};s=function(a,b){if(!(this instanceof +s))return new s(a,b);var c=[],d=function(a){(a=ac(a))&&(c=c.concat(a))};if(h.isArray(a))for(var e=0,f=a.length;ea?new s(b[a],this[a]):null},filter:function(a){var b=[];if(w.filter)b=w.filter.call(this,a,this);else for(var c=0,d=this.length;c").addClass(b),h("td",c).addClass(b).html(a)[0].colSpan=V(d),e.push(c[0]))};f(a,b);c._details&&c._details.detach();c._details=h(e); +c._detailsShow&&c._details.insertAfter(c.nTr)}return this});o(["row().child.show()","row().child().show()"],function(){Tb(this,!0);return this});o(["row().child.hide()","row().child().hide()"],function(){Tb(this,!1);return this});o(["row().child.remove()","row().child().remove()"],function(){db(this);return this});o("row().child.isShown()",function(){var a=this.context;return a.length&&this.length?a[0].aoData[this[0]]._detailsShow||!1:!1});var bc=/^([^:]+):(name|visIdx|visible)$/,Ub=function(a,b, +c,d,e){for(var c=[],d=0,f=e.length;d=0?b:g.length+b];if(typeof a==="function"){var e=Ba(c,f);return h.map(g,function(b,f){return a(f,Ub(c,f,0,0,e),i[f])?f:null})}var k=typeof a==="string"?a.match(bc): +"";if(k)switch(k[2]){case "visIdx":case "visible":b=parseInt(k[1],10);if(b<0){var n=h.map(g,function(a,b){return a.bVisible?b:null});return[n[n.length+b]]}return[aa(c,b)];case "name":return h.map(j,function(a,b){return a===k[1]?b:null});default:return[]}if(a.nodeName&&a._DT_CellIndex)return[a._DT_CellIndex.column];b=h(i).filter(a).map(function(){return h.inArray(this,i)}).toArray();if(b.length||!a.nodeName)return b;b=h(a).closest("*[data-dt-column]");return b.length?[b.data("dt-column")]:[]},c,f)}, +1);c.selector.cols=a;c.selector.opts=b;return c});u("columns().header()","column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh},1)});u("columns().footer()","column().footer()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTf},1)});u("columns().data()","column().data()",function(){return this.iterator("column-rows",Ub,1)});u("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData}, +1)});u("columns().cache()","column().cache()",function(a){return this.iterator("column-rows",function(b,c,d,e,f){return ja(b.aoData,f,"search"===a?"_aFilterData":"_aSortData",c)},1)});u("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,d,e){return ja(a.aoData,e,"anCells",b)},1)});u("columns().visible()","column().visible()",function(a,b){var c=this.iterator("column",function(b,c){if(a===k)return b.aoColumns[c].bVisible;var f=b.aoColumns,g=f[c],j=b.aoData, +i,m,l;if(a!==k&&g.bVisible!==a){if(a){var n=h.inArray(!0,D(f,"bVisible"),c+1);i=0;for(m=j.length;id;return!0};n.isDataTable= +n.fnIsDataTable=function(a){var b=h(a).get(0),c=!1;if(a instanceof n.Api)return!0;h.each(n.settings,function(a,e){var f=e.nScrollHead?h("table",e.nScrollHead)[0]:null,g=e.nScrollFoot?h("table",e.nScrollFoot)[0]:null;if(e.nTable===b||f===b||g===b)c=!0});return c};n.tables=n.fnTables=function(a){var b=!1;h.isPlainObject(a)&&(b=a.api,a=a.visible);var c=h.map(n.settings,function(b){if(!a||a&&h(b.nTable).is(":visible"))return b.nTable});return b?new s(c):c};n.camelToHungarian=J;o("$()",function(a,b){var c= +this.rows(b).nodes(),c=h(c);return h([].concat(c.filter(a).toArray(),c.find(a).toArray()))});h.each(["on","one","off"],function(a,b){o(b+"()",function(){var a=Array.prototype.slice.call(arguments);a[0]=h.map(a[0].split(/\s/),function(a){return!a.match(/\.dt\b/)?a+".dt":a}).join(" ");var d=h(this.tables().nodes());d[b].apply(d,a);return this})});o("clear()",function(){return this.iterator("table",function(a){oa(a)})});o("settings()",function(){return new s(this.context,this.context)});o("init()",function(){var a= +this.context;return a.length?a[0].oInit:null});o("data()",function(){return this.iterator("table",function(a){return D(a.aoData,"_aData")}).flatten()});o("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,g=b.nTHead,j=b.nTFoot,i=h(e),f=h(f),k=h(b.nTableWrapper),l=h.map(b.aoData,function(a){return a.nTr}),o;b.bDestroying=!0;r(b,"aoDestroyCallback","destroy",[b]);a||(new s(b)).columns().visible(!0);k.off(".DT").find(":not(tbody *)").off(".DT"); +h(E).off(".DT-"+b.sInstance);e!=g.parentNode&&(i.children("thead").detach(),i.append(g));j&&e!=j.parentNode&&(i.children("tfoot").detach(),i.append(j));b.aaSorting=[];b.aaSortingFixed=[];wa(b);h(l).removeClass(b.asStripeClasses.join(" "));h("th, td",g).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);f.children().detach();f.append(l);g=a?"remove":"detach";i[g]();k[g]();!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),i.css("width",b.sDestroyWidth).removeClass(d.sTable), +(o=b.asDestroyStripes.length)&&f.children().each(function(a){h(this).addClass(b.asDestroyStripes[a%o])}));c=h.inArray(b,n.settings);-1!==c&&n.settings.splice(c,1)})});h.each(["column","row","cell"],function(a,b){o(b+"s().every()",function(a){var d=this.selector.opts,e=this;return this.iterator(b,function(f,g,h,i,m){a.call(e[b](g,"cell"===b?h:d,"cell"===b?d:k),g,h,i,m)})})});o("i18n()",function(a,b,c){var d=this.context[0],a=S(a)(d.oLanguage);a===k&&(a=b);c!==k&&h.isPlainObject(a)&&(a=a[c]!==k?a[c]: +a._);return a.replace("%d",c)});n.version="1.10.18";n.settings=[];n.models={};n.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};n.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1};n.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null, +sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};n.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1, +bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+ +a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"}, +oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:h.extend({}, +n.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"};Z(n.defaults);n.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null}; +Z(n.defaults.column);n.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[], +aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button", +iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:k,oAjaxData:k,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==y(this)?1*this._iRecordsTotal: +this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==y(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,f=e.bPaginate;return e.bServerSide?!1===f||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!f||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null};n.ext=x={buttons:{}, +classes:{},build:"dt/dt-1.10.18",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:n.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:n.version};h.extend(x,{afnFiltering:x.search,aTypes:x.type.detect,ofnSearch:x.type.search,oSort:x.type.order,afnSortData:x.order,aoFeatures:x.feature,oApi:x.internal,oStdClasses:x.classes,oPagination:x.pager}); +h.extend(n.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled", +sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"", +sJUIHeader:"",sJUIFooter:""});var Kb=n.ext.pager;h.extend(Kb,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},numbers:function(a,b){return[ia(a,b)]},simple_numbers:function(a,b){return["previous",ia(a,b),"next"]},full_numbers:function(a,b){return["first","previous",ia(a,b),"next","last"]},first_last_numbers:function(a,b){return["first",ia(a,b),"last"]},_numbers:ia,numbers_length:7});h.extend(!0,n.ext.renderer,{pageButton:{_:function(a,b,c,d,e, +f){var g=a.oClasses,j=a.oLanguage.oPaginate,i=a.oLanguage.oAria.paginate||{},m,l,n=0,o=function(b,d){var k,s,u,r,v=function(b){Ta(a,b.data.action,true)};k=0;for(s=d.length;k").appendTo(b);o(u,r)}else{m=null;l="";switch(r){case "ellipsis":b.append('');break;case "first":m=j.sFirst;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "previous":m=j.sPrevious;l=r+(e>0?"":" "+g.sPageButtonDisabled);break;case "next":m= +j.sNext;l=r+(e",{"class":g.sPageButton+" "+l,"aria-controls":a.sTableId,"aria-label":i[r],"data-dt-idx":n,tabindex:a.iTabIndex,id:c===0&&typeof r==="string"?a.sTableId+"_"+r:null}).html(m).appendTo(b);Wa(u,{action:r},v);n++}}}},s;try{s=h(b).find(H.activeElement).data("dt-idx")}catch(u){}o(h(b).empty(),d);s!==k&&h(b).find("[data-dt-idx="+ +s+"]").focus()}}});h.extend(n.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return $a(a,c)?"num"+c:null},function(a){if(a&&!(a instanceof Date)&&!Zb.test(a))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||M(a)?"date":null},function(a,b){var c=b.oLanguage.sDecimal;return $a(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Pb(a,c,!0)?"html-num-fmt"+c:null},function(a){return M(a)|| +"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);h.extend(n.ext.type.search,{html:function(a){return M(a)?a:"string"===typeof a?a.replace(Mb," ").replace(Aa,""):""},string:function(a){return M(a)?a:"string"===typeof a?a.replace(Mb," "):a}});var za=function(a,b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Ob(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};h.extend(x.type.order,{"date-pre":function(a){a=Date.parse(a);return isNaN(a)?-Infinity:a},"html-pre":function(a){return M(a)? +"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return M(a)?"":"string"===typeof a?a.toLowerCase():!a.toString?"":a.toString()},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return ab?-1:0}});Da("");h.extend(!0,n.ext.renderer,{header:{_:function(a,b,c,d){h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc: +c.sSortingClass)}})},jqueryui:function(a,b,c,d){h("
").addClass(d.sSortJUIWrapper).append(b.contents()).append(h("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);h(a.nTable).on("order.dt.DT",function(e,f,g,h){if(a===f){e=c.idx;b.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass(h[e]=="asc"?d.sSortAsc:h[e]=="desc"?d.sSortDesc:c.sSortingClass);b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass(h[e]== +"asc"?d.sSortJUIAsc:h[e]=="desc"?d.sSortJUIDesc:c.sSortingClassJUI)}})}}});var Vb=function(a){return"string"===typeof a?a.replace(//g,">").replace(/"/g,"""):a};n.render={number:function(a,b,c,d,e){return{display:function(f){if("number"!==typeof f&&"string"!==typeof f)return f;var g=0>f?"-":"",h=parseFloat(f);if(isNaN(h))return Vb(f);h=h.toFixed(c);f=Math.abs(h);h=parseInt(f,10);f=c?b+(f-h).toFixed(c).substring(2):"";return g+(d||"")+h.toString().replace(/\B(?=(\d{3})+(?!\d))/g, +a)+f+(e||"")}}},text:function(){return{display:Vb}}};h.extend(n.ext.internal,{_fnExternApiFunc:Lb,_fnBuildAjax:sa,_fnAjaxUpdate:lb,_fnAjaxParameters:ub,_fnAjaxUpdateDraw:vb,_fnAjaxDataSrc:ta,_fnAddColumn:Ea,_fnColumnOptions:ka,_fnAdjustColumnSizing:$,_fnVisibleToColumnIndex:aa,_fnColumnIndexToVisible:ba,_fnVisbleColumns:V,_fnGetColumns:ma,_fnColumnTypes:Ga,_fnApplyColumnDefs:ib,_fnHungarianMap:Z,_fnCamelToHungarian:J,_fnLanguageCompat:Ca,_fnBrowserDetect:gb,_fnAddData:O,_fnAddTr:na,_fnNodeToDataIndex:function(a, +b){return b._DT_RowIndex!==k?b._DT_RowIndex:null},_fnNodeToColumnIndex:function(a,b,c){return h.inArray(c,a.aoData[b].anCells)},_fnGetCellData:B,_fnSetCellData:jb,_fnSplitObjNotation:Ja,_fnGetObjectDataFn:S,_fnSetObjectDataFn:N,_fnGetDataMaster:Ka,_fnClearTable:oa,_fnDeleteIndex:pa,_fnInvalidate:da,_fnGetRowElements:Ia,_fnCreateTr:Ha,_fnBuildHead:kb,_fnDrawHead:fa,_fnDraw:P,_fnReDraw:T,_fnAddOptionsHtml:nb,_fnDetectHeader:ea,_fnGetUniqueThs:ra,_fnFeatureHtmlFilter:pb,_fnFilterComplete:ga,_fnFilterCustom:yb, +_fnFilterColumn:xb,_fnFilter:wb,_fnFilterCreateSearch:Pa,_fnEscapeRegex:Qa,_fnFilterData:zb,_fnFeatureHtmlInfo:sb,_fnUpdateInfo:Cb,_fnInfoMacros:Db,_fnInitialise:ha,_fnInitComplete:ua,_fnLengthChange:Ra,_fnFeatureHtmlLength:ob,_fnFeatureHtmlPaginate:tb,_fnPageChange:Ta,_fnFeatureHtmlProcessing:qb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:rb,_fnScrollDraw:la,_fnApplyToChildren:I,_fnCalculateColumnWidths:Fa,_fnThrottle:Oa,_fnConvertToWidth:Eb,_fnGetWidestNode:Fb,_fnGetMaxLenString:Gb,_fnStringToCss:v, +_fnSortFlatten:X,_fnSort:mb,_fnSortAria:Ib,_fnSortListener:Va,_fnSortAttachListener:Ma,_fnSortingClasses:wa,_fnSortData:Hb,_fnSaveState:xa,_fnLoadState:Jb,_fnSettingsFromNode:ya,_fnLog:K,_fnMap:F,_fnBindAction:Wa,_fnCallbackReg:z,_fnCallbackFire:r,_fnLengthOverflow:Sa,_fnRenderer:Na,_fnDataSource:y,_fnRowAttributes:La,_fnExtend:Xa,_fnCalculateEnd:function(){}});h.fn.dataTable=n;n.$=h;h.fn.dataTableSettings=n.settings;h.fn.dataTableExt=n.ext;h.fn.DataTable=function(a){return h(this).dataTable(a).api()}; +h.each(n,function(a,b){h.fn.DataTable[a]=b});return h.fn.dataTable}); + + diff --git a/backend/app/plugins/wiaas/assets/js/wiaas-admin-dashboard.js b/backend/app/plugins/wiaas/assets/js/wiaas-admin-dashboard.js new file mode 100644 index 0000000..9d08e2b --- /dev/null +++ b/backend/app/plugins/wiaas/assets/js/wiaas-admin-dashboard.js @@ -0,0 +1,14 @@ +jQuery(document).ready(function($) { + $('#wiaas_order_central_table').DataTable({ + "paging": false, + "info": false, + "filter": false, + "order": [[ 0, "desc" ]] + }); + + $('#wiaas_next_actions_table').DataTable({ + "info": false, + "filter": false, + "order": [[ 0, "desc" ]] + }); +} ); \ 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 index 10341bb..9af6a14 100644 --- a/backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js +++ b/backend/app/plugins/wiaas/assets/js/wiaas-admin-delivery-process.js @@ -5,4 +5,34 @@ jQuery(document).ready(function ($) { $('#wiaas_delivery_process_navigation_action').val(action); }); + + $('#wiaas_delivery_process_add_note').click(function(e) { + if ( ! $( 'textarea#wiaas_add_order_note' ).val() ) { + return; + } + + $( '#wiaas_delivery_process_order_notes' ).block({ + message: null, + overlayCSS: { + background: '#fff', + opacity: 0.6 + } + }); + + var data = { + action: 'wiaas_add_order_note', + post_id: $( 'textarea#wiaas_add_order_note' ).data('order-id'), + note: $( 'textarea#wiaas_add_order_note' ).val(), + security: $( 'textarea#wiaas_add_order_note' ).data('nonce'), + }; + + + $.post( ajaxurl, data, function( response ) { + $( '#delivery_process_order_notes_list' ).prepend( response ); + $( '#wiaas_delivery_process_order_notes' ).unblock(); + $( '#wiaas_add_order_note' ).val( '' ); + }); + + return false; + }); }); diff --git a/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-orders.php b/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-orders.php index 2486d65..05347f5 100644 --- a/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-orders.php +++ b/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-orders.php @@ -114,10 +114,13 @@ class Wiaas_Admin_CL_Orders { $order = wc_get_order($order_id); - echo '#' . esc_attr( $order->get_order_number() ) . ''; + $order_url = $entry_url = admin_url('admin.php?page=wiaas-order-delivery&id=' . $order->get_id()); if ( $order->get_status() !== 'trash' ) { + echo '#' . esc_attr( $order->get_order_number() ) . ''; echo '' . esc_html( __( 'Preview', 'wiaas' ) ) . ''; + } else { + echo '#' . esc_attr( $order->get_order_number() ) . ''; } } } diff --git a/backend/app/plugins/wiaas/includes/admin/admin-supplier/class-wiaas-admin-supplier-orders.php b/backend/app/plugins/wiaas/includes/admin/admin-supplier/class-wiaas-admin-supplier-orders.php index 700272b..b4cbf3f 100644 --- a/backend/app/plugins/wiaas/includes/admin/admin-supplier/class-wiaas-admin-supplier-orders.php +++ b/backend/app/plugins/wiaas/includes/admin/admin-supplier/class-wiaas-admin-supplier-orders.php @@ -124,11 +124,14 @@ class Wiaas_Admin_Supplier_Orders { $order = wc_get_order($order_id); - echo '#' . esc_attr($order->get_order_number()) . ''; + $order_url = $entry_url = admin_url('admin.php?page=wiaas-order-delivery&id=' . $order->get_id()); - if ($order->get_status() !== 'trash') { - echo '' . esc_html(__('Preview', 'wiaas')) . ''; - } + if ( $order->get_status() !== 'trash' ) { + echo '#' . esc_attr( $order->get_order_number() ) . ''; + echo '' . esc_html( __( 'Preview', 'wiaas' ) ) . ''; + } else { + echo '#' . esc_attr( $order->get_order_number() ) . ''; + } } } } diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-dashboard.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-dashboard.php new file mode 100644 index 0000000..82e809c --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-dashboard.php @@ -0,0 +1,172 @@ + 5, + 'status' => array('open', 'processing') + )); + + if (empty($orders)) { + + ?> +
+

+ +

+
+ + + + + + + + + + + + + get_date_created() ? $order->get_date_created()->getTimestamp() : ''; + $show_date = '–'; + + if ( $order_timestamp ) { + + if ( $order_timestamp > strtotime( '-1 day', current_time( 'timestamp', true ) ) && $order_timestamp <= current_time( 'timestamp', true ) ) { + $show_date = sprintf( + /* translators: %s: human-readable time difference */ + _x( '%s ago', '%s = human-readable time difference', 'wiaas' ), + human_time_diff( $order->get_date_created()->getTimestamp(), current_time( 'timestamp', true ) ) + ); + } else { + $show_date = $order->get_date_created()->date_i18n( __( 'M j, Y', 'wiaas' ) ); + } + } + + ?> + + + + + + + +
+ + get_id() ) . '&action=edit' ); + } else { + $order_edit_url = admin_url('admin.php?page=wiaas-order-delivery&id=' . absint( $order->get_id() ) ); + } + + echo '#' . + esc_html($order->get_order_number()) . + ''; + ?> + +
+ +
+ + + get_status() ) ) ?> + + + get_formatted_order_total() ?>
+ + +
+

+ +

+
+ + + + + + + + + + + + + + + + +
+ + # + + + + + +
+ + $delivery_process = Wiaas_Delivery_Process::get_order_delivery_process_entry($order->get_id()); -
-

- -

-
- - - -
-
- get_steps(); - - /** - * Disable if: - * - actions for customer config validation is not done - * - action for customer acceptance is active or completed - */ - $is_disabled = false; - foreach ($steps as $step) { - - if (Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step) && - $step->get_status() !== 'complete') { - - $is_disabled = true; - break; - } - - if (Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step) && - ($step->get_id() === $current_step->get_id() || $step->get_status() === 'complete')) { - - $is_disabled = true; - break; - } - } - - $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-suppliers-delivery-dates.php'; - } - - public static function maybe_process_admin_step_change_action($feedback, $admin_action, $form, $entry) { + private static function _maybe_process_admin_step_change_action($entry) { $admin_action = rgpost( 'wiaas_delivery_process_navigation_action' ); if ($admin_action === 'complete') { - $api = new Gravity_Flow_API( $form['id'] ); + $api = new Gravity_Flow_API( $entry['form_id'] ); $current_step = $api->get_current_step($entry); @@ -142,294 +60,15 @@ class Wiaas_Admin_Order_Process_Flow { } $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' ) { $step_id = $action_id; - $api = new Gravity_Flow_API( $form['id'] ); + $api = new Gravity_Flow_API( $entry['form_id'] ); $api->send_to_step( $entry, $step_id ); - $entry = GFAPI::get_entry( $entry['id'] ); - $new_step = $api->get_current_step( $entry ); - $feedback = $new_step ? - sprintf( esc_html__( 'Sent to step: %s', 'wiaas' ), $new_step->get_name() ) : - esc_html__( 'Workflow Complete', 'wiaas' ); } - - return $feedback; - } - - public static function maybe_display_delivery_process_navigation($form, $entry, $current_step) { - - if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) || - empty( $current_step ) || - Wiaas_Delivery_Process_Action::is_action_form($form) ) { - return; - } - - $steps = gravity_flow()->get_steps($form['id'], $entry); - - // get next step id - $next_step = gravity_flow()->get_next_step($current_step, $entry, $form); - $next_step_id = empty($next_step) ? null : $next_step->get_id(); - - // get previous step id - foreach ($steps as $step) { - - $next = gravity_flow()->get_next_step($step, $entry, $form); - if ($next && $next->get_id() === $current_step->get_id()) { - $previous_step = $step; - } - } - $previous_step_id = empty($previous_step) ? null : $previous_step->get_id(); - - // bail out if none exist - if ( empty($next_step_id) && empty($previous_step_id) ) { - - return; - } - - /** - * @reference Gravity_Flow::maybe_process_admin_action for used field names - * which are being checked there - * - */ - - ?> - -
- - - - - - - - class="button button-primary wiaas_delivery_step_nav" - style="float:right;" value="PREV STEP"> -
- id]; - } - } - - // display process steps - - $workflow_api = new Gravity_Flow_API($form['id']); - - $steps = $workflow_api->get_steps(); - - ?> - -
-

- - Order placed -

-
- -
-

- - Assign process -

-
- - $step) { - - if (! $step->is_active()) { - continue; - } - - $is_step_completed = $step->get_status() === 'complete' || $step->get_status() === 'approved'; - $is_current_step = $current_step && $step->get_id() === $current_step->get_id(); - - if ($is_current_step) { - $style = 'color: #FD8049;'; - } else if ($is_step_completed) { - $style = 'color: #34C388;'; - } else { - $style = 'opacity: 0.5; color: #CCC;'; - } - - ?> - -
- -

- - get_name(), 'wiaas') ?> -

- - target_form_id ); - - if (empty($action_form)) { - - echo '
'; - - continue; - } - - $page_size = 20; - $search_criteria = array( - 'status' => 'active', - 'field_filters' => array( - array( 'key' => 'wiaas_delivery_process_id', - 'value' => $entry['id'] - ), - ), - ); - $sorting = array( 'key' => 'date_created', 'direction' => 'DESC' ); - $paging = array( 'offset' => 0, 'page_size' => $page_size ); - - $entries = GFAPI::get_entries( $action_form['id'], $search_criteria, $sorting, $paging ); - - if (empty($entries)) { - - echo '
'; - - continue; - } - - ?> - -
- - - -

'; - - - foreach ($entries as $action_entry) { - self::_display_step_action_entry($action_form, $action_entry); - } - - ?> - -
- - - -
- - - -
- get_current_step($action_entry); - - $entry_url = add_query_arg( array( - 'page' => 'gravityflow-inbox', - 'view' => 'entry', - 'id' => $action_entry['form_id'], - 'lid' => $action_entry['id'] - ), admin_url() ); - - - ?> - - - type === 'wiaas_order') { - continue; - } - - if ($field->type === 'workflow_discussion') { - - echo ''; - - continue; - } - - $value = $field->get_value_entry_detail($action_entry[$field->id]); - $label = $field->get_field_label(false, $action_entry[$field->id]); - - echo '' . - '' . - '' . - ''; - } - - ?> - - - - - - - - -
' . $field->format_discussion_value($action_entry[$field->id]) . '
' . $label . ' : ' . $value . '
- - - get_status($action_entry) : - $current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();; - - echo '' . - ' ' . - ''; - - ?> - - -
- -
- 'gravityflow-inbox', - 'view' => 'entry', - 'id' => $process_entry['form_id'], - 'lid' => $process_entry['id'] - ), admin_url() ); + $entry_url = admin_url('admin.php?page=wiaas-order-delivery&id=' . $order_id); ?> Delivery Process diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-admin-delivery-process-page.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-admin-delivery-process-page.php new file mode 100644 index 0000000..fea8937 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-admin-delivery-process-page.php @@ -0,0 +1,146 @@ +get_id()); + +if ( ! empty($delivery_process)) { + + $form_id = $delivery_process['form_id']; + $workflow_api = new Gravity_Flow_API($form_id); + + $current_step = $workflow_api->get_current_step($delivery_process); + + $steps = $workflow_api->get_steps(); +} + +?> + +
+
+ + +
+
+ +
+
+
+ + + +
+
+
+ +
+ +
+
+
+
+

+ Delivery Order + get_id() ) ) . '&action=edit' ) . '">#' . esc_attr( $order->get_order_number() ) . ''; + } else { + echo '#' . esc_attr($order->get_order_number()); + } + ?> +     + + + get_status() ) ) ?> + + +

+ + +

+ + + +

+ + + Delivery process has not been assigned.'; + } + + if (! empty($delivery_process)) { + + $is_disabled = ! Wiaas_Delivery_Process::can_delivery_dates_be_set($order->get_id(), $delivery_process, $steps); + + require 'html-order-suppliers-delivery-dates.php'; + } + + ?> +
+
+
+
+ + + +
+

+ + Order placed +

+
+ +
+

+ + Assign process +

+
+ + get_step($step->get_id(), $delivery_process); + require 'html-delivery-process-step.php'; + } + ?> + + + +
+ +
+
+
+
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-navigation.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-navigation.php new file mode 100644 index 0000000..22f9a05 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-navigation.php @@ -0,0 +1,48 @@ +get_next_step($current_step, $current_step->get_entry(), $current_step->get_form()); +$next_step_id = empty($next_step) ? null : $next_step->get_id(); + +// get previous step id +foreach ($steps as $step) { + + $next = gravity_flow()->get_next_step($step, $current_step->get_entry(), $current_step->get_form()); + if ($next && $next->get_id() === $current_step->get_id()) { + $previous_step = $step; + } +} +$previous_step_id = empty($previous_step) ? null : $previous_step->get_id(); + +// bail out if none exist +if ( empty($next_step_id) && empty($previous_step_id) ) { + + return; +} + +?> + +
+ + + + + + + + class="button button-primary wiaas_delivery_step_nav" + style="float:right;" value="PREV STEP"> +
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step-action.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step-action.php new file mode 100644 index 0000000..b52c8fd --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step-action.php @@ -0,0 +1,77 @@ +get_current_step($action_entry); + +$entry_url = add_query_arg( array( + 'page' => 'gravityflow-inbox', + 'view' => 'entry', + 'id' => $action_entry['form_id'], + 'lid' => $action_entry['id'] +), admin_url() ); + +?> + + + + type === 'wiaas_order') { + continue; + } + + if ($field->type === 'workflow_discussion') { + + echo ''; + + continue; + } + + $value = $field->get_value_entry_detail($action_entry[$field->id]); + $label = $field->get_field_label(false, $action_entry[$field->id]); + + echo '' . + '' . + '' . + ''; + } + + ?> + + + + + + + + +
' . $field->format_discussion_value($action_entry[$field->id]) . '
' . $label . ' : ' . $value . '
+ + + get_status($action_entry) : + $current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();; + + echo '' . + ' ' . + ''; + + ?> + + +
+ +
+ + diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step.php new file mode 100644 index 0000000..a4d2ee5 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-delivery-process-step.php @@ -0,0 +1,67 @@ +get_status() === 'complete' || $step->get_status() === 'approved'; +$is_current_step = $current_step && $step->get_id() === $current_step->get_id(); + +if ($is_current_step) { + $style = 'color: #FD8049;'; +} else if ($is_step_completed) { + $style = 'color: #34C388;'; +} else { + $style = 'opacity: 0.5; color: #CCC;'; +} + +?> + +
+ +

+ + get_name(), 'wiaas') ?> +

+ + get_form(), $form, $step->get_entry()); + + $action_form = GFAPI::get_form( $step->target_form_id ); + + if (! empty($action_form)) { + + $page_size = 20; + $search_criteria = array( + 'status' => 'active', + 'field_filters' => array( + array( 'key' => 'wiaas_delivery_process_id', + 'value' => $delivery_process['id'] + ), + ), + ); + $sorting = array( 'key' => 'date_created', 'direction' => 'DESC' ); + $paging = array( 'offset' => 0, 'page_size' => $page_size ); + + $entries = GFAPI::get_entries( $action_form['id'], $search_criteria, $sorting, $paging ); + + $action_workflow = new Gravity_Flow_API($action_form['id']); + $current_assignee_key = $step->get_current_assignee_key(); + + foreach ($entries as $action_entry) { + + $action_entry_step = $action_workflow->get_current_step($action_entry); + + $show_entry = GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) || + ($action_entry_step && + $action_entry_step->is_assignee($current_assignee_key)); + + if ($show_entry) { + require 'html-delivery-process-step-action.php'; + } + } + } + + ?> + +
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-notes.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-notes.php new file mode 100644 index 0000000..d13922b --- /dev/null +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-notes.php @@ -0,0 +1,53 @@ + $order->get_id(), 'type' => 'customer' ) ); + +?> + +
+ +
+ +
+ content ) ) ); ?> +
+

+ date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?> + added_by ) : + /* translators: %s: note author */ + printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by ); + endif; + ?> +

+ +
+ +
+

+ + +

+

+ + +

+
+ +
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php index 93ae9e4..774023d 100644 --- a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php +++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php @@ -2,9 +2,16 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } + +$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); + ?> -
+
+
@@ -54,35 +61,50 @@ if ( ! defined( 'ABSPATH' ) ) { placeholder="Tracking URL" value="" /> - - class="button" - onClick="saveTrackingInfo(event, )" - value="SAVE"> - - class="button" - onClick="deleteTrackingInfo(event, )" value="REMOVE" - > + + + + class="button" + onClick="saveTrackingInfo(event, )" + value="SAVE"> + + class="button" + onClick="deleteTrackingInfo(event, )" value="REMOVE" + > + + + + + - - - 0 ) { + $order = wc_get_order( $post_id ); + $comment_id = $order->add_order_note( $note, true, true ); + $note = wc_get_order_note( $comment_id ); + ?> +
+ content ) ) ); ?> +
+

+ date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?> + added_by ); + ?> +

+ get_current_step($delivery_process_entry); + + if ( empty($steps) ) { + $steps = $workflow_api->get_steps(); + } + + foreach ($steps as $step) { + $step = $workflow_api->get_step($step->get_id(), $delivery_process_entry); + + // customer validation not done + if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step) && + $step->get_status() !== 'complete') { + + return false; + } + + // customer acceptance is active or completed + if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step) && + ($current_step && $step->get_id() === $current_step->get_id() || $step->get_status() === 'complete')) { + + return false; + } + } + + return true; + } + + public static function get_next_actions_for_current_user() { + + $current_user = wp_get_current_user(); + + $field_filters = array(); + $field_filters[] = array( + 'key' => 'workflow_user_id_' . $current_user->ID, + 'value' => 'pending', + ); + + $user_roles = gravity_flow()->get_user_roles(); + foreach ( $user_roles as $user_role ) { + $field_filters[] = array( + 'key' => 'workflow_role_' . $user_role, + 'value' => 'pending', + ); + } + + $field_filters['mode'] = 'any'; + + $search_criteria = array(); + $search_criteria['field_filters'] = $field_filters; + $search_criteria['status'] = 'active'; + + $form_ids = gravity_flow()->get_workflow_form_ids(); + + $entries = GFAPI::get_entries( + $form_ids, + $search_criteria, + null, + null); + + $actions = array(); + + foreach ($entries as $entry) { + + $order_id = $entry['wiaas_delivery_order_id']; + $order = wc_get_order($order_id); + + if (! $order) { + continue; + } + + $step = gravity_flow()->get_step( $entry['workflow_step'] ); + + if (!$step) { + continue; + } + + $action = array( + 'order_id' => $order_id, + 'order_number' => $order->get_order_number(), + 'action_title' => $step->get_name() + ); + + if (is_admin()) { + $action['url'] = '?page=gravityflow-inbox&view=entry&id=' . $entry['form_id'] . '&lid=' . $entry['id']; + } + + $actions[] = $action; + } + + return $actions; + } + /** * Maybe complete parent order for completed delivery process * @param $entry_id From 1f74fd9c23636c7ed40ba10ac6ff631ea96144f1 Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Thu, 29 Nov 2018 13:05:53 +0100 Subject: [PATCH 10/37] Added pricing to quickedit --- .../js/wiaas-admin-product-quick-edit.js | 32 ++++++++ .../wiaas/includes/class-wiaas-product.php | 2 + .../class-wiaas-product-quick-edit.php | 74 +++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js create mode 100644 backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php diff --git a/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js b/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js new file mode 100644 index 0000000..5fd24e8 --- /dev/null +++ b/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js @@ -0,0 +1,32 @@ +/*global inlineEditPost, woocommerce_admin, woocommerce_quick_edit */ +jQuery(function( $ ) { + $('#the-list').on('click', '.editinline', function(){ + + /** + * Extract metadata and put it as the value for the custom field form + */ + inlineEditPost.revert(); + + var post_id = jQuery(this).closest('tr').attr('id'); + + post_id = post_id.replace("post-", ""); + + var $cfd_inline_data = jQuery('#package_additional_fields_inline_' + post_id), + $wc_inline_data = jQuery('#woocommerce_inline_' + post_id ); + + jQuery('textarea[name="_package_pricing"]', '.inline-edit-row').val($cfd_inline_data.find("#_package_prices").text()); + + + /** + * Only show custom field for appropriate types of products (simple) + */ + var product_type = $wc_inline_data.find('.product_type').text(); + + if (product_type==='bundle') { + jQuery('.custom_field_demo', '.inline-edit-row').show(); + } else { + jQuery('.custom_field_demo', '.inline-edit-row').hide(); + } + + }); +}); \ No newline at end of file diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-product.php b/backend/app/plugins/wiaas/includes/class-wiaas-product.php index 73f5a82..3ce3d0d 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-product.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-product.php @@ -5,6 +5,8 @@ class Wiaas_Product { public static function init() { require_once dirname( __FILE__ ) . '/product/class-wiaas-product-category.php'; require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php'; + require_once dirname( __FILE__ ) . '/product/class-wiaas-product-quick-edit.php'; + add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'manage_product_settings')); diff --git a/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php b/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php new file mode 100644 index 0000000..3352bc4 --- /dev/null +++ b/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php @@ -0,0 +1,74 @@ + +

+
+

+ + +
+ + + Date: Thu, 29 Nov 2018 13:15:41 +0100 Subject: [PATCH 11/37] Hide pricing from quick edit, for unsupported product types --- .../plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js | 4 ++-- .../wiaas/includes/product/class-wiaas-product-quick-edit.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js b/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js index 5fd24e8..971122b 100644 --- a/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js +++ b/backend/app/plugins/wiaas/assets/js/wiaas-admin-product-quick-edit.js @@ -23,9 +23,9 @@ jQuery(function( $ ) { var product_type = $wc_inline_data.find('.product_type').text(); if (product_type==='bundle') { - jQuery('.custom_field_demo', '.inline-edit-row').show(); + jQuery('#wiaas_pricing_quick_edit', '.inline-edit-row').show(); } else { - jQuery('.custom_field_demo', '.inline-edit-row').hide(); + jQuery('#wiaas_pricing_quick_edit', '.inline-edit-row').hide(); } }); diff --git a/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php b/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php index 3352bc4..797c195 100644 --- a/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php +++ b/backend/app/plugins/wiaas/includes/product/class-wiaas-product-quick-edit.php @@ -21,8 +21,7 @@ class Wiaas_Product_Quick_Edit { public static function add_additional_fields_to_edit() { ?> -

-
+

Suppliers
+ + class="button" + id= onClick="addAdditionalTrackingInfo(event)" + value="Add new tracking info"> +
- - class="button" - id= onClick="addAdditionalTrackingInfo(event)" - value="Add new tracking info"> -