Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
print menggunakan checkbox
mau nannya master kira kira dimana kesalahhannya ko gk bisaa jalan mentog terus form
<!-- REPORT issue -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">REPORT ISSUE</h3>
<ul class="panel-controls">
<!---------tombol prinnya disisi----------------------------------------------------------------------------->
<li><a href="#" id="hapus_record" class="panel-default"><span class=""> <span id="jumlah_pilih">print</span></span></a></li>
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
<li><a href="#" class="panel-refresh"><span class="fa fa-refresh"></span></a></li>
<li><a href="#" class="panel-fullscreen"><span class="glyphicon-fullscreen"></span></a></li>
<li><a href="#" class="panel-remove"><span class="fa fa-times"></span></a></li>
</ul>
</div>
<?php
include '../connection.php';
if(isset($_POST['cari'])){
//menangkap nilai form
$tgl_awal=$_POST['tgl_awal'];
$tgl_akhir=$_POST['tgl_akhir'];
echo '<div class="panel-body">';
if (empty($tgl_awal) and empty($tgl_akhir)) {
$result1 = mysql_query("SELECT * from stock_out");
}else{
$result1 = mysql_query("select * from stock_out where date between '$tgl_awal' and '$tgl_akhir'");
}
echo '<table class="table table-striped table-bordered dono">';
echo '<thead>';
echo '<tr>';
<!---------all checkbox----------------------------------------------------------------------------->
echo '<th width="4%"><input type="checkbox" id="pilih_semua"></th>';
echo '<th width="4%">ID</th>';
echo '<th width="10%">ITEM CODE</th>';
echo '<th width="30%">DESCRIPTIONS</th> ';
echo '<th width="5%">QTY</th> ';
echo '<th width="5%">UNIT</th> ';
echo '<th width="8%">DATE</th> ';
echo '<th width="8%">DOC.NO</th> ';
echo '<th width="8%">RECEIVED</th> ';
echo '<th width="8%">ACTION</th> ';
echo '</tr>';
echo '</thead>';
echo '<tbody id="myTable" >';
?>
<?php
while($row=mysql_fetch_array($result1)){
<!--------- checkbox----------------------------------------------------------------------------->
echo '<tr id="'.$row["id"].'">';
echo '<td><input type="checkbox" class="pgw_checkbox" data-pwg-id="'.$row["id"].'"></td>';
echo "<td>" .$row["id"]. "</td>";
echo "<td>" .$row["item_code"]. "</td>";
echo "<td>" .$row["description"]. "</td>";
echo "<td>" .$row["qty"]. "</td>";
echo "<td>" .$row["unit"]. "</td>";
echo "<td>" .$row["date"]. "</td>";
echo "<td>" .$row["doc_no"]. "</td>";
echo "<td>" .$row["rec"]. "</td>";
$item_code=''.$row["item_code"].'';
echo "<td><a href='return.php?stockno=".$row['item_code']."'class='btn btn-info btn-xs'>DETAIL</a> <a href='return.php?stockno=".$row['item_code']."'class='btn btn-info btn-xs'>RETURN</a></td>";
echo'</tr>';
}
echo'</tbody>';
echo'</table>';
} else{
unset($_POST['cari']);
}
echo'</div>';
echo'</div>';
echo'</div>';
?>
java script
$('document').ready(function() {
// checkbox untuk mencentang semua
jQuery('#pilih_semua').on('click', function(e) {
if($(this).is(':checked',true)) {
$(".pgw_checkbox").prop('checked', true);
}
else {
$(".pgw_checkbox").prop('checked',false);
}
// mengatur semua jumlah checkbox yang dicentang
$("#jumlah_pilih").html($("input.pgw_checkbox:checked").length+"");
});
// mengatur jumlah checkbox tertentu yang dicentang
$(".pgw_checkbox").on('click', function(e) {
$("#jumlah_pilih").html($("input.pgw_checkbox:checked").length+"");
});
// hapus record yang dicentang
jQuery('#hapus_record').on('click', function(e) {
var pegawai = [];
$(".pgw_checkbox:checked").each(function() {
pegawai.push($(this).data('pwg-id'));
});
if(pegawai.length <=0) {
alert("No Data Selected.");
}
else {
var message = "Sure you want remove this data.?";
var checked = confirm(message);
if(checked == true) {
var selected_values = pegawai.join(",");
$.ajax({
type: "POST",
url: "printissue.php",
cache:false,
data: 'pwg_id='+selected_values,
success: function(response) {
}
});
}
}
});
});
prosessss print
<?php
include_once("konek_db.php");
if(isset($_POST['pwg_id'])) {
$pwg_id = trim($_POST['pwg_id']);
$id=$pwg_id;
require('assets/pdf/fpdf.php');
$pdf = new FPDF("L","cm","A4");
$pdf->SetMargins(2,1,1);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','B',11);
$pdf->Image('logo/logo.png',1,1,2,2);
$pdf->SetX(4);
$pdf->MultiCell(19.5,0.5,'SPARE PARTS',0,'L');
$pdf->SetX(4);
$pdf->MultiCell(19.5,0.5,'REPORT ISSUE SPAREPARTS',0,'L');
$pdf->SetFont('Arial','B',10);
$pdf->SetX(4);
$pdf->MultiCell(19.5,0.5,'Priode : '.date("D-d/m/Y"),0,'L');
$pdf->SetX(4);
$pdf->MultiCell(19.5,0.5,'warung kopi',0,'L');
$pdf->Line(1,3.1,28.5,3.1);
$pdf->SetLineWidth(0.1);
$pdf->Line(1,3.2,28.5,3.2);
$pdf->SetLineWidth(0);
$pdf->ln(1);
$pdf->SetFont('Arial','B',14);
$pdf->Cell(25.5,0.7,"Report Data Issue",0,10,'C');
$pdf->ln(1);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(5,0.7,"POST : ".date("D-d/m/Y"),0,0,'C');
$pdf->ln(1);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(1, 0.8, 'NO', 1, 0, 'C');
$pdf->Cell(3, 0.8, 'Item Code', 1, 0, 'C');
$pdf->Cell(15, 0.8, 'Descriptions', 1, 0, 'C');
$pdf->Cell(2, 0.8, 'Qty', 1, 0, 'C');
$pdf->Cell(2.5, 0.8, 'Unit', 1, 0, 'C');
$pdf->Cell(2.5, 0.8, 'Price', 1, 1, 'C');
$pdf->SetFont('Arial','',10);
$no=1;
$query=mysql_query("select * from stock_out WHERE id='$id'");
while($lihat=mysql_fetch_array($query)){
$pdf->Cell(1, 0.8, $no , 1, 0, 'C');
$pdf->Cell(3, 0.8, $lihat['item_code'],1, 0, 'C');
$pdf->Cell(15, 0.8, $lihat['description'], 1, 0,'C');
$pdf->Cell(2, 0.8, $lihat['act'],1, 0, 'C');
$pdf->Cell(2.5, 0.8, $lihat['unit'], 1, 0,'C');
$pdf->Cell(2.5, 0.8, $lihat['price'],1, 1, 'C');
$no++;
}
}
$pdf->Output("Report Issue.pdf","I");
?>
4 Jawaban:
kalo mau buat pdf pake dompdf aja.
<a href='https://github.com/dompdf/dompdf '>https://github.com/dompdf/dompdf </a>
klo ngiprint satu mah dah bisa gan yg dimaksud di atas gimana cara ngeprint menggunakan checkbox misalnyaa ada data 1 2 3 4 5 mau ngeprint hanya data 2 dan 4 dan dicetak dalam satu file maksudnya gtu gan
udh dapat jawabannya gan? kalau udh boleh infokan bagaimana