public function actionCoupon_activate($id)
 {
     if ($this->userHasRedeemedCoupon($id)) {
         $this->render('coupon_already_redeemed');
         return;
     }
     $this->layout = "main";
     $model = new CouponRedemption();
     $customer = Customer::model()->findByPk(Yii::app()->user->getId());
     if ($customer == null) {
         throw new CHttpException(400, 'Invalid request. No customer found!');
     }
     $model->phone = $customer->mobile;
     if (isset($_POST['CouponRedemption'])) {
         $model->attributes = $_POST['CouponRedemption'];
         $model->date_created = date("Y-m-d h:i:s");
         if ($model->save()) {
             $this->redirect(array('listing/coupon_activated', 'id' => $model->credemption_id));
         }
     }
     if (isset($_GET['CouponRedemption'])) {
         $model->attributes = $_GET['CouponRedemption'];
     }
     $model->coupon_id = $id;
     $this->render('coupon_activate', array('model' => $model));
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new CouponRedemption();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['CouponRedemption'])) {
         $model->attributes = $_POST['CouponRedemption'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     if (isset($_GET['CouponRedemption'])) {
         $model->attributes = $_GET['CouponRedemption'];
     }
     $this->render('index', array('model' => $model));
 }