activities_controller.php
2 months ago
auth_controller.php
3 months ago
booking_form_settings_controller.php
3 months ago
bookings_controller.php
4 days ago
calendars_controller.php
3 months ago
carts_controller.php
4 days ago
controller.php
3 months ago
customer_cabinet_controller.php
2 months ago
customers_controller.php
4 days ago
dashboard_controller.php
2 months ago
default_agent_controller.php
3 months ago
events_controller.php
3 months ago
form_fields_controller.php
1 week ago
integrations_controller.php
3 months ago
invoices_controller.php
4 days ago
manage_booking_by_key_controller.php
3 months ago
manage_order_by_key_controller.php
3 months ago
notifications_controller.php
3 months ago
orders_controller.php
4 days ago
pro_controller.php
3 weeks ago
process_jobs_controller.php
3 months ago
processes_controller.php
1 month ago
razorpay_connect_controller.php
1 week ago
search_controller.php
3 months ago
services_controller.php
3 months ago
settings_controller.php
2 months ago
steps_controller.php
3 weeks ago
stripe_connect_controller.php
1 week ago
support_topics_controller.php
3 months ago
todos_controller.php
3 months ago
transactions_controller.php
4 days ago
wizard_controller.php
1 week ago
manage_order_by_key_controller.php
110 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2023 LatePoint LLC. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | |
| 11 | if ( ! class_exists( 'OsManageOrderByKeyController' ) ) : |
| 12 | |
| 13 | |
| 14 | class OsManageOrderByKeyController extends OsController { |
| 15 | private $order; |
| 16 | private $key_for; |
| 17 | private $key = ''; |
| 18 | |
| 19 | private function set_order_by_key() { |
| 20 | if ( empty( $this->params['key'] ) ) { |
| 21 | return; |
| 22 | } |
| 23 | $key = sanitize_text_field( $this->params['key'] ); |
| 24 | $data = OsOrdersHelper::get_order_id_and_manage_ability_by_key( $key ); |
| 25 | if ( empty( $data ) ) { |
| 26 | return; |
| 27 | } |
| 28 | $order = new OsOrderModel( $data['order_id'] ); |
| 29 | if ( $order->id ) { |
| 30 | $this->key = $key; |
| 31 | $this->order = $order; |
| 32 | $this->key_for = $data['for']; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | function __construct() { |
| 37 | parent::__construct(); |
| 38 | $this->views_folder = LATEPOINT_VIEWS_ABSPATH . 'manage_order_by_key/'; |
| 39 | |
| 40 | $this->action_access['public'] = array_merge( |
| 41 | $this->action_access['public'], |
| 42 | [ |
| 43 | 'show', |
| 44 | 'print', |
| 45 | 'list_payments', |
| 46 | ] |
| 47 | ); |
| 48 | |
| 49 | $this->set_order_by_key(); |
| 50 | } |
| 51 | |
| 52 | function list_payments() { |
| 53 | if ( empty( $this->order->id ) ) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | $transactions = $this->order->get_transactions(); |
| 58 | |
| 59 | $this->vars['order'] = $this->order; |
| 60 | $this->vars['transactions'] = $transactions; |
| 61 | |
| 62 | $this->set_layout( 'clean' ); |
| 63 | $this->format_render( __FUNCTION__ ); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | function show() { |
| 68 | if ( empty( $this->order->id ) ) { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | $this->vars['key'] = $this->key; |
| 74 | $this->vars['for'] = $this->key_for; |
| 75 | $this->vars['order'] = $this->order; |
| 76 | $this->vars['viewer'] = $this->key_for == 'agent' ? 'agent' : 'customer'; |
| 77 | |
| 78 | $this->vars['timezone_name'] = $this->key_for == 'agent' ? OsTimeHelper::get_wp_timezone_name() : $this->order->customer->get_selected_timezone_name(); |
| 79 | |
| 80 | if ( $this->get_return_format() == 'json' ) { |
| 81 | $this->set_layout( 'none' ); |
| 82 | $response_html = $this->format_render_return( __FUNCTION__ ); |
| 83 | $this->send_json( |
| 84 | array( |
| 85 | 'status' => LATEPOINT_STATUS_SUCCESS, |
| 86 | 'message' => $response_html, |
| 87 | ) |
| 88 | ); |
| 89 | } else { |
| 90 | $this->set_layout( 'clean' ); |
| 91 | $content = $this->format_render_return( __FUNCTION__ ); |
| 92 | echo $content; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | |
| 97 | function print() { |
| 98 | if ( empty( $this->order->id ) ) { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | $this->vars['order'] = $this->order; |
| 103 | $this->vars['customer'] = $this->order->customer; |
| 104 | $this->set_layout( 'print' ); |
| 105 | $content = $this->format_render_return( 'print_order_info', [], [], true ); |
| 106 | echo $content; |
| 107 | } |
| 108 | } |
| 109 | endif; |
| 110 |