<?php
	include "php_class/class_mysql.php";
	include "php_class/class_template.php";
	$DataTemplate = new DataTemplate;
?>
<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>
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script>
	$(document).ready(function(){
		$("#nama").click(function(){
			$("#myModal").modal('show');
		});
		$("#AddTrans").click(function(){
			$("#myModal2").modal('show');
		});
	});
</script>
<section class="content-header">
  <h1>
   Data Template Transaksi
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="<?php echo $base?>add-transaksi">Data Transaksi</a></li>
    <li class="active">Tambah Transaksi</li>
  </ol>
</section>
<section class="content">
 	<div class="row">
    	<div class="row">
        	<div class="col-md-12">
            </div>
        </div>
    	<div class="col-md-12">
        	 <div class="box box-info">
                <div class="box-header">
                  <h3 class="box-title">Tambah Transaksi</h3>
                </div>
                <div class="box-body">
                	<form method="post" action="<?php echo $base?>query-add-temp-grup-edit">
                    	<input type="hidden" name="idGrup" value="<?php echo $xcode?>">
                    	<input type="hidden" name="id" id="ids">
                        <div class="form-group">
                            <label class="control-label">Nama Template Transaksi</label>
                            <input type="text" class="form-control" placeholder="nama template transaksi" name="nama" id="nama">
                         </div>
                         <div class="form-group">
                            <label class="control-label">Biaya</label>
                            <input type="text" name="biaya"  class="form-control"  placeholder="biaya" id="biaya">
                         </div>
                         <div class="form-group">
                            <button type="submit" class="btn btn-default"><i class='glyphicon glyphicon-ok'></i> Simpan</button>
                          </div>
                    </form>
                </div>
               </div>
         </div>
    </div>
</section>
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	$("#example1").dataTable();
	
  });
</script>

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Daftar Transaksi</h4>
      </div>
      <div class="modal-body">
            <div class="table-responsive">
              <table id="example1" class="table table-bordered table-striped table-hover">
                 <thead>
                    <tr>
                        <th>Id Template</th>
                        <th>Nama</th>
                        <th>Biaya Reguler</th>
                        <th>Biaya Non Reguler</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                    $JumlahData = $DataTemplate->get_template_all('',$a,'jumlah');
                    if ($JumlahData<=0){
                        echo "<tr class='odd gradeX'>";
                        echo "<td>No Data</td>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "</tr>";	
                    }else{
                        for ($a=1;$a<=$JumlahData;$a++){
                            $id = $DataTemplate->get_template_all('NoID',$a,'');
                            $namaTrx = $DataTemplate->get_template_all('NamaTRX',$a,'');
                            $BiayaReguler = $DataTemplate->get_template_all('BiayaReguler',$a,'');
                            $BiayaNonReguler = $DataTemplate->get_template_all('BiayaNonReguler',$a,'');
                            echo "<tr ids='".$id."-".$namaTrx."-".$BiayaReguler."' class='odd gradeX context pilih'>";
                            echo "<td>".$id."</td>";
                            echo "<td>".$namaTrx."</td>";
                            echo "<td>".$BiayaReguler."</td>";
                            echo "<td>".$BiayaNonReguler."</td>";
                            echo "</tr>";
                        }
                    }
                ?>
                </tbody>
              </table>
           </div>
	  </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
	$(document).ready(function(){
		$('.pilih').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				id = pecah[0];
				nama = pecah[1];
				biaya = pecah[2];
				
			$('#ids').val(id);
			$('#nama').val(nama);
			$('#biaya').val(biaya);
			$('#myModal').modal('hide')
			$('#biaya').focus();
		});
	});
</script>

    	
    	
   