<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="robots" content="noindex, nofollow">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="Enambelasapp.my.id" />
    <meta name="author" content="Suroto" />
    <link rel="icon" type="image/png" href="<?php echo base_url('assets/') ?>/img/favicon.png"/>
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <![endif]-->
    <title>Laporan Penjualan Menu</title>
    <link href="<?php echo base_url() ?>/assets/css/bootstrap.css" rel="stylesheet" />
    <link href="<?php echo base_url() ?>/assets/css/font-awesome.css" rel="stylesheet" />
    <link href="<?php echo base_url() ?>/assets/css/style.css" rel="stylesheet" />

</head>
<body>
    <div class="container">
        <div align="center" class="no-print" id="formFilter" style="background-color: #F5F5F5;padding: 4px">
          <form class="form-inline" action="" method="get">
            <input type="hidden" name="filter1" id="filter1" value="ok1">
			  <div class="form-group">
			  <label for="kedai">Kedai : </label>
					 <select  name="kedai" id="kedai" required>
								    <option height='45px' value="">Pilih Kedai</option>
								    <option <?php {echo 'selected';}?> value="99">Semua Kedai</option>
								    <option <?php {echo 'selected';}?> value="98">Per Kedai</option>
								    <option <?php {echo 'selected';}?> value="KDR01">Ngronggo</option>
								    <option <?php {echo 'selected';}?> value="KDR02">Polim</option>
								    <option <?php {echo 'selected';}?> value="KDR06">Penanggungan</option>
								    <option <?php {echo 'selected';}?> value="KDR04">Gumul</option>
								    <option <?php {echo 'selected';}?> value="KDR05">Pare</option>
								    <option <?php {echo 'selected';}?> value="BLT01">Blitar</option>
								    <option <?php {echo 'selected';}?> value="KNR01">Srengat</option>
								    <option <?php {echo 'selected';}?> value="NJK01">Nganjuk</option>
								    <option <?php {echo 'selected';}?> value="NJK02">Kertosono</option>
								    <option <?php {echo 'selected';}?> value="NJK03">Warujayeng</option>
								    <option <?php {echo 'selected';}?> value="JBG01">Jombang 1</option>
								    <option <?php {echo 'selected';}?> value="JBG03">Jombang 2</option>
								    <option <?php {echo 'selected';}?> value="MJK01">Moker 1</option>
								    <option <?php {echo 'selected';}?> value="MJK02">Moker 2</option>
								    <option <?php {echo 'selected';}?> value="MJK03">Moker 3</option>
								    <option <?php {echo 'selected';}?> value="MJK04">Pandan</option>
								    <option <?php {echo 'selected';}?> value="MJK05">Mojosari</option>
								    <option <?php {echo 'selected';}?> value="MLG01">Malang</option>
								    <option <?php {echo 'selected';}?> value="SDR01">Sepanjang</option>
								    
							    </select>
			  </div>
              <div class="form-group">
                <label for="a">Jenis Cetak : </label>
                <select name="a" id="a" class="form-control">
                      <option <?php {echo 'selected';}?> value="tl">Total</option>
                      <option <?php {echo 'selected';}?> value="rg">Reguler</option>
                      <option <?php {echo 'selected';}?> value="do">DO</option>
                      <option <?php {echo 'selected';}?> value="pr">Promo</option>
                      <option <?php {echo 'selected';}?> value="bn">Bonus</option>
                      <option <?php {echo 'selected';}?> value="gf">Gofood</option>
                      <option <?php {echo 'selected';}?> value="gr">Grabfood</option>
                      <option <?php {echo 'selected';}?> value="sp">Shopeefood</option>
                      <option <?php {echo 'selected';}?> value="mx">Maxim</option>
                      <option <?php {echo 'selected';}?> value="al">Semua</option>
                </select>
                <label for="b">Jenis Menu : </label>
                <select name="b" id="b" class="form-control">
                      <option <?php {echo 'selected';}?> value="4">Mie Djoetek</option>
                      <option <?php {echo 'selected';}?> value="2">Snack</option>
                      <option <?php {echo 'selected';}?> value="5">Topping</option>
                      <option <?php {echo 'selected';}?> value="6">Bavarage</option>
                      <option <?php {echo 'selected';}?> value="Z">All Menu</option>
                </select>
                
              </div>
              <div class="form-group">
                <label for="pwd"> Tanggal </label>
                <select name="d" id="d" class="form-control">
                    <?php for ($i = 1; $i <= 31; $i++) {?>
                    <option <?php if ($i == $tgl) {echo 'selected';}?> value="<?php echo sprintf('%02d', $i) ?>"><?php echo sprintf('%02d', $i) ?></option>
                    <?php }?>
                </select>
                <select name="e" id="e" class="form-control">
                <?php for ($i = 1; $i <= 12; $i++) {?>
                    <option <?php if ($i == $bln) {echo 'selected';}?> value="<?php echo sprintf('%02d', $i) ?>"><?php echo sprintf('%02d', $i) ?></option>
                <?php }?>
                </select>
                <select name="f" id="f" class="form-control">
                <?php for ($i = 2016; $i <= date('Y'); $i++) {?>
                  <option <?php if ($i == $thn) {echo 'selected';}?> value="<?php echo $i ?>"><?php echo $i ?></option>
                <?php }?>
                </select>
                <label for="pwd"> S/d </label>
                <select name="g" id="g" class="form-control">
                    <?php for ($i = 1; $i <= 31; $i++) {?>
                    <option <?php if ($i == $tgl) {echo 'selected';}?> value="<?php echo sprintf('%02d', $i) ?>"><?php echo sprintf('%02d', $i) ?></option>
                    <?php }?>
                </select>
                <select name="h" id="h" class="form-control">
                <?php for ($i = 1; $i <= 12; $i++) {?>
                    <option <?php if ($i == $bln) {echo 'selected';}?> value="<?php echo sprintf('%02d', $i) ?>"><?php echo sprintf('%02d', $i) ?></option>
                <?php }?>
                </select>
                <select name="i" id="i" class="form-control">
                <?php for ($i = 2016; $i <= date('Y'); $i++) {?>
                  <option <?php if ($i == $thn) {echo 'selected';}?> value="<?php echo $i ?>"><?php echo $i ?></option>
                <?php }?>
                </select>
              </div>
              <button type="submit" class="btn btn-danger">Filter</button>
              <a href=""><button type="button" class="btn btn-success" onclick="window.print();return false;">Print</button></a>
               <a href="<?php echo base_url('dashboard/') ?>" class="btn btn-info"><img height="20px" src="<?php echo base_url() ?>/assets/img/home.png" /><font color='black'>Home</font></a>
          </form>
        </div>
            <h4 align="center">LAPORAN PENJUALAN MENU</h4>
			<?php 
				$nmtoko='Pusat';
				if($toko) {
					$nmtoko=$toko->nm_toko ; }
			?>
			
            <h5 align="center">KEDAI : <?php echo $nmtoko ?></h5>
            <?php if ($filter): ?>
                <h5 align="center">TANGGAL : <?php echo  date_indo($awal) ?> s/d <?php echo  date_indo($akhir) ?> / <?php echo $jual ?> / <?php echo $ketjenis ?> </h5>
            <?php else: ?>
            <h5 align="center">TANGGAL : <?php echo date_indo($tanggal) ?> / <?php echo $jual ?></h5>
            <?php endif?>
            <table id="tbPenjualan" class="table table-bordered table-striped table-responsive">
