list.pt 6.62 KB
<html metal:use-macro="load: ../base.pt">

<div metal:fill-slot="content">
  <link href="/static/datatables/extensions/TableTools/css/dataTables.tableTools.min.css" rel="stylesheet">
  <link href="/static/datatables/media/css/dataTables.bootstrap.css" rel="stylesheet">

<h4>Daftar STS</h4>
<hr>
<div class="container">
<!--form class="form-inline" role="form" id="frm_upload" name="frm_upload">
    <label for="upload" class="control-label">Upload:</label>
    <input type="text" class="form-control" id="upload">
    <button type="submit" class="btn btn-default">Upload</button>
</form-->
</div>
<p>
<table id="table1" name="table1" class="table table-bordered table-hover table-condensed" >
    <thead>
        <tr>
            <th>ID</th>
            <th>Kode</th>
            <th>Tanggal</th>
            <th>Uraian</th>
            <th>OPD</th>
            <th>Jumlah</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>
<script src="/static/datatables/media/js/jquery.dataTables.min.js"></script>
<!--script src="/static/datatables/media/js/jquery.jeditable.js')}"></script-->
<script src="/static/datatables/media/js/jquery.dataTables.ext.js"></script>
<script src="/static/datatables/extensions/TableTools/media/js/ZeroClipboard.js"></script>
<script src="/static/datatables/media/js/dataTables.bootstrap.js"></script>

<script>
  var mID;  
  var oTable;
  var iPos;
  var oFormUrl  = "/arsts/";
  var oTableUrl = oFormUrl+"grid/act";
  
  $(document).ready(function () {
      oTable = $('#table1').dataTable({
          "sAjaxSource"    : oTableUrl,
          "bStateSave"     : true,
          "bServerSide"    : true,
          "bProcessing"    : true,
          "sDom"           : '<"toolbar">lfrtip',
          "bScrollCollapse": true,
          "bSort"          : true,
          "bInfo"          : false,
          "bFilter"        : true,
          "bAutoWidth"     : false,
          "bPaginate"      : true,
          "sPaginationType": "full_numbers",
          
          "lengthMenu": [
              [10, 25, 50, 100],
              [10, 25, 50, 100]
          ],
          
          "aoColumnDefs": [
              {"bSearchable": false, "bVisible": false, "aTargets": [0]}
          ],

          "aoColumns": [
              null, 
              {"sWidth": "100px", "sClass": "left"},
              {"sWidth": "40px"},
              null, 
              null,
              {"sWidth": "80px", "sClass": "right"},
          ],
      });

      var tb_array = [
          '<div class="btn-group pull-left">',
          '	<button id="btn_tambah" class="btn btn btn-primary  pull-left" type="button">Tambah</button>',
          '	<button id="btn_edit"   class="btn btn btn-primary  pull-left" type="button">Edit</button>',
          '	<button id="btn_delete" class="btn btn btn-danger   pull-left" type="button">Hapus</button>',
          '	<button id="btn_print"  class="btn btn btn-primary  pull-left" type="button">Cetak</button>',
          '	<button id="btn_close"  class="btn btn btn-warning" type="button">Tutup</button>',
          '	&nbsp;',
          '</div>',
      ];

      var tb = tb_array.join(' ');
      $("div.toolbar").html(tb);

      $('#table1 tbody').on('click', 'tr', function () {
          if ($(this).hasClass('selected')) {
              mID = '';
              $(this).removeClass('selected');
          } else {
              iPos = oTable.fnGetPosition(this);
              var aData = oTable.fnGetData(iPos);
              mID = aData[0];
              oTable.$('tr.selected').removeClass('selected');
              $(this).addClass('selected');
          }
      });

      $('#btn_tambah').click(function () {
          window.location = oFormUrl+'add';
      });

      $('#btn_edit').click(function () {
          if (mID) {
              window.location = oFormUrl+mID+'/edit';
          } else {
              alert('Silahkan pilih data yang akan diedit');
          }
      });

      $('#btn_close').click(function () {
          window.location = "/"
      });

      /*$('#tanggal').click(
          function(){
            if (!Modernizr.inputtypes['date'] ||
                "date" != "date"){
              $('#tanggal').pickadate({"selectMonths": true,
                "submitFormat": "yyyy-mm-dd", 
                "selectYears": true, "format": "yyyy-mm-dd"});
            }
          }
      );
      $('#tanggal2').click(
          function(){
            if (!Modernizr.inputtypes['date'] ||
                "date" != "date"){
              $('#tanggal2').pickadate({"selectMonths": true,
                "submitFormat": "yyyy-mm-dd", 
                "selectYears": true, "format": "yyyy-mm-dd"});
            }
          }
      );*/
      
      $('#btn_print').click(function () {
          //$('#dlgRpt').modal('show');
          url = "/reports/act/r300?id="+mID;
          if (mID) {
                 window.open(url);
          } else {
              alert('Silahkan pilih Kode STS');
          }
      });

      $('#btn_pil_rpt').click(function () {
          url = "/reports/act/r300"
          window.open(url);
      });
      
      $('#btn_delete').click(function () {
          if (mID) {
              var hapus = confirm('Hapus data ini?');
              if (hapus == true) {
                  window.location = oFormUrl+mID+'/delete';
              };
          } else {
              alert('Silahkan pilih data yang akan dihapus');
          }
      });
  });
</script>
    <!-- Modal Report -->
    <div class="modal fade" id="dlgRpt">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title">Pilih Report</h4>
          </div>

        <div class="modal-body">
            <div class="row">
            <label for="tanggal" class="control-label col-md-2" id="req-tanggal">
                    Tanggal</label>
            <div class="col-md-4">
                <input id="tanggal" class="form-control" type="text" readonly 
                        value="" name="tanggal"/>
            </div>
            <div class="col-md-4">
                <input id="tanggal2" class="form-control" type="text" readonly 
                        value="" name="tanggal"/>
            </div>
            </div>
        </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
            <button type="button" class="btn btn-primary" id="btn_pil_rpt" name="btn_pil_rpt">Cetak</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
</html>