Merge branch 'master' into package-details

This commit is contained in:
Almira Krdzic
2018-09-06 23:30:03 +02:00
53 changed files with 2053 additions and 621 deletions

View File

@@ -1,6 +1,24 @@
<?php
class Wiass_REST_Delivery_Process_API {
const BASE_NAME = WP_HOME . '/';
const FILE_KEY_NAME = 'file';
const PATH_PARTS_TO_EXTRACT = 7;
const ACCEPTANCE_STATUS_FIELD_ID = 8;
const EXPIRATION_DATE_FIELD_ID = 9;
const DECLINE_REASON_FIELD_ID = 10;
const UPLOADED_FILES_FIELD_ID = 12;
const USER_INPUT_STEP_NAME = 'Upload acceptance file';
const ACCEPT_STATUS_LABEL = 'accept';
const DECLINE_STATUS_LABEL = 'decline';
const ACCEPTABLE_STATUS = [self::ACCEPT_STATUS_LABEL, self::DECLINE_STATUS_LABEL];
/**
* Endpoint namespace.
*
@@ -14,8 +32,25 @@ class Wiass_REST_Delivery_Process_API {
'methods' => 'GET',
'callback' => array(__CLASS__, 'get_next_actions_for_user'),
) );
}
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)', array(
'methods' => 'GET',
'callback' => array(__CLASS__, 'get_customer_acceptance'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)', array(
'methods' => 'POST',
'callback' => array(__CLASS__, 'submit_customer_acceptance'),
'permission_callback' => 'is_user_logged_in'
) );
register_rest_route( self::$namespace, 'customer-acceptance/(?P<entry_id>\d+)/upload-file' , array(
'methods' => 'POST',
'callback' => array(__CLASS__, 'upload_file'),
'permission_callback' => 'is_user_logged_in'
) );
}
public static function get_next_actions_for_user() {
$current_user = wp_get_current_user();
@@ -62,4 +97,207 @@ class Wiass_REST_Delivery_Process_API {
return $response;
}
public static function get_customer_acceptance(WP_REST_Request $request){
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return self::generate_error('Customer acceptance entry not found', 404);
}
$acceptance_documents = array();
$uploaded_files = json_decode($entry[self::UPLOADED_FILES_FIELD_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]);
$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;
}
$result = array(
'documents' => $acceptance_documents,
'expiration' => $entry[self::EXPIRATION_DATE_FIELD_ID],
'status' => $acceptance_status,
'decline_reason' => $entry[self::DECLINE_REASON_FIELD_ID]
);
return new WP_REST_Response($result);
}
public static function submit_customer_acceptance(WP_REST_Request $request){
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return self::generate_error('Customer acceptance entry not found', 404);
}
$status = $request['actionType'];
$reason = $request['declineReason'];
if (!in_array($status, self::ACCEPTABLE_STATUS)){
return self::generate_wiaas_response('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 self::generate_wiaas_response('DECLINE_REASON_EMPTY', 'error');
}
if (!$installation_declined && (count($uploaded_files)===0)){
return self::generate_wiaas_response('ACCEPTANCE_NOT_UPLOADED', 'error');
}
$entry[self::DECLINE_REASON_FIELD_ID] = $reason;
$entry[self::ACCEPTANCE_STATUS_FIELD_ID] = $status;
if (!GFAPI::update_entry( $entry )){
return self::generate_wiaas_response('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 self::generate_wiaas_response('ACCEPTANCE_STATUS_UPDATED', 'success');
}
if ( $current_step ) {
$current_step->purge_assignees();
$current_step->update_step_status( 'complete' );
}
$entry_id = $entry['id'];
$new_step_id = $current_step->get_id() + 1;
$new_step = $gf_api->get_step( $new_step_id, $entry );
$feedback = sprintf( esc_html__( 'Sent to step: %s', 'gravityflow' ), $new_step->get_name() );
$gf_api->add_timeline_note( $entry_id, $feedback );
$gf_api->log_activity( 'workflow', 'sent_to_step', $gf_api->form_id, $entry_id, $step_id );
gform_update_meta( $entry_id, 'workflow_final_status', 'pending' );
$new_step->start();
$gf_api->process_workflow( $entry_id );
if ($installation_declined){
return self::generate_wiaas_response('INSTALLATION_DECLINED', 'success');
}
return self::generate_wiaas_response('INSTALLATION_ACCEPTED', 'success');
}
public static function upload_file(WP_REST_Request $request){
$files = $request->get_file_params();
if (!$files[self::FILE_KEY_NAME]){
return self::generate_wiaas_response('NO_FILES_UPLOADED', 'error');
}
$entry = GFAPI::get_entry($request['entry_id']);
if (is_wp_error($entry)){
return self::generate_error('Customer acceptance entry not found', 404);
}
$form = GFAPI::get_form($entry['form_id']);
$form_upload_path = GFFormsModel::get_upload_path( $form['id'] );
$target_path = $form_upload_path . '/' . date('Y') . '/' . date('m') . '/';
wp_mkdir_p( $target_path );
GFCommon::recursive_add_index_file( $target_path );
$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 self::generate_wiaas_response('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 self::generate_wiaas_response('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 self::generate_wiaas_response('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 self::generate_wiaas_response('INTERNAL_SERVER_ERROR', 'error');
}
//Extract path relative to the root
//Last 6 strings (excluding last empty) are path relative to the root
$path_parts = explode('/', $target_path);
$relative_path = '';
$i = count($path_parts) - self::PATH_PARTS_TO_EXTRACT;
while($i < count($path_parts)-1){
$relative_path = $relative_path . $path_parts[$i] . '/';
$i++;
}
$file_url = self::BASE_NAME . $relative_path . $new_file_name;
$url_for_download = $upload_file_field->get_download_url($file_url);
$uploaded_files = json_decode($entry[self::UPLOADED_FILES_FIELD_ID]);
if ($uploaded_files === NULL){
$uploaded_files = [];
}
array_push($uploaded_files, $url_for_download);
$entry[self::UPLOADED_FILES_FIELD_ID] = json_encode($uploaded_files);
if (GFAPI::update_entry( $entry )) {
return self::generate_wiaas_response('FILE_UPLOADED','success');
}
return self::generate_wiaas_response('NOT_UPLOADED', 'error');
}
//Helper function
private static function generate_error($message, $code = 500){
$error = array(
'status' => $code,
'message' => $message,
);
$result = new WP_REST_Response($error);
$result->set_status($code);
return $result;
}
private static function generate_wiaas_response($message, $code, $data = NULL){
$response = array(
'messages' => [
array(
'code' => $code,
'message' => $message
)
],
'data' => $data
);
return new WP_REST_Response($response);
}
}

View File

@@ -9,7 +9,6 @@ class Wiaas_DB_Update {
'20180801222206' => 'wiaas_db_update_setup_gravity',
'20180802222206' => 'wiaas_db_update_add_delivery_process_forms',
'20180807222206' => 'wiaas_db_update_setup_customer_capabilities',
'20180809134511' => 'wiaas_db_update_add_customer_read_permission',
'20180811134511' => 'wiaas_db_update_enable_orders_access_management',
'20180813134511' => 'wiaas_db_update_enable_order_numbers',
'20180826153509' => 'wiaas_create_broker_access_group'

View File

@@ -23,8 +23,33 @@ class Wiaas_Delivery_Process {
add_filter( 'gform_entry_meta', array(__CLASS__, 'extend_gravity_form_entry_meta'), 10, 2 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_process_step'), 5, 3 );
add_action( 'gravityflow_workflow_complete', array(__CLASS__, 'maybe_complete_parent_order'), 10, 3 );
// Some temporary functions to make inbox page prettier
add_filter('gravityflow_inbox_submitter_name', array(__CLASS__, 'display_step_name_in_inbox'), 10, 3);
add_filter('gravityflow_approve_label_workflow_detail', array(__CLASS__, 'approval_step_approval_label'), 10, 2);
add_filter('gravityflow_reject_label_workflow_detail', array(__CLASS__, 'approval_step_reject_label'), 10, 2);
}
public static function approval_step_approval_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Complete step', 'wiaas' );
}
return $label;
}
public static function approval_step_reject_label($label, $step) {
if ($step->get_name() === 'Complete step') {
return esc_html__( 'Cancel', 'wiaas' );
}
return $label;
}
public static function display_step_name_in_inbox($name, $entry, $form) {
return $entry['wiaas_delivery_step_name'];
}
/**
* Registers our Delivery Process Step Type as available Gravity Flow Step Type
*/
@@ -34,6 +59,29 @@ class Wiaas_Delivery_Process {
Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() );
}
/**
* Maybe complete parent order for completed delivery process
* @param $entry_id
* @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'];
if (!isset($order_id)) {
return;
}
$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) {
$order = wc_get_order($order_id);
$order->update_status('completed', 'Completed order delivery process.', true);
}
}
/**
* Retrieves delivery process instance for order
*
@@ -134,6 +182,16 @@ class Wiaas_Delivery_Process {
),
);
$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;
}

View File

@@ -18,8 +18,19 @@ class Wiaas_Order {
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3);
add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2);
add_filter('woocommerce_new_order_note_data', array( __CLASS__, 'update_new_order_comment_date'), 10, 3);
}
public static function update_new_order_comment_date($comment_data, $order_data) {
$user = wp_get_current_user();
$comment_data['comment_author'] = $user->display_name;
$comment_data['comment_author_email'] = $user->user_email;
return $comment_data;
}
/**
* Assignees order to corresponding user organization when order is created.
*
@@ -94,6 +105,8 @@ class Wiaas_Order {
$data = self::_append_commercial_lead_info($data, $order, $request);
$data = self::_append_wiaas_order_details($data, $order, $request);
$data = self::_append_order_comments($data, $order, $request);
$response->set_data($data);
@@ -126,6 +139,7 @@ class Wiaas_Order {
private static function _append_commercial_lead_info($data, $order, $request) {
$data['commercial_lead'] = array(
'id' => 1,
'name' => 'Coor Service Management',
'phone' => '123456789',
'email' => 'rikard@co-ideation.com'
@@ -248,6 +262,34 @@ class Wiaas_Order {
return $data;
}
/** Append order comments if single order is requested
* @param $data
* @param $order
* @param $request
*/
private static function _append_order_comments($data, $order, $request) {
if (isset($request['id'])) {
$current_user = wp_get_current_user();
$comments = $order->get_customer_order_notes();
$data['comments'] = array();
foreach ($comments as $comment) {
$data['comments'][] = array(
'id' => $comment->comment_ID,
'content' => $comment->comment_content,
'username' => $comment->comment_author,
'date' => $comment->comment_date,
'is_owner' => $comment->comment_author === $current_user->display_name,
);
}
}
return $data;
}
}
Wiaas_Order::init();

