
  <div class="content-wrapper" style="margin-bottom: 20px;margin-left: 20px">
    <div class="container-fluid">
      <div class="row pad-botm">
          <div class="col-md-12">
               <?php 
				    $akses = $this->session->userdata('akses');
				    if($akses !='kasir') { ?>
				        <form class="header-line" class="form-inline" action="<?php echo base_url('kasir/rekapkedai/') ?>" method="post">
					    <tr>
						    <td>Kedai</td>
						    <td>:</td>
						    <td>
							    <select  name="kedai" id="kedai" required>
								    <option height='45px' value="">Pilih Kedai</option>
								    <option <?php if($this->input->post('kedai') == 'KDR01'){echo 'selected';}?> value="KDR01">Ngronggo</option>
								    <option <?php if($this->input->post('kedai') == 'KDR02'){echo 'selected';}?> value="KDR02">Polim</option>
								    <option <?php if($this->input->post('kedai') == 'KDR03'){echo 'selected';}?> value="KDR06">Penanggungan</option>
								    <option <?php if($this->input->post('kedai') == 'KDR04'){echo 'selected';}?> value="KDR04">Gumul</option>
								    <option <?php if($this->input->post('kedai') == 'KDR05'){echo 'selected';}?> value="KDR05">Pare</option>
								    <option <?php if($this->input->post('kedai') == 'BLT01'){echo 'selected';}?> value="BLT01">Blitar</option>
								    <option <?php if($this->input->post('kedai') == 'KNR01'){echo 'selected';}?> value="KNR01">Srengat</option>
								    <option <?php if($this->input->post('kedai') == 'NJK01'){echo 'selected';}?> value="NJK01">Nganjuk</option>
								    <option <?php if($this->input->post('kedai') == 'NJK02'){echo 'selected';}?> value="NJK02">Kertosono</option>
								    <option <?php if($this->input->post('kedai') == 'NJK03'){echo 'selected';}?> value="NJK03">Warujayeng</option>
								    <option <?php if($this->input->post('kedai') == 'JBG01'){echo 'selected';}?> value="JBG01">Jombang</option>
								    <option <?php if($this->input->post('kedai') == 'JBG03'){echo 'selected';}?> value="JBG03">Djoetek</option>
								    <option <?php if($this->input->post('kedai') == 'MJK01'){echo 'selected';}?> value="MJK01">Moker 1</option>
								    <option <?php if($this->input->post('kedai') == 'MJK02'){echo 'selected';}?> value="MJK02">Moker 2</option>
								    <option <?php if($this->input->post('kedai') == 'MJK03'){echo 'selected';}?> value="MJK03">Moker 3</option>
								    <option <?php if($this->input->post('kedai') == 'MJK04'){echo 'selected';}?> value="MJK04">Pandan</option>
								    <option <?php if($this->input->post('kedai') == 'MJK05'){echo 'selected';}?> value="MJK05">Mojosari</option>
								    <option <?php if($this->input->post('kedai') == 'MLG01'){echo 'selected';}?> value="MLG01">Malang</option>
								    <option <?php if($this->input->post('kedai') == 'SDR01'){echo 'selected';}?> value="SDR01">Sepanjang</option>
								    <option <?php if($this->input->post('kedai') == 'ZZ'){echo 'selected';}?> value="ZZ">Rekap All Kedai</option>
							    </select>
						    </td>
					        <td>Bulan</td>
					        <td>:</td>			
					        <td>
							    <select  name="utgl" id="utgl" required>
								    <option height='45px' value="">Pilih Bulan</option>
								    <option <?php if ($bulan == '01') {echo 'selected';}?> value="01">Januari</option>
                                    <option <?php if ($bulan == '02') {echo 'selected';}?> value="02">Februari</option>
                                    <option <?php if ($bulan == '03') {echo 'selected';}?> value="03">Maret</option>
                                    <option <?php if ($bulan == '04') {echo 'selected';}?> value="04">April</option>
                                    <option <?php if ($bulan == '05') {echo 'selected';}?> value="05">Mei</option>
                                    <option <?php if ($bulan == '06') {echo 'selected';}?> value="06">Juni</option>
                                    <option <?php if ($bulan == '07') {echo 'selected';}?> value="07">Juli</option>
                                    <option <?php if ($bulan == '08') {echo 'selected';}?> value="08">Agustus</option>
                                    <option <?php if ($bulan == '09') {echo 'selected';}?> value="09">September</option>
                                    <option <?php if ($bulan == '10') {echo 'selected';}?> value="10">Oktober</option>
                                    <option <?php if ($bulan == '11') {echo 'selected';}?> value="11">November</option>
                                    <option <?php if ($bulan == '12') {echo 'selected';}?> value="12">Desember</option>
							    </select>
						    </td>
						     <td>Tahun</td>
					        <td>:</td>	
					        <td>
						     <select  name="tahun" id="tahun" required>
								    <option height='45px' value="">Pilih Tahun</option>
								     <option <?php if ($bulan == '2021') {echo 'selected';}?> value="2021">2021</option>
                                    <option <?php if ($bulan == '2022') {echo 'selected';}?> value="2022">2022</option>
                                    <option <?php if ($bulan == '2023') {echo 'selected';}?> value="2023">2023</option>
                                    <option <?php if ($bulan == '2024') {echo 'selected';}?> value="2024">2024</option>
							    </select>
							 </td>   
						    <td>Nilai PB1</td>
					        <td>:</td>			
					        <td>
							    <input style="text-align: right;" name="npb1" type="number" id="npb1" onkeypress="return isNumber(event)" 
							    value="<?php if($this->input->post('npb1')){echo $this->input->post('npb1');}else{ echo '';}?>"  />
						    </td>
						    <td><button height='45px' class="btn" type="submit" ><font color='blue' ><b>GO</b></font></button></td>
					    </tr>
				        </form>	
		        <?php } else { ?>
		            <form class="header-line" class="form-inline" action="<?php echo base_url('kasir/rekapkedai/') ?>" method="post">
					    <tr>
					        <td>Tanggal</td>
					        <td>:</td>			
					        <td><input name='utgl' id='utgl' type='date' VALUE='<?php echo date("m") ?>'  readonly></input></td>
					        <button  class="btn" type="submit" ><font color='blue' ><b>GO</b></font></button>
					    </tr>
				    </form>	
		  <?php } ?>
			<!-- <h5 >REKAP <?php echo date_indo($tanggal) ?> <span class="pull-right"><a id="btnRekap" class="btn btn-danger" href="<?php echo base_url('kasir/cetak-rekap') ?>">Cetak Rekap</a></span></h5>	-->
          </div>
      </div>
	 
       <div class="row">
        <div class="col-md-12">
            <h4><strong>Rekap Penjualan Kedai</strong></h4> 
            <table id="tbPenjualan" class="table table-bordered table-striped table-responsive">
              <thead>
                <tr>
                  <th>No</th>
                  <th>Kedai</th>
				  <th>Tanggal</th>
                  <th>Hari</th>
                  <th>R.Total</th>
				  <th>R.Pb1</th>
                  <th>R.Netto</th>
                  <th>P.Total</th>
				  <th>P.Pb1</th>
                  <th>P.Netto</th>
                  <th>S.Pb1</th>
                  <th>%</th>
                <th>R.Ojol</th>
                  <th>R.Bank</th>
                  <th>R.Cash</th>
                  <th>P.Cash</th>
                  <th>S.Cash</th>
                  <th>Tunai</th>
                </tr>
              </thead>
                <!-- SUM(a.nilai) ptotal,SUM(a.nppn) ppb1,SUM(a.nilai+a.nppn) pnetto,SUM(a.nilai1) rtotal,SUM(a.nppn1) rpb1,SUM(a.nilai1+a.nppn1) rnetto") -->
              <tbody>
                <?php foreach ($penjualan->result() as $key): ?>
                <?php 
                    $pnet=$key->pnetto; 
                    $rnet=$key->rnetto; 
                    $rcash=$key->rtotal-$key->ojol-$key->bank;
                    $pcash=$key->ptotal-$key->ojol-$key->bank;
                    if($rnet==0) {$rnet='1';}
                    
                ?>
                <tr>
                  <td align="center"><?php echo $no++ ?></td>
                  <td><?php echo $key->nm_toko ?></td>
				  <td><?php echo $key->tgl ?></td>
                  <td><?php echo $key->hari ?></td>
                  <td align="right"><?php echo number_format($key->rtotal) ?></td>
				  <td align="right"><?php echo number_format($key->rnppn) ?></td>
				  <td align="right"><?php echo number_format($key->rnetto) ?></td>
                  <td align="right"><?php echo number_format($key->ptotal) ?></td>
				  <td align="right"><?php echo number_format($key->pnppn) ?></td>
				  <td align="right"><?php echo number_format($key->pnetto) ?></td>
				  <td align="right"><?php echo number_format(($key->rnppn-$key->pnppn)) ?></td>
				  <td align="right"><?php echo number_format(($pnet/$rnet),2)*100 ?></td>
				  <td align="right"><?php echo number_format($key->ojol) ?></td>
				  <td align="right"><?php echo number_format($key->bank) ?></td>
				  <td align="right"><?php echo number_format($rcash) ?></td>
				  <td align="right"><?php echo number_format($pcash) ?></td>
				  <td align="right"><?php echo number_format($rcash-$pcash) ?></td>
				  <td align="right"><?php echo number_format(($rcash-$pcash)*1.1) ?></td>
				  
                </tr>