<?php if ($filter): 
    if ($jenis=='al') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Kedai</th>
        <th>Keterangan</th>
        <th>K.Jenis</th>
        <th>Jenis Menu</th>
        <th>Kode</th>
        <th>Nama Menu</th>
        <th>T.qty</th>
        <th>Bruto</th>
		<th>PPn</th>
		<th>Netto</th>
        <th>Qty DI</th>
        <th>Rp DI</th>
        <th>Qty TA</th>
        <th>Rp TA</th>
        <th>Qty DO</th>
        <th>Rp DO</th>
        <th>Qty Pro</th>
        <th>Rp Pro</th>
        <th>Qty Bns</th>
        <th>Rp Bns</th>
        <th>Qty Gf</th>
        <th>Rp Gf</th>
        <th>Qty GR</th>
        <th>Rp GR</th>
        <th>Qty SF</th>
        <th>Rp SF</th>
        <th>Qty MX</th>
        <th>Rp MX</th>
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 $jum_tot = $key->tqty - $key->jum_retur;
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->kdcabang ?></td>
        <td style="text-align:left;"><?php echo $key->nm_toko ?></td>
        <td style="text-align:left;"><?php echo $key->jnsbarang ?></td>
        <td style="text-align:left;"><?php echo $key->keterangan ?></td>
        <td style="text-align:left;"><?php echo $key->kd_barang ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->tqty ?></td>
		<td style="text-align:right;"><?php echo number_format($key->brt_rp) ?></td>
		<td style="text-align:right;"><?php echo number_format($key->ppn_rp) ?></td>
        <td style="text-align:right;"><?php echo number_format($key->jum_rp) ?></td>
        <td style="text-align:center;"><?php echo $key->rg ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrg) ?></td>
        <td style="text-align:center;"><?php echo $key->prex ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rprex) ?></td>
        
        <td style="text-align:center;"><?php echo $key->rd ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrd) ?></td>
        <td style="text-align:center;"><?php echo $key->pr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rpr) ?></td>
        <td style="text-align:center;"><?php echo $key->bpr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->brpr) ?></td>
        <td style="text-align:center;"><?php echo $key->gf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgf) ?></td>
        <td style="text-align:center;"><?php echo $key->gr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgr) ?></td>
        <td style="text-align:center;"><?php echo $key->sf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rsf) ?></td>
        <td style="text-align:center;"><?php echo $key->mx ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rmx) ?></td>
    </tr>
    <?php
