Dashboards widgets
This commit is contained in:
@@ -4,135 +4,53 @@ class Wiaas_Admin_Order_Process_Flow {
|
||||
|
||||
public static function init() {
|
||||
|
||||
add_action( 'admin_menu', array(__CLASS__, 'add_delivery_process_page') );
|
||||
|
||||
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 add_delivery_process_page() {
|
||||
add_submenu_page(
|
||||
'edit.php?post_type=shop_order',
|
||||
__( 'Order Delivery', 'wiaas' ),
|
||||
null,
|
||||
'read',
|
||||
'wiaas-order-delivery',
|
||||
array(__CLASS__, 'output_delivery_process')
|
||||
);
|
||||
}
|
||||
|
||||
public static function render_procurement_order_download_link($form, $entry, $current_step) {
|
||||
public static function output_delivery_process() {
|
||||
$order_id = absint( $_GET['id'] );
|
||||
|
||||
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
|
||||
empty( $current_step ) ||
|
||||
Wiaas_Delivery_Process_Action::is_action_form($form) ) {
|
||||
return;
|
||||
}
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
$order_id = $entry['wiaas_delivery_order_id'];
|
||||
if ( !$order ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
$delivery_process = Wiaas_Delivery_Process::get_order_delivery_process_entry($order->get_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
|
||||
if ($delivery_process &&
|
||||
wp_verify_nonce($_POST['wiaas_delivery_process_navigation_nonce'], 'wiaas_delivery_process_navigation') &&
|
||||
GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
|
||||
}
|
||||
self::_maybe_process_admin_step_change_action($delivery_process);
|
||||
|
||||
public static function add_delivery_dates_box($form, $entry, $current_step) {
|
||||
// refresh order
|
||||
$order = wc_get_order($order_id);
|
||||
}
|
||||
|
||||
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
|
||||
empty( $current_step ) || Wiaas_Delivery_Process_Action::is_action_form($form) ) {
|
||||
return;
|
||||
}
|
||||
require 'views/html-admin-delivery-process-page.php';
|
||||
}
|
||||
|
||||
$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) {
|
||||
private static function _maybe_process_admin_step_change_action($entry) {
|
||||
|
||||
$admin_action = rgpost( 'wiaas_delivery_process_navigation_action' );
|
||||
|
||||
if ($admin_action === 'complete') {
|
||||
|
||||
$api = new Gravity_Flow_API( $form['id'] );
|
||||
$api = new Gravity_Flow_API( $entry['form_id'] );
|
||||
|
||||
$current_step = $api->get_current_step($entry);
|
||||
|
||||
@@ -142,294 +60,15 @@ class Wiaas_Admin_Order_Process_Flow {
|
||||
}
|
||||
|
||||
$api->process_workflow($entry['id']);
|
||||
|
||||
$feedback = esc_html__( 'Workflow Complete', 'wiaas' );
|
||||
|
||||
return $feedback;
|
||||
}
|
||||
|
||||
list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
|
||||
|
||||
if ( $base_admin_action == 'send_to_step' ) {
|
||||
$step_id = $action_id;
|
||||
$api = new Gravity_Flow_API( $form['id'] );
|
||||
$api = new Gravity_Flow_API( $entry['form_id'] );
|
||||
$api->send_to_step( $entry, $step_id );
|
||||
$entry = GFAPI::get_entry( $entry['id'] );
|
||||
$new_step = $api->get_current_step( $entry );
|
||||
$feedback = $new_step ?
|
||||
sprintf( esc_html__( 'Sent to step: %s', 'wiaas' ), $new_step->get_name() ) :
|
||||
esc_html__( 'Workflow Complete', 'wiaas' );
|
||||
}
|
||||
|
||||
return $feedback;
|
||||
}
|
||||
|
||||
public static function maybe_display_delivery_process_navigation($form, $entry, $current_step) {
|
||||
|
||||
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
|
||||
empty( $current_step ) ||
|
||||
Wiaas_Delivery_Process_Action::is_action_form($form) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$steps = gravity_flow()->get_steps($form['id'], $entry);
|
||||
|
||||
// get next step id
|
||||
$next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
|
||||
$next_step_id = empty($next_step) ? null : $next_step->get_id();
|
||||
|
||||
// get previous step id
|
||||
foreach ($steps as $step) {
|
||||
|
||||
$next = gravity_flow()->get_next_step($step, $entry, $form);
|
||||
if ($next && $next->get_id() === $current_step->get_id()) {
|
||||
$previous_step = $step;
|
||||
}
|
||||
}
|
||||
$previous_step_id = empty($previous_step) ? null : $previous_step->get_id();
|
||||
|
||||
// bail out if none exist
|
||||
if ( empty($next_step_id) && empty($previous_step_id) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @reference Gravity_Flow::maybe_process_admin_action for used field names
|
||||
* which are being checked there
|
||||
*
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,12 +77,7 @@ class Wiaas_Admin_Delivery_Process_Order {
|
||||
<?php
|
||||
} else{
|
||||
|
||||
$entry_url = add_query_arg( array(
|
||||
'page' => 'gravityflow-inbox',
|
||||
'view' => 'entry',
|
||||
'id' => $process_entry['form_id'],
|
||||
'lid' => $process_entry['id']
|
||||
), admin_url() );
|
||||
$entry_url = admin_url('admin.php?page=wiaas-order-delivery&id=' . $order_id);
|
||||
|
||||
?>
|
||||
<a href="<?php esc_attr_e($entry_url, 'wiaas') ?>"> Delivery Process </a>
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Order $order
|
||||
*
|
||||
*/
|
||||
|
||||
$delivery_process = Wiaas_Delivery_Process::get_order_delivery_process_entry($order->get_id());
|
||||
|
||||
if ( ! empty($delivery_process)) {
|
||||
|
||||
$form_id = $delivery_process['form_id'];
|
||||
$workflow_api = new Gravity_Flow_API($form_id);
|
||||
|
||||
$current_step = $workflow_api->get_current_step($delivery_process);
|
||||
|
||||
$steps = $workflow_api->get_steps();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<form name="delivery" action="" method="post">
|
||||
<input type="hidden" name="page" value="wiaas-order-delivery"/>
|
||||
<input type="hidden" name="id" value="<?php echo esc_attr($order->get_id()) ?>"/>
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
|
||||
<?php require 'html-order-notes.php' ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="postbox-container-2" class="postbox-container">
|
||||
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<div class="panel-wrap">
|
||||
<div class="panel">
|
||||
<h1>
|
||||
Delivery Order
|
||||
<?php
|
||||
if (current_user_can('edit_others_shop_orders')) {
|
||||
echo '<a href="' . esc_url( admin_url( 'post.php?post=' . absint( $order->get_id() ) ) . '&action=edit' ) . '">#' . esc_attr( $order->get_order_number() ) . '</a>';
|
||||
} else {
|
||||
echo '#' . esc_attr($order->get_order_number());
|
||||
}
|
||||
?>
|
||||
   
|
||||
<mark class="wiaas-order-status <?php esc_attr_e( sanitize_html_class( 'wiaas-order-status-' . $order->get_status() ), 'wiaas' ) ?>">
|
||||
<span>
|
||||
<?php esc_html_e( wc_get_order_status_name( $order->get_status() ) ) ?>
|
||||
</span>
|
||||
</mark>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
if (GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
|
||||
?>
|
||||
<p>
|
||||
<a
|
||||
id="wiaas_download_procurement_order_btn"
|
||||
href="<?php echo admin_url() . '?wiaas-procurement-order-id=' . $order->get_id() ?>"
|
||||
download
|
||||
class="button"
|
||||
>
|
||||
<span><?php esc_html_e('Download procurement report', 'wiaas') ?></span>
|
||||
</a>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
if (empty($delivery_process)) {
|
||||
|
||||
echo '<h2>Delivery process has not been assigned.</h2>';
|
||||
}
|
||||
|
||||
if (! empty($delivery_process)) {
|
||||
|
||||
$is_disabled = ! Wiaas_Delivery_Process::can_delivery_dates_be_set($order->get_id(), $delivery_process, $steps);
|
||||
|
||||
require 'html-order-suppliers-delivery-dates.php';
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
if (! empty($delivery_process)) {
|
||||
|
||||
if ($current_step && GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
|
||||
require 'html-delivery-process-navigation.php';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="postbox">
|
||||
<h3>
|
||||
<i class="dashicons dashicons-marker" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
|
||||
<span>Order placed </span>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<h3>
|
||||
<i class="dashicons dashicons-marker" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
|
||||
<span> Assign process </span>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
foreach ($steps as $step) {
|
||||
$step = $workflow_api->get_step($step->get_id(), $delivery_process);
|
||||
require 'html-delivery-process-step.php';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// get next step id
|
||||
$next_step = gravity_flow()->get_next_step($current_step, $current_step->get_entry(), $current_step->get_form());
|
||||
$next_step_id = empty($next_step) ? null : $next_step->get_id();
|
||||
|
||||
// get previous step id
|
||||
foreach ($steps as $step) {
|
||||
|
||||
$next = gravity_flow()->get_next_step($step, $current_step->get_entry(), $current_step->get_form());
|
||||
if ($next && $next->get_id() === $current_step->get_id()) {
|
||||
$previous_step = $step;
|
||||
}
|
||||
}
|
||||
$previous_step_id = empty($previous_step) ? null : $previous_step->get_id();
|
||||
|
||||
// bail out if none exist
|
||||
if ( empty($next_step_id) && empty($previous_step_id) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div style="padding:10px; height:40px">
|
||||
|
||||
<input id="wiaas_delivery_process_navigation_action" type="hidden" name="wiaas_delivery_process_navigation_action">
|
||||
<?php wp_nonce_field( 'wiaas_delivery_process_navigation', 'wiaas_delivery_process_navigation_nonce' ); ?>
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$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 style="padding: 10px;">
|
||||
|
||||
<?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="dashicons dashicons-external" style="font-size: 16px;"></i>' .
|
||||
'</a>';
|
||||
|
||||
?>
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
?>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$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="dashicons dashicons-marker" 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, $step->get_form(), $form, $step->get_entry());
|
||||
|
||||
$action_form = GFAPI::get_form( $step->target_form_id );
|
||||
|
||||
if (! empty($action_form)) {
|
||||
|
||||
$page_size = 20;
|
||||
$search_criteria = array(
|
||||
'status' => 'active',
|
||||
'field_filters' => array(
|
||||
array( 'key' => 'wiaas_delivery_process_id',
|
||||
'value' => $delivery_process['id']
|
||||
),
|
||||
),
|
||||
);
|
||||
$sorting = array( 'key' => 'date_created', 'direction' => 'DESC' );
|
||||
$paging = array( 'offset' => 0, 'page_size' => $page_size );
|
||||
|
||||
$entries = GFAPI::get_entries( $action_form['id'], $search_criteria, $sorting, $paging );
|
||||
|
||||
$action_workflow = new Gravity_Flow_API($action_form['id']);
|
||||
$current_assignee_key = $step->get_current_assignee_key();
|
||||
|
||||
foreach ($entries as $action_entry) {
|
||||
|
||||
$action_entry_step = $action_workflow->get_current_step($action_entry);
|
||||
|
||||
$show_entry = GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
|
||||
($action_entry_step &&
|
||||
$action_entry_step->is_assignee($current_assignee_key));
|
||||
|
||||
if ($show_entry) {
|
||||
require 'html-delivery-process-step-action.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$notes = wc_get_order_notes( array( 'order_id' => $order->get_id(), 'type' => 'customer' ) );
|
||||
|
||||
?>
|
||||
|
||||
<div id="wiaas_delivery_process_order_notes" class="delivery-process-notes">
|
||||
|
||||
<div id="delivery_process_order_notes_list">
|
||||
<?php
|
||||
foreach ($notes as $note) {
|
||||
|
||||
?>
|
||||
<div class="note_content">
|
||||
<?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); ?>
|
||||
</div>
|
||||
<p class="meta">
|
||||
<abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
|
||||
<?php
|
||||
if ( 'system' !== $note->added_by ) :
|
||||
/* translators: %s: note author */
|
||||
printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by );
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="add-note">
|
||||
<p>
|
||||
<label for="add_order_note"><?php _e( 'Add note', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ) ); ?></label>
|
||||
<textarea
|
||||
data-order-id="<?php esc_attr_e($order->get_id(), 'wiaas') ?>"
|
||||
data-nonce="<?php esc_attr_e( wp_create_nonce( 'wiaas-add-order-note' ), 'wiaas') ?>"
|
||||
type="text"
|
||||
name="order_note"
|
||||
id="wiaas_add_order_note"
|
||||
class="input-text"
|
||||
cols="20" rows="5"></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<input type="hidden" name="order_note_type" value="customer"/>
|
||||
<button type="button" id="wiaas_delivery_process_add_note" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -2,9 +2,16 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$suppliers = Wiaas_Order::get_suppliers($order_id);
|
||||
$final_estimated_date = Wiaas_Order::get_final_estimated_date($order_id);
|
||||
$final_confirmed_date = Wiaas_Order::get_final_confirmed_date($order_id);
|
||||
$earliest_installation_date = Wiaas_Order::get_earliest_installation_date($order_id);
|
||||
|
||||
?>
|
||||
|
||||
<div style="margin-top: -20px;">
|
||||
<div>
|
||||
<br>
|
||||
<table class="widefat" disabled="disabled">
|
||||
<tr style="background: #EAF2FA;">
|
||||
<th align="left"><strong>Suppliers</strong></th>
|
||||
@@ -54,35 +61,50 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
<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"
|
||||
>
|
||||
|
||||
<?php
|
||||
if (! $is_disabled) {
|
||||
|
||||
?>
|
||||
<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"
|
||||
>
|
||||
<?php
|
||||
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
if (! $is_disabled) {
|
||||
|
||||
?>
|
||||
<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 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
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ add_action( 'wp_ajax_wiaas_delete_tracking_info', 'wiaas_ajax_delete_tracking_in
|
||||
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');
|
||||
add_action( 'wp_ajax_wiaas_add_order_note', 'wiaas_ajax_add_order_note');
|
||||
|
||||
/**
|
||||
* Adds additional tracking info for supplier in order
|
||||
@@ -27,6 +28,38 @@ function wiaas_ajax_add_additional_tracking_info_for_supplier_in_order(){
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add order note via ajax.
|
||||
*/
|
||||
function wiaas_ajax_add_order_note() {
|
||||
check_ajax_referer( 'wiaas-add-order-note', 'security' );
|
||||
|
||||
if ( ! current_user_can( 'edit_shop_orders' ) ) {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
$post_id = absint( $_POST['post_id'] );
|
||||
$note = wp_kses_post( trim( wp_unslash( $_POST['note'] ) ) );
|
||||
|
||||
if ( $post_id > 0 ) {
|
||||
$order = wc_get_order( $post_id );
|
||||
$comment_id = $order->add_order_note( $note, true, true );
|
||||
$note = wc_get_order_note( $comment_id );
|
||||
?>
|
||||
<div class="note_content">
|
||||
<?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); ?>
|
||||
</div>
|
||||
<p class="meta">
|
||||
<abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
|
||||
<?php
|
||||
printf( ' ' . __( 'by %s', 'wiaas' ), $note->added_by );
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
wp_die();
|
||||
}
|
||||
|
||||
function wiaas_ajax_save_tracking_info(){
|
||||
check_ajax_referer('wiaas_save_tracking_info');
|
||||
$error = new WP_Error('-1', 'Failed to save tracking info');
|
||||
|
||||
Reference in New Issue
Block a user