  <div class="content-wrapper" style="margin-bottom: 20px">
    <div class="container">
      <div class="row pad-botm">
          <div class="col-md-12">
              <h6 class="header-line">DATA PROGRAM PROMOSI <span class="pull-right"><a href="" data-toggle="modal" data-target="#myModal">Tambah Data</a></span></h6>
          </div>
      </div>
      <div class="row">
        <div class="col-md-12">
            <table id="tbUser" class="table table-bordered  table-responsive">
              <thead>
                <tr>     
					<th>Nobukti</th>
					<th>Tgl</th>
					<th>IdPromo</th>
					<th>Mulai</th>
					<th>Akhir</th>
					<th>MinOrder</th>
					<th>MaxDisc</th>
					<th>Disc %</th>
					<th>Disc Rp</th>
					<th>Area</th>
					<th>Status</th>
					<th>Action</th>		
				</tr>	
              </thead>
              <tbody>
                <?php foreach ($listjob->result() as $key): 
					$nobukti=$key->nobukti;
					?>
				
                <tr>
				  
                  <td><?php echo $key->nobukti ?></td>
                  <td><?php echo $key->tgl ?></td>
				  <td><?php echo $key->idprogram ?></td>
                  <td><?php echo $key->tglawal ?></td>
				  <td><?php echo $key->tglakhir ?></td>
				  <td align='right'><?php echo number_format($key->minorder) ?></td>
				  <td align='right'><?php echo number_format($key->maxdisc) ?></td>
				  <td align='right'><?php echo number_format($key->disc1) ?></td>
				  <td align='right'><?php echo number_format($key->ndisc1) ?></td>
				  <td><?php echo $key->kedai ?></td>
				  <td><?php echo $key->kstat ?></td>
				  
                  <td align="center"><a href="javascript:void(0);" class="edit_record"  
				  data-nobukti="<?php echo $key->nobukti ?>" 
				  data-idprogram="<?php echo $key->idprogram ?>"
				  data-tgl="<?php echo $key->tgl ?>"
				  data-mulai="<?php echo $key->tglawal ?>"
				  data-akhir="<?php echo $key->tglakhir ?>"
				  data-minorder="<?php echo $key->minorder ?>"
				  data-maxdisc="<?php echo $key->maxdisc ?>"
				  
				  > Edit</a>
                </tr>
                <?php endforeach?>
              </tbody>
            </table>
        </div>
      </div>
    </div>
  </div>
  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Tambah Program Promo</h4>
        </div>
        <div class="modal-body">
          <form class="form-horizontal" action="<?php echo base_url('manajer/simpan_programpromo') ?>" method="post">
            <div class="form-group">
              <label class="control-label col-sm-2" for="id_user">ID User</label>
              <div class="col-sm-5">
                <input type="text" class="form-control" id="id_user" name="id_user" required>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-2" for="nm_user">Nama</label>
              <div class="col-sm-5">
                <input type="text" class="form-control" id="nm_user" name="nm_user" required>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-2" for="password">Password</label>
              <div class="col-sm-5">
                <input type="password" class="form-control" id="password" name="password" required>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-2" for="akses">Akses</label>
              <div class="col-sm-5">
                <select name="akses" id="akses" class="form-control" required>
                  <option value="">Pilih Hak Akses</option>
                  <option value="manager">Manager</option>
                  <option value="admin">Admin</option>
                  <option value="gudang">Gudang</option>
                  <option value="kasir">Kasir</option>
                </select>
              </div>
            </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary">Simpan</button>
        </div>
        </form>
      </div>
    </div>
  </div>
  
  <!-- detail promo -->
  		
  <div class="modal fade" id="modalEdit" tabindex="-1" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Detail Program Promo</h4>
        </div>
		
		<form class="form-horizontal" action="<?php echo base_url('manajer/simpan_programpromo_edit') ?>" method="post">
				<div class="modal-body">
					<div class="form-group">
						<div class="col-sm-12">
							<table class="table table-bordered">
								<div class="form-group">
									<div class="col-sm-6">
										<tr>
											<td>
												
												Nobukti : <input type="text" class="form-control col-sm-2" id="nobukti" name="nobukti" disabled></a>
											</td>
											<td>
												
												Tanggal :<input type="text" class="form-control col-sm-2" id="tgl"  name="tgl" disabled>
											</td>									
											<td>
												Id Promo :
												<input type="text" class="form-control col-sm-2" id="idprogram"  name="idprogram" disabled>
											</td>
										</tr>
										<tr>
											<td>
												Mulai :
												<input type="text" class="form-control col-sm-2" id="mulai"  name="mulai" disabled>
											</td>
											<td>
												Akhir :
												<input type="text" class="form-control col-sm-2" id="akhir"  name="akhir" disabled>
											</td>
										</tr>	
										<tr>
											<td>
												Min Order :
												<input type="text" class="form-control" id="minorder"  name="minorder" disabled>
											</td>	
											<td>
												Max Discount :
												<input type="text" class="form-control" id="maxdisc"  name="maxdisc" disabled>
											</td>	
										</tr>	
									</div>
								</div>
							</table>	
							<table class="table table-bordered">
									<thead>
									<tr>
										<th>Kedai</th>
										<th >Menu</th>
										<th >Pelanggan</th>
										<th style="text-align:center;">Disc.</th>
										<th style="text-align:center;">Coret Harga.</th>
									</tr>
									</thead>
									<tbody>
													<?php
														
														$query=$this->db->query("SELECT * FROM promoheader limit 10 ");
														foreach ($query->result_array() as $j) {
															$menu_nama=$j['nobukti'];
															$menu_harjul=$j['minorder'];
															$menu_porsi=$j['idprogram'];
															$menu_subtotal=$j['maxdisc'];
														
													?>
													<tr>
														<td><?php echo $menu_nama;?></td>
														<td style="text-align:center;"><?php echo number_format($menu_harjul);?></td>
														<td style="text-align:center;"><?php echo $menu_porsi;?></td>
														<td style="text-align:center;"><?php echo number_format($menu_subtotal);?></td>
													</tr>
													<?php } ?>
												</tbody>
							</table>		
						</div>
			</div>
