??????????????
??????????????
??????????????
??????????????
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/location_model.php
⬅ Kembali
<?php
class OsLocationModel extends OsModel {
public $id,
$name,
$full_address,
$selection_image_id,
$status,
$category_id,
$order_number,
$services_agents_table_name,
$updated_at,
$created_at;
function __construct( $id = false ) {
parent::__construct();
$this->table_name = LATEPOINT_TABLE_LOCATIONS;
$this->services_agents_table_name = LATEPOINT_TABLE_AGENTS_SERVICES;
$this->nice_names = array(
'name' => __( 'Location Name', 'latepoint' ),
);
if ( $id ) {
$this->load_by_id( $id );
}
}
public function generate_data_vars(): array {
$location_category = empty( $this->category_id ) ? false : new OsLocationCategoryModel( $this->category_id );
return [
'id' => $this->id,
'name' => $this->name,
'full_address' => $this->full_address,
'category' => $location_category ? $location_category->get_data_vars() : [],
];
}
public function filter_allowed_records(): OsModel {
if ( ! OsRolesHelper::are_all_records_allowed( 'location' ) ) {
$this->filter_where_conditions( [ 'id' => OsRolesHelper::get_allowed_records( 'location' ) ] );
}
return $this;
}
protected function allowed_params( $role = 'admin' ) {
$allowed_params = array(
'id',
'name',
'full_address',
'status',
'category_id',
'order_number',
'selection_image_id',
);
return $allowed_params;
}
protected function params_to_save( $role = 'admin' ) {
$params_to_save = array(
'id',
'name',
'status',
'category_id',
'order_number',
'full_address',
'selection_image_id',
);
return $params_to_save;
}
protected function before_create() {
}
protected function set_defaults() {
if ( empty( $this->category_id ) ) {
$this->category_id = 0;
}
if ( empty( $this->status ) ) {
$this->status = LATEPOINT_LOCATION_STATUS_ACTIVE;
}
}
public function save_custom_schedule( $work_periods ) {
foreach ( $work_periods as &$work_period ) {
$work_period['location_id'] = $this->id;
}
unset( $work_period );
OsWorkPeriodsHelper::save_work_periods( $work_periods );
}
public function get_google_maps_link( $embed = false ) {
$extra = $embed ? '&output=embed' : '';
return 'https://google.com/maps?q=' . urlencode( $this->full_address ) . $extra;
}
public function get_google_maps_iframe( $height = '240' ) {
return '<iframe width="100%" height="' . $height . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $this->get_google_maps_link( true ) . '"></iframe>';
}
public function delete_custom_schedule() {
$work_periods_model = new OsWorkPeriodModel();
$work_periods = $work_periods_model->where(
array(
'location_id' => $this->id,
'agent_id' => 0,
'service_id' => 0,
'custom_date' => 'IS NULL',
)
)->get_results_as_models();
if ( is_array( $work_periods ) ) {
foreach ( $work_periods as $work_period ) {
$work_period->delete();
}
}
}
public function count_number_of_connected_services( $agent_id = false ) {
if ( $this->is_new_record() ) {
return 0;
}
$args = [ 'location_id' => $this->id ];
if ( $agent_id ) {
$args['agent_id'] = $agent_id;
}
return OsConnectorHelper::count_connections( $args, 'service_id' );
}
public function get_connected_agents() {
$connector = new OsConnectorModel();
$agent_ids = $connector->select( 'agent_id' )->where( [ 'location_id' => $this->id ] )->group_by( 'agent_id' )->get_results();
$agents = [];
if ( $agent_ids ) {
foreach ( $agent_ids as $connector_row ) {
$agents[] = new OsAgentModel( $connector_row->agent_id );
}
}
return $agents;
}
public function save_agents_and_services( $agents ) {
if ( ! $agents ) {
return true;
}
$connections_to_save = [];
$connections_to_remove = [];
foreach ( $agents as $agent_key => $services ) {
$agent_id = str_replace( 'agent_', '', $agent_key );
foreach ( $services as $service_key => $service ) {
$service_id = str_replace( 'service_', '', $service_key );
$connection = [
'location_id' => $this->id,
'agent_id' => $agent_id,
'service_id' => $service_id,
];
if ( $service['connected'] == 'yes' ) {
$connections_to_save[] = $connection;
} else {
$connections_to_remove[] = $connection;
}
}
}
if ( ! empty( $connections_to_save ) ) {
foreach ( $connections_to_save as $connection_to_save ) {
OsConnectorHelper::save_connection( $connection_to_save );
}
}
if ( ! empty( $connections_to_remove ) ) {
foreach ( $connections_to_remove as $connection_to_remove ) {
OsConnectorHelper::remove_connection( $connection_to_remove );
}
}
return true;
}
public function delete( $id = false ) {
if ( ! $id && isset( $this->id ) ) {
$id = $this->id;
}
if ( $id && $this->db->delete( $this->table_name, array( 'id' => $id ), array( '%d' ) ) ) {
$this->db->delete( LATEPOINT_TABLE_AGENTS_SERVICES, array( 'location_id' => $id ), array( '%d' ) );
$this->db->delete( LATEPOINT_TABLE_BOOKINGS, array( 'location_id' => $id ), array( '%d' ) );
$this->db->delete( LATEPOINT_TABLE_WORK_PERIODS, array( 'location_id' => $id ), array( '%d' ) );
return true;
} else {
return false;
}
}
public function should_be_active() {
return $this->where( [ 'status' => LATEPOINT_LOCATION_STATUS_ACTIVE ] );
}
public function is_active() {
return ( $this->status == LATEPOINT_LOCATION_STATUS_ACTIVE );
}
public function get_selection_image_url() {
$default_location_image_url = LATEPOINT_IMAGES_URL . 'location-image.png';
return OsImageHelper::get_image_url_by_id( $this->selection_image_id, 'thumbnail', $default_location_image_url );
}
public function has_agent( $agent_id ) {
return OsConnectorHelper::has_connection(
[
'location_id' => $this->id,
'agent_id' => $agent_id,
]
);
}
public function has_agent_and_service( $agent_id, $service_id ) {
if ( $this->is_new_record() ) {
return false;
}
return OsConnectorHelper::has_connection(
[
'location_id' => $this->id,
'agent_id' => $agent_id,
'service_id' => $service_id,
]
);
}
protected function properties_to_validate() {
$validations = array(
'name' => array( 'presence', 'uniqueness' ),
);
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