コード例 #1
0
ファイル: PRQController.php プロジェクト: pedangkayu/rsos-git
    public function getGetallprq(Request $req)
    {
        if ($req->ajax()) {
            $res = [];
            $out = '';
            $items = data_prq::listprq($req->all(), $req->status)->paginate($req->limit);
            $no = $items->currentPage() == 1 ? 1 : $items->perPage() * $items->currentPage() - $items->perPage() + 1;
            $status = [1 => 'Baru', 2 => 'Proses', 3 => 'Selesai', 4 => 'Hapus'];
            if ($items->total() > 0) {
                foreach ($items as $item) {
                    $class = strtotime($item->target) > strtotime(date('Y-m-d')) ? '' : 'class=text-danger';
                    $selisih = strtotime($item->target) > strtotime(date('Y-m-d')) ? '<small class="text-muted">' . \Format::selisih_hari($item->target, date('Y-m-d')) . 'hari dari sekarang</small>' : '';
                    $tipe = $item->tipe == 1 ? 'Obat' : 'Barang';
                    $tanda = empty($item->id_acc) ? '<i class="fa fa-times text-muted pull-right" title="Belum terverifikasi"></i>' : '<i title="Terverifikasi" class="fa fa-check-circle text-success pull-right"></i>';
                    $edit = $item->status < 2 ? '| <a href="' . url('/prq/edit/' . $item->id_prq) . '">Edit</a>' : '';
                    $del = \Auth::user()->permission > 1 && $item->status < 2 ? '| <a href="javascript:;" onclick="hapusprq(' . $item->id_prq . ');" class="text-danger">Hapus</a>' : '';
                    if (!empty($item->tgl_approval) || $item->tgl_approval != '0000-00-00 00:00:00') {
                        $tgl_approval = '
                            <div>' . \Format::indoDate2($item->tgl_approval) . '</div>
                            <div class="text-muted"><small>' . \Format::hari($item->tgl_approval) . ', ' . \Format::jam($item->tgl_approval) . '</small></div>
                        ';
                    } else {
                        $tgl_approval = '<center>-</center>';
                    }
                    $out .= '
						<tr class="item-prq-' . $item->id_prq . '">
							<td>' . $no . '</td>
							<td>
								<div>
                                    ' . $item->no_prq . '
                                    ' . $tanda . '
                                </div>
								<div class="links">
									<small>
										[
											<a href="#" data-toggle="modal" data-target="#detailprq" onclick="detailprq(' . $item->id_prq . ')">Lihat</a>
											' . $edit . '
											' . $del . '
										]
									</small>
								</div>
							</td>
							<td>
								<div ' . $class . '> ' . \Format::indoDate2($item->target) . '</div>
								' . $selisih . '
							</td>
							<td title="' . $item->nm_depan . ' ' . $item->nm_belakang . '">
								' . \Format::substr($item->nm_depan . '  ' . $item->nm_belakang, 10) . '
								<div><small class="text-muted">' . \Format::indoDate($item->created_at) . '</small></div>
							</td>
                            <td>' . $tipe . '</td>
                            <td>' . $tgl_approval . '</td>
							<td>' . $status[$item->status] . '</td>
						</tr>
					';
                    $no++;
                }
            } else {
                $out = '
					<tr>
						<td colspan="7">Tidak ditemukan</td>
					</tr>
				';
            }
            $res['pagin'] = $items->render();
            $res['content'] = $out;
            return json_encode($res);
        }
    }