list_piutang.pt 11.4 KB
<html metal:use-macro="load: ./base.pt">
<div metal:fill-slot="content">
  <tal metal:use-macro="load:list_include.pt" />
  <div class="jarviswidget jarviswidget-color-blueLight"> <!-- jarviswidget -->
    <header role="heading">
      <h2>
        <i class="fa fa-fw fa-table"></i>
        ${request.title}
      </h2>
    </header>

    <div role="content">
      <div class="widget-body"> <!-- widget-body -->
        <div class="dataTables_wrapper form-inline no-footer">
          <div class="dt-toolbar" style="padding: 0; margin-bottom: 5px; background: #fff; border-bottom: none;">
            <!-- dt-toolbar -->
            <div class="col-xs-12 col-md-12 col-sm-10">
              <div class="dataTables_filter">
                <label> <!-- Tgl.realisasi -->
                  <span class="input-group-addon text-left" id="label-awal"
                    style="width: 120px!important;padding-left: 10px!important;">Tgl. Laporan</span>
                  <input class="form-control" id="awal" name="awal" type="text" value="${request.session['awal']}" />
                  <span class="input-group-addon" id="label-akhir" style="width: 50px!important;">s.d.</span>
                  <input class="form-control" id="akhir" name="akhir" type="text" value="${request.session['akhir']}" />
                </label>
              </div>
            </div>
          </div>
          <div class="dt-toolbar" style="padding: 0; margin-bottom: 5px; background: #fff; border-bottom: none;">
            <!-- dt-toolbar -->
            <div class="col-xs-12 col-sm-10">
              <div class="dataTables_filter">
                <label><!-- input pajak -->
                  <span class="input-group-addon text-left" id="label-tahun"
                    style="width: 120px!important;padding-left: 10px!important;">
                    Tahun Pajak
                  </span>
                  <select id="tahun" name="tahun" class="form-control" style="width:110px;">
                    <option value="0000">Semua</option>
                    <tal:block tal:repeat="x range(tahun, tahun-20, -1)">
                      <option tal:condition="x != int(request.session['tahun'])" tal:attributes="value x"
                        tal:content="x">
                      </option>
                      <option tal:condition="x == int(request.session['tahun'])" tal:attributes="value x"
                        tal:content="x" selected>
                      </option>
                    </tal:block>
                  </select>
                </label><!-- input pajak -->
              </div>

              <div class="dataTables_filter">

                <label><!-- input buku -->
                  <span class="input-group-addon text-left" id="label-buku"
                    style="width: 120px!important;padding-left: 10px!important;">Buku</span>
                  <select id="buku" name="buku" class="form-control" style="width:150px;">
                    <tal:block tal:repeat="buku bukus">
                      <option tal:condition="buku[0] != request.session['buku']" tal:attributes="value buku[0]"
                        tal:content="buku[1][0]">
                      </option>
                      <option tal:condition="buku[0] == request.session['buku']"
                        tal:attributes="value buku[0]; selected True" tal:content="buku[1][0]">
                      </option>
                    </tal:block>
                  </select>
                </label><!-- /input buku -->
              </div>
            </div>
          </div>

          <div class="dt-toolbar" style="padding: 0; margin-bottom: 25px; background: #fff; border-bottom: none;">
            <!-- dt-toolbar -->
            <div class="col-xs-12 col-sm-12">
              <div class="dataTables_filter">

                <label><!-- input kecamatan -->
                  <span class="input-group-addon text-left" id="label-kecamatn"
                    style="width:120px!important;padding-left: 10px!important;">Kecamatan</span>
                  <select id="kecamatan" name="kecamatan" class="form-control">
                    <option value="000" selected>--SEMUA--</option>
                    <tal:block tal:repeat="kecamatan kecamatans">
                      <option tal:condition="kecamatan.kd_kecamatan != request.session['kd_kecamatan']"
                        tal:attributes="value kecamatan.kd_kecamatan" tal:content="kecamatan.nm_kecamatan">
                      </option>
                      <option tal:condition="kecamatan.kd_kecamatan == request.session['kd_kecamatan']"
                        tal:attributes="value kecamatan.kd_kecamatan" tal:content="kecamatan.nm_kecamatan" selected>
                      </option>
                    </tal:block>
                  </select>

                  <span class="input-group-addon" id="label-kelurahan" style="width: 120px!important;">Kelurahan</span>
                  <select id="kelurahan" name="kelurahan" class="form-control">
                    <option value="000" selected>--SEMUA--</option>
                    <tal:block tal:repeat="kelurahan kelurahans">
                      <option tal:condition="kelurahan.kd_kelurahan  !=  request.session['kd_kelurahan']"
                        tal:attributes="value kelurahan.kd_kelurahan" tal:content="kelurahan.nm_kelurahan">
                      </option>
                      <option tal:condition="kelurahan.kd_kelurahan  ==  request.session['kd_kelurahan']"
                        tal:attributes="value kelurahan.kd_kelurahan" tal:content="kelurahan.nm_kelurahan" selected>
                      </option>
                    </tal:block>
                  </select>
                </label><!-- /input kelurahan -->
              </div>
            </div>
            <!-- <button class="btn btn-success" id="btnprint">Print Format</button> -->
          </div> <!-- dt-toolbar -->


          <!--class="display dataTables" class="ui-state-default"  style="border:solid #EDEDED; "-->


        </div>
        <table id="table1" class="display table table-bordered table-hover table-condensed"
          style="width: 100%; border: #0c0c0c;">
          <thead>
            <tr>
              <th class="center">Kode</th>
              <th class="center">Uraian</th>
              <th class="center">Jumlah</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
          <tfoot>
            <tr>
              <th>&nbsp;</th>
              <th class="right">Total</th>
              <th></th>
            </tr>
          </tfoot>
        </table>
      </div> <!-- /widget-body -->

    </div> <!-- /role-content -->
  </div> <!-- /jarviswidget -->