View File

@@ -1,387 +1,524 @@
{
"0": {
"title": "DELIVERY ACTION TYPE: Customer acceptance",
"description": "The customer must accept the implementation before further actions can be taken. If the customer isn't satisfied, the problems or discrepancies must be fixed in order to gen an acceptance.",
"labelPlacement": "top_label",
"descriptionPlacement": "below",
"button": {
"type": "text",
"text": "Submit",
"imageUrl": ""
},
"fields": [
{
"type": "workflow_user",
"id": 2,
"label": "customer-id",
"adminLabel": "customer-id",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "administrative",
"inputs": null,
"choices": [
],
"formId": 10,
"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": 10,
"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": "fileupload",
"id": 7,
"label": "Acceptance document",
"adminLabel": "",
"isRequired": false,
"size": "medium",
"errorMessage": "",
"visibility": "visible",
"inputs": null,
"formId": 10,
"description": "Upload your acceptance document",
"allowsPrepopulate": false,
"inputMask": false,
"inputMaskValue": "",
"inputType": "",
"labelPlacement": "",
"descriptionPlacement": "",
"subLabelPlacement": "",
"placeholder": "",
"cssClass": "",
"inputName": "",
"noDuplicates": false,
"defaultValue": "",
"choices": "",
"conditionalLogic": "",
"maxFileSize": "",
"maxFiles": "",
"multipleFiles": false,
"allowedExtensions": "",
"productField": "",
"calculationFormula": "",
"calculationRounding": "",
"enableCalculation": "",
"disableQuantity": false,
"displayAllCategories": false,
"useRichTextEditor": false,
"displayOnly": ""
}
],
"version": "2.3.2",
"id": 10,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
"postTitleTemplate": "",
"postContentTemplate": "",
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"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": "22",
"form_id": "10",
"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",
"type": "select",
"assignees": [
"role|administrator",
"assignee_user_field|2"
],
"editable_fields": [
"5"
],
"routing": "",
"assignee_policy": "any",
"highlight_editable_fields_enabled": "0",
"highlight_editable_fields_class": "green-triangle",
"instructionsEnable": "0",
"instructionsValue": "",
"display_fields_mode": "selected_fields",
"display_fields_selected": [
"5"
],
"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": "delay",
"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",
"status_expiration": "expired",
"destination_expired": "next",
"destination_complete": "next"
},
"addon_slug": "gravityflow",
"event_type": null
"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": ""
},
{
"id": "30",
"form_id": "10",
"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": "22",
"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": "22",
"destination_approved": "next"
},
"addon_slug": "gravityflow",
"event_type": null
"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.6"
},
"version": "2.3.2"
}

