<style>
    div.wrapper button.btn-apply-coupon {
        background-color: <?= $this->Settings_model->general()['navbar_color']; ?>;
        width: 150px;
    }

    div.wrapper button.order_now {
        background-color: <?= $this->Settings_model->general()['btncolor']; ?>;
    }

    div.wrapper button.order_now:hover {
        background-color: #454545;
    }
</style>

<div class="top-back">
    <a href="<?= base_url(); ?>" class="text-dark">
        <i class="fa fa-chevron-left"></i>
    </a>
</div>

<div class="wrapper">
    <h6>DETAIL PESANAN</h6>
    <hr>
    <div class="cart">
        <?php foreach ($this->cart->contents() as $item) : ?>
            <div class="item-cart" id="modalCartBodyListItem-<?= $item['rowid']; ?>">
                <img src="<?= $item['ex_img'] == 1 ? $item['img'] : base_url() . 'assets/images/product/' . $item['img']; ?>" alt="img product" class="thumb-img">
                <div class="text">
                    <h4 class="product-name"><?= $item['name']; ?></h4>
                    <p class="information mb-0"><?= $item['option']['Color'] != "" ? $item['option']['Color'] . ' - ' : NULL ?><?= $item['option']['Variant'] != "" ? $item['option']['Variant'] . ' - ' : NULL ?><?= intval($item['weight']) * intval($item['qty']); ?> gr | Qty: <?= $item['qty']; ?></p>
                    <h5 class="price" id="modalCartPriceProduct-<?= $item['rowid']; ?>">Rp. <?= number_format($item['subtotal'], 0, ",", "."); ?></h5>
                </div>
            </div>
        <?php endforeach; ?>
        <hr>
    </div>
    <form action="<?= base_url(); ?>checkout/go" method="post">
        <div class="form-group">
            <label for="name">Nama</label>
            <input type="text" class="form-control" name="name" required id="name" autocomplete="off">
        </div>
        <div class="form-group">
            <label for="wa">No WhatsApp</label>
            <input type="number" class="form-control" name="wa" required id="wa" autocomplete="off">
        </div>
        <div class="form-group">
            <label for="address">Alamat</label>
            <textarea class="form-control" name="address" required id="address"></textarea>
        </div>
        <?php if ($this->Settings_model->getSetting()['shipping_feature'] == 1) { ?>
            <div class="form-group">
                <label for="districtCheckoutPage">Kabupaten</label>
                <select name="district" id="districtCheckoutPage" class="form-control" required>
                    <option></option>
                    <?php foreach ($city as $c) : ?>
                        <option value="<?= $c['city_id']; ?>"><?= $c['type']; ?> <?= $c['city_name']; ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group">
                <label for="subdistrictCheckoutPage">Kecamatan</label>
                <select name="subdistrict" id="subdistrictCheckoutPage" class="form-control" required>
                    <option></option>
                </select>
            </div>
            <div class="form-group">
                <label for="courierCheckoutPage">Pilih Kurir</label>
                <select name="courier" id="courierCheckoutPage" class="form-control" required>
                    <option>Pilih kecamatan dulu</option>
                </select>
            </div>
            <input type="hidden" id="courierStatusIsAvailableCheckoutPage" value="true">
        <?php } else if ($this->Settings_model->getSetting()['flatshipping_feature'] == 1) { ?>
            <div class="form-group">
                <label for="location">Pilih Lokasi</label>
                <select onchange="chooseLocationFlatOngkir(this)" name="location" id="location" class="form-control">
                    <option value=""></option>
                    <?php foreach ($flat_ongkir->result_array() as $ongkir) : ?>
                        <option value="<?= $ongkir['id'] ?>**<?= $ongkir['fee'] ?>"><?= $ongkir['location'] ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        <?php } else { ?>
            <input type="hidden" id="courierStatusIsAvailableCheckoutPage" value="false">
        <?php } ?>
        <?php if ($this->Settings_model->getSetting()['payment_feature'] == 1) { ?>
            <input type="text" style="position: fixed; top: -500%;" name="payment-checking" value="" required id="paymentSelectCheckoutPage">
            <div class="form-group">
                <label for="payment">Pilih Pembayaran</label><br>
                <small class="text-danger" style="display: none" id="msgPaymentFirstCheckoutPage">Pilih pembayaran terlebih dahulu.<br></small>
                <?php if ($logo_pay['bca'] == 1) { ?>
                    <?php $bankbca = $this->db->get_where('rekening', ['rekening' => 1])->row_array(); ?>
                    <?php if ($bankbca) { ?>
                        <img onclick="changeUSDToIDR('1')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-1" src="<?= base_url(); ?>assets/images/payment/bca.png" alt="bank bca">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['mandiri'] == 1) { ?>
                    <?php $bankmandiri = $this->db->get_where('rekening', ['rekening' => 2])->row_array(); ?>
                    <?php if ($bankmandiri) { ?>
                        <img onclick="changeUSDToIDR('2')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-2" src="<?= base_url(); ?>assets/images/payment/mandiri.png" alt="bank mandiri">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['bri'] == 1) { ?>
                    <?php $bankbri = $this->db->get_where('rekening', ['rekening' => 3])->row_array(); ?>
                    <?php if ($bankbri) { ?>
                        <img onclick="changeUSDToIDR('3')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-3" src="<?= base_url(); ?>assets/images/payment/bri.png" alt="bank bri">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['bni'] == 1) { ?>
                    <?php $bankbni = $this->db->get_where('rekening', ['rekening' => 4])->row_array(); ?>
                    <?php if ($bankbni) { ?>
                        <img onclick="changeUSDToIDR('4')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-4" src="<?= base_url(); ?>assets/images/payment/bni.png" alt="bank bni">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['bcas'] == 1) { ?>
                    <?php $bankbcas = $this->db->get_where('rekening', ['rekening' => 5])->row_array(); ?>
                    <?php if ($bankbcas) { ?>
                        <img onclick="changeUSDToIDR('5')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-5" src="<?= base_url(); ?>assets/images/payment/bcas.png" alt="bank bcas">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['bsi'] == 1) { ?>
                    <?php $bankbsi = $this->db->get_where('rekening', ['rekening' => 6])->row_array(); ?>
                    <?php if ($bankbsi) { ?>
                        <img onclick="changeUSDToIDR('6')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-6" src="<?= base_url(); ?>assets/images/payment/bsi.jpg" alt="bank bsi">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['atmbersama'] == 1) { ?>
                    <?php $bankatmbersama = $this->db->get_where('rekening', ['rekening' => 7])->row_array(); ?>
                    <?php if ($bankatmbersama) { ?>
                        <img onclick="changeUSDToIDR('7')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-7" src="<?= base_url(); ?>assets/images/payment/atmbersama.png" alt="bank atmbersama">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['paypal'] == 1) { ?>
                    <?php $bankpaypal = $this->db->get_where('rekening', ['rekening' => 8])->row_array(); ?>
                    <?php if ($bankpaypal) { ?>
                        <img onclick="changeIDRToUSD()" class="logo-payment logo-payment-checkout-page logo-payment-checkout-8" src="<?= base_url(); ?>assets/images/payment/paypal.png" alt="bank paypal">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['jenius'] == 1) { ?>
                    <?php $bankjenius = $this->db->get_where('rekening', ['rekening' => 9])->row_array(); ?>
                    <?php if ($bankjenius) { ?>
                        <img onclick="changeUSDToIDR('9')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-9" src="<?= base_url(); ?>assets/images/payment/jenius.png" alt="bank jenius">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['ovo'] == 1) { ?>
                    <?php $bankovo = $this->db->get_where('rekening', ['rekening' => 10])->row_array(); ?>
                    <?php if ($bankovo) { ?>
                        <img onclick="changeUSDToIDR('10')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-10" src="<?= base_url(); ?>assets/images/payment/ovo.png" alt="bank ovo">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['dana'] == 1) { ?>
                    <?php $bankdana = $this->db->get_where('rekening', ['rekening' => 11])->row_array(); ?>
                    <?php if ($bankdana) { ?>
                        <img onclick="changeUSDToIDR('11')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-11" src="<?= base_url(); ?>assets/images/payment/dana.png" alt="bank dana">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['gopay'] == 1) { ?>
                    <?php $bankgopay = $this->db->get_where('rekening', ['rekening' => 12])->row_array(); ?>
                    <?php if ($bankgopay) { ?>
                        <img onclick="changeUSDToIDR('12')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-12" src="<?= base_url(); ?>assets/images/payment/gopay.png" alt="bank gopay">
                    <?php } ?>
                <?php } ?>
                <?php if ($logo_pay['jago'] == 1) { ?>
                    <?php $bankjago = $this->db->get_where('rekening', ['rekening' => 14])->row_array(); ?>
                    <?php if ($bankjago) { ?>
                        <img onclick="changeUSDToIDR('14')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-14" src="<?= base_url(); ?>assets/images/payment/jago.png" alt="bank jago">
                    <?php } ?>
                <?php } ?>
                <?php if ($this->Settings_model->general()['payment_cod_status'] == 1) { ?>
                    <img onclick="changeUSDToIDR('13')" class="logo-payment logo-payment-checkout-page logo-payment-checkout-13" src="<?= base_url(); ?>assets/images/icon/cod-icon.png" alt="cod">
                <?php } ?>
            </div>
        <?php } ?>
        <?php if ($this->Settings_model->getSetting()['potongan_feature'] == 1) { ?>
            <div class="form-group mt-4">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="MASUKAN KUPON" id="inputCouponCheckoutPage">
                    <div class="input-group-append">
                        <button class="btn text-light btn-apply-coupon" type="button" id="btnForApplyCouponCheckoutPage">TERAPKAN</button>
                    </div>
                </div>
                <small class="text-danger" id="msgDangerCouponWrongCheckoutPage"></small>
            </div>
        <?php } ?>
        <div class="info">
            <table class="table table-sm table-borderless">
                <tr>
                    <td>Subtotal</td>
                    <td id="subTotalCheckoutPageShow">Rp. <?= number_format($this->cart->total(), 0, ",", ".") ?></td>
                </tr>
                <?php if ($this->Settings_model->getSetting()['shipping_feature'] == 1) { ?>
                    <tr>
                        <td>Biaya Ongkir</td>
                        <td id="ongkirCheckoutPage">Rp. 0</td>
                    </tr>
                <?php } else if ($this->Settings_model->getSetting()['flatshipping_feature'] == 1) { ?>
                    <tr>
                        <td>Biaya Ongkir</td>
                        <td id="ongkirCheckoutPage">Rp. 0</td>
                    </tr>
                <?php } ?>
                <?php if ($this->Settings_model->getSetting()['potongan_feature'] == 1) { ?>
                    <tr>
                        <td>Potongan</td>
                        <td id="potonganCouponCheckoutPageShow">Rp. 0</td>
                    </tr>
                <?php } ?>
                <input type="hidden" name="potongan" id="potonganCouponCheckoutPageValue" value="0">
                <input type="hidden" id="valueOfFeeCODIfSelectCOD" value="0">
                <tr class="list-for-fee-cod-hide">
                    <td>Biaya COD <?= $this->Settings_model->general()['fee_cod']; ?>%</td>
                    <td class="valueOfUniqCodeOrFeeCODCheckoutPage"></td>
                </tr>
                <?php if ($this->Settings_model->getSetting()['uniq_code_feature'] == 1) { ?>
                    <?php $randomNum = rand(100, 999); ?>
                    <input type="hidden" id="valueRandomValueGenerateCheckoutPage" value="<?= $randomNum; ?>">
                    <tr class="list-for-uniq-code-show-first">
                        <td>Kode Unik</td>
                        <td id="uniqCodeTextCheckoutPage">Rp. <?= $randomNum ?></td>
                    </tr>
                <?php } else { ?>
                    <?php $randomNum = 0; ?>
                <?php } ?>
                <tr>
                    <th>TOTAL</th>
                    <th id="totalCheckoutPage">Rp. <?= number_format($this->cart->total() + $randomNum, 0, ",", ".") ?></th>
                </tr>
                <input type="hidden" name="ongkir" value="0" id="ongkirValueOrder">
                <input type="hidden" name="random" value="<?= $randomNum; ?>" id="uniqueCodeValueOrder">
                <input type="hidden" name="payment" value="0" id="paymentLogoSelectCheckoutPageValue">
            </table>
        </div>
        <button type="submit" class="order_now btn_order_now_checkout_page" onClick="fbq('track', 'Lead');">PESAN SEKARANG</button>
    </form>
</div>