PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / includes / AdminSalesReps.class.php

AdminSalesReps.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at includes/AdminSalesReps.class.php

209 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) exit;
3
4 if ( !class_exists( 'ewdotpAdminSalesReps' ) ) {
5 /**
6 * Class to handle the admin sales reps page for Order Tracking
7 *
8 * @since 3.0.0
9 */
10 class ewdotpAdminSalesReps {
11
12 /**
13 * The sales reps table
14 *
15 * This is only instantiated on the sales reps admin page at the moment when
16 * it is generated.
17 *
18 * @see self::show_admin_sales_reps_page()
19 * @see WP_List_table.BookingsTable.class.php
20 * @since 3.0.0
21 */
22 public $sales_reps_table;
23
24 public function __construct() {
25
26 // Add the admin menu
27 add_action( 'admin_menu', array( $this, 'add_menu_page' ) );
28
29 // Hide the 'Add New' item from the side menu
30 add_action( 'admin_head', array( $this, 'hide_add_new_menu_item' ) );
31 }
32
33 /**
34 * Add the top-level admin menu page
35 * @since 3.0.0
36 */
37 public function add_menu_page() {
38 global $ewd_otp_controller;
39
40 add_submenu_page(
41 'ewd-otp-orders',
42 _x( 'Sales Reps', 'Title of admin page that lets you view all sales reps', 'order-tracking' ),
43 _x( 'Sales Reps', 'Title of the sales reps admin menu item', 'order-tracking' ),
44 $ewd_otp_controller->settings->get_setting( 'access-role' ),
45 'ewd-otp-sales-reps',
46 array( $this, 'show_admin_sales_reps_page' )
47 );
48
49 add_submenu_page(
50 'ewd-otp-orders',
51 _x( 'Add/Edit Sales Rep', 'Title of admin page that lets you add or edit an sales rep', 'order-tracking' ),
52 _x( 'Add New', 'Title of the add/edit sales rep admin menu item', 'order-tracking' ),
53 $ewd_otp_controller->settings->get_setting( 'access-role' ),
54 'ewd-otp-add-edit-sales-rep',
55 array( $this, 'add_edit_sales_rep' )
56 );
57
58 $sales_rep = new ewdotpSalesRep();
59
60 $sales_rep->load_sales_rep_from_wp_id( get_current_user_id() );
61
62 if ( empty( $sales_rep->id ) or current_user_can( $ewd_otp_controller->settings->get_setting( 'access-role' ) ) ) { return; }
63
64 add_menu_page(
65 'Order Tracking Plugin',
66 'Order Tracking',
67 'read',
68 'ewd-otp-sales-rep-orders',
69 array( $this, 'show_sales_rep_orders_page' ),
70 'dashicons-location',
71 '50.9'
72 );
73 }
74
75 /**
76 * Hide the 'Add New' admin page from the WordPress sidebar menu
77 * @since 3.0.0
78 */
79 public function hide_add_new_menu_item() {
80
81 remove_submenu_page( 'ewd-otp-orders', 'ewd-otp-add-edit-sales-rep' );
82 }
83
84 /**
85 * Display the admin sales reps page
86 * @since 3.0.0
87 */
88 public function show_admin_sales_reps_page() {
89 global $ewd_otp_controller;
90
91 require_once( EWD_OTP_PLUGIN_DIR . '/includes/WP_List_Table.SalesRepsTable.class.php' );
92 $this->sales_reps_table = new ewdotpSalesRepsTable();
93 $this->sales_reps_table->prepare_items();
94
95 $permission = ( $ewd_otp_controller->permissions->check_permission( 'sales_reps' ) or get_option( 'ewd-otp-installation-time' ) < 1664742505 ) ? true : false;
96 ?>
97
98 <div class="wrap">
99 <h1>
100 <?php _e( 'Sales Reps', 'order-tracking' ); ?>
101 <?php if ( $permission ) { ?><a href="admin.php?page=ewd-otp-add-edit-sales-rep" class="add-new-h2 page-title-action add-sales_rep"><?php _e( 'Add New', 'order-tracking' ); ?></a><?php } ?>
102 </h1>
103
104 <?php if ( $permission ) { ?>
105
106 <?php do_action( 'ewd_otp_sales_reps_table_top' ); ?>
107 <form id="ewd-otp-sales-reps-table" method="POST" action="">
108 <input type="hidden" name="page" value="ewd-otp-sales-reps">
109
110 <div class="ewd-otp-primary-controls clearfix">
111 <div class="ewd-otp-views">
112 <?php $this->sales_reps_table->views(); ?>
113 </div>
114 <?php $this->sales_reps_table->advanced_filters(); ?>
115 </div>
116
117 <?php $this->sales_reps_table->display(); ?>
118 </form>
119 <?php do_action( 'ewd_otp_sales_reps_table_bottom' ); ?>
120
121 <?php } else { ?>
122
123 <div class='ewd-otp-premium-locked'>
124 <a href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1" target="_blank">Upgrade</a> to the premium version to use this feature
125 </div>
126 <?php } ?>
127 </div>
128
129 <?php
130 }
131
132 /**
133 * Display the admin sales reps page
134 * @since 3.0.0
135 */
136 public function show_sales_rep_orders_page() {
137
138 $sales_rep = new ewdotpSalesRep();
139
140 $sales_rep->load_sales_rep_from_wp_id( get_current_user_id() );
141
142 if ( empty( $sales_rep->id ) ) { return; }
143
144 $args['sales_rep'] = $sales_rep->id;
145
146 require_once( EWD_OTP_PLUGIN_DIR . '/includes/WP_List_Table.OrdersTable.class.php' );
147 $this->orders_table = new ewdotpOrdersTable( $args );
148 $this->orders_table->prepare_items();
149 ?>
150
151 <div class="wrap">
152 <h1>
153 <?php _e( 'Orders', 'order-tracking' ); ?>
154 <a href="admin.php?page=ewd-otp-add-edit-order" class="add-new-h2 page-title-action add-order"><?php _e( 'Add New', 'order-tracking' ); ?></a>
155 </h1>
156
157 <?php do_action( 'ewd_otp_orders_table_top' ); ?>
158 <form id="ewd-otp-orders-table" method="POST" action="">
159 <input type="hidden" name="page" value="ewd-otp-orders">
160
161 <div class="ewd-otp-primary-controls clearfix">
162 <div class="ewd-otp-views">
163 <?php $this->orders_table->views(); ?>
164 </div>
165 <?php $this->orders_table->advanced_filters(); ?>
166 </div>
167
168 <?php $this->orders_table->display(); ?>
169 </form>
170 <?php do_action( 'ewd_otp_orders_table_bottom' ); ?>
171 </div>
172
173 <?php
174 }
175
176 /**
177 * Display the admin sales reps page
178 * @since 3.0.0
179 */
180 public function add_edit_sales_rep() {
181 global $ewd_otp_controller;
182
183 $sales_rep_id = ! empty( $_GET['sales_rep_id'] ) ? intval( $_GET['sales_rep_id'] ) : 0;
184
185 $sales_rep = new ewdotpSalesRep();
186
187 if ( $sales_rep_id ) {
188
189 $sales_rep->load_sales_rep_from_id( $sales_rep_id );
190 }
191
192 if ( isset( $_POST['ewd_otp_admin_sales_rep_submit'] ) ) {
193
194 $sales_rep->process_admin_sales_rep_submission();
195 }
196
197 ewd_otp_load_view_files();
198
199 $args = array(
200 'sales_rep' => $sales_rep
201 );
202
203 $admin_sales_rep_view = new ewdotpAdminSalesRepFormView( $args );
204
205 echo $admin_sales_rep_view->render();
206 }
207 }
208 } // endif;
209