27 Commits

Author SHA1 Message Date
Almira Krdzic
4ee63b053c test 2018-10-21 02:40:58 +02:00
Almira Krdzic
bfc216b0fe test 2018-10-21 02:19:10 +02:00
Almira Krdzic
5cbdb482f2 test 2018-10-21 02:13:57 +02:00
Almira Krdzic
a61edbc984 test' 2018-10-20 14:02:06 +02:00
Almira Krdzic
70d16f95c5 test' 2018-10-20 13:46:02 +02:00
Almira Krdzic
5a42777500 test 2018-10-20 00:47:04 +02:00
Almira Krdzic
95318ff1c4 test 2018-10-20 00:42:03 +02:00
Almira Krdzic
88c5ae5eb1 test 2018-10-20 00:30:10 +02:00
Almira Krdzic
e618484725 test 2018-10-20 00:25:29 +02:00
Almira Krdzic
4d87551fef test 2018-10-20 00:08:48 +02:00
Almira Krdzic
52fb6dc5d9 test 2018-10-19 23:43:05 +02:00
Almira Krdzic
cfd602bef7 test 2018-10-19 23:30:03 +02:00
Almira Krdzic
6b3964c2ca test 2018-10-19 23:22:11 +02:00
Almira Krdzic
dc5461f616 test 2018-10-19 23:08:31 +02:00
Almira Krdzic
eecbeed2b8 test 2018-10-19 22:36:39 +02:00
Almira Krdzic
f21e1d90b5 test 2018-10-19 22:23:57 +02:00
Almira Krdzic
e323b597b1 test 2018-10-19 21:11:12 +02:00
Almira Krdzic
3d4c3c40c1 test 2018-10-19 20:55:33 +02:00
Almira Krdzic
c3b665cd51 test 2018-10-19 20:50:55 +02:00
Almira Krdzic
84f7974050 test 2018-10-19 20:44:30 +02:00
Almira Krdzic
bde4a9a91f test 2018-10-19 20:37:10 +02:00
Almira Krdzic
05863b4114 test 2018-10-19 20:32:42 +02:00
Almira Krdzic
fd2f01197e test 2018-10-19 20:20:19 +02:00
Almira Krdzic
30a51dae8c test 2018-10-19 20:16:05 +02:00
Almira Krdzic
b5b8a72eaf test 2018-10-19 20:10:20 +02:00
Almira Krdzic
5d8e759e80 Remove shop on org delete 2018-10-19 20:00:40 +02:00
Almira Krdzic
a5a795af93 Authenticate by role on frontend 2018-10-19 17:57:27 +02:00
132 changed files with 3176 additions and 7903 deletions

View File

@@ -1,6 +0,0 @@
# Added to prevent permission problems when building without using super user privileges
./database/volume
./docker/backend/uploads
./log/backend
./log/frontend

View File

@@ -18,9 +18,6 @@ ARG WP_SECURE_AUTH_SALT
ARG WP_LOGGED_IN_SALT
ARG WP_NONCE_SALT
ARG WP_JWT_AUTH_SECRET_KEY
ARG WP_SENDGRID_API_KEY
ARG WP_SENDGRID_FROM_EMAIL
ARG WP_SENDGRID_FROM_NAME
ENV WP_ENV ${WP_ENV}
ENV WP_HOME ${API_URL}
@@ -40,13 +37,9 @@ ENV WP_LOGGED_IN_SALT ${WP_LOGGED_IN_SALT}
ENV WP_NONCE_SALT ${WP_NONCE_SALT}
ENV WP_JWT_AUTH_SECRET_KEY ${WP_JWT_AUTH_SECRET_KEY}
ENV WP_SENDGRID_API_KEY ${WP_SENDGRID_API_KEY}
ENV WP_SENDGRID_FROM_EMAIL ${WP_SENDGRID_FROM_EMAIL}
ENV WP_SENDGRID_FROM_NAME ${WP_SENDGRID_FROM_NAME}
ENV WIAAS_CUSTOMER_INTERFACE ${WIAAS_CUSTOMER_INTERFACE}
RUN apt-get update && apt-get install -y git unzip gnupg mysql-client sudo libpng-dev
RUN apt-get update && apt-get install -y git unzip gnupg mysql-client sudo
COPY docker/php/composer.phar /usr/local/bin/composer
RUN chmod 755 /usr/local/bin/composer
@@ -57,8 +50,9 @@ RUN chmod +x /usr/local/bin/wp
COPY docker/php/setup.sh /init-scripts/
RUN chmod +x /init-scripts/setup.sh
RUN docker-php-ext-install pdo pdo_mysql mysqli opcache gd zip mbstring
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN a2enmod rewrite
RUN a2enmod headers
COPY docker/php/000-default.conf /etc/apache2/sites-available
COPY backend /home/wiaas/backend
@@ -67,18 +61,14 @@ WORKDIR /home/wiaas/backend/
RUN composer install --no-dev
WORKDIR /home/wiaas
RUN rm -rf backend/app/uploads
RUN cp -r backend/* /var/www/html/
WORKDIR home
RUN rm -rf wiaas
WORKDIR /var/www/html
RUN ln -s ../html api
COPY docker/php/.htaccess /var/www/html/
COPY docker/backend/TaC.pdf /var/www/html/
RUN chown -R www-data:www-data /var/www/html
#RUN chown -R www-data:www-data /var/www/html
CMD /init-scripts/setup.sh

View File

@@ -1,13 +0,0 @@
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# END WordPress

View File

@@ -19,46 +19,3 @@
.wc-order-preview footer {
display: none;
}
.gravityflow-discussion-item{
margin-bottom:10px;
padding: 6px;
}
.gravityflow-dicussion-item-name {
color:black;
font-weight:bold;
}
.gravityflow-dicussion-item-date {
color: #9b9b9b;
margin-left:8px;
font-size:90%;
}
.rtl .gravityflow-dicussion-item-date {
margin-right:8px;
margin-left: 0;
}
.gravityflow-dicussion-item-toggle-display {
float: right;
}
.rtl .gravityflow-dicussion-item-toggle-display {
float: left;
}
@media print {
.gravityflow-dicussion-item-hidden {
display:block !important;
}
.gravityflow-dicussion-item-toggle-display {
display: none;
}
}
.gravityflow-dicussion-item-value {
padding: 10px;
}

View File

@@ -1,3 +0,0 @@
.wc-order-preview-address {
display: none;
}

View File

@@ -1,8 +0,0 @@
jQuery(document).ready(function ($) {
$('.wiaas_delivery_step_nav').click(function (e) {
var action = $(this).data('step');
$('#wiaas_delivery_process_navigation_action').val(action);
});
});

View File

@@ -8,50 +8,4 @@ jQuery(document).ready(function($) {
$('#general_product_data').find('.pricing').addClass('hide_if_wiaastemplate hide_if_bundle');
$('#general_product_data').find('.pricing').removeClass('show_if_bundle show_if_wiaastemplate');
$( '.wiaas-search-documents' ).each(function() {
var element = $( this );
var searchTarget = $('#' + element.data('target'));
element.autocomplete({
source: function(request, response) {
$.get( window.ajaxurl, {
action: 'wiaas_json_search_documents',
query: request.term,
_ajax_nonce: element.data('search-nonce')
} ).done( function( documents ) {
response( documents || []);
}
);
},
select: function(event, ui) {
if (!searchTarget || $('#wiaas_attached_document_' + ui.item.id).length) {
return;
}
$.get(window.ajaxurl, {
action: 'wiaas_link_document',
_ajax_nonce: element.data('link-nonce'),
id: ui.item.id
}).done( function (document) {
searchTarget.find('tbody').append(document);
});
}
})
.autocomplete( 'instance' )._renderItem = function( ul, item ) {
return $( '<li role="option" id="wiaas-document-autocomplete-' + item.id + '">' )
.text( item.name )
.appendTo( ul );
};
});
$('#wiaas_attached_documents').delegate('.wiaas-remove-attached-document', 'click', function (e) {
e.preventDefault();
var id = $(this).data('id');
$('#wiaas_attached_document_' + id).remove();
});
});

View File

@@ -1,7 +0,0 @@
jQuery(document).ready(function($) {
$( document.body )
.on( 'wc_backbone_modal_loaded', function () {
$(".wc-order-preview-address").remove();
} );
});

View File

@@ -1,14 +0,0 @@
jQuery(document).bind('gform_load_field_settings', function (event, field, form) {
var isBundleDoc = field.type === 'wiaas_order_bundle_document';
var isOrderDoc = field.type === 'wiaas_order_document';
if (isBundleDoc || isOrderDoc) {
jQuery('#wiaas-doc-type-filter').val(field.wiaasDocTypeFilter);
}
jQuery('#wiaas-installation-organization-filter').prop('checked', !!field.wiaasOnlyInstallationOrg);
});

View File

@@ -1,136 +0,0 @@
<?php
/**
* Class Wiaas_Admin_Supplier_Orders
*/
class Wiaas_Admin_Supplier_Orders {
/**
* Displays list of orders from supplier
*
* Enables quick preview of each order
*
* This list of orders is achieved with customization of default order list for `shop_order` post
* by using hooks and filters to allow only data that suppliershould be able to see
*
*/
public static function init() {
add_filter('bulk_actions-edit-shop_order', array(__CLASS__, 'remove_bulk_actions_for_list_table_orders'), 999);
add_filter('woocommerce_admin_order_preview_actions', array(__CLASS__, 'remove_actions_from_order_preview'));
add_filter('woocommerce_admin_order_preview_line_items', array(__CLASS__, 'filter_order_items_for_order_preview'), 10, 2);
add_filter('manage_shop_order_posts_columns', array(__CLASS__, 'columns_for_list_table_orders'), 999);
add_filter('manage_edit-shop_order_sortable_columns', array(__CLASS__, 'define_sortable_columns_for_list_table_orders'));
add_action('manage_shop_order_posts_custom_column', array(__CLASS__, 'render_columns_for_list_table_orders'), 999, 2);
}
/**
* Remove all bulk actions for supplier
*
* @return array
*/
public static function remove_bulk_actions_for_list_table_orders() {
return array();
}
/**
* Remove actions from shop order preview modal so only data info is visible
*
* @return array
*/
public static function remove_actions_from_order_preview() {
return array();
}
/**
* Show only simple products from this supplier on order preview
*
* @param $order_items
* @param $order
*
* @return array
*/
public static function filter_order_items_for_order_preview($order_items, $order) {
$user_organisation_id = Wiaas_User_Organization::get_user_organization_id(wp_get_current_user()->ID);
$items = array();
foreach ($order_items as $key => $order_item) {
$product = wc_get_product($order_item->get_product_id());
if ($product->get_type() == 'simple') {
$supplier_organisation_id = Wiaas_Product_Supplier
::get_supplier_organisation_id_from_product($order_item->get_product_id());
if ($supplier_organisation_id === $user_organisation_id) {
$items[$key] = $order_item;
}
}
}
return $items;
}
/**
* Override default table columns so only supplier specific columns are visible
*
* @param $columns
*
* @return array
*/
public static function columns_for_list_table_orders($columns) {
$show_columns = array();
$show_columns['cb'] = $columns['cb'];
$show_columns['_wiaas_order_number'] = __( 'Order', 'woocommerce' );
$show_columns['order_date'] = __( 'Date', 'woocommerce' );
$show_columns['order_status'] = __( 'Status', 'woocommerce' );
return $show_columns;
}
/** Append supplier columns to table sortable columns
*
* @param $sortable_columns
*
* @return mixed
*/
public static function define_sortable_columns_for_list_table_orders($sortable_columns) {
$sortable_columns['_wiaas_order_number'] = 'ID';
return $sortable_columns;
}
/**
* Render supplier specific columns
*
* @param $column
* @param $order_id
*/
public static function render_columns_for_list_table_orders($column, $order_id) {
if ($column === '_wiaas_order_number') {
$order = wc_get_order($order_id);
echo '<strong>#' . esc_attr($order->get_order_number()) . '</strong>';
if ($order->get_status() !== 'trash') {
echo '<a href="#" class="order-preview" data-order-id="' . absint($order->get_id()) . '" title="' . esc_attr(__('Preview', 'wiaas')) . '">' . esc_html(__('Preview', 'wiaas')) . '</a>';
}
}
}
}
Wiaas_Admin_Supplier_Orders::init();

View File

