Untitled

 avatar
unknown
plain_text
a year ago
13 kB
6
Indexable
<?php include("include/top.php"); ?>

<div class="section">
			<!-- container -->
			<div class="container">
				<!-- row -->
				<div class="row">

					<div class="col-md-7">
						<!-- Billing Details -->
						<div class="billing-details">
							<div class="section-title">
								<h3 class="title">Điền thông tin nhận hàng</h3>
							</div>

                            <!-- LOGIN TRUE -->
                            <?php if($isLogin) { ?> 
								<input type="hidden" id="id" value="<?php echo $_SESSION["khachhang"]["id"]; ?>" >
								<input type="hidden" id="order_tongtien" value="<?php echo tinhtiengiohang(); ?>" >
                                <div class="form-group">
                                    <label>Họ và tên</label>
                                    <input class="input" type="text" id="order_name" value="<?php echo $_SESSION["khachhang"]["hoten"]; ?>" placeholder="Nhập họ và tên...">
                                </div>
                                <div class="form-group">
                                    <label>Số điện thoại</label>
                                    <input class="input" type="tel" id="order_sdt" value="<?php echo $_SESSION["khachhang"]["sdt"]; ?>" placeholder="Nhập số điện thoại...">
                                </div>
                                <div class="form-group">
                                    <label>Email</label>
                                    <input class="input" type="email" id="order_email" value="<?php echo $_SESSION["khachhang"]["email"]; ?>" placeholder="Nhập địa chỉ email...">
                                </div>
                                <div class="form-group">
                                    <label>Địa chỉ</label>
                                    <input class="input" type="text" id="order_diachi" value="<?php echo $_SESSION["khachhang"]["diachi"]; ?>" placeholder="Nhập địa chỉ...">
                                </div>
                                <div class="form-group">
                                    <label>Ghi chú</label>
                                    <textarea class="input" id="order_ghichu" placeholder="Nhập ghi chú..."></textarea>
                                </div>
                            <?php } else { ?>
								<input type="hidden" id="order_tongtien" value="<?php echo tinhtiengiohang(); ?>" >

                                <div class="form-group">
                                    <label>Họ và tên</label>
                                    <input class="input" type="text" id="order_name" placeholder="Nhập họ và tên...">
                                </div>
                                <div class="form-group">
                                    <label>Số điện thoại</label>
                                    <input class="input" type="tel" id="order_sdt" placeholder="Nhập số điện thoại...">
                                </div>
                                <div class="form-group">
                                    <label>Email</label>
                                    <input class="input" type="email" id="order_email" placeholder="Nhập email...">
                                </div>
                                <div class="form-group">
                                    <label>Địa chỉ</label>
                                    <input class="input" type="text" id="order_diachi" placeholder="Nhập địa chỉ...">
                                </div>
                                <div class="form-group">
                                    <label>Ghi chú</label>
                                    <textarea class="input" id="order_ghichu" placeholder="Nhập ghi chú..."></textarea>
                                </div>

                                <!-- <div class="form-group">
                                    <div class="input-checkbox">
                                        <input type="checkbox" id="create-account">
                                        <label for="create-account">
                                            <span></span>
                                            Create Account?
                                        </label>
                                        <div class="caption">
                                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.</p>
                                            <input class="input" type="password" name="password" placeholder="Enter Your Password">
                                        </div>
                                    </div>
                                </div> -->
                            <?php }?>

                            <hr><hr><hr><hr>

                            <div class="form-group">
                                <label for="province">Tỉnh/Thành phố</label>
                                <select id="province" name="province" class="form-control">
                                    <option value="">Chọn một tỉnh</option>
                                    <?php
                                        foreach($province as $p) {
                                    ?>
                                        <option value="<?php echo $p['province_id'] ?>"><?php echo $p['name'] ?></option>
                                    <?php
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="district">Quận/Huyện</label>
                                <select id="district" name="district" class="form-control">
                                    <option value="">Chọn một quận/huyện</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="wards">Phường/Xã</label>
                                <select id="wards" name="wards" class="form-control">
                                    <option value="">Chọn một xã</option>
                                </select>
                            </div>
                        </div>
						<!-- /Billing Details -->

						<!-- Shiping Details -->
						<!-- <div class="shiping-details">
							<div class="section-title">
								<h3 class="title">Shiping address</h3>
							</div>
							<div class="input-checkbox">
								<input type="checkbox" id="shiping-address">
								<label for="shiping-address">
									<span></span>
									Ship to a diffrent address?
								</label>
								<div class="caption">
									<div class="form-group">
										<input class="input" type="text" name="first-name" placeholder="First Name">
									</div>
									<div class="form-group">
										<input class="input" type="text" name="last-name" placeholder="Last Name">
									</div>
									<div class="form-group">
										<input class="input" type="email" name="email" placeholder="Email">
									</div>
									<div class="form-group">
										<input class="input" type="text" name="address" placeholder="Address">
									</div>
									<div class="form-group">
										<input class="input" type="text" name="city" placeholder="City">
									</div>
									<div class="form-group">
										<input class="input" type="text" name="country" placeholder="Country">
									</div>
									<div class="form-group">
										<input class="input" type="text" name="zip-code" placeholder="ZIP Code">
									</div>
									<div class="form-group">
										<input class="input" type="tel" name="tel" placeholder="Telephone">
									</div>
								</div>
							</div>
						</div> -->
						<!-- /Shiping Details -->
					</div>

					<!-- Order Details -->
					<div class="col-md-5 order-details">
						<div class="section-title text-center">
							<h3 class="title">GIỎ HÀNG</h3>
						</div>
						<div class="order-summary">
							<div class="order-col">
								<div><strong>SẢN PHẨM</strong></div>
								<div><strong>GIÁ BÁN</strong></div>
							</div>
							<div class="order-products">
                                <?php foreach($giohang as $id => $sp) : ?>
                                    <div class="order-col">
                                        <div><?php echo number_format($sp["soluong"]) . 'x '; echo $sp["tensanpham"];?></div>
                                        <div><?php echo number_format($sp["giaban"]); ?> đ</div>
                                    </div>
                                <?php endforeach; ?>
							</div>
							<div class="order-col">
								<div>Shiping</div>
								<div><strong>FREE</strong></div>
							</div>
							<div class="order-col">
								<div><strong>TỔNG TIỀN</strong></div>
								<div><strong class="order-total"><?php echo number_format(tinhtiengiohang()); ?>đ</strong></div>
							</div>
						</div>
						<div class="payment-method">
							<div class="input-radio">
								<input type="radio" name="payment" id="payment-1">
								<label for="payment-1">
									<span></span>
									Thanh toán khi nhận hàng
								</label>
							</div>
							<div class="input-radio">
								<input type="radio" name="payment" id="payment-2">
								<label for="payment-2">
									<span></span>
									Thanh toán qua chuyển khoản
								</label>
							</div>
						</div>
						<div class="text-center">
							<button class="primary-btn" id="btnThanhToan" type="button">Hoàn thành</button>
						</div>
					</div>
				</div>
			</div>
		</div>

	<script type="text/javascript">
        $(document).ready(function() {
            // INSERT DỮ LIỆU
            $('#btnThanhToan').on('click', function() 
            {
				var id = $('#id').val();
                var hoten = $('#order_name').val();
                var sdt = $('#order_sdt').val();
				var email = $('#order_email').val();
				var diachi = $('#order_diachi').val();
				var ghichu = $('#order_ghichu').val();
				var tongtien = $('#order_tongtien').val();
				
				if(hoten == "" || sdt == "" || email == "" || diachi == "") {
					toastr.error("Bạn vui lòng nhập đầy đủ thông tin nhận hàng, trước khi hoàn thành đơn hàng.", 'THÔNG BÁO');
                }
                else {
                    $.ajax({
						url: "./module/ajax/sanpham/ajax_thanhtoan.php",
						method: "POST",
						data: {
							id: id, 
							hoten: hoten, 
							sdt: sdt,
							email: email,
							diachi: diachi,
							ghichu: ghichu,
							tongtien: tongtien
						},
						success: function(response) {
							if(response == 1) {
								toastr.success("Bạn đã hoàn thành thanh toán hoá đơn thành công.", 'THÔNG BÁO');
								setTimeout(function() {
									window.location.href = '../index.php';
								}, 2000);
							}
							else {
								toastr.error("Lỗi không thể thanh toán hoá đơn.", 'THÔNG BÁO');
							}
						}
					});
                }
				
            });
        });
    </script>

	<script>
		$(document).ready(function() {
			$('#province').on('change', function() {
				var province_id = $(this).val();
				if (province_id) {
					$.ajax({
					url: "./module/ajax/andress/province.php",
					method: 'GET',
					dataType: "json",
					data: {
						province_id: province_id
					},
					success: function(data) {
						$('#district').empty();
							$.each(data, function(i, district) {
								$('#district').append($('<option>', {
									value: district.id,
									text: district.name
								}));
							});
							$('#wards').empty();
						},
						error: function(xhr, textStatus, errorThrown) {
							console.log('Error: ' + errorThrown);
						}
					});
					$('#wards').empty();
				} 
				else {
					$('#district').empty();
				}
			});
			
			$('#district').on('change', function() {
				var district_id = $(this).val();
				if (district_id) {
					$.ajax({
					url: "./module/ajax/andress/district.php",
					method: 'GET',
					dataType: "json",
					data: {
						district_id: district_id
					},
					success: function(data) {
						$('#wards').empty();
						$.each(data, function(i, wards) {
							$('#wards').append($('<option>', {
								value: wards.id,
								text: wards.name
							}));
						});
					}, 
					error: function(xhr, textStatus, errorThrown) {
						console.log('Error: ' + errorThrown);
					}
				});
			} 
			else {
				$('#wards').empty();
			}
			});
		});
  
	</script>

<?php include("include/bottom.php"); ?>
Editor is loading...
Leave a Comment