Merge branch 'order-delivery-flow' into 'master'

Order delivery flow integration with order fields and order organization participants

See merge request saburly/wiaas/new-wiaas!53
This commit was merged in pull request #53.
This commit is contained in:
Bilal Catic
2018-11-04 22:16:39 +00:00
56 changed files with 5295 additions and 2567 deletions

View File

@@ -46,7 +46,7 @@ ENV WP_SENDGRID_FROM_NAME ${WP_SENDGRID_FROM_NAME}
ENV WIAAS_CUSTOMER_INTERFACE ${WIAAS_CUSTOMER_INTERFACE}
RUN apt-get update && apt-get install -y git unzip gnupg mysql-client sudo
RUN apt-get update && apt-get install -y git unzip gnupg mysql-client sudo libpng-dev
COPY docker/php/composer.phar /usr/local/bin/composer
RUN chmod 755 /usr/local/bin/composer
@@ -57,7 +57,7 @@ RUN chmod +x /usr/local/bin/wp
COPY docker/php/setup.sh /init-scripts/
RUN chmod +x /init-scripts/setup.sh
RUN docker-php-ext-install pdo pdo_mysql mysqli opcache
RUN docker-php-ext-install pdo pdo_mysql mysqli opcache gd zip mbstring
RUN a2enmod rewrite
COPY docker/php/000-default.conf /etc/apache2/sites-available

View File

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

View File

@@ -1,15 +0,0 @@
.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;
}

View File

@@ -1,23 +1,8 @@
jQuery(document).ready(function($) {
jQuery(document).ready(function ($) {
$('.wiaas_delivery_step_nav').click(function (e) {
var action = $(this).data('step');
$('#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
$('#wiaas_delivery_process_navigation_action').val(action);
};
// 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);
}
});
});
});
});

View File

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

View File

@@ -3,18 +3,19 @@
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';
require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-flow.php';
require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-order.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}
public static function enqueue_scripts() {
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
wp_enqueue_script( 'wiaas_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' );
wp_enqueue_script( 'wiaas_admin_delivery_process', $plugin_url . '/assets/js/wiaas-admin-delivery-process.js' );
}
}

View File

