<script src="<?= base_url() ?>assets/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?= base_url() ?>assets/jquery.chained.js"></script>
<!-- Section -->
<section class="page-section">
    <div class="container">

        <div class="row">
            <div class="col-md-10 col-md-offset-1">
                <?php
                $jmlcart = $this->cart->total_items();
                if ($jmlcart == 0) {
                    ?>
                    <div class="alert alert-warning" role="alert">
                        <small> <span class="glyphicon glyphicon-warning-sign"></span> Maaf anda keranjang belanja anda masih kosong, silahkan melanjutkan belanja anda..</small>
                    </div>
                    <div class="pull-right">
                        <a href="<?= base_url() ?>toko" class="btn btn-mod btn-round btn-large">Lanjut Belanja</a>
                    </div>
                    <?php
                } else {
                    ?>
                    <table class="table table-striped shopping-cart-table">
                        <tr>
                            <th class="hidden-xs">
                                Photo
                            </th>
                            <th>
                                Product
                            </th>
                            <th>
                                Q-ty
                            </th>
                            <th>
                                Berat
                            </th>
                            <th>
                                Total
                            </th>
                            <th>

                            </th>
                        </tr>
                        <?php
                        $tberat = 0;
                        $total = 0;
                        foreach ($this->cart->contents() as $items) {
                            ?>  
                            <tr>
                                <td class="hidden-xs">
                                    <a href=""><img src="<?= base_url() ?>assets/product_image/<?= $items['foto'] ?>" alt="" width="70px"/></a>
                                </td>
                                <td>
                                    <a href="#" title=""><?= $items['name'] ?></a>
                                </td>
                                <td>
                                    <form class="form">
                                        <input type="number" disabled class="input-sm" style="width: 60px;" min="1" max="100" value="<?= $items['qty'] ?>" />
                                    </form>
                                </td>
                                <td>
                                    <a href="#" title=""><?= $items['berat'] ?></a>
                                </td>

                                <td>
                                    <div style="float: left">Rp.</div>
                                    <div style="float: right"><?= number_format($items['total'], 2) ?></div>
                                </td>
                                <td>
                                    <a href="<?= base_url() ?>toko/deleteProduct/<?= $items['rowid'] ?>"><i class="fa fa-times"></i> <span class="hidden-xs">Remove</span></a>
                                </td>
                            </tr>
                            <?php
                            $tberat += $items['berat'];
                            $total += $items['total'];
                        }
                        ?>
                    </table>

                    <hr />
                    <div class="row">
                        <form action="<?= base_url() ?>toko/to_cekout2" class="form" method="post">
                            <div class="col-sm-6">
                                <p class="small-title font-alt">Identitas Pembeli</p>
                                <div class="mb-10">
                                    <input id="nm_pembeli" name="nm_pembeli" placeholder="nama pembeli" class="input-md form-control" autofocus type="text">
                                </div>
                                <div class="mb-10">
                                    <input id="email" name="email" placeholder="email pembeli" class="input-md form-control" type="text">
                                </div>
                                <div class="mb-10">
                                    <input id="no_telp_pembeli" name="no_telp_pembeli" placeholder="no telp/ hp" class="input-md form-control" type="text">
                                </div>

                                <div class="mb-10">
                                    <textarea id="alamat_pembeli" name="alamat_pembeli" class="input-md form-control" placeholder="Alamat Pembeli"></textarea>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <p class="small-title font-alt">Pengiriman</p>
                                <div class="mb-10">
                                    <input id="nm_penerima" name="nm_penerima" placeholder="nama penerima" class="input-md form-control" type="text" pattern=".{3,100}">
                                </div>

                                <div class="mb-10">
                                    <input id="no_telp_penerima" name="no_telp_penerima" placeholder="no telp/ hp penerima" class="input-md form-control" type="text" pattern=".{3,100}">
                                </div>

                                <div class="mb-10">
                                    <textarea id="alamat_penerima" name="alamat_penerima" class="input-md form-control" placeholder="Alamat Penerima"></textarea>
                                </div>

                            </div>
                            <br/>
                            <hr/>
                            <div style="clear: both"></div>
                            <div class="col-sm-6">
                                <p class="small-title font-alt">Pembayaran</p>
                                <div class="mb-10">
                                    <select required class="input-md form-control" name="pembayaran_bank">
                                        <option value="">-Pilih Pembayaran-</option>
                                        <option value="bca">BCA</option>
                                        <option value="bri">BRI</option>
                                        <option value="mandiri">Mandiri</option>
                                    </select>
                                </div>
                            </div>
                            <div style="clear: both"></div>
                            <hr/>

                            <button type="submit" class="btn btn-mod btn-large btn-round btn-block">
                                Selanjutnya..
                            </button>
                        </form>
                    </div>

                    <?php
                }
                ?>

            </div>
        </div>

    </div>
</section>
<!-- End Section -->

<div class="mb-100"></div>

<script>
    $(document).ready(function() {
        $("#nm_pembeli").keydown(function() {
            var nm_pmbeli = $("#nm_pembeli").val();
            $("#nm_penerima").val(nm_pmbeli);
        });

        $("#no_telp_pembeli").keydown(function() {
            var nm_pmbeli = $("#no_telp_pembeli").val();
            $("#no_telp_penerima").val(nm_pmbeli);
        })

        $("#alamat_pembeli").keydown(function() {
            var nm_pmbeli = $("#alamat_pembeli").val();
            $("#alamat_penerima").val(nm_pmbeli);
        })
    });
</script>