<div class="offcanvas-overlay"></div>

    <!-- Page Title/Header Start -->
    <div class="page-title-section section" data-bg-image="assets/images/bg/page-title-1.webp">
        <div class="container">
            <div class="row">
                <div class="col">

                    <div class="page-title">
                        <h1 class="title">Wishlist</h1>
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                            <li class="breadcrumb-item active">Wishlist</li>
                        </ul>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <!-- Page Title/Header End -->

    <!-- Wishlist Section Start -->
    <div class="section section-padding">
        <div class="container">
            <form class="cart-form" action="#">
                <table class="cart-wishlist-table table">
                    <thead>
                        <tr>
                            <th class="name" colspan="2">Product</th>
                            <th class="price">Color</th>
                            <th class="price">Size</th>
                            <th class="price">Price</th>
                            <th class="add-to-cart">&nbsp;</th>
                            <th class="remove">&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>


                        


                        <?php  

                        $recordset = $this->db->select('*')->where('c_id', $this->session->userdata('customer'))->get('wishlist')->result_array();


                        foreach ($recordset as $key => $wishlist) {
                        $data_product = $this->db->select('*')->where('status', '1')->where('prd_id', $wishlist['prd_id'])->get('product')->result_array();
                        ?>
                        <tr>
                            <td class="thumbnail"><a href="<?php echo base_url().'Product/product_details/'.md5($data_product[0]['prd_id']).'/?mode='.md5($data_product[0]['prd_id']); ?>"><img src="<?php echo base_url();?>/uploads/product/<?php echo $data_product[0]['primary_image']; ?>" alt="wishlist product"></a></td>
                            <td class="name"> <a href="<?php echo base_url().'Product/product_details/'.md5($data_product[0]['prd_id']).'/?mode='.md5($data_product[0]['prd_id']); ?>"><?php echo $data_product[0]['p_title']; ?></a></td>
                            <td class="color">
                                <select class="form-control colour<?php echo $data_product[0]['prd_id']; ?>" >
                                    <?php $product_color=explode(',', $data_product[0]['product_colour']); 
                                    foreach ($product_color as  $key => $colour) {                                                
                                    ?>
                                    <option value="<?php echo $colour; ?>"><?php echo $colour; ?></option>
                                    <?php } ?>
                                </select>
                            </td>
                            <td class="size">
                                <select class="form-control size<?php echo $data_product[0]['prd_id']; ?>" >
                                    <?php 
                                    $product_size=explode(',', $data_product[0]['product_size']); 
                                    foreach ($product_size as $key =>  $size) {                                                
                                    ?>
                                    <option value="<?php echo $size; ?>"><?php echo $size; ?></option> 
                                <?php } ?>
                                <option value="a">a</option> 
                                </select>
                            </td>
                            <td class="price"><span>₹<?php echo $data_product[0]['p_sell_price'];?></span></td>
                            <td class="add-to-cart"><a href="javascript:void(0)" class="btn btn-light btn-hover-dark movetocart" data-productid="<?php echo $data_product[0]['prd_id'];?>" data-productqty="1" data-wishlist="<?php echo $wishlist['id'];?>" data-productprice="<?php echo $data_product[0]['p_sell_price'];?>" data-productname="<?php echo $data_product[0]['p_title'];?>"><i class="fal fa-shopping-cart mr-2"></i>Move to Cart</a></td>
                            <td class="remove"><a href="javascript:void(0)" class="btn delete_wishlist" data-productid="<?php echo $wishlist['id'];?>">×</a></td>
                        </tr>
                    <?php } if (sizeof($recordset)<1) {
                       ?>
                       <tr><td colspan="6">There are no items in this wishlist. Please add to wishlist your favourite product.</td></tr>

                    <?php } ?>
                    </tbody>
                </table>
                <div class="row">
                    <div class="col text-center mb-n3">
                        <a class="btn btn-light btn-hover-dark mr-3 mb-3" href="<?php echo base_url(); ?>">Continue Shopping</a>
                        <a class="btn btn-dark btn-outline-hover-dark mb-3" href="<?php echo base_url(); ?>product/cart_details">View Cart</a>
                    </div>
                </div>
            </form>
        </div>

    </div>
    <!-- Wishlist Section End -->
    <script type="text/javascript">
        $(document).ready(function(){

        $('.delete_wishlist').click(function(){

            var del    = $(this).data("productid");

            $.ajax({

                url : "<?php echo base_url(); ?>product/wishlist_remove",

                method : "POST",

                data : {del: del},

                success: function(data){

                    location.reload();

                }

            });

        });

    });
        $(document).ready(function(){

        $('.movetocart').click(function(){
            var product_id    = $(this).data("productid");
            var product_name  = $(this).data("productname");
            var product_price = $(this).data("productprice");
            var wishlist = $(this).data("wishlist");
            // var quantity       = $('#' + product_id).val();
            
            var colour    = $('.colour'+product_id).val();
            var size    = $('.size'+product_id).val();
            
            $.ajax({

                url : "<?php echo base_url(); ?>product/move_to_cart",

                method : "POST",

                data : {wishlist: wishlist,product_id: product_id,colour: colour,size: size, product_name: product_name, product_price: product_price},

                success: function(data){

                   if(data=='failed'){
                        var x = document.getElementById("snackbarfailed");
                        x.className = "show";
                        setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
                    }
                    else{
                        $('.cccount').html(data);
                        var x = document.getElementById("snackbar");
                        x.className = "show";
                        setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
                    }
                    setTimeout(function(){ location.reload(); }, 3100);

                }

            });

        });

    });
    </script>