supplyManageController.php
unknown
php_laravel_blade
2 years ago
2.4 kB
2
Indexable
public function filterTable($kode_pasok) { $supp = Supply::where('kode_pasok', $kode_pasok)->where('status', 'lunas')->get(); $data = "" ; $data .= '<table class="table table-bordered table-striped mb-0" id="datatable-default"> <thead> <tr>Surat Jalan: '. $supp[0]->surat_jalan .'</tr> <tr> <th>Kode</th> <th>Nama Barang</th> <th>Jumlah</th> <th>Harga Beli</th> <th>Subtotal</th> <th>Tanggal</th> <th>Aksi</th> </tr> </thead> <tbody>'; $total = 0; foreach ($supp as $no => $supply) { $total += $supply->subtotal; $product = Product::where('kode_barang', $supply->kode_barang)->first(); if ($supply->jenis_kemasan == 'pack') { $stok = $supply->jumlah; }else{ $stok = $supply->jumlah / $product->pack; } $data .= '<tr> <td>'.$supply->kode_pasok.'</td> <td>'.$product->nama_barang.'</td> <td>'.(int)$stok.' '.$supply->jenis_kemasan.'</td> <td>Rp. '.number_format($supply->harga_beli,0,',','.').'</td> <td>Rp. '.number_format($supply->subtotal,0,',','.').'</td> <td>'.$supply->created_at->toDateString().'</td> <td><a href="#" id="btn-delete-item" data-kode="'. $supply->id. '" data-nama="'. $supply->nama_barang . '" class="btn btn-icons btn-secondary btn-rounded btn-delete-modal"><i class="mdi mdi-close"></i></a></td> </tr>'; } $data .= '</tbody> <tfoot> <tr> <td colspan="4" class="text-right">Total</td> <td>Rp. '.number_format($total,0,',','.').'</td> <td colspan="2" class="text-right"></td> </tr> </tfoot> </table>'; return response()->json($data); }
Editor is loading...