Untitled

mail@pastecode.io avatar
unknown
php_laravel_blade
4 years ago
11 kB
4
Indexable
Never
@include('admin/header')
<!-- Begin Page Content -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    // $("#printtext").click(function() {
    //   $("#print").printThis({
    //     debug: true
    //   });
    // });



    function print(id) {
        var divContents = document.getElementById("area[" + id + "]").innerHTML;
        //document.getElementById('area['+id+']').setAttribute('class', 'card-body d-none');
        var a = window.open('', '', 'height=500, width=500');
        a.document.write('<html><head><title></title>');
        a.document.write(`<link href="{{ asset('css/sb-admin-2.min.css') }}" rel="stylesheet" media="all" >`);
        a.document.write(`<link href="{{ asset('css/kartu.css') }}" rel="stylesheet" media="all">`);
        a.document.write(`<link href="{{ asset('css/sb-admin-2.css') }}" rel="stylesheet" media="all">`);
        a.document.write(`<link href="{{ asset('css/style.css') }}" rel="stylesheet" media="all">`);
        a.document.write('</head><body >');
        a.document.write(divContents);
        // a.document.write(`<div class='card-width'>dd</div>`); 
        a.document.write('</body></html>');
        a.document.close();
        a.print();
        return true;
    }

    // function print(id){
    //   var doc = new jsPDF();
    //   let mywindow = window.open('', 'PRINT', 'height=650,width=900,top=100,left=150');
    //   mywindow.document.write(`<link href="{{ asset('css/sb-admin-2.min.css') }}" rel="stylesheet">`);
    //   mywindow.document.write(`<link href="{{ asset('css/kartu.css') }}" rel="stylesheet">`);
    //   mywindow.document.write(document.getElementById('area['+id+']').innerHTML);
    //   mywindow.document.write('</body></html>');
    //   mywindow.document.close(); // necessary for IE >= 10
    //   mywindow.focus(); // necessary for IE >= 10*/
    //   mywindow.print();
    //   return true;
    // };

    $("#coba_print").live("click", function() {
        var divContents = $("#area[708]").html();
        var printWindow = window.open('', '', 'height=400,width=800');
        printWindow.document.write('<html><head><title>DIV Contents</title>');
        printWindow.document.write('</head><body >');
        printWindow.document.write(divContents);
        printWindow.document.write('</body></html>');
        printWindow.document.close();
        printWindow.print();
    });

    function printPDF() {
        var printDoc = new jsPDF();
        printDoc.fromHTML($('#area[708]').get(0), 10, 10, {
            'width': 180
        });
        printDoc.autoPrint();
        printDoc.output(
        "dataurlnewwindow"); // this opens a new popup,  after this the PDF opens the print window view but there are browser inconsistencies with how this is handled
    }

</script>


<script>
    $(document).ready(function() {
        $("#bulk-print").click(function() {
            var id = [];
            $.each($("input[name='cek']:checked"), function() {
                id.push($(this).val());
            });
            //alert(id.length);
            var a = window.open('', '', 'height=500, width=500');
            a.document.write(`<link href="{{ asset('css/sb-admin-2.min.css') }}" rel="stylesheet">`);
            a.document.write(`<link href="{{ asset('css/kartu.css') }}" rel="stylesheet">`);
            for (let index = 0; index < id.length; index++) {
                var divContents = document.getElementById("area[" + id[index] + "]").innerHTML;
                console.log(document.getElementById("area[" + id[index] + "]").innerHTML);
                document.getElementById('area[' + id[index] + ']').setAttribute('class',
                    'card-body d-none');
                a.document.write(divContents);
            }
            a.document.close();
            a.print();
        });
    });

</script>