</div>
<div metal:fill-slot="scripts">
  <link href="${home}/static/v3/js/plugin/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
  <script src="${home}/static/v3/js/plugin/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
  <script src="${home}/static/v3/js/plugin/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
  <script>
    var mID;
    var mThn;
    var oTable;
    var iPos;
    var oTableUrl = "${home}/pbbm/piutang";
    var oTableUri = oTableUrl + "/grid/act";
    $(document).ready(function () {

      $('#awal, #akhir').datepicker({
        format: "dd-mm-yyyy"
      });

      $("#kecamatan, #kelurahan, #akhir, #tahun, #buku").change(function () {
        var kd_kecamatan = $("#kecamatan").val();
        var kd_kelurahan = $("#kelurahan").val();
        var tahun = $("#tahun").val();
        var buku = $("#buku").val();

        window.location = oTableUrl + "?kd_kecamatan=" + kd_kecamatan + "&kd_kelurahan=" + kd_kelurahan + "&tahun=" + tahun + "&buku=" + buku;
      });
    });

    function formatNumber(toFormat) {
      return toFormat.toString().replace(
        /\B(?=(\d{3})+(?!\d))/g, "."
      );
    };
    $(document).ready(function () {
      oTable = $('#table1').DataTable({
        dom: '<"row"<"col-md-6"<"toolbar">Bl><"col-md-6"fr>>tip',
        buttons: [
          'copyHtml5',
          'excelHtml5',
          'csvHtml5',
          'pdfHtml5'
        ],
        processing: true,
        serverSide: true,
        ajax: oTableUri,
        stateSave: true,
        scrollCollapse: true,
        sort: true,
        info: false,
        filter: true,
        autoWidth: false,
        paginate: true,
        paginationType: "full_numbers",

        lengthMenu: [
          [10, 25, 50, 100],
          [10, 25, 50, 100]
        ],
        columndefs: [{
          "targets": [2, 3, 8, 9, 10],
          "render": $.fn.dataTable.render.number('.', ',', 0, ''),
        }],
        columns: [
          { "data": "kode", "width": "200px", "className": "text-center", },
          { "data": "nama", "class": "left" },
          {
            "data": 'jumlah', "width": "150px", "class": "text-right",
            "render": $.fn.dataTable.render.number('.', ',', 0, '')
          },
        ],
        "language": {
          "search": "Cari: ",
          "paginate": {
            "first": "Awal ",
            "last": "Akhir ",
            "previous": "Mundur ",
            "next": "Maju ",
          },
          "lengthMenu": " _MENU_ baris "
        },

        "footerCallback": function (row, data, start, end, display) {
          var api = this.api(), data;

          // Remove the formatting to get integer data for summation
          var intVal = function (i) {
            return typeof i === 'string' ?
              i.replace(/[\$,]/g, '') * 1 :
              typeof i === 'number' ?
                i : 0;
          };

          // Total over all pages
          //total = api
          //    .column( 4 )
          //    .data()
          //    .reduce( function (a, b) {
          //        return intVal(a) + intVal(b);
          //    }, 0 );

          // Total over this page
          pageTotal = api
            .column(2, { page: 'current' })
            .data()
            .reduce(function (a, b) {
              return intVal(a) + intVal(b);
            }, 0);

          // Update footer
          $(api.column(2).footer()).html(
            formatNumber(pageTotal)
          );// +' ( $'+ total +' total)'
        }
      });
      // '<button id="btn_add" class="btn btn btn-success" type="button"><i class="fa fa-fw fa-plus"></i>&nbsp;Tambah</button>',
      // '	<button id="btn_close" class="btn btn btn-warning" type="button"><i class="fa fa-fw fa-undo"></i>&nbsp;Tutup</button>',

      var tb_array = [
        '<div class="btn-group pull-left">',
        '<button id="btn_pdf" class="btn btn btn-primary" type="button"><i class="fa fa-fw fa-file"></i>&nbsp;PDF</button>',
        '<button id="btn_csv" class="btn btn btn-primary" type="button"><i class="fa fa-fw fa-file"></i>&nbsp;CSV</button>',
        '	&nbsp;',
        '</div>',
      ];


      var tb = tb_array.join(' ');
      $("div.toolbar").html(tb);
      $("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;');

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

      $('#btn_pdf').click(function () {
        url = oTableUrl + "/pdf/rpt"
        window.open(url);
      });


      $('#btn_csv').click(function () {
        url = oTableUrl + "/csv/rpt"
        window.open(url);
      });

    });
  </script>
</div>

</html>