<div class="col-lg-9" style="border: 1px solid #ebebeb;border-radius: 6px;box-shadow: 0 2px 6px 0 rgba(0,0,0,.07); padding: 30px 40px; background-color: #ffff;margin-left: auto; 
    		margin-right: auto; border-bottom: 3px solid rgba(3,108,228,1);
	 		">
			<div class="myaccount-content mt-xs-15">
				<h3 class="gray mb-0">_หมวดหมู่: <?= $cate ?></h3>
				<div class="row mt-2 text-center" style="padding: 30px 40px;">
					<?php 
				$this->db->select('category.*,product.*');	
				$this->db->join('category', 'category.id_category = product.id_cate', 'left');
                $this->db->where('name_cate', $cate);
				$this->db->where('stock !=', 0);
				$query = $this->db->get('product');
                if($query->num_rows() != 0)
                {
                    foreach($query->result_array() as $data)
                    { ?>
                        <div class="cf-sm-6 cf-md-4 cf-lg-4 col-xs-6 col-sm-6 col-md-4 col-lg-3 mr-5 mb-5"
						style="padding:0px;box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%), 0 6px 20px 0 rgb(0 0 0 / 19%);">
						<div class="card mb-4">
							<img class="img-thumbnail" style="height: 220px;"
								src="<?= base_url('Products/').$data['image'].".jpg" ?>" alt="Card image cap">
							<div class="card-body" style="text-align: center;">
								<h5 class="card-title"><?= $data['name_pro'] ?> </h5>
								<p class="card-text mb-0">
									<?= $data['detail'] ?>
								</p>
								<p class="card-text mb-0">
									<?= number_format($data['price']-$data['discount']).' บาท/ไอดี' ?>
								</p>
								<p class="card-text mb-0">
									<?= 'คงเหลือ: '.number_format($data['stock']).' ไอดี' ?>
								</p>
								<?php 
								if($this->session->userdata('id_users') != null)
								{ ?>
								<a href="#" type="button" class="btn btn buy" style="background-color: #3298dc; color: #fff;"
									data-toggle="modal" data-target="#howtotopup" data-id="<?= $data['id_product'] ?>"
									data-name="<?= $data['name_pro'] ?>" data-price="<?= $data['price'] ?>"
									data-stock="<?= $data['stock'] ?>" data-discount="<?= $data['discount'] ?>">ซื้อสินค้า</a>
								<?php	
								}else{ ?>
								<a href="<?php echo base_url('Login') ?>" type="button" class="btn btn buy" style="background-color: #3298dc; color: #fff;">ซื้อสินค้า</a>
								<?php } ?>
							</div>
						</div>
					</div>
                        <?php		
                    }
                }else{ ?>
                    <div class="col-12">
                        <div class="alert alert-warning" role="alert">
                            <span>ขออภัยหมวดหมู่นี้ไม่มีสินค้าค่ะ</span> 
                        </div>
                    </div>
                <?php }
                ?>
				</div>
			</div>
		</div>
		</div>
		</div>
		<div class="modal fade" id="howtotopup" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle"
			aria-hidden="true">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<h5 class="modal-title" id="exampleModalLongTitle">ซื้อสินค้า</h5>
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
					</div>
					<div class="modal-body" style="border-bottom: 1px solid #e9ecef;">
						<div class="row justify-content-center">
							<div class="col-12 text-center">
								<h5 id="nameproduct"></h5>
							</div>
							<div class="col-12 text-center">
								<h5 id="pricepro"></h5>
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
					<form name="buyproduct_form" id="buyproduct_form" role="form">
						<div class="modal-body" style="border-bottom: 1px solid #e9ecef;">
							<div class="row justify-content-center">
								<div class="col-12 text-center">
									<span>กรุณากรอกจำนวนที่ต้องการซื้อ</span>
									<div class="form-group">
										<input type="text" class="form-control" id="amount" name="amount" onInput="onAmount()"
											autocomplete="off" placeholder="จำนวน">
									</div>
								</div>
								<div class="col-12 text-center">
									<span>โค้ดส่วนลด (ถ้ามี)</span>
									<div class="form-group">
										<input type="text" class="form-control" id="code" name="code" autocomplete="off"
											placeholder="โค้ดส่วนลด">
										<input type="hidden" class="form-control" id="idbuyproduct" name="id">
									</div>
								</div>
								<div class="col-12 text-center">
									<h5>รวมเป็นราคา</h5>
								</div>
								<div class="col-12 text-center">
									<h5 id="totalbuy">0 บาท</h5>
								</div>
								<div class="clearfix"></div>
							</div>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
							<button type="submit" class="btn btn-primary">Save changes</button>
						</div>
					</form>
				</div>
			</div>
		</div>