@@ -1,22 +0,0 @@
<?php
class Wiaas_Admin_Delivery_Process {
public static function init() {
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';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}
public static function enqueue_scripts() {
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
wp_enqueue_script( 'wiaas_admin_delivery_process', $plugin_url . '/assets/js/wiaas-admin-delivery-process.js' );
}
}
Wiaas_Admin_Delivery_Process::init();

View File

@@ -3,6 +3,9 @@
class Wiaas_Admin_Order_Projects {
public static function init() {
// Add admin page and subpage since woocommerce orders have custom menu page
// so this will not be automatic
add_filter('admin_menu', array(__CLASS__, 'add_admin_page'));
// Add is available fields to create and edit forms
add_action( 'shop_order_project_add_form_fields', array( __CLASS__, 'add_is_available_field' ) );
@@ -15,20 +18,18 @@ class Wiaas_Admin_Order_Projects {
// Save is available field when creating and editing
add_action( 'created_term', array( __CLASS__, 'save_is_available_field' ), 10, 3 );
add_action( 'edit_term', array( __CLASS__, 'save_is_available_field' ), 10, 3 );
add_action( 'load-term.php', array( __CLASS__, 'admin_menu_highlight' ) );
add_action( 'load-edit-tags.php', array( __CLASS__, 'admin_menu_highlight' ) );
}
/**
* Highlighting orders menu when shop orders page selected
* Add admin submenu page for order projects
*/
public static function admin_menu_highlight() {
global $plugin_page;
if ( isset( $_GET['taxonomy'] ) && ( $_GET['taxonomy'] === 'shop_order_project' ) ) {
$plugin_page = 'edit.php?post_type=shop_order';
}
public static function add_admin_page() {
add_submenu_page( 'woocommerce',
esc_html__( 'Order projects', 'wiaas' ),
esc_html__( 'Order projects', 'wiaas' ),
'manage_woocommerce',
'edit-tags.php?taxonomy=shop_order_project'
);
}
/**

View File

@@ -18,7 +18,7 @@ class Wiaas_Admin_Organization {
add_filter('woocommerce_customer_meta_fields', array(__CLASS__, 'hide_woocommerce_customer_fields'));
// save related customers when organization form data has been saved by acf
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 11);
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 999);
// load related customers for organization form
add_filter('acf/load_value/name=_wiaas_organization_customers', array(__CLASS__, 'load_related_customer_organizations'), 10, 3);
@@ -64,6 +64,10 @@ class Wiaas_Admin_Organization {
//get organization id
$id = absint(str_replace('term_', '', $id));
if (!$id) {
return;
}
$customer_organization_ids = $_POST['acf'][$field['key']];
$customer_organization_ids = is_array($customer_organization_ids) ?
@@ -226,7 +230,7 @@ class Wiaas_Admin_Organization {
// get current user
$current_user = wp_get_current_user();
update_user_meta($current_user->ID, '_wiaas_admin_role', $role->name);
update_user_meta($current_user->ID, '_wiaas_current_user_admin_role', $role->name);
// switch user role
$current_user->set_role($role->name);

View File

@@ -11,8 +11,9 @@ class Wiaas_Admin_Package {
require_once dirname( __FILE__ ) . '/package/class-wiaas-admin-linked-packages.php';
require_once dirname( __FILE__ ) . '/package/class-wiaas-admin-package-types.php';
add_action( 'woocommerce_product_data_tabs', array( __CLASS__, 'package_data_tabs' ), 1 );
add_action( 'manage_product_posts_columns', array( __CLASS__, 'manage_list_table_products_columns' ), 999, 2 );
add_action( 'woocommerce_product_data_tabs', array( __CLASS__, 'package_data_tabs' ), 999);
}
/**
@@ -30,7 +31,6 @@ class Wiaas_Admin_Package {
unset($tabs['variations']);
unset($tabs['advanced']);
unset($tabs['shipping']);
unset($tabs['inventory']);
return $tabs;
}

View File

@@ -4,13 +4,12 @@ class Wiaas_Admin_Product {
public static function init() {
add_action('acf/save_post', array(__CLASS__, 'save_initial_product_country_and_type'), 20, 1);
add_action('acf/save_post', array(__CLASS__, 'wiaas_my_save_post'), 20, 1);
add_action('woocommerce_after_register_post_type', array(__CLASS__, 'wiaas_register_product_status'));
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'wiaas_modify_product'));
add_action('add_meta_boxes', array(__CLASS__, 'maybe_remove_metaboxes'), 999);
add_action('add_meta_boxes', array(__CLASS__, 'wiaas_maybe_remove_metaboxes'), 999);
add_filter('wp_insert_post_data', array(__CLASS__, 'wiaas_maybe_set_no_country_status'), 999, 2);
add_action('acf/render_field/type=group', array(__CLASS__, 'render_choose_button_for_new_product'), 10, 1);
add_action('acf/render_field/type=taxonomy', array(__CLASS__, 'wiaas_render_field'), 10, 1);
}
@@ -29,12 +28,13 @@ class Wiaas_Admin_Product {
));
}
public static function render_choose_button_for_new_product($field) {
if ($field['_name'] === '_wiaas_product_general') {
public static function wiaas_render_field($field) {
if ($field['_name'] === '_wiaas_product_country') {
?>
<div id="submitpost" style="padding: 20px 0;">
<input style="float:right;" name="publish" id="publish" class="button button-large button-primary" type="submit" value="Choose"/>
<div id="submitpost" style="padding: 20px;">
<input style="float:right;" name="save" id="save-post" class="button" type="submit" value="Choose"/>
</div>
<?php
}
@@ -42,7 +42,7 @@ class Wiaas_Admin_Product {
}
public static function maybe_remove_metaboxes() {
public static function wiaas_maybe_remove_metaboxes() {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
@@ -53,14 +53,19 @@ class Wiaas_Admin_Product {
$post_id = $post->ID;
if ($post_id === 0 || $post->post_status === '_wiaas_no_country') {
if ($post_id === 0 ||
($post->post_status !== 'publish' && !(Wiaas_Countries::get_package_country(wc_get_product($post_id))))) {
remove_meta_box('woocommerce-product-data', 'product', 'normal');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('slugdiv', 'product', 'normal');
remove_meta_box('wiaas_upload_and_link_document', 'product', 'normal');
remove_meta_box('postexcerpt', 'product', 'normal');
remove_meta_box('template_product_meta_box', 'product', 'normal');
remove_meta_box('postimagediv', 'product', 'normal');
remove_meta_box('woocommerce-product-images', 'product', 'normal');
remove_meta_box('wc-jetpack-product_by_user_role', 'product', 'normal');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('groups-permissions', 'product', 'side');
remove_meta_box('tagsdiv-product_tag', 'product', 'side');
@@ -68,16 +73,15 @@ class Wiaas_Admin_Product {
remove_meta_box('tagsdiv-supplier', 'product', 'side');
remove_meta_box('postimagediv', 'product', 'side');
remove_meta_box('woocommerce-product-images', 'product', 'side');
remove_meta_box('submitdiv', 'product', 'side');
remove_meta_box('wiaas_upload_and_link_document', 'product', 'side');
remove_meta_box('tagsdiv-product_country', 'product', 'side');
remove_meta_box('radio-tagsdiv-product_country', 'product', 'side');
remove_meta_box('tagsdiv-_wiaas_shop_prices', 'product', 'side');
remove_meta_box('tagsdiv-wiaas_units', 'product', 'side');
}
//Always hide product category, it is added wit advanced custom fields plugin for simple product
remove_meta_box('product_catdiv', 'product', 'side');
// Always hide
remove_meta_box('tagsdiv-product_country', 'product', 'side');
remove_meta_box('radio-product_catdiv', 'product', 'side');
}
@@ -95,54 +99,25 @@ class Wiaas_Admin_Product {
* @param $post_id
*/
public static function save_initial_product_country_and_type($post_id) {
public static function wiaas_my_save_post($post_id) {
global $post;
$status = get_post_status( $post->ID);
if ($post->post_type !== 'product') {
return;
}
$value = get_field('_wiaas_product_country', $post_id, true);
$type = get_field('_wiaas_product_type', $post_id, true);
$general = get_field('_wiaas_product_general', $post_id);
$country = $general['_wiaas_product_country'];
$type = $general['_wiaas_product_type'];
if (!empty($value) && $status === '_wiaas_no_country' ) {
/**
* If type is missing set status to no country
*
* If this is not template product type and country is missing set status to no country
*
*/
if (empty($type) || ( empty($country) && $type !== 'wiaastemplate' )) {
wp_update_post(array(
'ID' => $post_id,
'post_status' => '_wiaas_no_country'
));
wp_set_object_terms($post_id, $value, 'product_country', true);
wp_set_object_terms($post_id, $type, 'product_type', true);
return;
}
/**
* Country and type are selected for simple and bundle products so
* link them
*/
wp_set_object_terms($post_id, $type, 'product_type', true);
if ($type !== 'wiaastemplate') {
wp_set_object_terms($post_id, $country, 'product_country', true);
}
/**
* If product had no country status change it to draft status
*/
if ($post->post_status === '_wiaas_no_country') {
wp_update_post(array(
'ID' => $post_id,
'post_status' => 'draft'
));
}
}

View File

@@ -1,34 +0,0 @@
<?php
class Wiaas_Admin_Supplier {
public static function init() {
add_action('init', array(__CLASS__, 'init_admin_supplier'));
}
public static function init_admin_supplier() {
$current_user = wp_get_current_user();
$role = $current_user->roles[0];
$is_supplier = $role === 'supplier';
if ($is_supplier) {
require_once dirname( __FILE__ ) . '/admin-supplier/class-wiaas-admin-supplier-orders.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}
}
public static function enqueue_scripts() {
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
wp_enqueue_script( 'wiaas-admin-supplier', $plugin_url . '/assets/js/wiaas-admin-supplier.js' );
wp_enqueue_style( 'wiaas-admin-supplier', $plugin_url . '/assets/css/wiaas-admin-supplier.css' );
}
}
Wiaas_Admin_Supplier::init();

View File

@@ -1,437 +0,0 @@
<?php
class Wiaas_Admin_Order_Process_Flow {
public static function init() {
add_action( 'gravityflow_entry_detail', array( __CLASS__, 'display_process_steps_details' ), 10, 3 );
//add_action( 'gravityflow_title_entry_detail', array( __CLASS__, 'process_title' ), 10, 3 );
add_action('gravityflow_entry_detail', array(__CLASS__, 'add_delivery_dates_box'), 9, 3);
add_action('gravityflow_entry_detail', array(__CLASS__, 'maybe_display_delivery_process_navigation'), 9, 3);
add_action('gravityflow_workflow_detail_sidebar', array(__CLASS__, 'render_procurement_order_download_link'), 10, 3);
add_filter('gravityflow_admin_action_feedback', array(__CLASS__, 'maybe_process_admin_step_change_action'), 10, 4);
add_filter('gravityflow_admin_actions_workflow_detail', array(__CLASS__, 'filter_workflow_admin_actions'), 10, 5);
}
/**
* Filter workflow admin actions
*
* @param $admin_actions
* @param $current_step
* @param $steps
* @param $form
* @param $entry
*
* @return array
*/
public static function filter_workflow_admin_actions($admin_actions, $current_step, $steps, $form, $entry) {
$allowed_actions = array();
// allow basic admin actions for step action workflow
if (Wiaas_Delivery_Process_Action::is_action_form($form)) {
$allowed_actions = array( 'cancel_workflow', 'restart_workflow', 'restart_step');
}
$filtered_admin_actions = array();
foreach ( $admin_actions as $admin_action ) {
if (in_array($admin_action['value'], $allowed_actions)) {
$filtered_admin_actions[] = $admin_action;
}
}
return $filtered_admin_actions;
}
public static function render_procurement_order_download_link($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;
}
$order_id = $entry['wiaas_delivery_order_id'];
?>
<div class="postbox">
<h3 class="hndle">
<?php esc_html_e('Procurement report', 'wiaas') ?>
</h3>
<div style="padding: 10px;">
<a
id="wiaas_download_procurement_order_btn"
href="<?php echo admin_url() . '?wiaas-procurement-order-id=' . $order_id ?>"
download
class="button"
>
<span><?php esc_html_e('Download procurement report', 'wiaas') ?></span>
</a>
</div>
</div>
<?php
}
public static function add_delivery_dates_box($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;
}
$workflow_api = new Gravity_Flow_API($form['id']);
$steps = $workflow_api->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) {
$admin_action = rgpost( 'wiaas_delivery_process_navigation_action' );
if ($admin_action === 'complete') {
$api = new Gravity_Flow_API( $form['id'] );
$current_step = $api->get_current_step($entry);
if ( $current_step ) {
$current_step->purge_assignees();
$current_step->update_step_status( 'complete' );
}
$api->process_workflow($entry['id']);
$feedback = esc_html__( 'Workflow Complete', 'wiaas' );
return $feedback;
}
list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
if ( $base_admin_action == 'send_to_step' ) {
$step_id = $action_id;
$api = new Gravity_Flow_API( $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
*
*/
?>
<div style="padding:10px; height:40px">
<input id="wiaas_delivery_process_navigation_action" type="hidden" name="wiaas_delivery_process_navigation_action">
<input type="hidden" name="_gravityflow_admin_action" value="1">
<input
data-step="<?php echo empty($next_step_id) ? 'complete' : 'send_to_step|'.$next_step_id ?>"
type="submit"
class="button button-primary wiaas_delivery_step_nav"
style="float:right; margin-left: 20px;"
value="<?php echo empty($next_step_id) ? 'COMPLETE' : 'NEXT STEP' ?>"
>
<input
data-step="send_to_step|<?php esc_attr_e($previous_step_id, 'wiaas') ?>"
type="submit"
<?php disabled(empty($previous_step_id), true, true) ?>
class="button button-primary wiaas_delivery_step_nav"
style="float:right;" value="PREV STEP">
</div>
<?php
}
public static function display_process_steps_details($form, $entry, $current_step) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
if ($delivery_settings['delivery_form_type'] === 'action') {
return;
}
// get process order ID
$order_id = absint($entry['wiaas_delivery_order_id']);
if (empty($order_id)) {
$order_field = GFCommon::get_fields_by_type($form, array( 'wiaas_order') )[0];
if ( ! empty($order_field)) {
$order_id = $entry[$order_field->id];
}
}
// display process steps
$workflow_api = new Gravity_Flow_API($form['id']);
$steps = $workflow_api->get_steps();
?>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
<span>Order placed </span>
</h3>
</div>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
<span> Assign process </span>
</h3>
</div>
<?php
foreach ($steps as $index => $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;';
}
?>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px; <?php esc_attr_e($style, 'wiaas') ?>"></i>
<span><?php esc_html_e($step->get_name(), 'wiaas') ?></span>
</h3>
<?php
Gravity_Flow_Entry_Detail::maybe_show_instructions(true, true, $current_step, $form, $entry);
$action_form = GFAPI::get_form( $step->target_form_id );
if (empty($action_form)) {
echo '</div>';
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 '</div>';
continue;
}
?>
<div class="submitbox" style="padding: 10px;">
<table>
<tbody>
<?php
echo '<br><br><br>';
foreach ($entries as $action_entry) {
self::_display_step_action_entry($action_form, $action_entry);
}
?>
</tbody>
</table>
</div>
<?php
?>
</div>
<?php
}
}
private static function _display_step_action_entry($action_form, $action_entry) {
$workflow_api = new Gravity_Flow_API($action_entry['form_id']);
$current_action_step = $workflow_api->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() );
?>
<table>
<?php
foreach ($action_form['fields'] as $field) {
if ($field->type === 'wiaas_order') {
continue;
}
if ($field->type === 'workflow_discussion') {
echo '<tr style="padding: 20px;"><td colspan="2">' . $field->format_discussion_value($action_entry[$field->id]) . '</td></tr>';
continue;
}
$value = $field->get_value_entry_detail($action_entry[$field->id]);
$label = $field->get_field_label(false, $action_entry[$field->id]);
echo '<tr>' .
'<td><strong>' . $label . ' : </strong></td>' .
'<td>' . $value . '</td>' .
'</tr>';
}
?>
<tfoot>
<tr>
<td colspan="2" style="text-transform: uppercase;font-size: 11px; letter-spacing: 0.4px; margin:10px;">
<strong>
<?php
echo empty($current_action_step) ?
$workflow_api->get_status($action_entry) :
$current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();;
echo '<a target="_blank" href="' . $entry_url . '">' .
' <i class="fa fa-external-link" style="font-size: 16px;"></i>' .
'</a>';
?>
</strong>
</td>
</tr>
</tfoot>
<?php
?>
</table>
<hr />
<?php
}
}
Wiaas_Admin_Order_Process_Flow::init();

View File

@@ -1,221 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class Wiaas_Admin_Delivery_Process_Order {
public static function init() {
if (isset($_GET['wiaas-procurement-order-id'])) {
add_action('admin_init', array(__CLASS__, 'download_procurement_order'));
}
add_action('add_meta_boxes', array(__CLASS__, 'add_delivery_process_metabox'), 100 );
add_action('woocommerce_process_shop_order_meta', array(__CLASS__, 'maybe_assign_delivery_process'), 999);
}
/**
* Assign delivery process for order
*
* @param int $order_id
*/
public static function maybe_assign_delivery_process($order_id) {
if (! empty($_POST['wiaas_order_delivery_process_id'])) {
$process_id = absint($_POST['wiaas_order_delivery_process_id']);
Wiaas_Delivery_Process::create_delivery_process_for_order($order_id, $process_id);
}
}
public static function add_delivery_process_metabox() {
add_meta_box(
'order_delivery_process_meta_box',
__('Delivery Process', 'cmb'),
array(__CLASS__, 'order_delivery_process_meta_box'),
'shop_order',
'side',
'high'
);
}
public static function order_delivery_process_meta_box() {
global $post;
$order_id = $post->ID;
$process_entry = Wiaas_Delivery_Process::get_order_delivery_process_entry($order_id);
if ( empty($process_entry) ) {
$order = wc_get_order($order_id);
$list_of_delivery_processes = Wiaas_Delivery_Process::get_available_process_list_for_country(
Wiaas_Countries::get_country_code_by_currency($order->get_currency())
);
?>
<div>
<select name="wiaas_order_delivery_process_id" style="width: 100%;">
<option value="" disabled selected>Assign process to order ... </option>
<?php
foreach($list_of_delivery_processes as $index => $process){
echo '<option value=' . $process['id'] . '>' . $process['title'] . '</option>';
}
?>
</select>
<button type="submit" class="button" style="margin-top: 10px;">Assign</button>
</div>
<?php
} else{
$entry_url = add_query_arg( array(
'page' => 'gravityflow-inbox',
'view' => 'entry',
'id' => $process_entry['form_id'],
'lid' => $process_entry['id']
), admin_url() );
?>
<a href="<?php esc_attr_e($entry_url, 'wiaas') ?>"> Delivery Process </a>
<?php
}
}
/**
* Download procurement order report
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*
*/
public static function download_procurement_order() {
if (!is_user_logged_in()) {
wp_die( __( 'No Access.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 403 ) );
}
$order_id = $_GET['wiaas-procurement-order-id'];
$order = wc_get_order($order_id);
if (! $order) {
wp_die( __( 'Invalid order.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
}
$customer_user_id = $order->get_customer_id();
$organization_id = wiaas_get_user_organization_id($customer_user_id);
$customer_organization_info = wiaas_get_organization_info($organization_id);
$delivery_address = $order->get_shipping_address_1() . ',' .
$order->get_shipping_city() . ',' .
$order->get_shipping_country() . ',' .
$order->get_shipping_postcode();
$billing_address = $order->get_billing_address_1() . ',' .
$order->get_billing_city() . ',' .
$order->get_billing_country() . ',' .
$order->get_billing_postcode();
$order_procurement_info = wiaas_get_order_procurement_info($order->get_id());
$spreadsheet = new Spreadsheet();
$spreadsheet->getProperties()->setCreator("RICOH")
->setLastModifiedBy("Ricoh Dash")
->setTitle("Order Procurement Report")
->setSubject("Order Procurement Report")
->setDescription("Order Procurement Report")
->setKeywords("office 2007 openxml php order procurement")
->setCategory("Procurement report file");
$spreadsheet->setActiveSheetIndex(0);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('Order procurement');
$sheet->setCellValue('A1', 'Customer details');
$sheet->setCellValue('A2', 'Name');
$sheet->setCellValue('A3', 'Invoice address');
$sheet->setCellValue('A4', 'Invoice Full Name');
$sheet->setCellValue('A5', 'Invoice Email');
$sheet->setCellValue('A6', 'VAT Number');
$sheet->setCellValue('B2', ! empty($customer_organization_info) ? $customer_organization_info['name'] : '');
$sheet->setCellValue('B3', $billing_address);
$sheet->setCellValue('B4', $order->get_formatted_billing_full_name());
$sheet->setCellValue('B5', $order->get_billing_email());
$sheet->setCellValue('B6', ! empty($customer_organization_info) ? $customer_organization_info['vat_code'] : '');
$sheet->getStyle('A1')->getFont()->setBold(true);
$sheet->setCellValue('A9', 'OrderDetails');
$sheet->setCellValue('A10', 'Order number');
$sheet->setCellValue('A11', 'Project number');
$sheet->setCellValue('A12', 'Delivery addres');
$sheet->setCellValue('A13', 'Delivery Full Name');
$sheet->setCellValue('A14', 'Reference');
$sheet->setCellValue('B10', $order->get_order_number());
$sheet->setCellValue('B11', Wiaas_Order_Project::get_project_name_for_order($order->get_id()) );
$sheet->setCellValue('B12', $delivery_address);
$sheet->setCellValue('B13', $order->get_formatted_shipping_full_name());
$sheet->setCellValue('B14', $order->get_meta('_wiaas_reference'));
$sheet->getStyle('A9')->getFont()->setBold(true);
$row = 14;
foreach ($order_procurement_info as $category => $products) {
$col = 1; $row += 2;
$sheet->getColumnDimensionByColumn($col)->setAutoSize(true);
$sheet->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true);
$sheet->setCellValueByColumnAndRow($col, $row, ucfirst(strtolower($category)));
$row += 2;
if (! empty($products)) {
$product_columns = array_keys($products[0]);
foreach ($product_columns as $product_column_index => $product_column) {
$sheet->getColumnDimensionByColumn($product_column_index + 1)->setAutoSize(true);
$sheet->getStyleByColumnAndRow($product_column_index + 1, $row)->getFont()->setBold(true);
$sheet->setCellValueByColumnAndRow($product_column_index + 1, $row, $product_column);
}
}
$row += 1;
foreach ($products as $product) {
$product_values = array_values($product);
foreach ($product_values as $product_value_index => $product_value) {
$sheet->setCellValueByColumnAndRow($product_value_index + 1, $row, $product_value);
}
$row += 1;
}
}
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Procurement Report '.$order->get_order_number().'.xlsx"');
header('Cache-Control: max-age=0');
$writer = new Xlsx($spreadsheet);
$writer->save('php://output');
exit;
}
}
Wiaas_Admin_Delivery_Process_Order::init();

View File

@@ -1,38 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<p class="form-field form-field-wide">
<label for="estimated-delivery-date">Estimated delivery date:</label>
<input id="estimated-delivery-date" name="estimated-delivery-date"
type="date" value="<?php echo $order_estimated_delivery_date ? date("Y-m-d", $order_estimated_delivery_date) : ""; ?>"
onChange="onOrderEstimatedDeliveryDateChange(this.value)"/>
</p>
<script type="text/javascript">
function onOrderEstimatedDeliveryDateChange(date) {
var timestamp = parseInt((new Date(date).getTime() / 1000).toFixed(0));
if (isNaN(timestamp)){
timestamp = '';
}
var data = {
action: 'wiaas_save_estimated_date_for_order',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_save_estimated_date_for_order" ) ?>',
order: '<?php echo $order_id ?>',
date: timestamp
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
$.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
</script>

View File

@@ -1,225 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div style="margin-top: -20px;">
<table class="widefat" disabled="disabled">
<tr style="background: #EAF2FA;">
<th align="left"><strong>Suppliers</strong></th>
<th align="left"><strong>Estimated date</strong></th>
<th align="left"><strong>Confirmed date</strong></th>
</tr>
<?php
foreach($suppliers as $supplier){
echo '<tr style="background: #f5f5f5;"><td><strong>' . $supplier['name'] . '</strong></td>';
$estimated_date = $supplier['estimated_date'] ? date("Y-m-d", $supplier['estimated_date']) : "";
$confirmed_date = $supplier['confirmed_date'] ? date("Y-m-d", $supplier['confirmed_date']) : "";
?>
<td>
<input
id=<?php echo 'estimate-date-' . $supplier['id'] ?>
<?php disabled($is_disabled, true, true) ?>
type="date"
onChange="onEstimatedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)"
value="<?php echo $estimated_date ?>" />
</td>
<td>
<input
id=<?php echo 'confirmed-date-' . $supplier['id'] ?>
<?php disabled($is_disabled, true, true) ?>
type="date" onChange="onConfirmedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)"
value="<?php echo $confirmed_date ?>" />
</td>
</tr>
<tr>
<td colspan="3">
<span>Tracking:</span>
</td>
</tr>
<?php
foreach($supplier['tracking_info'] as $index => $tracking_info){
?>
<tr>
<td colspan="3">
<input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_num_' . $index ?>
<?php disabled($is_disabled, true, true) ?>
placeholder="Tracking number" value="<?php echo $tracking_info['number'] ?>" />
<input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_url_' . $index ?>
<?php disabled($is_disabled, true, true) ?>
placeholder="Tracking URL" value="<?php echo $tracking_info['url'] ?>" />
<input
type="button"
<?php disabled($is_disabled, true, true) ?>
class="button"
onClick="saveTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)"
value="SAVE">
<input
type="button"
<?php disabled($is_disabled, true, true) ?>
class="button"
onClick="deleteTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)" value="REMOVE"
>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">
<input
type="button"
<?php disabled($is_disabled, true, true) ?>
class="button"
id=<?php echo $supplier['id'] ?> onClick="addAdditionalTrackingInfo(event)"
value="Add new tracking info">
</td>
</tr>
<?php
}
?>
<tr>
<td><h4>Final dates : </h4></td>
<td><h4><?php echo $final_estimated_date ? date('Y-m-d', $final_estimated_date) : '-' ?></h4></td>
<td><h4><?php echo $final_confirmed_date ? date('Y-m-d', $final_confirmed_date) : '-' ?></h4></td>
</tr>
<tfoot>
<tr>
<td><h4>Earliest installation date : </h4></td>
<td colspan="2">
<h4><?php echo $earliest_installation_date ? date('Y-m-d', $earliest_installation_date) : '-' ?></h4>
</td>
</tr>
</tfoot>
</table>
</div>
<script type="text/javascript">
function onEstimatedDeliveryDateChange(supplierID, date) {
var timestamp = parseInt((new Date(date).getTime() / 1000).toFixed(0));
if (isNaN(timestamp)){
timestamp = '';
}
var data = {
action: 'wiaas_save_estimated_date_for_supplier',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_save_estimated_date_for_supplier" ) ?>',
order: '<?php echo $order_id ?>',
supplier: supplierID,
date: timestamp
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
function onConfirmedDeliveryDateChange(supplierID, date) {
var timestamp = parseInt((new Date(date).getTime() / 1000).toFixed(0));
if (isNaN(timestamp)){
timestamp = '';
}
var data = {
action: 'wiaas_save_confirmed_date_for_supplier',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_save_confirmed_date_for_supplier" ) ?>',
order: '<?php echo $order_id ?>',
supplier: supplierID,
date: timestamp
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
function addAdditionalTrackingInfo(e){
e.preventDefault();
var data = {
action: 'wiaas_add_additional_tracking_info_for_supplier_in_order',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_add_additional_tracking_info_for_supplier_in_order" ) ?>',
order: '<?php echo $order_id ?>',
supplier: e.target.id
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
function saveTrackingInfo(e, supplierID, index){
e.preventDefault();
var tracking_num = document.getElementById('supplier_' + supplierID + '_tracking_num_' + index).value;
var tracking_url = document.getElementById('supplier_' + supplierID + '_tracking_url_' + index).value;
var data = {
action: 'wiaas_save_tracking_info',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_save_tracking_info" ) ?>',
order: '<?php echo $order_id ?>',
supplier: supplierID,
index: index,
tracking_num: tracking_num,
tracking_url: tracking_url
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
function deleteTrackingInfo(e, supplierID, index){
e.preventDefault();
var data = {
action: 'wiaas_delete_tracking_info',
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_delete_tracking_info" ) ?>',
order: '<?php echo $order_id ?>',
supplier: supplierID,
index: index
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
if (response.success){
location.reload();
}else{
alert(response.data[0].message);
}
});
}
</script>

View File

@@ -1,120 +0,0 @@
<?php
add_action( 'wp_ajax_wiaas_add_additional_tracking_info_for_supplier_in_order', 'wiaas_ajax_add_additional_tracking_info_for_supplier_in_order' );
add_action( 'wp_ajax_wiaas_save_tracking_info', 'wiaas_ajax_save_tracking_info');
add_action( 'wp_ajax_wiaas_delete_tracking_info', 'wiaas_ajax_delete_tracking_info');
add_action( 'wp_ajax_wiaas_save_estimated_date_for_supplier', 'wiaas_ajax_save_estimated_date_for_supplier');
add_action( 'wp_ajax_wiaas_save_confirmed_date_for_supplier', 'wiaas_ajax_save_confirmed_date_for_supplier');
add_action( 'wp_ajax_wiaas_save_estimated_date_for_order', 'wiaas_ajax_save_estimated_date_for_order');
/**
* Adds additional tracking info for supplier in order
*/
function wiaas_ajax_add_additional_tracking_info_for_supplier_in_order(){
check_ajax_referer('wiaas_add_additional_tracking_info_for_supplier_in_order');
$error = new WP_Error('-1', 'Failed to add additional tracking info');
if (!isset($_POST['order']) || !isset($_POST['supplier'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$supplier_id = intval( $_POST['supplier'] );
if (Wiaas_Order::add_additional_tracking_info($order_id, $supplier_id)){
wp_send_json_success();
}
wp_send_json_error($error);
}
function wiaas_ajax_save_tracking_info(){
check_ajax_referer('wiaas_save_tracking_info');
$error = new WP_Error('-1', 'Failed to save tracking info');
if (!isset($_POST['order']) || !isset($_POST['supplier']) || !isset($_POST['index'])
|| !isset($_POST['tracking_num']) || !isset($_POST['tracking_url'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$supplier_id = intval( $_POST['supplier'] );
$index = intval($_POST['index']);
$tracking_num = $_POST['tracking_num'];
$tracking_url = $_POST['tracking_url'];
if (Wiaas_Order::save_tracking_info($order_id, $supplier_id, $index, $tracking_num, $tracking_url)){
wp_send_json_success();
}
wp_send_json_error($error);
}
function wiaas_ajax_delete_tracking_info(){
check_ajax_referer('wiaas_delete_tracking_info');
$error = new WP_Error('-1', 'Failed to save tracking info');
if (!isset($_POST['order']) || !isset($_POST['supplier']) || !isset($_POST['index'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$supplier_id = intval( $_POST['supplier'] );
$index = intval($_POST['index']);
if (Wiaas_Order::delete_tracking_info($order_id, $supplier_id, $index)){
wp_send_json_success();
}
wp_send_json_error($error);
}
function wiaas_ajax_save_estimated_date_for_supplier(){
check_ajax_referer('wiaas_save_estimated_date_for_supplier');
$error = new WP_Error('-1', 'Failed to save estimated date');
if (!isset($_POST['order']) || !isset($_POST['supplier']) || !isset($_POST['date'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$supplier_id = intval( $_POST['supplier'] );
$date = intval($_POST['date']);
if (Wiaas_Order::save_estimated_date($order_id, $supplier_id, $date)){
wp_send_json_success();
}
wp_send_json_error($error);
}
function wiaas_ajax_save_confirmed_date_for_supplier(){
check_ajax_referer('wiaas_save_confirmed_date_for_supplier');
$error = new WP_Error('-1', 'Failed to save confirmed date');
if (!isset($_POST['order']) || !isset($_POST['supplier']) || !isset($_POST['date'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$supplier_id = intval( $_POST['supplier'] );
$date = intval($_POST['date']);
if (Wiaas_Order::save_confirmed_date($order_id, $supplier_id, $date)){
wp_send_json_success();
}
wp_send_json_error($error);
}
function wiaas_ajax_save_estimated_date_for_order(){
check_ajax_referer('wiaas_save_estimated_date_for_order');
$error = new WP_Error('-1', 'Failed to save global estimated date for order');
if (!isset($_POST['order']) || !isset($_POST['date'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$date = intval($_POST['date']);
if (Wiaas_Order::save_order_estimated_date($order_id, $date)){
wp_send_json_success();
}
wp_send_json_error($error);
}

View File

@@ -152,29 +152,18 @@ $insert_new_document = $post->post_type !== 'wiaas_doc';
response = response.response;
var infoContainer = jQuery('#wiaas_upload_info');
if (response.substring(0, 6) === 'ERROR:') {
infoContainer.html('<span style="color: darkred;">' +
'<i class="dashicons dashicons-warning"></i>' +
jQuery('#wiaas_upload_errors').html('<span class="text-danger">' +
'<i class="fa fa-exclamation-triangle"></i>' +
' &nbsp; ' + response.substring(6, response.length) +
'</span>');
return;
}
infoContainer.html('<span style="color: darkgreen;">' +
'<i class="dashicons dashicons-yes"></i>' +
' &nbsp; ' + 'Document uploaded and linked' +
'</span>');
<?php
if ($insert_new_document) {
?>
$('#wiaas_attached_documents').find('tbody').append(response);
$('.wiaas_documents_tab a').click();
<?php
} else {
?>
@@ -263,8 +252,7 @@ $insert_new_document = $post->post_type !== 'wiaas_doc';
</div>
</div>
<div id="wiaas_upload_info">
<div id="wiaas_upload_errors" style="color: darkred;">
</div>
</div>

View File

@@ -8,17 +8,62 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$( '.wiaas-search-documents' ).each(function() {
var element = $( this );
var searchTarget = $('#' + element.data('target'));
element.autocomplete({
source: function(request, response) {
$.get( window.ajaxurl, {
action: 'wiaas_json_search_documents',
query: request.term,
_ajax_nonce: '<?php echo wp_create_nonce('wiaas_json_search_documents') ?>'
} ).done( function( documents ) {
response( documents || []);
}
);
},
select: function(event, ui) {
if (!searchTarget || $('#wiaas_attached_document_' + ui.item.id).length) {
return;
}
$.get(window.ajaxurl, {
action: 'wiaas_link_document',
_ajax_nonce: '<?php echo wp_create_nonce('wiaas_link_document') ?>',
id: ui.item.id
}).done( function (document) {
searchTarget.find('tbody').append(document);
});
}
})
.autocomplete( 'instance' )._renderItem = function( ul, item ) {
return $( '<li role="option" id="wiaas-document-autocomplete-' + item.id + '">' )
.text( item.name )
.appendTo( ul );
};
});
$('#wiaas_attached_documents').delegate('.wiaas-remove-attached-document', 'click', function (e) {
e.preventDefault();
var id = $(this).data('id');
$('#wiaas_attached_document_' + id).remove();
});
});
</script>
<div id="wiaas_documents" class="panel woocommerce_options_panel">
<div class="options_group">
<p class="form-field">
<label style="font-weight: bold;" for="wiaas_addon_packages"><?php esc_html_e( 'Search documents:', 'wiaas' ); ?></label>
<input
type="text"
data-target="wiaas_attached_documents"
data-search-nonce="<?php echo wp_create_nonce('wiaas_json_search_documents') ?>"
data-link-nonce="<?php echo wp_create_nonce('wiaas_link_document') ?>"
class="wiaas-search-documents"
/>
<input type="text" data-target="wiaas_attached_documents" class="wiaas-search-documents"/>
</p>
</div>
<div class="options_group">

View File

@@ -21,10 +21,24 @@ class Wiaas_Admin_Package_Pricing {
}
public static function get_package_price_html($price_html, $package) {
$bundled_items = $package->get_bundled_items();
$recurring_price = 0;
foreach ($bundled_items as $bundled_item) {
$product = $bundled_item->product;
$product_price = Wiaas_Product_Pricing::get_product_price($product);
if ($product_price['is_recurring']) {
$recurring_price += $product_price['price'] * $bundled_item->get_quantity();
}
}
$edit_link = admin_url( 'edit.php?post_type=product&page=wiaas-package_price_editor&id=' . absint( $package->get_id() ) );
return '<a class="button button-link" href="' . esc_url($edit_link) .'" target="_blank">Edit price<a>';
$price_html = 'Fixed: ' . $price_html . ' and ' . $recurring_price . ' / month' .
' <br> <a class="button button-link" href="' . esc_url($edit_link) .'" target="_blank">Edit price<a>';
return $price_html;
}
public static function render_edit_prices_link() {
@@ -148,8 +162,6 @@ class Wiaas_Admin_Package_Pricing {
$pricing_rules,
$commission,
$max_cost_margin);
Wiaas_Access_Management::maybe_handle_product_access($package_id, get_post($package_id));
}
}

View File

@@ -121,7 +121,8 @@ if ( ! defined( 'ABSPATH' ) ) {
if ($cat === 'product') {
$products_total_cost = wiaas_get_package_product_procurement_cost($package);
$products_total_cost = wiaas_get_package_hardware_procurement_cost($package) +
wiaas_get_package_software_procurement_cost($package);
esc_html_e('Total: ' . $products_total_cost, 'wiaas');
}

View File

@@ -44,14 +44,6 @@ class Wiaas_Admin_Product_Additional_Info {
}
}
/**
* This method filters search results by template country
* In addition it adds template category to label of every product
*
* @param $search_results array provided by filter
* @return mixed array of filtered search results
*/
public static function filter_product_by_country($search_results) {
$url = wp_get_referer();
@@ -67,14 +59,9 @@ class Wiaas_Admin_Product_Additional_Info {
if (!empty($search_results)) {
$search_result_objects = array_map('wc_get_product', array_keys($search_results));
foreach ($search_result_objects as $result_id => $product_form_search) {
if (Wiaas_Countries::get_product_country_term_id($product_form_search) !== $country_id) {
unset($search_results[$product_form_search->get_id()]);
} else {
$template_category = wp_get_object_terms($product_form_search->get_id(), 'template_category', array('fields' => 'names'));
if(!empty($template_category)){
$search_results[$product_form_search->get_id()] = $search_results[$product_form_search->get_id()].' ['.$template_category[0].']';
}
foreach ($search_result_objects as $result_id => $producta) {
if (Wiaas_Countries::get_product_country_term_id($producta) !== $country_id) {
unset($search_results[$producta->get_id()]);
}
}
}

View File

@@ -56,16 +56,10 @@ class Wiaas_Admin_Template_Selection {
<div id="wiaas_selected_template_items_container"><?php
$template_products_data = self::show_template_products($value);
$product = wc_get_product( $post->ID );
if ($product->get_type() == 'bundle') {
$bundled_items = $product->get_bundled_items('view');
$categories_form_bundle = WC_Product_Template::extract_bundled_product_categories($bundled_items);
self::render_template_products($template_products_data['hardware'], $categories_form_bundle);
self::render_template_products($template_products_data['services'], $categories_form_bundle);
self::render_template_products($template_products_data['installation'], $categories_form_bundle);
self::render_template_products($template_products_data['software'], $categories_form_bundle);
}
self::render_template_products($template_products_data['hardware']);
self::render_template_products($template_products_data['services']);
self::render_template_products($template_products_data['installation']);
self::render_template_products($template_products_data['software']);
?></div><?php
}
@@ -138,22 +132,17 @@ class Wiaas_Admin_Template_Selection {
* Render html of template categories
*
* @param $template_products array containing template category information
* @param $categories_form_bundle
*/
public static function render_template_products($template_products, $categories_form_bundle = array()) {
public static function render_template_products($template_products) {
if (!empty($template_products)) {
foreach ($template_products as $item) {
$connected_product = $categories_form_bundle[$item['template_category_id']] ?
$categories_form_bundle[$item['template_category_id']]->product_name : '';
$product_id = $item['template_category_id'];
$title = $item['template_category_title'];
$quantity = $item['quantity'];
$connected_product_name = $connected_product;
include('views/html-wiaas-template-selection.php');
}

View File

@@ -83,8 +83,7 @@ class Wiaas_Template_Admin_Ajax {
$terms = get_terms(array(
'taxonomy' => 'template_category',
'name__like' => $term,
'hide_empty' => false
'name__like' => $term
));
foreach ($terms as $t) {

View File

@@ -9,6 +9,5 @@ if (!defined('ABSPATH')) {
<h3>
<strong class="item-title"><?php echo $title; ?></strong>
<strong class="item-title">[<?php echo $quantity; ?>]</strong>
<strong class="item-title">[<?php echo $connected_product_name; ?>]</strong>
</h3>
</div><?php

View File

@@ -5,6 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
* TODO: This is temporary implemetation and will probably be changed during work on pending wiaas cart task
* Class Wiaas_Document_API
*/
class Wiaas_Document_API {
@@ -29,26 +30,30 @@ class Wiaas_Document_API {
)
) );
register_rest_route( self::$namespace, 'order/(?P<id>\d+)/item/(?P<item_id>\d+)/document/(?P<key>[\w-]+)', array(
register_rest_route( self::$namespace, 'documents/order/(?P<id>\d+)/(?P<type>[\w-]+)', array(
'args' => array(
'id' => array(
'description' => __( 'Order ID.', 'wiaas' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
)
),
'type' => array(
'description' => __( 'Order document type.', 'wiaas' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_key',
),
),
array(
'methods' => 'GET',
'permission_callback' => 'is_user_logged_in',
'callback' => array(__CLASS__, 'download_order_item_document'),
'callback' => array(__CLASS__, 'download_order_document'),
'args' => array(
'item_id' => array(
'description' => __( 'Package Order Item ID.', 'wiaas' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
'required' => true
),
'key' => array(
'document_key' => array(
'description' => __( 'Unique key identifier for order document.', 'wiaas' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_key',
@@ -57,29 +62,6 @@ class Wiaas_Document_API {
)
)
) );
register_rest_route(self::$namespace, 'order/(?P<id>\d+)/document/(?P<key>[\w-]+)', array(
'args' => array(
'id' => array(
'description' => __( 'Order ID.', 'wiaas' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
)
),
array(
'methods' => 'GET',
'permission_callback' => 'is_user_logged_in',
'callback' => array(__CLASS__, 'download_order_other_document'),
'args' => array(
'key' => array(
'description' => __( 'Unique key identifier for order document.', 'wiaas' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_key',
'required' => true
),
)
)
));
}
/**
@@ -94,23 +76,14 @@ class Wiaas_Document_API {
}
/**
* Download order item document
*
* Download order document
* @param WP_REST_Request $request
*/
public static function download_order_item_document($request) {
public static function download_order_document($request) {
Wiaas_Document_Download::download_order_item_document(
$request['id'],
$request['item_id'],
$request['key']);
}
/**
* Download order document
*
* @param WP_REST_Request $request
*/
public static function download_order_other_document($request) {
Wiaas_Document_Download::download_order_other_document($request['id'], $request['key']);
$request['type'],
$request['document_key']);
}
}

View File

@@ -73,7 +73,7 @@ class Wiaas_REST_Customer_API {
$customer_shops = array_map(function($customer_shop) {
return array(
'id' => $customer_shop['owner_id'],
'id' => absint($customer_shop['owner_id']),
'type' => $customer_shop['order_type'],
'name' => wiaas_get_organization_name($customer_shop['owner_id'])
);

View File

@@ -26,44 +26,28 @@ class Wiass_REST_Delivery_Process_API {
*/
private static $namespace = 'wiaas';
private static $rest_base = 'delivery';
public static function register_routes() {
register_rest_route( self::$namespace, '/' . self::$rest_base . '/next-actions', array(
register_rest_route( self::$namespace, 'next-delivery-steps', array(
'methods' => 'GET',
'callback' => array(__CLASS__, 'get_next_actions_for_user'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, '/' . self::$rest_base . '/(?P<order_id>\d+)/customer-acceptance', array(
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)', array(
'methods' => 'GET',
'callback' => array(__CLASS__, 'get_customer_acceptance'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, '/' . self::$rest_base . '/(?P<order_id>\d+)/customer-acceptance', array(
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)', array(
'methods' => 'POST',
'callback' => array(__CLASS__, 'submit_customer_acceptance'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, '/' . self::$rest_base . '/(?P<order_id>\d+)/customer-acceptance/upload' , array(
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)/upload-file' , array(
'methods' => 'POST',
'callback' => array(__CLASS__, 'upload_customer_acceptance'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, '/' . self::$rest_base . '/(?P<order_id>\d+)/customer-questionnaires', array(
'methods' => 'GET',
'callback' => array(__CLASS__, 'get_customer_questionnaires'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, '/' . self::$rest_base . '/(?P<order_id>\d+)/customer-questionnaires/upload/(?P<action_entry_id>\d+)', array(
'methods' => 'POST',
'callback' => array(__CLASS__, 'upload_customer_questionnaire'),
'callback' => array(__CLASS__, 'upload_file'),
'permission_callback' => 'is_user_logged_in'
) );
}
@@ -77,6 +61,14 @@ class Wiass_REST_Delivery_Process_API {
'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();
@@ -85,11 +77,10 @@ class Wiass_REST_Delivery_Process_API {
$form_ids = gravity_flow()->get_workflow_form_ids();
$entries = GFAPI::get_entries(
$form_ids,
$search_criteria,
null,
null);
$total_count = 7;
$entries = GFAPI::get_entries( $form_ids, $search_criteria, null, null, $total_count );
$data = array();
foreach ($entries as $entry) {
@@ -102,76 +93,200 @@ class Wiass_REST_Delivery_Process_API {
);
}
return rest_ensure_response($data);
}
global $wpdb;
public function get_customer_questionnaires(WP_REST_Request $request) {
$order_id = absint($request['order_id']);
$data = array();
$total = 0;
$queries =$wpdb->queries;
foreach ($queries as $query) {
$data[] = array(
$query[0],
$query[1]
);
$data = Wiaas_Delivery_Process::get_customer_questionnaires_data($order_id);
$total += $query[1];
}
return rest_ensure_response($data);
}
global $wp_timer;
public function upload_customer_questionnaire(WP_REST_Request $request) {
$order_id = absint($request['order_id']);
$action_entry_id = absint($request['action_entry_id']);
Wiaas_Delivery_Process::upload_customer_questionnaire($order_id, $action_entry_id);
return wiaas_api_notice('INSTALLATION_ACCEPTED', 'success');
return rest_ensure_response(array(
'data' => $queries,
'total' => $total * 1000,
'start' => (microtime() - $wp_timer) * 1000
));
}
public static function get_customer_acceptance(WP_REST_Request $request){
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return wiaas_api_generate_error('Customer acceptance entry not found', 404);
}
$order_id = absint($request['order_id']);
$acceptance_documents = array();
$uploaded_files = json_decode($entry[self::UPLOADED_FILES_FIELD_ID]);
$data = Wiaas_Delivery_Process::get_customer_acceptance_data($order_id);
foreach($uploaded_files as $file_url){
//example of decoded url :
//http://localhost/wp/index.php?gf-download=2018/08/rokovi-1535378841.docx&form-id=1&field-id=12&hash=1be6c30f0eeff93563b352d15fe459d5ded12ee06c2c8f36fed66b42dedf2534
$decoded_url = urldecode($file_url);
$url_parts = explode('?', $decoded_url);
$file_name_base_parts = explode('&', $url_parts[1]);
$file_name_parts = explode('/', $file_name_base_parts[0]);
$file_name_with_extension_parts = explode('.', $file_name_parts[2]);
return rest_ensure_response($data);
$acceptance_documents_entry = array(
'name' => $file_name_with_extension_parts[0],
'extension' => $file_name_with_extension_parts[1],
'url' => $file_url
);
array_push($acceptance_documents, $acceptance_documents_entry);
}
$acceptance_status = 0;
if ($entry[self::ACCEPTANCE_STATUS_FIELD_ID]){
$acceptance_status = ($entry[self::ACCEPTANCE_STATUS_FIELD_ID] === 'accept') ? 1 : -1;
}
return rest_ensure_response(array(
'documents' => $acceptance_documents,
'expiration' => $entry[self::EXPIRATION_DATE_FIELD_ID],
'status' => $acceptance_status,
'decline_reason' => $entry[self::DECLINE_REASON_FIELD_ID]
));
}
public static function submit_customer_acceptance(WP_REST_Request $request) {
public static function submit_customer_acceptance(WP_REST_Request $request){
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return wiaas_api_generate_error('Customer acceptance entry not found', 404);
}
$status = $request['action_type'];
$reason = $request['decline_reason'];
$status = $request['actionType'];
$reason = $request['declineReason'];
if (!in_array($status, self::ACCEPTABLE_STATUS)){
return wiaas_api_notice('ACCEPTANCE_STATUS_MISSING', 'error');
}
$installation_declined = ($status === self::DECLINE_STATUS_LABEL);
$uploaded_files = json_decode($entry[self::UPLOADED_FILES_FIELD_ID]);
if ($installation_declined && $reason === ''){
return wiaas_api_notice('DECLINE_REASON_EMPTY', 'error');
}
$order_id = $request['order_id'];
if (! $installation_declined && ! Wiaas_Delivery_Process::is_customer_acceptance_uploaded($order_id)) {
if (!$installation_declined && (count($uploaded_files)===0)){
return wiaas_api_notice('ACCEPTANCE_NOT_UPLOADED', 'error');
}
Wiaas_Delivery_Process::update_customer_acceptance_status($order_id, $status, $reason);
$entry[self::DECLINE_REASON_FIELD_ID] = $reason;
$entry[self::ACCEPTANCE_STATUS_FIELD_ID] = $status;
if (!GFAPI::update_entry( $entry )){
return wiaas_api_notice('INTERNAL_SERVER_ERROR', 'error');
}
//Check if step is already completed, to not submit again
$gf_api = new Gravity_Flow_API($entry['form_id']);
$current_step = $gf_api->get_current_step($entry);
if ($current_step->get_name() !== self::USER_INPUT_STEP_NAME){
return wiaas_api_notice('ACCEPTANCE_STATUS_UPDATED', 'success');
}
if ( $current_step ) {
$current_step->purge_assignees();
$current_step->update_step_status( 'complete' );
}
$entry_id = $entry['id'];
$new_step_id = $current_step->get_id() + 1;
$new_step = $gf_api->get_step( $new_step_id, $entry );
$feedback = sprintf( esc_html__( 'Sent to step: %s', 'gravityflow' ), $new_step->get_name() );
$gf_api->add_timeline_note( $entry_id, $feedback );
$gf_api->log_activity( 'workflow', 'sent_to_step', $gf_api->form_id, $entry_id, $step_id );
gform_update_meta( $entry_id, 'workflow_final_status', 'pending' );
$new_step->start();
$gf_api->process_workflow( $entry_id );
if ($installation_declined){
return wiaas_api_notice('INSTALLATION_DECLINED', 'success');
}
return wiaas_api_notice('INSTALLATION_ACCEPTED', 'success');
}
public static function upload_customer_acceptance(WP_REST_Request $request){
public static function upload_file(WP_REST_Request $request){
$files = $request->get_file_params();
if (!$files[self::FILE_KEY_NAME]){
return wiaas_api_notice('NO_FILES_UPLOADED', 'error');
}
$order_id = $request['order_id'];
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return wiaas_api_generate_error('Customer acceptance entry not found', 404);
}
$success = Wiaas_Delivery_Process::upload_customer_acceptance_document($order_id);
$form = GFAPI::get_form($entry['form_id']);
$form_upload_path = GFFormsModel::get_upload_path( $form['id'] );
$target_path = $form_upload_path . '/' . date('Y') . '/' . date('m') . '/';
wp_mkdir_p( $target_path );
GFCommon::recursive_add_index_file( $target_path );
if ($success) {
$upload_file_field = GFAPI::get_field($form['id'], self::UPLOADED_FILES_FIELD_ID);
$file_name = sanitize_file_name($files[self::FILE_KEY_NAME]['name']);
$file_path_details = pathinfo($file_name);
if ( GFCommon::file_name_has_disallowed_extension( $file_name ) ) {
return wiaas_api_notice('INVALID_FILE_ACCEPTANCE', 'error');
}
$allowed_extensions = ! empty( $upload_file_field->allowedExtensions ) ? GFCommon::clean_extensions( explode( ',', strtolower( $upload_file_field->allowedExtensions ) ) ) : array();
if ( ! empty( $allowed_extensions ) ) {
if ( ! GFCommon::match_file_extension( $file_name, $allowed_extensions ) ) {
return wiaas_api_notice('INVALID_FILE_ACCEPTANCE', 'error');
}
}
$new_file_name = $file_path_details['filename'] . '-' . time() . '.' . $file_path_details['extension'];
// Bypasses security checks when running unit tests.
if ( defined( 'WP_TEST_IN_PROGRESS' ) && WP_TEST_IN_PROGRESS ) {
return wiaas_api_notice('FILE_UPLOADED', 'success');
}
if ( move_uploaded_file($files[self::FILE_KEY_NAME]['tmp_name'], $target_path . $new_file_name ) ) {
GFFormsModel::set_permissions( $target_path . $new_file_name );
} else {
return wiaas_api_notice('INTERNAL_SERVER_ERROR', 'error');
}
//Extract path relative to the root
//Last 6 strings (excluding last empty) are path relative to the root
$path_parts = explode('/', $target_path);
$relative_path = '';
$i = count($path_parts) - self::PATH_PARTS_TO_EXTRACT;
while($i < count($path_parts)-1){
$relative_path = $relative_path . $path_parts[$i] . '/';
$i++;
}
$file_url = self::BASE_NAME . $relative_path . $new_file_name;
$url_for_download = $upload_file_field->get_download_url($file_url);
$uploaded_files = json_decode($entry[self::UPLOADED_FILES_FIELD_ID]);
if ($uploaded_files === NULL){
$uploaded_files = [];
}
array_push($uploaded_files, $url_for_download);
$entry[self::UPLOADED_FILES_FIELD_ID] = json_encode($uploaded_files);
if (GFAPI::update_entry( $entry )) {
return wiaas_api_notice('FILE_UPLOADED','success');
}

View File

@@ -17,7 +17,6 @@ class Wiaas_Access_Management {
add_action( 'save_post', array( __CLASS__, 'maybe_handle_product_access' ), 999, 2 );
add_action('woocommerce_new_order', array( __CLASS__, 'assign_order_to_organization' ));
add_action('woocommerce_payment_complete', array( __CLASS__, 'assign_order_to_suppliers'),20,1 );
}
/**
@@ -77,26 +76,6 @@ class Wiaas_Access_Management {
}
}
/**
* Assignees order to supplier organizations extracted from ordered items when order payment is complete.
*
* @param int $order_id
*/
public static function assign_order_to_suppliers($order_id){
$order = wc_get_order($order_id);
$product_from_order = $order->get_items('line_item');
foreach ($product_from_order as $product_item) {
$supplier_organisation_id = Wiaas_Product_Supplier
::get_supplier_organisation_id_from_product($product_item->get_product_id());
Wiaas_User_Organization::assign_post_to_organization($order_id, $supplier_organisation_id);
}
}
}
Wiaas_Access_Management::init();

View File

@@ -1,9 +1,12 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Wiaas_Admin {
public static function init() {
require_once dirname( __FILE__ ) . '/admin/class-wiaas-admin-package.php';
require_once dirname( __FILE__ ) . '/admin/class-wiaas-admin-pricing.php';
require_once dirname(__FILE__) . '/admin/template/class-wiaas-admin-template-selection.php';
@@ -17,17 +20,11 @@ class Wiaas_Admin {
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-documents.php';
// Admin organization interface
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-organization.php';
// Admin order delivery process
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-delivery-process.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-cl.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-product.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-delivery-process.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-supplier.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}

View File

@@ -9,177 +9,171 @@
*/
class Wiaas_Authentication {
const SUPER_ADMIN_USER_ID = 1;
const SUPER_ADMIN_USER_ID = 1;
public static function init() {
// authenticate current user
add_action('determine_current_user', array(__CLASS__, 'authenticate_current_user'), 999);
public static function init() {
// authenticate current user
# add_action('determine_current_user', array(__CLASS__, 'authenticate_current_user'), 999);
// authenticates user on login
add_filter( 'authenticate', array( __CLASS__, 'authenticate_user_on_login' ), 999, 3);
// authenticates user on login
# add_filter( 'authenticate', array( __CLASS__, 'authenticate_user_on_login' ), 999, 3);
add_filter('jwt_auth_token_before_dispatch', array(__CLASS__, 'authenticate_rest_user_on_login'), 999, 2);
// retrieve preferred user role for user
add_filter('get_user_metadata', array(__CLASS__, 'maybe_filter_user_roles'), 10, 3);
// redirect to dashboard after login
add_filter( 'login_redirect', array( __CLASS__, 'login_redirect' ) );
}
// redirect to dashboard after login
# add_filter( 'login_redirect', array( __CLASS__, 'login_redirect' ) );
}
/**
* Redirect admin user to dashboard
*
* @return string
*/
public static function login_redirect() {
return admin_url('index.php') ;
}
/**
* Redirect admin user to dashboard
*
* @return string
*/
public static function login_redirect() {
return admin_url('index.php') ;
}
/**
* Authenticate current user based on roles assigned to organization
*
* If this is non admin request successfully validate user if he can have customer role.
*
* If this is admin panel request successfully validate user if has admin panel role selected
* and also he still can have that role (role was not removed from his customer organization)
*
* @param int|false $user_id
* @return int|false|WP_Error
*/
public static function authenticate_current_user($user_id) {
// do nothing if user not authenticated, user is super admin or this is REST API request
if (! $user_id || (int) $user_id === self::SUPER_ADMIN_USER_ID) {
return $user_id;
}
/**
* Authenticate current user based on roles assigned to organization
*
* User role will be determined in `maybe_filter_user_roles` based on his organization roles
*
* If this is REST API request user will be only authenticated with customer role if his organization has
* customer role assigned to it.
*
* If this is backend request user will be authenticated with previously selected or first available role
* from his organization roles.
*
* @param int|false $user_id
* @return int|false|WP_Error
*/
public static function authenticate_current_user($user_id) {
// do nothing if user not authenticated, user is super admin or this is REST API request
if (! $user_id || $user_id === self::SUPER_ADMIN_USER_ID) {
return $user_id;
}
global $current_user;
$user = new WP_User($user_id);
if (empty($current_user)) {
if (empty($user->roles)) {
return new WP_Error('wiaas_authentication_error', 'No permissions!');
}
$current_user = new WP_User($user_id);
}
return $user_id;
}
$rest_api_slug = rest_get_url_prefix();
$valid_api_uri = strpos($_SERVER['REQUEST_URI'], $rest_api_slug);
/**
* Authenticate wiaas user on login based on roles assigned to organization
*
* User role will be determined in `maybe_filter_user_roles` based on his organization roles
*
* If this is REST API login request user will be only authenticated with customer role if his organization his
* customer role assigned to it.
*
* If this is backend login request user will be authenticated with previously selected or first available role
* from his organization roles.
*
* @param WP_User $user
* @return WP_User|WP_Error
*/
public static function authenticate_user_on_login($user) {
// do nothing if there is an error already,
// user is super admin
if (is_wp_error($user) || $user->ID === self::SUPER_ADMIN_USER_ID) {
return $user;
}
if ($valid_api_uri) {
//for non admin request check if user has customer role
$role = 'customer';
} else {
// for admin panel request check if user has selected role
$role = get_user_meta($user_id, '_wiaas_admin_role', true);
}
if (empty($user->roles)) {
return new WP_Error('wiaas_authentication_error', 'No permissions!');
}
if ( empty($role) || ! user_can($user_id, 'wiaas_' . $role)) {
// not available roles for user
$current_user->set_role('');
return new WP_Error('wiaas_authentication_error', 'No set permissions!', array(
'status' => 403,
));
}
// authenticate valid admin panel user
$current_user->set_role($role);
return $user_id;
}
/**
* Authenticate wiaas user on login based on roles assigned to organization
*
* If this is non admin panel request authenticate user if he can be customer.
*
* If this is admin panel login request user will be authenticated with previously selected or first available role
* from his organization roles.
*
* @param WP_User $user
* @return WP_User|WP_Error
*/
public static function authenticate_user_on_login($user) {
// do nothing if there is an error already,
// user is super admin
if (is_wp_error($user) || $user->ID === self::SUPER_ADMIN_USER_ID ) {
return $user;
}
return $user;
}
$rest_api_slug = rest_get_url_prefix();
$valid_api_uri = strpos($_SERVER['REQUEST_URI'], $rest_api_slug);
/**
*
* Override default user roles with only his organization roles.
*
* If this is REST API request retrieve customer role if organization has that role.
*
* If this is backend request retrieve previously selected role or first available organization role with
* backend access.
*
* @param $null
* @param int $user_id
* @param string $meta_key
* @return array|null
*/
public static function maybe_filter_user_roles($null, $user_id, $meta_key) {
global $wpdb;
/**
* CUSTOMER API AUTHENTICATION
*/
// validate customer user login
if ($valid_api_uri) {
if ($user_id !== 0 && $user_id !== self::SUPER_ADMIN_USER_ID && $meta_key === $wpdb->get_blog_prefix() . 'capabilities') {
$role = user_can($user->ID, 'wiaas_customer') ? 'customer' : '';
$user->set_role($role);
return array( array( 'administrator' => true ) );
return empty($role) ?
new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array(
'status' => 403,
)) :
$user;
}
// import organization functions (during user authentication it is not yet loaded)
require_once dirname( __FILE__ ) . '/user/wiaas-organization-functions.php';
/**
* ADMIN PANEL AUTHENTICATION
*/
// get user organization
$organization_id = wiaas_get_user_organization_id($user_id);
// retrieve selected role for user
$role = get_user_meta($user->ID, '_wiaas_admin_role', true);
// if user has selected role then use it
if (! empty($role) && user_can($user->ID, 'wiaas_' . $role)) {
return $user;
}
// validate if user has organization
if ( empty( $organization_id) ) {
return array();
}
// user does not have selected role so try to assign one in order of access
if (user_can($user->ID, 'wiaas_administrator')) {
$role = 'administrator';
} else if (user_can($user->ID, 'wiaas_commercial_lead')) {
$role = 'commercial_lead';
} else if (user_can($user->ID, 'wiaas_supplier')) {
$role = 'supplier';
}
// get organization roles
$roles = wiaas_get_organization_roles($organization_id);
if (empty($role)) {
return new WP_Error('wiaas_authentication_error', 'No permissions!', array(
'status' => 403,
));
}
// if organization has no roles assigned to it user will have no roles
if ( empty($roles) ) {
return array();
}
update_user_meta($user->ID, '_wiaas_admin_role', $role);
/**
* REST API access
*/
$user->set_role($role);
// for REST API access allow only customer role for user
if ( $is_rest_api = strpos($_SERVER['REQUEST_URI'], rest_get_url_prefix()) ) {
return in_array('customer', $roles) ? array( array( 'customer' => true ) ) : array();
}
return $user;
}
/**
* BACKEND ACCESS
*/
/**
* validate that successfully logged in rest api user can be customer
*
* @param array $data
* @param WP_User $user
* @return array | WP_Error
*
*/
// remove customer role
$roles = array_diff($roles, array( 'customer'));
public static function authenticate_rest_user_on_login($data, $user) {
// if admin do nothing
if ($user->ID === self::SUPER_ADMIN_USER_ID) {
return $data;
}
$role = user_can($user->ID, 'wiaas_customer') ? 'customer' : '';
$user->set_role($role);
// not available backend roles for user
if ( empty($roles) ) {
return array();
}
return empty($role) ?
new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array(
'status' => 403,
)) :
$data;
}
// retrieve selected role for user
$role = get_user_meta($user_id, '_wiaas_current_user_admin_role', true);
// if user has no selected role, selected role in invalid (deleted) or organization has no selected role
// assign first available role to user
if ( empty($role) ||
! wp_roles()->is_role($role) ||
! in_array($role, $roles) ) {
// pick first role
$role = $roles[0];
update_user_meta($user_id, '_wiaas_current_user_admin_role', $role);
}
return array( array ( "$role" => true ));
}
return null;
}
}
Wiaas_Authentication::init();

View File

@@ -28,18 +28,6 @@ class Wiaas_Cart {
add_action( 'woocommerce_cart_loaded_from_session', array( __CLASS__, 'on_calculate_totals' ), 99, 1);
add_action('woocommerce_checkout_create_order', array(__CLASS__, 'add_additional_order_data'), 99);
add_action('woocommerce_set_cart_cookies', array(__CLASS__, 'do_not_set_cart_cookies'));
}
/**
* Do not set cart cookies
*/
public static function do_not_set_cart_cookies() {
if ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS );
wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS );
}
}
/**
@@ -164,35 +152,11 @@ class Wiaas_Cart {
return false;
}
// Validate that order contains only stuff from single commercial lead / reseller / shop owner
if ( ! WC()->cart->is_empty() ) {
// TODO: Add validation that only packages from the same country can be added to cart at the same time
update_user_meta( get_current_user_id(), '_wiaas_cart_items_country', $country);
$current_shop_owner_id = get_user_meta(get_current_user_id(), '_wiaas_cart_shop_owner_id', true);
if (absint($shop_owner_id) !== absint($current_shop_owner_id)) {
wc_add_notice('Only packages from one catalogue can be purchased at the same time!', 'error');
return false;
}
} else {
update_user_meta( get_current_user_id(), '_wiaas_cart_shop_owner_id', $shop_owner_id);
}
// Validate that order contains only items for single country
if ( ! WC()->cart->is_empty() ) {
$current_country = get_user_meta(get_current_user_id(), '_wiaas_cart_items_country', true);
if ($country !== $current_country) {
wc_add_notice('Only packages from one country can be purchased at the same time!', 'error');
return false;
}
} else {
update_user_meta( get_current_user_id(), '_wiaas_cart_items_country', $country);
}
// TODO: Add validation that only packages from the same shop can be added to cart at the same time
update_user_meta( get_current_user_id(), '_wiaas_cart_shop_owner_id', $shop_owner_id);
$customer_id = wiaas_get_current_user_organization_id();
@@ -272,10 +236,6 @@ class Wiaas_Cart {
* @return bool
*/
public static function update_package_quantity($package_cart_item_key, $new_quantity) {
if ($new_quantity > 65000){
return false;
}
$cart_item = WC()->cart->get_cart_item($package_cart_item_key);
if (!$cart_item) {
@@ -322,12 +282,8 @@ class Wiaas_Cart {
}
/**
* Persist additional metadata for every order item
* This includes:
*
* 1. payment info
* 2. relation info for addons and options
* 3. prices for simple products
* Persist used payment type information for package in corresponding order line item.
* Also for standard package type list of addons and options will be saved.
*
* @param $order_item
* @param $cart_item_key
@@ -337,11 +293,7 @@ class Wiaas_Cart {
* @return WC_Order_Item
*/
public static function add_order_item_meta( $order_item, $cart_item_key, $cart_item ) {
$is_bundle_item = wc_pb_is_bundle_container_cart_item($cart_item);
$is_bundled_item = wc_pb_is_bundled_cart_item($cart_item);
if ($is_bundle_item && isset($cart_item['_wiaas_payment'])) {
if (wc_pb_is_bundle_container_cart_item($cart_item) && isset($cart_item['_wiaas_payment'])) {
$payment = $cart_item['_wiaas_payment'];
@@ -410,36 +362,6 @@ class Wiaas_Cart {
$order_item->add_meta_data( '_wiaas_documents', $item_documents, true );
}
// save simple product information that needs to be available later on
// even if this data is changed or removed from product at that time
if($is_bundled_item) {
$product = wc_get_product($cart_item['product_id']);
$order_item->add_meta_data('_wiaas_category', Wiaas_Product_Category::get_category($product), true);
$order_item->add_meta_data('_wiaas_manufacturer_product_no', $product->get_meta('_manufacturer_product_no'), true);
$order_item->add_meta_data('_wiaas_supplier_product_no', $product->get_meta('_supplier_product_no'), true);
// get supplier
if ($supplier_organization_id = Wiaas_Product_Supplier::get_supplier_organisation_id_from_product($cart_item['product_id'])) {
$order_item->add_meta_data('_wiaas_supplier_organization_id', $supplier_organization_id, true);
}
// save bundled product item total cost (price x period)
$product_price = Wiaas_Pricing::get_product_total_cost($product);
$order_item->add_meta_data('_wiaas_product_price', $product_price, true);
}
// save number of days before earliest installation for bundles
if ($is_bundle_item) {
$order_item->add_meta_data(
'_wiaas_earliest_installation_additional_days',
Wiaas_Package::get_earliest_installation_additional_days($cart_item['product_id']),
true);
}
return $order_item;
}
@@ -467,14 +389,6 @@ class Wiaas_Cart {
'_wiaas_option_group_name',
'_wiaas_standard_package',
'_wiaas_documents',
'_wiaas_category',
'_wiaas_manufacturer_product_no',
'_wiaas_supplier_product_no',
'_wiaas_supplier_organization_id',
'_wiaas_product_price',
'_wiaas_earliest_installation_additional_days',
'wiaas_installation',
'wiaas_installation_date'
) );
}
@@ -494,89 +408,11 @@ class Wiaas_Cart {
$order->set_currency($currency);
// get order commercial lead
// set order commercial lead
$shop_owner_id = get_user_meta(get_current_user_id(), '_wiaas_cart_shop_owner_id', true);
$shop_owner_id = absint($shop_owner_id);
// save commercial lead info in case it gets deleted
$order->add_meta_data('_wiaas_commercial_lead_id', $shop_owner_id);
$commercial_lead_organization_info = wiaas_get_organization_info($shop_owner_id);
$order->add_meta_data('_wiaas_commercial_lead_info', $commercial_lead_organization_info);
// save customer organization info in case it gets deleted
$customer_user_id = $order->get_customer_id();
$customer_organization_id = wiaas_get_user_organization_id($customer_user_id);
$order->add_meta_data('_wiaas_customer_id', $customer_organization_id);
$customer_organization_info = wiaas_get_organization_info($customer_organization_id);
$order->add_meta_data('_wiaas_customer_info', $customer_organization_info);
// add supplier organizations information to order in case supplier organizations are deleted
// save installation suppliers separately
$suppliers_info = array();
$installation_suppliers_info = array();
$items = $order->get_items('line_item');
foreach($items as $item) {
$supplier_organization_id = $item['wiaas_supplier_organization_id'];
if (! empty($supplier_organization_id) && $item['wiaas_category'] !== 'installation' &&
empty($suppliers_info[$supplier_organization_id]) ) {
$suppliers_info[$supplier_organization_id] = array(
'id' => $supplier_organization_id,
'estimated_delivery_date' => null,
'confirmed_delivery_date' => null,
'tracking_info' => array(),
);
$supplier_organization_info = wiaas_get_organization_info($supplier_organization_id);
foreach ($supplier_organization_info as $key => $info) {
$suppliers_info[$supplier_organization_id][$key] = $info;
}
}
if (! empty($supplier_organization_id) && $item['wiaas_category'] === 'installation' &&
empty($installation_suppliers_info[$supplier_organization_id]) ) {
$installation_suppliers_info[$supplier_organization_id] = array(
'id' => $supplier_organization_id,
);
$supplier_organization_info = wiaas_get_organization_info($supplier_organization_id);
foreach ($supplier_organization_info as $key => $info) {
$installation_suppliers_info[$supplier_organization_id][$key] = $info;
}
}
}
$order->add_meta_data('_wiaas_delivery_suppliers', $suppliers_info, true);
$order->add_meta_data('_wiaas_installation_suppliers', $installation_suppliers_info, true);
// add additional date fields to order
$order->add_meta_data('_wiaas_estimated_delivery_date', null, true);
$order->add_meta_data('_wiaas_final_estimated_delivery_date', null, true);
$order->add_meta_data('_wiaas_final_confirmed_delivery_date', null, true);
$order->add_meta_data('_wiaas_earliest_installation_date', null, true);
// calculate number of days before earlier installation for whole order
$earliest_installation_additional_days = 0;
$items = $order->get_items('line_item');
foreach($items as $item) {
if (! empty($item['_wiaas_earliest_installation_additional_days'])) {
$additional_days = absint($item['_wiaas_earliest_installation_additional_days']);
$earliest_installation_additional_days = max($additional_days, $earliest_installation_additional_days);
}
}
$order->add_meta_data('_wiaas_order_additional_days_prior_installation', $earliest_installation_additional_days, true);
}
/**
@@ -740,7 +576,6 @@ class Wiaas_Cart {
$documents_ids = array();
// Retrieve all document ids attached to cart content
foreach ($items as $key => $item) {
if (!isset($item['_wiaas_standard_package'])) {
continue;
@@ -758,19 +593,16 @@ class Wiaas_Cart {
}
}
// Retrieve all customer visible template documents attached to cart content
$q = new WP_Query();
$retrieved_items = $q->query(array(
'post_status' => 'publish',
'post_type' => 'wiaas_doc',
'post__in' => array_keys($documents_ids),
'meta_key' => '_wiaas_doc_visible',
'meta_value' => 'yes', // visible to customer
'tax_query' => array(
array(
'taxonomy' => 'wiaas_doc_type',
'field' => 'slug',
'terms' => array_keys(self::$cart_doc_types), // templates only
'terms' => array_keys(self::$cart_doc_types),
)
)
));

View File

@@ -65,8 +65,7 @@ class Wiaas_Checkout {
do_action( 'woocommerce_checkout_order_processed', $order_id, array(), $order );
//Change order status from default 'Pending payment' to open (custom wiaas status)
$order->update_status('open');
$order->payment_complete();
WC()->cart->empty_cart( true );

View File

@@ -62,19 +62,6 @@ class Wiaas_Countries {
return '';
}
public static function get_country_code_by_currency($currency) {
foreach (self::$available_countries as $country) {
if ($country['currency'] === $currency) {
return $country['code'];
}
}
return null;
}
/**
* Registers product taxonomy for avaiable countries
*/
@@ -107,7 +94,7 @@ 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');
wp_update_term($available_country['name'], 'product_country');
}
}

View File

@@ -5,28 +5,26 @@ defined( 'ABSPATH' ) || exit;
class Wiaas_DB_Update {
private static $db_updates = array(
'20180728222206' => 'wiaas_db_update_enable_product_by_user_role',
'20180801222206' => 'wiaas_db_update_setup_gravity',
'20180802222206' => 'wiaas_db_update_add_delivery_process_forms',
'20180811134511' => 'wiaas_db_update_enable_orders_access_management',
'20180813134511' => 'wiaas_db_update_enable_order_numbers',
'20180826153509' => 'wiaas_create_broker_access_group',
'20180911101010' => 'wiaas_db_setup_exclusive_taxonomies',
'20181003164100' => 'wiaas_db_setup_customer_capabilities',
'20181012164450' => 'wiaas_db_update_add_user_organization_ui_fields',
'20181017164550' => 'wiaas_db_update_create_default_roles',
'20181017174550' => 'wiaas_db_import_aam_role_settings',
'20181018014550' => 'wiaas_db_update_update_supplier_capabilities',
'20181018024550' => 'wiaas_db_update_update_admin_capabilities',
'20181018034550' => 'wiaas_admin_create_role_access_groups',
'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'
'201810121644700' => 'wiaas_db_update_add_user_organization_ui_fields',
'201810171645700' => 'wiaas_db_update_create_default_roles',
'201810171745700' => 'wiaas_db_import_aam_role_settings',
'201810180145700' => 'wiaas_db_update_update_supplier_capabilities',
'201810180245700' => 'wiaas_db_update_update_admin_capabilities',
'201810180345700' => 'wiaas_create_role_access_groups',
'201810180444700' => 'wiaas_db_setup_create_customer_commercial_lead_table',
'201810180544702' => 'wiaas_db_update_update_commercial_lead_capabilities',
'201810180644703' => 'wiaas_db_update_add_organization_info_ui_fields',
'201910190145700' => 'wiaas_db_update_add_general_ui_fields',
'201910190146700' => 'wiaas_db_update_add_product_properties_ui_fields',
'201810190644704' => 'wiaas_db_update_add_reference_ui_field'
);
public static function execute() {

View File

@@ -10,82 +10,53 @@ defined( 'ABSPATH' ) || exit;
class Wiaas_Delivery_Process {
private static $process_form_title_prefix = 'DELIVERY PROCESS:';
public static function init() {
self::_register_delivery_process();
self::_register_delivery_process_step_type();
self::_init_hooks();
}
private static function _init_hooks() {
add_action('woocommerce_new_order', array( __CLASS__, 'create_delivery_process_for_order' ));
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 2 );
add_filter( 'gform_entry_meta', array(__CLASS__, 'extend_gravity_form_entry_meta'), 10, 2 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_process_step'), 5, 3 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 3 );
// Some temporary functions to make inbox page prettier
add_filter('gravityflow_inbox_submitter_name', array(__CLASS__, 'display_step_name_in_inbox'), 10, 3);
add_filter('gravityflow_approve_label_workflow_detail', array(__CLASS__, 'approval_step_approval_label'), 10, 2);
add_filter('gravityflow_reject_label_workflow_detail', array(__CLASS__, 'approval_step_reject_label'), 10, 2);
}
public static function approval_step_approval_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Complete step', 'wiaas' );
}
return $label;
}
public static function approval_step_reject_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Cancel', 'wiaas' );
}
return $label;
}
public static function display_step_name_in_inbox($name, $entry, $form) {
return $entry['wiaas_delivery_step_name'];
}
/**
*
* Registers our Delivery Process Addons
*
* Registers our Delivery Process Step Type as available Gravity Flow Step Type
*/
private static function _register_delivery_process() {
require_once( 'delivery-process/class-wiaas-delivery-process-addon.php' );
require_once( 'delivery-process/class-wiaas-delivery-process-action.php' );
require_once( 'delivery-process/class-wiaas-delivery-process-step-assignee.php' );
private static function _register_delivery_process_step_type() {
require_once( 'delivery-process/class-wiaas-delivery-process-step.php' );
// order fields
require_once( 'delivery-process/class-wiaas-order-fields.php' );
require_once( 'delivery-process/class-wiaas-field-order-number.php' );
require_once( 'delivery-process/class-wiaas-field-order-bundle.php' );
require_once( 'delivery-process/class-wiaas-field-order-installation-select.php' );
require_once( 'delivery-process/class-wiaas-field-order-bundle-document.php' );
require_once( 'delivery-process/class-wiaas-field-order-document.php' );
require_once( 'delivery-process/class-wiaas-field-order-bundle-installation-date.php' );
// merge tags (for emails)
require_once( 'delivery-process/class-wiaas-merge-tag-customer-order-url.php' );
Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() );
GFAddOn::register( 'Wiaas_Delivery_Process_Addon' );
}
public static function create_delivery_process_for_order($order_id, $process_id) {
$process_form = null;
$process_form = GFAPI::get_form($process_id);
if( $process_form ) {
$new_process_entry = array(
'wiaas_delivery_order_id' => $order_id,
'form_id' => $process_id,
);
$order_fields = GFCommon::get_fields_by_type($process_form, array('wiaas_order'));
if (! empty($order_fields)) {
$order_field = $order_fields[0];
$new_process_entry[$order_field['id']] = $order_id;
}
$process_entry_id = GFAPI::add_entry( $new_process_entry );
update_post_meta($order_id, 'wiaas_delivery_process_id', $process_id);
update_post_meta($order_id, 'wiaas_delivery_process_entry_id', $process_entry_id);
$order = wc_get_order($order_id);
$order->set_status('processing', 'Started order delivery process.', true);
$order->save();
return $process_entry_id;
}
return false;
}
/**
@@ -94,10 +65,9 @@ class Wiaas_Delivery_Process {
* @param $form
*/
public static function maybe_complete_parent_order($entry_id, $form) {
$entry = GFAPI::get_entry($entry_id);
$order_id = $entry['wiaas_delivery_order_id'];
$order_id = $entry['wiaas_delivery_order_id'];
if (!isset($order_id)) {
return;
@@ -106,170 +76,12 @@ class Wiaas_Delivery_Process {
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
// order process entry completed, so complete order
if (absint($process_entry_id) === absint($entry_id)) {
if (absint($process_entry_id) === $entry_id) {
$order = wc_get_order($order_id);
$order->update_status('completed', 'Completed order delivery process.', true);
}
}
public static function get_available_process_list_for_country($country_code) {
$forms = GFAPI::get_forms();
$available_process_forms = array();
foreach ($forms as $form) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
if ($delivery_settings['delivery_form_type'] === 'process' &&
$delivery_settings['delivery_country'] === $country_code) {
$available_process_forms[] = $form;
}
}
return $available_process_forms;
}
public static function get_customer_acceptance_data($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
$data = array();
if (! empty($delivery_process_entry)) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step)) {
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
$data[] = Wiaas_Delivery_Process_Action::get_customer_acceptance_action_data($action_entry['id']);
}
}
return empty( $data ) ? $data : $data[0];
}
public static function get_customer_questionnaires_data($order_id) {
$data = array();
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry)) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step)) {
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
foreach ($action_entries as $action_entry) {
$action_data = Wiaas_Delivery_Process_Action::get_customer_validate_questionnaires_action_data($action_entry['id']);
if (! empty($action_data)) {
$data[] = $action_data;
}
}
}
}
return $data;
}
public static function update_customer_acceptance_status($order_id, $status, $reason) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
Wiaas_Delivery_Process_Action::update_customer_acceptance_status($action_entry['id'], $status, $reason);
}
}
public static function is_customer_acceptance_uploaded($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
return Wiaas_Delivery_Process_Action::is_customer_acceptance_uploaded($action_entry['id']);
}
return false;
}
public static function upload_customer_questionnaire($order_id, $action_entry_id) {
Wiaas_Delivery_Process_Action::upload_customer_questionnaire($action_entry_id);
}
public static function upload_customer_acceptance_document($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
$success = Wiaas_Delivery_Process_Action::upload_customer_acceptance_document($action_entry['id']);
return $success;
}
return false;
}
public static function get_order_delivery_process_entry($order_id) {
$order = wc_get_order($order_id);
$process_entry_id = $order->get_meta('wiaas_delivery_process_entry_id', true);
if (empty($process_entry_id)) {
return array();
}
return GFAPI::get_entry($process_entry_id);
}
/**
* Retrieves delivery process instance for order
*
@@ -279,9 +91,8 @@ class Wiaas_Delivery_Process {
*/
public static function get_order_delivery_process($order_id) {
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
if (empty($process_entry_id)) {
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id');
if (!isset($process_entry_id)) {
return null;
}
@@ -296,57 +107,114 @@ class Wiaas_Delivery_Process {
$delivery_process = array(
'id' => $process_form['id'],
'name' => $process_form['title'],
'steps' => array(
array(
'short_desc' => 'Order placed',
'status' => 'complete',
'order_id' => $order_id,
'process_id' => $process_entry_id,
'step_id' => -1,
),
array(
'short_desc' => 'Assign process',
'status' => 'complete',
'order_id' => $order_id,
'process_id' => $process_entry_id,
'step_id' => 0,
)
)
'steps' => array()
);
$current_step = $api->get_current_step($process_instance);
foreach ( $steps_info as $step_info ) {
$step = $api->get_step( $step_info->get_id(), $process_instance );
$step = $api->get_step( $step_info->get_id(), $process_instance );
if (! $step->is_visible_to_customer) {
continue;
}
$action_code = Wiaas_Delivery_Process_Action::get_process_step_action_form_action_code($step);
$info = $step->get_feed_meta();
$status = $step->get_status();
if ($current_step && $current_step->get_id() === $step->get_id()) {
$status = 'pending';
}
$delivery_process['steps'][] = array(
'step_id' => $step->get_id(),
'process_id' => $process_entry_id,
'step_form_entry_id' => $step->get_target_form_entry_id() ?: null,
'short_desc' => $info['step_name'],
'full_desc' => $info['description'],
'action_code' => $action_code,
'status' => $status,
'action_code' => $step->get_delivery_action_type(),
'step_type' => $step->get_delivery_action_type() === 'manual' ? 'manual' : 'extraAction',
'status' => $step->get_status() ?: 'inactive',
'order_id' => $order_id,
'actual_date' => $step->get_target_actual_date(),
'comments' => $step->get_target_step_comments(),
);
}
return $delivery_process;
}
/**
* Automatically create delivery process instance when order is created
* @param $order_id
*/
public static function create_delivery_process_for_order($order_id) {
$process_form = null;
$forms = GFFormsModel::search_forms( self::$process_form_title_prefix, true );
$process_form = $forms[0];
if(isset($process_form)) {
$order = wc_get_order( $order_id );
$new_process_entry = array(
'form_id' => $process_form->id,
'2' => $order->get_customer_id(),
'wiaas_delivery_order_id' => $order_id,
);
$process_entry_id = GFAPI::add_entry( $new_process_entry );
add_post_meta($order_id, 'wiaas_delivery_process_id', $process_form->id);
add_post_meta($order_id, 'wiaas_delivery_process_entry_id', $process_entry_id);
}
}
/**
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
*
* This way we can track for each delivery step its parent process
* @param $entry_meta
*
* @return mixed
*/
public static function extend_gravity_form_entry_meta($entry_meta) {
$entry_meta[ 'wiaas_delivery_process_id' ] = array(
'label' => 'Wiaas Delivery Process Id',
'is_numeric' => true,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_order_id' ] = array(
'label' => 'Wiaas Delivery Process Order Id',
'is_numeric' => true,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_step_name' ] = array(
'label' => 'Wiaas Delivery Step name',
'is_numeric' => false,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
return $entry_meta;
}
/**
* Process parent process when single step workflow has completed
* @param $entry_id
* @param $form
* @param $final_status
*/
public static function maybe_complete_parent_process_step($entry_id, $form) {
$entry = GFAPI::get_entry($entry_id);
$parent_entry_id = $entry['wiaas_delivery_process_id'];
if (empty($parent_entry_id)) {
return false;
}
$parent_entry_id = absint( $parent_entry_id );
$parent_entry = GFAPI::get_entry( $parent_entry_id );
$parent_api = new Gravity_Flow_API( $parent_entry['form_id'] );
$parent_api->process_workflow( $parent_entry_id );
}
}
add_action( 'gravityflow_loaded', array('Wiaas_Delivery_Process', 'init') );

View File

@@ -18,16 +18,9 @@ class Wiaas_Order {
public static function init() {
require_once dirname( __FILE__ ) . '/order/class-wiaas-order-project.php';
require_once dirname( __FILE__ ) . '/order/wiaas-order-functions.php';
add_filter('woocommerce_register_post_type_shop_order', array(__CLASS__, 'manage_order_settings'));
add_filter( 'woocommerce_register_shop_order_post_statuses', array(__CLASS__, 'register_custom_order_statuses'), 10, 1);
add_filter( 'wc_order_statuses', array(__CLASS__, 'add_custom_statuses_to_list' ), 10, 1);
add_filter( 'bulk_actions-edit-shop_order', array(__CLASS__, 'add_custom_statuses_to_bulk_edit' ), 10, 1);
add_filter('woocommerce_rest_check_permissions', array( __CLASS__, 'check_order_access'), 10, 4);
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3);
@@ -35,223 +28,6 @@ class Wiaas_Order {
add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2);
add_filter('woocommerce_new_order_note_data', array( __CLASS__, 'update_new_order_comment_date'), 10, 3);
add_filter('woocommerce_order_number', array( __CLASS__, 'format_order_number'));
}
/**
* Prefix order number
*
* @param int $number
*
* @return string
*/
public static function format_order_number($number) {
return "1000000$number";
}
public static function get_additional_days_prior_installation($order_id){
$order = wc_get_order($order_id);
return $order->get_meta('_wiaas_order_additional_days_prior_installation');
}
public static function add_additional_tracking_info($order_id, $supplier_id){
$suppliers = self::get_suppliers($order_id);
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
$suppliers[$key]['tracking_info'][] = array(
'number' => '',
'url' => ''
);
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
}
return false;
}
public static function save_tracking_info($order_id, $supplier_id, $tracking_index, $tracking_num, $tracking_url){
$suppliers = self::get_suppliers($order_id);
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
$suppliers[$key]['tracking_info'][$tracking_index]['number'] = $tracking_num;
$suppliers[$key]['tracking_info'][$tracking_index]['url'] = $tracking_url;
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
}
return false;
}
public static function delete_tracking_info($order_id, $supplier_id, $tracking_index){
$suppliers = self::get_suppliers($order_id);
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
unset($suppliers[$key]['tracking_info'][$tracking_index]);
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
}
return false;
}
public static function save_estimated_date($order_id, $supplier_id, $date){
$suppliers = self::get_suppliers($order_id);
$updated = false;
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
$suppliers[$key]['estimated_date'] = $date;
$updated = true;
}
}
if (!$updated){
return false;
}
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
self::_update_max_and_earliest_dates($order, $suppliers);
$order->save_meta_data();
return true;
}
public static function save_confirmed_date($order_id, $supplier_id, $date){
$suppliers = self::get_suppliers($order_id);
$updated = false;
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
$suppliers[$key]['confirmed_date'] = $date;
$updated = true;
if (!$suppliers[$key]['estimated_date']){
$suppliers[$key]['estimated_date'] = $date;
}
}
}
if (!$updated){
return false;
}
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
self::_update_max_and_earliest_dates($order, $suppliers);
$order->save_meta_data();
return true;
}
public static function get_order_estimated_date($order_id){
$order = wc_get_order($order_id);
if (!$order){
return NULL;
}
return $order->get_meta('_wiaas_order_estimated_delivery_date') ?: NULL;
}
public static function save_order_estimated_date($order_id, $date){
return update_post_meta($order_id, '_wiaas_order_estimated_delivery_date', $date);
}
public static function get_final_estimated_date($order_id){
$order = wc_get_order($order_id);
if (!$order){
return 0;
}
return $order->get_meta('_wiaas_final_estimated_delivery_date') ?: 0;
}
public static function get_final_confirmed_date($order_id){
$order = wc_get_order($order_id);
if (!$order){
return 0;
}
return $order->get_meta('_wiaas_final_confirmed_delivery_date') ?: 0;
}
public static function get_earliest_installation_date($order_id){
$order = wc_get_order($order_id);
if (!$order){
return 0;
}
return $order->get_meta('_wiaas_earliest_installation_date') ?: 0;
}
/**
* Get suppliers related to order
*/
public static function get_suppliers($order_id){
$order = wc_get_order($order_id);
return $order->get_meta('_wiaas_delivery_suppliers');
}
/**
* Register additional order statuses
*
* @param array $order_statuses
*
* @return array
*/
public static function register_custom_order_statuses($order_statuses){
// Status must start with "wc-"
$order_statuses['wc-open'] = array(
'label' => _x( 'Open', 'Order status', 'woocommerce' ),
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Open <span class="count">(%s)</span>', 'Open <span class="count">(%s)</span>', 'woocommerce' ),
);
return $order_statuses;
}
/**
* display custom wiaas statuses in order status dropdown
*
* @param array $order_statuses
*
* @return array
*/
public static function add_custom_statuses_to_list($order_statuses){
$order_statuses['wc-open'] = _x( 'Open', 'Order status', 'woocommerce' );
return $order_statuses;
}
/**
* display custom wiaas statuses in bulk actions
*
* @param array $bulk_actions
*
* @return array
*/
public static function add_custom_statuses_to_bulk_edit($bulk_actions){
// Note: "mark_" must be there instead of "wc"
$bulk_actions['mark_open'] = 'Change status to open';
return $bulk_actions;
}
/**
@@ -400,50 +176,12 @@ class Wiaas_Order {
public static function get_order_tender($order_id) {
return get_post_meta($order_id, '_wiaas_tender', true);
}
}
/**
* PRIVATE
*/
private static function _update_max_and_earliest_dates($order, $suppliers){
$max_estimated_date = 0;
$max_confirmed_date = 0;
$earliest_installation_date = 0;
$missing_estimated = false;
foreach($suppliers as $supplier) {
if (! empty($supplier['confirmed_date']) ) {
$max_confirmed_date = max($max_confirmed_date, $supplier['confirmed_date']);
} else {
$missing_confirmed = true;
}
if (! empty($supplier['estimated_date']) ) {
$max_estimated_date = max($max_estimated_date, $supplier['estimated_date']);
} else {
$missing_estimated = true;
$earliest_installation_date = 0;
}
}
if (! $missing_estimated) {
$earliest_installation_date = max($max_estimated_date, $max_confirmed_date);
$earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order->id) . ' days', $earliest_installation_date);
}
$order->update_meta_data('_wiaas_final_confirmed_delivery_date', $max_confirmed_date);
$order->update_meta_data('_wiaas_final_estimated_delivery_date', $max_estimated_date);
$order->update_meta_data('_wiaas_earliest_installation_date', $earliest_installation_date);
}
/**
* Append specific wiaas order details, like reference
* @param $data
@@ -463,35 +201,19 @@ class Wiaas_Order {
/**
* Appends additional wiaas customer lead info to order json response
* @param $data
* @param WC_Order $order
* @param $order
* @param $request
*
* @return mixed
*/
private static function _append_commercial_lead_info($data, $order, $request) {
$commercial_lead_org_id = $order->get_meta('_wiaas_commercial_lead_id', true);
$commercial_lead_organization_info = $order->get_meta('_wiaas_commercial_lead_info', true);
if (! empty($commercial_lead_org_id) && empty($commercial_lead_organization_info)) {
$commercial_lead_organization_info = wiaas_get_organization_info($commercial_lead_org_id);
$data['commercial_lead'] = array(
'id' => $commercial_lead_org_id,
'name' => $commercial_lead_organization_info['name'],
'phone' => $commercial_lead_organization_info['phone'],
'email' => $commercial_lead_organization_info['email']
);
}
if (!empty($commercial_lead_organization_info)) {
$commercial_lead_organization_info['id'] = $commercial_lead_organization_info;
$data['commercial_lead'] = $commercial_lead_organization_info;
}
$data['commercial_lead'] = array(
'id' => 1,
'name' => 'Coor Service Management',
'phone' => '123456789',
'email' => 'rikard@co-ideation.com'
);
return $data;
}
@@ -499,34 +221,25 @@ class Wiaas_Order {
/**
* Appends additional wiaas customer info to order json response
* @param $data
* @param WC_Order $order
* @param $order
* @param $request
*
* @return mixed
*/
private static function _append_customer_info($data, $order, $request) {
$customer_organization_id = $order->get_meta('_wiaas_customer_id', true);
$current_user = wp_get_current_user();
$customer_user_id = $order->get_customer_id();
$customer_id = $data['customer_id'];
if (empty($customer_organization_id)) {
$customer_user = get_user_by('id', $customer_id);
$data['customer'] = array(
'email' => $customer_user->user_email,
'name' => $customer_user->display_name,
'phone' => '+46 (10) 5595148'
);
$customer_organization_id = wiaas_get_user_organization_id($customer_user_id);
}
$customer_organization_info = $order->get_meta('_wiaas_customer_info', true);
if ( !empty($customer_organization_id) && empty($customer_organization_info) ) {
$customer_organization_info = wiaas_get_organization_info($customer_organization_id);
$customer_organization_info['id'] = $customer_organization_id;
}
$data['customer'] = $customer_organization_info;
$data['is_my_order'] = $customer_user_id === get_current_user_id();
$data['is_my_order'] = $customer_id === $current_user->ID;
return $data;
}
@@ -596,12 +309,6 @@ class Wiaas_Order {
}
}
// installation date
if (! empty($item['wiaas_installation_date'])) {
$product_line['installation_date'] = $item['wiaas_installation_date'];
}
$line_items[] = $product_line;
}
}
@@ -680,14 +387,11 @@ class Wiaas_Order {
if (wiaas_is_order_item__standard_package($order_item)) {
$documents = wiaas_get_standard_package_order_item_documents($order, $product_line['id']);
$data['line_items'][$index] ['documents'] = $documents;
}
}
$data['documents'] = wiaas_get_order_other_documents($order->get_id());
return $data;
}
}

View File

@@ -48,10 +48,6 @@ class Wiaas_Package {
return $response;
}
public static function get_earliest_installation_additional_days($package_id){
return get_post_meta($package_id, 'additional_days_prior_earliest_installation', true);
}
/**
* Append package documents
* @param $data

View File

@@ -70,10 +70,6 @@ class Wiaas_Product {
return $args;
}
public static function get_supplier_id($product_id){
return wp_get_post_terms($product_id, 'supplier', array('fields' => 'ids'))[0];
}
}
Wiaas_Product::init();

View File

@@ -19,8 +19,10 @@ class Wiaas_Shop {
// update prices search terms for package after prices extras have been updated
add_action('wiaas_package_prices_extras_set', array(__CLASS__, 'update_package_prices_search_terms'), 10, 4);
// remove customer shop relationships for all deactivated and removed shops
// create new shop if organization was assigned commercial lead role
// or remove shop if commercial lead role was removed for organization
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'remove_deactivated_shop'));
add_action('wiaas_organization_deleted', array(__CLASS__, 'remove_shop'));
}
@@ -99,7 +101,8 @@ class Wiaas_Shop {
}
/**
* remove shop
* Remove shop
*
* @param int $owner_id
*/
public static function remove_shop($owner_id) {
@@ -138,7 +141,7 @@ class Wiaas_Shop {
* $extra_price_payment_type => {
* @type bool visible Indicates if payment type is visible to customer
* }
* }
* }
* @param array $old_cl_extras {
* $extra_price_payment_type => {
* @type bool visible Indicates if payment type is visible to customer
@@ -205,7 +208,7 @@ class Wiaas_Shop {
foreach ($cl_extras_per_customer as $customer_id => $visible) {
$terms[] = '_' . $owner_id . '_customer_' . $customer_id . '_' .
($visible ? 'visible' : 'hidden');
($visible ? 'visible' : 'hidden');
}
return $terms;

View File

@@ -15,7 +15,7 @@ class Wiaas_User {
add_action('plugins_loaded', array(__CLASS__, 'remove_default_user_groups'), 30);
add_filter('woocommerce_rest_prepare_customer', array(__CLASS__, 'transform_rest_customer'), 10, 3);
add_filter('jwt_auth_token_before_dispatch', array(__CLASS__, 'transform_jwt_token_response'), 999, 2);
add_filter('jwt_auth_token_before_dispatch', array(__CLASS__, 'transform_jwt_token_response'), 10, 2);
}
public static function load_user_organization() {
@@ -58,10 +58,6 @@ class Wiaas_User {
* @return mixed
*/
public static function transform_jwt_token_response($data, $user) {
if (is_wp_error($data)) {
return $data;
}
return new WP_REST_Response(array(
'token' => $data['token'],
'userInfo' => array(

View File

@@ -1 +0,0 @@
{"0":{"title":"DELIVERY PROCESS EXAMPLE: Copy and set to active to create new delivery process","description":"","labelPlacement":"top_label","descriptionPlacement":"below","button":{"type":"text","text":"Submit","imageUrl":""},"fields":[{"type":"wiaas_order","id":1,"label":"Order number","adminLabel":"","isRequired":false,"size":"medium","errorMessage":"","visibility":"visible","inputs":null,"formId":36,"description":"","allowsPrepopulate":false,"inputMask":false,"inputMaskValue":"","inputType":"","labelPlacement":"","descriptionPlacement":"","subLabelPlacement":"","placeholder":"","cssClass":"","inputName":"","noDuplicates":false,"defaultValue":"","choices":"","conditionalLogic":"","enableCalculation":false,"numberFormat":"decimal_dot","rangeMin":"","rangeMax":"","productField":"","multipleFiles":false,"maxFiles":"","calculationFormula":"","calculationRounding":"","disableQuantity":false,"displayAllCategories":false,"useRichTextEditor":false,"displayOnly":"","enablePrice":""}],"version":"2.3.2","id":36,"useCurrentUserAsAuthor":true,"postContentTemplateEnabled":false,"postTitleTemplateEnabled":false,"postTitleTemplate":"","postContentTemplate":"","lastPageButton":null,"pagination":null,"firstPageCssClass":null,"wiaas_delivery_process":{"delivery_form_type":"process","delivery_country":"se"},"is_active":"1","date_created":"2018-11-02 10:15:28","is_trash":"0","confirmations":[{"id":"5bdb1c7c26da9","name":"Default Confirmation","isDefault":true,"type":"message","message":"Thanks for contacting us! We will get in touch with you shortly.","url":"","pageId":"","queryString":""}],"notifications":[{"id":"5bdb1c7c26952","to":"{admin_email}","name":"Admin Notification","event":"form_submission","toType":"email","subject":"New submission from {form_title}","message":"{all_fields}"}],"feeds":{"gravityflow":[{"id":"120","form_id":"36","is_active":"1","feed_order":"0","meta":{"step_name":"Delivery Step Placeholder (Use Delivery Step type to create process workflow steps)","description":"","step_type":"wiaas_delivery_step","step_highlight":"0","step_highlight_type":"color","step_highlight_color":"#dd3333","feed_condition_conditional_logic":"0","feed_condition_conditional_logic_object":[],"scheduled":"0","schedule_type":"delay","schedule_date":"","schedule_delay_offset":"","schedule_delay_unit":"hours","schedule_date_field_offset":"0","schedule_date_field_offset_unit":"hours","schedule_date_field_before_after":"after","instructionsEnable":"0","instructionsValue":"","is_visible_to_customer":"1","target_form_id":"","destination_complete":"next"},"addon_slug":"gravityflow","event_type":null}]}},"version":"2.3.2"}

View File

@@ -0,0 +1,524 @@
{
"0": {
"title": "DELIVERY ACTION TYPE: Customer acceptance",
"description": "The customer must accept the implementation before further actions can be taken. If the customer isn't satisfied, the problems or discrepancies must be fixed in order to gen an acceptance.",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "workflow_user",
"id": 2,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "administrative",
"inputs": null,
"choices": [
],
"formId": 1,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "customer-id",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"failed_validation": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": "",
"gravityflowUsersRoleFilter": ""
},
{
"type": "date",
"id": 6,
"label": "Actual date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "none",
"formId": 1,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "ymd_dash",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
},
{
"type": "radio",
"id": 8,
"label": "acceptance",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"choices": [
{
"text": "not-accepted",
"value": "not-accepted",
"isSelected": true,
"price": ""
},
{
"text": "accept",
"value": "accept",
"isSelected": false,
"price": ""
},
{
"text": "decline",
"value": "decline",
"isSelected": false,
"price": ""
}
],
"formId": 1,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"productField": "",
"enableOtherChoice": "",
"enablePrice": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
},
{
"type": "date",
"id": 9,
"label": "Expiration date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "none",
"formId": 1,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "ymd_dash",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
},
{
"type": "text",
"id": 10,
"label": "Reason",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"formId": 1,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"productField": "",
"enablePasswordInput": "",
"maxLength": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": ""
},
{
"type": "fileupload",
"id": 12,
"label": "File",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"formId": 1,
"description": "Upload customer acceptance file",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"maxFileSize": "",
"maxFiles": "",
"multipleFiles": true,
"allowedExtensions": "pdf,docx,doc,xlsx,xls,odt,ods,jpg,png,jpeg",
"productField": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false
}
],
"version": "2.3.2",
"id": 1,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-15 20:30:18",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f75f7494b7",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
],
"notifications": [
{
"id": "5b5f75f748cee",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"feeds": {
"gravityflow": [
{
"id": "1",
"form_id": "1",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Upload acceptance file",
"description": "",
"step_type": "user_input",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field": "6",
"type": "select",
"assignees": [
"role|administrator",
"assignee_user_field|2"
],
"routing": "",
"assignee_policy": "any",
"highlight_editable_fields_enabled": "0",
"highlight_editable_fields_class": "green-triangle",
"instructionsEnable": "0",
"instructionsValue": "",
"display_fields_mode": "selected_fields",
"default_status": "hidden",
"note_mode": "not_required",
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "Upload order acceptance file",
"assignee_notification_message": "A new entry requires your input.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"in_progress_notification_enabled": "0",
"in_progress_notification_type": "select",
"in_progress_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"in_progress_notification_from_name": "",
"in_progress_notification_from_email": "{admin_email}",
"in_progress_notification_reply_to": "",
"in_progress_notification_bcc": "",
"in_progress_notification_subject": "",
"in_progress_notification_message": "Entry {entry_id} has been updated and remains in progress.",
"in_progress_notification_disable_autoformat": "0",
"complete_notification_enabled": "0",
"complete_notification_type": "select",
"complete_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"complete_notification_from_name": "",
"complete_notification_from_email": "{admin_email}",
"complete_notification_reply_to": "",
"complete_notification_bcc": "",
"complete_notification_subject": "",
"complete_notification_message": "Entry {entry_id} has been updated completing the step.",
"complete_notification_disable_autoformat": "0",
"confirmation_messageEnable": "0",
"confirmation_messageValue": "Thank you.",
"expiration": "0",
"expiration_type": "date_field",
"expiration_date": "",
"expiration_delay_offset": "7",
"expiration_delay_unit": "days",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"expiration_date_field": "9",
"status_expiration": "expired",
"destination_expired": "2",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "2",
"form_id": "1",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Approve customer acceptance",
"description": "",
"step_type": "approval",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"type": "select",
"assignees": [
"role|administrator"
],
"routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"assignee_policy": "any",
"instructionsEnable": "0",
"instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button",
"display_fields_mode": "all_fields",
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "",
"assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"rejection_notification_enabled": "0",
"rejection_notification_type": "select",
"rejection_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"rejection_notification_from_name": "",
"rejection_notification_from_email": "{admin_email}",
"rejection_notification_reply_to": "",
"rejection_notification_bcc": "",
"rejection_notification_subject": "",
"rejection_notification_message": "Entry {entry_id} has been rejected",
"rejection_notification_disable_autoformat": "0",
"approval_notification_enabled": "0",
"approval_notification_type": "select",
"approval_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"approval_notification_from_name": "",
"approval_notification_from_email": "{admin_email}",
"approval_notification_reply_to": "",
"approval_notification_bcc": "",
"approval_notification_subject": "",
"approval_notification_message": "Entry {entry_id} has been approved",
"approval_notification_disable_autoformat": "0",
"revertEnable": "0",
"revertValue": 1,
"note_mode": "not_required",
"expiration": "0",
"expiration_type": "delay",
"expiration_date": "",
"expiration_delay_offset": "",
"expiration_delay_unit": "hours",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"status_expiration": "rejected",
"destination_expired": "next",
"destination_rejected": 1,
"destination_approved": "next"
},
"addon_slug": "gravityflow",
"event_type": null
}
]
}
},
"version": "2.3.2"
}

View File

@@ -0,0 +1,252 @@
{
"0": {
"title": "DELIVERY ACTION TYPE: Manual",
"description": "Manual process step action type",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "workflow_user",
"id": 2,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "administrative",
"inputs": null,
"choices": [
{
"value": 2,
"text": "Customer Wiaas"
},
{
"value": 1,
"text": "wpUser"
}
],
"formId": 4,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "customer-id",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"failed_validation": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": "",
"gravityflowUsersRoleFilter": ""
},
{
"type": "date",
"id": 3,
"label": "Actual Date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 4,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "ymd_dash",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
}
],
"version": "2.3.2",
"id": 4,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f9ebc52a80",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
],
"notifications": [
{
"id": "5b5f9ebc520f3",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"feeds": {
"gravityflow": [
{
"id": "6",
"form_id": "4",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Complete step",
"description": "",
"step_type": "approval",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field": "3",
"type": "select",
"assignees": [
"role|administrator"
],
"routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"assignee_policy": "any",
"instructionsEnable": "0",
"instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button",
"display_fields_mode": "all_fields",
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "",
"assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"rejection_notification_enabled": "0",
"rejection_notification_type": "select",
"rejection_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"rejection_notification_from_name": "",
"rejection_notification_from_email": "{admin_email}",
"rejection_notification_reply_to": "",
"rejection_notification_bcc": "",
"rejection_notification_subject": "",
"rejection_notification_message": "Entry {entry_id} has been rejected",
"rejection_notification_disable_autoformat": "0",
"approval_notification_enabled": "0",
"approval_notification_type": "select",
"approval_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"approval_notification_from_name": "",
"approval_notification_from_email": "{admin_email}",
"approval_notification_reply_to": "",
"approval_notification_bcc": "",
"approval_notification_subject": "",
"approval_notification_message": "Entry {entry_id} has been approved",
"approval_notification_disable_autoformat": "0",
"note_mode": "not_required",
"expiration": "0",
"expiration_type": "delay",
"expiration_date": "",
"expiration_delay_offset": "",
"expiration_delay_unit": "hours",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"expiration_date_field": "3",
"status_expiration": "rejected",
"destination_expired": "next",
"destination_rejected": "complete",
"destination_approved": "next"
},
"addon_slug": "gravityflow",
"event_type": null
}
]
}
},
"version": "2.3.2"
}

View File

@@ -0,0 +1,406 @@
{
"0": {
"title": "DELIVERY ACTION TYPE: Schedule meeting",
"description": "Schedule meeting with customer",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "workflow_user",
"id": 3,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "administrative",
"inputs": null,
"choices": [
{
"value": 2,
"text": "Customer Wiaas"
},
{
"value": 1,
"text": "wpUser"
}
],
"formId": 2,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "customer-id",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"failed_validation": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"gravityflowUsersRoleFilter": ""
},
{
"type": "date",
"id": 4,
"label": "Actual Date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 2,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "ymd_dash",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
},
{
"type": "date",
"id": 5,
"label": "Schedule date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 2,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "ymd_dash",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false
}
],
"version": "2.3.2",
"id": 2,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-09 15:35:59",
"is_trash": "0",
"confirmations": [
{
"id": "5b60b12baa00e",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
],
"notifications": [
{
"id": "5b60b12ba9850",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"feeds": {
"gravityflow": [
{
"id": "3",
"form_id": "2",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Broker proposes meeting date",
"description": "",
"step_type": "user_input",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field": "4",
"type": "select",
"assignees": [
"role|administrator"
],
"editable_fields": [
"4",
"5"
],
"routing": "",
"assignee_policy": "all",
"highlight_editable_fields_enabled": "0",
"highlight_editable_fields_class": "green-triangle",
"instructionsEnable": "0",
"instructionsValue": "",
"display_fields_mode": "selected_fields",
"display_fields_selected": [
"4",
"5"
],
"default_status": "submit_buttons",
"note_mode": "not_required",
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "",
"assignee_notification_message": "A new entry requires your input.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"in_progress_notification_enabled": "0",
"in_progress_notification_type": "select",
"in_progress_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"in_progress_notification_from_name": "",
"in_progress_notification_from_email": "{admin_email}",
"in_progress_notification_reply_to": "",
"in_progress_notification_bcc": "",
"in_progress_notification_subject": "",
"in_progress_notification_message": "Entry {entry_id} has been updated and remains in progress.",
"in_progress_notification_disable_autoformat": "0",
"complete_notification_enabled": "0",
"complete_notification_type": "select",
"complete_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"complete_notification_from_name": "",
"complete_notification_from_email": "{admin_email}",
"complete_notification_reply_to": "",
"complete_notification_bcc": "",
"complete_notification_subject": "",
"complete_notification_message": "Entry {entry_id} has been updated completing the step.",
"complete_notification_disable_autoformat": "0",
"confirmation_messageEnable": "0",
"confirmation_messageValue": "Thank you.",
"expiration": "0",
"expiration_type": "delay",
"expiration_date": "",
"expiration_delay_offset": "",
"expiration_delay_unit": "hours",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"expiration_date_field": "4",
"status_expiration": "complete",
"destination_expired": "next",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "4",
"form_id": "2",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Customer approval for scheduled date",
"description": "",
"step_type": "approval",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field": "4",
"type": "select",
"assignees": [
"assignee_user_field|3"
],
"routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"assignee_policy": "all",
"instructionsEnable": "0",
"instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button",
"display_fields_mode": "selected_fields",
"display_fields_selected": [
"5"
],
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "",
"assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"rejection_notification_enabled": "0",
"rejection_notification_type": "select",
"rejection_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"rejection_notification_from_name": "",
"rejection_notification_from_email": "{admin_email}",
"rejection_notification_reply_to": "",
"rejection_notification_bcc": "",
"rejection_notification_subject": "",
"rejection_notification_message": "Entry {entry_id} has been rejected",
"rejection_notification_disable_autoformat": "0",
"approval_notification_enabled": "0",
"approval_notification_type": "select",
"approval_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"approval_notification_from_name": "",
"approval_notification_from_email": "{admin_email}",
"approval_notification_reply_to": "",
"approval_notification_bcc": "",
"approval_notification_subject": "",
"approval_notification_message": "Entry {entry_id} has been approved",
"approval_notification_disable_autoformat": "0",
"revertEnable": "0",
"revertValue": 3,
"note_mode": "not_required",
"expiration": "0",
"expiration_type": "delay",
"expiration_date": "",
"expiration_delay_offset": "",
"expiration_delay_unit": "hours",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"expiration_date_field": "4",
"status_expiration": "rejected",
"destination_expired": "next",
"destination_rejected": 3,
"destination_approved": "complete"
},
"addon_slug": "gravityflow",
"event_type": null
}
]
}
},
"version": "2.3.2"
}

View File

@@ -0,0 +1,264 @@
{
"0": {
"title": "DELIVERY ACTION TYPE: Validate Questionnaire",
"description": "The configuration details submitted at ordering must be validated and any missing or incomplete information must be added.",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "workflow_user",
"id": 4,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "administrative",
"inputs": null,
"choices": [
{
"value": 2,
"text": "Customer Wiaas"
},
{
"value": 1,
"text": "wpUser"
}
],
"formId": 3,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "customer-id",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"failed_validation": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": "",
"gravityflowUsersRoleFilter": ""
},
{
"type": "date",
"id": 5,
"label": "Actual date",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "none",
"formId": 3,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"calendarIconUrl": "",
"dateFormat": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false
}
],
"version": "2.3.2",
"id": 3,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f688188e90",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
],
"notifications": [
{
"id": "5b5f68818822e",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"feeds": {
"gravityflow": [
{
"id": "5",
"form_id": "3",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Approve customer configuration",
"description": "",
"step_type": "approval",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": {
"conditionalLogic": {
"actionType": "show",
"logicType": "all",
"rules": [
{
"fieldId": "2",
"operator": "is",
"value": "administrator"
}
]
}
},
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field": "5",
"type": "select",
"assignees": [
"role|administrator"
],
"routing": [
{
"target": false,
"fieldId": "0",
"operator": "is",
"value": "",
"type": false,
"assignee": "user_id|2"
}
],
"assignee_policy": "any",
"instructionsEnable": "1",
"instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button",
"display_fields_mode": "selected_fields",
"assignee_notification_enabled": "0",
"assignee_notification_from_name": "",
"assignee_notification_from_email": "{admin_email}",
"assignee_notification_reply_to": "",
"assignee_notification_bcc": "",
"assignee_notification_subject": "",
"assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.",
"assignee_notification_disable_autoformat": "0",
"resend_assignee_emailEnable": "0",
"resend_assignee_emailValue": "7",
"resend_assignee_email_repeatEnable": "0",
"resend_assignee_email_repeatValue": "3",
"rejection_notification_enabled": "0",
"rejection_notification_type": "select",
"rejection_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"rejection_notification_from_name": "",
"rejection_notification_from_email": "{admin_email}",
"rejection_notification_reply_to": "",
"rejection_notification_bcc": "",
"rejection_notification_subject": "",
"rejection_notification_message": "Entry {entry_id} has been rejected",
"rejection_notification_disable_autoformat": "0",
"approval_notification_enabled": "0",
"approval_notification_type": "select",
"approval_notification_routing": [
{
"assignee": "user_id|2",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"approval_notification_from_name": "",
"approval_notification_from_email": "{admin_email}",
"approval_notification_reply_to": "",
"approval_notification_bcc": "",
"approval_notification_subject": "",
"approval_notification_message": "Entry {entry_id} has been approved",
"approval_notification_disable_autoformat": "0",
"note_mode": "not_required",
"expiration": "0",
"expiration_type": "delay",
"expiration_date": "",
"expiration_delay_offset": "",
"expiration_delay_unit": "hours",
"expiration_date_field_offset": "0",
"expiration_date_field_offset_unit": "hours",
"expiration_date_field_before_after": "after",
"expiration_date_field": "5",
"status_expiration": "rejected",
"destination_expired": "next",
"destination_rejected": "complete",
"destination_approved": "next"
},
"addon_slug": "gravityflow",
"event_type": null
}
]
}
},
"version": "2.3.2"
}

View File

@@ -0,0 +1,338 @@
{
"0": {
"title": "DELIVERY PROCESS: Normal Delivery",
"description": "Normal delivery process",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "number",
"id": 1,
"label": "order-id",
"adminLabel": "order-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"numberFormat": "decimal_dot",
"formId": 5,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "order-id",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"enableCalculation": false,
"rangeMin": "",
"rangeMax": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": ""
},
{
"type": "workflow_user",
"id": 2,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"choices": [
{
"value": 2,
"text": "Customer Wiaas"
},
{
"value": 1,
"text": "wpUser"
}
],
"formId": 5,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "customer-id",
"noDuplicates": false,
"defaultValue": "",
"conditionalLogic": "",
"failed_validation": "",
"productField": "",
"multipleFiles": false,
"maxFiles": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": "",
"enablePrice": "",
"gravityflowUsersRoleFilter": ""
}
],
"version": "2.3.2.6",
"id": 5,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f7ae4bb79e",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
],
"notifications": [
{
"id": "5b5f7ae4baced",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}",
"isActive": false
}
],
"feeds": {
"gravityflow": [
{
"id": "7",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Validate customer configuration information",
"description": "Validate customer configuration information",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": 3,
"store_new_entry_idEnable": "1",
"new_entry_id_field": "6",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "8",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Wait for installation to be scheduled and confirmed",
"description": "Wait for installation to be scheduled and confirmed",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "9",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Installation",
"description": " Installation",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "10",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Customer acceptance",
"description": "Customer acceptance",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"target_form_id": 1,
"store_new_entry_idEnable": "1",
"new_entry_id_field": "7",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "11",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Customer training",
"description": "Customer training",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next",
"feedName": " - Copy 1"
},
"addon_slug": "gravityflow",
"event_type": null
},
{
"id": "12",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
"step_name": "Set start\/stop dates for contracts",
"description": "Set start\/stop dates for contracts",
"step_type": "wiaas_delivery_step",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
}
]
}
},
"version": "2.3.2"
}

View File

@@ -1,117 +0,0 @@
[
{
"key": "group_5bc845c001de4",
"title": "Bundle Properties",
"fields": [
{
"key": "field_5bc845dc7eed5",
"label": "Reference",
"name": "_wiaas_package_reference",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_tag",
"field_type": "select",
"allow_null": 0,
"add_term": 1,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
},
{
"key": "field_5bcfcc2cf88f4",
"label": "Country",
"name": "country",
"type": "taxonomy",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
},
{
"key": "field_5bdb1512ab14f",
"label": "Additional days prior earliest installation",
"name": "additional_days_prior_earliest_installation",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": 5,
"placeholder": "",
"prepend": "",
"append": "",
"min": 0,
"max": "",
"step": ""
},
{
"key": "field_5bc86761aeafc",
"label": "Unit",
"name": "unit",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "wiaas_units",
"field_type": "select",
"allow_null": 0,
"add_term": 1,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "product"
},
{
"param": "post_taxonomy",
"operator": "==",
"value": "product_type:bundle"
}
]
],
"menu_order": 0,
"position": "acf_after_title",
"style": "seamless",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": ""
}
]

View File

@@ -4,10 +4,10 @@
"title": "General",
"fields": [
{
"key": "field_5bceef4c9771c",
"label": "General",
"name": "_wiaas_product_general",
"type": "group",
"key": "field_5bc0965a35406",
"label": "Type",
"name": "_wiaas_product_type",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
@@ -16,65 +16,48 @@
"class": "",
"id": ""
},
"layout": "block",
"sub_fields": [
{
"key": "field_5bc0965a35406",
"label": "Type",
"name": "_wiaas_product_type",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"simple": "Simple",
"bundle": "Bundle",
"wiaastemplate": "Template"
},
"default_value": [],
"allow_null": 0,
"multiple": 0,
"ui": 1,
"ajax": 0,
"return_format": "value",
"placeholder": ""
},
{
"key": "field_5bbf899bba1af",
"label": "Country",
"name": "_wiaas_product_country",
"type": "taxonomy",
"instructions": "",
"required": 1,
"conditional_logic": [
[
{
"field": "field_5bc0965a35406",
"operator": "!=",
"value": "wiaastemplate"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
]
"choices": {
"simple": "Simple",
"bundle": "Bundle",
"wiaastemplate": "Template"
},
"default_value": [],
"allow_null": 0,
"multiple": 0,
"ui": 1,
"ajax": 0,
"return_format": "value",
"placeholder": ""
},
{
"key": "field_5bbf899bba1af",
"label": "Country",
"name": "_wiaas_product_country",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5bc0965a35406",
"operator": "!=",
"value": "wiaastemplate"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
],
"location": [
@@ -93,7 +76,7 @@
],
"menu_order": 0,
"position": "acf_after_title",
"style": "seamless",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",

View File

@@ -49,7 +49,7 @@
},
{
"key": "field_5bc867c3aeafd",
"label": "Category",
"label": "Product category",
"name": "category",
"type": "taxonomy",
"instructions": "",
@@ -90,37 +90,10 @@
"load_terms": 1,
"return_format": "id",
"multiple": 0
},
{
"key": "field_5bcfcceffe617",
"label": "Country",
"name": "country",
"type": "taxonomy",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_country",
"field_type": "select",
"allow_null": 0,
"add_term": 0,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "product"
},
{
"param": "post_taxonomy",
"operator": "==",

View File

@@ -0,0 +1,52 @@
[
{
"key": "group_5bc845c001de4",
"title": "Package Reference",
"fields": [
{
"key": "field_5bc845dc7eed5",
"label": "Reference",
"name": "_wiaas_package_reference",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "product_tag",
"field_type": "select",
"allow_null": 0,
"add_term": 1,
"save_terms": 1,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "product"
},
{
"param": "post_taxonomy",
"operator": "==",
"value": "product_type:bundle"
}
]
],
"menu_order": 0,
"position": "acf_after_title",
"style": "seamless",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": ""
}
]

View File

@@ -6,6 +6,14 @@
* General functions for updating wiaas database to latest version
*/
/**
* Enable restricting visibility by user roles for products
*/
function wiaas_db_update_enable_product_by_user_role() {
update_option('wcj_product_by_user_role_enabled', 'yes');
}
function wiaas_db_update_setup_gravity() {
// Gravity Form settings
update_option('gform_pending_installation', false);
@@ -17,6 +25,59 @@ function wiaas_db_update_setup_gravity() {
update_option('gravityflow_pending_installation', false);
}
function wiaas_db_update_add_delivery_process_forms() {
$action_type_forms_files = array(
'delivery_action_customer_acceptance_form',
'delivery_action_schedule_meeting',
'delivery_action_validate_questionnaire_form',
'delivery_action_manual_form',
);
// Since import action will generate form with new id, we need to remember this mapping
// so we can update process delivery steps to point to correct form ids
$action_type_forms_ids_mappings = array();
$process_forms_files = array(
'delivery_process_normal_delivery_form'
);
$created_forms = array();
// import forms for delivery action types
foreach ($action_type_forms_files as $action_type_form_file) {
$form_json = file_get_contents( dirname( __FILE__ ) . "/data/delivery-forms/" . $action_type_form_file . '.json' );
$form_meta = json_decode( $form_json, true );
$form_meta = $form_meta[0];
$form_id = GFAPI::add_form($form_meta);
$created_forms[] = GFAPI::get_form($form_id);
$action_type_forms_ids_mappings[$form_meta['id']] = $form_id;
}
// import forms for delivery process
foreach ($process_forms_files as $process_form_file) {
$form_json = file_get_contents( dirname( __FILE__ ) . "/data/delivery-forms/" . $process_form_file . '.json' );
$form_meta = json_decode( $form_json, true );
$form_meta = $form_meta[0];
// update delivery steps forms ids with correct values
foreach ($form_meta['feeds']['gravityflow'] as $key => $process_step_meta) {
$process_step_target_form_id = $form_meta['feeds']['gravityflow'][$key]['meta']['target_form_id'];
$form_meta['feeds']['gravityflow'][$key]['meta']['target_form_id'] = $action_type_forms_ids_mappings[$process_step_target_form_id];
}
$form_id = GFAPI::add_form($form_meta);
$created_forms[] = GFAPI::get_form($form_id);
}
do_action('gform_forms_post_import', $created_forms);
}
function wiaas_db_update_enable_orders_access_management() {
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
@@ -27,10 +88,26 @@ function wiaas_db_update_enable_orders_access_management() {
Groups_Options::update_option(Groups_Post_Access::POST_TYPES, $post_types_option);
}
function wiaas_db_update_enable_order_numbers() {
update_option('wcj_order_numbers_enabled', 'yes');
update_option('wcj_order_number_sequential_enabled', 'no');
update_option('wcj_order_number_counter', '0');
update_option('wcj_order_number_counter_reset_enabled', 'no');
update_option('wcj_order_number_prefix', '1000000');
}
function wiaas_create_broker_access_group() {
Groups_Group::create(array(
'name' => 'Broker',
));
}
function wiaas_db_setup_exclusive_taxonomies() {
update_option('radio_button_for_taxonomies_options', array(
'taxonomies' => array(
'shop_order_project',
'product_cat',
'product_country',
'wiaas_document_types',
),
'delete' => 0,
));
@@ -68,68 +145,4 @@ function wiaas_db_setup_create_customer_commercial_lead_table() {
";
dbDelta( $sql );
}
function wiaas_create_organization_roles_capabilities() {
$roles = array( 'commercial_lead', 'supplier', 'customer', 'administrator');
foreach ($roles as $role) {
Groups_Capability::create( array( 'capability' => 'wiaas_' . $role ));
}
}
function wiaas_disable_processing_order_email_delivery() {
update_option( 'woocommerce_customer_processing_order_settings', array(
'enabled' => 'no',
'subject' => '',
'heading' => '',
'mail_type' => 'html'
) );
}
function wiaas_db_update_update_delivery_forms() {
$forms = GFAPI::get_forms();
foreach ($forms as $form) {
RGFormsModel::update_form_active($form['id'], false);
}
$created_forms = array();
$actions_forms_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-action-forms.json' );
$action_forms_meta = json_decode( $actions_forms_json, true );
foreach ($action_forms_meta as $action_form_meta) {
$form_id = GFAPI::add_form($action_form_meta);
$created_forms[] = GFAPI::get_form($form_id);
}
$sample_form_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-process-sample-form.json' );
$sample_form = json_decode( $sample_form_json, true );
$sample_form = $sample_form[0];
$sample_form_id = GFAPI::add_form($sample_form);
RGFormsModel::update_form_active($sample_form_id, false);
$created_forms[] = GFAPI::get_form($sample_form_id);
do_action('gform_forms_post_import', $created_forms);
}
function wiaas_db_update_add_installation_date_delivery_action_form() {
$action_form_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-action-enter-installation-date.json' );
$action_form_meta = json_decode( $action_form_json, true )[0];
$action_form_id = GFAPI::add_form($action_form_meta);
do_action('gform_forms_post_import', array( GFAPI::get_form($action_form_id) ));
}

View File

@@ -10,268 +10,126 @@
function wiaas_db_update_create_default_roles() {
$roles = array(
'customer', // this role will be created by woocommerce so we do not have to create it here
'supplier',
'commercial_lead'
);
$roles = array(
'customer', // this role will be created by woocommerce so we do not have to create it here
'supplier',
'commercial_lead'
);
// remove wordpress default roles
remove_role('author');
remove_role('contributor');
remove_role('editor');
remove_role('subscriber');
// remove wordpress default roles
remove_role('author');
remove_role('contributor');
remove_role('editor');
remove_role('subscriber');
// remove woocoommerce shop manager role
remove_role('shop_manager');
// remove woocoommerce shop manager role
remove_role('shop_manager');
// Dummy gettext calls to get strings in the catalog.
/* translators: user role */
_x( 'Supplier', 'User role', 'wiaas' );
/* translators: user role */
_x( 'Commercial Lead', 'User role', 'wiaas' );
// Dummy gettext calls to get strings in the catalog.
/* translators: user role */
_x( 'Supplier', 'User role', 'wiaas' );
/* translators: user role */
_x( 'Commercial Lead', 'User role', 'wiaas' );
// Add wiaas roles
add_role(
'commercial_lead',
'Commercial Lead',
array(
'read' => true,
)
);
// Add wiaas roles
add_role(
'commercial_lead',
array(
'read' => true,
)
);
add_role(
'supplier',
'Supplier',
array(
'read' => true,
)
);
add_role(
'supplier',
array(
'read' => true,
)
);
add_role(
'user',
'User',
array(
'read' => true
)
);
add_role(
'user',
array(
'read' => true
)
);
// set default wiaas role
update_option('default_role', 'user');
// set default wiaas role
update_option('default_role', 'user');
// capabilities
// capabilities
$capabilities = array();
$capabilities = array();
$capability_types = array( 'wiaas_doc' );
$capability_types = array( 'wiaas_doc' );
foreach ( $capability_types as $capability_type ) {
foreach ( $capability_types as $capability_type ) {
$capabilities[ $capability_type ] = array(
// Post type.
"edit_{$capability_type}",
"read_{$capability_type}",
"delete_{$capability_type}",
"edit_{$capability_type}s",
"edit_others_{$capability_type}s",
"publish_{$capability_type}s",
"read_private_{$capability_type}s",
"delete_{$capability_type}s",
"delete_private_{$capability_type}s",
"delete_published_{$capability_type}s",
"delete_others_{$capability_type}s",
"edit_private_{$capability_type}s",
"edit_published_{$capability_type}s",
$capabilities[ $capability_type ] = array(
// Post type.
"edit_{$capability_type}",
"read_{$capability_type}",
"delete_{$capability_type}",
"edit_{$capability_type}s",
"edit_others_{$capability_type}s",
"publish_{$capability_type}s",
"read_private_{$capability_type}s",
"delete_{$capability_type}s",
"delete_private_{$capability_type}s",
"delete_published_{$capability_type}s",
"delete_others_{$capability_type}s",
"edit_private_{$capability_type}s",
"edit_published_{$capability_type}s",
// Terms.
"manage_{$capability_type}_terms",
"edit_{$capability_type}_terms",
"delete_{$capability_type}_terms",
"assign_{$capability_type}_terms",
);
}
// Terms.
"manage_{$capability_type}_terms",
"edit_{$capability_type}_terms",
"delete_{$capability_type}_terms",
"assign_{$capability_type}_terms",
);
}
foreach ( $capabilities as $cap_group ) {
foreach ( $cap_group as $cap ) {
wp_roles()->add_cap( 'administrator', $cap );
wp_roles()->add_cap( 'commercial_lead', $cap );
}
}
foreach ( $capabilities as $cap_group ) {
foreach ( $cap_group as $cap ) {
wp_roles()->add_cap( 'administrator', $cap );
wp_roles()->add_cap( 'commercial_lead', $cap );
}
}
}
function wiaas_db_import_aam_role_settings() {
// update role settings that are imported
$content = file_get_contents( dirname( __FILE__ ) . '/data/aam-settings.json' );
// update role settings that are imported
$content = file_get_contents( dirname( __FILE__ ) . '/data/aam-settings.json' );
$importer = new AAM_Core_Importer($content);
$importer = new AAM_Core_Importer($content);
$importer->run();
$importer->run();
// update toolbar settins manually since it does not get imported
update_option('aam_toolbar_default', array (
'about' => '1',
'toolbar-wp-logo' => '1',
'wporg' => '1',
'documentation' => '1',
'support-forums' => '1',
'feedback' => '1',
'toolbar-site-name' => '0',
'view-site' => '1',
'view-store' => '1',
'toolbar-updates' => '1',
'toolbar-comments' => '1',
'toolbar-new-content' => '1',
'new-post' => '1',
'new-media' => '1',
'new-page' => '1',
'new-product' => '1',
'new-shop_order' => '1',
'new-shop_coupon' => '1',
'new-wiaas_doc' => '1',
'new-user' => '1',
'gravityforms-new-form' => '1',
)
);
update_option('aam_menu_default', array (
'menu-edit.php' => '1',
'edit.php' => '1',
'post-new.php' => '1',
'edit-tags.php?taxonomy=category' => '1',
'edit-tags.php?taxonomy=post_tag' => '1',
'menu-edit.php?post_type=page' => '1',
'edit.php?post_type=page' => '1',
'post-new.php?post_type=page' => '1',
'menu-woocommerce' => '1',
'woocommerce' => '1',
'edit.php?post_type=shop_coupon' => '1',
'edit-tags.php?taxonomy=shop_order_project' => '1',
'wc-reports' => '1',
'wc-settings' => '1',
'wc-status' => '1',
'wc-addons' => '1',
'wcj-tools' => '1',
'admin.php?page=wc-settings&tab=jetpack' => '1',
'menu-themes.php' => '1',
'themes.php' => '1',
'customize.php' => '1',
'widgets.php' => '1',
'nav-menus.php' => '1',
'custom-header' => '1',
'menu-tools.php' => '1',
'tools.php' => '1',
'import.php' => '1',
'export.php' => '1',
'export_personal_data' => '1',
'remove_personal_data' => '1',
'menu-options-general.php' => '1',
'options-general.php' => '1',
'options-writing.php' => '1',
'options-reading.php' => '1',
'options-discussion.php' => '1',
'options-media.php' => '1',
'options-permalink.php' => '1',
'privacy.php' => '1',
'radio-buttons-for-taxonomies' => '1',
'sendgrid-settings' => '1',
'menu-plugins.php' => '1',
'plugins.php' => '1',
'plugin-install.php' => '1',
'menu-groups-admin' => '1',
'groups-admin' => '1',
'groups-admin-capabilities' => '1',
'groups-admin-options' => '1',
'groups-admin-add-ons' => '1',
)
);
update_option('aam-utilities', array(
'core.settings.getStarted' => '0',
'ui.settings.renderAccessActionLink' => '0',
'core.settings.secureLogin' => '0',
'core.settings.xmlrpc' => '0',
'core.settings.cron' => '0',
'core.settings.extensionSupport' => '0',
'ui.settings.renderAccessMetabox' => '0',
'core.settings.apiAccessControl' => '0',
'core.settings.frontendAccessControl' => '0',
));
update_option('aam_menu_role_administrator', array(
'menu-edit.php' => '1',
'edit.php' => '1',
'post-new.php' => '1',
'edit-tags.php?taxonomy=category' => '1',
'edit-tags.php?taxonomy=post_tag' => '1',
'menu-edit.php?post_type=page' => '1',
'edit.php?post_type=page' => '1',
'post-new.php?post_type=page' => '1',
'menu-woocommerce' => '1',
'woocommerce' => '1',
'edit.php?post_type=shop_coupon' => '1',
'wc-reports' => '1',
'wc-settings' => '1',
'wc-status' => '1',
'wc-addons' => '1',
'wcj-tools' => '1',
'admin.php?page=wc-settings&tab=jetpack' => '1',
'menu-themes.php' => '1',
'themes.php' => '1',
'customize.php' => '1',
'widgets.php' => '1',
'nav-menus.php' => '1',
'custom-header' => '1',
'menu-tools.php' => '1',
'tools.php' => '1',
'import.php' => '1',
'export.php' => '1',
'export_personal_data' => '1',
'remove_personal_data' => '1',
'menu-options-general.php' => '1',
'options-general.php' => '1',
'options-writing.php' => '1',
'options-reading.php' => '1',
'options-discussion.php' => '1',
'options-media.php' => '1',
'options-permalink.php' => '1',
'privacy.php' => '1',
'radio-buttons-for-taxonomies' => '1',
'sendgrid-settings' => '1',
'menu-plugins.php' => '1',
'plugins.php' => '1',
'plugin-install.php' => '1',
'menu-groups-admin' => '1',
'groups-admin' => '1',
'groups-admin-capabilities' => '1',
'groups-admin-options' => '1',
'groups-admin-add-ons' => '1',
'menu-edit-comments.php' => '1',
));
update_option('aam_metabox_default', array(
'dashboard' =>
array (
'rg_forms_dashboard' => '1',
'dashboard_quick_press' => '1',
'dashboard_primary' => '1',
'woocommerce_dashboard_status' => '1',
'dashboard_activity' => '1',
),
));
update_option('aam_metabox_role_administrator', array(
'dashboard' =>
array (
'rg_forms_dashboard' => '1',
'dashboard_quick_press' => '1',
'dashboard_primary' => '1',
'woocommerce_dashboard_status' => '1',
'dashboard_activity' => '1',
'dashboard_right_now' => '1',
),
));
// update toolbar settins manually since it does not get imported
update_option('aam_toolbar_default', array (
'about' => '1',
'toolbar-wp-logo' => '1',
'wporg' => '1',
'documentation' => '1',
'support-forums' => '1',
'feedback' => '1',
'toolbar-site-name' => '0',
'view-site' => '1',
'view-store' => '1',
'toolbar-updates' => '1',
'toolbar-comments' => '1',
'toolbar-new-content' => '1',
'new-post' => '1',
'new-media' => '1',
'new-page' => '1',
'new-product' => '1',
'new-shop_order' => '1',
'new-shop_coupon' => '1',
'new-wiaas_doc' => '1',
'new-user' => '1',
'gravityforms-new-form' => '1',
)
);
}
function wiaas_db_update_update_commercial_lead_capabilities() {
@@ -302,25 +160,23 @@ function wiaas_db_update_update_supplier_capabilities() {
function wiaas_db_update_update_admin_capabilities() {
wp_roles()->add_cap( 'administrator', 'create_products' );
wp_roles()->add_cap( 'administrator', 'manage_wiaas_order_projects' );
}
function wiaas_admin_create_role_access_groups() {
function wiaas_create_role_access_groups() {
Groups_Group::create(array(
'name' => 'admin',
));
}
function wiaas_db_update_update_supplier_order_capabilities() {
// add supplier role to view orders
wp_roles()->add_cap( 'supplier', 'edit_shop_orders' );
}
Groups_Group::create(array(
'name' => 'commercial_lead',
));
function wiaas_db_update_enable_workflow_inbox_for_roles() {
// add workflow inbox for supplier
wp_roles()->add_cap( 'supplier', 'gravityflow_inbox' );
// add workflow inbox for commercial lead
wp_roles()->add_cap( 'commercial_lead', 'gravityflow_inbox' );
Groups_Group::create(array(
'name' => 'supplier',
));
Groups_Group::create(array(
'name' => 'customer',
));
}

View File

@@ -18,9 +18,9 @@ function wiaas_db_update_add_user_organization_ui_fields() {
_wiaas_import_field_group($ui_json);
}
function wiaas_db_update_add_bundle_properties_ui_field() {
function wiaas_db_update_add_reference_ui_field() {
$ui_json = file_get_contents( dirname( __FILE__ ) . '/data/wiaas-ui-field-bundle-properties.json' );
$ui_json = file_get_contents( dirname( __FILE__ ) . '/data/wiaas-ui-field-reference.json' );
$ui_json = json_decode( $ui_json, true );

View File

@@ -147,7 +147,7 @@ class Wiaas_Shop_DB {
$shops = array_map(function($result_row) {
return array(
'owner_id' => absint($result_row->shop_owner_id),
'owner_id' => $result_row->shop_owner_id,
'order_type' => $result_row->order_type
);
}, $results);
@@ -155,11 +155,6 @@ class Wiaas_Shop_DB {
return $shops;
}
/**
* Remove shop
*
* @param int $owner_id
*/
public static function remove_shop($owner_id) {
global $wpdb;

View File

@@ -1,423 +0,0 @@
<?php
/**
* Class Wiaas_Delivery_Process_Action
*/
class Wiaas_Delivery_Process_Action {
/**
* Check if form is delivery process action form
*
* @param $form
*
* @return bool
*/
public static function is_action_form($form) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
return ! empty($delivery_settings) && $delivery_settings['delivery_form_type'] === 'action';
}
/**
* Retrieve action form for step
*
* @param Wiaas_Delivery_Process_Step $step
*
* @return mixed|null
*/
public static function get_process_step_action_form($step) {
if (empty($step->target_form_id)) {
return null;
}
return GFAPI::get_form($step->target_form_id);
}
/**
* Get action code for delivery process step form
*
* Action code is used for implementing specific logic for step form
*
* @param Wiaas_Delivery_Process_Step $step
*
* @return string
*/
public static function get_process_step_action_form_action_code($step) {
$action_form = self::get_process_step_action_form($step);
if (empty($action_form)) {
return 'manual';
}
$delivery_settings = rgar($action_form, 'wiaas_delivery_process');
return empty($delivery_settings) ? 'manual' : $delivery_settings['delivery_action_code'];
}
/**
* Check if delivery process step has customer acceptance action form
*
* @param Wiaas_Delivery_Process_Step $step
*
* @return bool
*/
public static function process_step_has_customer_acceptance_action($step) {
return self::get_process_step_action_form_action_code($step) === 'customer-acceptance';
}
/**
* Check if delivery process step has customer validate action form
*
* @param Wiaas_Delivery_Process_Step $step
*
* @return bool
*/
public static function process_step_has_customer_validate_questionnaires_action($step) {
return self::get_process_step_action_form_action_code($step) === 'validate-questionnaire';
}
/**
* @param Wiaas_Delivery_Process_Step $step
*
* @return array|WP_Error
*/
public static function get_process_step_action_entries(Wiaas_Delivery_Process_Step $step) {
$action_form = self::get_process_step_action_form($step);
if (!$action_form) {
return array();
}
$search_criteria = array(
'field_filters' => array(
array( 'key' => 'wiaas_delivery_process_id',
'value' => $step->get_entry_id()
),
),
);
$sorting = array( 'key' => 'date_created', 'direction' => 'DESC' );
return GFAPI::get_entries( $action_form, $search_criteria, $sorting );
}
/**
* Retrieve forms that will be used as possible action forms
*
* @return array
*/
public static function get_action_forms() {
$forms = GFAPI::get_forms();
$action_forms = array();
foreach ( $forms as $form ) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
if ( ! empty($delivery_settings) && $delivery_settings['delivery_form_type'] === 'action'){
$action_forms[] = $form;
}
}
return $action_forms;
}
/**
* Complete current workflow step for action form
*
* @param int $action_entry_id
*/
public static function complete_action_step($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$workflow = new Gravity_Flow_API($action_form['id']);
$current_step = $workflow->get_current_step($action_entry);
if ( $current_step ) {
$new_status = $current_step->get_type() === 'approval' ? 'approved' : 'complete';
$assignees = $current_step->get_assignees();
foreach ($assignees as $assignee) {
$current_step->process_assignee_status($assignee, $new_status, $action_form);
}
}
gravity_flow()->process_workflow($action_form, $action_entry['id']);
}
/**
* Upload customer questionnaire document
*
* @param int $action_entry_id
*/
public static function upload_customer_questionnaire($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$document_field = GFCommon::get_fields_by_type(GFAPI::get_form($action_entry['form_id']), 'wiaas_order_bundle_document')[0];
$new_file = $document_field->get_single_file_value($action_entry['form_id'], 'file');
$action_entry[$document_field->id] = $new_file;
GFAPI::update_entry($action_entry);
self::complete_action_step($action_entry_id);
}
/**
* Check if customer uploaded acceptance document
*
* @param int $action_entry_id
*
* @return bool
*/
public static function is_customer_acceptance_uploaded($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_document')[0];
return ! empty( $action_entry[$acceptance_documents_field->id]);
}
/**
* Update acceptance status for order
*
* @param int $action_entry_id
* @param $new_status
* @param $reason
*/
public static function update_customer_acceptance_status($action_entry_id, $new_status, $reason) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$acceptance_field = GFCommon::get_fields_by_type($action_form, 'radio')[0];
$decline_reason_field = GFCommon::get_fields_by_type($action_form, 'textarea')[0];
$action_entry[$acceptance_field->id] = $new_status;
$action_entry[$decline_reason_field->id] = $reason;
GFAPI::update_entry($action_entry);
if ($new_status === 'accept') {
Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']);
}
}
/**
* Upload customer acceptance document for order
*
* @param int $action_entry_id
*
* @return bool
*/
public static function upload_customer_acceptance_document($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_document')[0];
$old_value = $action_entry[$acceptance_documents_field->id];
$value = $acceptance_documents_field->get_single_file_value($action_form['id'], 'file');
if ($acceptance_documents_field->multipleFiles ) {
$value = array( $value );
$old_value = json_decode( $old_value );
if (! empty($old_value)) {
$old_value = is_array( $old_value ) ? $old_value : array( $old_value );
$value = array_merge( $value, $old_value );
}
$value = json_encode( $value );
}
$action_entry[$acceptance_documents_field->id] = $value;
$result = GFAPI::update_entry($action_entry);
// complete step if current step is customer acceptance user input
$workflow = new Gravity_Flow_API($action_form['id']);
$current_step = $workflow->get_current_step($action_entry);
if ($current_step->get_type() === 'user_input' && ! is_wp_error($result)) {
Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']);
}
return ! is_wp_error($result);
}
/**
* Collect customer acceptance action data
*
* @param int $action_entry_id
*
* @return array
*/
public static function get_customer_acceptance_action_data($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_document')[0];
$acceptance_field = GFCommon::get_fields_by_type($action_form, 'radio')[0];
$decline_reason_field = GFCommon::get_fields_by_type($action_form, 'textarea')[0];
$expiration_date_field = GFCommon::get_fields_by_type($action_form, 'date')[0];
$file_paths = json_decode($action_entry[$acceptance_documents_field->id]);
$documents = array();
foreach ($file_paths as $file_path) {
$info = pathinfo( $file_path );
$documents[] = array(
'name' => $info['basename'],
'extension' => $info['extension'],
'url' => $acceptance_documents_field->get_download_url( $file_path, true )
);
}
$status = 0;
if ($action_entry[$acceptance_field->id] === 'accept') {
$status = 1;
}
if ($action_entry[$acceptance_field->id] === 'decline') {
$status = -1;
}
return array(
'action_id' => $action_entry['id'],
'documents' => $documents,
'expiration' => $action_entry[$expiration_date_field->id],
'decline_reason' => $action_entry[$decline_reason_field->id],
'status' => $status
);
}
/**
* Get customer validate questionnaires action data
*
* @param int $action_entry_id
*
* @return array|null
*/
public static function get_customer_validate_questionnaires_action_data($action_entry_id) {
$action_entry = GFAPI::get_entry($action_entry_id);
$action_form = GFAPI::get_form($action_entry['form_id']);
$order_id = $action_entry['wiaas_delivery_order_id'];
$order = wc_get_order($order_id);
// we need to collect document, bundle id and current status
$bundle_item_id = null; $status = null;
$bundle_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_bundle')[0];
$bundle_item_id = absint(explode('|', $action_entry[$bundle_field->id])[1]);
if (empty($bundle_item_id)) {
return null;
}
$document_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_bundle_document')[0];
$file_path = $action_entry[$document_field->id];
$info = pathinfo( $action_entry[$document_field->id] );
$document = array(
'name' => $info['basename'],
'extension' => $info['extension'],
'url' => $document_field->get_download_url( $file_path, true )
);
$discussion_field = GFCommon::get_fields_by_type(GFAPI::get_form($action_entry['form_id']), 'workflow_discussion')[0];
$discussion_items = json_decode($action_entry[$discussion_field->id], ARRAY_A);
$formatted_comments = array();
if (is_array($discussion_items)) {
foreach ($discussion_items as $item) {
$formatted = $discussion_field->format_discussion_item( $item, 'text', $action_entry_id );
$formatted = explode("\n", $formatted);
$formatted_comments[] = array(
'header' => $formatted[0],
'value' => $formatted[1]
);
}
}
$action_workflow_api = new Gravity_Flow_API($action_form['id']);
$action_step = $action_workflow_api->get_current_step($action_entry);
// if completed it means that document got validated
$status = 'validated';
if (! empty($action_step)) {
$is_assignee = $action_step->is_assignee($action_step->get_current_assignee_key());
if ($is_assignee) {
// if customer is assignee it means it is his turn to upload changed version of document
// which means it was rejected
$status = 'invalid';
} else {
// if customer is not assignee it means administrator is still reviewing document
$status = 'not-validated';
}
}
return array(
'item_id' => $bundle_item_id,
'order_id' =>$order->get_id(),
'action_id' => $action_entry['id'],
'document' => $document,
'status' => $status,
'comments' => $formatted_comments
);
}
}

View File

@@ -1,232 +0,0 @@
<?php
if (! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
private static $_instance = null;
protected $_slug = 'wiaas_delivery_process';
protected $_title = 'Delivery Process';
protected $_short_title = 'Delivery Process';
public static function get_instance() {
if ( self::$_instance == null ) {
self::$_instance = new Wiaas_Delivery_Process_Addon();
}
return self::$_instance;
}
public function init() {
parent::init();
add_filter( 'gform_enqueue_scripts', array( $this, 'filter_gform_enqueue_scripts' ) );
}
public function filter_gform_enqueue_scripts( ) {
wp_enqueue_script( 'gform_datepicker_init' );
}
/**
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
*
* @param array $entry_meta
* @param int $form_id
*
* @return array
*/
public function get_entry_meta( $entry_meta, $form_id ) {
$entry_meta[ 'wiaas_delivery_process_id' ] = array(
'label' => 'Wiaas Delivery Process Id',
'is_numeric' => true,
'update_entry_meta_callback' => array( __CLASS__, 'update_entry_delivery_process_id' ),
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_order_id' ] = array(
'label' => 'Wiaas Delivery Process Order Id',
'is_numeric' => true,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_step_name' ] = array(
'label' => 'Wiaas Delivery Step name',
'is_numeric' => false,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
return $entry_meta;
}
public static function update_entry_delivery_process_id($key, $entry, $form) {
if ( isset( $_REQUEST['wiaas_delivery_process_id'] ) ) {
return absint( $_REQUEST['wiaas_delivery_process_id'] );
}
if ( isset( $entry[ $key ] ) ) {
return $entry[ $key ];
}
return '';
}
public function scripts() {
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
$scripts = array(
array(
'handle' => 'wiaas_form_editor_js',
'src' => $plugin_url . '/assets/js/wiaas-form-editor.js',
'enqueue' => array(
array(
'admin_page' => array('form_editor'),
),
),
)
);
return array_merge( parent::scripts(), $scripts );
}
/**
* Add settings menu for form delivery process
*
* @param $tabs
* @param $form_id
*
* @return array
*/
public function add_form_settings_menu( $tabs, $form_id ) {
$tabs[] = array(
'name' => $this->_slug,
'label' => esc_html__( 'Delivery Process', 'wiaas' ),
'query' => array( 'fid' => null )
);
return $tabs;
}
/**
* Add settings field for delivery process settings menu
*
* @param $form
*
* @return array
*/
public function form_settings_fields($form) {
return array(
array(
'title' => esc_html__( 'Delivery Process', 'wiaas' ),
'fields' => array(
array(
'name' => 'delivery_process',
'label' => esc_html__( 'Delivery Form Type', 'wiaas' ),
'type' => 'delivery_process',
)
)
)
);
}
public function settings_delivery_process() {
$this->settings_select(array(
'name' => 'delivery_form_type',
'choices' => array(
array( 'value' => 'process', 'label' => 'Process Form' ),
array( 'value' => 'action', 'label' => 'Action Form' ),
),
'after_select' => '<p class="description"> Choose if this form will be used as process form or action form.</p>' .
'<p class="description"> <strong>Process form</strong> defines order delivery process workflow.</p>' .
'<p class="description"> <strong>Action form</strong> defines custom order data that is collected from delivery process participants.</p>'
));
?>
<br /> <br /> <br />
<?php
$settings = $this->get_current_settings();
if ($settings['delivery_form_type'] !== 'process') {
$this->settings_select(array(
'name' => 'delivery_action_code',
'choices' => array(
array( 'value' => '', 'label' => 'Select action code ...' ),
array( 'value' => 'customer-acceptance', 'label' => 'Customer acceptance' ),
array( 'value' => 'validate-questionnaire', 'label' => 'Validate Questionnaire' ),
array( 'value' => 'schedule-meeting', 'label' => 'Schedule meeting' ),
),
'after_select' => '<p class="description"> Choose action code for action form.</p>'
));
$this->settings_checkbox_and_select(array(
'checkbox' => array(
'label' => esc_html__( 'Automatic', 'wiaas' ),
'name' => 'automatic_action_entries_enabled',
'default_value' => '0',
),
'select' => array(
'name' => 'automatic_action_entries_type',
'choices' => array(
array(
'value' => 'single',
'label' => esc_html__( 'Single entry', 'wiaas' ),
),
array(
'value' => 'bundle',
'label' => esc_html__( 'Entry per bundle', 'wiaas' ),
)
),
'after_select' => '<p class="description">Automatic entries can be created once per order or per every bundle in order.</p>' .
'<p class="description">Automatic entry will not be created if any required field cannot be populated.</p>',
)
));
return;
}
$this->settings_select(array(
'name' => 'delivery_country',
'choices' => array(
array( 'value' => 'se', 'label' => 'Sweden' ),
array( 'value' => 'dk', 'label' => 'Denmark' ),
array( 'value' => 'fi', 'label' => 'Finland' )
),
'after_select' => '<p class="description"> Choose country for which this process is defined.</p>'
));
}
}

View File

@@ -1,186 +0,0 @@
<?php
/**
* Handle organization and order level assignment to delivery process step.
*
* Currently Gravity Flow enables assignment of roles to step, but these roles are not bounded to organization level
* so cannot be used in that form for our delivery processes.
*
* This will enable delivery process step to be assigned to order admin, order seller, order customer or
* single order supplier organization.
*
*
* Class Wiaas_Delivery_Process_Step_Assignee
*/
class Wiaas_Delivery_Process_Step_Assignee {
public static function init() {
add_filter('gravityflow_assignee_choices', array (__CLASS__, 'filter_delivery_process_step_assignee_choices'));
add_filter('gravityflow_step_assignees', array (__CLASS__, 'maybe_handle_order_organization_assignees'), 10, 2);
}
/**
* Allow only order specific organization roles and fields as choices for delivery process step assignee
*
* @param array $old_choices
*
* @return array
*/
public static function filter_delivery_process_step_assignee_choices($old_choices) {
$choices = array(
$choices[] = array(
'label' => __( 'Order', 'wiaas' ),
'choices' => array(
array(
'value' => 'role|administrator', // allow global administrator role here since it is only one
'label' => __('Administrator', 'wiaas')
)
),
)
);
// add administrator users
$args = array(
'number' => 1000,
'orderby' => 'display_name',
'role' => 'administrator'
);
$accounts = get_users( $args );
$account_choices = array();
foreach ( $accounts as $account ) {
$account_choices[] = array( 'value' => 'user_id|' . $account->ID, 'label' => $account->display_name );
}
$choices[] = array(
'label' => __( 'Users', 'gravityflow' ),
'choices' => $account_choices,
);
// append field choices
foreach ($old_choices as $old_choice) {
if ($old_choice['label'] === 'Fields') {
$choices[] = $old_choice;
break;
}
}
return $choices;
}
/**
* Handle order level assignees for delivery process step
*
* @param $assignees
*
* @param Gravity_Flow_Step $step
*
* @return array
*/
public static function maybe_handle_order_organization_assignees($assignees, Gravity_Flow_Step $step) {
$mapped_assignees = array();
$order_id = self::get_order_id_for_step($step);
$order = wc_get_order($order_id);
foreach ($assignees as $assignee) {
if (strpos($assignee->get_type(), 'wiaas_installation_') !== false) {
$item_id = $assignee->get_id();
$item = $order->get_item($item_id);
$organization_id = $item['wiaas_supplier_organization_id'];
$user_ids = wiaas_get_organization_user_ids($organization_id);
if (empty($user_ids)) {
continue;
}
$user_id = $user_ids[0];
$mapped_assignees[] = $step->get_assignee( array(
'id' => $user_id,
'type' => 'user_id',
'editable_fields' => $assignee->get_editable_fields()
) );
continue;
}
if ($assignee->get_type() === 'wiaas_order_role') {
$order_role = $assignee->get_id();
if ($order_role === 'customer') {
$customer_user_id = $order->get_customer_id();
// for now assign only customer that create order
// check if all customer organization users should be able to see order step
$mapped_assignees[] = $step->get_assignee( array(
'id' => $customer_user_id,
'type' => 'user_id',
'editable_fields' => $assignee->get_editable_fields()
) );
continue;
}
}
$mapped_assignees[] = $assignee;
}
return $mapped_assignees;
}
/**
* Retrieve order id for delivery process step
*
* @param Gravity_Flow_Step $step
*
* @return bool|int Order id on success, false if step does not have associated order id
*
*/
public static function get_order_id_for_step(Gravity_Flow_Step $step) {
$entry = $step->get_entry();
// if order is present in entry metadata use that value
if (! empty($entry['wiaas_delivery_order_id'])) {
return absint($entry['wiaas_delivery_order_id']);
}
// try getting order id from order field
$form = GFAPI::get_form($entry['form_id']);
$order_fields = GFCommon::get_fields_by_type($form, array( 'wiaas_order'));
if (! empty($order_fields)) {
$order_field = $order_fields[0]; // there should only be one order field per entry
return absint($entry[$order_field->id]);
}
return false;
}
}
Wiaas_Delivery_Process_Step_Assignee::init();

View File

@@ -7,12 +7,30 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
* @var string
*/
public $_step_type = 'wiaas_delivery_step';
private static $delivery_action_form_title_prefix = 'DELIVERY ACTION TYPE:';
private static $delivery_action_types = array(
'DELIVERY ACTION TYPE: Customer acceptance' => 'customer-acceptance',
'DELIVERY ACTION TYPE: Validate Questionnaire' => 'validate-questionnaire',
'DELIVERY ACTION TYPE: Manual' => 'manual',
'DELIVERY ACTION TYPE: Schedule meeting' => 'schedule-meeting'
);
public static function get_delivery_action_types() {
return array_keys(self::$delivery_action_types);
}
public static function get_delivery_action_type_prefix() {
return self::$delivery_action_form_title_prefix;
}
/**
* Returns label for Wiass Delivery Process Step
* @return string
*/
public function get_label() {
return esc_html__( 'Delivery Step', 'wiaas' );
return esc_html__( 'Wiaas Delivery Step', 'wiaas' );
}
/**
@@ -23,13 +41,13 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
$settings_api = $this->get_common_settings_api();
$forms = $this->get_action_forms_choices();
$forms = $this->get_target_forms_choices();
$form_choices[] = array( 'label' => esc_html__( 'Select a Form', 'wiaas' ), 'value' => '' );
foreach ( $forms as $form ) {
$form_choices[] = array( 'label' => $form['title'], 'value' => $form['id'] );
$form_choices[] = array( 'label' => $form->title, 'value' => $form->id );
}
$settings = array(
'title' => esc_html__( 'Wiaas Delivery Step', 'wiaas' ),
'fields' => array(
@@ -53,56 +71,13 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
'type' => 'select',
'onchange' => "jQuery(this).closest('form').submit();",
'choices' => $form_choices,
)
),
),
);
return $settings;
}
public function start() {
parent::start();
$this->update_step_status('pending');
return false;
}
public function evaluate_status() {
return $this->get_status();
}
public function get_status_label($status) {
$label = parent::get_status_label($status);
if (empty($label)) {
$label = __('Not started', 'wiaas');
}
return $label;
}
public function update_step_status($status = false) {
if ($status === 'cancelled' && $admin_action = rgpost( 'wiaas_delivery_process_navigation_action' )) {
list( $base_admin_action, $step_id ) = rgexplode( '|', $admin_action, 2 );
$next_step = gravity_flow()->get_next_step($this, $this->get_entry(), $this->get_form());
// going to next step
if ($base_admin_action === 'send_to_step' && $next_step && $next_step->get_id() == $step_id) {
$status = 'complete';
}
}
parent::update_step_status($status);
}
/**
* Process Wiass Delivery Process Step
*
@@ -115,77 +90,81 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
$entry = $this->get_entry();
$target_form = GFAPI::get_form( $this->target_form_id );
# if target form is not set we are done
# if target form is not valid just finish the step
if (!$target_form) {
// return false since we wait for admin to process the step
return false;
return true;
}
$delivery_settings = rgar($target_form, 'wiaas_delivery_process');
# create new entry for target form with populated value for customer-id from parent entry
$new_entry = array(
'form_id' => $this->target_form_id,
'wiaas_delivery_process_id' => $this->get_entry_id(),
'wiaas_delivery_order_id' => $entry['wiaas_delivery_order_id'],
'wiaas_delivery_step_name' => $this->get_name(),
);
if (! $delivery_settings['automatic_action_entries_enabled']) {
$customer_id_value = null;
return false;
}
$action_entries_ids = gform_get_meta($this->get_entry_id(), 'wiaas_delivery_step_' . $this->get_id() . '_action_entry_ids');
// if action entries present this step is reprocessing and we should not be creating new action entries
if (! empty($action_entries_ids)) {
// return false since we wait for admin to process the step
return false;
if ( is_array( $form['fields'] ) ) {
foreach ( $form['fields'] as $field ) {
if (GFCommon::get_label( $field ) === 'customer-id') {
$customer_id_value = $entry[$field->id];
break;
}
}
}
// create new entries for step action forms
$order_field = GFCommon::get_fields_by_type($form, 'wiaas_order')[0];
$order_id = empty($order_field) ? null : absint($entry[$order_field->id]);
// if process has not order we cannot create actions
if (empty($order_id)) {
// return false since we wait for admin to process the step
return false;
if ( is_array( $target_form['fields'] ) ) {
foreach ( $target_form['fields'] as $field ) {
if (GFCommon::get_label( $field ) === 'customer-id') {
$new_entry[$field->id] = $customer_id_value;
break;
}
}
}
$delivery_settings = rgar($target_form, 'wiaas_delivery_process');
switch ($delivery_settings['automatic_action_entries_type']) {
case 'single':
$action_entries_ids = $this->_create_single_action_entry($target_form, $order_id);
break;
case 'bundle':
$action_entries_ids = $this->_create_per_bundle_action_entries($target_form, $order_id);
$entry_id = GFAPI::add_entry( $new_entry );
if ( is_wp_error( $entry_id ) ) {
$this->log_debug( __METHOD__ .'(): failed to add entry' );
} else {
// store entry id
gform_update_meta($this->get_entry_id(), 'wiaas_delivery_step_' . $this->get_id() .'_entry_id', $entry_id);
}
gform_update_meta($this->get_entry_id(), 'wiaas_delivery_step_' . $this->get_id() . '_action_entry_ids', $action_entries_ids);
$note = $this->get_name() . ': ' . esc_html__( 'started.', 'wiaas' );
$this->add_note( $note );
// return false since we wait for admin to process the step
# return false since we wait for workflow of target entry to be complete first
return false;
}
public function workflow_detail_box($form, $args) {
parent::workflow_detail_box($form, $args);
/**
* Evaluates current step status based on target form entry status
*
* If target form entry has associated workflow current step will complete its status
* only when target form entry workflow is completed
* @return string
*/
public function status_evaluation() {
$target_form = GFAPI::get_form( $this->target_form_id );
# retrieve target form entry to check its workflow status
$target_form_entry = $this->get_target_form_entry();
if (empty( $target_form)) {
return;
# if there is no target form entry just complete the step
if(!$target_form_entry) {
return 'complete';
}
?>
<h4>Step: <?php echo $this->get_name() ?></h4>
<h4>Action: <?php echo $target_form['title'] ?></h4>
<?php
# retrieve target form entry workflow status
$api = new Gravity_Flow_API( $this->target_form_id );
$status = $api->get_status($target_form_entry);
# status is complete only if target entry flow is complete
return $status === 'complete' || $status === 'approved' ? 'complete' : 'pending';
}
/**
* Expands step entry with additional metadata to track created target actions entries id
*
* Expands step entry with additional metadata to track created target entry id
* @param array $entry_meta
* @param int $form_id
*
@@ -193,19 +172,69 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
*/
public function get_entry_meta($entry_meta, $form_id) {
if ($form_id === $this->get_form_id()) {
$entry_meta['wiaas_delivery_step_' . $this->get_id() . '_action_entry_ids'] = array();
$entry_meta['wiaas_delivery_step_' . $this->get_id() .'_entry_id'] = null;
}
return $entry_meta;
}
/**
* Retrieves forms that are valid options for delivery step action
*
* @return array
*/
public function get_action_forms_choices() {
public function get_target_forms_choices() {
return GFFormsModel::search_forms(self::$delivery_action_form_title_prefix, true);
}
return Wiaas_Delivery_Process_Action::get_action_forms();
/**
* Retrieves delivery action type that is executed with this step
* @return string
*/
public function get_delivery_action_type() {
$target_form = GFAPI::get_form( $this->target_form_id );
return self::$delivery_action_types[$target_form['title']];
}
public function get_target_actual_date() {
$target_entry = $this->get_target_form_entry();
$target_form = GFAPI::get_form( $this->target_form_id );
if (!is_wp_error($target_entry) && is_array($target_form['fields'])) {
foreach ( $target_form['fields'] as $field ) {
if (GFCommon::get_label( $field ) === 'Actual Date') {
return $target_entry[$field->id];
}
}
}
return null;
}
public function get_target_step_comments() {
$notes = RGFormsModel::get_lead_notes( $this->get_target_form_entry_id() );
$comments = array();
foreach ( $notes as $key => $note ) {
if ( $note->note_type !== 'gravityflow' ) {
$comments[] = array(
'date' => $note->date_created,
'text' => $note->value,
'user' => $note->user_name
);
}
}
return $comments;
}
/**
* Retrieves target form entry created when step was started
* @return array|null
*/
public function get_target_form_entry() {
$entry = GFAPI::get_entry($this->get_target_form_entry_id());
if(is_wp_error($entry)) {
return null;
}
return $entry;
}
@@ -218,67 +247,4 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
return absint($value);
}
private function _create_single_action_entry($target_form, $order_id) {
$action_entries_ids = array();
$new_entry = Wiaas_Order_Fields::map_order_to_entry($order_id, $target_form);
if (empty($new_entry)) {
// entry cannot be created
return $action_entries_ids;
}
$new_entry['form_id'] = $target_form['id'];
$new_entry['wiaas_delivery_process_id'] = $this->get_entry_id();
$new_entry['wiaas_delivery_order_id'] = $order_id;
$entry_id = GFAPI::add_entry( $new_entry );
if ( is_wp_error( $entry_id ) ) {
$this->log_debug( __METHOD__ .'(): failed to add entry' );
} else {
// store entry id
$action_entries_ids[] = $entry_id;
}
return $action_entries_ids;
}
private function _create_per_bundle_action_entries($target_form, $order_id) {
$action_entries_ids = array();
$bundle_items = wiaas_get_order_standard_bundle_items($order_id);
foreach ($bundle_items as $item) {
$new_entry = Wiaas_Order_Fields::map_order_to_entry($order_id, $target_form, $item->get_id());
if (empty($new_entry)) {
// entry cannot be created
continue;
}
$new_entry['form_id'] = $target_form['id'];
$new_entry['wiaas_delivery_process_id'] = $this->get_entry_id();
$new_entry['wiaas_delivery_order_id'] = $order_id;
$entry_id = GFAPI::add_entry( $new_entry );
if ( is_wp_error( $entry_id ) ) {
$this->log_debug( __METHOD__ .'(): failed to add entry' );
} else {
// store entry id
$action_entries_ids[] = $entry_id;
}
}
return $action_entries_ids;
}
}

View File

@@ -1,73 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Field_Order_Bundle_Document extends GF_Field_FileUpload {
public $type ='wiaas_order_bundle_document';
public $wiaasDocTypeFilter = 'config';
public function get_form_editor_field_settings() {
return array(
'wiaas_doc_type_filter',
'multiple_files_setting',
'conditional_logic_field_setting',
'error_message_setting',
'label_setting',
'label_placement_setting',
'admin_label_setting',
'rules_setting',
'file_extensions_setting',
'file_size_setting',
'visibility_setting',
'description_setting',
'css_class_setting',
);
}
public function get_input_type() {
return 'fileupload';
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
public function get_form_editor_field_title() {
return esc_attr__( 'Bundle Document', 'wiaas' );
}
public function get_download_url( $file, $force_download = false ) {
$upload_root = GFFormsModel::get_upload_url( $this->formId );
$upload_root = trailingslashit( $upload_root );
// handle download for order documents not uploaded by gravity forms
if ( strpos( $file, $upload_root ) === false ) {
return admin_url() . '?gf-wiaas-order-doc=' . urlencode($file);
}
return parent::get_download_url( $file, $force_download );
}
public function sanitize_settings() {
parent::sanitize_settings();
$this->wiaasDocTypeFilter = sanitize_key($this->wiaasDocTypeFilter);
}
}
GF_Fields::register( new Wiaas_Field_Order_Bundle_Document() );

View File

@@ -1,38 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Field_Order_Bundle_Installation_Date extends GF_Field_Date {
public $type ='wiaas_order_bundle_installation_date';
public $inputType = 'date';
public $dateType = 'datepicker';
public function get_input_type() {
return 'date';
}
public function get_form_editor_field_title() {
return esc_attr__( 'Bundle Install Date', 'wiaas' );
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
}
GF_Fields::register( new Wiaas_Field_Order_Bundle_Installation_Date() );

View File

@@ -1,63 +0,0 @@
<?php
class Wiaas_Field_Order_Bundle extends GF_Field_Text {
public $type = 'wiaas_order_bundle';
public function get_form_editor_field_title() {
return esc_attr__( 'Bundle', 'wiaas' );
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
return $this->get_bundle_display_name($value);
}
public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br ) {
return $this->get_bundle_display_name($value);
}
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
return $this->get_bundle_display_name($value);
}
public function get_bundle_item($value) {
list($order_id, $item_id) = rgexplode('|', $value, 2);
if (! empty($order_id) && ! empty($item_id) && $order = wc_get_order($order_id)) {
return $order->get_item($item_id);
}
return null;
}
public function get_bundle_display_name($value) {
$item = $this->get_bundle_item($value);
if (! empty($item)) {
return $item->get_name();
}
return '';
}
}
GF_Fields::register( new Wiaas_Field_Order_Bundle() );

View File

@@ -1,74 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Field_Order_Document extends GF_Field_FileUpload {
public $type ='wiaas_order_document';
public $wiaasDocTypeFilter = 'install_guide';
public function get_form_editor_field_settings() {
return array(
'wiaas_doc_type_filter',
'multiple_files_setting',
'conditional_logic_field_setting',
'error_message_setting',
'label_setting',
'label_placement_setting',
'admin_label_setting',
'rules_setting',
'file_extensions_setting',
'file_size_setting',
'visibility_setting',
'description_setting',
'css_class_setting',
);
}
public function get_input_type() {
return 'fileupload';
}
public function get_form_editor_field_title() {
return esc_attr__( 'Order Document', 'wiaas' );
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
public function get_download_url( $file, $force_download = false ) {
$upload_root = GFFormsModel::get_upload_url( $this->formId );
$upload_root = trailingslashit( $upload_root );
// handle download for order documents not uploaded by gravity forms
if ( strpos( $file, $upload_root ) === false ) {
return admin_url() . '?gf-wiaas-order-doc=' . urlencode($file);
}
return parent::get_download_url( $file, true );
}
public function sanitize_settings() {
parent::sanitize_settings();
$this->wiaasDocTypeFilter = sanitize_key($this->wiaasDocTypeFilter);
}
}
GF_Fields::register( new Wiaas_Field_Order_Document() );

View File

@@ -1,127 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Order_Installation_Select extends GF_Field_Select {
public $type = 'wiaas_order_installation_select';
public function get_input_type() {
return 'workflow_assignee_select';
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
public function get_field_input( $form, $value = '', $entry = null ) {
if ( empty($entry) ) {
return parent::get_field_input($form, $value, $entry);
}
// get bundle item field
$bundle_item_field = GFCommon::get_fields_by_type($form, array( 'wiaas_order_bundle') )[0];
if (! empty($bundle_item_field) &&
$bundle_item = $bundle_item_field->get_bundle_item($entry[$bundle_item_field->id])) {
$bundled_items = wc_pb_get_bundled_order_items($bundle_item);
$installation_items = array();
foreach ($bundled_items as $id => $bundled_item) {
$product = $bundled_item->get_product();
if ($product && Wiaas_Product_Category::is_installation($product)) {
$installation_items[] = $bundled_item;
}
}
$choices = array(
array( 'value' => '0', 'text' => 'Select installation ...')
);
$order_id = $bundle_item->get_order_id();
foreach ($installation_items as $installation_item) {
$choices[] = array(
'value' => 'wiaas_installation_' . $order_id . '|' . $installation_item->get_id(),
'text' => $installation_item->get_name()
);
}
$this->choices = $choices;
}
return parent::get_field_input($form, $value, $entry);
}
public function get_form_editor_field_title() {
return esc_attr__( 'Installation Select', 'wiaas' );
}
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
return $this->get_selected_installation_display_name($value);
}
public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br ) {
return $this->get_selected_installation_display_name($value);
}
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
return $this->get_selected_installation_display_name($value);
}
public function get_selected_installation($value) {
$value = $value ? str_replace('wiaas_installation_', '', $value) : '';
list ($order_id, $item_id) = explode('|', $value);
if (! empty($order_id) && ! empty($item_id) && $order = wc_get_order($order_id)) {
return $order->get_item($item_id);
}
return null;
}
public function get_selected_installation_display_name($value) {
$item = $this->get_selected_installation($value);
return ! empty($item) ? $item->get_name() : '';
}
public function post_convert_field() {
if ($this->is_form_editor()) {
$this->choices = array(
array( 'value' => '0', 'text' => 'Select installation ...')
);
}
}
}
GF_Fields::register( new Wiaas_Order_Installation_Select() );

View File

@@ -1,66 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Field_Order_Number extends GF_Field_Number {
public $type = 'wiaas_order';
function get_form_editor_field_settings() {
return array(
'conditional_logic_field_setting',
'prepopulate_field_setting',
'error_message_setting',
'label_setting',
'label_placement_setting',
'admin_label_setting',
'size_setting',
'rules_setting',
'visibility_setting',
'duplicate_setting',
'default_value_setting',
'placeholder_setting',
'description_setting',
'css_class_setting',
);
}
public function sanitize_settings() {
parent::sanitize_settings();
}
public function get_form_editor_field_title() {
return esc_attr__( 'Order Number', 'wiaas' );
}
public function add_button( $field_groups ) {
$field_groups = Wiaas_Order_Fields::maybe_add_order_field_group($field_groups);
return parent::add_button( $field_groups );
}
public function get_form_editor_button() {
return array(
'group' => 'wiaas_order_fields',
'text' => $this->get_form_editor_field_title(),
);
}
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
return "#100000$value";
}
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
return "#100000$value";
}
public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br ) {
return "#100000$value";
}
}
GF_Fields::register( new Wiaas_Field_Order_Number() );

View File

@@ -1,59 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Merge_Tag_Customer_Order_Url extends Gravity_Flow_Merge_Tag {
/**
* Name of the merge tag
*
* @var string
*/
public $name = 'customer_order_url';
/**
* The regular expression to use for the matching.
*
* @var string
*/
protected $regex = '/{customer_order_url(:(.*?))?}/';
public function replace( $text ) {
$matches = $this->get_matches( $text );
if ( ! empty( $matches ) ) {
$entry = $this->entry;
$form = GFAPI::get_form($entry['form_id']);
$order_field = GFCommon::get_fields_by_type($form, 'wiaas_order')[0];
if (empty($order_field)) {
return $text;
}
$order_id = $entry[$order_field->id];
$url = WIAAS_CUSTOMER_INTERFACE . '/orders/' . $order_id;
$link = sprintf( '<a href="%s">%s</a>', $url, 'Order' );
foreach ( $matches as $match ) {
$full_tag = $match[0];
$text = str_replace( $full_tag, $link, $text );
}
}
return $text;
}
}
Gravity_Flow_Merge_Tags::register( new Wiaas_Merge_Tag_Customer_Order_Url );

View File

@@ -1,478 +0,0 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Order_Fields {
public static function init() {
add_action( 'gform_field_standard_settings', array( __CLASS__, 'field_settings' ) );
add_filter('gform_fileupload_entry_value_file_path', array( __CLASS__, 'display_order_document_fields' ), 999, 2);
add_action('gform_post_update_entry', array(__CLASS__, 'maybe_map_entry_to_order'), 10, 2);
add_action('gform_after_update_entry', array(__CLASS__, 'maybe_apply_user_input_changes'), 10, 3);
}
/**
* Workflow user input are handled separately in gravity flow. We get them here
* and then try to apply changes to order
*
* @param $form
* @param $entry_id
* @param $original_entry
*/
public static function maybe_apply_user_input_changes($form, $entry_id, $original_entry) {
$entry = GFAPI::get_entry($entry_id);
self::maybe_map_entry_to_order($entry, $original_entry);
}
/**
* Persist workflow entry change to order
*
* @param $entry
* @param $old_entry
*/
public static function maybe_map_entry_to_order($entry, $old_entry) {
$form = GFAPI::get_form($old_entry['form_id']);
$order_field = GFCommon::get_fields_by_type($form, 'wiaas_order')[0];
if (empty($order_field)) {
return;
}
$order_id = $entry[$order_field->id];
// get order process entry
$order = wc_get_order($order_id);
$process_entry = Wiaas_Delivery_Process::get_order_delivery_process_entry($order_id);
if ( !$order || empty($process_entry) ) {
return;
}
// apply entry changes to order properties
foreach ($form['fields'] as $field) {
$old_value = $old_entry[$field->id];
$new_value = $entry[$field->id];
// check if field changed
if ($old_value === $new_value || empty($new_value)) {
continue;
}
// save changes to order
switch ($field->type) {
case 'wiaas_order_bundle_installation_date':
/**
* Persist bundle installation date
*/
// get corresponding bundle field
$bundle_field = GFCommon::get_fields_by_type( $form, 'wiaas_order_bundle' )[0];
if (empty($bundle_field)) {
continue;
}
$bundle_item = $bundle_field->get_bundle_item( $entry[$bundle_field->id] );
if (empty($bundle_item)) {
continue;
}
$bundle_item->update_meta_data('_wiaas_installation_date', $new_value);
$bundle_item->save_meta_data();
break;
case 'wiaas_order_bundle_document':
/**
* Persist delivery flow documents for bundle
*/
// get corresponding bundle field
$bundle_field = GFCommon::get_fields_by_type( $form, 'wiaas_order_bundle' )[0];
if (empty($bundle_field)) {
continue;
}
$bundle_item = $bundle_field->get_bundle_item( $entry[$bundle_field->id] );
if (empty($bundle_item)) {
continue;
}
$bundle_documents = $bundle_item->get_meta('_wiaas_documents', true);
if (empty($bundle_documents)) {
$bundle_documents = array();
}
$new_documents = $field->multipleFiles ? json_decode( $new_value ) : array( $new_value );
if (! empty($old_value) ) {
$old_documents = $field->multipleFiles ? json_decode( $old_value ) : array( $old_value );
$added_documents = array_diff($new_documents, $old_documents);
} else {
$added_documents = $new_documents;
}
foreach ($added_documents as $added_document) {
$info = pathinfo( $added_document );
$dir = wp_upload_dir();
$relative_file_path = str_replace($dir['baseurl'] . '/', '', $added_document);
$bundle_documents[] = array(
'key' => wp_generate_uuid4(),
'name' => $info['filename'],
'extension' => $info['extension'],
'version' => $relative_file_path,
'url' => $field->get_download_url( $added_document, true ),
'type' => $field->wiaasDocTypeFilter
);
}
$bundle_item->update_meta_data('_wiaas_documents', $bundle_documents);
$bundle_item->save_meta_data();
break;
case 'wiaas_order_document':
/**
* Persist delivery flow documents for order
*/
$new_documents = $field->multipleFiles ? json_decode( $new_value ) : array( $new_value );
if (! empty($old_value) ) {
$old_documents = $field->multipleFiles ? json_decode( $old_value ) : array( $old_value );
$added_documents = array_diff($new_documents, $old_documents);
} else {
$added_documents = $new_documents;
}
$order_documents = $order->get_meta('_wiaas_other_documents', true);
if (empty($order_documents)) {
$order_documents = array();
}
foreach ($added_documents as $added_document) {
$info = pathinfo( $added_document );
$dir = wp_upload_dir();
$relative_file_path = str_replace($dir['baseurl'] . '/', '', $added_document);
$order_documents[] = array(
'key' => wp_generate_uuid4(),
'name' => $info['filename'],
'extension' => $info['extension'],
'version' => $relative_file_path,
'url' => $field->get_download_url( $added_document, true ),
'type' => $field->wiaasDocTypeFilter
);
}
$order->update_meta_data('_wiaas_other_documents', $order_documents);
$order->save_meta_data();
break;
case 'wiaas_order_installation_select':
/**
* Persist installation for bundle
*/
$selected_installation = $field->get_selected_installation($new_value);
if ( empty($selected_installation) ) {
// no installation selected
continue;
}
// get corresponding bundle field
$bundle_field = GFCommon::get_fields_by_type( $form, 'wiaas_order_bundle' )[0];
if (empty($bundle_field)) {
continue;
}
$bundle_item = $bundle_field->get_bundle_item( $entry[$bundle_field->id] );
if (empty($bundle_item)) {
continue;
}
$bundle_item->update_meta_data('_wiaas_installation', $selected_installation->get_id());
$bundle_item->save_meta_data();
}
}
}
/**
* Adds the Order Fields group to the form editor.
*
* @param array $field_groups The properties for the field groups.
*
* @return array
*/
public static function maybe_add_order_field_group( $field_groups ) {
foreach ( $field_groups as $field_group ) {
if ( $field_group['name'] == 'wiaas_order_fields' ) {
return $field_groups;
}
}
$field_groups[] = array(
'name' => 'wiaas_order_fields',
'label' => __( 'Order Fields', 'wiaas' ),
'fields' => array()
);
return $field_groups;
}
public static function display_order_document_fields($file_path, $field) {
if (strpos($file_path, 'gf-download') === false &&
strpos($file_path, 'gf-wiaas-order-doc') === false) {
$field = new Wiaas_Field_Order_Bundle_Document();
return $field->get_download_url($file_path);
}
return $file_path;
}
/**
* Add custom settings for form order fields
*
* @param int $position
*/
public static function field_settings( $position ) {
if ( $position === 20 ) {
// After Field description setting.
?>
<li class="wiaas_doc_type_filter field_setting">
<label for="wiaas-doc-type-filter" class="section_label">
<?php esc_html_e( 'Document Type', 'wiaas' ); ?>
</label>
<select id="wiaas-doc-type-filter" onchange="SetFieldProperty('wiaasDocTypeFilter',this.value);">
<option value="configuration"><?php esc_html_e( 'Configuration', 'wiaas' ); ?></option>
<option value="order_questionaire"><?php esc_html_e( 'Order Questionaire', 'wiaas' ); ?></option>
<option value="installation_protocol"><?php esc_html_e( 'Installation protocol', 'wiaas' ); ?></option>
<option value="install_guide"><?php esc_html_e( 'Installation Guide', 'wiaas' ); ?></option>
<option value="customer_acceptance"><?php esc_html_e( 'Customer acceptance', 'wiaas' ); ?></option>
</select>
</li>
<li class="wiaas_installation_organization_filter field_setting">
<input type="checkbox" id="wiaas-installation-organization-filter"
onclick="var value = jQuery(this).is(':checked'); SetFieldProperty('wiaasOnlyInstallationOrg', value);""/>
<label for="wiaas-installation-organization-filter" class="inline">
<?php esc_html_e( 'Only installation', 'wiaas' ); ?>
</label>
</li>
<?php
}
}
public static function get_value_from_order_field($entry, $field) {
switch ($field->type) {
case 'wiaas_order_bundle':
$value = $entry[$field->id];
list ($order_id, $item_id) = explode('|', $value);
if ( ! empty($order_id) && ! empty($item_id)) {
return array(
'id' => $item_id,
'name' => $field->get_selected_bundle_display_name($value)
);
}
return null;
case '':
}
}
public static function map_order_to_entry($order_id, $form, $bundle_item_id = null) {
if (empty($form['fields']) ||
empty(GFCommon::get_fields_by_type( $form, array('wiaas_order')) ) ) {
// form does not have order field so cannot be mapped
return false;
}
$order = wc_get_order($order_id);
$entry = array();
foreach ($form['fields'] as $field) {
switch ($field->type) {
case 'wiaas_order':
$entry[(string) $field->id] = $order->get_id();
break;
case 'workflow_user':
$entry[(string) $field->id] = $order->get_customer_id(); // save customer if needed
break;
case 'wiaas_order_bundle':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty($bundle_item)) {
$entry[(string) $field->id] = $order->get_id() . '|' . $bundle_item->get_id();
}
break;
case 'wiaas_order_bundle_document':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty($bundle_item)) {
$documents = wiaas_get_standard_package_order_item_documents($order, $bundle_item_id);
$filtered_documents = array();
foreach ($documents as $document) {
if ($document['type'] === $field->wiaasDocTypeFilter) {
$filtered_documents[] = $document;
}
}
if ( empty($filtered_documents) && $field->isRequired ) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty ($filtered_documents) && ! $field->multipleFiles) {
$document = $filtered_documents[0];
$entry[$field->id] = $document['version'];
} else if (! empty ($filtered_documents) ) {
$versions = array();
foreach ($filtered_documents as $filtered_document) {
$versions[] = $filtered_document['version'];
}
$entry[$field->id] = json_encode($versions);
}
}
break;
case 'wiaas_order_installation_select':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
// installation is already selected
if (!empty($bundle_item->get_meta('wiaas_installation', true))) {
$entry[(string) $field->id] = 'wiaas_installation_' . $order->get_id() . '|' . $bundle_item->get_meta('wiaas_installation', true);
continue;
}
$bundled_items = wc_pb_get_bundled_order_items($bundle_item, $order);
$installation_items = array();
foreach ($bundled_items as $id => $bundled_item) {
$product = $bundled_item->get_product();
if ($product && Wiaas_Product_Category::is_installation($product)) {
$installation_items[] = $bundled_item;
}
}
if (empty($installation_items)) {
// there is no data for required field so entry cannot be created
return false;
}
if (count($installation_items) === 1) {
$installation_item = $installation_items[0];
$entry[(string) $field->id] = 'wiaas_installation_' . $order->get_id() . '|' . $installation_item->get_id();
} else if (count($installation_items) > 1) {
// force admin to select installation
$entry[(string) $field->id] = '0';
}
}
}
return $entry;
}
}
Wiaas_Order_Fields::init();

View File

@@ -12,35 +12,6 @@ class Wiaas_Document_Download {
if ( isset($_GET['wiaasdoc']) ) {
add_action( 'init', array( __CLASS__, 'admin_download' ) );
}
if (isset($_GET['gf-wiaas-order-doc'])) {
add_action( 'init', array( __CLASS__, 'admin_gf_order_document_download' ) );
}
}
/**
* Handle download for order documents by gravity flow steps
*/
public static function admin_gf_order_document_download() {
if (!is_user_logged_in()) {
wp_die( __( 'No Access.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 403 ) );
}
// relative file path from upload dir for document
$version = urldecode($_GET['gf-wiaas-order-doc']);
$file_path = wiaas_get_document_version_path($version);
if (!file_exists($file_path)) {
wp_die( __( 'Document not found.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
}
WC_Download_Handler::download_file_force(
$file_path,
pathinfo( $file_path, PATHINFO_FILENAME ) . '.' . pathinfo( $file_path, PATHINFO_EXTENSION )
);
}
/**
@@ -83,49 +54,6 @@ class Wiaas_Document_Download {
);
}
/**
* Download order other document (not binded to any bundle)
* @param int $order_id
* @param string $document_key
*/
public static function download_order_other_document($order_id, $document_key) {
$order = wc_get_order($order_id);
if (!$order) {
wp_die( __( 'Invalid Document Request.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 400 ) );
}
$order_other_documents = wiaas_get_order_other_documents($order_id);
$order_document = null;
foreach ($order_other_documents as $order_other_document) {
if ($order_other_document['key'] === $document_key) {
$order_document = $order_other_document;
break;
}
}
if (!isset($order_document)) {
wp_die( __( 'Invalid Document Request.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 400 ) );
}
$file_path = wiaas_get_document_version_path($order_document['version']);
error_log($file_path);
if (!file_exists($file_path)) {
wp_die( __( 'Document not found.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
}
WC_Download_Handler::download_file_force(
$file_path,
pathinfo( $file_path, PATHINFO_FILENAME ) . '.' . pathinfo( $file_path, PATHINFO_EXTENSION )
);
}
/**
* Download document related to order item
*
@@ -134,7 +62,7 @@ class Wiaas_Document_Download {
* @param $type
* @param $document_key
*/
public static function download_order_item_document($order_id, $item_id, $document_key) {
public static function download_order_item_document($order_id, $item_id, $type, $document_key) {
$order = wc_get_order($order_id);
if (!$order) {
wp_die( __( 'Invalid Document Request.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 400 ) );
@@ -149,7 +77,7 @@ class Wiaas_Document_Download {
$order_document = null;
foreach ($item_documents as $item_document) {
if ($item_document['key'] === $document_key) {
if ($item_document['key'] === $document_key && $item_document['type'] === $type) {
$order_document = $item_document;
break;
}

View File

@@ -303,11 +303,11 @@ class Wiaas_Document {
return;
}
foreach (self::$available_doc_types as $key => $available_doc_type) {
wp_insert_term($available_doc_type['name'], 'wpdmcategory', array(
'slug' => $key
));
}
// foreach (self::$available_doc_types as $key => $available_doc_type) {
// wp_insert_term($available_doc_type['name'], 'wpdmcategory', array(
// 'slug' => $key
// ));
// }
}
public static function register_wiaas_document() {
@@ -388,6 +388,7 @@ class Wiaas_Document {
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'wiaas_doc_type' ),
'show_in_rest' => false,
'capabilities' => array(
'manage_terms' => 'manage_wiaas_doc_terms',
'edit_terms' => 'edit_wiaas_doc_terms',
@@ -399,9 +400,11 @@ class Wiaas_Document {
register_taxonomy( 'wiaas_doc_type', array( 'wiaas_doc' ), $args );
foreach (self::$available_doc_types as $key => $available_doc_type) {
wp_insert_term($available_doc_type['name'], 'wiaas_doc_type', array(
'slug' => $key
));
// if (! has_term($available_doc_type['name'], 'wiaas_doc_type')) {
// wp_insert_term($available_doc_type['name'], 'wiaas_doc_type', array(
// 'slug' => $key
// ));
// }
}
}

View File

@@ -26,17 +26,6 @@ function wiaas_documents_upload_dir() {
* @return string
*/
function wiaas_get_document_version_path($version) {
// documents uploaded with gravity forms have relevant path to form entry upload folder
if (strpos($version, 'gravity_forms') !== false) {
$wp_uploads = wp_upload_dir();
$wp_uploads_dir = $wp_uploads['basedir'];
return $wp_uploads_dir . '/' . $version;
}
return wiaas_documents_upload_dir() . '/' . $version;
}
@@ -193,60 +182,9 @@ function wiaas_get_standard_package_order_item_documents($order, $package_item_i
return array_map(function($doc) {
// append document extension and name information
$doc['extension'] = isset($doc['extension']) ? $doc['extension'] : wiaas_get_doc_version_extension($doc['version']);
$doc['extension'] = wiaas_get_doc_version_extension($doc['version']);
$doc['name'] = isset($doc['name']) ? $doc['name'] : wiaas_get_doc_version_filename($doc['version']);
return $doc;
}, $order_documents);
}
/**
* Retrieve documents for order item
*
* @param $order_item
* @param string|null $doc_type
*
* @return array {
* $param string key Unique key used for frontend downloand
* $param string name Document name visible in download link
* $param string version Relative path from upload directory to physical document file
* $param string type Document type
*
* @reference Wiaas_Document
* }
*/
function wiaas_get_order_item_documents($order_item, $doc_type = null) {
$documents = empty($order_item['wiaas_documents']) ? array() : $order_item['wiaas_documents'];
if (empty($doc_type)) {
return $documents;
}
$filtered_documents = array();
foreach ($documents as $document) {
if ($document['type'] === $doc_type) {
$filtered_documents[] = $document;
}
}
return $filtered_documents;
}
/**
* Retrieve order other documents (not binded to any order item)
*
* @param int $order_id
*
* @return array|mixed
*/
function wiaas_get_order_other_documents($order_id) {
$order = wc_get_order($order_id);
$documents = $order->get_meta('_wiaas_other_documents', true);
return empty($documents) ? array() : $documents;
}

View File

@@ -31,12 +31,6 @@ class Wiaas_Order_Project {
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'shop_order_project' ),
'capabilities' => array(
'manage_terms' => 'manage_wiaas_order_projects',
'edit_terms' => 'manage_wiaas_order_projects',
'delete_terms' => 'manage_wiaas_order_projects',
'assign_terms' => 'manage_wiaas_order_projects',
),
'update_count_callback' => array(__CLASS__, 'update_count_callback')
);
@@ -61,25 +55,21 @@ class Wiaas_Order_Project {
public static function get_available_order_projects() {
$all_terms = get_terms(array(
'taxonomy' => 'shop_order_project',
'hide_empty' => false
'hide_empty' => false,
'meta_key' => '_wiaas_is_available',
'meta_value' => 'yes'
));
if (is_wp_error($all_terms)) {
return array();
}
$available_terms = array();
foreach ($all_terms as $term) {
if (self::is_order_project_available($term->term_id)) {
$available_terms[] = array(
'id' => $term->term_id,
'name' => $term->name
);
}
}
return $available_terms;
return array_map(function($term) {
return array(
'id' => $term->term_id,
'name' => $term->name
);
}, $all_terms);
}
/**

View File

@@ -1,92 +0,0 @@
<?php
/**
* Retrieve standard bundles from order
*
* @param int|WC_Order $order
*
* @return array
*/
function wiaas_get_order_standard_bundle_items($order) {
if (is_numeric($order)) {
$order = wc_get_order($order);
}
$items = $order->get_items();
$standard_bundle_items = array();
foreach ($items as $item) {
if (isset($item['wiaas_standard_package'])) {
$standard_bundle_items[] = $item;
}
}
return $standard_bundle_items;
}
/**
* Retrieve order summary data for procurement order for suppliers
*
* @param int $order_id
*
* @return array
*/
function wiaas_get_order_procurement_info($order_id) {
$order = wc_get_order($order_id);
$order_items = $order->get_items();
$order_suppliers_info = array();
$order_delivery_suppliers_info = $order->get_meta('_wiaas_delivery_suppliers');
$order_installation_suppliers_info = $order->get_meta('_wiaas_installation_suppliers');
foreach ($order_delivery_suppliers_info as $id => $order_delivery_supplier_info) {
$order_suppliers_info[$id] = $order_delivery_supplier_info;
}
foreach ($order_installation_suppliers_info as $id => $order_installation_supplier_info) {
$order_suppliers_info[$id] = $order_installation_supplier_info;
}
$data = array();
foreach ($order_items as $order_item_id => $order_item) {
$category = $order_item['wiaas_category'];
$supplier_organization_id = $order_item['wiaas_supplier_organization_id'];
$supplier_info = $order_suppliers_info[$supplier_organization_id];
if (empty($category)) {
continue;
}
$data[$category] ?: array();
// get price and quantity
$single_product_item_cost = floatval($order_item['wiaas_product_price']);
$quantity = absint($order_item['quantity']);
$total_price = $quantity * $single_product_item_cost;
$data[$category][] = array(
'Name' => $order_item->get_name(),
'Category' => ucfirst(strtolower($category)),
'Manufacturer Product No' => $order_item['wiaas_manufacturer_product_no'],
'Supplier Product No' => $order_item['wiaas_supplier_product_no'],
'Units' => $quantity,
'Price' => $total_price,
'Supplier Company' => $supplier_info['name'],
'Supplier VAT' => $supplier_info['vat_code'],
'Supplier Phone' => $supplier_info['phone'],
'Supplier Email' => $supplier_info['email'],
);
}
return $data;
}

View File

@@ -54,7 +54,7 @@ class Wiaas_Package_Type {
$types = apply_filters('wiaas_package_types', array('standard'));
foreach ($types as $type) {
wp_insert_term($type, 'package_type');
wp_update_term($type, 'package_type');
}
}

View File

@@ -50,14 +50,14 @@ function wiaas_get_price_margin($fixed_price, $principal_amount, $total_cost) {
return $total_gain - $total_cost;
}
function wiaas_get_package_product_procurement_cost($package){
function wiaas_get_package_hardware_procurement_cost($package) {
$bundled_items = $package->get_bundled_items();
$total_cost = 0;
foreach ($bundled_items as $bundled_item) {
$product = $bundled_item->product;
if (Wiaas_Product_Category::is_product($product)) {
if (Wiaas_Product_Category::get_category($product) === 'hardware') {
$total_cost += Wiaas_Pricing::get_product_total_cost($product) * $bundled_item->get_quantity();
}
}
@@ -65,6 +65,19 @@ function wiaas_get_package_product_procurement_cost($package){
return $total_cost;
}
function wiaas_get_package_software_procurement_cost($package) {
$bundled_items = $package->get_bundled_items();
$total_cost = 0;
foreach ($bundled_items as $bundled_item) {
if (Wiaas_Product_Category::is_hardware($bundled_item->product)) {
$total_cost += Wiaas_Pricing::get_product_total_cost($bundled_item->product) * $bundled_item->get_quantity();
}
}
return $total_cost;
}
function wiaas_get_package_installation_procurement_cost($package) {
$bundled_items = $package->get_bundled_items();
$total_cost = 0;

View File

@@ -47,7 +47,7 @@ class Wiaas_Product_Category {
foreach (self::$available_product_categories as $key => $available_product_category) {
if (! has_term_meta($key)) {
wp_insert_term($key, 'product_cat');
wp_update_term($key, 'product_cat');
}
}
}
@@ -86,15 +86,26 @@ class Wiaas_Product_Category {
}
/**
* Determines if provided product type is product (hardware or software)
* Determines if provided product is hardware
* @param $product
*
* @return bool
*/
public static function is_product($product) {
return self::_get_product_category_type($product) === 'product';
public static function is_hardware($product) {
return self::_get_product_category_type($product) === 'hardware';
}
/**
* Determines if provided product is software
* @param $product
*
* @return bool
*/
public static function is_software($product) {
return self::_get_product_category_type($product) === 'software';
}
// PRIVATE

View File

@@ -6,8 +6,7 @@ class Wiaas_Product_Supplier {
public static function init() {
add_action('init', array(__CLASS__, 'register_supplier_taxonomy'));
add_action('wiaas_organization_created', array(__CLASS__, 'on_organization_added'), 20, 2);
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'on_organization_added'), 20, 2);
add_action('created_' . 'wiaas-user-organization', array(__CLASS__, 'on_organization_added'));
}
/**
@@ -34,7 +33,7 @@ class Wiaas_Product_Supplier {
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'meta_box_cb' => false,
'meta_box_cb' => false,
'query_var' => true,
'rewrite' => array('slug' => 'template_category'),
);
@@ -47,45 +46,19 @@ class Wiaas_Product_Supplier {
* Create corresponding supplier term for organization
*
* @param $organization_id
* @param $roles
*/
public static function on_organization_added($organization_id, $roles) {
public static function on_organization_added($organization_id) {
$organization = get_term_by('id', $organization_id, 'wiaas-user-organization');
$supplier = term_exists($organization->slug, 'supplier');
$supplier = term_exists($organization->slug, 'supplier');
if (!$supplier && in_array('supplier', $roles)) {
$supplier = wp_insert_term($organization->name, 'supplier', array(
'slug' => $organization->slug
));
if (! $supplier) {
$supplier = wp_insert_term($organization->name, 'supplier', array(
'slug' => $organization->slug
));
}
add_term_meta($supplier['term_id'], 'organisation_id', $organization->term_id);
}
/**
* Retrieve organisation id of the supplier of the product
*
* @param $product_id
* @return int|false organization_id
*/
public static function get_supplier_organisation_id_from_product($product_id) {
$supplier_terms = wp_get_object_terms($product_id, 'supplier');
if (empty( $supplier_terms )) {
return false;
}
$supplier_organisation_slug = $supplier_terms[0]->slug;
$supplier_organisation = get_term_by('slug', $supplier_organisation_slug, 'wiaas-user-organization');
if ($supplier_organisation) {
return $supplier_organisation->term_id;
}
return $supplier_organisation ? $supplier_organisation->term_id : false;
add_term_meta($supplier['term_id'], 'organisation_id', $organization->term_id);
}
}

View File

@@ -9,17 +9,11 @@ class Wiaas_Template_Category_Object {
public $quantity = '';
public $product_id = '';
public $product_name = '';
public function __construct($id, $title, $quant, $product_id = '', $product_name = '') {
public function __construct($id, $title, $quant) {
$this->template_category_id = $id;
$this->name = $title;
$this->quantity = $quant;
$this->product_id = $product_id;
$this->product_name = $product_name;
}
public function get_quantity(){

View File

@@ -92,9 +92,7 @@ function construct_template_products_class() {
$template_category_object = new Wiaas_Template_Category_Object(
$category_template_id,
$cat,
$item_data['quantity_max'],
$item->get_id(),
$item->get_title());
$item_data['quantity_max']);
$template_category_objects[$category_template_id] = $template_category_object;
}

View File

@@ -15,8 +15,7 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
'plural' => __('Organizations', 'wiaas'),
'exclusive' => true,
'public' => true,
'show_in_rest' => true,
'rest_base' => 'organization'
'show_in_rest' => false,
);
$labels = array();
$caps = array();
@@ -45,15 +44,15 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
// Remove bulk editor for organizations on users list
remove_filter( 'admin_notices', array( $this, 'bulk_notice'));
remove_filter( 'bulk_actions-users', array( $this, 'bulk_actions'));
remove_filter( 'bulk_actions-users', array( $this, 'bulk_actions_sort'));
remove_action( 'handle_bulk_actions-users', array( $this, 'handle_bulk_actions'));
remove_filter( 'admin_notices', array( $this, 'bulk_notice'));
remove_filter( 'bulk_actions-users', array( $this, 'bulk_actions'));
remove_filter( 'bulk_actions-users', array( $this, 'bulk_actions_sort'));
remove_action( 'handle_bulk_actions-users', array( $this, 'handle_bulk_actions'));
// remove default organization info from profiles
// it will be handled by custom fields
remove_action( 'show_user_profile', array( $this, 'edit_user_relationships' ), 99);
remove_action( 'edit_user_profile', array( $this, 'edit_user_relationships' ), 99 );
// remove default organization info from profiles
// it will be handled by custom fields
remove_action( 'show_user_profile', array( $this, 'edit_user_relationships' ), 99);
remove_action( 'edit_user_profile', array( $this, 'edit_user_relationships' ), 99 );
}
// hooks functions
@@ -61,15 +60,12 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
/**
* Creates corresponding access group for newly created organizational term
*
* @param int $organization_id id of the organization term
* @param $organization_id id of the organization term
*/
public static function on_organization_added($organization_id) {
self::_create_organization_access_group($organization_id);
$roles = wiaas_get_organization_roles($organization_id);
do_action('wiaas_organization_created', $organization_id, $roles);
self::_assign_organization_roles_capabilities($organization_id, $roles);
do_action('wiaas_organization_created', $organization_id);
}
/**
@@ -108,11 +104,8 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
$id = absint(str_replace('term_', '', $id));
if ($id) {
self::_assign_organization_roles_capabilities($id, $roles);
do_action('wiaas_organization_roles_updated', $id, $roles);
}
do_action('wiaas_organization_roles_updated', $id, $roles);
}
}
@@ -161,7 +154,7 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
*/
public static function get_user_organization_id($user_id = null) {
if (!isset($user_id)) {
$user_id = get_current_user_id();
$user_id = get_current_user_id();
}
$organization_id = get_user_meta($user_id, '_wiaas_organization_id', true);
@@ -292,33 +285,4 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
}
}
}
/**
*Reflect organization roles in access group
*
* This will be used when assigning roles to user
*
* @param int $organization_id
* @param array $roles
*/
private static function _assign_organization_roles_capabilities($organization_id, $roles) {
$access_group_id = self::_get_organization_access_group_id($organization_id);
$all_roles = array( 'commercial_lead', 'supplier', 'customer', 'administrator');
foreach ($all_roles as $role) {
$cap = Groups_Capability::read_by_capability('wiaas_' . $role);
Groups_Group_Capability::delete($access_group_id, $cap->capability_id);
}
foreach ($roles as $role) {
$cap = Groups_Capability::read_by_capability('wiaas_' . $role);
Groups_Group_Capability::create(array(
'group_id' => $access_group_id,
'capability_id' => $cap->capability_id
));
}
}
}

View File

@@ -103,38 +103,4 @@ function wiaas_get_user_organization_id($user_id) {
*/
function wiaas_get_current_user_organization_id() {
return wiaas_get_user_organization_id(get_current_user_id());
}
function wiaas_get_organization_user_ids($organization_id) {
$user_ids = get_objects_in_term($organization_id, Wiaas_User_Organization::TAXONOMY_NAME);
return is_wp_error($user_ids) ? array() : $user_ids;
}
function wiaas_get_organization_info($organization_id) {
$organization = get_term($organization_id);
if ($organization) {
$user_ids = wiaas_get_organization_user_ids($organization_id);
$email = null;
if (! empty($user_ids)) {
$user = get_userdata($user_ids[0]);
$email = $user ? $user->user_email : null;
}
return array(
'name' => $organization->name,
'description' => $organization->description,
'vat_code' => get_term_meta($organization_id, '_wiaas_organization_vat', true),
'phone' => get_term_meta($organization_id, '_wiaas_organization_phone', true),
'email' => $email
);
}
}

View File

@@ -73,9 +73,7 @@ class Wiaas_Measurement_Units {
register_taxonomy('wiaas_units', array('product'), $args);
foreach (self::$available_units as $available_unit) {
if (!term_exists($available_unit, 'wiaas_units')) {
wp_insert_term($available_unit['unit'], 'wiaas_units');
}
wp_update_term($available_unit['unit'], 'wiaas_units');
}
}
}

View File

@@ -49,24 +49,21 @@
"johnpbloch/wordpress": "4.9.7",
"oscarotero/env": "1.1.0",
"roots/wp-password-bcrypt": "1.0.0",
"phpoffice/phpspreadsheet": "1.5",
"woocommerce/woocommerce": "3.5.0",
"3rdparty/woocommerce-product-bundles": "*",
"wpackagist-plugin/akismet": "4.0.3",
"woocommerce/woocommerce": "3.4.4",
"wpackagist-plugin/woocommerce-jetpack": "3.7.0",
"wpackagist-plugin/groups": "2.3.1",
"wpackagist-plugin/mailchimp-for-woocommerce": "2.1.7",
"wpackagist-plugin/jwt-authentication-for-wp-rest-api": "1.2.4",
"wpackagist-plugin/wp-user-groups": "2.2.0",
"wpackagist-plugin/radio-buttons-for-taxonomies": "1.8.3",
"wpackagist-plugin/advanced-access-manager": "5.4.3.2",
"wpackagist-plugin/advanced-custom-fields" : "5.7.7",
"wpackagist-plugin/radio-buttons-for-taxonomies": "1.8.3",
"wpackagist-plugin/sendgrid-email-delivery-simplified" : "1.11.8",
"3rdparty/gravityforms": "*",
"3rdparty/gravityflow": "*"
"3rdparty/gravityflow": "*",
"3rdparty/woocommerce-product-bundles": "*"
},
"require-dev": {
"vlucas/phpdotenv": "2.5.0"
@@ -89,15 +86,14 @@
"activate-plugins": [
"wp plugin activate woocommerce",
"wp plugin activate woocommerce-product-bundles",
"wp plugin activate woocommerce-jetpack",
"wp plugin activate jwt-authentication-for-wp-rest-api",
"wp plugin activate gravityforms",
"wp plugin activate gravityflow",
"wp plugin activate groups",
"wp plugin activate wp-user-groups",
"wp plugin activate radio-buttons-for-taxonomies",
"wp plugin activate advanced-access-manager",
"wp plugin activate advanced-custom-fields",
"wp plugin activate sendgrid-email-delivery-simplified",
"wp plugin activate wiaas"
],
"update-db": [

294
backend/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6e6e270e7e619ff0ceaa12a0f586d517",
"content-hash": "9380f64d0712c55d18f8120b57c5fe50",
"packages": [
{
"name": "3rdparty/gravityflow",
@@ -285,101 +285,6 @@
],
"time": "2018-01-29T14:49:29+00:00"
},
{
"name": "markbaker/complex",
"version": "1.4.7",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
"shasum": ""
},
"require": {
"php": "^5.6.0|^7.0.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"phpcompatibility/php-compatibility": "^8.0",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "2.*",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^4.8.35|^5.4.0",
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "^3.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
},
"files": [
"classes/src/functions/abs.php",
"classes/src/functions/acos.php",
"classes/src/functions/acosh.php",
"classes/src/functions/acot.php",
"classes/src/functions/acoth.php",
"classes/src/functions/acsc.php",
"classes/src/functions/acsch.php",
"classes/src/functions/argument.php",
"classes/src/functions/asec.php",
"classes/src/functions/asech.php",
"classes/src/functions/asin.php",
"classes/src/functions/asinh.php",
"classes/src/functions/atan.php",
"classes/src/functions/atanh.php",
"classes/src/functions/conjugate.php",
"classes/src/functions/cos.php",
"classes/src/functions/cosh.php",
"classes/src/functions/cot.php",
"classes/src/functions/coth.php",
"classes/src/functions/csc.php",
"classes/src/functions/csch.php",
"classes/src/functions/exp.php",
"classes/src/functions/inverse.php",
"classes/src/functions/ln.php",
"classes/src/functions/log2.php",
"classes/src/functions/log10.php",
"classes/src/functions/negative.php",
"classes/src/functions/pow.php",
"classes/src/functions/rho.php",
"classes/src/functions/sec.php",
"classes/src/functions/sech.php",
"classes/src/functions/sin.php",
"classes/src/functions/sinh.php",
"classes/src/functions/sqrt.php",
"classes/src/functions/tan.php",
"classes/src/functions/tanh.php",
"classes/src/functions/theta.php",
"classes/src/operations/add.php",
"classes/src/operations/subtract.php",
"classes/src/operations/multiply.php",
"classes/src/operations/divideby.php",
"classes/src/operations/divideinto.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"time": "2018-10-13T23:28:42+00:00"
},
{
"name": "oscarotero/env",
"version": "v1.1.0",
@@ -422,141 +327,6 @@
],
"time": "2017-07-17T20:41:59+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "2dfd06c59825914a1a325f2a2ed13634b9d8c411"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/2dfd06c59825914a1a325f2a2ed13634b9d8c411",
"reference": "2dfd06c59825914a1a325f2a2ed13634b9d8c411",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"markbaker/complex": "^1.4.1",
"php": "^5.6|^7.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"dompdf/dompdf": "^0.8.0",
"friendsofphp/php-cs-fixer": "@stable",
"jpgraph/jpgraph": "^4.0",
"mpdf/mpdf": "^7.0.0",
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.3",
"tecnickcom/tcpdf": "^6.2"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "http://blog.maartenballiauw.be"
},
{
"name": "Erik Tilt"
},
{
"name": "Franck Lefevre",
"homepage": "http://rootslabs.net"
},
{
"name": "Mark Baker",
"homepage": "http://markbakeruk.net"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"time": "2018-10-21T10:04:54+00:00"
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "roots/wp-password-bcrypt",
"version": "1.0.0",
@@ -616,16 +386,16 @@
},
{
"name": "woocommerce/woocommerce",
"version": "3.5.0",
"version": "3.4.4",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce.git",
"reference": "703ae4d26d035d77dd9dd7bda797f03f7c0bf9d2"
"reference": "322ba60a76a553e759c81ddc09a1b9efc1e6b4ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce/zipball/703ae4d26d035d77dd9dd7bda797f03f7c0bf9d2",
"reference": "703ae4d26d035d77dd9dd7bda797f03f7c0bf9d2",
"url": "https://api.github.com/repos/woocommerce/woocommerce/zipball/322ba60a76a553e759c81ddc09a1b9efc1e6b4ef",
"reference": "322ba60a76a553e759c81ddc09a1b9efc1e6b4ef",
"shasum": ""
},
"require": {
@@ -656,7 +426,7 @@
],
"description": "An eCommerce toolkit that helps you sell anything. Beautifully.",
"homepage": "https://woocommerce.com/",
"time": "2018-10-23T16:14:13+00:00"
"time": "2018-07-25T18:00:37+00:00"
},
{
"name": "wpackagist-plugin/advanced-access-manager",
@@ -698,6 +468,26 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/advanced-custom-fields/"
},
{
"name": "wpackagist-plugin/akismet",
"version": "4.0.3",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/akismet/",
"reference": "tags/4.0.3"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/akismet.4.0.3.zip",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/akismet/"
},
{
"name": "wpackagist-plugin/groups",
"version": "2.3.1",
@@ -738,6 +528,26 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/"
},
{
"name": "wpackagist-plugin/mailchimp-for-woocommerce",
"version": "2.1.7",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/mailchimp-for-woocommerce/",
"reference": "tags/2.1.7"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/mailchimp-for-woocommerce.2.1.7.zip",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/mailchimp-for-woocommerce/"
},
{
"name": "wpackagist-plugin/radio-buttons-for-taxonomies",
"version": "1.8.3",
@@ -759,16 +569,16 @@
"homepage": "https://wordpress.org/plugins/radio-buttons-for-taxonomies/"
},
{
"name": "wpackagist-plugin/sendgrid-email-delivery-simplified",
"version": "1.11.8",
"name": "wpackagist-plugin/woocommerce-jetpack",
"version": "3.7.0",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/sendgrid-email-delivery-simplified/",
"reference": "tags/1.11.8"
"url": "https://plugins.svn.wordpress.org/woocommerce-jetpack/",
"reference": "trunk"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/sendgrid-email-delivery-simplified.1.11.8.zip",
"url": "https://downloads.wordpress.org/plugin/woocommerce-jetpack.zip?timestamp=1529631506",
"reference": null,
"shasum": null
},
@@ -776,7 +586,7 @@
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/sendgrid-email-delivery-simplified/"
"homepage": "https://wordpress.org/plugins/woocommerce-jetpack/"
},
{
"name": "wpackagist-plugin/wp-user-groups",

View File

@@ -20,7 +20,7 @@ define('WP_ENV', env('WP_ENV') ?: 'development');
$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';
if (file_exists($env_config)) {
require_once $env_config;
require_once $env_config;
}
/**
@@ -63,15 +63,6 @@ define('NONCE_SALT', env('WP_NONCE_SALT'));
define('JWT_AUTH_SECRET_KEY', env('WP_JWT_AUTH_SECRET_KEY'));
define('JWT_AUTH_CORS_ENABLE', true);
/**
* Emails
*
*/
define('SENDGRID_API_KEY', env('WP_SENDGRID_API_KEY'));
define('SENDGRID_FROM_EMAIL', env('WP_SENDGRID_FROM_EMAIL') ?: 'info@wiaas.com');
define('SENDGRID_FROM_NAME', env('WP_SENDGRID_FROM_NAME' ?: 'Wiaas'));
/**
* Wiaas Env variables
*/
@@ -88,5 +79,5 @@ define('DISALLOW_FILE_EDIT', true);
* Bootstrap WordPress
*/
if (!defined('ABSPATH')) {
define('ABSPATH', $webroot_dir . '/wp/');
define('ABSPATH', $webroot_dir . '/wp/');
}

View File

@@ -1,8 +1,16 @@
<?php
/** Development */
define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
define('DISABLE_WP_CRON', true);
ini_set('display_errors',0);
ini_set('error_reporting', 0 );
/**
* Use Dotenv to set required environment variables and load .local.env file

View File

@@ -1,10 +1,14 @@
<?php
/** Development */
ini_set('display_errors', 0);
define('SAVEQUERIES', true);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
/** Disable all file modifications including updates and update notifications */
define('DISALLOW_FILE_MODS', true);
ini_set('display_errors',EP_NONE);
ini_set('error_reporting', EP_NONE );
/**
* Stops redirect loop on login page

View File

@@ -1,8 +1,18 @@
<?php
/** Development */
define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);
define('SAVEQUERIES', false);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
ini_set('display_errors',0);
ini_set('error_reporting', 0 );
/** Disable all file modifications including updates and update notifications */
define('DISALLOW_FILE_MODS', true);
/**
* Use Dotenv to set required environment variables and load .local.env file

View File

@@ -6,4 +6,8 @@
*/
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/config/application.php');
global $wp_timer;
$wp_timer = microtime();
require_once(ABSPATH . 'wp-settings.php');

File diff suppressed because one or more lines are too long

View File

@@ -21,12 +21,9 @@ services:
- WP_LOGGED_IN_SALT
- WP_NONCE_SALT
- WP_JWT_AUTH_SECRET_KEY
- WP_SENDGRID_API_KEY
- WP_SENDGRID_FROM_EMAIL
- WP_SENDGRID_FROM_NAME
volumes:
- ./log/backend/:/var/log/apache2/
- ./docker/backend/uploads/:/var/www/html/app/uploads/
restart: always
ports:
- '8081:80'
depends_on:
@@ -43,6 +40,7 @@ services:
- API_URL
volumes:
- ./log/frontend/:/var/log/apache2/
restart: always
ports:
- '8080:80'
@@ -57,6 +55,7 @@ services:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
restart: always
ports:
- '23306:3306'
volumes:

View File

@@ -1 +0,0 @@
uploads/

Binary file not shown.

View File

@@ -25,10 +25,10 @@
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
LogLevel emerg
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog /dev/null combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to

View File

@@ -15,6 +15,8 @@
Options FollowSymLinks Indexes
AllowOverride None
Header always set Access-Control-Max-Age "86400"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
@@ -35,7 +37,6 @@
LogLevel emerg
ErrorLog ${APACHE_LOG_DIR}/error.log
# Do not log every request
CustomLog /dev/null combined
# For most configuration files from conf-available/, which are

Some files were not shown because too many files have changed in this diff Show More