Handle process visualization and going from one step to another
This commit is contained in:
@@ -7,24 +7,6 @@ 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
|
||||
@@ -44,7 +26,17 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
|
||||
$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'] );
|
||||
|
||||
$delivery_settings = rgar($form, 'wiaas_delivery_process');
|
||||
|
||||
$code = $form['id'];
|
||||
|
||||
if (! empty($delivery_settings['delivery_action_code'])) {
|
||||
|
||||
$code = $delivery_settings['delivery_action_code'];
|
||||
}
|
||||
|
||||
$form_choices[] = array( 'label' => $form['title'], 'value' => $code );
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
@@ -77,15 +69,47 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public function start() {
|
||||
|
||||
$complete = parent::start();
|
||||
|
||||
if ($complete) {
|
||||
|
||||
$this->update_step_status('complete');
|
||||
} else {
|
||||
|
||||
$this->update_step_status('pending');
|
||||
}
|
||||
|
||||
return $complete;
|
||||
}
|
||||
|
||||
public function evaluate_status() {
|
||||
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
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 (isset( $_POST['_gravityflow_admin_action'] ) ) {
|
||||
if ($status === 'cancelled' && $admin_action = rgpost( 'gravityflow_admin_action' )) {
|
||||
|
||||
$admin_action = rgpost( 'gravityflow_admin_action' );
|
||||
list( $base_admin_action, $step_id ) = rgexplode( '|', $admin_action, 2 );
|
||||
|
||||
list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
|
||||
|
||||
if ($base_admin_action === 'send_to_step' && $this->get_status() === 'pending') {
|
||||
$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';
|
||||
}
|
||||
@@ -157,18 +181,6 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_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() {
|
||||
|
||||
// return 'pending';
|
||||
}
|
||||
|
||||
public function workflow_detail_box($form, $args) {
|
||||
parent::workflow_detail_box($form, $args);
|
||||
|
||||
@@ -225,27 +237,6 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step {
|
||||
return $action_forms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves target form entry id created when step was started
|
||||
|
||||
Reference in New Issue
Block a user