tambah kolom server di pdf barang bawaan

This commit is contained in:
2026-07-29 08:01:24 +07:00
parent 7d90548717
commit 4c2fefe9c3
2 changed files with 13 additions and 8 deletions
+4 -2
View File
@@ -22,9 +22,10 @@ class Asset extends CI_Controller {
// ================= GET DATA ================= // ================= GET DATA =================
public function get_data(){ public function get_data(){
$data = $this->db $data = $this->db
->select('assets.*, lokasi_asset.nama as nama_lokasi') ->select('assets.*, lokasi_asset.nama as nama_lokasi, item_barcodes.barcode as barcode, item_barcodes.id as barcode_id')
->from('assets') ->from('assets')
->join('lokasi_asset', 'lokasi_asset.id = assets.lokasi_asset_id', 'left') ->join('lokasi_asset', 'lokasi_asset.id = assets.lokasi_asset_id', 'left')
->join('item_barcodes', 'item_barcodes.id = assets.barcode_id', 'left')
->order_by('assets.tanggal_perolehan','DESC') ->order_by('assets.tanggal_perolehan','DESC')
->get() ->get()
->result(); ->result();
@@ -37,7 +38,7 @@ class Asset extends CI_Controller {
$no++, $no++,
$d->tanggal_perolehan, $d->tanggal_perolehan,
$d->kode_asset ?? '-', $d->kode_asset ?? '-',
$d->nama_asset, $d->nama_asset . ($d->barcode_id ? '<br><small class="text-muted"><i>'.$d->barcode.'</i></small>' : ''),
$d->nama_lokasi ?? '-', $d->nama_lokasi ?? '-',
$d->keterangan ?? '-', $d->keterangan ?? '-',
number_format($d->nilai_perolehan), number_format($d->nilai_perolehan),
@@ -204,6 +205,7 @@ class Asset extends CI_Controller {
// INSERT ASSET // INSERT ASSET
$this->db->insert('assets',[ $this->db->insert('assets',[
'item_id' => $item_id, 'item_id' => $item_id,
'barcode_id' => $barcode_id,
'kode_asset' => 'AST-'.time(), 'kode_asset' => 'AST-'.time(),
'nama_asset' => $nama_asset, 'nama_asset' => $nama_asset,
'harga_per_unit' => $harga, 'harga_per_unit' => $harga,
+9 -6
View File
@@ -8,7 +8,7 @@ class PDF_BarangBawaan extends FPDF
private $tanggal; private $tanggal;
private $teknisi; private $teknisi;
private $colWidths = [8, 18, 27, 44, 26, 10, 57]; private $colWidths = [8, 18, 27, 42, 24, 10, 46, 15];
public function __construct($orientation = 'L', $unit = 'mm', $size = 'A5') public function __construct($orientation = 'L', $unit = 'mm', $size = 'A5')
{ {
@@ -57,7 +57,7 @@ class PDF_BarangBawaan extends FPDF
$this->SetTextColor(255, 255, 255); $this->SetTextColor(255, 255, 255);
$this->SetFont('Arial', 'B', 7); $this->SetFont('Arial', 'B', 7);
$headers = ['No', 'Tanggal', 'Barcode', 'Nama Barang', 'Serial Number', 'Jumlah', 'Keterangan']; $headers = ['No', 'Tanggal', 'Barcode', 'Nama Barang', 'Serial Number', 'Jumlah', 'Keterangan', 'Server'];
foreach ($headers as $i => $h) { foreach ($headers as $i => $h) {
$this->Cell($this->colWidths[$i], 7, $h, 1, 0, 'C', true); $this->Cell($this->colWidths[$i], 7, $h, 1, 0, 'C', true);
} }
@@ -73,8 +73,8 @@ class PDF_BarangBawaan extends FPDF
$minRowH = 8; $minRowH = 8;
$no = 1; $no = 1;
$colsMultiCell = [false, false, true, true, true, false, true]; $colsMultiCell = [false, false, true, true, true, false, true, false];
$cellAligns = ['C', 'C', 'L', 'L', 'L', 'C', 'L']; $cellAligns = ['C', 'C', 'L', 'L', 'L', 'C', 'L', 'L'];
foreach ($items as $item) { foreach ($items as $item) {
$keterangan = isset($item->keterangan) ? $item->keterangan : ''; $keterangan = isset($item->keterangan) ? $item->keterangan : '';
@@ -82,6 +82,7 @@ class PDF_BarangBawaan extends FPDF
$serial = $item->serial_number ?? '-'; $serial = $item->serial_number ?? '-';
$barcode = $item->barcode ?? '-'; $barcode = $item->barcode ?? '-';
$jumlah = isset($item->qty_sisa) ? (int)$item->qty_sisa : 1; $jumlah = isset($item->qty_sisa) ? (int)$item->qty_sisa : 1;
$server = '';
$cellValues = [ $cellValues = [
(string)$no, (string)$no,
@@ -90,7 +91,8 @@ class PDF_BarangBawaan extends FPDF
$namaBarang, $namaBarang,
$serial, $serial,
(string)$jumlah, (string)$jumlah,
$keterangan $keterangan,
$server
]; ];
$maxLines = 1; $maxLines = 1;
@@ -122,7 +124,8 @@ class PDF_BarangBawaan extends FPDF
foreach ($cellValues as $i => $val) { foreach ($cellValues as $i => $val) {
$this->SetXY($currentX, $startY); $this->SetXY($currentX, $startY);
if ($colsMultiCell[$i]) { if ($colsMultiCell[$i]) {
$contentH = $maxLines * $lineH; $colLines = $this->NbLines($this->colWidths[$i], $val);
$contentH = $colLines * $lineH;
$offsetY = ($rowH - $contentH) / 2; $offsetY = ($rowH - $contentH) / 2;
$this->SetXY($currentX, $startY + $offsetY); $this->SetXY($currentX, $startY + $offsetY);
$this->MultiCell($this->colWidths[$i], $lineH, $val, 0, $cellAligns[$i]); $this->MultiCell($this->colWidths[$i], $lineH, $val, 0, $cellAligns[$i]);