move date selection to workflow
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
.delivery-process {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.delivery-process:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('#delivery-process-selector').change(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var data = {
|
||||
action: 'wiaas_create_order_delivery_process',
|
||||
_ajax_nonce: $('#wiaas_create_order_delivery_process_nonce').val(),
|
||||
order: $('#wiaas_order_id').val(),
|
||||
form: e.target.value
|
||||
|
||||
};
|
||||
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,16 @@ class Wiaas_Admin_Delivery_Process {
|
||||
public static function init() {
|
||||
require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-flow.php';
|
||||
require_once dirname( __FILE__ ) . '/delivery-process/wiaas-admin-delivery-process-ajax.php';
|
||||
|
||||
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
|
||||
|
||||
wp_enqueue_script( 'wiaas_delivery_process', $plugin_url . '/assets/js/wiaas-admin-delivery-process.js' );
|
||||
|
||||
wp_enqueue_style( 'wiaas_admin_delivery_process', $plugin_url . '/assets/css/wiaas-admin-delivery-process.css' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,37 +3,33 @@
|
||||
class Wiaas_Admin_Order_Process_Flow {
|
||||
|
||||
public static function init() {
|
||||
add_action('add_meta_boxes', array(__CLASS__, 'create_custom_meta_box'), 100);
|
||||
add_action('woocommerce_admin_order_data_after_order_details', array(__CLASS__, 'add_custom_fields_after_order_details'), 10, 1 );
|
||||
add_action('add_meta_boxes', array(__CLASS__, 'create_process_flow_meta_box'), 100);
|
||||
add_action('gravityflow_entry_detail', array(__CLASS__, 'add_delivery_dates_box'), 11, 3);
|
||||
}
|
||||
|
||||
public static function create_custom_meta_box() {
|
||||
add_meta_box(
|
||||
public static function create_process_flow_meta_box(){
|
||||
add_meta_box(
|
||||
'order_process_flow_meta_box',
|
||||
__('Order Process Flow', 'cmb'),
|
||||
'Wiaas_Admin_Order_Process_Flow::add_process_flow_meta_box',
|
||||
'shop_order',
|
||||
'normal',
|
||||
'default'
|
||||
);
|
||||
|
||||
add_meta_box(
|
||||
'order_delivery_dates_meta_box',
|
||||
__('Delivery dates', 'cmb'),
|
||||
'Wiaas_Admin_Order_Process_Flow::add_delivery_dates_meta_box',
|
||||
'shop_order',
|
||||
'normal',
|
||||
'default'
|
||||
'high'
|
||||
);
|
||||
}
|
||||
|
||||
public static function add_custom_fields_after_order_details($order){
|
||||
$global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id);
|
||||
|
||||
$order_id = $order->id;
|
||||
require 'views/html-order-global-delivery-date.php';
|
||||
public static function add_delivery_dates_box($form, $entry, $current_step){
|
||||
$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-delivery-dates.php';
|
||||
}
|
||||
|
||||
|
||||
public static function add_process_flow_meta_box(){
|
||||
global $post;
|
||||
|
||||
@@ -43,27 +39,35 @@ class Wiaas_Admin_Order_Process_Flow {
|
||||
|
||||
if ($process === NULL){
|
||||
$list_of_delivery_processes = Wiaas_Delivery_Process::get_available_delivery_processes();
|
||||
require 'views/html-order-select-delivery-process.php';
|
||||
}else{
|
||||
$title = $process['name'];
|
||||
$steps = $process['steps'];
|
||||
|
||||
echo '<div>
|
||||
<h1>Please select a process for the order:</h1>
|
||||
<br/>
|
||||
<select id="delivery-process-selector">
|
||||
<option value="" disabled selected>Select ... </option>';
|
||||
|
||||
require 'views/html-order-process-flow.php';
|
||||
foreach($list_of_delivery_processes as $index => $process){
|
||||
echo '<option value=' . $process['id'] . '>' . $process['title'] . '</option>';
|
||||
}
|
||||
echo '</select>
|
||||
</div>';
|
||||
wp_nonce_field( 'wiaas_create_order_delivery_process', 'wiaas_create_order_delivery_process_nonce' );
|
||||
echo '<input type="hidden" id="wiaas_order_id" name="wiaas_order_id" value="' . $order_id . '"/>';
|
||||
|
||||
}else{
|
||||
$workflow_url = "";
|
||||
|
||||
echo '<div>
|
||||
<a href=' . $workflow_url . '>Go to process flow</a>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function add_delivery_dates_meta_box(){
|
||||
global $post;
|
||||
|
||||
$order_id = $post->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-delivery-dates.php';
|
||||
public static function add_custom_fields_after_order_details($order){
|
||||
$global_estimated_delivery_date = Wiaas_Order::get_global_estimated_date($order->id);
|
||||
|
||||
$order_id = $order->id;
|
||||
require 'views/html-order-global-delivery-date.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div>
|
||||
<div style="background:white;padding:8px 10px;">
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<th align="left">Suppliers</th>
|
||||
@@ -67,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><h3>Final dates : </h3></td>
|
||||
<td><h4>Final dates : </h4></td>
|
||||
<td><h4><?php echo $final_estimated_date ? date('Y-m-d', $final_estimated_date) : '-' ?></h4></td>
|
||||
<td><h4><?php echo $final_confirmed_date ? date('Y-m-d', $final_confirmed_date) : '-' ?></h4></td>
|
||||
</tr>
|
||||
@@ -75,7 +74,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
<td colspan="5"><hr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><h3>Earliest installation date : </h3></td>
|
||||
<td><h4>Earliest installation date : </h4></td>
|
||||
<td><h4><?php echo $earliest_installation_date ? date('Y-m-d', $earliest_installation_date) : '-' ?></h4></td>
|
||||
</tr>
|
||||
|
||||
@@ -100,7 +99,7 @@ function onEstimatedDeliveryDateChange(supplierID, date) {
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
@@ -125,7 +124,7 @@ function onConfirmedDeliveryDateChange(supplierID, date) {
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
@@ -145,7 +144,7 @@ function addAdditionalTrackingInfo(e){
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
@@ -170,7 +169,7 @@ function saveTrackingInfo(e, supplierID, index){
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
@@ -190,7 +189,7 @@ function deleteTrackingInfo(e, supplierID, index){
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<style>
|
||||
.collapsible {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.collapsible-active, .collapsible:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.collapsible-content {
|
||||
padding: 0 18px;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.2s ease-out;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h3><?php echo $title ?></h3>
|
||||
<br/>
|
||||
<?php
|
||||
foreach($steps as $index => $step){
|
||||
$count = $index + 1;
|
||||
echo '<button class="collapsible">' . $count . '. ' . $step['short_desc'] . '</button>';
|
||||
echo '<div class="collapsible-content">';
|
||||
echo $step['full_desc'];
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var coll = document.getElementsByClassName("collapsible");
|
||||
var i;
|
||||
|
||||
for (i = 0; i < coll.length; i++) {
|
||||
coll[i].addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
this.classList.toggle("collapsible-active");
|
||||
var content = this.nextElementSibling;
|
||||
if (content.style.maxHeight){
|
||||
content.style.maxHeight = null;
|
||||
} else {
|
||||
content.style.maxHeight = content.scrollHeight + "px";
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
.delivery-process {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.delivery-process:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>Please select a process for the order:</h1>
|
||||
<br/>
|
||||
<select id="delivery-process-selector">
|
||||
<option value="" disabled selected>Select ... </option>
|
||||
<?php
|
||||
foreach($list_of_delivery_processes as $index => $process){
|
||||
echo '<option value=' . $process['id'] . '>' . $process['title'] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" >
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('#delivery-process-selector').change(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
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: e.target.value
|
||||
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
alert(response.data[0].message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user