예제 #1
0
 public function lap_keluar()
 {
     set_time_limit(300);
     $awal = Input::get('awal');
     $akhir = Input::get('akhir');
     if ($awal == '') {
         $awal = date('Y-m-d');
     }
     if ($akhir == '') {
         $akhir = date('Y-m-d');
     }
     $jenis = Input::get('jns');
     $format = Input::get('format');
     switch ($jenis) {
         case "0":
             $barang = DB::table('pkm_alokasi')->join('pkm_alokasidtl', 'pkm_alokasi.nomor', '=', 'pkm_alokasidtl.nomor')->join('pkm_inventori', 'pkm_alokasidtl.id_inventori', '=', 'pkm_inventori.id')->where('pkm_alokasi.tanggal', '>=', $awal)->where('pkm_alokasi.tanggal', '<=', $akhir)->select('pkm_alokasi.*', 'pkm_alokasidtl.harga', 'pkm_alokasidtl.jumlah', 'nama_barang', 'nama_satuan')->orderBy('pkm_alokasi.tanggal', 'asc')->orderBy('id_puskesmas', 'asc')->get();
             $data = 'LAPORAN PENGELUARAN BARANG PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
             $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center;">
                     <th style = "width: 5%;">No</th>
                     <th style = "width: 15%;">Nomor</th>
                     <th style = "width: 10%;">Tanggal</th>
                     <th style = "width: 35%;text-align: left">  Puskesmas</th>
                     <th style = "width: 35%;text-align: left">  Unit</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
             $content = '';
             $jenis = '';
             $n = 1;
             $m = 1;
             for ($i = 0; $i < count($barang); $i++) {
                 if ($jenis != $barang[$i]->nomor) {
                     $content .= '
                     <tr style = "font-weight: bold;text-align: left">
                         <td style = "width: 5%;text-align: center">' . $n . '</td>
                         <td style = "width: 15%;">' . $barang[$i]->nomor . '</td>
                         <td style = "width: 10%;text-align: center">' . $barang[$i]->tanggal . '</td>
                         <td style = "width: 35%;">' . $barang[$i]->id_puskesmas . '-' . $barang[$i]->nama_puskesmas . '</td>
                         <td style = "width: 35%;">' . $barang[$i]->id_unit . '-' . $barang[$i]->nama_unit . '</td>
                     </tr>';
                     $jenis = $barang[$i]->nomor;
                     $m = 1;
                     $n++;
                 }
                 $content .= '
                 <tr style="text-align: center">
                     <td style="width: 5%">&nbsp;</td>
                     <td style="width: 5%">' . sprintf("%03d", $m) . '</td>
                     <td style = "width: 30%;text-align: left">' . $barang[$i]->nama_barang . '</td>
                     <td style = "width: 10%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga) . '</td>
                     <td style = "width: 10%;text-align: right">' . number_format($barang[$i]->jumlah) . '</td>
                     <td style = "width: 10%;text-align: left">' . $barang[$i]->nama_satuan . '</td>
                     <td style = "width: 10%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga * $barang[$i]->jumlah) . '</td>
                 </tr>';
                 $m++;
             }
             break;
         case "id_unit":
             $sup = Input::get('p_unit');
             if ($sup == '') {
                 $op = '<>';
             } else {
                 $op = '=';
             }
             $barang = DB::table('pkm_alokasi')->join('pkm_alokasidtl', 'pkm_alokasi.nomor', '=', 'pkm_alokasidtl.nomor')->join('pkm_inventori', 'pkm_alokasidtl.id_inventori', '=', 'pkm_inventori.id')->where('pkm_alokasi.id_unit', $op, $sup)->where('pkm_alokasi.tanggal', '>=', $awal)->where('pkm_alokasi.tanggal', '<=', $akhir)->select('pkm_alokasi.*', 'pkm_alokasidtl.harga', 'pkm_alokasidtl.jumlah', 'nama_barang', 'nama_satuan')->orderBy('pkm_alokasi.id_unit', 'asc')->orderBy('pkm_alokasi.tanggal', 'asc')->get();
             $data = 'LAPORAN PENGELUARAN PUSKESMAS PER UNIT PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
             $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center">
                     <th style = "width: 3%;">&nbsp;</th>
                     <th style = "width: 5%;">NoID</th>
                     <th style = "width: 10%">Tanggal</th>
                     <th style = "width: 40%;text-align: left">Nama Barang</th>
                     <th style = "width: 11%;text-align: right">Harga</th>
                     <th style = "width: 8%;text-align: right">Qty</th>
                     <th style = "width: 12%;">Satuan</th>
                     <th style = "width: 11%;text-align: right">Total</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
             $content = '';
             $jenis = '';
             $n = 1;
             $sum = array(0, 0, 0);
             $m = 1;
             for ($i = 0; $i < count($barang); $i++) {
                 if ($jenis != $barang[$i]->id_unit) {
                     if ($i != 0) {
                         $content .= '
                             <tr style = "vertical-align: middle;font-weight: bold">
                                 <td style = "width: 3%;">&nbsp;</td>
                                 <td style = "width: 5%;">&nbsp;</td>
                                 <td style = "width: 10%;">&nbsp;</td>
                                 <td style = "width: 40%;text-align: right"> Jumlah  </td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[0]) . '</td>
                                 <td style = "width: 8%;text-align: right">' . number_format($sum[1]) . '</td>
                                 <td style = "width: 12%;">&nbsp;</td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[2]) . '</td>
                             </tr> ';
                     }
                     $sum = array(0, 0, 0);
                     $content .= '
                 <tr style = "vertical-align: middle">
                     <td style = "width: 3%;text-align: center;font-weight: bold"> ' . $n . ' </td>
                     <td colspan = "7" style = "font-weight: bold"> ' . $barang[$i]->nama_unit . ' </td>
                 </tr> ';
                     $jenis = $barang[$i]->id_unit;
                     $m = 1;
                     $n++;
                 }
                 $content .= '
                 <tr style = "vertical-align: middle;text-align: center">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">' . sprintf("%03d", $m) . '</td>
                     <td style = "width: 10%;">' . date('d-m-Y', strtotime($barang[$i]->tanggal)) . '</td>
                     <td style = "width: 40%;text-align: left">' . $barang[$i]->nama_barang . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga) . '</td>
                     <td style = "width: 8%;text-align: right">' . number_format($barang[$i]->jumlah) . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->nama_satuan . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga * $barang[$i]->jumlah) . '</td>
                 </tr>';
                 $m++;
                 $sum = array($sum[0] + $barang[$i]->harga, $sum[1] + $barang[$i]->jumlah, $sum[2] + $barang[$i]->harga * $barang[$i]->jumlah);
             }
             $content .= '
                 <tr style = "vertical-align: middle;font-weight: bold">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">&nbsp;</td>
                     <td style = "width: 10%;">&nbsp;</td>
                     <td style = "width: 40%;text-align: right"> Jumlah  </td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[0]) . '</td>
                     <td style = "width: 8%;text-align: right"> ' . number_format($sum[1]) . '</td>
                     <td style = "width: 12%;">&nbsp;</td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[2]) . '</td>
                 </tr> ';
             break;
         case "id_puskesmas":
             $sup = explode('-', Input::get('p_pkm'));
             if ($sup[0] == '') {
                 $op = '<>';
             } else {
                 $op = '=';
             }
             $barang = DB::table('pkm_alokasi')->join('pkm_alokasidtl', 'pkm_alokasi.nomor', '=', 'pkm_alokasidtl.nomor')->join('pkm_inventori', 'pkm_alokasidtl.id_inventori', '=', 'pkm_inventori.id')->where('pkm_alokasi.id_puskesmas', $op, $sup[0])->where('pkm_alokasi.tanggal', '>=', $awal)->where('pkm_alokasi.tanggal', '<=', $akhir)->select('pkm_alokasi.*', 'pkm_alokasidtl.harga', 'pkm_alokasidtl.jumlah', 'nama_barang', 'nama_satuan')->orderBy('pkm_alokasi.id_puskesmas', 'asc')->orderBy('pkm_alokasi.tanggal', 'asc')->get();
             $data = 'LAPORAN PENGELUARAN PUSKESMAS PER PUSKESMAS PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
             $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center">
                     <th style = "width: 3%;">&nbsp;</th>
                     <th style = "width: 5%;">NoID</th>
                     <th style = "width: 10%">Tanggal</th>
                     <th style = "width: 40%;text-align: left">Nama Barang</th>
                     <th style = "width: 11%;text-align: right">Harga</th>
                     <th style = "width: 8%;text-align: right">Qty</th>
                     <th style = "width: 12%;">Satuan</th>
                     <th style = "width: 11%;text-align: right">Total</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
             $content = '';
             $jenis = '';
             $n = 1;
             $sum = array(0, 0, 0);
             $m = 1;
             for ($i = 0; $i < count($barang); $i++) {
                 if ($jenis != $barang[$i]->id_puskesmas) {
                     if ($i != 0) {
                         $content .= '
                             <tr style = "vertical-align: middle;font-weight: bold">
                                 <td style = "width: 3%;">&nbsp;</td>
                                 <td style = "width: 5%;">&nbsp;</td>
                                 <td style = "width: 10%;">&nbsp;</td>
                                 <td style = "width: 40%;text-align: right"> Jumlah  </td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[0]) . '</td>
                                 <td style = "width: 8%;text-align: right">' . number_format($sum[1]) . '</td>
                                 <td style = "width: 12%;">&nbsp;</td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[2]) . '</td>
                             </tr> ';
                     }
                     $sum = array(0, 0, 0);
                     $content .= '
                 <tr style = "vertical-align: middle">
                     <td style = "width: 3%;text-align: center;font-weight: bold"> ' . $n . ' </td>
                     <td colspan = "7" style = "font-weight: bold"> ' . $barang[$i]->nama_puskesmas . ' </td>
                 </tr> ';
                     $jenis = $barang[$i]->id_puskesmas;
                     $m = 1;
                     $n++;
                 }
                 $content .= '
                 <tr style = "vertical-align: middle;text-align: center">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">' . sprintf("%03d", $m) . '</td>
                     <td style = "width: 10%;">' . date('d-m-Y', strtotime($barang[$i]->tanggal)) . '</td>
                     <td style = "width: 40%;text-align: left">' . $barang[$i]->nama_barang . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga) . '</td>
                     <td style = "width: 8%;text-align: right">' . number_format($barang[$i]->jumlah) . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->nama_satuan . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga * $barang[$i]->jumlah) . '</td>
                 </tr>';
                 $m++;
                 $sum = array($sum[0] + $barang[$i]->harga, $sum[1] + $barang[$i]->jumlah, $sum[2] + $barang[$i]->harga * $barang[$i]->jumlah);
             }
             $content .= '
                 <tr style = "vertical-align: middle;font-weight: bold">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">&nbsp;</td>
                     <td style = "width: 10%;">&nbsp;</td>
                     <td style = "width: 40%;text-align: right"> Jumlah  </td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[0]) . '</td>
                     <td style = "width: 8%;text-align: right"> ' . number_format($sum[1]) . '</td>
                     <td style = "width: 12%;">&nbsp;</td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[2]) . '</td>
                 </tr> ';
             break;
         case "id_barang":
             $sup1 = Input::get('p_jb');
             if ($sup1 == '') {
                 $op = '<>';
             } else {
                 $op = '=';
             }
             $sup = Input::get('p_b');
             if ($sup == '') {
                 $barang = DB::table('pkm_alokasi')->join('pkm_alokasidtl', 'pkm_alokasi.nomor', '=', 'pkm_alokasidtl.nomor')->join('pkm_inventori', 'pkm_alokasidtl.id_inventori', '=', 'pkm_inventori.id')->where('jenis', $op, $sup1)->where('pkm_alokasi.tanggal', '>=', $awal)->where('pkm_alokasi.tanggal', '<=', $akhir)->select('pkm_alokasi.*', 'pkm_alokasidtl.harga', DB::raw('sum(pkm_masukdtl.jumlah) as ttl'), 'id_barang', 'nama_barang', 'nama_satuan')->groupBy('pkm_masuk.id_puskesmas')->orderBy('id_barang', 'asc')->orderBy('pkm_alokasi.tanggal', 'asc')->get();
             } else {
                 $barang = DB::table('pkm_alokasi')->join('pkm_alokasidtl', 'pkm_alokasi.nomor', '=', 'pkm_alokasidtl.nomor')->join('pkm_inventori', 'pkm_alokasidtl.id_inventori', '=', 'pkm_inventori.id')->where('id_barang', $sup)->where('pkm_alokasi.tanggal', '>=', $awal)->where('pkm_alokasi.tanggal', '<=', $akhir)->select('pkm_alokasi.*', 'pkm_alokasidtl.harga', DB::raw('sum(pkm_masukdtl.jumlah) as ttl'), 'id_barang', 'nama_barang', 'nama_satuan')->groupBy('pkm_masuk.id_puskesmas')->orderBy('id_barang', 'asc')->orderBy('pkm_alokasi.tanggal', 'asc')->get();
             }
             $data = 'LAPORAN PENGELUARAN PUSKESMAS PER BARANG PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
             $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center">
                     <th style = "width: 3%;">&nbsp;</th>
                     <th style = "width: 5%;">NoID</th>
                     <th style = "width: 10%">Tanggal</th>
                     <th style = "width: 20%;text-align: left">Puskesmas</th>
                     <th style = "width: 20%;text-align: left">Unit</th>
                     <th style = "width: 11%;text-align: right">Harga</th>
                     <th style = "width: 8%;text-align: right">Qty</th>
                     <th style = "width: 12%;">Satuan</th>
                     <th style = "width: 11%;text-align: right">Total</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
             $content = '';
             $jenis = '';
             $n = 1;
             $sum = array(0, 0, 0);
             $m = 1;
             for ($i = 0; $i < count($barang); $i++) {
                 if ($jenis != $barang[$i]->id_barang) {
                     if ($i != 0) {
                         $content .= '
                             <tr style = "vertical-align: middle;font-weight: bold">
                                 <td style = "width: 3%;">&nbsp;</td>
                                 <td style = "width: 5%;">&nbsp;</td>
                                 <td style = "width: 10%;">&nbsp;</td>
                                 <td style = "width: 20%;text-align: right"> &nbsp;</td>
                                 <td style = "width: 20%;text-align: right"> Jumlah  </td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[0]) . '</td>
                                 <td style = "width: 8%;text-align: right">' . number_format($sum[1]) . '</td>
                                 <td style = "width: 12%;">&nbsp;</td>
                                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[2]) . '</td>
                             </tr> ';
                     }
                     $sum = array(0, 0, 0);
                     $content .= '
                 <tr style = "vertical-align: middle">
                     <td style = "width: 3%;text-align: center;font-weight: bold"> ' . $n . ' </td>
                     <td colspan = "7" style = "font-weight: bold"> ' . $barang[$i]->nama_barang . ' </td>
                 </tr> ';
                     $jenis = $barang[$i]->id_barang;
                     $m = 1;
                     $n++;
                 }
                 $content .= '
                 <tr style = "vertical-align: middle;text-align: center">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">' . sprintf("%03d", $m) . '</td>
                     <td style = "width: 10%;">' . date('d-m-Y', strtotime($barang[$i]->tanggal)) . '</td>
                     <td style = "width: 20%;text-align: left">' . $barang[$i]->nama_puskesmas . '</td>
                     <td style = "width: 20%;text-align: left">' . $barang[$i]->nama_unit . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga) . '</td>
                     <td style = "width: 8%;text-align: right">' . number_format($barang[$i]->ttl) . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->nama_satuan . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->harga * $barang[$i]->ttl) . '</td>
                 </tr>';
                 $m++;
                 $sum = array($sum[0] + $barang[$i]->harga, $sum[1] + $barang[$i]->ttl, $sum[2] + $barang[$i]->harga * $barang[$i]->ttl);
             }
             $content .= '
                 <tr style = "vertical-align: middle;font-weight: bold">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">&nbsp;</td>
                     <td style = "width: 10%;">&nbsp;</td>
                     <td style = "width: 20%;text-align: right"> &nbsp;</td>
                     <td style = "width: 20%;text-align: right"> Jumlah  </td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[0]) . '</td>
                     <td style = "width: 8%;text-align: right"> ' . number_format($sum[1]) . '</td>
                     <td style = "width: 12%;">&nbsp;</td>
                     <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[2]) . '</td>
                 </tr> ';
             break;
         default:
             echo "Your favorite color is neither red, blue, or green!";
     }
     $footer = '</table>';
     switch ($format) {
         case "0":
             $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
             $pdf->SetCreator(PDF_CREATOR);
             $pdf->SetAuthor(PDF_AUTHOR);
             $pdf->SetTitle('Gudang DKK');
             $pdf->SetSubject('Laporan Pengeluaran Barang');
             $pdf->setPrintHeader(false);
             $pdf->setPrintFooter(false);
             $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
             $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
             $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
             $pdf->SetAutoPageBreak(TRUE, 8);
             $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
             // CONTENT-------------------------------------------
             $pdf->SetFont('helvetica', 'B', 10);
             if (Input::get('jns') != '0') {
                 $pdf->AddPage('P', 'A4');
             } else {
                 $pdf->AddPage('P', 'A4');
             }
             $pdf->Write(0, "PEMERINTAH KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0);
             $pdf->SetFont('helvetica', 'B', 12);
             $pdf->Write(0, "DINAS KESEHATAN KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0);
             $pdf->SetFont('helvetica', 'U', 10);
             $pdf->Write(0, "JL. JEMURSARI NO 197 Tlp (031)8439473, 8439372, Fax. (031)8494965", '', 0, 'C', true, 0, false, false, 0);
             $pdf->SetFont('helvetica', 'B', 10);
             $pdf->Write(0, $data, '', 0, 'C', true, 0, false, false, 0);
             $pdf->ln();
             $pdf->SetFont('helvetica', '', 8);
             $pdf->writeHTML($header . $content . $footer, true, false, false, false, '');
             $pdf->Output('lap_keluar_all' . date('d-m-Y') . ' . pdf', 'I');
             break;
         case "1":
             $header1 = '
             <table cellpadding = "10" border="1">
                 <tr style="font-weight: bold;"><td colspan="7" style="text-align: center">PEMERINTAH KOTA SURABAYA</td></tr>
                 <tr style="font-weight: bold;"><td colspan="7" style="text-align: center">DINAS KESEHATAN KOTA SURABAYA</td></tr>
                 <tr style="font-weight: bold;"><td colspan="7" style="text-align: center">JL. JEMURSARI NO 197 Tlp (031)8439473, 8439372, Fax. (031)8494965</td></tr>
                 <tr style="font-weight: bold;"><td colspan="7" style="text-align: center">' . $data . '</td></tr>
                 <tr style="font-weight: bold;"><td colspan="7"></td></tr>
             </table>
             ';
             $tabel = $header1 . $header . $content . $footer;
             //return View::make('excel', compact('tabel'));
             Excel::create('Lapkeluarall_' . date('d-m-Y'), function ($excel) use($tabel) {
                 $excel->sheet('Pengeluaran', function ($sheet) use($tabel) {
                     $sheet->loadView('excel', array('tabel' => $tabel));
                 });
             })->export('xls');
             break;
         default:
             echo "Eror Value!!";
     }
 }
예제 #2
0
 public function report_terima()
 {
     set_time_limit(60);
     $kat = array('cKdSupplier' => 'SUPPLIER', 'cKdSumber' => 'SUMBER ANGGARAN', 'cTahunPengadaan' => 'TAHUN');
     $field = array('cKdSupplier' => 'cSupplier', 'cKdSumber' => 'cSumber', 'cTahunPengadaan' => 'cTahunPengadaan');
     $awal = Input::get('awal');
     $akhir = Input::get('akhir');
     $val = array();
     if ($awal == '') {
         $awal = date('Y-m-d');
     }
     if ($akhir == '') {
         $akhir = date('Y-m-d');
     }
     if (Input::get('p_sup') != '0') {
         $j = explode('-', Input::get('p_sup'));
         $tmp = array('cKdSupplier' => $j[0]);
         $val += $tmp;
         //array_push($val, $tmp);
     }
     if (Input::get('p_sumber') != '0') {
         $j = explode('-', Input::get('p_sumber'));
         $tmp = array('cKdSumber' => $j[0]);
         $val += $tmp;
         //array_push($val, $tmp);
     }
     if (Input::get('p_tahun') != '') {
         $tmp = array('cTahunPengadaan' => Input::get('p_tahun'));
         $val += $tmp;
         //array_push($val, $tmp);
     }
     if (Input::get('jns') != '0') {
         $barang = DB::table('tbterima')->join('tbterimadtl', 'tbterima.cNomor', '=', 'tbterimadtl.cNomor')->where($val)->where($field[Input::get('jns')], '<>', '')->where('dTanggal', '>=', $awal)->where('dTanggal', '<=', $akhir)->orderBy(Input::get('jns'), 'asc')->orderBy('dTanggal', 'asc')->get();
         $data = 'LAPORAN DATA' . count($barang) . ' PENGELUARAN BARANG PER ' . $kat[Input::get('jns')] . ' PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
         $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center">
                     <th style = "width: 3%;border-bottom: solid">&nbsp;</th>
                     <th style = "width: 5%;border-bottom: solid">NoID</th>
                     <th style = "width: 10%;border-bottom: solid">Tanggal</th>
                     <th style = "width: 40%;border-bottom: solid;text-align: left">Nama Barang</th>
                     <th style = "width: 11%;border-bottom: solid;text-align: right">Harga</th>
                     <th style = "width: 8%;border-bottom: solid;text-align: right">Qty</th>
                     <th style = "width: 12%;border-bottom: solid">Satuan</th>
                     <th style = "width: 11%;border-bottom: solid;text-align: right">Total</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
     } else {
         $barang = DB::table('tbterima')->join('tbterimadtl', 'tbterima.cNomor', '=', 'tbterimadtl.cNomor')->where($val)->where('dTanggal', '>=', $awal)->where('dTanggal', '<=', $akhir)->orderBy('dTanggal', 'asc')->orderBy('tbterima.cNomor', 'asc')->get();
         $data = 'LAPORAN PENERIMAAN BARANG PERIODE ' . date('d-m-Y', strtotime($awal)) . ' s / d ' . date('d-m-Y', strtotime($akhir));
         $header = '
             <table cellpadding = "10">
             <thead>
                 <tr style = "font-weight: bold;text-align: center;">
                     <th rowspan="2" style = "width: 3%;border-bottom: solid;border-top: solid;border-right: solid">No</th>
                     <th rowspan="2" style = "width: 8%;border-bottom: solid;border-top: solid;border-left: solid;border-right: solid">Nomor</th>
                     <th rowspan="2" style = "width: 6%;border-bottom: solid;border-top: solid;border-left: solid;border-right: solid">Tanggal</th>
                     <th rowspan="2" style = "width: 22%;border-bottom: solid;border-top: solid;border-left: solid;border-right: solid;text-align: left">  Supplier</th>
                     <th colspan="2" style = "width: 18%;border-top: solid;border-left: solid;border-right: solid">Bukti Penerimaan</th>
                     <th colspan="3" style = "width: 26%;border-top: solid;border-left: solid;border-right: solid">Dasar Penerimaan</th>
                     <th colspan="2" style = "width: 18%;border-top: solid;border-left: solid;">Berita Acara</th>
                 </tr>
                 <tr style = "font-weight: bold;text-align: center">
                     <th style = "width: 12%;border-bottom: solid;border-left: solid;">Nomor</th>
                     <th style = "width: 6%;border-bottom: solid;border-right: solid">Tanggal</th>
                     <th style = "width: 8%;border-bottom: solid;border-left: solid">Jenis</th>
                     <th style = "width: 12%;border-bottom: solid;">Nomor</th>
                     <th style = "width: 6%;border-bottom: solid;border-right: solid">Tanggal</th>
                     <th style = "width: 12%;border-bottom: solid;border-left: solid">Nomor</th>
                     <th style = "width: 6%;border-bottom: solid">Tanggal</th>
                 </tr>
                 <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
             </thead>
             ';
     }
     $content = '';
     $jenis = '';
     $n = 1;
     $sum = array(0, 0, 0);
     $m = 1;
     for ($i = 0; $i < count($barang); $i++) {
         if (Input::get('jns') != '0') {
             if ($jenis != $barang[$i]->{$field}[Input::get('jns')]) {
                 if ($i != 0) {
                     $content .= '
                     <tr style = "vertical-align: middle;font-weight: bold">
                         <td style = "width: 3%;">&nbsp;</td>
                         <td style = "width: 5%;">&nbsp;</td>
                         <td style = "width: 10%;">&nbsp;</td>
                         <td style = "width: 40%;text-align: right"> Jumlah  </td>
                         <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[0]) . '</td>
                         <td style = "width: 8%;text-align: right">' . number_format($sum[1]) . '</td>
                         <td style = "width: 12%;">&nbsp;</td>
                         <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($sum[2]) . '</td>
                     </tr> ';
                 }
                 $sum = array(0, 0, 0);
                 $content .= '
                 <tr style = "vertical-align: middle">
                     <td style = "width: 3%;text-align: center;font-weight: bold"> ' . $n . ' </td>
                     <td colspan = "7" style = "font-weight: bold"> ' . $barang[$i]->{$field}[Input::get('jns')] . ' </td>
                 </tr> ';
                 $jenis = $barang[$i]->{$field}[Input::get('jns')];
                 $m = 1;
                 $n++;
             }
             $content .= '
                 <tr style = "vertical-align: middle;text-align: center">
                     <td style = "width: 3%;">&nbsp;</td>
                     <td style = "width: 5%;">' . sprintf("%03d", $m) . '</td>
                     <td style = "width: 10%;">' . date('d-m-Y', strtotime($barang[$i]->dTanggal)) . '</td>
                     <td style = "width: 40%;text-align: left">' . $barang[$i]->cNama . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->nHarga) . '</td>
                     <td style = "width: 8%;text-align: right">' . number_format($barang[$i]->nQty) . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->cSatuan . '</td>
                     <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->nSTotal) . '</td>
                 </tr>';
             $m++;
             $sum = array($sum[0] + $barang[$i]->nHarga, $sum[1] + $barang[$i]->nQty, $sum[2] + $barang[$i]->nSTotal);
         } else {
             if ($jenis != $barang[$i]->cNomor) {
                 $sum = 0;
                 $content .= '
                  <tr style = "font-weight: bold;text-align: center">
                     <td style = "width: 3%;">' . $n . '</td>
                     <td style = "width: 8%;">' . $barang[$i]->cNomor . '</td>
                     <td style = "width: 6%;">' . date('d-m-Y', strtotime($barang[$i]->dTanggal)) . '</td>
                     <td style = "width: 22%;text-align: left">' . $barang[$i]->cSupplier . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->cNoBukti . '</td>
                     <td style = "width: 6%;">' . date('d-m-Y', strtotime($barang[$i]->dTglBukti)) . '</td>
                     <td style = "width: 8%;">' . $barang[$i]->cJnsSurat . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->cNoSurat . '</td>
                     <td style = "width: 6%;">' . date('d-m-Y', strtotime($barang[$i]->dTglSurat)) . '</td>
                     <td style = "width: 12%;">' . $barang[$i]->cNoAcara . '</td>
                     <td style = "width: 6%;">' . date('d-m-Y', strtotime($barang[$i]->dTglAcara)) . '</td>
                 </tr>';
                 $jenis = $barang[$i]->cNomor;
                 $m = 1;
                 $n++;
             }
             $content .= '
             <tr style="text-align: center">
                 <td style="width: 3%">&nbsp;</td>
                 <td style="width: 5%">' . sprintf("%03d", $m) . '</td>
                 <td style = "width: 30%;text-align: left">' . $barang[$i]->cNama . '</td>
                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->nHarga) . '</td>
                 <td style = "width: 8%;text-align: right">' . number_format($barang[$i]->nQty) . '</td>
                 <td style = "width: 10%;text-align: left">' . $barang[$i]->cSatuan . '</td>
                 <td style = "width: 11%;text-align: right">' . Terbilang::format_no_sign($barang[$i]->nSTotal) . '</td>
             </tr>';
             $m++;
         }
     }
     if (Input::get('jns') != '0') {
         $content .= '
         <tr style = "vertical-align: middle;font-weight: bold">
             <td style = "width: 3%;">&nbsp;</td>
             <td style = "width: 5%;">&nbsp;</td>
             <td style = "width: 10%;">&nbsp;</td>
             <td style = "width: 40%;text-align: right"> Jumlah  </td>
             <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[0]) . '</td>
             <td style = "width: 8%;text-align: right"> ' . number_format($sum[1]) . '</td>
             <td style = "width: 12%;">&nbsp;</td>
             <td style = "width: 11%;text-align: right"> ' . Terbilang::format_no_sign($sum[2]) . '</td>
         </tr> ';
     }
     $footer = "</table>";
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle('Gudang DKK');
     $pdf->SetSubject('Laporan Stok Barang');
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetAutoPageBreak(TRUE, 8);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // CONTENT-------------------------------------------
     $pdf->SetFont('helvetica', 'B', 10);
     if (Input::get('jns') != '0') {
         $pdf->AddPage('P', 'A4');
     } else {
         $pdf->AddPage('L', 'A4');
     }
     $pdf->Write(0, "PEMERINTAH KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0);
     $pdf->SetFont('helvetica', 'B', 12);
     $pdf->Write(0, "DINAS KESEHATAN KOTA SURABAYA", '', 0, 'C', true, 0, false, false, 0);
     $pdf->SetFont('helvetica', 'U', 10);
     $pdf->Write(0, "JL. JEMURSARI NO 197 Tlp (031)8439473, 8439372, Fax. (031)8494965", '', 0, 'C', true, 0, false, false, 0);
     $pdf->SetFont('helvetica', 'B', 10);
     $pdf->Write(0, $data, '', 0, 'C', true, 0, false, false, 0);
     $pdf->ln();
     $pdf->SetFont('helvetica', '', 8);
     $pdf->writeHTML($header . $content . $footer, true, false, false, false, '');
     $pdf->Output('laporan_penerimaan' . date('d-m-Y') . ' . pdf', 'I');
     //return '';
 }