Handle assigment for order delivery flow
This commit is contained in:
@@ -2,9 +2,13 @@ jQuery(document).bind('gform_load_field_settings', function (event, field, form)
|
||||
|
||||
var isBundleDoc = field.type === 'wiaas_order_bundle_document';
|
||||
|
||||
if (isBundleDoc) {
|
||||
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);
|
||||
|
||||
});
|
||||
@@ -7,205 +7,389 @@ class Wiaas_Admin_Delivery_Process {
|
||||
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('add_meta_boxes', array(__CLASS__, 'add_delivery_process_metabox'), 100);
|
||||
|
||||
add_action( 'wp_ajax_wiaas_create_order_delivery_process', array(__CLASS__, 'wiaas_ajax_create_order_delivery_process') );
|
||||
|
||||
add_filter('gravityflow_admin_actions_workflow_detail', array (__CLASS__, 'filter_process_send_to_step_options'), 10, 5);
|
||||
}
|
||||
|
||||
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 filter_process_send_to_step_options($admin_actions, $current_step, $steps, $form, $entry) {
|
||||
|
||||
$delivery_process_actions = array();
|
||||
|
||||
if ( $current_step ) {
|
||||
|
||||
$previous_step_id = null;
|
||||
// get previous step id for current step
|
||||
foreach ($steps as $index => $step) {
|
||||
|
||||
$next_step = gravity_flow()->get_next_step($step, $entry, $form);
|
||||
|
||||
if ($next_step && $next_step->get_id() === $current_step->get_id()) {
|
||||
|
||||
$previous_step_id = $step->get_id();
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($previous_step_id)) {
|
||||
|
||||
$delivery_process_actions[] = array(
|
||||
'label' => esc_html__( 'Previous step', 'wiaas' ),
|
||||
'value' => 'send_to_step|' . $previous_step_id
|
||||
);
|
||||
}
|
||||
|
||||
// get next step id for current step
|
||||
$next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
|
||||
if ($next_step) {
|
||||
|
||||
$delivery_process_actions[] = array(
|
||||
'label' => esc_html__( 'Next step', 'wiaas' ),
|
||||
'value' => 'send_to_step|' . $next_step->get_id()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $delivery_process_actions;
|
||||
}
|
||||
|
||||
|
||||
public static function display_process_steps_details($form, $entry, $current_step) {
|
||||
public static function wiaas_ajax_create_order_delivery_process() {
|
||||
check_ajax_referer('wiaas_create_order_delivery_process');
|
||||
|
||||
$delivery_settings = rgar($form, 'wiaas_delivery_process');
|
||||
$error = new WP_Error('-1', 'Failed to create order delivery process');
|
||||
|
||||
if ($delivery_settings['delivery_form_type'] === 'action') {
|
||||
return;
|
||||
}
|
||||
if (!isset($_POST['order']) || !isset($_POST['form'])){
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
// get process order ID
|
||||
$order_id = absint($entry['wiaas_delivery_order_id']);
|
||||
$order_id = intval( $_POST['order'] );
|
||||
$form_id = intval( $_POST['form'] );
|
||||
|
||||
if (empty($order_id)) {
|
||||
if ($process_entry_id = Wiaas_Delivery_Process::create_delivery_process_for_order($order_id, $form_id)){
|
||||
|
||||
$order_field = GFCommon::get_fields_by_type($form, array( 'wiaas_order') )[0];
|
||||
$workflow = new Gravity_Flow_API($form_id);
|
||||
|
||||
if ( ! empty($order_field)) {
|
||||
$step = $workflow->get_current_step(GFAPI::get_entry($process_entry_id));
|
||||
|
||||
$order_id = $entry[$order_field->id];
|
||||
}
|
||||
}
|
||||
$entry_url = $step->get_entry_url();
|
||||
|
||||
// display process steps
|
||||
wp_send_json_success(array(
|
||||
'url' => $entry_url
|
||||
));
|
||||
}
|
||||
|
||||
$workflow_api = new Gravity_Flow_API($form['id']);
|
||||
|
||||
$steps = $workflow_api->get_steps();
|
||||
|
||||
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
|
||||
if ($is_current_step) {
|
||||
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;
|
||||
}
|
||||
|
||||
$action_delivery_settings = rgar($action_form, 'wiaas_delivery_process');
|
||||
|
||||
?>
|
||||
|
||||
<div class="submitbox" style="padding: 10px;">
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
if (! $action_delivery_settings['automatic_action_entries_enabled']) {
|
||||
|
||||
$form_url = admin_url( 'admin-ajax.php' ) .
|
||||
'?action=wiaas_delivery_get_form&order_id=' . $order_id .
|
||||
'&form_id=' . $action_form['id'] .
|
||||
'&wiaas_delivery_process_id=' . $entry['id'];
|
||||
$form_url .= '&is_admin=1';
|
||||
|
||||
$form_link = sprintf(
|
||||
'<a href="%s&TB_iframe=true&width=600&height=550" class="button button-primary thickbox">' .
|
||||
'<i class="fa fa-plus"></i> ' . $action_form['title'] . '</a>',
|
||||
$form_url );
|
||||
|
||||
echo $form_link;
|
||||
}
|
||||
|
||||
echo '<br><br><br>';
|
||||
|
||||
$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, $search_criteria, $sorting, $paging );
|
||||
|
||||
foreach ($entries as $action_entry) {
|
||||
self::_display_step_action_entry($action_form, $action_entry);
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_thickbox();
|
||||
}
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
|
||||
public static function order_delivery_process_meta_box() {
|
||||
|
||||
private static function _display_step_action_entry($action_form, $action_entry) {
|
||||
$workflow_api = new Gravity_Flow_API($action_entry['form_id']);
|
||||
global $post;
|
||||
|
||||
$current_action_step = $workflow_api->get_current_step($action_entry);
|
||||
$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())
|
||||
);
|
||||
|
||||
?>
|
||||
<table>
|
||||
|
||||
<?php
|
||||
foreach ($action_form['fields'] as $field) {
|
||||
|
||||
if ($field->type === 'wiaas_order') {
|
||||
continue;
|
||||
<div>
|
||||
<select id="delivery-process-selector" 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>
|
||||
|
||||
if ($field->type === 'workflow_discussion') {
|
||||
<a id="assign_delivery_process" class="button" style="margin-top: 10px;">Assign</a>
|
||||
</div>
|
||||
|
||||
echo '<tr style="padding: 20px;"><td colspan="2">' . $field->format_discussion_value($action_entry[$field->id]) . '</td></tr>';
|
||||
<script type="text/javascript" >
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
continue;
|
||||
}
|
||||
$('#assign_delivery_process').click(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
$value = $field->get_value_entry_detail($action_entry[$field->id]);
|
||||
$label = $field->get_field_label(false, $action_entry[$field->id]);
|
||||
var data = {
|
||||
action: 'wiaas_create_order_delivery_process',
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_create_order_delivery_process" ) ?>',
|
||||
order: '<?php echo $order_id ?>',
|
||||
form: $('#delivery-process-selector').val()
|
||||
|
||||
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
|
||||
if (! empty($current_action_step)) {
|
||||
echo $current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();
|
||||
echo '<a target="_blank" href="' . $current_action_step->get_entry_url() . '">' .
|
||||
' <i class="fa fa-external-link" style="font-size: 16px;"></i>' .
|
||||
'</a>';
|
||||
|
||||
} else {
|
||||
echo $workflow_api->get_status($action_entry);
|
||||
// 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);
|
||||
}
|
||||
?>
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<?php
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
?>
|
||||
</table>
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
<?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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
if ($is_current_step) {
|
||||
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;
|
||||
}
|
||||
|
||||
$action_delivery_settings = rgar($action_form, 'wiaas_delivery_process');
|
||||
|
||||
?>
|
||||
|
||||
<div class="submitbox" style="padding: 10px;">
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
if (! $action_delivery_settings['automatic_action_entries_enabled']) {
|
||||
|
||||
$form_url = admin_url( 'admin-ajax.php' ) .
|
||||
'?action=wiaas_delivery_get_form&order_id=' . $order_id .
|
||||
'&form_id=' . $action_form['id'] .
|
||||
'&wiaas_delivery_process_id=' . $entry['id'];
|
||||
$form_url .= '&is_admin=1';
|
||||
|
||||
$form_link = sprintf(
|
||||
'<a href="%s&TB_iframe=true&width=600&height=550" class="button button-primary thickbox">' .
|
||||
'<i class="fa fa-plus"></i> ' . $action_form['title'] . '</a>',
|
||||
$form_url );
|
||||
|
||||
echo $form_link;
|
||||
}
|
||||
|
||||
echo '<br><br><br>';
|
||||
|
||||
$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, $search_criteria, $sorting, $paging );
|
||||
|
||||
foreach ($entries as $action_entry) {
|
||||
self::_display_step_action_entry($action_form, $action_entry);
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_thickbox();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
?>
|
||||
<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
|
||||
if (! empty($current_action_step)) {
|
||||
echo $current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();
|
||||
echo '<a target="_blank" href="' . $current_action_step->get_entry_url() . '">' .
|
||||
' <i class="fa fa-external-link" style="font-size: 16px;"></i>' .
|
||||
'</a>';
|
||||
|
||||
} else {
|
||||
echo $workflow_api->get_status($action_entry);
|
||||
}
|
||||
?>
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
?>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
Wiaas_Admin_Delivery_Process::init();
|
||||
|
||||
@@ -77,14 +77,6 @@ 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();
|
||||
@@ -93,10 +85,11 @@ class Wiass_REST_Delivery_Process_API {
|
||||
|
||||
$form_ids = gravity_flow()->get_workflow_form_ids();
|
||||
|
||||
$total_count = 7;
|
||||
|
||||
|
||||
$entries = GFAPI::get_entries( $form_ids, $search_criteria, null, null, $total_count );
|
||||
$entries = GFAPI::get_entries(
|
||||
$form_ids,
|
||||
$search_criteria,
|
||||
null,
|
||||
null);
|
||||
|
||||
$data = array();
|
||||
foreach ($entries as $entry) {
|
||||
@@ -167,6 +160,7 @@ class Wiass_REST_Delivery_Process_API {
|
||||
if ($installation_declined){
|
||||
return wiaas_api_notice('INSTALLATION_DECLINED', 'success');
|
||||
}
|
||||
|
||||
return wiaas_api_notice('INSTALLATION_ACCEPTED', 'success');
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,19 @@ 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
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,8 @@ class Wiaas_DB_Update {
|
||||
'20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields',
|
||||
'20181019064450' => 'wiaas_db_update_add_bundle_properties_ui_field',
|
||||
'20191020014650' => 'wiaas_create_organization_roles_capabilities',
|
||||
'20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities'
|
||||
'20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities',
|
||||
'20191031162450' => 'update_delivery_forms'
|
||||
);
|
||||
|
||||
public static function execute() {
|
||||
|
||||
@@ -27,24 +27,58 @@ class Wiaas_Delivery_Process {
|
||||
*
|
||||
*/
|
||||
private static function _register_delivery_process() {
|
||||
require_once( 'delivery-process/class-wiaas-delivery-process-step.php' );
|
||||
|
||||
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' );
|
||||
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-select.php' );
|
||||
require_once( 'delivery-process/class-wiaas-field-order-supplier-select.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' );
|
||||
|
||||
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);
|
||||
|
||||
return $process_entry_id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe complete parent order for completed delivery process
|
||||
* @param $entry_id
|
||||
@@ -147,7 +181,7 @@ class Wiaas_Delivery_Process {
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function update_customer_acceptance_status($order_id,$status, $reason) {
|
||||
public static function update_customer_acceptance_status($order_id, $status, $reason) {
|
||||
|
||||
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
|
||||
|
||||
@@ -228,10 +262,12 @@ class Wiaas_Delivery_Process {
|
||||
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 (!isset($process_entry_id)) {
|
||||
return array();
|
||||
if (empty($process_entry_id)) {
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
return GFAPI::get_entry($process_entry_id);
|
||||
@@ -246,7 +282,7 @@ class Wiaas_Delivery_Process {
|
||||
*/
|
||||
public static function get_order_delivery_process($order_id) {
|
||||
|
||||
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id');
|
||||
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
|
||||
|
||||
if (empty($process_entry_id)) {
|
||||
return null;
|
||||
@@ -263,7 +299,22 @@ class Wiaas_Delivery_Process {
|
||||
$delivery_process = array(
|
||||
'id' => $process_form['id'],
|
||||
'name' => $process_form['title'],
|
||||
'steps' => array()
|
||||
'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,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$current_step = $api->get_current_step($process_instance);
|
||||
@@ -302,37 +353,3 @@ class Wiaas_Delivery_Process {
|
||||
}
|
||||
|
||||
add_action( 'gravityflow_loaded', array('Wiaas_Delivery_Process', 'init') );
|
||||
|
||||
|
||||
add_filter( 'gform_notification', 'rw_notification_attachments', 10, 3 );
|
||||
function rw_notification_attachments( $notification, $form, $entry ) {
|
||||
|
||||
$fileupload_fields = GFAPI::get_fields_by_type( $form, array( 'fileupload' ) , true);
|
||||
|
||||
if ( ! is_array( $fileupload_fields ) ) {
|
||||
return $notification;
|
||||
}
|
||||
|
||||
$notification['attachments'] = rgar( $notification, 'attachments', array() );
|
||||
$upload_root = RGFormsModel::get_upload_root();
|
||||
|
||||
foreach( $fileupload_fields as $field ) {
|
||||
|
||||
$url = rgar( $entry, $field->id );
|
||||
|
||||
if ( empty( $url ) ) {
|
||||
continue;
|
||||
} elseif ( $field->multipleFiles ) {
|
||||
$uploaded_files = json_decode( stripslashes( $url ), true );
|
||||
foreach ( $uploaded_files as $uploaded_file ) {
|
||||
$attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file );
|
||||
$notification['attachments'][] = $attachment;
|
||||
}
|
||||
} else {
|
||||
$attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );
|
||||
$notification['attachments'][] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,425 +0,0 @@
|
||||
{
|
||||
"0": {
|
||||
"title": "DELIVERY PROCESS: Normal Delivery",
|
||||
"description": "Normal delivery process",
|
||||
"labelPlacement": "top_label",
|
||||
"descriptionPlacement": "below",
|
||||
"button": {
|
||||
"type": "text",
|
||||
"text": "Submit",
|
||||
"imageUrl": ""
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
"type": "wiaas_order",
|
||||
"id": 3,
|
||||
"label": "Order",
|
||||
"adminLabel": "",
|
||||
"isRequired": false,
|
||||
"size": "medium",
|
||||
"errorMessage": "",
|
||||
"visibility": "visible",
|
||||
"inputs": null,
|
||||
"formId": 5,
|
||||
"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": 5,
|
||||
"useCurrentUserAsAuthor": true,
|
||||
"postContentTemplateEnabled": false,
|
||||
"postTitleTemplateEnabled": false,
|
||||
"postTitleTemplate": "",
|
||||
"postContentTemplate": "",
|
||||
"lastPageButton": null,
|
||||
"pagination": null,
|
||||
"firstPageCssClass": null,
|
||||
"is_active": "1",
|
||||
"date_created": "2018-10-24 18:12:10",
|
||||
"is_trash": "0",
|
||||
"notifications": [
|
||||
{
|
||||
"id": "5b5f7ae4baced",
|
||||
"to": "{admin_email}",
|
||||
"name": "Admin Notification",
|
||||
"event": "form_submission",
|
||||
"toType": "email",
|
||||
"subject": "New submission from {form_title}",
|
||||
"message": "{all_fields}",
|
||||
"isActive": false
|
||||
}
|
||||
],
|
||||
"confirmations": [
|
||||
{
|
||||
"id": "5b5f7ae4bb79e",
|
||||
"name": "Default Confirmation",
|
||||
"isDefault": true,
|
||||
"type": "message",
|
||||
"message": "Thanks for contacting us! We will get in touch with you shortly.",
|
||||
"url": "",
|
||||
"pageId": "",
|
||||
"queryString": ""
|
||||
}
|
||||
],
|
||||
"wiaas_delivery_process": {
|
||||
"delivery_form_type": "process",
|
||||
"delivery_action_code": "",
|
||||
"automatic_action_entries_enabled": "0",
|
||||
"automatic_action_entries_type": "single"
|
||||
},
|
||||
"feeds": {
|
||||
"gravityflow": [
|
||||
{
|
||||
"id": "7",
|
||||
"form_id": "5",
|
||||
"is_active": "1",
|
||||
"feed_order": "0",
|
||||
"meta": {
|
||||
"step_name": "Validate customer configuration information",
|
||||
"description": "Review configuration documents uploaded by customer during order creation process.\r\nApprove or reject each document.",
|
||||
"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": "1",
|
||||
"instructionsValue": "Review configuration documents uploaded by customer during order creation process.\u00a0 Approve or reject each document.",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "12",
|
||||
"destination_complete": "next"
|
||||
},
|
||||
"addon_slug": "gravityflow",
|
||||
"event_type": null
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"form_id": "5",
|
||||
"is_active": "1",
|
||||
"feed_order": "0",
|
||||
"meta": {
|
||||
"step_name": "Procure components",
|
||||
"description": "",
|
||||
"step_type": "wiaas_delivery_step",
|
||||
"step_highlight": "0",
|
||||
"step_highlight_type": "color",
|
||||
"step_highlight_color": "#c7e8d6",
|
||||
"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": "0",
|
||||
"target_form_id": "11",
|
||||
"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": "",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "",
|
||||
"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": "",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "14",
|
||||
"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",
|
||||
"instructionsEnable": "0",
|
||||
"instructionsValue": "",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "16",
|
||||
"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": "",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "",
|
||||
"destination_complete": "next"
|
||||
},
|
||||
"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": "",
|
||||
"is_visible_to_customer": "1",
|
||||
"target_form_id": "",
|
||||
"destination_complete": "next"
|
||||
},
|
||||
"addon_slug": "gravityflow",
|
||||
"event_type": null
|
||||
},
|
||||
{
|
||||
"id": "36",
|
||||
"form_id": "5",
|
||||
"is_active": "1",
|
||||
"feed_order": "0",
|
||||
"meta": {
|
||||
"step_name": "Complete delivery",
|
||||
"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": "role|administrator",
|
||||
"fieldId": "0",
|
||||
"operator": "is",
|
||||
"value": "",
|
||||
"type": ""
|
||||
}
|
||||
],
|
||||
"assignee_policy": "all",
|
||||
"instructionsEnable": "0",
|
||||
"instructionsValue": "Instructions: please review the values in the fields below and click on the Approve or Reject button",
|
||||
"display_fields_mode": "all_fields",
|
||||
"assignee_notification_enabled": "0",
|
||||
"assignee_notification_from_name": "",
|
||||
"assignee_notification_from_email": "{admin_email}",
|
||||
"assignee_notification_reply_to": "",
|
||||
"assignee_notification_bcc": "",
|
||||
"assignee_notification_subject": "",
|
||||
"assignee_notification_message": "A new entry is pending your approval. Please check your Workflow Inbox.",
|
||||
"assignee_notification_disable_autoformat": "0",
|
||||
"resend_assignee_emailEnable": "0",
|
||||
"resend_assignee_emailValue": "7",
|
||||
"resend_assignee_email_repeatEnable": "0",
|
||||
"resend_assignee_email_repeatValue": "3",
|
||||
"rejection_notification_enabled": "0",
|
||||
"rejection_notification_type": "select",
|
||||
"rejection_notification_routing": [
|
||||
{
|
||||
"assignee": "role|administrator",
|
||||
"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": "role|administrator",
|
||||
"fieldId": "0",
|
||||
"operator": "is",
|
||||
"value": "",
|
||||
"type": ""
|
||||
}
|
||||
],
|
||||
"approval_notification_from_name": "",
|
||||
"approval_notification_from_email": "{admin_email}",
|
||||
"approval_notification_reply_to": "",
|
||||
"approval_notification_bcc": "",
|
||||
"approval_notification_subject": "",
|
||||
"approval_notification_message": "Entry {entry_id} has been approved",
|
||||
"approval_notification_disable_autoformat": "0",
|
||||
"note_mode": "not_required",
|
||||
"expiration": "0",
|
||||
"expiration_type": "delay",
|
||||
"expiration_date": "",
|
||||
"expiration_delay_offset": "",
|
||||
"expiration_delay_unit": "hours",
|
||||
"expiration_date_field_offset": "0",
|
||||
"expiration_date_field_offset_unit": "hours",
|
||||
"expiration_date_field_before_after": "after",
|
||||
"status_expiration": "rejected",
|
||||
"destination_expired": "next",
|
||||
"destination_rejected": "complete",
|
||||
"destination_approved": "next"
|
||||
},
|
||||
"addon_slug": "gravityflow",
|
||||
"event_type": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": "2.3.2"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -79,7 +79,7 @@ function wiaas_create_organization_roles_capabilities() {
|
||||
}
|
||||
|
||||
|
||||
function import_delivery_action_forms() {
|
||||
function update_delivery_forms() {
|
||||
|
||||
$forms = GFAPI::get_forms();
|
||||
|
||||
@@ -89,5 +89,5 @@ function import_delivery_action_forms() {
|
||||
|
||||
GFExport::import_file(dirname( __FILE__ ) . "/data/delivery-forms/delivery-action-forms.json");
|
||||
|
||||
//GFExport::import_file(dirname( __FILE__ ) . "/data/delivery-forms/delivery-process-normal-delivery-form.json");
|
||||
GFExport::import_file(dirname( __FILE__ ) . "/data/delivery-forms/delivery-process-sample-form.json");
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
<?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');
|
||||
@@ -9,6 +19,13 @@ class Wiaas_Delivery_Process_Action {
|
||||
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)) {
|
||||
@@ -16,11 +33,18 @@ class Wiaas_Delivery_Process_Action {
|
||||
return null;
|
||||
}
|
||||
|
||||
$action_form = GFAPI::get_form($step->target_form_id);
|
||||
|
||||
return $action_form;
|
||||
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);
|
||||
@@ -35,16 +59,35 @@ class Wiaas_Delivery_Process_Action {
|
||||
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);
|
||||
@@ -67,6 +110,11 @@ class Wiaas_Delivery_Process_Action {
|
||||
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();
|
||||
@@ -86,9 +134,14 @@ class Wiaas_Delivery_Process_Action {
|
||||
return $action_forms;
|
||||
}
|
||||
|
||||
public static function complete_action_step($action_id) {
|
||||
/**
|
||||
* 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_id);
|
||||
$action_entry = GFAPI::get_entry($action_entry_id);
|
||||
|
||||
$action_form = GFAPI::get_form($action_entry['form_id']);
|
||||
|
||||
@@ -111,6 +164,11 @@ class Wiaas_Delivery_Process_Action {
|
||||
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);
|
||||
@@ -125,56 +183,34 @@ class Wiaas_Delivery_Process_Action {
|
||||
GFAPI::update_entry($action_entry);
|
||||
}
|
||||
|
||||
public static function get_customer_acceptance_action_data($action_id) {
|
||||
|
||||
$action_entry = GFAPI::get_entry($action_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, 'fileupload')[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'],
|
||||
'url' => $acceptance_documents_field->get_download_url( $file_path, true )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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' => ($action_entry[$acceptance_field->id] === 'accept') ? 1 : -1
|
||||
);
|
||||
}
|
||||
|
||||
public static function is_customer_acceptance_uploaded($action_id) {
|
||||
|
||||
$action_entry = GFAPI::get_entry($action_id);
|
||||
$action_form = GFAPI::get_form($action_entry['form_id']);
|
||||
|
||||
|
||||
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'fileupload')[0];
|
||||
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_document')[0];
|
||||
|
||||
return ! empty( $action_entry[$acceptance_documents_field->id]);
|
||||
}
|
||||
|
||||
public static function update_customer_acceptance_status($action_id, $new_status, $reason) {
|
||||
/**
|
||||
* 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_id);
|
||||
$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];
|
||||
@@ -184,14 +220,28 @@ class Wiaas_Delivery_Process_Action {
|
||||
$action_entry[$decline_reason_field->id] = $reason;
|
||||
|
||||
GFAPI::update_entry($action_entry);
|
||||
|
||||
$workflow = new Gravity_Flow_API($action_form['id']);
|
||||
$current_step = $workflow->get_current_step($action_entry);
|
||||
|
||||
if ($current_step && $current_step->get_t)
|
||||
|
||||
Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']);
|
||||
}
|
||||
|
||||
public static function upload_customer_acceptance_document($action_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_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, 'fileupload')[0];
|
||||
$acceptance_documents_field = GFCommon::get_fields_by_type($action_form, 'wiaas_order_document')[0];
|
||||
|
||||
$old_value = $action_entry[$acceptance_documents_field->id];
|
||||
|
||||
@@ -220,9 +270,69 @@ class Wiaas_Delivery_Process_Action {
|
||||
return ! is_wp_error($result);
|
||||
}
|
||||
|
||||
public static function get_customer_validate_questionnaires_action_data($action_id) {
|
||||
/**
|
||||
* 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_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]);
|
||||
|
||||
error_log($action_entry[$acceptance_documents_field->id]);
|
||||
|
||||
$documents = array();
|
||||
|
||||
foreach ($file_paths as $file_path) {
|
||||
|
||||
$info = pathinfo( $file_path );
|
||||
|
||||
$documents[] = array(
|
||||
'name' => $info['basename'],
|
||||
'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']);
|
||||
|
||||
@@ -240,9 +350,8 @@ class Wiaas_Delivery_Process_Action {
|
||||
|
||||
return null;
|
||||
}
|
||||
$bundle_item = $order->get_item($bundle_item_id);
|
||||
|
||||
$document_field = GFCommon::get_fields_by_type(GFAPI::get_form($action_entry['form_id']), 'wiaas_order_bundle_document')[0];
|
||||
$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] );
|
||||
@@ -260,25 +369,29 @@ class Wiaas_Delivery_Process_Action {
|
||||
if (is_array($discussion_items)) {
|
||||
foreach ($discussion_items as $item) {
|
||||
|
||||
$formated_comments[] = $discussion_field->format_discussion_item( $item, 'text', $action_id );
|
||||
$formated_comments[] = $discussion_field->format_discussion_item( $item, 'text', $action_entry_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$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)) {
|
||||
|
||||
if ($action_step->get_type() === 'approval') {
|
||||
|
||||
$status = 'not-validated';
|
||||
}
|
||||
|
||||
if ($action_step->get_type() === 'user_input') {
|
||||
$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';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,18 +32,17 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
|
||||
|
||||
add_filter('gravityflow_assignee_choices', array ($this, 'add_orders_assignee_choices'));
|
||||
|
||||
add_filter('gravityflow_admin_actions_workflow_detail', array ($this, 'filter_process_send_to_step_options'), 10, 5);
|
||||
|
||||
add_filter('gravityflow_step_assignees', array ($this, 'maybe_assign_organization_to_step'), 10, 2);
|
||||
}
|
||||
|
||||
public function init_ajax() {
|
||||
parent::init_ajax();
|
||||
|
||||
// this AJAX action is here and not in /admin folder because of Gravity Forms extension logic
|
||||
add_action( 'wp_ajax_wiaas_delivery_get_form', array( $this, 'ajax_get_form' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle organization assignee for step (Map users from organization as assignees to step)
|
||||
*
|
||||
* @param $assignees
|
||||
* @param Gravity_Flow_Step $step
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function maybe_assign_organization_to_step($assignees, Gravity_Flow_Step $step) {
|
||||
|
||||
$mapped_assignees = array();
|
||||
@@ -78,46 +77,6 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
|
||||
return $mapped_assignees;
|
||||
}
|
||||
|
||||
public function filter_process_send_to_step_options($admin_actions, $current_step, $steps, $form, $entry) {
|
||||
|
||||
$delivery_process_actions = array();
|
||||
|
||||
if ( $current_step ) {
|
||||
|
||||
$previous_step_id = null;
|
||||
// get previous step id for current step
|
||||
foreach ($steps as $index => $step) {
|
||||
|
||||
$next_step = gravity_flow()->get_next_step($step, $entry, $form);
|
||||
|
||||
if ($next_step && $next_step->get_id() === $current_step->get_id()) {
|
||||
|
||||
$previous_step_id = $step->get_id();
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($previous_step_id)) {
|
||||
|
||||
$delivery_process_actions[] = array(
|
||||
'label' => esc_html__( 'Previous step', 'wiaas' ),
|
||||
'value' => 'send_to_step|' . $previous_step_id
|
||||
);
|
||||
}
|
||||
|
||||
// get next step id for current step
|
||||
$next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
|
||||
if ($next_step) {
|
||||
|
||||
$delivery_process_actions[] = array(
|
||||
'label' => esc_html__( 'Next step', 'wiaas' ),
|
||||
'value' => 'send_to_step|' . $next_step->get_id()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $delivery_process_actions;
|
||||
}
|
||||
|
||||
|
||||
public function allow_only_administrator_to_be_assigned_to_step($args) {
|
||||
|
||||
@@ -133,34 +92,6 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public function ajax_get_form() {
|
||||
|
||||
$form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
|
||||
|
||||
$field_id = sanitize_text_field( rgget( 'field_id' ) );
|
||||
|
||||
$entry_id = absint( rgget( 'entry_id' ) );
|
||||
|
||||
$field_values = array( $field_id => $entry_id );
|
||||
|
||||
gravity_form_enqueue_scripts( $form_id, true );
|
||||
|
||||
$is_admin = isset( $_GET['is_admin'] );
|
||||
if ( $is_admin ) {
|
||||
wp_enqueue_style( 'common', site_url() . '/wp-admin/css/common.css', array(), $this->_version );
|
||||
} else {
|
||||
wp_enqueue_style( 'common', get_stylesheet_directory_uri() . '/style.css', array(), $this->_version );
|
||||
}
|
||||
|
||||
wp_print_styles();
|
||||
wp_print_scripts();
|
||||
// Render an AJAX-enabled form.
|
||||
// https://www.gravityhelp.com/documentation/article/embedding-a-form/#function-call
|
||||
$html = gravity_form( $form_id, true, false, false, $field_values, true, 1, false );
|
||||
printf( "<div id='wiaas-delivery-process-form' style='padding:10px;'>%s</div>", $html );
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
|
||||
*
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
<?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);
|
||||
|
||||
$product_id = $item['product_id'];
|
||||
|
||||
//TODO: Get this value from order since product can get changed or deleted later
|
||||
$organization_id = Wiaas_Product_Supplier::get_supplier_organisation_id_from_product($product_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();
|
||||
@@ -27,16 +27,7 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
|
||||
$form_choices[] = array( 'label' => esc_html__( 'Select a Form', 'wiaas' ), 'value' => '' );
|
||||
foreach ( $forms as $form ) {
|
||||
|
||||
$delivery_settings = rgar($form, 'wiaas_delivery_process');
|
||||
|
||||
$code = $form['id'];
|
||||
|
||||
if (! empty($delivery_settings['delivery_action_code'])) {
|
||||
|
||||
$code = $delivery_settings['delivery_action_code'];
|
||||
}
|
||||
|
||||
$form_choices[] = array( 'label' => $form['title'], 'value' => $code );
|
||||
$form_choices[] = array( 'label' => $form['title'], 'value' => $form['id'] );
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
@@ -215,26 +206,12 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
|
||||
|
||||
/**
|
||||
* Retrieves forms that are valid options for delivery step action
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_action_forms_choices() {
|
||||
|
||||
$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;
|
||||
return Wiaas_Delivery_Process_Action::get_action_forms();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class Wiaas_Field_Order_Bundle_Document extends GF_Field_FileUpload {
|
||||
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',
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ( ! class_exists( 'GFForms' ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
class Wiaas_Field_Order_Bundle_Select extends GF_Field_Select {
|
||||
|
||||
|
||||
public $type = 'wiaas_order_bundle';
|
||||
|
||||
|
||||
public function get_form_editor_field_title() {
|
||||
return esc_attr__( 'Bundle Select', 'wiaas' );
|
||||
}
|
||||
|
||||
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
|
||||
return $this->get_selected_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_selected_bundle_display_name($value);
|
||||
}
|
||||
|
||||
|
||||
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
|
||||
return $this->get_selected_bundle_display_name($value);
|
||||
}
|
||||
|
||||
// public function get_field_input( $form, $value = '', $entry = null ) {
|
||||
//
|
||||
// $this->choices = array();
|
||||
//
|
||||
// $order_id = null;
|
||||
//
|
||||
// if (! empty($entry)) {
|
||||
//
|
||||
// $order_field = GFCommon::get_fields_by_type($form, array( 'wiaas_order' ) )[0];
|
||||
//
|
||||
// $order_id = ! empty($order_field) ? $entry[$order_field->id] : null;
|
||||
//
|
||||
// } else if( ! empty($value)) {
|
||||
//
|
||||
// list ($order_id, $item_id) = explode('|', $value);
|
||||
// } else {
|
||||
//
|
||||
// $order_id = absint(rgget('order_id'));
|
||||
// }
|
||||
//
|
||||
// if (! empty($order_id)) {
|
||||
//
|
||||
// $this->choices = $this->get_selected_bundle_display_name($order_id);
|
||||
// }
|
||||
//
|
||||
// return parent::get_field_input( $form, $value, $entry );
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Adds bundles as choices
|
||||
*/
|
||||
public function post_convert_field() {
|
||||
|
||||
if ($this->is_form_editor()) {
|
||||
|
||||
$this->choices = array();
|
||||
}
|
||||
|
||||
if ( ! $this->is_form_editor() && ! empty( rgget('order_id') )) {
|
||||
$this->choices = $this->get_bundles_as_choices(absint(rgget('order_id')));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_selected_bundle_display_name($value) {
|
||||
|
||||
list ($order_id, $item_id) = explode('|', $value);
|
||||
|
||||
if (! empty($order_id) && ! empty($item_id) && $order = wc_get_order($order_id)) {
|
||||
|
||||
$item = $order->get_item($item_id);
|
||||
|
||||
return $item->get_name();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function get_bundles_as_choices($order_id) {
|
||||
|
||||
$choices = array();
|
||||
|
||||
if (! empty ($order_id) && $order = wc_get_order($order_id)) {
|
||||
|
||||
$standard_bundle_items = wiaas_get_order_standard_bundle_items($order);
|
||||
|
||||
foreach ($standard_bundle_items as $item) {
|
||||
|
||||
$choices[] = array(
|
||||
'value' => $order_id . '|' . $item->get_id(),
|
||||
'text' => $item->get_name()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
}
|
||||
|
||||
GF_Fields::register( new Wiaas_Field_Order_Bundle_Select() );
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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 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() );
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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 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() );
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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 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_display_name($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)) {
|
||||
|
||||
$item = $order->get_item($item_id);
|
||||
|
||||
return $item->get_name();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
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() );
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ( ! class_exists( 'GFForms' ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
class Wiaas_Field_Order_Supplier_Select extends GF_Field_Select {
|
||||
|
||||
public $type = 'wiaas_order_supplier';
|
||||
|
||||
public function get_input_type() {
|
||||
// set this input type so delivery workflow step can be assigned to supplier in this field
|
||||
return 'workflow_assignee_select';
|
||||
}
|
||||
|
||||
public function get_form_editor_field_title() {
|
||||
return esc_attr__( 'Supplier Select', 'wiaas' );
|
||||
}
|
||||
|
||||
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
|
||||
return $this->_get_selected_supplier_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_supplier_display_name($value);
|
||||
}
|
||||
|
||||
|
||||
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
|
||||
return $this->_get_selected_supplier_display_name($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds bundles as choices
|
||||
*/
|
||||
public function post_convert_field() {
|
||||
$this->choices = array();
|
||||
|
||||
if ( ! $this->is_form_editor() ) {
|
||||
$this->choices = $this->_get_suppliers_as_choices();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _get_selected_supplier_display_name($value) {
|
||||
|
||||
list ($order_key, $supplier_id) = explode('|', $value);
|
||||
|
||||
if (! empty($supplier_id)) {
|
||||
|
||||
return wiaas_get_organization_name($supplier_id);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
private function _get_suppliers_as_choices() {
|
||||
|
||||
$choices = array();
|
||||
|
||||
$order_id = absint(rgget('order_id'));
|
||||
|
||||
if (! empty ($order_id) && $order = wc_get_order($order_id)) {
|
||||
|
||||
$suppliers = wiaas_get_order_suppliers($order);
|
||||
|
||||
foreach ($suppliers as $supplier_id => $supplier_name) {
|
||||
|
||||
$choices[] = array(
|
||||
'value' => 'wiaas_organization_order_' . $order_id . '|' . $supplier_id,
|
||||
'text' => $supplier_name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
}
|
||||
|
||||
GF_Fields::register( new Wiaas_Field_Order_Supplier_Select() );
|
||||
@@ -9,6 +9,21 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
public static function display_order_document_fields($file_path, $field) {
|
||||
|
||||
if ($field->type === 'wiaas_order_bundle_document') {
|
||||
|
||||
$field = new Wiaas_Field_Order_Bundle_Document();
|
||||
|
||||
return $field->get_download_url($file_path);
|
||||
}
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,11 +45,20 @@ class Wiaas_Order_Fields {
|
||||
<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
|
||||
}
|
||||
}
|
||||
@@ -73,8 +97,6 @@ class Wiaas_Order_Fields {
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
$bundle_item = $order->get_item($bundle_item_id);
|
||||
|
||||
$entry = array();
|
||||
|
||||
foreach ($form['fields'] as $field) {
|
||||
@@ -87,8 +109,15 @@ class Wiaas_Order_Fields {
|
||||
|
||||
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;
|
||||
@@ -103,6 +132,8 @@ class Wiaas_Order_Fields {
|
||||
|
||||
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;
|
||||
@@ -110,31 +141,80 @@ class Wiaas_Order_Fields {
|
||||
|
||||
if (! empty($bundle_item)) {
|
||||
|
||||
$documents = wiaas_get_order_item_documents($bundle_item, $field->wiaasDocTypeFilter);
|
||||
$documents = wiaas_get_standard_package_order_item_documents($order, $bundle_item_id);
|
||||
|
||||
if ( empty($documents) && $field->isRequired) {
|
||||
$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($documents)) {
|
||||
if (! empty ($filtered_documents) && ! $field->multipleFiles) {
|
||||
|
||||
$document = $documents[0];
|
||||
$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_supplier':
|
||||
$suppliers = wiaas_get_order_suppliers($order);
|
||||
case 'wiaas_order_installation_select':
|
||||
|
||||
$supplier_ids = array_keys($suppliers);
|
||||
$bundle_item = $order->get_item($bundle_item_id);
|
||||
|
||||
$supplier_id = $supplier_ids[0];
|
||||
if ( empty($bundle_item) && $field->isRequired) {
|
||||
// there is no data for required field so entry cannot be created
|
||||
return false;
|
||||
}
|
||||
|
||||
$entry[(string) $field->id] = 'wiaas_organization_order_' . $order_id . '|' . $supplier_id;
|
||||
$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) && $field->isRequired) {
|
||||
// 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';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class Wiaas_Document_Upload {
|
||||
);
|
||||
|
||||
public static function init() {
|
||||
//add_filter( 'upload_dir', array( __CLASS__, 'upload_dir' ) );
|
||||
add_filter( 'upload_dir', array( __CLASS__, 'upload_dir' ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -222,9 +222,4 @@ function wiaas_get_order_item_documents($order_item, $doc_type = null) {
|
||||
}
|
||||
|
||||
return $filtered_documents;
|
||||
}
|
||||
|
||||
function wiaas_get_order_item_document_admin_download_link($order_id, $item_id, $version) {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,26 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Retrieve order suppliers
|
||||
*
|
||||
* @param int|WC_Order $order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wiaas_get_order_suppliers($order) {
|
||||
|
||||
if (is_numeric($order)) {
|
||||
|
||||
$order = wc_get_order($order);
|
||||
}
|
||||
|
||||
$items = $order->get_items();
|
||||
|
||||
$suppliers = wiaas_get_suppliers();
|
||||
|
||||
return $suppliers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve standard bundles from order
|
||||
*
|
||||
|
||||
@@ -41,7 +41,11 @@ class OrderProcess extends Component {
|
||||
<Row>
|
||||
<Col xl="12" lg="12" md="12" xs="12" className="order-package-process">
|
||||
{
|
||||
visibleSteps.reverse().map((step, index) => <ProcessStep isStepVisible={this.isStepVisible} stepNumber={visibleSteps.length - index} step={step} key={'step-' + step.idProcess + '-' + step.idProcessStep}/>)
|
||||
visibleSteps.reverse().map((step, index) => <ProcessStep
|
||||
isStepVisible={this.isStepVisible}
|
||||
stepNumber={visibleSteps.length - index}
|
||||
step={step}
|
||||
key={'step-' + step.idProcess + '-' + step.idProcessStep}/>)
|
||||
}
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user