예제 #1
0
 public function getTerkait(Request $req)
 {
     if ($req->ajax()) {
         $res = [];
         $skb = data_skb::whereId_spb($req->id);
         $out = '';
         if ($skb->count() > 0) {
             foreach ($skb->get() as $item) {
                 $out .= '<tr>
                     <td><a href="' . url('/skb/view/' . $item->id_skb) . '">' . $item->no_skb . '</a></td>
                 </tr>';
             }
         } else {
             $out = '
                 <tr>
                     <td>Tidak ditemukan</td>
                 </tr>
             ';
         }
         $res['total'] = $skb->count();
         $res['content'] = $out;
         return json_encode($res);
     }
 }
 public function getPrintexcel(Request $req)
 {
     $kd_barang = data_barang::where('id_barang', $req->barang)->select('kode')->first();
     $gudang = ref_gudang::find($req->gudang);
     \Excel::create('Kartu_Stok_' . str_replace('-', '_', str_slug($gudang->nm_gudang)) . '_' . $kd_barang->kode . '_' . date('d_F_Y'), function ($excel) use($req) {
         if ($req->barang == 0) {
             return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Item tidak ditemukan!']);
         }
         $items = [];
         // Data Barang
         $barang = data_item_gudang::join('data_barang', 'data_barang.id_barang', '=', 'data_item_gudang.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_item_gudang.status', 1)->where('data_item_gudang.id_gudang', $req->gudang)->where('data_item_gudang.id_barang', $req->barang)->where('data_barang.tipe', $req->tipe)->select('data_barang.nm_barang', 'data_barang.kode', 'data_item_gudang.in', 'data_item_gudang.out', 'ref_satuan.nm_satuan')->first();
         if ($barang == null) {
             return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Item tidak ditemukan!']);
         }
         //Sisa per priode
         $sisapriode = data_log_barang::sisapriode($req->all())->get();
         //dd($sisapriode);
         $sisa = 0;
         foreach ($sisapriode as $sp) {
             if ($sp->kondisi == 1) {
                 $sisa += $sp->qty;
             } else {
                 $sisa -= $sp->qty;
             }
         }
         $lastsisa = $sisa;
         // Log stok
         $logs = data_log_barang::kartostokbyitem($req->all())->get();
         foreach ($logs as $item) {
             if ($item->tipe == 1) {
                 $parent = data_skb::find($item->id_parent);
             } else {
                 if ($item->tipe == 2) {
                     //$parent = data_spbm::find($item->id_parent);
                     $parent = data_spbm::join('data_spbm_item', 'data_spbm_item.id_spbm', '=', 'data_spbm.id_spbm')->where('data_spbm_item.id_barang', $req->barang)->where('data_spbm.id_spbm', $item->id_parent)->select('data_spbm.*', 'data_spbm_item.tgl_exp')->first();
                 } else {
                     if ($item->tipe == 3) {
                         $parent = data_penyesuaian_stok::find($item->id_parent);
                     } else {
                         if ($item->tipe == 4) {
                             $parent = data_retur::find($item->id_parent);
                         } else {
                             if ($item->tipe == 5) {
                                 $parent = data_retur::find($item->id_parent);
                             }
                         }
                     }
                 }
             }
             if ($item->kondisi == 1) {
                 $lastsisa += $item->qty;
             } else {
                 $lastsisa -= $item->qty;
             }
             $items[] = ['tipe' => $item->tipe, 'parent' => $parent, 'kondisi' => $item->kondisi, 'qty' => $item->qty, 'sisa' => $lastsisa, 'oleh' => $item->nm_depan . ' ' . $item->nm_belakang];
         }
         $jenis = [1 => 'SKB', 2 => 'Good Receive', 3 => 'Penyesuaian', 4 => 'Retur Gudang', 5 => 'Retur Pembelian'];
         // Parameters
         $params = '';
         foreach ($req->all() as $par => $val) {
             if ($par != '_token') {
                 $params .= $par . '=' . $val . '&';
             }
         }
         $param = rtrim($params, '&');
         $gudang = ref_gudang::find($req->gudang);
         $data = ['barang' => $barang, 'items' => $items, 'req' => $req, 'jenis' => $jenis, 'param' => $params, 'gudang' => $gudang];
         $excel->sheet('New sheet', function ($sheet) use($data) {
             $sheet->loadView('Print.Pengadaan.SubGudang.Excel', $data);
         });
     })->export('xlsx');
 }
 public function getCreate($id)
 {
     $skb = data_skb::find($id);
     if ($skb == null) {
         return redirect('/returgudang')->withNotif(['label' => 'danger', 'err' => 'Tidak ditemukan!']);
     }
     if ($skb->tipe > 1) {
         return redirect('/returgudang')->withNotif(['label' => 'danger', 'err' => 'Tidak ditemukan!']);
     }
     $items = data_skb_item::retur($id)->get();
     $me = \Me::subgudang();
     return view('Pengadaan.ReturGudang.Create', ['skb' => $skb, 'items' => $items, 'me' => $me]);
 }