View File

@@ -30,7 +30,7 @@
"text": "wpUser"
}
],
"formId": 12,
"formId": 4,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
@@ -71,7 +71,7 @@
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 12,
"formId": 4,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
@@ -102,7 +102,7 @@
}
],
"version": "2.3.2",
"id": 12,
"id": 4,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
@@ -111,17 +111,9 @@
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"notifications": [
{
"id": "5b5f9ebc520f3",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"is_active": "1",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f9ebc52a80",
@@ -134,11 +126,22 @@
"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": "27",
"form_id": "12",
"id": "6",
"form_id": "4",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -245,5 +248,5 @@
]
}
},
"version": "2.3.2.6"
"version": "2.3.2"
}

View File

@@ -30,7 +30,7 @@
"text": "wpUser"
}
],
"formId": 13,
"formId": 2,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
@@ -70,7 +70,7 @@
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 13,
"formId": 2,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
@@ -111,7 +111,7 @@
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "calendar",
"formId": 13,
"formId": 2,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
@@ -141,7 +141,7 @@
}
],
"version": "2.3.2",
"id": 13,
"id": 2,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
@@ -150,6 +150,9 @@
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-08-09 15:35:59",
"is_trash": "0",
"confirmations": [
{
"id": "5b60b12baa00e",
@@ -176,8 +179,8 @@
"feeds": {
"gravityflow": [
{
"id": "31",
"form_id": "13",
"id": "3",
"form_id": "2",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -286,8 +289,8 @@
"event_type": null
},
{
"id": "32",
"form_id": "13",
"id": "4",
"form_id": "2",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -377,7 +380,7 @@
"approval_notification_message": "Entry {entry_id} has been approved",
"approval_notification_disable_autoformat": "0",
"revertEnable": "0",
"revertValue": "31",
"revertValue": 3,
"note_mode": "not_required",
"expiration": "0",
"expiration_type": "delay",
@@ -390,7 +393,7 @@
"expiration_date_field": "4",
"status_expiration": "rejected",
"destination_expired": "next",
"destination_rejected": "31",
"destination_rejected": 3,
"destination_approved": "complete"
},
"addon_slug": "gravityflow",
@@ -399,5 +402,5 @@
]
}
},
"version": "2.3.2.6"
"version": "2.3.2"
}

