Beispiel #1
0
 public function postDetailspb(Request $req)
 {
     if ($req->ajax()) {
         $result = [];
         $out = '';
         $spb = data_spb::find($req->id);
         if ($spb->status > 2) {
             $items = data_spb_item::join('data_barang', 'data_barang.id_barang', '=', 'data_spb_item.id_item')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_spb_item.id_satuan')->where('data_spb_item.id_spb', $req->id)->whereIn('data_spb_item.status', [1, 2])->select('data_spb_item.*', 'data_barang.nm_barang', 'data_barang.kode', 'ref_satuan.nm_satuan')->get();
         } else {
             $items = data_spb_item::join('data_barang', 'data_barang.id_barang', '=', 'data_spb_item.id_item')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_spb_item.id_satuan')->where('data_spb_item.id_spb', $req->id)->where('data_spb_item.status', 1)->select('data_spb_item.*', 'data_barang.nm_barang', 'data_barang.kode', 'ref_satuan.nm_satuan')->get();
         }
         if ($spb->id_acc > 0) {
             $me = data_karyawan::find($spb->id_acc);
             $out .= '<div class="grid simple">
                         <div class="grid-title no-border"></div>
                         <div class="grid-body no-border">
                             <b>Disetujui Oleh : </b> ' . $me->nm_depan . ' ' . $me->nm_belakang . '
                         </div>
                     </div>
             ';
         } else {
             $out .= '<div class="grid simple">
                         <div class="grid-title no-border"></div>
                         <div class="grid-body no-border">
                             <i class="fa fa-warning"></i> Permintaan belum disetujui Kepala
                         </div>
                     </div>
             ';
         }
         $out .= '<div class="grid simple">
                     <div class="grid-title no-border">
                     <h4>' . count($items) . ' barang <strong>ditemukan</strong></4><br />
                     <small>Deadline : ' . \Format::indoDate($spb->deadline) . '</small>
                     </div>
                     <div class="grid-body no-border">
                         <table class="table table-striped">
                             <thead>
                             <tr>
                                 <th>Kode</th>
                                 <th>Barang</th>
                                 <th class="text-right">Req Qty</th>
                             </tr>
                             </thead>
                             <tbody>
             ';
         foreach ($items as $item) {
             $out .= '
                 <tr>
                     <td>' . $item->kode . '</td>
                     <td>' . \Format::substr($item->nm_barang, 20) . '</td>
                     <td class="text-right">' . number_format($item->qty_lg, 0, ',', '.') . ' ' . $item->nm_satuan . '</td>
                 </tr>
             ';
         }
         $out .= '
                         </tbody>
                     </table>
                 </div>
             </div>';
         $btn = $spb->id_acc > 0 && \Auth::user()->permission > 1 && in_array($spb->status, [1, 2]) ? '<a href="' . url('/skb/process/' . $req->id) . '" class="btn btn-primary">Proses</a>' : '';
         $result['kode'] = $spb->no_spb;
         $result['content'] = $out;
         $result['button'] = $btn;
         return json_encode($result);
     }
 }
 public function getPrintspb($id)
 {
     $find = data_spb::join('data_karyawan', 'data_karyawan.id_karyawan', '=', 'data_spb.id_pemohon')->join('data_departemen', 'data_departemen.id_departemen', '=', 'data_spb.id_departemen')->where('data_spb.id_spb', $id)->where('data_spb.id_departemen', \Me::data()->id_departemen)->select('data_spb.*', 'data_karyawan.nm_depan', 'data_karyawan.nm_belakang', 'data_departemen.nm_departemen');
     if ($find->count() == 0) {
         return redirect('/pmbumum');
     }
     $spb = $find->first();
     $items = data_spb_item::join('data_barang', 'data_barang.id_barang', '=', 'data_spb_item.id_item')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_spb_item.id_spb', $id)->select('data_spb_item.*', 'data_barang.id_barang', 'data_barang.in', 'data_barang.out', 'data_barang.nm_barang', 'data_barang.kode', 'ref_satuan.nm_satuan')->get();
     return view('Print.Pengadaan.SPB', ['spb' => $spb, 'items' => $items]);
 }