Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/views/pages/ecommerce/coupon-list.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
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 ? __( 'Amount', 'tutor' ) : __( 'Percent', '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->coupon_status;
193
+
if ( CouponModel::STATUS_ACTIVE === $coupon_status ) {
194
+
$coupon_status = $coupon_controller->model->has_coupon_validity( $coupon ) ? $coupon->coupon_status : 'expired';
195
+
}
196
+
echo wp_kses_post( tutor_utils()->translate_dynamic_text( $coupon_status, true ) );
197
+
?>
198
+
</td>
199
+
200
+
<td>
201
+
<?php echo esc_html( $coupon->usage_count ); ?>
202
+
</td>
203
+
<td>
204
+
<div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-2">
205
+
<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">
206
+
<?php esc_html_e( 'Edit', 'tutor' ); ?>
207
+
</a>
208
+
<?php if ( 'trash' === $active_tab ) : ?>
209
+
<div class="tutor-dropdown-parent">
210
+
<button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
211
+
<span class="tutor-icon-kebab-menu" area-hidden="true"></span>
212
+
</button>
213
+
<div id="table-dashboard-coupon-list-<?php echo esc_attr( $coupon->id ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
214
+
<a href="javascript:void(0)" class="tutor-dropdown-item tutor-delete-permanently"
215
+
data-tutor-modal-target="tutor-common-confirmation-modal" data-action="tutor_coupon_permanent_delete" data-id="<?php echo esc_attr( $coupon->id ); ?>">
216
+
<i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
217
+
<span>
218
+
<?php esc_html_e( 'Delete Permanently', 'tutor' ); ?>
219
+
</span>
220
+
</a>
221
+
</div>
222
+
</div>
223
+
<?php endif ?>
224
+
</div>
225
+
</td>
226
+
</tr>
227
+
<?php endforeach; ?>
228
+
</tbody>
229
+
</table>
230
+
<?php else : ?>
231
+
<?php tutils()->render_list_empty_state(); ?>
232
+
<?php endif; ?>
233
+
234
+
<div class="tutor-admin-page-pagination-wrapper tutor-mt-32">
235
+
<?php
236
+
/**
237
+
* Prepare pagination data & load template
238
+
*/
239
+
if ( $total_items > $limit ) {
240
+
$pagination_data = array(
241
+
'total_items' => $total_items,
242
+
'per_page' => $limit,
243
+
'paged' => $paged_filter,
244
+
);
245
+
$pagination_template = tutor()->path . 'views/elements/pagination.php';
246
+
tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
247
+
}
248
+
?>
249
+
</div>
250
+
</div>
251
+
<!-- end table responsive -->
252
+
</div>
253
+
</div>
254
+
</div>
255
+
256
+
<?php
257
+
tutor_load_template_from_custom_path(
258
+
tutor()->path . 'views/elements/common-confirm-popup.php',
259
+
array(
260
+
'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ),
261
+
)
262
+
);
263
+