public function getItems(Request $req) { if ($req->ajax()) { $res = []; $out = ''; $me = \Me::subgudang(); $tipes = [1 => 'Obat', 2 => 'Barang']; $items = data_item_gudang::detail($req->all())->paginate($req->limit); if ($items->total() > 0) { $no = $items->currentPage() == 1 ? 1 : $items->perPage() * $items->currentPage() - $items->perPage() + 1; foreach ($items as $item) { $info = $item->stok_minimal >= $item->in - $item->out ? '<small class="text-danger semi-bold">(Stok Limit)</small>' : ''; $out .= ' <tr class="item_' . $item->id_barang . ' items"> <td>' . $no . '</td> <td> <a href="javascript:;" title="' . $item->nm_barang . '" data-toggle="tooltip" data-placement="bottom">' . \Format::substr($item->nm_barang, 15) . '</a> <div style="display:none;" class="tbl-opsi"> <small>[ <a href="#" data-toggle="modal" data-target="#review" onclick="review(' . $item->id_barang . ')">Lihat</a> ]</small> </div> </td> <td> ' . $item->kode . '<br /> <small class="text-muted">' . \Format::hari($item->created_at) . ', ' . \Format::indoDate($item->created_at) . '</small> </td> <td title="' . $item->nm_kategori . '">' . \Format::substr($item->nm_kategori, 20) . '</td> <td>' . $tipes[$item->tipe] . '</td> <td class="text-right"> ' . number_format($item->in - $item->out, 0, ',', '.') . ' ' . $item->nm_satuan . ' <div>' . $info . '</div> </td> </tr> '; $no++; } } else { $out = ' <tr> <td colspan="7">Tidak ditemukan</td> </tr> '; } $res['data'] = $out; $res['total'] = $items->total(); $res['pagin'] = $items->render(); return json_encode($res); } }
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 getDetailprq(Request $req) { if ($req->ajax()) { $res = []; $prq = data_prq::find($req->id_prq); $items = data_prq_item::join('data_barang', 'data_barang.id_barang', '=', 'data_prq_item.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_prq_item.id_satuan')->where('data_prq_item.id_prq', $req->id_prq)->select('data_prq_item.*', 'data_barang.nm_barang', 'data_barang.kode', 'data_barang.in', 'data_barang.out', 'ref_satuan.nm_satuan')->get(); $out = '<h5>' . count($items) . ' barang <b>ditemukan</b></h5>'; $out .= ' <table class="table table-striped"> <thead> <tr> <th>Kode</th> <th>Barang</th> <th>Sisa</th> <th class="text-right">REQ QTY</th> </tr> </thead> <tbody> '; foreach ($items as $item) { $out .= ' <tr title="' . $item->nm_barang . '"> <td>' . $item->kode . '</td> <td>' . \Format::substr($item->nm_barang, 10) . '</td> <td>' . number_format($item->in - $item->out, 0, ',', '.') . ' ' . $item->nm_satuan . '</td> <td class="text-right">' . number_format($item->qty, 0, ',', '.') . ' ' . $item->nm_satuan . '</td> </tr> '; } $out .= '</tbody></table>'; $btn = \Auth::user()->permission > 2 && $prq->id_acc < 1 && $prq->status < 4 ? '<button data-loading-text="<i class=\'fa fa-circle-o-notch fa-spin\'></i> Proses..." class="btn btn-primary btn-accs" onclick="accprq(' . $req->id_prq . ');"><i class="fa fa-check"></i> Disetujui</button>' : ''; $res['no_prq'] = $prq->no_prq; $res['content'] = $out; $res['btn'] = $btn; return json_encode($res); } }
public function getAllitems(Request $req) { if ($req->ajax()) { $res = []; $tipes = [1 => 'Obat', 2 => 'Barang']; $fileds = $req->sort; switch ($fileds) { case "barang": $filed = 'data_barang.nm_barang'; break; case "kode": $filed = 'data_barang.kode'; break; case "kategori": $filed = 'ref_kategori.nm_kategori'; break; case "waktu": $filed = 'data_barang.created_at'; break; default: $filed = 'data_barang.nm_barang'; } if ($req->stok === 'true') { $items = data_barang::detailslimit($req->src, $req->kat, $filed, $req->orderby, $req->tipe, $req->kode)->paginate($req->limit); } else { $items = data_barang::details($req->src, $req->kat, $filed, $req->orderby, $req->tipe, $req->kode)->paginate($req->limit); } $out = ''; $total = $items->total(); if ($total > 0) { $no = $items->currentPage() == 1 ? 1 : $items->perPage() * $items->currentPage() - $items->perPage() + 1; foreach ($items as $item) { $link = \Auth::user()->permission > 1 ? '| <a href="' . url('/logistik/update/' . $item->id_barang) . '">Edit</a> ' : ''; $info = $item->stok_minimal >= $item->in - $item->out ? '<small class="text-danger semi-bold">(Stok Limit)</small>' : ''; $btn = \Auth::user()->permission > 2 ? '<button type="button" class="close hapus" onclick="hapus(\'' . $item->nm_barang . '\', ' . $item->id_barang . ');"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>' : ''; $out .= ' <tr class="item_' . $item->id_barang . ' items"> <td>' . $no . '</td> <td> <a href="javascript:;" title="' . $item->nm_barang . '" data-toggle="tooltip" data-placement="bottom">' . \Format::substr($item->nm_barang, 15) . '</a> <div style="display:none;" class="tbl-opsi"> <small>[ <a href="#" data-toggle="modal" data-target="#review" onclick="review(' . $item->id_barang . ')">Lihat</a> | <a href="' . url('/logistik/detail/' . $item->id_barang) . '">Rinci</a> ' . $link . ' ]</small> </div> </td> <td> ' . $item->kode . '<br /> <small class="text-muted">' . \Format::hari($item->created_at) . ', ' . \Format::indoDate($item->created_at) . '</small> </td> <td title="' . $item->nm_kategori . '">' . \Format::substr($item->nm_kategori, 20) . '</td> <td>' . $tipes[$item->tipe] . '</td> <td class="text-right"> ' . number_format($item->in - $item->out, 0, ',', '.') . ' ' . $item->nm_satuan . ' <div>' . $info . '</div> </td> <td class="text-right"> ' . $btn . ' </td> </tr> '; $no++; } } else { $out = ' <tr> <td colspan="7">Tidak ditemukan</td> </tr> '; } $res['data'] = $out; $res['pagin'] = $items->render(); $res['total'] = number_format($total, 0, ',', '.'); return json_encode($res); } }
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_barang.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', 'data_barang.in', 'data_barang.out', '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', 'data_barang.in', 'data_barang.out', '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 . '<br /> <small class="text-muted">' . \Format::hari($spb->tgl_approval) . ', ' . \Format::indoDate2($spb->tgl_approval) . ' ' . \Format::jam($spb->tgl_approval) . '</small> </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>Sisa</th> <th class="text-right">Qty</th> </tr> </thead> <tbody> '; foreach ($items as $item) { $out .= ' <tr> <td>' . $item->kode . '</td> <td>' . \Format::substr($item->nm_barang, 20) . '</td> <td>' . number_format($item->in - $item->out, 0, ',', '.') . ' ' . $item->nm_satuan . '</td> <td class="text-right">' . number_format($item->qty_lg, 0, ',', '.') . ' ' . $item->nm_satuan . '</td> </tr> '; } $out .= ' </tbody> </table> </div> </div>'; $btn = \Auth::user()->permission > 2 && $spb->status < 2 && empty($spb->id_acc) ? '<button data-loading-text="<i class=\'fa fa-circle-o-notch fa-spin\'></i> Proses..." class="btn btn-primary btn-accspb" onclick="acc(' . $req->id . ');"><i class="fa fa-check"></i> Setujui</button>' : ''; $result['kode'] = $spb->no_spb; $result['content'] = $out; $result['button'] = $btn; return json_encode($result); } }
public function getPrq(Request $req) { if ($req->ajax()) { $res = []; $out = ''; $stat = [1 => 'Baru', 2 => 'Proses', 3 => 'Selesai']; $status = $req->status == 0 ? [1, 2] : $req->status; $prq = data_prq_item::forsph($req->all(), $status, $this->ids)->paginate($req->limit); $total = $prq->total(); if ($total > 0) { foreach ($prq as $item) { $st = $item->status > 1 ? 'Proses' : ''; $when = time() > strtotime($item->target) ? '' : \Format::selisih_hari(date('Y-m-d'), $item->target) . ' hari dari sekarang'; $danger = strtotime(date('Y-m-d')) > strtotime($item->target) ? 'text-danger semi-bold' : ''; $add = $item->id_acc > 0 && $item->status < 3 ? '<button class="btn btn-white" onclick="add(' . $item->id_prq_item . ');"><i class="fa fa-plus"></i></button>' : '<div title="Belum Ter Verifikasi"><i class="fa fa-times text-danger"></i></div>'; $out .= ' <tr title="' . $item->nm_barang . '" class="item-prq-' . $item->id_prq_item . '"> <td> ' . \Format::substr($item->nm_barang, 20) . ' <div><small class="text-muted">' . $item->kode . '</small></div> </td> <td class="text-right"> ' . number_format($item->qty, 0, ',', '.') . ' ' . $item->nm_satuan . ' <div class="text-muted"><small>' . $st . '</small></div> </td> <td> ' . $item->no_prq . ' <div><small class="text-muted">' . \Format::indoDate($item->created_at) . '</small></div> </td> <td> <div class="' . $danger . '">' . \Format::indoDate($item->target) . '</div> <div><small class="text-muted">' . $when . '</small></div> </td> <td class="text-center"> ' . $add . ' </td> </tr> '; } } else { $out = '<tr> <td colspan="5">Tidak ditemukan</td> </tr>'; } $res['total'] = $total; $res['pagin'] = $prq->render(); $res['content'] = $out; return json_encode($res); } }