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.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / views / pages / ecommerce / coupon-list.php
tutor / views / pages / ecommerce Last commit date
coupon-list.php 1 week ago order-list.php 6 months ago
coupon-list.php
260 lines
1 <?php
2 /**
3 * Course List Template.
4 *
5 * @package Tutor\Views
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 2.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 use Tutor\Ecommerce\CouponController;
16 use Tutor\Ecommerce\OptionKeys;
17 use Tutor\Ecommerce\Settings;
18 use TUTOR\Input;
19 use Tutor\Models\CouponModel;
20
21 /**
22 * Determine active tab
23 */
24 $active_tab = Input::get( 'data', 'all' );
25
26 /**
27 * Pagination data
28 */
29 $paged_filter = Input::get( 'paged', 1, Input::TYPE_INT );
30 $limit = (int) tutor_utils()->get_option( 'pagination_per_page', 10 );
31 $offset = ( $limit * $paged_filter ) - $limit;
32
33 $coupon_controller = new CouponController( false );
34
35 $get_coupons = $coupon_controller->get_coupons( $limit, $offset );
36 $coupons = $get_coupons['results'];
37 $total_items = $get_coupons['total_count'];
38 /**
39 * Navbar data to make nav menu
40 */
41 $page_slug = $coupon_controller::PAGE_SLUG;
42 $coupon_page_url = $coupon_controller::get_coupon_page_url();
43
44 $navbar_data = array(
45 'page_title' => $coupon_controller->page_title,
46 'tabs' => $coupon_controller->tabs_key_value(),
47 'active' => $active_tab,
48 'add_button' => true,
49 'button_title' => __( 'Add New', 'tutor' ),
50 'button_url' => $coupon_controller::get_coupon_page_url() . '&action=add_new',
51 );
52
53 $applies_to_options = array(
54 array(
55 'key' => '',
56 'title' => __( 'Select', 'tutor' ),
57 ),
58 );
59
60 $applies_to = array_map(
61 function ( $val, $key ) {
62 return array(
63 'key' => $key,
64 'title' => $val,
65 );
66 },
67 CouponModel::get_coupon_applies_to(),
68 array_keys( CouponModel::get_coupon_applies_to() )
69 );
70
71 $applies_to_options = array_merge( $applies_to_options, $applies_to );
72
73 /**
74 * Bulk action & filters
75 */
76 $filters = array(
77 'bulk_action' => $coupon_controller->bulk_action,
78 'bulk_actions' => $coupon_controller->prepare_bulk_actions(),
79 'ajax_action' => 'tutor_coupon_bulk_action',
80 'filters' => array(
81 array(
82 'label' => __( 'Status', 'tutor' ),
83 'field_type' => 'select',
84 'field_name' => 'data',
85 'options' => $coupon_controller->tabs_key_value(),
86 'searchable' => false,
87 'value' => Input::get( 'data', '' ),
88 ),
89 array(
90 'label' => __( 'Applies To', 'tutor' ),
91 'field_type' => 'select',
92 'field_name' => 'applies_to',
93 'options' => $applies_to_options,
94 'show_label' => true,
95 'value' => Input::get( 'applies_to', '' ),
96 ),
97 ),
98 );
99
100 ?>
101
102 <div class="tutor-admin-wrap">
103 <?php
104 /**
105 * Load Templates with data.
106 */
107 $navbar_template = tutor()->path . 'views/elements/list-navbar.php';
108 $filters_template = tutor()->path . 'views/elements/list-filters.php';
109 tutor_load_template_from_custom_path( $navbar_template, $navbar_data );
110 tutor_load_template_from_custom_path( $filters_template, $filters );
111 $currency_symbol = Settings::get_currency_symbol_by_code( tutor_utils()->get_option( OptionKeys::CURRENCY_CODE, 'USD' ) );
112 ?>
113 <div class="tutor-admin-container tutor-admin-container-lg">
114 <div class="tutor-mt-24 tutor-dashboard-list-table">
115 <div class="tutor-table-responsive">
116 <?php if ( is_array( $coupons ) && count( $coupons ) ) : ?>
117 <table class="tutor-table tutor-table-middle">
118 <thead class="tutor-text-sm tutor-text-400">
119 <tr>
120 <th>
121 <div class="tutor-d-flex">
122 <input type="checkbox" id="tutor-bulk-checkbox-all" class="tutor-form-check-input" />
123 </div>
124 </th>
125 <th class="tutor-table-rows-sorting">
126 <?php esc_html_e( 'Name', 'tutor' ); ?>
127 </th>
128 <th>
129 <?php esc_html_e( 'Applies to', 'tutor' ); ?>
130 </th>
131 <th>
132 <?php esc_html_e( 'Discount', 'tutor' ); ?>
133 </th>
134 <th>
135 <?php esc_html_e( 'Type', 'tutor' ); ?>
136 </th>
137 <th>
138 <?php esc_html_e( 'Code', 'tutor' ); ?>
139 </th>
140 <th>
141 <?php esc_html_e( 'Status', 'tutor' ); ?>
142 </th>
143 <th colspan="2">
144 <?php esc_html_e( 'Usage', 'tutor' ); ?>
145 </th>
146 </tr>
147 </thead>
148
149 <tbody>
150
151 <?php
152 foreach ( $coupons as $key => $coupon ) :
153 ?>
154 <tr>
155 <td>
156 <div class="td-checkbox tutor-d-flex ">
157 <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $coupon->id ); ?>" />
158 </div>
159 </td>
160
161 <td>
162 <a href="<?php echo esc_url( $coupon_page_url . '&action=edit&coupon_id=' . $coupon->id ); ?>" class="tutor-table-link tutor-fs-7">
163 <?php echo esc_html( $coupon->coupon_title ); ?>
164 </a>
165 </td>
166
167 <td>
168 <div class="tutor-fs-7">
169 <?php echo esc_html( CouponModel::get_coupon_applies_to_label( $coupon->applies_to ) ); ?>
170 </div>
171 </td>
172
173 <td>
174 <div class="tutor-fs-7">
175 <?php echo wp_kses_post( ( 'flat' === $coupon->discount_type ? tutor_utils()->tutor_price( $coupon->discount_amount ) : $coupon->discount_amount . '%' ) ); ?>
176 </div>
177 </td>
178 <td>
179 <div class="tutor-fs-7">
180 <?php echo esc_html( 'flat' === $coupon->discount_type ? __( 'Fixed Amount', 'tutor' ) : __( 'Percentage', 'tutor' ) ); ?>
181 </div>
182 </td>
183
184 <td>
185 <div class="tutor-fs-7">
186 <?php echo esc_html( 'automatic' === $coupon->coupon_type ? __( 'Automatic', 'tutor' ) : $coupon->coupon_code ); ?>
187 </div>
188 </td>
189
190 <td>
191 <?php
192 $coupon_status = $coupon_controller->get_coupon_display_status( $coupon );
193 echo wp_kses_post( tutor_utils()->translate_dynamic_text( $coupon_status, true ) );
194 ?>
195 </td>
196
197 <td>
198 <?php echo esc_html( $coupon->usage_count ); ?>
199 </td>
200 <td>
201 <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-2">
202 <a href="<?php echo esc_url( $coupon_page_url . '&action=edit&coupon_id=' . $coupon->id ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-sm">
203 <?php esc_html_e( 'Edit', 'tutor' ); ?>
204 </a>
205 <?php if ( 'trash' === $active_tab ) : ?>
206 <div class="tutor-dropdown-parent">
207 <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
208 <span class="tutor-icon-kebab-menu" aria-hidden="true"></span>
209 </button>
210 <div id="table-dashboard-coupon-list-<?php echo esc_attr( $coupon->id ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
211 <a href="javascript:void(0)" class="tutor-dropdown-item tutor-delete-permanently"
212 data-tutor-modal-target="tutor-common-confirmation-modal" data-action="tutor_coupon_permanent_delete" data-id="<?php echo esc_attr( $coupon->id ); ?>">
213 <i class="tutor-icon-trash-can-bold tutor-mr-8" aria-hidden="true"></i>
214 <span>
215 <?php esc_html_e( 'Delete Permanently', 'tutor' ); ?>
216 </span>
217 </a>
218 </div>
219 </div>
220 <?php endif ?>
221 </div>
222 </td>
223 </tr>
224 <?php endforeach; ?>
225 </tbody>
226 </table>
227 <?php else : ?>
228 <?php tutils()->render_list_empty_state(); ?>
229 <?php endif; ?>
230
231 <div class="tutor-admin-page-pagination-wrapper tutor-mt-32">
232 <?php
233 /**
234 * Prepare pagination data & load template
235 */
236 if ( $total_items > $limit ) {
237 $pagination_data = array(
238 'total_items' => $total_items,
239 'per_page' => $limit,
240 'paged' => $paged_filter,
241 );
242 $pagination_template = tutor()->path . 'views/elements/pagination.php';
243 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
244 }
245 ?>
246 </div>
247 </div>
248 <!-- end table responsive -->
249 </div>
250 </div>
251 </div>
252
253 <?php
254 tutor_load_template_from_custom_path(
255 tutor()->path . 'views/elements/common-confirm-popup.php',
256 array(
257 'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ),
258 )
259 );
260