@@ -3,23 +3,91 @@
class Wiaas_Admin_Order_Process_Flow {
public static function init() {
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);
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__, 'remove_workflow_admin_actions'));
}
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',
'high'
);
public static function remove_workflow_admin_actions() {
return array();
}
public static function render_procurement_order_download_link($form, $entry, $current_step) {
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
empty( $current_step ) ||
Wiaas_Delivery_Process_Action::is_action_form($form) ) {
return;
}
$order_id = $entry['wiaas_delivery_order_id'];
?>
<div class="postbox">
<h3 class="hndle">
<?php esc_html_e('Procurement report', 'wiaas') ?>
</h3>
<div style="padding: 10px;">
<a
id="wiaas_download_procurement_order_btn"
href="<?php echo admin_url() . '?wiaas-procurement-order-id=' . $order_id ?>"
download
class="button"
>
<span><?php esc_html_e('Download procurement report', 'wiaas') ?></span>
</a>
</div>
</div>
<?php
}
public static function add_delivery_dates_box($form, $entry, $current_step){
public static function add_delivery_dates_box($form, $entry, $current_step) {
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
empty( $current_step ) || Wiaas_Delivery_Process_Action::is_action_form($form) ) {
return;
}
$workflow_api = new Gravity_Flow_API($form['id']);
$steps = $workflow_api->get_steps();
/**
* Disable if:
* - actions for customer config validation is not done
* - action for customer acceptance is active or completed
*/
$is_disabled = false;
foreach ($steps as $step) {
if (Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step) &&
$step->get_status() !== 'complete') {
$is_disabled = true;
break;
}
if (Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step) &&
($step->get_id() === $current_step->get_id() || $step->get_status() === 'complete')) {
$is_disabled = true;
break;
}
}
$order_id = $entry['wiaas_delivery_order_id'];
$suppliers = Wiaas_Order::get_suppliers($order_id);
@@ -30,46 +98,318 @@ class Wiaas_Admin_Order_Process_Flow {
require 'views/html-order-suppliers-delivery-dates.php';
}
public static function add_process_flow_meta_box(){
global $post;
public static function maybe_process_admin_step_change_action($feedback, $admin_action, $form, $entry) {
$order_id = $post->ID;
$admin_action = rgpost( 'wiaas_delivery_process_navigation_action' );
$process = Wiaas_Delivery_Process::get_order_delivery_process($order_id);
if ($admin_action === 'complete') {
if ($process === NULL){
$list_of_delivery_processes = Wiaas_Delivery_Process::get_available_delivery_processes();
echo '<div>
<h1>Please select a process for the order:</h1>
<br/>
<select id="delivery-process-selector">
<option value="" disabled selected>Select ... </option>';
$api = new Gravity_Flow_API( $form['id'] );
foreach($list_of_delivery_processes as $index => $process){
echo '<option value=' . $process['id'] . '>' . $process['title'] . '</option>';
$current_step = $api->get_current_step($entry);
if ( $current_step ) {
$current_step->purge_assignees();
$current_step->update_step_status( 'complete' );
}
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{
$current_step = Wiaas_Delivery_Process::get_active_step($order_id);
$workflow_url = $current_step->get_entry_url();
$api->process_workflow($entry['id']);
echo '<div>
<a href=' . $workflow_url . '>Go to delivery process page</a>
</div>';
$feedback = esc_html__( 'Workflow Complete', 'wiaas' );
return $feedback;
}
list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
if ( $base_admin_action == 'send_to_step' ) {
$step_id = $action_id;
$api = new Gravity_Flow_API( $form['id'] );
$api->send_to_step( $entry, $step_id );
$entry = GFAPI::get_entry( $entry['id'] );
$new_step = $api->get_current_step( $entry );
$feedback = $new_step ?
sprintf( esc_html__( 'Sent to step: %s', 'wiaas' ), $new_step->get_name() ) :
esc_html__( 'Workflow Complete', 'wiaas' );
}
return $feedback;
}
public static function maybe_display_delivery_process_navigation($form, $entry, $current_step) {
if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
empty( $current_step ) ||
Wiaas_Delivery_Process_Action::is_action_form($form) ) {
return;
}
$steps = gravity_flow()->get_steps($form['id'], $entry);
// get next step id
$next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
$next_step_id = empty($next_step) ? null : $next_step->get_id();
// get previous step id
foreach ($steps as $step) {
$next = gravity_flow()->get_next_step($step, $entry, $form);
if ($next && $next->get_id() === $current_step->get_id()) {
$previous_step = $step;
}
}
$previous_step_id = empty($previous_step) ? null : $previous_step->get_id();
// bail out if none exist
if ( empty($next_step_id) && empty($previous_step_id) ) {
return;
}
/**
* @reference Gravity_Flow::maybe_process_admin_action for used field names
* which are being checked there
*
*/
?>
<div style="padding:10px; height:40px">
<input id="wiaas_delivery_process_navigation_action" type="hidden" name="wiaas_delivery_process_navigation_action">
<input type="hidden" name="_gravityflow_admin_action" value="1">
<input
data-step="<?php echo empty($next_step_id) ? 'complete' : 'send_to_step|'.$next_step_id ?>"
type="submit"
class="button button-primary wiaas_delivery_step_nav"
style="float:right; margin-left: 20px;"
value="<?php echo empty($next_step_id) ? 'COMPLETE' : 'NEXT STEP' ?>"
>
<input
data-step="send_to_step|<?php esc_attr_e($previous_step_id, 'wiaas') ?>"
type="submit"
<?php disabled(empty($previous_step_id), true, true) ?>
class="button button-primary wiaas_delivery_step_nav"
style="float:right;" value="PREV STEP">
</div>
<?php
}
public static function display_process_steps_details($form, $entry, $current_step) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
if ($delivery_settings['delivery_form_type'] === 'action') {
return;
}
// get process order ID
$order_id = absint($entry['wiaas_delivery_order_id']);
if (empty($order_id)) {
$order_field = GFCommon::get_fields_by_type($form, array( 'wiaas_order') )[0];
if ( ! empty($order_field)) {
$order_id = $entry[$order_field->id];
}
}
// display process steps
$workflow_api = new Gravity_Flow_API($form['id']);
$steps = $workflow_api->get_steps();
?>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
<span>Order placed </span>
</h3>
</div>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px;color: #34C388; "></i>
<span> Assign process </span>
</h3>
</div>
<?php
foreach ($steps as $index => $step) {
if (! $step->is_active()) {
continue;
}
$is_step_completed = $step->get_status() === 'complete' || $step->get_status() === 'approved';
$is_current_step = $current_step && $step->get_id() === $current_step->get_id();
if ($is_current_step) {
$style = 'color: #FD8049;';
} else if ($is_step_completed) {
$style = 'color: #34C388;';
} else {
$style = 'opacity: 0.5; color: #CCC;';
}
?>
<div class="postbox">
<h3>
<i class="fa fa-circle" style="font-size: 22px; margin-right: 10px; <?php esc_attr_e($style, 'wiaas') ?>"></i>
<span><?php esc_html_e($step->get_name(), 'wiaas') ?></span>
</h3>
<?php
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['id'], $search_criteria, $sorting, $paging );
foreach ($entries as $action_entry) {
self::_display_step_action_entry($action_form, $action_entry);
}
?>
</tbody>
</table>
</div>
<?php
}
?>
</div>
<?php
}
}
public static function add_custom_fields_after_order_details($order){
$order_estimated_delivery_date = Wiaas_Order::get_order_estimated_date($order->id);
$order_id = $order->id;
require 'views/html-order-delivery-date.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);
?>
<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_Order_Process_Flow::init();
Wiaas_Admin_Order_Process_Flow::init();

View File

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

View File

@@ -4,61 +4,84 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
<div style="background:white;padding:8px 10px;">
<table style="width:100%">
<tr>
<th align="left">Suppliers</th>
<th align="left">Estimated date</th>
<th align="left">Confirmed date</th>
<div style="margin-top: -20px;">
<table class="widefat" disabled="disabled">
<tr style="background: #EAF2FA;">
<th align="left"><strong>Suppliers</strong></th>
<th align="left"><strong>Estimated date</strong></th>
<th align="left"><strong>Confirmed date</strong></th>
</tr>
<tr>
<td colspan="5"><hr></td>
<tr>
<?php
foreach($suppliers as $supplier){
echo '<tr><td>' . $supplier['name'] . '</td>';
echo '<tr style="background: #f5f5f5;"><td><strong>' . $supplier['name'] . '</strong></td>';
$estimated_date = $supplier['estimated_date'] ? date("Y-m-d", $supplier['estimated_date']) : "";
$confirmed_date = $supplier['confirmed_date'] ? date("Y-m-d", $supplier['confirmed_date']) : "";
?>
<td>
<input id=<?php echo 'estimate-date-' . $supplier['id'] ?> type="date" onChange="onEstimatedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)" value="<?php echo $estimated_date ?>" />
<input
id=<?php echo 'estimate-date-' . $supplier['id'] ?>
<?php disabled($is_disabled, true, true) ?>
type="date"
onChange="onEstimatedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)"
value="<?php echo $estimated_date ?>" />
</td>
<td>
<input id=<?php echo 'confirmed-date-' . $supplier['id'] ?> type="date" onChange="onConfirmedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)" value="<?php echo $confirmed_date ?>" />
<input
id=<?php echo 'confirmed-date-' . $supplier['id'] ?>
<?php disabled($is_disabled, true, true) ?>
type="date" onChange="onConfirmedDeliveryDateChange(<?php echo $supplier['id'] ?>, this.value)"
value="<?php echo $confirmed_date ?>" />
</td>
</tr>
<tr>
<td colspan="5"><h4>Tracking</h4></td>
</tr>
<tr>
<td><button id=<?php echo $supplier['id'] ?> onClick="addAdditionalTrackingInfo(event)">Add more tracking info</button></td>
<td colspan="3">
<span>Tracking:</span>
</td>
</tr>
<?php
foreach($supplier['tracking_info'] as $index => $tracking_info){
?>
<tr>
<td></td>
<td><input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_num_' . $index ?>
placeholder="Tracking number" value="<?php echo $tracking_info['number'] ?>" /></td>
<td><input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_url_' . $index ?>
placeholder="Tracking URL" value="<?php echo $tracking_info['url'] ?>" /></td>
<td><button class="dashicons-before dashicons-yes" onClick="saveTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)"></button></td>
<td><button class="dashicons-before dashicons-dismiss" onClick="deleteTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)"></button></td>
<td colspan="3">
<input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_num_' . $index ?>
<?php disabled($is_disabled, true, true) ?>
placeholder="Tracking number" value="<?php echo $tracking_info['number'] ?>" />
<input id=<?php echo 'supplier_' . $supplier['id'] . '_tracking_url_' . $index ?>
<?php disabled($is_disabled, true, true) ?>
placeholder="Tracking URL" value="<?php echo $tracking_info['url'] ?>" />
<input
type="button"
<?php disabled($is_disabled, true, true) ?>
class="button"
onClick="saveTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)"
value="SAVE">
<input
type="button"
<?php disabled($is_disabled, true, true) ?>
class="button"
onClick="deleteTrackingInfo(event, <?php echo $supplier['id'] . ',' . $index ?>)" value="REMOVE"
>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="5"><hr></td>
<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
@@ -70,13 +93,15 @@ if ( ! defined( 'ABSPATH' ) ) {
<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>
<tr>
<td colspan="5"><hr></td>
</tr>
<tr>
<td><h4>Earliest installation date : </h4></td>
<td><h4><?php echo $earliest_installation_date ? date('Y-m-d', $earliest_installation_date) : '-' ?></h4></td>
</tr>
<tfoot>
<tr>
<td><h4>Earliest installation date : </h4></td>
<td colspan="2">
<h4><?php echo $earliest_installation_date ? date('Y-m-d', $earliest_installation_date) : '-' ?></h4>
</td>
</tr>
</tfoot>
</table>
</div>

View File

@@ -1,6 +1,5 @@
<?php
add_action( 'wp_ajax_wiaas_create_order_delivery_process', 'wiaas_ajax_create_order_delivery_process' );
add_action( 'wp_ajax_wiaas_add_additional_tracking_info_for_supplier_in_order', 'wiaas_ajax_add_additional_tracking_info_for_supplier_in_order' );
add_action( 'wp_ajax_wiaas_save_tracking_info', 'wiaas_ajax_save_tracking_info');
add_action( 'wp_ajax_wiaas_delete_tracking_info', 'wiaas_ajax_delete_tracking_info');
@@ -8,25 +7,6 @@ add_action( 'wp_ajax_wiaas_save_estimated_date_for_supplier', 'wiaas_ajax_save_e
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');
/**
* Creates delivery process for order
*/
function wiaas_ajax_create_order_delivery_process() {
check_ajax_referer('wiaas_create_order_delivery_process');
$error = new WP_Error('-1', 'Failed to create order delivery process');
if (!isset($_POST['order']) || !isset($_POST['form'])){
wp_send_json_error($error);
}
$order_id = intval( $_POST['order'] );
$form_id = intval( $_POST['form'] );
if (Wiaas_Delivery_Process::create_delivery_process_for_order($order_id, $form_id)){
wp_send_json_success();
}
wp_send_json_error($error);
}
/**
* Adds additional tracking info for supplier in order
*/

View File

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

View File

@@ -1,12 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Wiaas_Admin {
public static function init() {
require_once dirname( __FILE__ ) . '/admin/class-wiaas-admin-package.php';
require_once dirname( __FILE__ ) . '/admin/class-wiaas-admin-pricing.php';
require_once dirname(__FILE__) . '/admin/template/class-wiaas-admin-template-selection.php';
@@ -27,6 +24,8 @@ class Wiaas_Admin {
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-product.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-delivery-process.php';
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-supplier.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );

View File

@@ -298,8 +298,12 @@ class Wiaas_Cart {
}
/**
* Persist used payment type information for package in corresponding order line item.
* Also for standard package type list of addons and options will be saved.
* Persist additional metadata for every order item
* This includes:
*
* 1. payment info
* 2. relation info for addons and options
* 3. prices for simple products
*
* @param $order_item
* @param $cart_item_key
@@ -309,7 +313,11 @@ class Wiaas_Cart {
* @return WC_Order_Item
*/
public static function add_order_item_meta( $order_item, $cart_item_key, $cart_item ) {
if (wc_pb_is_bundle_container_cart_item($cart_item) && isset($cart_item['_wiaas_payment'])) {
$is_bundle_item = wc_pb_is_bundle_container_cart_item($cart_item);
$is_bundled_item = wc_pb_is_bundled_cart_item($cart_item);
if ($is_bundle_item && isset($cart_item['_wiaas_payment'])) {
$payment = $cart_item['_wiaas_payment'];
@@ -378,6 +386,36 @@ class Wiaas_Cart {
$order_item->add_meta_data( '_wiaas_documents', $item_documents, true );
}
// save simple product information that needs to be available later on
// even if this data is changed or removed from product at that time
if($is_bundled_item) {
$product = wc_get_product($cart_item['product_id']);
$order_item->add_meta_data('_wiaas_category', Wiaas_Product_Category::get_category($product), true);
$order_item->add_meta_data('_wiaas_manufacturer_product_no', $product->get_meta('_manufacturer_product_no'), true);
$order_item->add_meta_data('_wiaas_supplier_product_no', $product->get_meta('_supplier_product_no'), true);
// get supplier
if ($supplier_organization_id = Wiaas_Product_Supplier::get_supplier_organisation_id_from_product($cart_item['product_id'])) {
$order_item->add_meta_data('_wiaas_supplier_organization_id', $supplier_organization_id, true);
}
// save bundled product item total cost (price x period)
$product_price = Wiaas_Pricing::get_product_total_cost($product);
$order_item->add_meta_data('_wiaas_product_price', $product_price, true);
}
// save number of days before earliest installation for bundles
if ($is_bundle_item) {
$order_item->add_meta_data(
'_wiaas_earliest_installation_additional_days',
Wiaas_Package::get_earliest_installation_additional_days($cart_item['product_id']),
true);
}
return $order_item;
}
@@ -405,6 +443,12 @@ class Wiaas_Cart {
'_wiaas_option_group_name',
'_wiaas_standard_package',
'_wiaas_documents',
'_wiaas_category',
'_wiaas_manufacturer_product_no',
'_wiaas_supplier_product_no',
'_wiaas_supplier_organization_id',
'_wiaas_product_price',
'_wiaas_earliest_installation_additional_days'
) );
}
@@ -431,54 +475,70 @@ class Wiaas_Cart {
$order->add_meta_data('_wiaas_commercial_lead_id', $shop_owner_id);
// add suppliers to order
$suppliers = array();
// add supplier organizations information to order
// save installation suppliers separately
$suppliers_info = array();
$installation_suppliers_info = array();
$items = $order->get_items('line_item');
foreach($items as $item){
$product = wc_get_product($item['product_id']);
foreach($items as $item) {
if ($product->is_type('simple') && !Wiaas_Product_Category::is_installation($product)){
$supplier_id = Wiaas_Product::get_supplier_id($product->id);
$supplier_name = wiaas_get_organization_name($supplier_id);
if (!isset($suppliers[$supplier_id])){
$suppliers[$supplier_id] = array(
'id' => $supplier_id,
'name' => $supplier_name,
'estimated_date' => NULL,
'confirmed_date' => NULL,
'tracking_info' => array(),
'items' => array($product->id)
);
}else{
$suppliers[$supplier_id]['items'][] = $product->id;
$supplier_organization_id = $item['wiaas_supplier_organization_id'];
if (! empty($supplier_organization_id) && $item['wiaas_category'] !== 'installation' &&
empty($suppliers_info[$supplier_organization_id]) ) {
$suppliers_info[$supplier_organization_id] = array(
'id' => $supplier_organization_id,
'estimated_delivery_date' => null,
'confirmed_delivery_date' => null,
'tracking_info' => array(),
);
$supplier_organization_info = wiaas_get_organization_info($supplier_organization_id);
foreach ($supplier_organization_info as $key => $info) {
$suppliers_info[$supplier_organization_id][$key] = $info;
}
}
if (! empty($supplier_organization_id) && $item['wiaas_category'] === 'installation' &&
empty($installation_suppliers_info[$supplier_organization_id]) ) {
$installation_suppliers_info[$supplier_organization_id] = array(
'id' => $supplier_organization_id,
);
$supplier_organization_info = wiaas_get_organization_info($supplier_organization_id);
foreach ($supplier_organization_info as $key => $info) {
$installation_suppliers_info[$supplier_organization_id][$key] = $info;
}
}
}
$order->add_meta_data('_wiaas_suppliers', $suppliers, true);
$order->add_meta_data('_wiaas_delivery_suppliers', $suppliers_info, true);
$order->add_meta_data('_wiaas_installation_suppliers', $installation_suppliers_info, true);
// add additional date fields to order
$order->add_meta_data('_wiaas_estimated_delivery_date', NULL, true);
$order->add_meta_data('_wiaas_final_estimated_delivery_date', 0, true);
$order->add_meta_data('_wiaas_final_confirmed_delivery_date', 0, true);
$order->add_meta_data('_wiaas_earliest_installation_date', 0, true);
$order->add_meta_data('_wiaas_estimated_delivery_date', null, true);
$order->add_meta_data('_wiaas_final_estimated_delivery_date', null, true);
$order->add_meta_data('_wiaas_final_confirmed_delivery_date', null, true);
$order->add_meta_data('_wiaas_earliest_installation_date', null, true);
//add additional days prior installation field
$max_additional_days = 0;
// calculate number of days before earlier installation for whole order
$earliest_installation_additional_days = 0;
$items = $order->get_items('line_item');
foreach($items as $item){
$product = wc_get_product($item['product_id']);
if ($product->get_type() === 'bundle'){
$package_additional_days = Wiaas_Package::get_earliest_installation_additional_days($product->id);
if ($package_additional_days > $max_additional_days){
$max_additional_days = $package_additional_days;
}
foreach($items as $item) {
if (! empty($item['_wiaas_earliest_installation_additional_days'])) {
$additional_days = absint($item['_wiaas_earliest_installation_additional_days']);
$earliest_installation_additional_days = max($additional_days, $earliest_installation_additional_days);
}
}
$order->add_meta_data('_wiaas_order_additional_days_prior_installation', $max_additional_days, true);
$order->add_meta_data('_wiaas_order_additional_days_prior_installation', $earliest_installation_additional_days, true);
}

View File

@@ -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
*/

View File

@@ -6,7 +6,6 @@ class Wiaas_DB_Update {
private static $db_updates = array(
'20180801222206' => 'wiaas_db_update_setup_gravity',
'20180802222206' => 'wiaas_db_update_add_delivery_process_forms',
'20180811134511' => 'wiaas_db_update_enable_orders_access_management',
'20180911101010' => 'wiaas_db_setup_exclusive_taxonomies',
'20181003164100' => 'wiaas_db_setup_customer_capabilities',
@@ -24,7 +23,9 @@ class Wiaas_DB_Update {
'20181019064450' => 'wiaas_db_update_add_bundle_properties_ui_field',
'20191020014650' => 'wiaas_create_organization_roles_capabilities',
'20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities',
'20191102112451' => 'wiaas_disable_processing_order_email_delivery'
'20191102112451' => 'wiaas_disable_processing_order_email_delivery',
'20191131172850' => 'wiaas_db_update_update_delivery_forms',
'20191131182856' => 'wiaas_db_update_enable_workflow_inbox_for_roles'
);
public static function execute() {

View File

@@ -10,51 +10,73 @@ defined( 'ABSPATH' ) || exit;
class Wiaas_Delivery_Process {
private static $process_form_title_prefix = 'DELIVERY PROCESS:';
public static function init() {
self::_register_delivery_process_step_type();
self::_register_delivery_process();
self::_init_hooks();
}
private static function _init_hooks() {
add_filter( 'gform_entry_meta', array(__CLASS__, 'extend_gravity_form_entry_meta'), 10, 2 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_process_step'), 5, 3 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 3 );
// Some temporary functions to make inbox page prettier
add_filter('gravityflow_inbox_submitter_name', array(__CLASS__, 'display_step_name_in_inbox'), 10, 3);
add_filter('gravityflow_approve_label_workflow_detail', array(__CLASS__, 'approval_step_approval_label'), 10, 2);
add_filter('gravityflow_reject_label_workflow_detail', array(__CLASS__, 'approval_step_reject_label'), 10, 2);
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 2 );
}
public static function approval_step_approval_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Complete step', 'wiaas' );
}
return $label;
}
public static function approval_step_reject_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Cancel', 'wiaas' );
}
return $label;
}
public static function display_step_name_in_inbox($name, $entry, $form) {
return $entry['wiaas_delivery_step_name'];
}
/**
* Registers our Delivery Process Step Type as available Gravity Flow Step Type
*
* Registers our Delivery Process Addons
*
*/
private static function _register_delivery_process_step_type() {
private static function _register_delivery_process() {
require_once( 'delivery-process/class-wiaas-delivery-process-addon.php' );
require_once( 'delivery-process/class-wiaas-delivery-process-action.php' );
require_once( 'delivery-process/class-wiaas-delivery-process-step-assignee.php' );
require_once( 'delivery-process/class-wiaas-delivery-process-step.php' );
// order fields
require_once( 'delivery-process/class-wiaas-order-fields.php' );
require_once( 'delivery-process/class-wiaas-field-order-number.php' );
require_once( 'delivery-process/class-wiaas-field-order-bundle.php' );
require_once( 'delivery-process/class-wiaas-field-order-installation-select.php' );
require_once( 'delivery-process/class-wiaas-field-order-bundle-document.php' );
require_once( 'delivery-process/class-wiaas-field-order-document.php' );
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;
}
/**
@@ -63,9 +85,10 @@ class Wiaas_Delivery_Process {
* @param $form
*/
public static function maybe_complete_parent_order($entry_id, $form) {
$entry = GFAPI::get_entry($entry_id);
$order_id = $entry['wiaas_delivery_order_id'];
$order_id = $entry['wiaas_delivery_order_id'];
if (!isset($order_id)) {
return;
@@ -74,45 +97,181 @@ class Wiaas_Delivery_Process {
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
// order process entry completed, so complete order
if (absint($process_entry_id) === $entry_id) {
if (absint($process_entry_id) === absint($entry_id)) {
$order = wc_get_order($order_id);
$order->update_status('completed', 'Completed order delivery process.', true);
}
}
/**
* List available delivery processes
*
* @return array
*/
public static function get_available_delivery_processes(){
$forms = GFFormsModel::search_forms( self::$process_form_title_prefix, true );
$result = array();
foreach($forms as $form){
$result[] = array(
'title' => str_replace(self::$process_form_title_prefix, '', $form->title),
'id' => $form->id
);
}
public static function get_available_process_list_for_country($country_code) {
$forms = GFAPI::get_forms();
$available_process_forms = array();
foreach ($forms as $form) {
$delivery_settings = rgar($form, 'wiaas_delivery_process');
if ($delivery_settings['delivery_form_type'] === 'process' &&
$delivery_settings['delivery_country'] === $country_code) {
$available_process_forms[] = $form;
}
}
return $result;
}
return $available_process_forms;
}
public static function get_active_step($order_id){
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id');
if (empty($process_entry_id)) {
return null;
public static function get_customer_acceptance_data($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
$data = array();
if (! empty($delivery_process_entry)) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step)) {
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
$data[] = Wiaas_Delivery_Process_Action::get_customer_acceptance_action_data($action_entry['id']);
}
}
$process_instance = GFAPI::get_entry($process_entry_id);
$api = new Gravity_Flow_API($process_instance['form_id']);
$steps_info = $api->get_steps();
return empty( $data ) ? $data : $data[0];
}
foreach ( $steps_info as $step_info ) {
return $api->get_step( $step_info->get_id(), $process_instance );
}
return null;
}
public static function get_customer_questionnaires_data($order_id) {
$data = array();
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry)) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
if ($step && Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step)) {
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
foreach ($action_entries as $action_entry) {
$action_data = Wiaas_Delivery_Process_Action::get_customer_validate_questionnaires_action_data($action_entry['id']);
if (! empty($action_data)) {
$data[] = $action_data;
}
}
}
}
return $data;
}
public static function update_customer_acceptance_status($order_id, $status, $reason) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
Wiaas_Delivery_Process_Action::update_customer_acceptance_status($action_entry['id'], $status, $reason);
if ($status === 'accept') {
Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']);
}
}
}
public static function is_customer_acceptance_uploaded($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
return Wiaas_Delivery_Process_Action::is_customer_acceptance_uploaded($action_entry['id']);
}
return false;
}
public static function upload_customer_questionnaire($order_id, $action_entry_id) {
Wiaas_Delivery_Process_Action::upload_customer_questionnaire($action_entry_id);
Wiaas_Delivery_Process_Action::complete_action_step($action_entry_id);
}
public static function upload_customer_acceptance_document($order_id) {
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
if (! empty($delivery_process_entry) ) {
$workflow = new Gravity_Flow_API($delivery_process_entry['form_id']);
$step = $workflow->get_current_step($delivery_process_entry);
$action_entries = Wiaas_Delivery_Process_Action::get_process_step_action_entries($step);
$action_entry = $action_entries[0];
$success = Wiaas_Delivery_Process_Action::upload_customer_acceptance_document($action_entry['id']);
if ($success) {
Wiaas_Delivery_Process_Action::complete_action_step($action_entry['id']);
}
return $success;
}
return false;
}
public static function get_order_delivery_process_entry($order_id) {
$order = wc_get_order($order_id);
$process_entry_id = $order->get_meta('wiaas_delivery_process_entry_id', true);
if (empty($process_entry_id)) {
return array();
}
return GFAPI::get_entry($process_entry_id);
}
/**
* Retrieves delivery process instance for order
@@ -123,7 +282,8 @@ class Wiaas_Delivery_Process {
*/
public static function get_order_delivery_process($order_id) {
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id');
$process_entry_id = get_post_meta($order_id, 'wiaas_delivery_process_entry_id', true);
if (empty($process_entry_id)) {
return null;
}
@@ -139,117 +299,57 @@ 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,
)
)
);
foreach ( $steps_info as $step_info ) {
$step = $api->get_step( $step_info->get_id(), $process_instance );
$current_step = $api->get_current_step($process_instance);
foreach ( $steps_info as $step_info ) {
$step = $api->get_step( $step_info->get_id(), $process_instance );
if (! $step->is_visible_to_customer) {
continue;
}
$action_code = Wiaas_Delivery_Process_Action::get_process_step_action_form_action_code($step);
$info = $step->get_feed_meta();
$status = $step->get_status();
if ($current_step && $current_step->get_id() === $step->get_id()) {
$status = 'pending';
}
$delivery_process['steps'][] = array(
'step_id' => $step->get_id(),
'step_form_entry_id' => $step->get_target_form_entry_id() ?: null,
'process_id' => $process_entry_id,
'short_desc' => $info['step_name'],
'full_desc' => $info['description'],
'action_code' => $step->get_delivery_action_type(),
'step_type' => $step->get_delivery_action_type() === 'manual' ? 'manual' : 'extraAction',
'status' => $step->get_status() ?: 'inactive',
'action_code' => $action_code,
'status' => $status,
'order_id' => $order_id,
'actual_date' => $step->get_target_actual_date(),
'comments' => $step->get_target_step_comments(),
);
}
return $delivery_process;
}
/**
* create delivery process instance
* @param $order_id
*/
public static function create_delivery_process_for_order($order_id, $form_id) {
$process_form = null;
$forms = GFFormsModel::search_forms( self::$process_form_title_prefix, true );
$process_form = GFFormsModel::get_form($form_id);
if(isset($process_form)) {
$order = wc_get_order( $order_id );
$new_process_entry = array(
'form_id' => $process_form->id,
'2' => $order->get_customer_id(),
'wiaas_delivery_order_id' => $order_id,
);
$process_entry_id = GFAPI::add_entry( $new_process_entry );
add_post_meta($order_id, 'wiaas_delivery_process_id', $process_form->id);
add_post_meta($order_id, 'wiaas_delivery_process_entry_id', $process_entry_id);
return true;
}
return false;
}
/**
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
*
* This way we can track for each delivery step its parent process
* @param $entry_meta
*
* @return mixed
*/
public static function extend_gravity_form_entry_meta($entry_meta) {
$entry_meta[ 'wiaas_delivery_process_id' ] = array(
'label' => 'Wiaas Delivery Process Id',
'is_numeric' => true,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_order_id' ] = array(
'label' => 'Wiaas Delivery Process Order Id',
'is_numeric' => true,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
$entry_meta[ 'wiaas_delivery_step_name' ] = array(
'label' => 'Wiaas Delivery Step name',
'is_numeric' => false,
'update_entry_meta_callback' => null,
'is_default_column' => false, // this column will be displayed by default on the entry list
'filter' => array(
'operators' => array( 'is' ),
),
);
return $entry_meta;
}
/**
* Process parent process when single step workflow has completed
* @param $entry_id
* @param $form
* @param $final_status
*/
public static function maybe_complete_parent_process_step($entry_id, $form) {
$entry = GFAPI::get_entry($entry_id);
$parent_entry_id = $entry['wiaas_delivery_process_id'];
if (empty($parent_entry_id)) {
return false;
}
$parent_entry_id = absint( $parent_entry_id );
$parent_entry = GFAPI::get_entry( $parent_entry_id );
$parent_api = new Gravity_Flow_API( $parent_entry['form_id'] );
$parent_api->process_workflow( $parent_entry_id );
}
}
add_action( 'gravityflow_loaded', array('Wiaas_Delivery_Process', 'init') );

View File

@@ -18,6 +18,7 @@ class Wiaas_Order {
public static function init() {
require_once dirname( __FILE__ ) . '/order/class-wiaas-order-project.php';
require_once dirname( __FILE__ ) . '/order/wiaas-order-functions.php';
add_filter('woocommerce_register_post_type_shop_order', array(__CLASS__, 'manage_order_settings'));
@@ -59,7 +60,7 @@ class Wiaas_Order {
);
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_suppliers', $suppliers);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
@@ -77,7 +78,7 @@ class Wiaas_Order {
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_suppliers', $suppliers);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
@@ -93,7 +94,7 @@ class Wiaas_Order {
unset($suppliers[$key]['tracking_info'][$tracking_index]);
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_suppliers', $suppliers);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
$order->save_meta_data();
return true;
}
@@ -118,7 +119,7 @@ class Wiaas_Order {
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_suppliers', $suppliers);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
self::_update_max_and_earliest_dates($order, $suppliers);
$order->save_meta_data();
@@ -126,8 +127,10 @@ class Wiaas_Order {
}
public static function save_confirmed_date($order_id, $supplier_id, $date){
$suppliers = self::get_suppliers($order_id);
$updated = false;
foreach($suppliers as $key => $supplier){
if ($supplier['id'] === $supplier_id){
$suppliers[$key]['confirmed_date'] = $date;
@@ -144,7 +147,7 @@ class Wiaas_Order {
$order = wc_get_order($order_id);
$order->update_meta_data('_wiaas_suppliers', $suppliers);
$order->update_meta_data('_wiaas_delivery_suppliers', $suppliers);
self::_update_max_and_earliest_dates($order, $suppliers);
$order->save_meta_data();
@@ -197,7 +200,7 @@ class Wiaas_Order {
*/
public static function get_suppliers($order_id){
$order = wc_get_order($order_id);
return $order->get_meta('_wiaas_suppliers');
return $order->get_meta('_wiaas_delivery_suppliers');
}
/**
@@ -357,46 +360,31 @@ class Wiaas_Order {
$max_confirmed_date = 0;
$earliest_installation_date = 0;
$missing_estimated = false;
$missing_confirmed = false;
$no_earliest = false;
foreach($suppliers as $supplier){
if (!$supplier['estimated_date']){
$missing_estimated = true;
}
if (!$supplier['confirmed_date']){
foreach($suppliers as $supplier) {
if (! empty($supplier['confirmed_date']) ) {
$max_confirmed_date = max($max_confirmed_date, $supplier['confirmed_date']);
} else {
$missing_confirmed = true;
}
if ($supplier['estimated_date'] > $max_estimated_date){
$max_estimated_date = $supplier['estimated_date'];
}
if ($supplier['confirmed_date'] > $max_confirmed_date){
$max_confirmed_date = $supplier['confirmed_date'];
}
if (! empty($supplier['estimated_date']) ) {
if (!$no_earliest){
$supplier_date = $supplier['estimated_date'];
if ($supplier['confirmed_date'] > $supplier_date){
$supplier_date = $supplier['confirmed_date'];
}
if ($supplier_date > 0){
if ($supplier_date > $earliest_installation_date){
$earliest_installation_date = $supplier_date;
}
}else{
$no_earliest = true;
$earliest_installation_date = 0;
}
$max_estimated_date = max($max_estimated_date, $supplier['estimated_date']);
} else {
$missing_estimated = true;
$earliest_installation_date = 0;
}
}
if ($missing_estimated && $missing_confirmed){
$no_earliest = true;
$earliest_installation_date = 0;
}
if (! $missing_estimated) {
if (!$no_earliest){
$earliest_installation_date = max($max_estimated_date, $max_confirmed_date);
$earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order->id) . ' days', $earliest_installation_date);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,59 +17,6 @@ function wiaas_db_update_setup_gravity() {
update_option('gravityflow_pending_installation', false);
}
function wiaas_db_update_add_delivery_process_forms() {
$action_type_forms_files = array(
'delivery_action_customer_acceptance_form',
'delivery_action_schedule_meeting',
'delivery_action_validate_questionnaire_form',
'delivery_action_manual_form',
);
// Since import action will generate form with new id, we need to remember this mapping
// so we can update process delivery steps to point to correct form ids
$action_type_forms_ids_mappings = array();
$process_forms_files = array(
'delivery_process_normal_delivery_form'
);
$created_forms = array();
// import forms for delivery action types
foreach ($action_type_forms_files as $action_type_form_file) {
$form_json = file_get_contents( dirname( __FILE__ ) . "/data/delivery-forms/" . $action_type_form_file . '.json' );
$form_meta = json_decode( $form_json, true );
$form_meta = $form_meta[0];
$form_id = GFAPI::add_form($form_meta);
$created_forms[] = GFAPI::get_form($form_id);
$action_type_forms_ids_mappings[$form_meta['id']] = $form_id;
}
// import forms for delivery process
foreach ($process_forms_files as $process_form_file) {
$form_json = file_get_contents( dirname( __FILE__ ) . "/data/delivery-forms/" . $process_form_file . '.json' );
$form_meta = json_decode( $form_json, true );
$form_meta = $form_meta[0];
// update delivery steps forms ids with correct values
foreach ($form_meta['feeds']['gravityflow'] as $key => $process_step_meta) {
$process_step_target_form_id = $form_meta['feeds']['gravityflow'][$key]['meta']['target_form_id'];
$form_meta['feeds']['gravityflow'][$key]['meta']['target_form_id'] = $action_type_forms_ids_mappings[$process_step_target_form_id];
}
$form_id = GFAPI::add_form($form_meta);
$created_forms[] = GFAPI::get_form($form_id);
}
do_action('gform_forms_post_import', $created_forms);
}
function wiaas_db_update_enable_orders_access_management() {
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
@@ -138,4 +85,40 @@ function wiaas_disable_processing_order_email_delivery() {
'heading' => '',
'mail_type' => 'html'
) );
}
function wiaas_db_update_update_delivery_forms() {
$forms = GFAPI::get_forms();
foreach ($forms as $form) {
RGFormsModel::update_form_active($form['id'], false);
}
$created_forms = array();
$actions_forms_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-action-forms.json' );
$action_forms_meta = json_decode( $actions_forms_json, true );
foreach ($action_forms_meta as $action_form_meta) {
$form_id = GFAPI::add_form($action_form_meta);
$created_forms[] = GFAPI::get_form($form_id);
}
$sample_form_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-process-sample-form.json' );
$sample_form = json_decode( $sample_form_json, true );
$sample_form = $sample_form[0];
$sample_form_id = GFAPI::add_form($sample_form);
RGFormsModel::update_form_active($sample_form_id, false);
$created_forms[] = GFAPI::get_form($sample_form_id);
do_action('gform_forms_post_import', $created_forms);
}

View File

@@ -315,4 +315,12 @@ function wiaas_admin_create_role_access_groups() {
function wiaas_db_update_update_supplier_order_capabilities() {
// add supplier role to view orders
wp_roles()->add_cap( 'supplier', 'edit_shop_orders' );
}
function wiaas_db_update_enable_workflow_inbox_for_roles() {
// add workflow inbox for supplier
wp_roles()->add_cap( 'supplier', 'gravityflow_inbox' );
// add workflow inbox for commercial lead
wp_roles()->add_cap( 'commercial_lead', 'gravityflow_inbox' );
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,251 @@
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
class Wiaas_Order_Fields {
public static function init() {
add_action( 'gform_field_standard_settings', array( __CLASS__, 'field_settings' ) );
add_filter('gform_fileupload_entry_value_file_path', array( __CLASS__, 'display_order_document_fields' ), 999, 2);
}
/**
* Adds the Order Fields group to the form editor.
*
* @param array $field_groups The properties for the field groups.
*
* @return array
*/
public static function maybe_add_order_field_group( $field_groups ) {
foreach ( $field_groups as $field_group ) {
if ( $field_group['name'] == 'wiaas_order_fields' ) {
return $field_groups;
}
}
$field_groups[] = array(
'name' => 'wiaas_order_fields',
'label' => __( 'Order Fields', 'wiaas' ),
'fields' => array()
);
return $field_groups;
}
public static function display_order_document_fields($file_path, $field) {
if (strpos($file_path, 'gf-download') === false &&
strpos($file_path, 'gf-wiaas-order-doc') === false) {
$field = new Wiaas_Field_Order_Bundle_Document();
return $field->get_download_url($file_path);
}
return $file_path;
}
/**
* Add custom settings for form order fields
*
* @param int $position
*/
public static function field_settings( $position ) {
if ( $position === 20 ) {
// After Field description setting.
?>
<li class="wiaas_doc_type_filter field_setting">
<label for="wiaas-doc-type-filter" class="section_label">
<?php esc_html_e( 'Document Type', 'wiaas' ); ?>
</label>
<select id="wiaas-doc-type-filter" onchange="SetFieldProperty('wiaasDocTypeFilter',this.value);">
<option value="configuration"><?php esc_html_e( 'Configuration', 'wiaas' ); ?></option>
<option value="order_questionaire"><?php esc_html_e( 'Order Questionaire', 'wiaas' ); ?></option>
<option value="installation_protocol"><?php esc_html_e( 'Installation protocol', 'wiaas' ); ?></option>
<option value="install_guide"><?php esc_html_e( 'Installation Guide', 'wiaas' ); ?></option>
<option value="customer_acceptance"><?php esc_html_e( 'Customer acceptance', 'wiaas' ); ?></option>
</select>
</li>
<li class="wiaas_installation_organization_filter field_setting">
<input type="checkbox" id="wiaas-installation-organization-filter"
onclick="var value = jQuery(this).is(':checked'); SetFieldProperty('wiaasOnlyInstallationOrg', value);""/>
<label for="wiaas-installation-organization-filter" class="inline">
<?php esc_html_e( 'Only installation', 'wiaas' ); ?>
</label>
</li>
<?php
}
}
public static function get_value_from_order_field($entry, $field) {
switch ($field->type) {
case 'wiaas_order_bundle':
$value = $entry[$field->id];
list ($order_id, $item_id) = explode('|', $value);
if ( ! empty($order_id) && ! empty($item_id)) {
return array(
'id' => $item_id,
'name' => $field->get_selected_bundle_display_name($value)
);
}
return null;
case '':
}
}
public static function map_order_to_entry($order_id, $form, $bundle_item_id = null) {
if (empty($form['fields']) ||
empty(GFCommon::get_fields_by_type( $form, array('wiaas_order')) ) ) {
// form does not have order field so cannot be mapped
return false;
}
$order = wc_get_order($order_id);
$entry = array();
foreach ($form['fields'] as $field) {
switch ($field->type) {
case 'wiaas_order':
$entry[(string) $field->id] = $order->get_id();
break;
case 'workflow_user':
$entry[(string) $field->id] = $order->get_customer_id(); // save customer if needed
break;
case 'wiaas_order_bundle':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty($bundle_item)) {
$entry[(string) $field->id] = $order->get_id() . '|' . $bundle_item->get_id();
}
break;
case 'wiaas_order_bundle_document':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty($bundle_item)) {
$documents = wiaas_get_standard_package_order_item_documents($order, $bundle_item_id);
$filtered_documents = array();
foreach ($documents as $document) {
if ($document['type'] === $field->wiaasDocTypeFilter) {
$filtered_documents[] = $document;
}
}
if ( empty($filtered_documents) && $field->isRequired ) {
// there is no data for required field so entry cannot be created
return false;
}
if (! empty ($filtered_documents) && ! $field->multipleFiles) {
$document = $filtered_documents[0];
$entry[$field->id] = $document['version'];
} else if (! empty ($filtered_documents) ) {
$versions = array();
foreach ($filtered_documents as $filtered_document) {
$versions[] = $filtered_document['version'];
}
$entry[$field->id] = json_encode($versions);
}
}
break;
case 'wiaas_order_installation_select':
$bundle_item = $order->get_item($bundle_item_id);
if ( empty($bundle_item) && $field->isRequired) {
// there is no data for required field so entry cannot be created
return false;
}
$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';
}
}
}
return $entry;
}
}
Wiaas_Order_Fields::init();

View File

@@ -12,6 +12,35 @@ class Wiaas_Document_Download {
if ( isset($_GET['wiaasdoc']) ) {
add_action( 'init', array( __CLASS__, 'admin_download' ) );
}
if (isset($_GET['gf-wiaas-order-doc'])) {
add_action( 'init', array( __CLASS__, 'admin_gf_order_document_download' ) );
}
}
/**
* Handle download for order documents by gravity flow steps
*/
public static function admin_gf_order_document_download() {
if (!is_user_logged_in()) {
wp_die( __( 'No Access.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 403 ) );
}
// relative file path from upload dir for document
$version = urldecode($_GET['gf-wiaas-order-doc']);
$file_path = wiaas_get_document_version_path($version);
if (!file_exists($file_path)) {
wp_die( __( 'Document not found.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
}
WC_Download_Handler::download_file_force(
$file_path,
pathinfo( $file_path, PATHINFO_FILENAME ) . '.' . pathinfo( $file_path, PATHINFO_EXTENSION )
);
}
/**

View File

@@ -187,4 +187,39 @@ function wiaas_get_standard_package_order_item_documents($order, $package_item_i
return $doc;
}, $order_documents);
}
/**
* Retrieve documents for order item
*
* @param $order_item
* @param string|null $doc_type
*
* @return array {
* $param string key Unique key used for frontend downloand
* $param string name Document name visible in download link
* $param string version Relative path from upload directory to physical document file
* $param string type Document type
*
* @reference Wiaas_Document
* }
*/
function wiaas_get_order_item_documents($order_item, $doc_type = null) {
$documents = empty($order_item['wiaas_documents']) ? array() : $order_item['wiaas_documents'];
if (empty($doc_type)) {
return $documents;
}
$filtered_documents = array();
foreach ($documents as $document) {
if ($document['type'] === $doc_type) {
$filtered_documents[] = $document;
}
}
return $filtered_documents;
}

View File

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

View File

@@ -68,15 +68,24 @@ class Wiaas_Product_Supplier {
* Retrieve organisation id of the supplier of the product
*
* @param $product_id
* @return int organization_id
* @return int|false organization_id
*/
public static function get_supplier_organisation_id_from_product($product_id) {
$supplier_terms = wp_get_object_terms($product_id, 'supplier');
$supplier_organisation_slug = $supplier_terms[0]->slug;
$supplier_organisation_id = get_term_by('slug', $supplier_organisation_slug, 'wiaas-user-organization')->term_id;
if (empty( $supplier_terms )) {
return $supplier_organisation_id;
return false;
}
$supplier_organisation_slug = $supplier_terms[0]->slug;
$supplier_organisation = get_term_by('slug', $supplier_organisation_slug, 'wiaas-user-organization');
if ($supplier_organisation) {
return $supplier_organisation->term_id;
}
return $supplier_organisation ? $supplier_organisation->term_id : false;
}
}

View File

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

View File

@@ -49,6 +49,7 @@
"johnpbloch/wordpress": "4.9.7",
"oscarotero/env": "1.1.0",
"roots/wp-password-bcrypt": "1.0.0",
"phpoffice/phpspreadsheet": "1.5",
"woocommerce/woocommerce": "3.5.0",
"3rdparty/woocommerce-product-bundles": "*",

232
backend/composer.lock generated
View File

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

View File

@@ -19,7 +19,7 @@ export const fetchNextActions = () => {
return dispatch => {
dispatch(requestNextActions());
return client.fetch({
url: `${API_SERVER}/wp-json/wiaas/next-delivery-steps`
url: `${API_SERVER}/wp-json/wiaas/delivery/next-actions`
})
.then(response => dispatch(recieveNextActions(response.data)))
.catch(error => {

View File

@@ -23,11 +23,11 @@ const recieveCustomerAcceptance = (json) => ({
customerAcceptance: json
});
export const fetchCustomerAcceptance = (idEntry) => {
export const fetchCustomerAcceptance = (idOrder) => {
return dispatch => {
dispatch(requestCustomerAcceptance());
return htmlClient.fetch({
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance`,
method: 'get'
})
.then(response => {
@@ -45,15 +45,15 @@ const uploadAcceptanceAction = () => ({
type: UPLOAD_CUSTOMER_ACCEPTANCE
});
export const uploadAcceptance = (idEntry, file) => {
export const uploadAcceptance = (idOrder, file) => {
return dispatch => {
dispatch(uploadAcceptanceAction());
return htmlClient.uploadFile(file, {
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}/upload-file`
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance/upload`
}).then(response => {
if (typeof response.data !== 'undefined') {
dispatch(updateMessages(response.data.messages, orderMessages));
dispatch(fetchCustomerAcceptance(idEntry));
dispatch(fetchCustomerAcceptance(idOrder));
}
}).catch(error => {
htmlClient.onError(error, dispatch);
@@ -71,21 +71,21 @@ const sendCustomerAcceptance = () => ({
type: SEND_CUSTOMER_ACCEPTANCE
});
export const acceptDeclineInstallation = (idEntry, actionType, declineReason) => {
export const acceptDeclineInstallation = (idOrder, actionType, declineReason) => {
return dispatch => {
dispatch(sendCustomerAcceptance());
return htmlClient.fetch({
url: `${API_SERVER}/wp-json/wiaas/customer-acceptance/${idEntry}`,
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-acceptance`,
method: 'post',
data: {
actionType,
declineReason
'action_type': actionType,
'decline_reason': declineReason
}
})
.then(response => {
if (response.data) {
dispatch(updateMessages(response.data.messages, orderMessages));
dispatch(fetchCustomerAcceptance(idEntry));
dispatch(fetchCustomerAcceptance(idOrder));
}
})
.catch(error => {

View File

@@ -0,0 +1,68 @@
import {
API_SERVER
} from '../../config';
import {
UPLOAD_CUSTOMER_QUESTIONNAIRE,
REQUEST_CUSTOMER_QUESTIONNAIRES,
RECEIVE_CUSTOMER_QUESTIONNAIRES,
orderMessages, REQUEST_CUSTOMER_ACCEPTANCE, RECEIVE_CUSTOMER_ACCEPTANCE, UPLOAD_CUSTOMER_ACCEPTANCE
} from '../../constants/ordersConstants';
import {
updateMessages
} from '../notification/notificationActions';
import HtmlClient from '../../helpers/HtmlClient';
import {fetchCustomerAcceptance} from "./customerAcceptanceActions";
const htmlClient = new HtmlClient();
const requestCustomerQuestionnaires = () => ({
type: REQUEST_CUSTOMER_QUESTIONNAIRES
});
const receiveCustomerQuestionnaires = (json) => ({
type: RECEIVE_CUSTOMER_QUESTIONNAIRES,
customerQuestionnaires: json
});
const uploadCustomerQuestionnaireAction = () => ({
type: UPLOAD_CUSTOMER_QUESTIONNAIRE
});
export const fetchCustomerQuestionnaires = (idOrder) => {
return dispatch => {
dispatch(requestCustomerQuestionnaires());
return htmlClient.fetch({
url: `${API_SERVER}/wp-json/wiaas/delivery/${idOrder}/customer-questionnaires`,
method: 'get'
})
.then(response => {
if (typeof response.data !== 'undefined') {
dispatch(receiveCustomerQuestionnaires(response.data));
}
})
.catch(error => {
htmlClient.onError(error, dispatch);
});
}
}
export const uploadCustomerQuestionnaire = (orderId, actionId, file) => {
return dispatch => {
dispatch(uploadCustomerQuestionnaireAction());
return htmlClient.uploadFile(file, {
url: `${API_SERVER}/wp-json/wiaas/delivery/${orderId}/customer-questionnaires/upload/${actionId}`,
}).then(response => {
if (typeof response.data !== 'undefined') {
dispatch(updateMessages(response.data.messages, orderMessages));
dispatch(fetchCustomerQuestionnaires(orderId));
}
}).catch(error => {
htmlClient.onError(error, dispatch);
});
}
}

View File

@@ -46,6 +46,10 @@ export const SET_VIEW_ALL_ORDERS = MODULE + 'SET_VIEW_ALL_ORDERS';
export const REQUEST_ALL_SHIPPING_DATES_CONFIRMED = MODULE + 'REQUEST_ALL_SHIPPING_DATES_CONFIRMED';
export const RECEIVE_ALL_SHIPPING_DATES_CONFIRMED = MODULE + 'RECEIVE_ALL_SHIPPING_DATES_CONFIRMED';
export const UPLOAD_CUSTOMER_QUESTIONNAIRE = MODULE + 'UPLOAD_CUSTOMER_QUESTIONNAIRE';
export const REQUEST_CUSTOMER_QUESTIONNAIRES = MODULE + 'REQUEST_CUSTOMER_QUESTIONNAIRES';
export const RECEIVE_CUSTOMER_QUESTIONNAIRES = MODULE + 'RECEIVE_CUSTOMER_QUESTIONNAIRES';
export const orderMessages = {
SYSTEM_ALLOWED_LANGUAGES_EMPTY: 'There are no languages added in the system.',
ALLOWED_LANGUAGE: 'Allowed languages are:',

View File

@@ -61,7 +61,7 @@ class CartUploadDocument extends Component {
</div>
<Dropzone className={classnames('upload-file-drop-zone', { 'pending-upload': !uploadedDocument })}
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods"
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods, .zip"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(cartItem.key, idDocumentType, acceptedFiles, rejectedFiles, packages)}}>
{
uploadedDocument

View File

@@ -31,10 +31,10 @@ class CustomerAcceptance extends Component {
fileHandler.download(fileUrl, fileName);
}
uploadFile(idEntry, acceptedFiles, rejectedFiles) {
uploadFile(idOrder, acceptedFiles, rejectedFiles) {
if(acceptedFiles && acceptedFiles.length){
const file = acceptedFiles[0];
this.props.dispatch(uploadAcceptance(idEntry, file));
this.props.dispatch(uploadAcceptance(idOrder, file));
}
if(rejectedFiles && rejectedFiles.length) {
@@ -59,9 +59,9 @@ class CustomerAcceptance extends Component {
}
acceptDeclineInstallation() {
const {idProcess} = this.props.step;
const {idOrder} = this.props.step;
const {actionType, reason} = this.state;
this.props.dispatch(acceptDeclineInstallation(idProcess, actionType, reason));
this.props.dispatch(acceptDeclineInstallation(idOrder, actionType, reason));
this.setState({reason: ''});
}
@@ -107,8 +107,8 @@ class CustomerAcceptance extends Component {
}
componentDidMount(){
const {idProcess} = this.props.step;
this.props.dispatch(fetchCustomerAcceptance(idProcess));
const {idOrder} = this.props.step;
this.props.dispatch(fetchCustomerAcceptance(idOrder));
}
render() {
@@ -135,9 +135,9 @@ class CustomerAcceptance extends Component {
<Col xl="4" lg="5" md="4">
<Dropzone className="upload-file-drop-zone"
multiple={false}
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods,.jpg,.png,.jpeg"
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods,.jpg,.png,.jpeg, .zip"
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idProcess, acceptedFiles, rejectedFiles)}}>
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
<h5 className="drop-zone-text">{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}</h5>
</Dropzone>
</Col>
@@ -148,7 +148,7 @@ class CustomerAcceptance extends Component {
{
customerAcceptance.documents.map((document, index) => <div key={'acceptance-documnet-' + index}>
<span className="document-link">
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} ({document.extension}) </a>
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
</span>
<span className="document-status">
{document.validation} <div className={'status-icon ' + document.validation}></div>

View File

@@ -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>

View File

@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {fetchCustomerDocuments, fetchValidationComments} from '../../../../actions/orders/processActions';
import {fetchCustomerQuestionnaires} from '../../../../actions/orders/customerQuestionnairesActions';
import ValidateQuestionnaireItem from './ValidateQuestionnaireItem.jsx';
import '../../style/ValidateQuestionnaire.css';
@@ -8,7 +8,7 @@ class ValidateQuestionnaire extends Component {
componentDidMount(){
const {idOrder, idProcessStep} = this.props.step;
//this.props.dispatch(fetchCustomerDocuments(idOrder, 'orderQuestionaire'));
this.props.dispatch(fetchCustomerQuestionnaires(idOrder));
//this.props.dispatch(fetchValidationComments(idOrder, idProcessStep, 'invalidQuestionnaireComment'));
}
@@ -18,18 +18,18 @@ class ValidateQuestionnaire extends Component {
}
render() {
const {customerDocuments, validationComments, orderPackages} = this.props;
const {customerQuestionnaires, orderPackages} = this.props;
return (
<div id="validate-questionnaire" className="validate-questionnaire">
{
customerDocuments &&
Object.keys(customerDocuments).map((idOrderPackagePair) =>
customerQuestionnaires &&
customerQuestionnaires.map((customerQuestionnaryAction) =>
<ValidateQuestionnaireItem
customerDocuments={customerDocuments[idOrderPackagePair]}
validationComments={validationComments && validationComments[idOrderPackagePair] ? validationComments[idOrderPackagePair] : []}
orderPackage={orderPackages.find((orderPackage)=>{ return this.findById(orderPackage, idOrderPackagePair)})}
key={'validate-questionnaire-' + idOrderPackagePair}/>
action={customerQuestionnaryAction}
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
/>
)
}
</div>
@@ -38,8 +38,7 @@ class ValidateQuestionnaire extends Component {
}
const mapStateToProps = (state) => ({
customerDocuments: state.processReducer.customerDocuments,
validationComments: state.processReducer.validationComments,
customerQuestionnaires: state.processReducer.customerQuestionnaires,
orderPackages: state.processReducer.orderInfo.packages
});

View File

@@ -2,7 +2,7 @@ import React, {Component} from 'react';
import {connect} from 'react-redux';
import Dropzone from 'react-dropzone';
import {Row, Col} from 'reactstrap';
import {reUploadOrderDocument, badFile} from '../../../../actions/orders/processActions';
import {uploadCustomerQuestionnaire, badFile} from '../../../../actions/orders/customerQuestionnairesActions';
import {API_SERVER} from '../../../../config';
import FileDownloader from '../../../../helpers/FileDownloader';
import {orderTexts} from '../../../../constants/ordersConstants';
@@ -16,48 +16,50 @@ class ValidateQuestionnaireItem extends Component {
fileHandler.download(fileUrl, fileName);
}
uploadFile(idPackage, idOrder, idDocument,acceptedFiles, rejectedFiles) {
uploadFile(action,acceptedFiles, rejectedFiles) {
if(acceptedFiles && acceptedFiles.length){
const file = acceptedFiles[0];
this.props.dispatch(reUploadOrderDocument(idPackage, idOrder, idDocument, file));
this.props.dispatch(uploadCustomerQuestionnaire(action.order_id, action.action_id, file));
}
if(rejectedFiles && rejectedFiles.length) {
this.props.dispatch(badFile());
}
// if(rejectedFiles && rejectedFiles.length) {
// this.props.dispatch(badFile());
// }
}
render() {
const {customerDocuments, validationComments, orderPackage} = this.props;
const {action, orderPackage} = this.props;
const customerDocuments = [ action.document ];
return (
<div id="validate-questionnaire" className="validate-questionnaire">
{
customerDocuments &&
<div>
{orderPackage.packageName}
{orderPackage.name}
{
customerDocuments.map(document => <div key={'package-document-' + document.idDocument}>
customerDocuments.map(document => <div key={'package-document-' + document.key}>
{
document.validation === 'invalid'
action.status === 'invalid'
? <div className="package-document">
<Row>
<Col xl="7" lg="8">
<div>
<span className="document-link"
onClick={() => {this.downloadDocument(document)}}>
<i className={'fa fa-file'}></i> {document.documentName} ({document.extension}) {' '}
<span className="document-link">
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
</span>
<br />
<span className="document-status">
{document.validation.replace(/-/g,' ')} <div className={'status-icon ' + document.validation}></div>
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
</span>
</div>
{
(validationComments && validationComments.length > 0) &&
(action.comments && action.comments.length > 0) &&
<div>
{validationComments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
<div>{comment.user} - {comment.addDate}</div>
<div>{comment.comment}</div>
{action.comments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
<div>{comment}</div>
</div>)}
</div>
}
@@ -65,9 +67,9 @@ class ValidateQuestionnaireItem extends Component {
<Col xl="5">
<Dropzone className="upload-file-drop-zone"
multiple={false}
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods"
accept=".pdf,.docx,.doc,.xlsx,.xls,.odt,.ods, .zip"
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(document.idPackage, document.idOrder, document.idDocument, acceptedFiles, rejectedFiles)}}>
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
<h5 className="drop-zone-text">{orderTexts.labels.SELECT_OR_DROP}</h5>
</Dropzone>
</Col>
@@ -76,12 +78,12 @@ class ValidateQuestionnaireItem extends Component {
: <div className="package-document">
<Row>
<Col>
<span className="document-link"
onClick={() => {this.downloadDocument(document)}}>
<i className={'fa fa-file'}></i> {document.documentName} ({document.extension}) {' '}
<span className="document-link">
<i className={'fa fa-file'}></i> <a target="_blank" href={document.url}> {document.name} </a>
</span>
<br />
<span className="document-status">
{document.validation.replace(/-/g,' ')} <div className={'status-icon ' + document.validation}></div>
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
</span>
</Col>
</Row>

View File

@@ -46,7 +46,7 @@ class HtmlClient {
let formData = new FormData();
formData.append('file', file, file.name);
if(configParams) {
if(configParams && configParams.data) {
Object.keys(configParams.data).forEach((paramKey) => {
formData.append(paramKey, configParams.data[paramKey]);

View File

@@ -11,10 +11,15 @@ function formatAddress(addressObject) {
}
export const fromWCOrder = (WCOrder) => {
let processInfo = Object.assign({},WCOrder['delivery-process']);
if (WCOrder['delivery-process']){
let processInfo = undefined;
if (WCOrder['delivery-process']) {
processInfo = Object.assign({},WCOrder['delivery-process']);
processInfo.steps = WCOrder['delivery-process'].steps.map(step=>fromWiaasProcessStep(step));
}
return {
id: WCOrder.id,
number: WCOrder.number,

View File

@@ -3,17 +3,14 @@ import moment from "moment";
export const fromWiaasProcessStep = (step) => {
return {
actionCode: step.action_code,
actualDate: step.actual_date,
comments: step.comments,
fullDesc: step.full_desc,
idOrder: step.order_id,
idProcess: step.step_form_entry_id, //not sure about this
idProcess: step.process_id, //not sure about this
idProcessStep: step.step_id, //not sure about this
isNewCommentVisible: 1, //TODO : get this from backend
isVisibleForCustomer: 1, //TODO : get this from backend
now: moment().format("Do MMM YY"),
shortDesc: step.short_desc,
status: step.status,
stepType: step.step_type,
}
};

View File

@@ -4,6 +4,7 @@ import {
RECEIVE_CUSTOMER_DOCUMENTS,
RECEIVE_VALIDATION_COMMENTS,
RECEIVE_CUSTOMER_ACCEPTANCE,
RECEIVE_CUSTOMER_QUESTIONNAIRES,
RECEIVE_IS_COMPONENT_DISABLED,
RECEIVE_IS_NEXT_STEP_WANTED,
SET_EARLIEST_INSTALLATION_DATE,
@@ -53,6 +54,14 @@ moduleReducers[RECEIVE_CUSTOMER_ACCEPTANCE] = (state, action) => {
});
};
moduleReducers[RECEIVE_CUSTOMER_QUESTIONNAIRES] = (state, action) => {
return Object.assign({}, state, {
customerQuestionnaires: action.customerQuestionnaires
});
};
moduleReducers[RECEIVE_IS_COMPONENT_DISABLED] = (state, action) => {
const newState = {isComponentDisabled : {}};
newState.isComponentDisabled.installationScheduling = state.isComponentDisabled && state.isComponentDisabled.installationScheduling