$tot += $key->tqty;
$totrp += $key->jum_rp;
$totbrt += $key->brt_rp;
$totppn += $key->ppn_rp;

$totreg += $key->rg;
$totregrp += $key->rrg;

$totdo += $key->rd;
$totdorp += $key->rrd;

$totpro += $key->pr;
$totprorp += $key->rpr;
$totbpro += $key->bpr;
$totbprorp += $key->brpr;

$totproex+= $key->prex;
$totprorpex += $key->rprex;

$totgf += $key->gf;
$totgfrp += $key->rgf;

$totgr += $key->gr;
$totgrrp += $key->rgr;

$totsf += $key->sf;
$totsfrp += $key->rsf;
$totmx += $key->mx;
$totmxrp += $key->rmx;

?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="7" style="text-align:center;"><b>Total</b></td>
        <td style="text-align:center;"><b><?php echo $tot ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totbrt) ?></b></td>
		<td style="text-align:right;"><b><?php echo number_format($totppn) ?></b></td>
		<td style="text-align:right;"><b><?php echo number_format($totrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
         <td style="text-align:center;"><b><?php echo $totproex ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totprorpex) ?></b></td>
       
        <td style="text-align:center;"><b><?php echo $totdo ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totdorp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totpro ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totprorp) ?></b></td>
        
        <td style="text-align:center;"><b><?php echo $totbpro ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totbprorp) ?></b></td>
        
        
        <td style="text-align:center;"><b><?php echo $totgf ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totgfrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totgr ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totgrrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totsf ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totsfrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totmx ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totmxrp) ?></b></td>
</tfoot>
<?php endif ?>
<?php
 if ($jenis=='tl') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>T.qty</th>
        <th>T.Rp</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
