??????????????
??????????????
??????????????
??????????????
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/transaction_model.php
⬅ Kembali
<?php
class OsTransactionModel extends OsModel {
public $id,
$token,
$invoice_id,
$order_id,
$customer_id,
$processor,
$payment_method,
$payment_portion,
$access_key,
$receipt_number,
$kind,
$amount,
$status,
$notes,
$updated_at,
$created_at;
function __construct( $id = false ) {
parent::__construct();
$this->table_name = LATEPOINT_TABLE_TRANSACTIONS;
$this->nice_names = [ 'token' => __( 'Confirmation Number', 'latepoint' ) ];
if ( $id ) {
$this->load_by_id( $id );
}
}
/**
* @return OsTransactionRefundModel[]
*/
public function get_refunds( $force_query = false ): array {
if ( ! isset( $this->refunds ) || $force_query ) {
$transaction_refunds = new OsTransactionRefundModel();
$transaction_refunds = $transaction_refunds->where( [ 'transaction_id' => $this->id ] )->get_results_as_models();
$this->refunds = $transaction_refunds;
}
return $this->refunds;
}
public function get_total_refunded_amount() {
$refunds = $this->get_refunds();
$total = 0;
if ( $refunds ) {
foreach ( $refunds as $refund ) {
$total = $total + $refund->amount;
}
}
return $total;
}
public function is_fully_refunded(): bool {
return ! ( $this->get_total_refunded_amount() < $this->amount );
}
public function can_refund(): bool {
if ( $this->is_new_record() ) {
return false;
}
$can_refund = apply_filters( 'latepoint_transaction_is_refund_available', false, $this );
if ( ! $can_refund ) {
return false;
}
if ( $this->is_fully_refunded() ) {
return false;
}
return true;
}
public function properties_to_query(): array {
return [
'payment_method' => __( 'Payment Method', 'latepoint' ),
'payment_portion' => __( 'Payment Portion', 'latepoint' ),
'kind' => __( 'Type', 'latepoint' ),
];
}
public function generate_data_vars(): array {
return [
'id' => $this->id,
'order_id' => $this->order_id,
'invoice_id' => $this->invoice_id,
'token' => $this->token,
'customer_id' => $this->customer_id,
'processor' => $this->processor,
'payment_method' => $this->payment_method,
'payment_portion' => $this->payment_portion_nice_name,
'kind' => $this->kind,
'status' => $this->status,
'amount' => OsMoneyHelper::format_price( $this->amount ),
'notes' => $this->notes,
];
}
public function get_receipt_url(): string {
if ( empty( $this->access_key ) ) {
$this->update_attributes( [ 'access_key' => OsUtilHelper::generate_uuid() ] );
}
return OsRouterHelper::build_admin_post_link( [ 'transactions', 'view_receipt_by_key' ], [ 'key' => $this->access_key ] );
}
public function get_invoice_url(): string {
if ( empty( $this->invoice_id ) ) {
return '';
}
$invoice = new OsInvoiceModel( $this->invoice_id );
if ( $invoice->is_new_record() ) {
return '';
}
return $invoice->get_access_url();
}
public function filter_allowed_records(): OsModel {
if ( ! OsRolesHelper::are_all_records_allowed() ) {
// join orders table to filter allowed transactions
$this->join( LATEPOINT_TABLE_BOOKINGS, [ 'id' => $this->table_name . '.order_id' ] );
$this->select( LATEPOINT_TABLE_TRANSACTIONS . '.*' );
if ( ! OsRolesHelper::are_all_records_allowed( 'agent' ) ) {
$this->select( LATEPOINT_TABLE_BOOKINGS . '.agent_id' );
$this->filter_where_conditions( [ LATEPOINT_TABLE_BOOKINGS . '.agent_id' => OsRolesHelper::get_allowed_records( 'agent' ) ] );
}
if ( ! OsRolesHelper::are_all_records_allowed( 'location' ) ) {
$this->select( LATEPOINT_TABLE_BOOKINGS . '.location_id' );
$this->filter_where_conditions( [ LATEPOINT_TABLE_BOOKINGS . '.location_id' => OsRolesHelper::get_allowed_records( 'location' ) ] );
}
if ( ! OsRolesHelper::are_all_records_allowed( 'service' ) ) {
$this->select( LATEPOINT_TABLE_BOOKINGS . '.service_id' );
$this->filter_where_conditions( [ LATEPOINT_TABLE_BOOKINGS . '.service_id' => OsRolesHelper::get_allowed_records( 'service' ) ] );
}
}
return $this;
}
protected function params_to_sanitize() {
return [ 'amount' => 'money' ];
}
public function generate_receipt_number(): string {
return strtoupper( OsUtilHelper::random_text( 'distinct', 8 ) );
}
protected function before_save() {
if ( empty( $this->receipt_number ) ) {
$this->receipt_number = $this->generate_receipt_number();
}
if ( empty( $this->access_key ) ) {
$this->access_key = OsUtilHelper::generate_uuid();
}
}
public function get_payment_portion_nice_name( $default = '' ) {
$payment_portions = OsPaymentsHelper::get_payment_portions_list();
$nice_name = ( ! empty( $this->payment_portion ) && isset( $payment_portions[ $this->payment_portion ] ) ) ? $payment_portions[ $this->payment_portion ] : $default;
return $nice_name;
}
protected function get_customer(): OsCustomerModel {
$order = $this->get_order();
return $order->customer;
}
protected function get_order(): OsOrderModel {
if ( $this->order_id ) {
if ( ! isset( $this->order ) || ( isset( $this->order ) && ( $this->order->id != $this->order_id ) ) ) {
$this->order = new OsOrderModel( $this->order_id );
}
} else {
$this->order = new OsOrderModel();
}
return $this->order;
}
protected function params_to_save( $role = 'admin' ): array {
$params_to_save = array(
'id',
'token',
'invoice_id',
'order_id',
'processor',
'customer_id',
'payment_method',
'payment_portion',
'access_key',
'receipt_number',
'kind',
'amount',
'status',
'notes',
);
return $params_to_save;
}
protected function allowed_params( $role = 'admin' ): array {
$allowed_params = array(
'id',
'token',
'invoice_id',
'order_id',
'processor',
'customer_id',
'payment_method',
'payment_portion',
'access_key',
'receipt_number',
'kind',
'amount',
'status',
'notes',
);
return $allowed_params;
}
protected function properties_to_validate(): array {
$validations = array(
'order_id' => array( 'presence' ),
);
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