
<?php 
    $wp = $this->db->query("SELECT a.waktu_proses FROM `rb_penjualan_otomatis` a JOIN rb_penjualan b ON a.kode_transaksi=b.kode_transaksi where a.nominal='$unik[nominal]' AND b.proses='0' AND SUBSTR(timediff(now(), a.waktu_proses),1,2)<'24' GROUP BY b.kode_transaksi")->row_array();
    $date1 = str_replace('-', '/', $wp['waktu_proses']);
    $tomorrow = date('Y-m-d H:i:s',strtotime($date1 . "+1 days"));
    $ss = $this->db->query("SELECT a.*, b.proses, timediff('$tomorrow', now()) as sisa_waktu, SUBSTR(timediff(now(), a.waktu_proses),1,2) as durasi FROM `rb_penjualan_otomatis` a JOIN rb_penjualan b ON a.kode_transaksi=b.kode_transaksi where a.nominal='$unik[nominal]' AND b.proses='0' AND SUBSTR(timediff(now(), a.waktu_proses),1,2)<'24' GROUP BY b.kode_transaksi")->row_array();
?>

<div class="ps-breadcrumb">
    <div class="container">
        <ul class="breadcrumb">
            <li><a href="index.html">Home</a></li>
            <li><a href="<?php echo base_url()."konfirmasi/tracking"; ?>">Tracking</a></li>
            <li><?php echo $judul; ?></li>
        </ul>
    </div>
</div>
<?php 
$cp = $this->db->query("SELECT * FROM rb_penjualan_otomatis where kode_transaksi='$judul' AND nominal='$unik[nominal]'")->row_array();
if ($cp['status_trx']=='tripay' AND $cp['pembayaran']!='1'){
    $kolom1 = 6;
    $kolom2 = '';
    $sidebar = 'd-none';
    $style = 'margin:0 auto; border:radius:10px; border:1px solid #e3e3e3; padding:30px; box-shadow: 0px 0px 2px 1px #e3e3e3;';
}else{
    $kolom1 = 8;
    $kolom2 = 4;
    $sidebar = '';
    $style='';
}
?>
<div class="ps-section--shopping ps-shopping-cart">
    <div class="container">
        <div class="ps-section__content" style='min-height:450px'>
            <div class="table-responsive">
                <div class="row">
                <div style='<?= $style; ?>' class="col-xl-<?= $kolom1; ?> col-lg-<?= $kolom1; ?> col-md-12 col-sm-12 col-12 ">
                    
                <?php 
                    echo "<table class='table table-sm'>
                    <tbody>
                    <tr><td style='width:120px'><strong>No. Invoice</strong></td>  <td class='text-success'><b>$judul</b></td></tr>";
                        
                    echo "<tr><td><strong>Data Pembeli</strong></td> <td><b>$rows[nama_lengkap]</b> (".substr($rows['no_hp'], 0, -2)."xx)<br>
                                                                            ".alamat($judul)."</td></tr>";
                    echo "</tbody>
                    </table><hr>
                    
                    <div class='row mt-5'>
                        <div class='col-12 col-md-6'>
                            <a target='_BLANK' style='margin-bottom:10px' class='ps-btn ps-btn--outline ps-btn--fullwidth' href='".base_url()."t/".$judul."?print'>Lihat dan Cetak Tagihan</a>
                        </div>
                        <div class='col-12 col-md-6'>
                            <a class='ps-btn ps-btn--fullwidth' href='".base_url()."app/pos'>Buat Transaksi Baru</a>
                        </div>
                    </div><br>";
                ?>
                
                </div>

                <div class="col-xl-<?= $kolom2; ?> col-lg-<?= $kolom2; ?> col-md-12 col-sm-12 col-12 <?= $sidebar; ?>">
                    <div class="ps-block--shopping-total">
                        <div class="ps-block__header">
                            <?php 
                            $cek_jml_kurir = $this->db->query("SELECT * FROM rb_penjualan where kode_transaksi='$judul'")->num_rows();
                            
                            $co = $this->db->query("SELECT * FROM rb_penjualan where kode_transaksi='$judul' AND kode_kurir!=''")->num_rows();
                            if ($co>=1){
                                $angka_acak = substr($judul,-2);
                            }else{
                                $angka_acak = 0;
                            }
                            
                                $ong = $this->db->query("SELECT sum(ongkir) as ongkir, sum(fee_admin)/count(*) as fee_admin FROM rb_penjualan where kode_transaksi='$kode'")->row_array();
                                $cekk = $this->db->query("SELECT jenis_produk FROM rb_penjualan_detail a JOIN rb_produk b ON a.id_produk=b.id_produk where a.id_penjualan='$rows[id_penjualan]' GROUP BY b.jenis_produk")->row_array();
                            
                            if ($cek_jml_kurir==1){
                                echo "<p style='margin-bottom:0px'><b>Status Order<span class='text-danger'>".status($total['proses'])."</span></b></p><hr>";
                            }
                            
                            ?>
                                <p style='margin-bottom:0px'>Berat<span> <?php echo ($total['total_berat']>1000?number_format($total['total_berat']/1000,1).' Kg':$total['total_berat'].' Gram'); ?></span></p>
                            <p style='margin-bottom:0px'>Subtotal <span> <?php echo "Rp ".rupiah($total['total']-$total['diskon_total']); ?></span></p>
                            <hr>
                        </div>
                        <div class="ps-block__content">
                            <h3>Total <span><b class='nominaltrx2'><?php echo rupiah($unik['nominal']); ?></b></span></h3>
                        </div>
                    </div>
                </div>
                </div>
            </div>
        </div>
        <hr>

    </div>
</div>