View File

@@ -30,7 +30,7 @@
"text": "wpUser"
}
],
"formId": 9,
"formId": 3,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
@@ -71,7 +71,7 @@
"inputs": null,
"dateType": "datepicker",
"calendarIconType": "none",
"formId": 9,
"formId": 3,
"description": "",
"allowsPrepopulate": false,
"inputMask": false,
@@ -101,7 +101,7 @@
}
],
"version": "2.3.2",
"id": 9,
"id": 3,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
@@ -110,17 +110,9 @@
"lastPageButton": null,
"pagination": null,
"firstPageCssClass": null,
"notifications": [
{
"id": "5b5f68818822e",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}"
}
],
"is_active": "1",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"confirmations": [
{
"id": "5b5f688188e90",
@@ -133,11 +125,22 @@
"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": "20",
"form_id": "9",
"id": "5",
"form_id": "3",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -257,5 +260,5 @@
]
}
},
"version": "2.3.2.6"
"version": "2.3.2"
}

View File

@@ -21,7 +21,7 @@
"visibility": "visible",
"inputs": null,
"numberFormat": "decimal_dot",
"formId": "11",
"formId": 5,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
@@ -71,7 +71,7 @@
"text": "wpUser"
}
],
"formId": "11",
"formId": 5,
"description": "",
"allowsPrepopulate": true,
"inputMask": false,
@@ -102,7 +102,7 @@
}
],
"version": "2.3.2.6",
"id": "11",
"id": 5,
"useCurrentUserAsAuthor": true,
"postContentTemplateEnabled": false,
"postTitleTemplateEnabled": false,
@@ -112,20 +112,8 @@
"pagination": null,
"firstPageCssClass": null,
"is_active": "1",
"date_created": "2018-07-30 20:53:56",
"date_created": "2018-08-09 15:36:00",
"is_trash": "0",
"notifications": [
{
"id": "5b5f7ae4baced",
"to": "{admin_email}",
"name": "Admin Notification",
"event": "form_submission",
"toType": "email",
"subject": "New submission from {form_title}",
"message": "{all_fields}",
"isActive": false
}
],
"confirmations": [
{
"id": "5b5f7ae4bb79e",
@@ -138,11 +126,23 @@
"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": "28",
"form_id": "11",
"id": "7",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -164,7 +164,7 @@
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": "9",
"target_form_id": 3,
"store_new_entry_idEnable": "1",
"new_entry_id_field": "6",
"destination_complete": "next"
@@ -173,8 +173,8 @@
"event_type": null
},
{
"id": "33",
"form_id": "11",
"id": "8",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -196,7 +196,7 @@
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": "12",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
@@ -205,8 +205,8 @@
"event_type": null
},
{
"id": "34",
"form_id": "11",
"id": "9",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -228,7 +228,7 @@
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": "12",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
@@ -237,8 +237,8 @@
"event_type": null
},
{
"id": "29",
"form_id": "11",
"id": "10",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -258,7 +258,7 @@
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"target_form_id": "10",
"target_form_id": 1,
"store_new_entry_idEnable": "1",
"new_entry_id_field": "7",
"destination_complete": "next"
@@ -267,8 +267,8 @@
"event_type": null
},
{
"id": "36",
"form_id": "11",
"id": "11",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -290,7 +290,7 @@
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": "12",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next",
@@ -300,8 +300,8 @@
"event_type": null
},
{
"id": "35",
"form_id": "11",
"id": "12",
"form_id": "5",
"is_active": "1",
"feed_order": "0",
"meta": {
@@ -323,7 +323,7 @@
"schedule_date_field_before_after": "after",
"instructionsEnable": "0",
"instructionsValue": "",
"target_form_id": "12",
"target_form_id": 4,
"store_new_entry_idEnable": "0",
"new_entry_id_field": "",
"destination_complete": "next"
@@ -334,5 +334,5 @@
]
}
},
"version": "2.3.2.6"
"version": "2.3.2"
}