$jum_tot = $key->jum_item - $key->jum_retur;
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->jum_item ?></td>
        <td style="text-align:right;"><?php echo number_format($key->jum_rp) ?></td>
        
    </tr>
    <?php
$tot += $key->jum_item;
$totrp += $key->jum_rp;

?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
        <td style="text-align:center;"><b><?php echo $tot ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totrp) ?></b></td>
        
</tfoot>
<?php endif?>

<?php
 if ($jenis=='rg') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty Reg</th>
        <th>Rp Reg</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
if ($key->rg >0 ):
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->rg ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrg) ?></td>
        
    </tr>
<?php endif?>

<?php 
$totreg += $key->rg;
$totregrp += $key->rrg;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>

<?php
 if ($jenis=='mx') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty MX</th>
        <th>Rp MX</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
if ($key->mx >0 ):
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->mx ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rmx) ?></td>
        
    </tr>
<?php endif?>

<?php 
$totreg += $key->mx;
$totregrp += $key->rmx;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>


<?php
 if ($jenis=='bn') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty Bns</th>
        <th>Rp Bns</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
if ($key->bpr >0 ):
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->bpr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->brpr) ?></td>
        
    </tr>
<?php endif?>

<?php 
$totreg += $key->bpr;
$totregrp += $key->brpr;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>



<?php
 if ($jenis=='do') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty DO</th>
        <th>Rp DO</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 if ($key->rd >0): 
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->rd ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrd) ?></td>
        
    </tr>
<?php endif ?>    
<?php $totreg += $key->rd;
$totregrp += $key->rrd;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>



<?php
 if ($jenis=='pr') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty Pro</th>
        <th>Rp Pro</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 if ($key->pr >0): 
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->pr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rpr) ?></td>
        
    </tr>
<?php endif ?>    
<?php $totreg += $key->pr;
$totregrp += $key->rpr;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>


<?php
 if ($jenis=='gf') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty GF</th>
        <th>Rp GF</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 if ($key->gf >0): 
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->gf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgf) ?></td>
        
    </tr>
<?php endif ?>    
<?php $totreg += $key->gf;
$totregrp += $key->rgf;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>


<?php
 if ($jenis=='gr') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty GR</th>
        <th>Rp GR</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 if ($key->gr >0): 
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->gr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgr) ?></td>
        
    </tr>
<?php endif ?>    
<?php $totreg += $key->gr;
$totregrp += $key->rgr;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>



<?php
 if ($jenis=='sp') :   
        ?>     
    
    <thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Nama Menu</th>
        <th>Qty SF</th>
        <th>Rp SF</th>
        
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
 if ($key->sf >0): 
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->sf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rsf) ?></td>
        
    </tr>
<?php endif ?>    
<?php $totreg += $key->sf;
$totregrp += $key->rsf;
?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="2" style="text-align:center;"><b>Total</b></td>
         <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        
</tfoot>
<?php endif?>



<?php else: ?>
<thead>
    <tr>
        <th style="width:50px;">No</th>
        <th>Kode</th>
        <th>Nama Menu</th>
        <th>T.qty</th>
        <th>T.Rp</th>
        <th>Qty Reg</th>
        <th>Rp Reg</th>
        <th>Qty DO</th>
        <th>Rp DO</th>
        <th>Qty Pro</th>
        <th>Rp Pro</th>
        <th>Qty Pro Exp</th>
        <th>Rp Pro Exp</th>
        <th>Qty Gf</th>
        <th>Rp Gf</th>
        <th>Qty GR</th>
        <th>Rp GR</th>
        <th>Qty SF</th>
        <th>Rp SF</th>
        <th>Qty MX</th>
        <th>Rp MX</th>
    </tr>
</thead>
<tbody>
    <?php foreach ($penjualan->result() as $key): ?>
        <?php