@foreach ($anggota as $item)
    <div class="card-body print d-none" id="area[{{ $item->id }}]">
        <div class="container">
            <div class='card-width' style='position: relative;'>
                @foreach ($cms as $cmss)
                    <div style='position: absolute;left:50%;top:50%;transform: translate(-50%, -50%);opacity: 0.5'>
                        <img src='{{ asset('data_file/' . $cmss->bg) }}' style='width:180px;' />
                    </div>
                @endforeach

                <div class="row row-cols-2 p-4">
                    <div class="col-4">
                        <center>
                            <img src="{{ asset('data_file/' . $item->file) }}" height="151px" width="113px"
                                alt="foto" />
                        </center>
                    </div>
                    <div class="col-8 text-center">
                        @foreach ($cms as $items)
                            <center>
                                <img src="{{asset('data_file/'.$items->file) }}"   width="53px" alt="logo" />
      </center>
        @endforeach
        
        <p style="font-size: 13px; margin-top: 13px"><b><span>TENTARA NASIONAL INDONESIA</span><br />
        <span>KARTU SENJATA PRAJURIT</span><br />
	<span>DENZIPUR 3/ATD</span></p><br /></b>
      </div>
      <div class="col-4"></div>
      <div class="col-8"><hr class="hr" /></div>
      <div class="col-4 text-center">
        <center><img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(110)->generate($item->nrp)) !!} " width="60px">
      </center></div>
      <div class="col-8">
        <span style="font-size: 15px">{{$item->nama}}</span><br />
        <span style="font-size: 15px">{{$item->pangkat}}</span><br />
        <span style="font-size: 15px">NRP {{$item->nrp }}</span><br />
       	<span style="font-size: 15px">{{$item->satuan}}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endforeach


<div class="container-fluid">
    <!-- Page Heading -->
    <div class="d-sm-flex align-items-center justify-content mb-4">
        <h1 class="h3 mb-0 text-gray-800">Data Anggota</h1>
        <a href="{{ route('admin/tambah-anggota') }}"
            class="mr-3 ml-3 d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
                class="fas fa-plus fa-sm text-white-50"></i> Tambah Data</a>
        <a href="{{ route('admin/anggota-export') }}" target="_blank"
            class="d-none d-sm-inline-block btn btn-sm btn-success shadow-sm"><i
                class="fas fa-plus fa-sm text-white-50"></i> Export Data</a>
    </div>
    <!-- Content Row -->
    <div class="row">
        <!-- Area Chart -->
        <div class="col-xl-12 col-lg-7">
            <div class="card shadow mb-4">
                <!-- Card Header - Dropdown -->
                <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
                    <h6 class="m-0 font-weight-bold text-primary">Data Anggota</h6>
                </div>
                <!-- Card Body -->
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                            <div class="dropdown mb-4 ">
                                <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
                                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    Aksi
                                </button>
                                <div class="dropdown-menu animated--fade-in" aria-labelledby="dropdownMenuButton">
                                    <a class="dropdown-item" href="#" id="bulk-print">Print</a>
                                </div>
                            </div>
                            <thead>
                                <tr>
                                    <th></th>
                                    <th>Nama</th>
                                    <th>NRP</th>
                                    <th>Pangkat</th>
                                    <th>Alamat</th>
                                    <th>Foto</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($anggota as $item)
                                    <tr>
                                        <td><input type="checkbox" name="cek" id="cek" data-id="{{ $item->id }}"
                                                value="{{ $item->id }}"></td>
                                        <td>{{ $item->nama }}</td>
                                        <td>{{ $item->nrp }}</td>
                                        <td>{{ $item->pangkat }}</td>
                                        <td>{{ $item->alamat }}</td>
                                        <td><img src="/data_file/{{ $item->file }}" width="40"></td>
                                        <td>
                                            <a href="#" onclick="print({{ $item->id }})"
                                                class="btn btn-success btn-circle btn-sm">
                                                <i class="fa fa-print"></i>
                                            </a>
                                            <a href="/admin/edit-anggota/{{ $item->id }}"
                                                class="btn btn-warning btn-circle btn-sm">
                                                <i class="fa fa-edit"></i>
                                            </a>
                                            <a onclick="return confirm('Yakin Menghapus Data?')"
                                                href="/admin/anggota/{{ $item->id }}"
                                                class="delete-confirm btn btn-danger btn-circle btn-sm">
                                                <i class="fa fa-trash"></i>
                                            </a>

                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@include('admin/footer');