View File

@@ -82,12 +82,10 @@ function wiaas_db_update_setup_customer_capabilities() {
$customer_role = get_role('customer');
$customer_role->add_cap('read_private_shop_orders');
$customer_role->add_cap('read_shop_order');
}
function wiaas_db_update_add_customer_read_permission() {
$role = get_role( 'customer' );
$role->add_cap( 'read_private_products' );
$customer_role->add_cap('read_private_products');
$customer_role->add_cap('read_shop_order');
$customer_role->add_cap('publish_shop_orders');
}
function wiaas_db_update_enable_orders_access_management() {

View File

@@ -100,6 +100,7 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
'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(),
);
$customer_id_value = null;

View File

@@ -0,0 +1,27 @@
x\9C\AD[O\AF\E36\BF\E7S\E4\\E0\A5\FAc\C96\F0\CBK\98[\BB\D8C\D1\DBn \9D\B6\97\F9\FAK\91\92%Y\B4d\8F\DBA+&)\8A?\89\A4D=q\93\D7o\97\FF]\FC3\A3\B9\A9\EB\D0\C9\DBp\FD\EB?\97\FDp\FD\EFE\DCF
\FF]\D7\DF\FD~1榯\D6@-G \CFR!\E3\F5\B7.\AA\B37^J\F7\9C\BC\D4VC?\F4\B2\EB\F3w\9D\F0L\EF\A0\93\BD\B3v\E9\B1wd\C9;T\A6\D3\E2\D6o)\E3_\F2\CA\D0K^z\C7+C\EF\D6ʐ9\853\D2\FB\E7\C5X\A7o\AFo\E3\F5\F3\DF\D7_H\AF\9F\BF\FDrrzSw\A1\F0SO\C3]t\F8h&\F8\B0\A2\9F\F0\E77\F8}\98\C2\CF\C3$\C5]\8C\C0j\DC\D7<\BDɻxG6 \DF\F0\E3#\CA qr\FA\F5\F3\CB\E5\F9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\9F\C6~\B7\\C2\D9Uz\EB\A9\C0>[\9DG\AF8q\EA(\83\B2\EC\FB\B2\89\92\F50\B4\DC^\EC$\B4սX\D7\CDĿ\8C\A8\E8\8A\E3B\93\FF\F8\A7\DCB/\C1\D0\D1:n\00\CA\E9\B1\FF\8FJ\F6èp\9B\AA\93\A8\94J\B5.\AF\A9";\F7\C7\CB\DArw\A1\F0\F4’\D5\C9\C3%^M\AA\E5\\F6L\E9ٲ\DF\FEč\97\BF6\nrk\94\AEf\C7=q\BBr{t\E4\8A՚\FD0r\E5\8E\E6$nk\85\9A\A8qɼ
~\A0

