Пример #1
0
 /**
  * Regsiter a new user
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function actionCreate()
 {
     $model = new Users();
     $ncashCredit = self::REWARD_ON_REGSITER;
     $promoCodeValidate = true;
     if (!empty($_GET['promo_code'])) {
         $promoCodeModel = new CouponCode();
         $promoData = $promoCodeModel->findByCouponCodeValue($_GET['promo_code']);
         $currentDate = $this->getCurrentDateTime();
         if ($promoData && $currentDate > $promoData->valid_from && $currentDate < $promoData->valid_to && $promoData->is_active) {
             $ncashCredit = $promoData->ncash_credit;
         } else {
             $this->result['message'] = 'Invalid Promo code.';
             $promoCodeValidate = false;
         }
     }
     if ($promoCodeValidate) {
         if (!empty($_GET['username']) && !empty($_GET['password'])) {
             if ($model->findByUsername($_GET['username'])) {
                 $this->result['message'] = 'Username already exist. Choose different one.';
             } else {
                 if (!empty($_GET['facebookAccount'])) {
                     $_GET['password'] = md5($_GET['facebookAccount']);
                 } else {
                     $_GET['password'] = isset($_GET['password']) ? md5($_GET['password']) : '';
                 }
                 $model->attributes = $_GET;
                 $model->slugname = $_GET['username'];
                 $model->active = 1;
                 if (!empty($promoData->id_coupon_code)) {
                     $model->fk_coupon_code = $promoData->id_coupon_code;
                 }
                 //                $model->rewardpoints = self::REWARD_ON_REGSITER;
                 if ($model->validate() && $model->save()) {
                     $notficationModel = new Notifications();
                     $notficationModel->sendPushNotification(array('deviceToken' => $model->deviceToken, 'deviceType' => $model->deviceType, 'message' => 1));
                     $userObj = $model->findByUsername($_GET['username']);
                     $nCash = new Ncash();
                     $nCash->addAmount($userObj->user_id, $ncashCredit, 4);
                     $this->result['data'] = $userObj;
                     $this->result['success'] = true;
                     $this->result['message'] = 'User regsitered successfully.';
                 } else {
                     $this->result['message'] = 'Invalid Data.';
                 }
             }
         } else {
             $this->result['message'] = 'No data to save.';
         }
     }
     $this->sendResponse($this->result);
 }
Пример #2
0
 public function testCouponCode()
 {
     if (!class_exists('lttLib')) {
         include dirname(__FILE__) . '/lttLib.php';
     }
     $cc = new CouponCode();
     $out = $cc->handle('0051234512345', array());
     $expected_error = DisplayLib::boxMsg(_("product not found") . "<br />" . _("in transaction"), '', true, DisplayLib::standardClearButton());
     $this->assertArrayHasKey('output', $out);
     $this->assertEquals($out['output'], $expected_error);
     lttLib::clear();
     $out = $cc->handle('0051234599210', array());
     $record = lttLib::genericRecord();
     $record['upc'] = '0051234599210';
     $record['description'] = ' * Manufacturers Coupon';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'CP';
     $record['trans_status'] = 'C';
     $record['quantity'] = 1;
     $record['ItemQtty'] = 1;
     $record['unitPrice'] = -0.1;
     $record['total'] = -0.1;
     $record['regPrice'] = -0.1;
     lttLib::verifyRecord(1, $record, $this);
     lttLib::clear();
     $db = Database::tDataConnect();
     $db->query('TRUNCATE TABLE couponApplied');
     $u = new UPC();
     $u->parse('0001101312028');
     $out = $cc->handle('0051101399901', array());
     $record = lttLib::genericRecord();
     $record['upc'] = '0051101399901';
     $record['description'] = ' * Manufacturers Coupon';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'CP';
     $record['trans_status'] = 'C';
     $record['department'] = 181;
     $record['quantity'] = 1;
     $record['ItemQtty'] = 1;
     $record['unitPrice'] = -4.59;
     $record['total'] = -4.59;
     $record['regPrice'] = -4.59;
     lttLib::verifyRecord(2, $record, $this);
 }
    }
    /*
        echo '<script>window.location.href="paymentoptions.php";</script>';
        exit();*/
    //  }
}
// Shipping total
$_SESSION['SHIPPING_TOTAL'] = $_POST['shippingtotal'] == "" ? 0 : $_POST['shippingtotal'];
// Tax total
$_SESSION["TAX_TOTAL"] = $_POST['taxtotal'] == "" ? 0 : $_POST['taxtotal'];
// coupon code
$coupnCode = $_POST['couponCode'] == "" ? "" : $_POST['couponCode'];
$couponCodePrice = $_POST['couponCodePrice'] == "" ? 0 : $_POST['couponCodePrice'];
$response = array();
if ($coupnCode != "") {
    $response = CouponCode::checkCouponcodeExists($coupnCode, $userId);
    $arrayCount = count($response);
    if ($arrayCount > 0) {
        $data = array("message" => "valid", "couponcode" => $response->ccCode, "discount" => $response->ccDiscount, "title" => $response->ccDescription);
        $couponCode_det = array();
        $couponCode_det['ccID'] = $response->ccID;
        $couponCode_det['ccCode'] = $response->ccCode;
        $couponCode_det['ccDiscount'] = $response->ccDiscount;
        $couponCode_det['ccPrice'] = $couponCodePrice;
        $_SESSION['couponCode_det'] = $couponCode_det;
    }
}
// Amount Paid
$_SESSION['amount_paid'] = $_POST['grandtotal'] == "" ? 0 : $_POST['grandtotal'];
$chkSameAsAbove = $_POST["chkSameAsAbove"];
$txtBillingFirstName = $_POST["txtBillingFirstName"];