coupon-list.php
216 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 | |
| 20 | /** |
| 21 | * Determine active tab |
| 22 | */ |
| 23 | $active_tab = Input::get( 'data', 'all' ); |
| 24 | |
| 25 | /** |
| 26 | * Pagination data |
| 27 | */ |
| 28 | $paged_filter = Input::get( 'paged', 1, Input::TYPE_INT ); |
| 29 | $limit = (int) tutor_utils()->get_option( 'pagination_per_page', 10 ); |
| 30 | $offset = ( $limit * $paged_filter ) - $limit; |
| 31 | |
| 32 | $coupon_controller = new CouponController(); |
| 33 | |
| 34 | $get_coupons = $coupon_controller->get_coupons( $limit, $offset ); |
| 35 | $coupons = $get_coupons['results']; |
| 36 | $total_items = $get_coupons['total_count']; |
| 37 | /** |
| 38 | * Navbar data to make nav menu |
| 39 | */ |
| 40 | $page_slug = $coupon_controller::PAGE_SLUG; |
| 41 | $coupon_page_url = $coupon_controller::get_coupon_page_url(); |
| 42 | |
| 43 | $navbar_data = array( |
| 44 | 'page_title' => $coupon_controller->page_title, |
| 45 | 'tabs' => $coupon_controller->tabs_key_value(), |
| 46 | 'active' => $active_tab, |
| 47 | 'add_button' => true, |
| 48 | 'button_title' => __( 'Add New', 'tutor' ), |
| 49 | 'button_url' => $coupon_controller::get_coupon_page_url() . '&action=add_new', |
| 50 | ); |
| 51 | |
| 52 | /** |
| 53 | * Bulk action & filters |
| 54 | */ |
| 55 | $filters = array( |
| 56 | 'bulk_action' => $coupon_controller->bulk_action, |
| 57 | 'bulk_actions' => $coupon_controller->prepare_bulk_actions(), |
| 58 | 'ajax_action' => 'tutor_coupon_bulk_action', |
| 59 | 'filters' => true, |
| 60 | ); |
| 61 | |
| 62 | ?> |
| 63 | |
| 64 | <div class="tutor-admin-wrap"> |
| 65 | <?php |
| 66 | /** |
| 67 | * Load Templates with data. |
| 68 | */ |
| 69 | $navbar_template = tutor()->path . 'views/elements/navbar.php'; |
| 70 | $filters_template = tutor()->path . 'views/elements/filters.php'; |
| 71 | tutor_load_template_from_custom_path( $navbar_template, $navbar_data ); |
| 72 | tutor_load_template_from_custom_path( $filters_template, $filters ); |
| 73 | $currency_symbol = Settings::get_currency_symbol_by_code( tutor_utils()->get_option( OptionKeys::CURRENCY_CODE, 'USD' ) ); |
| 74 | ?> |
| 75 | <div class="tutor-admin-body"> |
| 76 | <div class="tutor-mt-24"> |
| 77 | <div class="tutor-table-responsive"> |
| 78 | |
| 79 | <table class="tutor-table tutor-table-middle table-dashboard-course-list"> |
| 80 | <thead class="tutor-text-sm tutor-text-400"> |
| 81 | <tr> |
| 82 | <th> |
| 83 | <div class="tutor-d-flex"> |
| 84 | <input type="checkbox" id="tutor-bulk-checkbox-all" class="tutor-form-check-input" /> |
| 85 | </div> |
| 86 | </th> |
| 87 | <th class="tutor-table-rows-sorting"> |
| 88 | <?php esc_html_e( 'Name', 'tutor' ); ?> |
| 89 | </th> |
| 90 | <th> |
| 91 | <?php esc_html_e( 'Discount', 'tutor' ); ?> |
| 92 | </th> |
| 93 | <th> |
| 94 | <?php esc_html_e( 'Type', 'tutor' ); ?> |
| 95 | </th> |
| 96 | <th> |
| 97 | <?php esc_html_e( 'Code', 'tutor' ); ?> |
| 98 | </th> |
| 99 | <th> |
| 100 | <?php esc_html_e( 'Status', 'tutor' ); ?> |
| 101 | </th> |
| 102 | <th colspan="2"> |
| 103 | <?php esc_html_e( 'Uses', 'tutor' ); ?> |
| 104 | </th> |
| 105 | </tr> |
| 106 | </thead> |
| 107 | |
| 108 | <tbody> |
| 109 | <?php if ( is_array( $coupons ) && count( $coupons ) ) : ?> |
| 110 | <?php |
| 111 | foreach ( $coupons as $key => $coupon ) : |
| 112 | ?> |
| 113 | <tr> |
| 114 | <td> |
| 115 | <div class="td-checkbox tutor-d-flex "> |
| 116 | <input type="checkbox" class="tutor-form-check-input tutor-bulk-checkbox" name="tutor-bulk-checkbox-all" value="<?php echo esc_attr( $coupon->id ); ?>" /> |
| 117 | </div> |
| 118 | </td> |
| 119 | |
| 120 | <td> |
| 121 | <div class="tutor-fs-7"> |
| 122 | <?php echo esc_html( $coupon->coupon_title ); ?> |
| 123 | </div> |
| 124 | </td> |
| 125 | |
| 126 | <td> |
| 127 | <div class="tutor-fs-7"> |
| 128 | <?php echo esc_html( 'flat' === $coupon->discount_type ? $currency_symbol . $coupon->discount_amount : $coupon->discount_amount . '%' ); ?> |
| 129 | </div> |
| 130 | </td> |
| 131 | <td> |
| 132 | <div class="tutor-fs-7"> |
| 133 | <?php echo esc_html( 'flat' === $coupon->discount_type ? __( 'Amount', 'tutor' ) : __( 'Percent', 'tutor' ) ); ?> |
| 134 | </div> |
| 135 | </td> |
| 136 | |
| 137 | <td> |
| 138 | <div class="tutor-fs-7"> |
| 139 | <?php echo esc_html( 'automatic' === $coupon->coupon_type ? __( 'Automatic', 'tutor' ) : $coupon->coupon_code ); ?> |
| 140 | </div> |
| 141 | </td> |
| 142 | |
| 143 | <td> |
| 144 | <?php |
| 145 | echo wp_kses_post( tutor_utils()->translate_dynamic_text( $coupon->coupon_status, true ) ); |
| 146 | ?> |
| 147 | </td> |
| 148 | |
| 149 | <td> |
| 150 | <?php echo esc_html( $coupon->usage_count ); ?> |
| 151 | </td> |
| 152 | <td> |
| 153 | <div class="tutor-d-flex tutor-align-center tutor-justify-end tutor-gap-2"> |
| 154 | <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"> |
| 155 | <?php esc_html_e( 'Edit', 'tutor' ); ?> |
| 156 | </a> |
| 157 | <?php if ( 'trash' === $active_tab ) : ?> |
| 158 | <div class="tutor-dropdown-parent"> |
| 159 | <button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle"> |
| 160 | <span class="tutor-icon-kebab-menu" area-hidden="true"></span> |
| 161 | </button> |
| 162 | <div id="table-dashboard-coupon-list-<?php echo esc_attr( $coupon->id ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left"> |
| 163 | <a href="javascript:void(0)" class="tutor-dropdown-item tutor-delete-permanently" |
| 164 | data-tutor-modal-target="tutor-common-confirmation-modal" data-action="tutor_coupon_permanent_delete" data-id="<?php echo esc_attr( $coupon->id ); ?>"> |
| 165 | <i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i> |
| 166 | <span> |
| 167 | <?php esc_html_e( 'Delete Permanently', 'tutor' ); ?> |
| 168 | </span> |
| 169 | </a> |
| 170 | </div> |
| 171 | </div> |
| 172 | <?php endif ?> |
| 173 | </div> |
| 174 | </td> |
| 175 | </tr> |
| 176 | <?php endforeach; ?> |
| 177 | <?php else : ?> |
| 178 | <tr> |
| 179 | <td colspan="100%" class="column-empty-state"> |
| 180 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 181 | </td> |
| 182 | </tr> |
| 183 | <?php endif; ?> |
| 184 | </tbody> |
| 185 | </table> |
| 186 | |
| 187 | <div class="tutor-admin-page-pagination-wrapper tutor-mt-32"> |
| 188 | <?php |
| 189 | /** |
| 190 | * Prepare pagination data & load template |
| 191 | */ |
| 192 | if ( $total_items > $limit ) { |
| 193 | $pagination_data = array( |
| 194 | 'total_items' => $total_items, |
| 195 | 'per_page' => $limit, |
| 196 | 'paged' => $paged_filter, |
| 197 | ); |
| 198 | $pagination_template = tutor()->path . 'views/elements/pagination.php'; |
| 199 | tutor_load_template_from_custom_path( $pagination_template, $pagination_data ); |
| 200 | } |
| 201 | ?> |
| 202 | </div> |
| 203 | </div> |
| 204 | <!-- end table responsive --> |
| 205 | </div> |
| 206 | </div> |
| 207 | </div> |
| 208 | |
| 209 | <?php |
| 210 | tutor_load_template_from_custom_path( |
| 211 | tutor()->path . 'views/elements/common-confirm-popup.php', |
| 212 | array( |
| 213 | 'message' => __( 'Deletion of the course will erase all its topics, lessons, quizzes, events, and other information. Please confirm your choice.', 'tutor' ), |
| 214 | ) |
| 215 | ); |
| 216 |