Merge branch 'add-installation-date-action' into 'master'
Add installation date action See merge request saburly/wiaas/new-wiaas!57
This commit was merged in pull request #57.
This commit is contained in:
@@ -16,12 +16,40 @@ class Wiaas_Admin_Order_Process_Flow {
|
|||||||
|
|
||||||
add_filter('gravityflow_admin_action_feedback', array(__CLASS__, 'maybe_process_admin_step_change_action'), 10, 4);
|
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'));
|
add_filter('gravityflow_admin_actions_workflow_detail', array(__CLASS__, 'filter_workflow_admin_actions'), 10, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function remove_workflow_admin_actions() {
|
/**
|
||||||
|
* Filter workflow admin actions
|
||||||
|
*
|
||||||
|
* @param $admin_actions
|
||||||
|
* @param $current_step
|
||||||
|
* @param $steps
|
||||||
|
* @param $form
|
||||||
|
* @param $entry
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function filter_workflow_admin_actions($admin_actions, $current_step, $steps, $form, $entry) {
|
||||||
|
|
||||||
return array();
|
$allowed_actions = array();
|
||||||
|
|
||||||
|
// allow basic admin actions for step action workflow
|
||||||
|
if (Wiaas_Delivery_Process_Action::is_action_form($form)) {
|
||||||
|
|
||||||
|
$allowed_actions = array( 'cancel_workflow', 'restart_workflow', 'restart_step');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filtered_admin_actions = array();
|
||||||
|
|
||||||
|
foreach ( $admin_actions as $admin_action ) {
|
||||||
|
|
||||||
|
if (in_array($admin_action['value'], $allowed_actions)) {
|
||||||
|
$filtered_admin_actions[] = $admin_action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filtered_admin_actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function render_procurement_order_download_link($form, $entry, $current_step) {
|
public static function render_procurement_order_download_link($form, $entry, $current_step) {
|
||||||
@@ -269,74 +297,61 @@ class Wiaas_Admin_Order_Process_Flow {
|
|||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($is_current_step) {
|
Gravity_Flow_Entry_Detail::maybe_show_instructions(true, true, $current_step, $form, $entry);
|
||||||
Gravity_Flow_Entry_Detail::maybe_show_instructions(true, true, $current_step, $form, $entry);
|
|
||||||
|
|
||||||
$action_form = GFAPI::get_form( $step->target_form_id );
|
$action_form = GFAPI::get_form( $step->target_form_id );
|
||||||
|
|
||||||
if (empty($action_form)) {
|
if (empty($action_form)) {
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
continue;
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$page_size = 20;
|
||||||
|
$search_criteria = array(
|
||||||
|
'status' => 'active',
|
||||||
|
'field_filters' => array(
|
||||||
|
array( 'key' => 'wiaas_delivery_process_id',
|
||||||
|
'value' => $entry['id']
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$sorting = array( 'key' => 'date_created', 'direction' => 'DESC' );
|
||||||
|
$paging = array( 'offset' => 0, 'page_size' => $page_size );
|
||||||
|
|
||||||
|
$entries = GFAPI::get_entries( $action_form['id'], $search_criteria, $sorting, $paging );
|
||||||
|
|
||||||
|
if (empty($entries)) {
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="submitbox" style="padding: 10px;">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
echo '<br><br><br>';
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($entries as $action_entry) {
|
||||||
|
self::_display_step_action_entry($action_form, $action_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -349,6 +364,13 @@ class Wiaas_Admin_Order_Process_Flow {
|
|||||||
|
|
||||||
$current_action_step = $workflow_api->get_current_step($action_entry);
|
$current_action_step = $workflow_api->get_current_step($action_entry);
|
||||||
|
|
||||||
|
$entry_url = add_query_arg( array(
|
||||||
|
'page' => 'gravityflow-inbox',
|
||||||
|
'view' => 'entry',
|
||||||
|
'id' => $action_entry['form_id'],
|
||||||
|
'lid' => $action_entry['id']
|
||||||
|
), admin_url() );
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
@@ -384,15 +406,15 @@ class Wiaas_Admin_Order_Process_Flow {
|
|||||||
<strong>
|
<strong>
|
||||||
|
|
||||||
<?php
|
<?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 empty($current_action_step) ?
|
||||||
echo $workflow_api->get_status($action_entry);
|
$workflow_api->get_status($action_entry) :
|
||||||
}
|
$current_action_step->get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();;
|
||||||
|
|
||||||
|
echo '<a target="_blank" href="' . $entry_url . '">' .
|
||||||
|
' <i class="fa fa-external-link" style="font-size: 16px;"></i>' .
|
||||||
|
'</a>';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</strong>
|
</strong>
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class Wiaas_DB_Update {
|
|||||||
'20191102112451' => 'wiaas_disable_processing_order_email_delivery',
|
'20191102112451' => 'wiaas_disable_processing_order_email_delivery',
|
||||||
'20191131172850' => 'wiaas_db_update_update_delivery_forms',
|
'20191131172850' => 'wiaas_db_update_update_delivery_forms',
|
||||||
'20191131182856' => 'wiaas_db_update_enable_workflow_inbox_for_roles',
|
'20191131182856' => 'wiaas_db_update_enable_workflow_inbox_for_roles',
|
||||||
'20191201133550' => 'wiaas_db_update_add_bundle_properties_ui_field'
|
'20191201133550' => 'wiaas_db_update_add_bundle_properties_ui_field',
|
||||||
|
'20191202133553' => 'wiaas_db_update_add_installation_date_delivery_action_form'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function execute() {
|
public static function execute() {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Wiaas_Delivery_Process {
|
|||||||
require_once( 'delivery-process/class-wiaas-field-order-installation-select.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-bundle-document.php' );
|
||||||
require_once( 'delivery-process/class-wiaas-field-order-document.php' );
|
require_once( 'delivery-process/class-wiaas-field-order-document.php' );
|
||||||
|
require_once( 'delivery-process/class-wiaas-field-order-bundle-installation-date.php' );
|
||||||
|
|
||||||
Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() );
|
Gravity_Flow_Steps::register( new Wiaas_Delivery_Process_Step() );
|
||||||
|
|
||||||
|
|||||||
@@ -571,6 +571,12 @@ class Wiaas_Order {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// installation date
|
||||||
|
if (! empty($item['wiaas_installation_date'])) {
|
||||||
|
|
||||||
|
$product_line['installation_date'] = $item['wiaas_installation_date'];
|
||||||
|
}
|
||||||
|
|
||||||
$line_items[] = $product_line;
|
$line_items[] = $product_line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -121,4 +121,15 @@ function wiaas_db_update_update_delivery_forms() {
|
|||||||
$created_forms[] = GFAPI::get_form($sample_form_id);
|
$created_forms[] = GFAPI::get_form($sample_form_id);
|
||||||
|
|
||||||
do_action('gform_forms_post_import', $created_forms);
|
do_action('gform_forms_post_import', $created_forms);
|
||||||
|
}
|
||||||
|
|
||||||
|
function wiaas_db_update_add_installation_date_delivery_action_form() {
|
||||||
|
|
||||||
|
$action_form_json = file_get_contents( dirname( __FILE__ ) . '/data/delivery-forms/delivery-action-enter-installation-date.json' );
|
||||||
|
|
||||||
|
$action_form_meta = json_decode( $action_form_json, true )[0];
|
||||||
|
|
||||||
|
$action_form_id = GFAPI::add_form($action_form_meta);
|
||||||
|
|
||||||
|
do_action('gform_forms_post_import', array( GFAPI::get_form($action_form_id) ));
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,18 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
|
|||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
add_filter( 'gform_enqueue_scripts', array( $this, 'filter_gform_enqueue_scripts' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filter_gform_enqueue_scripts( ) {
|
||||||
|
|
||||||
|
wp_enqueue_script( 'gform_datepicker_init' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
|
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( ! class_exists( 'GFForms' ) ) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Wiaas_Field_Order_Bundle_Installation_Date extends GF_Field_Date {
|
||||||
|
|
||||||
|
public $type ='wiaas_order_bundle_installation_date';
|
||||||
|
|
||||||
|
public $inputType = 'date';
|
||||||
|
|
||||||
|
public $dateType = 'datepicker';
|
||||||
|
|
||||||
|
public function get_input_type() {
|
||||||
|
return 'date';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_form_editor_field_title() {
|
||||||
|
return esc_attr__( 'Bundle Install Date', '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(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GF_Fields::register( new Wiaas_Field_Order_Bundle_Installation_Date() );
|
||||||
@@ -76,6 +76,33 @@ class Wiaas_Order_Fields {
|
|||||||
// save changes to order
|
// save changes to order
|
||||||
switch ($field->type) {
|
switch ($field->type) {
|
||||||
|
|
||||||
|
case 'wiaas_order_bundle_installation_date':
|
||||||
|
/**
|
||||||
|
* Persist bundle installation date
|
||||||
|
*/
|
||||||
|
|
||||||
|
// get corresponding bundle field
|
||||||
|
$bundle_field = GFCommon::get_fields_by_type( $form, 'wiaas_order_bundle' )[0];
|
||||||
|
|
||||||
|
if (empty($bundle_field)) {
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bundle_item = $bundle_field->get_bundle_item( $entry[$bundle_field->id] );
|
||||||
|
|
||||||
|
if (empty($bundle_item)) {
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log($new_value);
|
||||||
|
|
||||||
|
$bundle_item->update_meta_data('wiaas_installation_date', $new_value);
|
||||||
|
$bundle_item->save_meta_data();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'wiaas_order_bundle_document':
|
case 'wiaas_order_bundle_document':
|
||||||
/**
|
/**
|
||||||
* Persist delivery flow documents for bundle
|
* Persist delivery flow documents for bundle
|
||||||
@@ -171,7 +198,7 @@ class Wiaas_Order_Fields {
|
|||||||
|
|
||||||
$selected_installation = $field->get_selected_installation($new_value);
|
$selected_installation = $field->get_selected_installation($new_value);
|
||||||
|
|
||||||
if (empty($selected_installation)) {
|
if ( empty($selected_installation) ) {
|
||||||
// no installation selected
|
// no installation selected
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -394,6 +421,14 @@ class Wiaas_Order_Fields {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// installation is already selected
|
||||||
|
if (!empty($bundle_item->get_meta('wiaas_installation', true))) {
|
||||||
|
|
||||||
|
$entry[(string) $field->id] = 'wiaas_installation_' . $order->get_id() . '|' . $bundle_item->get_meta('wiaas_installation', true);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$bundled_items = wc_pb_get_bundled_order_items($bundle_item, $order);
|
$bundled_items = wc_pb_get_bundled_order_items($bundle_item, $order);
|
||||||
|
|
||||||
$installation_items = array();
|
$installation_items = array();
|
||||||
@@ -408,7 +443,7 @@ class Wiaas_Order_Fields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($installation_items) && $field->isRequired) {
|
if (empty($installation_items)) {
|
||||||
// there is no data for required field so entry cannot be created
|
// there is no data for required field so entry cannot be created
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ class OrderInfo extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const {totalPrice, installationData} = this.props;
|
const {totalPrice, installationData} = this.props;
|
||||||
const {acceptedDate, proposedDate, isPreliminaryInstallationDate, isInstallationInOrder} = this.state;
|
const {acceptedDate, proposedDate, isPreliminaryInstallationDate, isInstallationInOrder} = this.state;
|
||||||
const orderPackages = installationData.packages;
|
|
||||||
const isInstallationInPackage = installationData.isInstallationInPackage;
|
const isInstallationInPackage = installationData.isInstallationInPackage;
|
||||||
const orderInfo = this.props.orderInfo;
|
const orderInfo = this.props.orderInfo;
|
||||||
|
const orderPackages = orderInfo ? orderInfo.packages : [];
|
||||||
|
|
||||||
|
const hasInstallationDates = orderPackages ? !!orderPackages.find(orderPackage => orderPackage.installationDate !== undefined) : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container fluid={true} id="order-info-description">
|
<Container fluid={true} id="order-info-description">
|
||||||
@@ -85,36 +87,35 @@ class OrderInfo extends Component {
|
|||||||
<span>{orderInfo.tender || '-'}</span>
|
<span>{orderInfo.tender || '-'}</span>
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
{ isInstallationInOrder &&
|
{
|
||||||
|
orderPackages &&
|
||||||
|
orderPackages.map(orderPackage => {
|
||||||
|
|
||||||
|
if (orderPackage.installationDate) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
{ hasInstallationDates &&
|
||||||
<Col xl="3">
|
<Col xl="3">
|
||||||
<div>
|
<div>
|
||||||
<div className="subtitle">
|
<div className="subtitle">
|
||||||
{ isPreliminaryInstallationDate
|
<h6>{orderTexts.labels.INSTALLATION_DATE}:</h6>
|
||||||
? <h6>{orderTexts.labels.PRELIMINARY_INSTALLATION_DATE_LABEL}:</h6>
|
|
||||||
: <h6>{orderTexts.labels.INSTALLATION_DATE}:</h6>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
{ orderPackages &&
|
{ orderPackages &&
|
||||||
orderPackages.map(orderPackage =>
|
orderPackages.map(orderPackage => {
|
||||||
<div key={'package-install-date-' + orderPackage.idOrderPackagePair}>
|
if (orderPackage.installationDate) {
|
||||||
{ isInstallationInPackage[orderPackage.idOrderPackagePair] &&
|
|
||||||
<div>
|
|
||||||
{ orderPackages.length > 1 &&
|
|
||||||
<span>{orderPackage.packageName}: </span>
|
|
||||||
}
|
|
||||||
<span className="installation-date-per-package">
|
|
||||||
{ acceptedDate && acceptedDate[orderPackage.idOrderPackagePair]
|
|
||||||
? acceptedDate[orderPackage.idOrderPackagePair]
|
|
||||||
: proposedDate && proposedDate[orderPackage.idOrderPackagePair]
|
|
||||||
? proposedDate[orderPackage.idOrderPackagePair]
|
|
||||||
: orderTexts.labels.NOT_SET
|
|
||||||
}
|
|
||||||
|
|
||||||
</span>
|
return (<div key={orderPackage.id}>
|
||||||
</div>
|
<span>{orderPackage.name}: </span>
|
||||||
}
|
<span className="installation-date-per-package"> { orderPackage.installationDate } </span>
|
||||||
</div>
|
</div>)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export const fromWCOrder = (WCOrder) => {
|
|||||||
payPeriod: packageLine['pay_period'],
|
payPeriod: packageLine['pay_period'],
|
||||||
shortDesc: packageLine['short_desc'],
|
shortDesc: packageLine['short_desc'],
|
||||||
dateCompleted: formatDate(packageLine['date_completed']),
|
dateCompleted: formatDate(packageLine['date_completed']),
|
||||||
|
installationDate: formatDate(packageLine['installation_date']),
|
||||||
additionalPackages: packageLine['additional_packages'] ? packageLine['additional_packages'].map(additionalPackage => ({
|
additionalPackages: packageLine['additional_packages'] ? packageLine['additional_packages'].map(additionalPackage => ({
|
||||||
idPackage: additionalPackage.id,
|
idPackage: additionalPackage.id,
|
||||||
packageName: additionalPackage.name,
|
packageName: additionalPackage.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user