<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
	
	$("#example1").dataTable();
	
	$('.context').click(function(e){
		var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});
	
	/*$('.context').bind('contextmenu', function(e){
		e.preventDefault();
    	var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});*/
	
	$('#editdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'edit-dosen/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-delete-dosen/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		window.location=''+base+'add-dosen';
	});

  });
   
</script>
<aside class="right-side">                
                <section class="content-header">
                    <h1>
                        Data Pemesanan
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="home"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li class="active">Data Pemesanan</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                	<div class="col-sm-4">
                                    <form action="data-pemesanan" method="post">
                                         <div class="form-group">
                                         <?php
											$tanggal = $_POST['tanggal'];
											$tanggal = substr($tanggal, 0, 10);
											if($tanggal == ''){
												$tanggal = date('Y-m-d');
											}
										 ?>
                                            <div class="input-group date form_date" data-date="" data-date-format="mm-dd-yyyy" data-link-field="tgl">
                                                <input required="required" class="form-control" type="text" value="<?php echo $tanggal;?>" readonly id="tgl2">
                                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                                <input type="hidden" id="tgl" name="tanggal" value="" />
                                                <script type="text/javascript">
                                                    $('.form_date').datetimepicker({
                                                        language:  'id',
                                                        weekStart: 1,
                                                        todayBtn:  1,
                                                        autoclose: 1,
                                                        todayHighlight: 1,
                                                        startView: 2,
                                                        minView: 2,
                                                        forceParse: 0
                                                    });
                                                </script>  
                                            </div>
                                         </div>
                                	</div>
                                    <div class="col-sm-4">
                                    	<button type="submit" class="btn btn-success" style="width:150px;"><i class='glyphicon glyphicon-search'></i> Cari</button>
                                    </div>
                                    </form>
                                    <div class="col-sm-4">
                                        <a href="<?php echo $base?>singkong"><button class="btn btn-primary" style="width:150px; float:right; margin-right:20px;" type="button"><i class='glyphicon glyphicon-refresh'></i> Refresh</button></a>
                                    </div>
                                </div><!-- /.box-header -->
        <div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No</th>
                    <th>Kode Pemesanan</th>
                    <th>Tanggal</th>
                    <th>Nama</th>
                    <th>email</th>
                    <th>Telp</th>
					<th>Alamat</th>
                    <th>Total</th>                    
                    <th><div align="center">Aksi</div></th>
                </tr>
            </thead>
            <tbody>
			<?php  
				    include("config/connection.php");
					if($tanggal != ''){
              			$sql ="select tb_pemesanan.*, sum(tb_pemesanan_detil.harga) as total, tb_member.* from tb_pemesanan
							inner join tb_pemesanan_detil on tb_pemesanan.id_pemesanan = tb_pemesanan_detil.id_pemesanan
							inner join tb_member on tb_pemesanan.id_member = tb_member.id_member
							where tb_pemesanan.Status = '1' and tb_pemesanan_detil.tanggal = '".$tanggal."'
							group by tb_pemesanan.id_pemesanan
							";
					}else{
						$sql ="select tb_pemesanan.*, sum(tb_pemesanan_detil.harga) as total, tb_member.* from tb_pemesanan
							inner join tb_pemesanan_detil on tb_pemesanan.id_pemesanan = tb_pemesanan_detil.id_pemesanan
							inner join tb_member on tb_pemesanan.id_member = tb_member.id_member
							where tb_pemesanan.Status = '1' and tb_pemesanan_detil.tanggal = '".date('Y-m-d')."'
							group by tb_pemesanan.id_pemesanan
							";
					}
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					$a = 0;
					while($row = mysql_fetch_object($hasil)){
						    
						$id_pemesanan = $row->id_pemesanan;
						$nama = $row->nama;
						$email = $row->email;
						$alamat = $row->alamat;
						$telp = $row->telp;
						$tanggal_trx = $row->tanggal_trx;
						$total = $row->total;
						$a = $a + 1;
						
			?>
            		<tr>
                    	<td><?php echo $a ?></td>
                        <td><?php echo $id_pemesanan ?></td>
                        <td><?php echo $tanggal_trx ?></td>
                        <td><?php echo $nama ?></td>
                        <td><?php echo $email ?></td>
                        <td><?php echo $telp ?></td>
                        <td><?php echo $alamat ?></td>
                        <td>Rp. <?php echo number_format($total); ?></td>
                        <td><div align="center"><a data-toggle="modal" data-id='<?php echo $id_pemesanan?>' href="#modalEdit" class="open-Edit btn btn-xs btn-primary"><i class="fa fa-ticket"></i></a></div></td>
                    </tr>
            <?php		
					}
			?>         
        	</tbody>
          </table>
          </div>
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
                              <div class="modal fade" id="modalEdit" tabindex="-1" role="dialog">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Ubah Pemesanan</h4>
                                        </div>
                                        <div class="modal-body" id="isi">

                                        </div> 
                                        <div class="modal-footer">
                                            <div class="form-group">  
                                                <label class="col-sm-2" for="aksi"></label>      
                                                    <div class="col-sm-10">
                                                        
                                                    </div>
                                            </div>
                                        </div>
                                    </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>

  
  
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="js/bootstrap.min.js" type="text/javascript"></script>

        <script src="js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
        <script src="js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="js/AdminLTE/app.js" type="text/javascript"></script>
		<script type="text/javascript">
            $(function() {
                $("#example1").dataTable();
                $('#example2').dataTable({
                    "bPaginate": true,
                    "bLengthChange": false,
                    "bFilter": false,
                    "bSort": true,
                    "bInfo": true,
                    "bAutoWidth": false
                });
            });
        </script>
    <script>
        $(document).on("click", ".open-Edit", function () {
            var Id = $(this).data('id');
            //event.preventDefault();
            $.ajax({
                type: "post",
                url: "jsonpemesanan.php",
                data: "id_pemesanan="+Id,
                success: function(data){
                    $("#isi").html(data);
                },
                error: function(){
                    alert("failure");
                }
            });
        });
        $(document).on("click", ".open-Delete", function () {
            var Id = $(this).data('id');
            //event.preventDefault();
            $('#idd').val(Id);
            $('#modalDelete').modal('show');
        });

    </script>
<script>
	function refpem(){
alert('oke');
                var flickerAPI =  'http://localhost/admintiket/singkong.php';
                $.getJSON( flickerAPI, {
					id: '1'
                })
                  .done(function( data ) {
                    alert(JSON.stringify(data))
                  $.ajax({
                        type: "POST",
                         cache:false,
                        url: 'http://localhost/admintiket/singkongsimpan.php',
                        data: {data: data},
                        success: function(data){
                              $.alert('Data Sasaran Berhasil Di Sinkronosasi...');        
                        }
                      });
                  });
 
}



</script>