??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/renovaid.co.uk/wp-content/plugins/latepoint/lib/models/process_job_model.php
⬅ Kembali
<?php
/*
* Copyright (c) 2022 LatePoint LLC. All rights reserved.
*/
class OsProcessJobModel extends OsModel {
var $id,
$process_id,
$object_id,
$object_model_type,
$to_run_after_utc,
$status = LATEPOINT_JOB_STATUS_SCHEDULED,
$settings,
$run_result,
$process_info,
$updated_at,
$created_at;
function __construct( $id = false ) {
parent::__construct();
$this->table_name = LATEPOINT_TABLE_PROCESS_JOBS;
if ( $id ) {
$this->load_by_id( $id );
}
}
public function get_link_to_object() {
$href = '#';
$attrs = '';
switch ( $this->process->event_type ) {
case 'order_updated':
case 'order_created':
$attrs = OsOrdersHelper::quick_order_btn_html( $this->object_id );
break;
case 'customer_created':
$attrs = OsCustomerHelper::quick_customer_btn_html( $this->object_id );
break;
case 'booking_start':
case 'booking_end':
case 'booking_created':
case 'booking_updated':
$attrs = OsBookingHelper::quick_booking_btn_html( $this->object_id );
break;
}
$link = '<a href="' . esc_url( $href ) . '" ' . $attrs . '>' . esc_html( $this->object_id ) . '</a>';
return $link;
}
public function get_original_process_attribute( $attribute ) {
$process_info = json_decode( $this->process_info, true );
return $process_info[ $attribute ] ?? __( 'n/a', 'latepoint' );
}
public function get_action_by_id_from_settings( $action_id ) {
foreach ( $this->actions as $action ) {
if ( $action->id == $action_id ) {
return $action;
}
}
return null;
}
public function get_actions( $force_refresh = false ) {
if ( ! isset( $this->actions ) || $force_refresh ) {
$this->actions = [];
$settings = json_decode( $this->settings, true );
if ( $settings ) {
foreach ( $settings['action_data'] as $action_id => $action_data ) {
$action = new \LatePoint\Misc\ProcessAction();
$action->id = $action_id;
$action->type = $settings['action_info'][ $action_id ]['type'];
$action->prepared_data_for_run = $action_data;
$this->actions[] = $action;
}
}
}
return $this->actions;
}
public function get_actions_summary() {
$actions_html = '';
$process_actions = $this->get_actions();
$run_result = '';
if ( ! empty( $this->run_result ) ) {
$run_result = json_decode( $this->run_result, true );
}
if ( empty( $process_actions ) && empty( $run_result ) ) {
return __( 'No Actions', 'latepoint' );
}
foreach ( $process_actions as $action ) {
if ( isset( $run_result['ran_actions_info'][ $action->id ] ) ) {
$status_icon = $run_result['ran_actions_info'][ $action->id ]['run_status'] == LATEPOINT_STATUS_SUCCESS ? '<i style="color: #78ad06;" class="latepoint-icon latepoint-icon-checkmark"></i>' : '<i style="color: #ad0606;" class="latepoint-icon latepoint-icon-x-square"></i>';
$action_name = '<span>' . \LatePoint\Misc\ProcessAction::get_action_name_for_type( $run_result['ran_actions_info'][ $action->id ]['type'] ) . '</span>' . $status_icon . '</span>';
} else {
$action_name = '<span>' . \LatePoint\Misc\ProcessAction::get_action_name_for_type( $action->type ) . '</span><i class="latepoint-icon latepoint-icon-bell"></i></span>';
}
$action_icon = '';
switch ( $action->type ) {
case 'send_email':
$action_icon = '<i class="latepoint-icon latepoint-icon-mail"></i>';
break;
case 'send_sms':
$action_icon = '<i class="latepoint-icon latepoint-icon-message-circle"></i>';
break;
case 'trigger_webhook':
$action_icon = '<i class="latepoint-icon latepoint-icon-globe"></i>';
break;
}
$actions_html .= '<span
data-os-action="' . OsRouterHelper::build_route_name( 'process_jobs', 'preview_job_action' ) . '"
data-os-output-target="side-panel"
data-os-after-call="latepoint_init_json_view"
data-os-params="' . OsUtilHelper::build_os_params(
[
'job_id' => $this->id,
'action_id' => $action->id,
]
) . '"
data-os-lightbox-classes="width-800"
class="action-run-info-pill">' . $action_icon . $action_name . '</span>';
}
return $actions_html;
}
protected function get_process() {
if ( $this->process_id ) {
if ( ! isset( $this->process ) || ( isset( $this->process ) && ( $this->process->id != $this->process_id ) ) ) {
$this->process = new OsProcessModel( $this->process_id );
$this->process->build_from_json();
}
} else {
$this->process = new OsProcessModel();
}
return $this->process;
}
/**
* @param $action_ids_to_run IDs of actions that need to be run, all will run by default
* @return $this
*/
public function run( array $action_ids_to_run = [] ) {
$actions = $this->get_actions();
if ( $actions ) {
$settings = json_decode( $this->settings, true );
$error_messages = [];
// try to load from previous run, if it ever existed and if select action IDs are passed, otherwise overwrite. This is done to not override actions that ran before with partial actions that ran now
$previous_run_result = empty( $this->run_result ) ? [] : json_decode( $this->run_result, true );
$ran_actions_info = ( isset( $previous_run_result['ran_actions_info'] ) && $action_ids_to_run ) ? $previous_run_result['ran_actions_info'] : [];
foreach ( $actions as $action ) {
// skip if specific action IDs are passed and action in this loop is not one of the requested to be run
if ( $action_ids_to_run && ! in_array( $action->id, $action_ids_to_run ) ) {
continue;
}
if ( ! isset( $settings['action_data'][ $action->id ] ) ) {
$error_messages[] = $action->id . ': ' . __( 'Process action have been modified since the job was created.', 'latepoint' );
continue;
}
$action->prepared_data_for_run = $settings['action_data'][ $action->id ];
$result = $action->run( false );
$ran_actions_info[ $action->id ] = [
'type' => $action->type,
'id' => $action->id,
'run_status' => $result['status'],
'run_datetime_utc' => OsTimeHelper::now_datetime_utc_in_db_format(),
'run_message' => $result['message'],
];
if ( $result['status'] != LATEPOINT_STATUS_SUCCESS ) {
$error_messages[] = $action->id . ': ' . $result['message'];
}
}
if ( empty( $error_messages ) ) {
$this->status = LATEPOINT_JOB_STATUS_COMPLETED;
$message = $action_ids_to_run ? __( 'Selected actions ran successfully.', 'latepoint' ) . ' [' . implode( ',', $action_ids_to_run ) . ']' : __( 'The job ran successfully.', 'latepoint' );
$this->run_result = wp_json_encode(
[
'status' => LATEPOINT_STATUS_SUCCESS,
'run_datetime_utc' => OsTimeHelper::now_datetime_utc_in_db_format(),
'message' => $message,
'ran_actions_info' => $ran_actions_info,
]
);
} else {
$this->status = LATEPOINT_JOB_STATUS_ERROR;
$this->run_result = wp_json_encode(
[
'status' => LATEPOINT_STATUS_ERROR,
'run_datetime_utc' => OsTimeHelper::now_datetime_utc_in_db_format(),
'message' => implode( ', ', $error_messages ),
'ran_actions_info' => $ran_actions_info,
]
);
}
} else {
$this->run_result = wp_json_encode(
[
'status' => LATEPOINT_STATUS_SUCCESS,
'run_datetime_utc' => OsTimeHelper::now_datetime_utc_in_db_format(),
'message' => __( 'Job process has no actions to run', 'latepoint' ),
]
);
$this->status = LATEPOINT_JOB_STATUS_COMPLETED;
}
$activity = new OsActivityModel();
$event_type = $this->get_original_process_attribute( 'event_type' );
switch ( $event_type ) {
case 'order_created':
case 'order_updated':
$order = new OsOrderModel( $this->object_id );
$activity->customer_id = $order->customer_id;
$activity->order_id = $order->id;
break;
case 'booking_created':
case 'booking_updated':
case 'booking_start':
case 'booking_end':
$booking = new OsBookingModel( $this->object_id );
$activity->booking_id = $this->object_id;
$activity->customer_id = $booking->customer_id;
$activity->agent_id = $booking->agent_id;
$activity->service_id = $booking->service_id;
$activity->location_id = $booking->location_id;
$activity->order_id = $booking->order->id;
break;
case 'customer_created':
$activity->customer_id = $this->object_id;
break;
case 'transaction_created':
$transaction = new OsTransactionModel( $this->object_id );
$activity->order_id = $transaction->order_id;
break;
case 'payment_request_created':
$payment_request = new OsPaymentRequestModel( $this->object_id );
$activity->order_id = $payment_request->order_id;
break;
}
$this->save();
$activity->code = 'process_job_run';
if ( OsAuthHelper::get_highest_current_user_type() ) {
$activity->initiated_by = OsAuthHelper::get_highest_current_user_type();
$activity->initiated_by_id = OsAuthHelper::get_highest_current_user_id();
}
$activity->description = wp_json_encode(
[
'job_id' => $this->id,
'processed_datetime' => OsTimeHelper::now_datetime_in_db_format(),
'run_result' => $this->run_result,
'status' => LATEPOINT_STATUS_SUCCESS,
]
);
/**
* Activity that is created when a process job is run
*
* @since 5.1.0
* @hook latepoint_job_run_activity
*
* @param {OsActivityModel} $activity Activity model
* @param {OsProcessJobModel} $process_job Process job model
*
* @returns {OsActivityModel} Filtered activity model
*/
$activity = apply_filters( 'latepoint_job_run_activity', $activity, $this, $event_type );
$activity->save();
return $this;
}
protected function params_to_save( $role = 'admin' ) {
$params_to_save = [
'id',
'process_id',
'object_id',
'object_model_type',
'to_run_after_utc',
'status',
'process_info',
'settings',
'run_result',
];
return $params_to_save;
}
protected function allowed_params( $role = 'admin' ) {
$allowed_params = [
'id',
'process_id',
'object_id',
'object_model_type',
'to_run_after_utc',
'status',
'process_info',
'settings',
'run_result',
];
return $allowed_params;
}
protected function properties_to_validate() {
$validations = [];
return $validations;
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 activity_model.php
php
5.1 KB
2026-03-10 11:15
🐘 agent_meta_model.php
php
190 B
2026-03-10 11:15
🐘 agent_model.php
php
13.5 KB
2026-03-19 14:44
🐘 booking_meta_model.php
php
194 B
2026-03-10 11:15
🐘 booking_model.php
php
43.7 KB
2026-06-24 10:07
🐘 bundle_meta_model.php
php
192 B
2026-03-10 11:15
🐘 bundle_model.php
php
8.9 KB
2026-06-24 10:07
🐘 cart_item_model.php
php
8.4 KB
2026-03-10 11:15
🐘 cart_meta_model.php
php
253 B
2026-03-10 11:15
🐘 cart_model.php
php
16.8 KB
2026-06-15 12:21
🐘 connector_model.php
php
1.1 KB
2026-03-10 11:15
🐘 customer_meta_model.php
php
196 B
2026-03-10 11:15
🐘 customer_model.php
php
15.6 KB
2026-05-14 14:27
🐘 invoice_model.php
php
6 KB
2026-06-15 12:21
🐘 join_bundles_services_model.php
php
1 KB
2026-03-10 11:15
🐘 location_category_model.php
php
4.4 KB
2026-03-10 11:15
🐘 location_model.php
php
6.2 KB
2026-03-10 11:15
🐘 meta_model.php
php
3.8 KB
2026-03-10 11:15
🐘 model.php
php
32.2 KB
2026-03-10 11:15
🐘 off_period_model.php
php
3.1 KB
2026-03-10 11:15
🐘 order_intent_meta_model.php
php
268 B
2026-03-10 11:15
🐘 order_intent_model.php
php
18.8 KB
2026-06-24 10:07
🐘 order_item_model.php
php
8.4 KB
2026-03-10 11:15
🐘 order_meta_model.php
php
255 B
2026-03-10 11:15
🐘 order_model.php
php
18 KB
2026-05-29 11:28
🐘 otp_model.php
php
1.1 KB
2026-03-10 11:15
🐘 payment_request_model.php
php
2.5 KB
2026-03-10 11:15
🐘 process_job_model.php
php
10.3 KB
2026-03-10 11:15
🐘 process_model.php
php
7.8 KB
2026-05-29 11:28
🐘 recurrence_model.php
php
793 B
2026-03-10 11:15
🐘 service_category_model.php
php
3.8 KB
2026-03-10 11:15
🐘 service_meta_model.php
php
194 B
2026-03-10 11:15
🐘 service_model.php
php
18.6 KB
2026-03-10 11:15
🐘 session_model.php
php
898 B
2026-03-10 11:15
🐘 settings_model.php
php
973 B
2026-03-10 11:15
🐘 step_settings_model.php
php
1.1 KB
2026-03-10 11:15
🐘 transaction_intent_model.php
php
11 KB
2026-03-10 11:15
🐘 transaction_model.php
php
6 KB
2026-03-10 11:15
🐘 transaction_refund_model.php
php
1.5 KB
2026-03-10 11:15
🐘 work_period_model.php
php
1.6 KB
2026-03-10 11:15