<?php
$rtotal += $key->rtotal;
$rnppn += $key->rnppn;
$rnetto += $key->rnetto;
$pnppn += $key->pnppn;
$ptotal += $key->ptotal;
$pnetto += $key->pnetto;
$tojol += $key->ojol;
$tbank += $key->bank;
$trcash += $rcash;
$tpcash += $pcash;
$tscash += $rcash-$pcash;


$selisih += $key->rnppn-$key->pnppn;
?>
                <?php endforeach?>
              </tbody>
                  <thead>
                    <tr>
						<td colspan="4" align="center">Total Omset Penjualan</td>
						<td align="right"><?php echo number_format($rtotal, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($rnppn, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($rnetto, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($ptotal, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($pnppn, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($pnetto, 0, ',', '.') ?></td>
						<td align="right"><?php echo number_format($selisih, 0, ',', '.') ?></td>
                        <td></td>
                        <td align="right"><?php echo number_format($tojol, 0, ',', '.') ?></td>
                        <td align="right"><?php echo number_format($tbank, 0, ',', '.') ?></td>
                        <td align="right"><?php echo number_format($trcash, 0, ',', '.') ?></td>
                        <td align="right"><?php echo number_format($tpcash, 0, ',', '.') ?></td>
                        <td align="right"><?php echo number_format($tscash, 0, ',', '.') ?></td>
                        <td align="right"><?php echo number_format(($tscash*1.1), 0, ',', '.') ?></td>
                    </tr>
                  </thead>
            </table>
        </div>
      </div>
    </div>
  </div>
     <!-- CONTENT-WRAPPER SECTION END-->
    <section id="gradient11" class="footer-section">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                   &copy; Copyright <?php echo date('Y') ?>, <a href="enambelasapp.my.id" target="_blank">Mandiri</a>
                </div>
            </div>
        </div>
    </section>
  
   
    
    <!-- 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);
      
     
    </script>
<style type="text/css">
	#gradient11 {
	  background-image: radial-gradient(circle, red, yellow, green);
	}
</style>
</body>
</html>