58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Coupons extends Users_Controller {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
|
|
redirect(home);
|
|
}
|
|
}
|
|
|
|
public function index(){
|
|
|
|
$data = $this->getSessionArray();
|
|
$this->load->model('coupon_model');
|
|
$activeCouponResult = $this->coupon_model->loadMemberActiveCoupons($_SESSION['member_id'] ,$fliters=[]);
|
|
$_SESSION['coupon'] = $activeCouponResult->num_rows();
|
|
$data['coupon_table_row'] = $activeCouponResult->result();
|
|
|
|
$redeemCouponResult = $this->coupon_model->loadMemberRedeemCoupons($_SESSION['member_id'] ,$fliters=[]);
|
|
$data['coupon_redeem_row'] = $redeemCouponResult->result();
|
|
|
|
|
|
|
|
$data['page_title'] ="Coupons";
|
|
$this->renderSecurePage('users/view_coupon', $data);
|
|
}
|
|
|
|
public function redeem(){
|
|
|
|
$what = $this->input->get('what');
|
|
$value = $this->input->get('value');
|
|
|
|
if ($what !='' && $value!=''){
|
|
$data = $this->getSessionArray();
|
|
$in=[];
|
|
|
|
$in['code_id'] = $what;
|
|
$in['code'] = $value; // just maing sure
|
|
$in['member_id'] = $_SESSION['member_id'];
|
|
$in['action'] = WRENCHBOARD_COUPON_REDEEM;
|
|
$this->load->model('backend_model');
|
|
$out = array();
|
|
$res = $this->backend_model->wrenchboard_api($in, $out);
|
|
if ( $res == 0 ){
|
|
echo 'Completed';
|
|
}
|
|
else
|
|
{
|
|
echo 'Redeem fail';
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
} |