/** * ajax return coupon list page */ function load_page() { header('HTTP/1.0 200 OK'); header('Content-type: application/json'); $paged = $_GET['paged']; $args = array('post_type' => 'je_coupon', 'post_status' => 'publish', 'paged' => $paged); $coupon_list = new WP_Query($args); $plans = et_get_payment_plans(); $resume_plan = et_get_resume_plans(); $currency = ET_Payment::get_currency(); $tr = ''; while ($coupon_list->have_posts()) { $coupon_list->the_post(); global $post; $coupon_data = $this->generate_coupon_response(get_the_title()); $date_limit = $coupon_data['date_limit']; $added_product = $coupon_data['added_product']; if ($date_limit == 'on') { $start_date = $coupon_data['start_date']; $expired_date = $coupon_data['expired_date']; } else { $start_date = __("Lifetime", ET_DOMAIN); $expired_date = __("Lifetime", ET_DOMAIN); } if ($coupon_data['discount_type'] == 'percent') { $type = ' (%)'; } else { $type = $currency['code']; } $products = ''; if (empty($added_product)) { $products = __("All job packages", ET_DOMAIN); } else { $num = count($added_product); $i = 0; foreach ($added_product as $key => $value) { $i++; $products .= $value; if ($i < $num) { $products .= ', '; } } } $tr .= '<tr id="coupon-' . $post->ID . '" data-coupon="' . $post->ID . '" >' . '<script id="coupon_' . $post->ID . '" type="text/data">' . json_encode($coupon_data) . '</script>' . '<td>' . $coupon_data['coupon_code'] . '</td>' . '<td align="center">' . $start_date . '</td>' . '<td align="center">' . $expired_date . '</td>' . '<td>' . $coupon_data['discount_rate'] . ' ' . $type . '</td>' . '<td>' . $products . '</td>' . '<td>' . intval($coupon_data['have_been_used']) . '<span class="count">/' . $coupon_data['usage_count'] . '</span></td>' . '<td align="center">' . '<a href="#" class="delete" title="' . __("Delete", ET_DOMAIN) . '"><span class="icon" data-icon="-"></span></a>' . '<a href="#" class="edit" title="' . __("Edit", ET_DOMAIN) . '"><span class="icon" data-icon="p"></span></a>' . '</td>' . '</tr>'; } $paginate = ''; if ($coupon_list->max_num_pages > 1) { for ($i = 1; $i <= $coupon_list->max_num_pages; $i++) { if ($i != $paged) { $paginate .= '<li data-page="' . $i . '" ><a href="#" class="pi">' . $i . '</a></li>'; } else { $paginate .= '<li data-page="' . $i . '" ><span class="current">' . $i . '</span></li>'; } } } $response = array('success' => true, 'data' => $tr, 'paginate' => $paginate); echo json_encode($response); exit; }
<?php $plans = et_get_payment_plans(); $resume_plan = et_get_resume_plans(); ?> <div id="add_coupon_form" style="display:none"> <div class="module"> <div class="title font-quicksand"><?php _e("New Coupon", ET_DOMAIN); ?> <a class="f-right back-coupon" href="#" title="Back to Coupon List" id="back_to_list"> <span class="icon" data-icon="["></span> <?php _e("Back to Coupon List ", ET_DOMAIN); ?> </a> </div> <div class="desc no-left"> <?php //_e("Specify options for coupon code", ET_DOMAIN); ?> </div> </div> <div class="module job-coupon-form"> <form action="#" method="post" id="coupon_form"> <input type="hidden" name="coupon_id" value="" /> <input type="hidden" name="action" value="je-update-coupon" /> <div class="form-item"> <label><?php _e("Coupon Usage Count <span>(How many times the coupon can be used)</span>", ET_DOMAIN);