예제 #4
0
 public function getListskb(Request $req)
 {
     if ($req->ajax()) {
         $res = [];
         $items = data_skb::whereId_spb($req->id);
         $total = $items->count();
         $res['total'] = $total;
         $out = '<table class="table table-hover table-bordered">';
         if ($total > 0) {
             foreach ($items->get() as $item) {
                 $out .= '<tr>
                     <td><a href="' . url('/skb/print/' . $item->id_skb) . '" target="_blank">' . $item->no_skb . '</a>
                         <span class="pull-right">' . \Format::indoDate($item->created_at) . '</span>
                     </td>
                 </tr>';
             }
         } else {
             $out .= '
                 <tr>
                     <td>Tidak ditemukan</td>
                 </tr>
             ';
         }
         $out .= '<table>';
     }
     $res['content'] = $out;
     return json_encode($res);
 }
 public function getPrintpdf(Request $req)
 {
     $day = \Format::selisih_hari($req->dari, $req->sampai);
     if ($day > 31) {
         return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Pencarian tidak boleh lebih dari 30 hari!']);
     }
     if ($req->barang == 0) {
         return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Item tidak ditemukan!']);
     }
     $items = [];
     // Data Barang
     $barang = data_barang::join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('id_barang', $req->barang)->select('data_barang.*', 'ref_satuan.nm_satuan')->first();
     //Sisa per priode
     $sisapriode = data_log_barang::sisapriode($req->all())->get();
     //dd($sisapriode);
     $sisa = 0;
     foreach ($sisapriode as $sp) {
         if ($sp->kondisi == 1) {
             $sisa += $sp->qty;
         } else {
             $sisa -= $sp->qty;
         }
     }
     $lastsisa = $barang->stok_awal + $sisa;
     $aftersisa = $lastsisa;
     // Log stok
     $logs = data_log_barang::kartostokbyitem($req->all())->get();
     foreach ($logs as $item) {
         if ($item->tipe == 1) {
             $parent = data_skb::find($item->id_parent);
         } else {
             if ($item->tipe == 2) {
                 $parent = data_spbm::find($item->id_parent);
             } else {
                 if ($item->tipe == 3) {
                     $parent = data_penyesuaian_stok::find($item->id_parent);
                 } else {
                     if ($item->tipe == 4) {
                         $parent = data_retur::find($item->id_parent);
                     } else {
                         if ($item->tipe == 5) {
                             $parent = data_retur::find($item->id_parent);
                         }
                     }
                 }
             }
         }
         if ($item->kondisi == 1) {
             $lastsisa += $item->qty;
         } else {
             $lastsisa -= $item->qty;
         }
         $items[] = ['tipe' => $item->tipe, 'parent' => $parent, 'kondisi' => $item->kondisi, 'qty' => $item->qty, 'sisa' => $lastsisa, 'oleh' => $item->nm_depan . ' ' . $item->nm_belakang];
     }
     $jenis = [1 => 'SKB', 2 => 'Good Receive', 3 => 'Penyesuaian', 4 => 'Retur Gudang', 5 => 'Retur Pembelian'];
     $r = array('barang' => $barang, 'items' => $items, 'req' => $req, 'lastsisa' => $aftersisa, 'jenis' => $jenis);
     $pdf = PDF::loadView('Print.Pengadaan.KartuStok.pdfKS', $r);
     return $pdf->stream();
     //$file = 'KartuStok-'.date('Y-m-d').'.pdf';
     //return $pdf->download($file);
 }
예제 #6
0
 public function getPrintskb(Request $req)
 {
     $items = data_skb::with(['rekap' => function ($query) {
         $query->join('data_barang', 'data_barang.id_barang', '=', 'data_skb_item.id_item');
     }])->rekapskb($req->all())->get();
     return view('Print.Transaksi.SKB', ['items' => $items, 'req' => $req]);
 }