<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
<title>Sudila Printers - Kurunegala Sri Lanka</title>
<link href="stylesheets/font_css.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap.min.css" media=all rel=stylesheet />
<link href="stylesheets/font-awesome.min.css" media=all rel=stylesheet />
<link href="stylesheets/hightop-font.css" media=all rel=stylesheet />
<link href="stylesheets/isotope.css" media=all rel=stylesheet />
<link href="stylesheets/jquery.fancybox.css" media=all rel=stylesheet />
<link href="stylesheets/fullcalendar.css" media=all rel=stylesheet />
<link href="stylesheets/wizard.css" media=all rel=stylesheet />
<link href="stylesheets/select2.css" media=all rel=stylesheet />
<link href="stylesheets/morris.css" media=all rel=stylesheet />
<link href="stylesheets/datatables.css" media=all rel=stylesheet />
<link href="stylesheets/datepicker.css" media=all rel=stylesheet />
<link href="stylesheets/timepicker.css" media=all rel=stylesheet />
<link href="stylesheets/colorpicker.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap-switch.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap-editable.css" media=all rel=stylesheet />
<link href="stylesheets/daterange-picker.css" media=all rel=stylesheet />
<link href="stylesheets/typeahead.css" media=all rel=stylesheet />
<link href="stylesheets/summernote.css" media=all rel=stylesheet />
<link href="stylesheets/ladda-themeless.min.css" media=all rel=stylesheet />
<link href="stylesheets/social-buttons.css" media=all rel=stylesheet />
<link href="stylesheets/jquery.fileupload-ui.css" media=screen rel=stylesheet />
<link href="stylesheets/dropzone.css" media=screen rel=stylesheet />
<link href="stylesheets/nestable.css" media=screen rel=stylesheet />
<link href="stylesheets/pygments.css" media=all rel=stylesheet />
<link href="stylesheets/style.css" media=all rel=stylesheet />
<link href="stylesheets/color/green.css" media=all rel="alternate stylesheet" title=green-theme />
<link href="stylesheets/color/orange.css" media=all rel="alternate stylesheet" title=orange-theme />
<link href="stylesheets/color/magenta.css" media=all rel="alternate stylesheet" title=magenta-theme />
<link href="stylesheets/color/gray.css" media=all rel="alternate stylesheet" title=gray-theme />
<link rel="shortcut icon" type="image/x-icon" href="../image/favicon.ico">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name=viewport>
<link rel="stylesheet" href="../backend/bootstrap-sweetalert/lib/sweet-alert.css" />
</head>
<body class="page-header-fixed bg-1">
<div class=modal-shiftfix>
<?php include "common/header.php"; ?>
  <div class="container-fluid main-content">
    <div class=row> 
    <!-- Start Row -->
      <div class=col-lg-12>
          <!-- Table1 -->
		  <div class="widget-container fluid-height clearfix">
			<div class=heading> My Wish List</div>
			<div class="widget-content padded clearfix">
			  <div class=table-responsive>
				<table class="table table-bordered table-striped table-hover" id=dataTable1>
				  <thead>
				    <th>ID</th>
					<th>Date</th>
					<th>Image</th>
					<th>Name</th>
					<th>ISBN</th>
					<th>Unit Price (Rs)</th>
					<th>Discounted Price (Rs)</th>
					<th>Add to Cart</th>
					<th>Remove</th>
				  </thead>
				  <tbody>
					<?php
					$result = mysqli_query($conn, "SELECT
bookdetails.discount,
DATE_FORMAT(wish_list.date, '%Y-%m-%d') AS date,
wish_list.item_id,
wish_list.id,
bookdetails.name,
bookdetails.price,
bookdetails.front_image,
bookdetails.isbn,
bookdetails.search_id,
bookdetails.qty
FROM
wish_list
Inner Join bookdetails ON wish_list.item_id = bookdetails.id
WHERE
wish_list.user_id = '$uid'");
					$xx = 0;
					while ($row = mysqli_fetch_array($result)){ $xx++;
						$f_img = $row['front_image'];
						if(empty($f_img)) { $front_img = 'noimg.jpg'; } else { $front_img = $f_img; }
						
						$dis_val = ($row['price'] * $row['discount']/100);
						$discount = $row['price'] - $dis_val;
					?>
					<tr>
					  <td><?php echo $xx; ?>.</td>
					  <td><?php echo $row['date']; ?></td>
					  <td><a href="../book-details-sudila-printers-sri-lanka?bid=<?php echo $row['search_id']; ?>"><img class="img-responsive" src="../image/books/thumb/<?php echo $front_img; ?>" width="50" alt="<?php echo $row['name']; ?>"></a></td>
					  <td><a href="../book-details-sudila-printers-sri-lanka?bid=<?php echo $row['search_id']; ?>"><?php echo $row['name']; ?></a></td>
					  <td><?php echo $row['isbn']; ?></td>
					  <td align="right"><?php echo number_format($row['price'], 2); ?></td>
					  <td align="right"><?php echo number_format($discount, 2); ?></td>
					  <td align="center"><button class="btn btn-success btn-sm btn_add" value="<?php echo $row['item_id']; ?>" data-row-id="<?php echo $row['id']; ?>">Add to Cart</button></td>
					  <td align="center"><button class="btn btn-danger btn-sm btn_remove" value="<?php echo $row['id']; ?>">Remove</button></td>
					</tr>
					<?php  } ?>
				  </tbody>
				</table>
			  </div>
			</div>
		  </div>
		  <!-- End Table1 -->
      </div>
    </div>
    <!-- End Row -->
  </div>
</div>
<script src="javascripts/jquery-1.10.2.min.js"></script> 
<script src="javascripts/jquery-ui.js"></script> 
<script src="javascripts/bootstrap.min.js"></script> 
<script src="javascripts/raphael.min.js"></script> 
<script src="javascripts/selectivizr-min.js"></script> 
<script src="javascripts/jquery.mousewheel.js"></script> 
<script src="javascripts/jquery.vmap.min.js"></script> 
<script src="javascripts/jquery.vmap.sampledata.js"></script> 
<script src="javascripts/jquery.vmap.world.js"></script> 
<script src="javascripts/jquery.bootstrap.wizard.js"></script> 
<script src="javascripts/fullcalendar.min.js"></script> 
<script src="javascripts/gcal.js"></script> 
<script src="javascripts/jquery.dataTables.min.js"></script> 
<script src="javascripts/datatable-editable.js"></script> 
<script src="javascripts/jquery.easy-pie-chart.js"></script> 
<script src="javascripts/excanvas.min.js"></script> 
<script src="javascripts/jquery.isotope.min.js"></script> 
<script src="javascripts/isotope_extras.js"></script> 
<script src="javascripts/modernizr.custom.js"></script> 
<script src="javascripts/jquery.fancybox.pack.js"></script> 
<script src="javascripts/select2.js"></script> 
<script src="javascripts/styleswitcher.js"></script> 
<script src="javascripts/wysiwyg.js"></script> 
<script src="javascripts/typeahead.js"></script> 
<script src="javascripts/summernote.min.js"></script> 
<script src="javascripts/jquery.inputmask.min.js"></script> 
<script src="javascripts/jquery.validate.js"></script> 
<script src="javascripts/bootstrap-fileupload.js"></script> 
<script src="javascripts/bootstrap-datepicker.js"></script> 
<script src="javascripts/bootstrap-timepicker.js"></script> 
<script src="javascripts/bootstrap-colorpicker.js"></script> 
<script src="javascripts/bootstrap-switch.min.js"></script> 
<script src="javascripts/typeahead.js"></script> 
<script src="javascripts/spin.min.js"></script> 
<script src="javascripts/ladda.min.js"></script> 
<script src="javascripts/moment.js"></script> 
<script src="javascripts/mockjax.js"></script> 
<script src="javascripts/bootstrap-editable.min.js"></script> 
<script src="javascripts/xeditable-demo-mock.js"></script> 
<script src="javascripts/xeditable-demo.js"></script> 
<script src="javascripts/address.js"></script> 
<script src="javascripts/daterange-picker.js"></script> 
<script src="javascripts/date.js"></script> 
<script src="javascripts/morris.min.js"></script> 
<script src="javascripts/skycons.js"></script> 
<script src="javascripts/fitvids.js"></script> 
<script src="javascripts/jquery.sparkline.min.js"></script> 
<script src="javascripts/dropzone.js"></script> 
<script src="javascripts/jquery.nestable.js"></script> 
<script src="javascripts/main.js"></script> 
<script src="javascripts/respond.js"></script>
<script src="../backend/bootstrap-sweetalert/lib/sweet-alert.min.js"></script>
<script>
/* Remove Item */
$('.btn_remove').click(function() {
  var row_id = $(this).val();
  swal({
	title: "",
	text: "Are you sure you want to remove this item?",
	type: "warning",
	showCancelButton: true,
	confirmButtonClass: "btn-danger",
	confirmButtonText: "Yes !",
	closeOnConfirm: false
  },
	function () {
	  $.post('connection/update_user_acc', {'remove_wishlist_item': 'data' , row_id : row_id}, function (e) {
		if (e.status == "ok") {
		  swal({
			title: "",
			text: "Successfully Deleted",
			type: "success",
			confirmButtonText: "OK"
			  },
			  function (isConfirm) {
				window.location.href = "wish-list";
		  });
		
		} else {
		  swal("Oops...", "Something went wrong. Please Try Again!", "warning");
		}
	  }, "json");
	}
  );
});

/* Add to Cart */
$('.btn_add').click(function() {
  var item_id = $(this).val();
  var row_id = $(this).attr('data-row-id');
  swal({
	title: "",
	text: "Are you sure you want to add this item to your cart?",
	type: "warning",
	showCancelButton: true,
	confirmButtonClass: "btn-danger",
	confirmButtonText: "Yes !",
	closeOnConfirm: false
  },
	function () {
	  $.post('../connection/my_cart_conn', {add_to_cart: 'data', item_id:item_id, qty: 1}, function (data) {
		if (data.msgType === 1) {
			$.post('connection/update_user_acc', {'remove_wishlist_item': 'data' , row_id : row_id}, function (e) {
				if (e.status == "ok") {
				  swal({
					title: "",
					text: "Successfully Added",
					type: "success",
					confirmButtonText: "OK"
					  },
					  function (isConfirm) {
						window.location.href = "wish-list";
				  });
				}
			}, "json");
		} else {
		  swal("Oops...", "Something went wrong. Please Try Again!", "warning");
		}
	  }, "json");
	}
  );
});
</script>
</body>
</html>