public function actionUpdate()
    {
        $taxModel = new Tax();
        $id = $_POST['id'];
        //doc id
        $chkPage = $_POST['pagechk'];
        $quantity = $_POST['quantity'];
        //doc id
        $getCurrency = Yii::app()->params['adminCurrency'];
        $output = '';
        //check the existing quantity from db, if that quanityt is avalibale which is posted by user
        $getQuantity = "SELECT instock from reward where id = {$id}";
        $getQtyValueDB = Yii::app()->db->createCommand($getQuantity)->queryRow();
        if ($getQtyValueDB['instock'] < $quantity) {
            $output .= '<div id="AjFlash" class="flash-success" style="color:red">You cannot order more than instock.</div>';
        }
        if (array_key_exists($id, $_SESSION['items'])) {
            //update the quantity
            $_SESSION['items'][$id]['quantity'] = $quantity;
        } else {
            if ($id != '') {
                //add
                //$_SESSION['cart_quantity'][$id]=$quantity;
                $_SESSION['items'][$id]['quantity'] = $quantity;
            }
        }
        if ($chkPage == 'checkout') {
            $output .= '<h3>Confirm Order</h3>
                      
                          <div class="cart-info">';
        } else {
            $output .= '<h1 class="heading1"><span class="maintext"> Shopping Cart</span><span class="subtext"> All items in your  Shopping Cart</span></h1>
                    
                        <div class="cart-info" >';
        }
        $output .= '
                     <table class="table table-striped table-bordered" >
                        <tr>
                          <th class="image">Image</th>
                          <th class="name">Product Name</th>
                          <th class="quantity">Qty</th>
                        
                          <th class="price">Unit Price</th>
                          <th class="total">Total</th>
                         
                        </tr>';
        if (count($_SESSION['items']) > 0) {
            // get the product ids
            $ids = "";
            foreach ($_SESSION['items'] as $key => $data) {
                $price = $data['price'];
                $id = $data['id'];
                $title = $data['title'];
                $img = $data['image'];
                $quantity = $data['quantity'];
                $total_price = $data['price'] * $data['quantity'];
                $subTotal += $total_price;
                $total_price_final = number_format((double) $total_price, 2, '.', '');
                $output .= '<tr>
                          <td class="image"><a href="' . Yii::app()->request->baseUrl . '/index.php?r=reward/view&id=' . $id . '"><img title="product" alt="product" src="' . Yii::app()->request->baseUrl . '/images/reward/' . $id . '/' . $img . '" height="50" width="50"></a></td>
                          <td  class="name"><a href="' . Yii::app()->request->baseUrl . '/index.php?r=reward/view&id=' . $id . '">' . $title . '</a></td>
                          <td class="quantity">
                            <div id="flash' . $id . '"></div>
                            <input type="text" size="1" value="' . $quantity . '" name="quantity' . $id . '" id="quantity' . $id . '" class="span1"><br/>
                            <input type="submit" value="Update" class="quantity_submit" id="' . $id . '"> | <input type="submit" value="Delete" class="delete_submit" id="' . $id . '">
                            
                           
                           </td> <td class="price">' . $getCurrency . '' . $price . '</td>
                           <td class="total">' . $getCurrency . '' . $total_price_final . '</td>
                        </tr>';
            }
        } else {
            $output .= '<tr><td colspan="5" ><p align="center">Shopping cart is empty.</p></td></tr>';
        }
        $output .= '</table>';
        $output .= '</div>';
        if (count($_SESSION['items']) > 0) {
            $subTotalFinal = number_format((double) $subTotal, 2, '.', '');
            /*$tax = $taxModel->searchTax();
              $findTaxAmt = ($subTotalFinal*($tax/100));
              $findTaxAmtFinal = number_format((float)$findTaxAmt, 2, '.', '');
              
              $vat = $taxModel->searchVat();
              $findVatAmt = ($subTotalFinal*($vat/100));
              $findVatAmtFinal =number_format((float)$findVatAmt, 2, '.', '');*/
            $grandTotal = $subTotalFinal;
            $grandTotalFinal = number_format((double) $grandTotal, 2, '.', '');
            $_SESSION['grandTotalFinal'] = $grandTotalFinal;
            if ($chkPage == 'checkout') {
                $output .= '<div class="row">';
            } else {
                $output .= '<div class="container">';
            }
            $output .= '<div class="pull-right">
                        <div class="span4 pull-right">
                          <table class="table table-striped table-bordered ">
                            <tr>
                              <td><span class="extra bold">Sub-Total :</span></td>
                              <td><span class="bold">' . $getCurrency . '' . $subTotalFinal . '</span></td>
                            </tr>
                           
                            <!-- <tr>
                              <td><span class="extra bold">Eco Tax (' . $taxModel->searchTax() . '%) :</span></td>
                              <td><span class="bold">' . $getCurrency . '' . $findTaxAmtFinal . '</span></td>
                            </tr>
                            <tr>
                              <td><span class="extra bold">VAT (' . $taxModel->searchVat() . '%) :</span></td>
                              <td><span class="bold">' . $getCurrency . '' . $findVatAmtFinal . '</span></td>
                            </tr> -->

                            <tr>
                              <td><span class="extra bold totalamout">Total :</span></td>
                              <td><span class="bold totalamout">' . $getCurrency . '' . $grandTotalFinal . '</span></td>
                            </tr>
                          </table>';
            if ($chkPage == 'checkout') {
                $output .= ' <input type="submit"  onclick="window.location.href=\'index.php?r=shoppingCart/thank\'"  value="Place Order" class="btn btn-orange pull-right">';
            } else {
                $output .= '            <input type="submit" onclick="window.location.href=\'index.php?r=shoppingCart/checkout\'" value="Checkout" class="btn btn-orange pull-right" data-toggle="modal" data-target="#myModal">
              ';
            }
            $output .= ' <input type="submit"  value="Continue Shopping" class="btn btn-orange pull-right mr10">
                        </div>
                      </div>
                      </div>';
        }
        echo $output;
    }