</div>			
						
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" id="btnSimpan" class="btn btn-primary">Simpan</button>
        </div>
        </form>
      </div>
    </div>
  </div>
     <!-- CONTENT-WRAPPER SECTION END-->
    <section 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>
</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/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>
      $('#tbUser').DataTable({
         "searching" : false,
          "ordering": false,
		  
      });
      $('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);

      $(document).ready(function() {
          $('#tbUser').on('click','.edit_record',function(){
              var nobukti=$(this).data('nobukti');
              var tgl=$(this).data('tgl');
              var idprogram=$(this).data('idprogram');
			  var mulai=$(this).data('mulai');
			  var akhir=$(this).data('akhir');
			  var minorder=$(this).data('minorder');
			  var maxdisc=$(this).data('maxdisc');
              $('#modalEdit').modal('show');
              $('[name="nobukti"]').val(nobukti);
              $('[name="tgl"]').val(tgl);
              $('[name="idprogram"]').val(idprogram);
			  $('[name="mulai"]').val(mulai);
			  $('[name="akhir"]').val(akhir);
			  $('[name="minorder"]').val(minorder);
			  $('[name="maxdisc"]').val(maxdisc);
			  
			
			  
			  
          });

          $('#tbUser').on('click','.hapus_record',function(){
              var id=$(this).data('id');
              var result = confirm("Apakah yakin akan menghapus kode "+id+" ini?");
              var akses = "<?php echo $this->session->userdata('akses') ?>";
              if (akses == 'manager') {
                  if (result) {
                    window.location.href = '<?php echo base_url('manajer/hapus_user/') ?>'+id;
                  }
              }
          });
      });

      $("#id_user").keypress(function(e){
          if(e.which==32){
              return false;
          }
      });

    </script>

</body>
</html>