View File

@@ -9,6 +9,15 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
var $order_id, $api;
/**
* Test REST Server
*
* @var WP_REST_Server
*/
protected $server;
protected $namespaced_route = '/wiaas';
function setUp() {
parent::setUp();
@@ -17,6 +26,41 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
$this->order_id = $order->get_id();
wp_set_current_user(1);
/** @var WP_REST_Server $wp_rest_server */
global $wp_rest_server;
$this->server = $wp_rest_server = new \WP_REST_Server;
do_action( 'rest_api_init' );
$original_valid_customer_acceptance = __DIR__ . '/../dummy-files/valid-customer-acceptance.odt';
$this->test_file_valid_customer_acceptance = '/tmp/valid-customer-acceptance.odt';
copy( $original_valid_customer_acceptance, $this->test_file_valid_customer_acceptance );
$original_invalid_customer_acceptance = __DIR__ . '/../dummy-files/invalid-customer-acceptance.txt';
$this->test_file_invalid_customer_acceptance = '/tmp/invalid-customer-acceptance.txt';
copy( $original_invalid_customer_acceptance, $this->test_file_invalid_customer_acceptance );
}
function test_register_route() {
$routes = $this->server->get_routes();
$this->assertArrayHasKey( $this->namespaced_route, $routes );
}
function test_endpoints() {
$the_route = $this->namespaced_route;
$routes = $this->server->get_routes();
foreach( $routes as $route => $route_config ) {
if( 0 === strpos( $the_route, $route ) ) {
$this->assertTrue( is_array( $route_config ) );
foreach( $route_config as $i => $endpoint ) {
$this->assertArrayHasKey( 'callback', $endpoint );
$this->assertArrayHasKey( 0, $endpoint[ 'callback' ], get_class( $this ) );
$this->assertArrayHasKey( 1, $endpoint[ 'callback' ], get_class( $this ) );
$this->assertTrue( is_callable( array( $endpoint[ 'callback' ][0], $endpoint[ 'callback' ][1] ) ) );
}
}
}
}
/**
@@ -49,4 +93,429 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
$this->assertEquals($pending_step['status'], 'pending');
$this->assertNotEmpty($pending_step['step_action']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::get_customer_acceptance
*/
function test_get_customer_acceptance_as_guest() {
wp_set_current_user(0);
$request = new WP_REST_Request( 'GET', '/wiaas/customer-acceptance/99191991919191');
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 401);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Sorry, you are not allowed to do that.');
}
/**
* @covers Wiass_REST_Delivery_Process_API::get_customer_acceptance
*/
function test_get_nonexisting_customer_acceptance() {
wp_set_current_user(1);
$request = new WP_REST_Request( 'GET', '/wiaas/customer-acceptance/911919191919' ); //non existing entry ID
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 404);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Customer acceptance entry not found');
}
/**
* @covers Wiass_REST_Delivery_Process_API::get_customer_acceptance
*/
function test_get_valid_customer_acceptance() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'GET', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertTrue(is_array($response_data));
$this->assertArrayHasKey('documents', $response_data);
$this->assertArrayHasKey('expiration', $response_data);
$this->assertArrayHasKey('status', $response_data);
$this->assertArrayHasKey('decline_reason', $response_data);
$this->assertTrue(is_array($response_data['documents']));
$uploaded_file = $response_data['documents'][0];
$this->assertTrue(is_array($uploaded_file));
$this->assertArrayHasKey('name', $uploaded_file);
$this->assertArrayHasKey('extension', $uploaded_file);
$this->assertArrayHasKey('url', $uploaded_file);
$this->assertEquals($uploaded_file['name'], 'file1');
$this->assertEquals($uploaded_file['extension'], 'docx');
$this->assertEquals($uploaded_file['url'], 'http://localhost/wp/index.php?gf-download=2018%2F08%2Ffile1.docx&form-id=1&field-id=12&hash=1be6c30f0eeff93563b352d15fe459d5ded12ee06c2c8f36fed66b42dedf2534');
$this->assertEquals($response_data['status'], 1); //1 means accept
$this->assertEquals($response_data['expiration'], "2020-01-01");
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_customer_acceptance_as_guest() {
wp_set_current_user(0);
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/9191919191' );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 401);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Sorry, you are not allowed to do that.');
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_nonexisting_customer_acceptance() {
wp_set_current_user(1);
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/919191919191' );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 404);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Customer acceptance entry not found');
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_customer_acceptance_with_invalid_status() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id );
$request->set_body_params(array(
'actionType' => 'invalid status',
'declineReason' => ''
));
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('error', $message['code']);
$this->assertEquals('ACCEPTANCE_STATUS_MISSING', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_customer_acceptance_with_accepted_status() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id );
$request->set_body_params(array(
'actionType' => 'accept',
'declineReason' => ''
));
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('success', $message['code']);
$this->assertEquals('INSTALLATION_ACCEPTED', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_customer_acceptance_with_declined_status_and_empty_reason() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id );
$request->set_body_params(array(
'actionType' => 'decline',
'declineReason' => ''
));
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('error', $message['code']);
$this->assertEquals('DECLINE_REASON_EMPTY', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::submit_customer_acceptance
*/
function test_submit_customer_acceptance_with_decline_status() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id );
$request->set_body_params(array(
'actionType' => 'decline',
'declineReason' => 'This is very reasonable reason'
));
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('success', $message['code']);
$this->assertEquals('INSTALLATION_DECLINED', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::upload_file
*/
function test_upload_customer_acceptance_file_as_guest() {
wp_set_current_user(0);
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/919199191/upload-file' );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 401);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Sorry, you are not allowed to do that.');
}
/**
* @covers Wiass_REST_Delivery_Process_API::upload_file
*/
function test_upload_customer_acceptance_file_to_non_existing_entry() {
wp_set_current_user(1);
$original_valid_customer_acceptance = __DIR__ . '/../dummy-files/valid-customer-acceptance.odt';
$this->test_file_valid_customer_acceptance = '/tmp/valid-customer-acceptance.odt';
copy( $original_valid_customer_acceptance, $this->test_file_valid_customer_acceptance );
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/919199191/upload-file' );
$request->set_file_params( array(
'file' => array(
'file' => file_get_contents( $this->test_file_valid_customer_acceptance ),
'name' => 'valid-customer-acceptance.odt',
'size' => filesize( $this->test_file_valid_customer_acceptance ),
'tmp_name' => $this->test_file_valid_customer_acceptance,
),
) );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertTrue($response->is_error());
$this->assertEquals($response->get_status(), 404);
$error_data = $response->as_error();
$this->assertEquals($error_data->get_error_message(), 'Customer acceptance entry not found');
}
/**
* @covers Wiass_REST_Delivery_Process_API::upload_file
*/
function test_upload_customer_acceptance_file_without_file() {
wp_set_current_user(1);
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/919199191/upload-file' );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('error', $message['code']);
$this->assertEquals('NO_FILES_UPLOADED', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::upload_file
*/
function test_upload_invalid_customer_acceptance_file() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id . '/upload-file' );
$request->set_file_params( array(
'file' => array(
'file' => file_get_contents( $this->test_file_invalid_customer_acceptance ),
'name' => 'invalid-customer-acceptance.txt',
'size' => filesize( $this->test_file_invalid_customer_acceptance ),
'tmp_name' => $this->test_file_invalid_customer_acceptance,
),
) );
$request->set_header( 'Content-MD5', md5_file( $this->test_file_invalid_customer_acceptance ) );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('error', $message['code']);
$this->assertEquals('INVALID_FILE_ACCEPTANCE', $message['message']);
}
/**
* @covers Wiass_REST_Delivery_Process_API::upload_file
*/
function test_upload_valid_customer_acceptance_file() {
wp_set_current_user(1);
$customer_acceptance_entry_id = self::create_pending_customer_acceptance_entry();
$request = new WP_REST_Request( 'POST', '/wiaas/customer-acceptance/' . $customer_acceptance_entry_id . '/upload-file' );
$request->set_file_params( array(
'file' => array(
'file' => file_get_contents( $this->test_file_valid_customer_acceptance ),
'name' => 'valid-customer-acceptance.odt',
'size' => filesize( $this->test_file_valid_customer_acceptance ),
'tmp_name' => $this->test_file_valid_customer_acceptance,
),
) );
$request->set_header( 'Content-MD5', md5_file( $this->test_file_valid_customer_acceptance ) );
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$response_data = $response->get_data();
$this->assertArrayHasKey('messages', $response_data);
$this->assertArrayHasKey('data', $response_data);
$message = $response_data['messages'][0];
$this->assertArrayHasKey('code', $message);
$this->assertArrayHasKey('message', $message);
$this->assertEquals('success', $message['code']);
$this->assertEquals('FILE_UPLOADED', $message['message']);
}
public function tearDown() {
parent::tearDown();
if ( file_exists( $this->test_file_valid_customer_acceptance ) ) {
unlink( $this->test_file_valid_customer_acceptance );
}
if ( file_exists( $this->test_file_invalid_customer_acceptance ) ) {
unlink( $this->test_file_invalid_customer_acceptance );
}
$this->remove_added_uploads();
}
//===================================================================================
/**
* Helper function : creates customer acceptance entry
*/
private function create_pending_customer_acceptance_entry(){
$customer_acceptance_form_id = 1;
$customer_id_field_id = 2;
$actual_date_field_id = 6;
$acceptance_status_field_id = 8;
$expiration_date_field_id = 9;
$decline_reason_field_id = 10;
$files_uploaded_field_id = 12;
$input_values['input_' . $acceptance_status_field_id] = 'accept';
$input_values['input_' . $expiration_date_field_id] = "2020-01-01";
//$input_values['input_' . $files_uploaded_field_id] = json_encode(['http://path/to/file1.docx']);
GFAPI::submit_form($customer_acceptance_form_id, $input_values);
//this part is needed since form submit does not store files for some reason, probably files should be sent some other way
$entry = GFAPI::get_entries($customer_acceptance_form_id)[0];
$entry[$files_uploaded_field_id] = json_encode(['http://localhost/wp/index.php?gf-download=2018%2F08%2Ffile1.docx&form-id=1&field-id=12&hash=1be6c30f0eeff93563b352d15fe459d5ded12ee06c2c8f36fed66b42dedf2534']);
$entry['workflow_step'] = 1;
$entry['workflow_step_status_1'] = 'pending';
$entry['workflow_step_status_2'] = false;
$entry['workflow_timestamp'] = false;
$update = GFAPI::update_entry($entry);
return $entry['id'];
}
}

View File

@@ -14,7 +14,9 @@ class Wiaas_Unit_Test_Case extends WP_UnitTestCase {
wiaas_db_update_setup_gravity();
wiaas_db_update_enable_orders_access_management();
wiaas_db_update_enable_orders_access_management();
define('WP_TEST_IN_PROGRESS',true);
}
function tearDown() {