$jum_tot = $key->jum_item - $key->jum_retur;
?>
    <tr>
        <td style="text-align:center;"><?php echo $no++ ?></td>
        <td style="text-align:left;"><?php echo $key->kd_barang ?></td>
        <td style="text-align:left;"><?php echo $key->nm_barang ?></td>
        <td style="text-align:center;"><?php echo $key->jum_item ?></td>
        <td style="text-align:right;"><?php echo number_format($key->jum_rp) ?></td>
        <td style="text-align:center;"><?php echo $key->rg ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrg) ?></td>
        <td style="text-align:center;"><?php echo $key->rd ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rrd) ?></td>
        <td style="text-align:center;"><?php echo $key->pr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rpr) ?></td>
         <td style="text-align:center;"><?php echo $key->prex?></td>
        <td style="text-align:right;"><?php echo number_format($key->rprex) ?></td>
        <td style="text-align:center;"><?php echo $key->gf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgf) ?></td>
        <td style="text-align:center;"><?php echo $key->gr ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rgr) ?></td>
        <td style="text-align:center;"><?php echo $key->sf ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rsf) ?></td>
        <td style="text-align:center;"><?php echo $key->mx ?></td>
        <td style="text-align:right;"><?php echo number_format($key->rmx) ?></td>
    </tr>
    <?php
$tot += $key->jum_item;
$totrp += $key->jum_rp;

$totreg += $key->rg;
$totregrp += $key->rrg;

$totdo += $key->rd;
$totdorp += $key->rrd;

$totpro += $key->pr;
$totprorp += $key->rpr;

$totprorpex += $key->rprex;
$totproex += $key->prex;

$totgf += $key->gf;
$totgfrp += $key->rgf;

$totgr += $key->gr;
$totgrrp += $key->rgr;

$totsf += $key->sf;
$totsfrp += $key->rsf;
$totmx += $key->mx;
$totmxrp += $key->rmx;

?>
    <?php endforeach?>
</tbody>
<tfoot>
    <tr>
        <td colspan="3" style="text-align:center;"><b>Total</b></td>
        <td style="text-align:center;"><b><?php echo $tot ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totreg ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totregrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totdo ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totdorp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totpro ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totprorp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totproex ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totprorpex) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totgf ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totgfrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totgr ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totgrrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totsf ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totsfrp) ?></b></td>
        <td style="text-align:center;"><b><?php echo $totmx ?></b></td>
        <td style="text-align:right;"><b><?php echo number_format($totmxrp) ?></b></td>
</tfoot>
     <?php endif?>
</table>
</div>
 <!-- FOOTER SECTION END-->
    <!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
    <script src="<?php echo base_url() ?>/assets/js/jquery-3.3.1.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/jszip.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/pdfmake.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/vfs_fonts.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/bootstrap.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/custom.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/sweetalert.min.js"></script>
    <script src="<?php echo base_url() ?>/assets/js/toastr.min.js"></script>
    
     <script>
      $('#tbPenjualan').DataTable({
          "paging":   false,
          "ordering": false,
          "info":     false,
          "searching":     false,
          "dom": 'Bfrtip',
          "buttons": [
            'copy', 'csv', 'pdf', 'print','excel'
        ]
      });
      $('form').attr('autocomplete', 'off');
      $("ul.nav li.dropdown").hover(function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeIn(500)},function(){$(this).find(".dropdown-menu").stop(!0,!0).delay(100).fadeOut(500)});
      var pesan="<?php echo $this->session->flashdata('msg'); ?>",error="<?php echo $this->session->flashdata('error'); ?>";pesan?(toastr.options={positionClass:"toast-top-right"},toastr.success(pesan)):error&&swal(error);
      function convertToRupiah(r){for(var e="",t=r.toString().split("").reverse().join(""),n=0;n<t.length;n++)n%3==0&&(e+=t.substr(n,3)+".");return e.split("",e.length-1).reverse().join("")};
	function isNumber(evt) {
        evt = (evt) ? evt : window.event;
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            return false;
        }
      return true;
    } 
    </script>
</body>
</html>