Files
web-sekolah/application/controllers/Invoice.php
T
2026-06-26 13:37:55 +07:00

669 lines
29 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Invoice extends CI_Controller {
//load model
public function __construct()
{
parent::__construct();
$this->load->model('invoice_model');
$this->load->model('biayaformulir_model');
$this->simple_login->check_login();
}
public function search(){
// Ambil data pendaftar yang dikirim via ajax post
$no_pendaftaran = $this->input->post('no_pendaftaran');
$siswa = $this->biayaformulir_model->viewByNoInvoice($no_pendaftaran);
if( ! empty($siswa)){ // Jika data siswa ada/ditemukan
// Buat sebuah array
// cari dulu ditabel pengumuman
$cari1= $this->db->get_where("pengumuman", ["no_pendaftaran" =>$siswa->no_pendaftaran ]);
if ($cari1->num_rows() > 0) {
$datapengumuman= $cari1->row();
if ($datapengumuman->status == "BELUM LULUS" || $datapengumuman->status == "TIDAK LULUS") {
$callback = array('status' => 'belum');
} else {
$setppdb = $this->db->get("biaya_ppdb")->row();
$biaya_pendaftaran_formatted = number_format($siswa->biaya_pendaftaran, 0, ',', '.');
$potgel=0;
$potkembar=0;
$potsekolah=0;
$potyatim=0;
$potspp=0;
if ($siswa->gelombang == "Gelombang 1") {
// potongangelombang
$potgel= $setppdb->pot_gel;
// potongansekolah_dp
if ($siswa->sekolah_asal=="SMP Dharma Pertiwi") {
$potsekolah = $setppdb->pot_dp;
}
// // potonganyatim
// if ($siswa->ket=="Yatim") {
// $potsekolah = $setppdb->pot_yatim;
// // potongan SPP
// if ($siswa->kd_pompetensi =="TJKT") {
// $potspp = $setppdb->pot_spp_tkj;
// }
// else{
// $potspp = $setppdb->pot_spp;
// }
// }
} else {
// if ($siswa->sekolah_asal=="SMP Dharma Pertiwi") {
// $potsekolah = $setppdb->pot_dp;
// }
// potonganyatim
// if ($siswa->ket=="Yatim") {
// $potsekolah = $setppdb->pot_yatim;
// // potongan SPP
// if ($siswa->kd_pompetensi =="TJKT") {
// $potspp = $setppdb->pot_spp_tkj;
// }
// else{
// $potspp = $setppdb->pot_spp;
// }
// }
}
$totalpotongan = $potgel+$potsekolah+$potspp+$potyatim;
$totalketentuan = $siswa->biaya_pendaftaran-$totalpotongan;
$callback = array(
'status' => 'success', // Set array status dengan success
'nama_lengkap' => $siswa->nama_lengkap, // Set array nama
'sekolah_asal' => $siswa->sekolah_asal, // Set array sekolah
'kompetensi' => $siswa->kompetensi, // Set array kompetensi
'gelombang' => $siswa->gelombang, // Set array kompetensi
'biaya_pendaftaran' => $siswa->biaya_pendaftaran, // Set array kompetensi
'biaya' => $biaya_pendaftaran_formatted, // Set array kompetensi
'potgel' => $potgel, // Set array kompetensi
'potsekolah' => $potsekolah, // Set array kompetensi
'potspp' => $potspp, // Set array kompetensi
'potyatim' => $potyatim, // Set array kompetensi
'ketentuan' => $totalketentuan, // Set array kompetensi
);
}
}
else{
$callback = array('status' => 'belum');
}
}else{
$callback = array('status' => 'failed'); // set array status dengan failed
}
echo json_encode($callback); // konversi varibael $callback menjadi JSON
}
public function caripotongan() {
// Ambil data dari AJAX request
$potongan = $this->input->post('potongan');
$nopendaftaran = $this->input->post('nopendaftaran');
$siswa = $this->db->get_where("data_siswa", ["no_pendaftaran" => $nopendaftaran])->row();
if( ! empty($siswa)){ // Jika data siswa ada/ditemukan
// Buat sebuah array
$setppdb = $this->db->get("biaya_ppdb")->row();
// $biaya_pendaftaran_formatted = number_format($siswa->biaya_pendaftaran, 0, ',', '.');
$potgel=0;
$potkembar=0;
$potsekolah=0;
$potyatim=0;
$potspp=0;
$potyayasan=0;
// potonganyatim
if ($potongan=="Yatim") {
$potyatim = $setppdb->pot_yatim;
// potongan SPP
if ($siswa->kd_kompetensi =="TJKT") {
$potspp = $setppdb->pot_spp_tkj;
}
elseif ($siswa->kd_kompetensi =="MPLB") {
$potspp = $setppdb->pot_spp;
}
elseif ($siswa->kd_kompetensi =="ANIMASI") {
$potspp = $setppdb->pot_spp_animasi;
}
else{
$potspp = $setppdb->pot_spp_kuliner;
}
}
elseif ($potongan=="Kembar") {
$potkembar = $setppdb->pot_kembar;
}
elseif ($potongan=="Yatim & Kembar") {
$potkembar = $setppdb->pot_kembar;
$potyatim = $setppdb->pot_yatim;
// potongan SPP
if ($siswa->kd_kompetensi =="TJKT") {
$potspp = $setppdb->pot_spp_tkj;
}
elseif ($siswa->kd_kompetensi =="MPLB") {
$potspp = $setppdb->pot_spp;
}
elseif ($siswa->kd_kompetensi =="ANIMASI") {
$potspp = $setppdb->pot_spp_animasi;
}
else{
$potspp = $setppdb->pot_spp_kuliner;
}
}
elseif ($potongan=="Yayasan") {
}
elseif ($potongan=="SKTM") {
# code...
}
// $totalpotongan = $potgel+$potsekolah+$potspp+$potyatim;
// $totalketentuan = $siswa->biaya_pendaftaran-$totalpotongan;
$callback = array(
'status' => 'success', // Set array status dengan success
// 'nama_lengkap' => $siswa->nama_lengkap, // Set array nama
// 'sekolah_asal' => $siswa->sekolah_asal, // Set array sekolah
// 'kompetensi' => $siswa->kompetensi, // Set array kompetensi
// // 'biaya_pendaftaran' => $siswa->biaya_pendaftaran, // Set array kompetensi
// 'biaya' => $biaya_pendaftaran_formatted, // Set array kompetensi
'potgel' => $potgel, // Set array kompetensi
'potsekolah' => $potsekolah, // Set array kompetensi
'potspp' => $potspp, // Set array kompetensi
'potyatim' => $potyatim, // Set array kompetensi
'potkembar' => $potkembar, // Set array kompetensi
// 'ketentuan' => $totalketentuan, // Set array kompetensi
);
}else{
$callback = array('status' => 'failed'); // set array status dengan failed
}
echo json_encode($callback); // konversi varibael $callback menjadi JSON
}
public function caripotongandp() {
// Ambil data dari AJAX request
$potongan = $this->input->post('potongan');
$nopendaftaran = $this->input->post('nopendaftaran');
$siswa = $this->db->get_where("data_siswa", ["no_pendaftaran" => $nopendaftaran])->row();
if( ! empty($siswa)){ // Jika data siswa ada/ditemukan
// Buat sebuah array
$setppdb = $this->db->get("biaya_ppdb")->row();
// $biaya_pendaftaran_formatted = number_format($siswa->biaya_pendaftaran, 0, ',', '.');
$potgel=0;
$potkembar=0;
$potsekolah=0;
$potyatim=0;
$potspp=0;
$potyayasan=0;
// potonganyatim
if ($potongan=="YA") {
$potsekolah = $setppdb->pot_dp;
}
else{
}
$callback = array(
'status' => 'success', // Set array status dengan success
'potdp' => $potsekolah, // Set array nama
);
}else{
$callback = array('status' => 'failed'); // set array status dengan failed
}
echo json_encode($callback); // konversi varibael $callback menjadi JSON
}
public function index()
{
$invoice = $this->invoice_model->listing();
$total = $this->invoice_model->total();
$biaya = $this->db->get("setting")->row()->biaya_for;
$diskon = $this->db->get("setting")->row()->diskon;
// no invoice otomatis
// Ambil tanggal saat ini dalam format 'Ymd'
$tanggal_sekarang = date('dmy');
// Lakukan query untuk mendapatkan nomor urutan terakhir
$query = $this->db->query("SELECT MAX(CAST(RIGHT(no_invoice, 4) AS UNSIGNED)) AS max_urutan FROM invoice");
$row = $query->row();
$max_urutan = ($row->max_urutan != null) ? $row->max_urutan : 0;
// Tambahkan 1 ke nomor urutan terakhir
$no_urut = sprintf("%04s", $max_urutan + 1);
// Gabungkan semua elemen menjadi nomor transaksi
$nomor_transaksi = 'IN-' . $tanggal_sekarang . $no_urut;
$data = array( 'title' => 'Invoice Biaya PPDB [ '.$total->total.' ]',
'invoice' => $invoice,
'notr' => $nomor_transaksi,
'content' => 'invoice/index'
);
$this->load->view('layout/wrapper', $data, FALSE);
}
public function tambah()
{
// Ambil data dari input form
$data = array(
'no_invoice' => $this->input->post('noinvoice'),
'tgl_invoice' => date('Y-m-d'),
'no_pendaftaran' => $this->input->post('no_pendaftaran'),
'biaya' => $this->input->post('realbiaya'),
'pot_gel' => $this->input->post('potongan_gel_1'),
'pot_dp' => $this->input->post('potongan_dp'),
'pot_yatim' => $this->input->post('potongan_yatim'),
'pot_spp' => $this->input->post('potongan_spp'),
'pot_kembar' => $this->input->post('potongan_kembar'),
'pot_yayasan' => str_replace('.', '', $this->input->post('potongan_yayasan')),
'pot_sktm' => str_replace('.', '', $this->input->post('potongan_sktm')),
'pot_lain' => str_replace('.', '', $this->input->post('potongan_lainnya')),
'ketentuan' => $this->input->post('total'),
'operator' => $this->session->userdata('nama')
);
// Simpan data ke dalam tabel invoice
$this->db->insert('invoice', $data);
// Redirect ke halaman setelah berhasil menyimpan
$this->session->set_flashdata('sukses', 'Data Invoice telah ditambah..!');
redirect('invoice');
}
//Edit user
public function edit($no_pendaftaran)
{
//panggil data user yang akan diedit
$invoice = $this->invoice_model->detail($no_pendaftaran);
$data= array( 'title' => 'Edit Data Invoice Pendaftar : '.$invoice->no_pendaftaran.' -- '.$invoice->nama_lengkap.' -- '.$invoice->gelombang,
'invoice' => $invoice,
'content' => 'invoice/edit'
);
$this->load->view('layout/wrapper', $data, FALSE);
//jika validasi oke, masuk database
}
public function transaksi($no_pendaftaran)
{
//panggil data user yang akan diedit
$invoice = $this->invoice_model->detail($no_pendaftaran);
$datatrx = $this->db->get_where("tr_invoice", ["no_pendaftaran" => $no_pendaftaran])->result();
// Inisialisasi variabel untuk menyimpan total pembayaran
$total_pembayaran = 0;
// Iterasi setiap baris hasil query dan tambahkan nilai kolom 'bayar' ke variabel $total_pembayaran
foreach ($datatrx as $trx) {
$total_pembayaran += $trx->bayar;
}
$tanggal_sekarang = date('dmy');
// Lakukan query untuk mendapatkan nomor urutan terakhir
$query = $this->db->query("SELECT MAX(CAST(RIGHT(no_trans, 4) AS UNSIGNED)) AS max_urutan FROM tr_invoice");
$row = $query->row();
$max_urutan = ($row->max_urutan != null) ? $row->max_urutan : 0;
// Tambahkan 1 ke nomor urutan terakhir
$no_urut = sprintf("%04s", $max_urutan + 1);
// Gabungkan semua elemen menjadi nomor transaksi
$nomor_transaksi = 'TI-' . $tanggal_sekarang . $no_urut;
$data= array( 'title' => 'Transaksi Invoice : '.$invoice->no_pendaftaran.' -- '.$invoice->nama_lengkap.' -- '.$invoice->gelombang,
'invoice' => $invoice,
'transaksi' => $datatrx,
'sudahbayar' => $total_pembayaran,
'notr' => $nomor_transaksi,
'content' => 'invoice/transaksi'
);
$this->load->view('layout/wrapper', $data, FALSE);
//jika validasi oke, masuk database
}
public function simpanedit($no_pendaftaran)
{
//panggil data user yang akan diedit
$data = array(
'pot_gel' => $this->input->post('potongan_gel_1'),
'pot_dp' => $this->input->post('potongan_dp'),
'pot_yatim' => $this->input->post('potongan_yatim'),
'pot_spp' => $this->input->post('potongan_spp'),
'pot_kembar' => $this->input->post('potongan_kembar'),
'pot_yayasan' => str_replace('.', '', $this->input->post('potongan_yayasan')),
'pot_sktm' => str_replace('.', '', $this->input->post('potongan_sktm')),
'pot_lain' => str_replace('.', '', $this->input->post('potongan_lainnya')),
'ketentuan' => $this->input->post('total'),
'operator' => $this->session->userdata('nama')
);
$this->db->where('no_pendaftaran', $no_pendaftaran);
$this->db->update('invoice', $data);
$this->session->set_flashdata('sukses', 'Data invoice '.$no_pendaftaran.' telah diedit.');
redirect(base_url('invoice'),'refresh');
//jika validasi oke, masuk database
}
public function delete($no_pendaftaran)
{
$data = array('no_pendaftaran' => $no_pendaftaran);
//proses hapus
$this->invoice_model->delete($data);
$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
$this->db->delete('tr_invoice', $data);
//notifikasi
$this->session->set_flashdata('sukses', 'Data invoice telah dihapus..!');
redirect(base_url('invoice'),'refresh');
}
// transaksi invoice
public function fungsi_edit_invoice()
{
// Ambil data yang dikirim melalui AJAX
$noTrans = $this->input->post('no_trans');
// Query ke tabel tr_invoice berdasarkan nomor transaksi
$data = $this->db->get_where('tr_invoice', array('no_trans' => $noTrans))->row();
// Kirim data dalam format JSON
echo json_encode($data);
}
public function cetaktransaksi($no_pendaftaran)
{
$data['invoice'] = $this->invoice_model->detail($no_pendaftaran);
$data['data'] = $this->db->get_where('v_rpt_trans_invoice',['no_pendaftaran'=>$no_pendaftaran])->row();
$data['datatrx'] = $this->db->get_where('v_rpt_trans_invoice',['no_pendaftaran'=>$no_pendaftaran])->result();
$datatrx = $this->db->get_where("tr_invoice", ["no_pendaftaran" => $no_pendaftaran])->result();
// Inisialisasi variabel untuk menyimpan total pembayaran
$total_pembayaran = 0;
// Iterasi setiap baris hasil query dan tambahkan nilai kolom 'bayar' ke variabel $total_pembayaran
foreach ($datatrx as $trx) {
$total_pembayaran += $trx->bayar;
}
$data["total"] = $total_pembayaran;
$this->load->view('invoice/cetak',$data);
}
public function simpantransaksi(){
$editkah = $this->input->post("editkah");
$nopen = $this->input->post("nopen");
$noin = $this->input->post("noin");
$notr = $this->input->post("notr");
$keterangan_cicilan = $this->input->post("keterangan_cicilan");
$besarcicilan = str_replace('.', '',$this->input->post("besarcicilan"));
if ($editkah == "editkah") {
$data = [
"angsuran" => $keterangan_cicilan,
"bayar" => $besarcicilan,
"tgl_bayar" => date('Y-m-d'),
'operator' => $this->session->userdata('nama')
];
$this->db->where('no_trans', $notr);
$this->db->update('tr_invoice', $data);
$this->session->set_flashdata('sukses', 'Data Transaksi invoice '.$notr.' telah diedit.');
redirect(base_url('invoice/transaksi/'.$nopen),'refresh');
} else {
$data = [
"angsuran" => $keterangan_cicilan,
"bayar" => $besarcicilan,
"tgl_bayar" => date('Y-m-d'),
"no_trans" => $notr,
"no_pendaftaran" => $nopen,
"no_invoice" => $noin,
"no_invoice" => $noin,
'operator' => $this->session->userdata('nama')
];
$this->db->insert('tr_invoice', $data);
$this->session->set_flashdata('sukses', 'Data Transaksi invoice '.$notr.' telah ditambahkan.');
redirect(base_url('invoice/transaksi/'.$nopen),'refresh');
}
}
public function deletetransaksi($no_trans)
{
$no_pendaftaran = $this->input->get('no_pendaftaran');
$data = array('no_trans' => $no_trans);
//proses hapus
$this->invoice_model->deletetransaksi($data);
//notifikasi
$this->session->set_flashdata('sukses', 'Data Transaksi invoice '.$no_trans.' telah dihapus.');
redirect(base_url('invoice/transaksi/'.$no_pendaftaran),'refresh');
}
//EXPORT NILAI KE EXCEL
public function export(){
// Load plugin PHPExcel nya
include APPPATH.'third_party/PHPExcel/PHPExcel.php';
// Panggil class PHPExcel nya
$excel = new PHPExcel();
// Settingan awal fil excel
$excel->getProperties()->setCreator('By : 415 DIL')
->setLastModifiedBy('By : 415 DIL')
->setTitle("Data Invoice")
->setSubject("Invoice")
->setDescription("Laporan Data Invoice")
->setKeywords("Data Invoice");
// Buat sebuah variabel untuk menampung pengaturan style dari header tabel
$style_col = array(
'font' => array('bold' => true), // Set font nya jadi bold
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, // Set text jadi ditengah secara horizontal (center)
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER // Set text jadi di tengah secara vertical (middle)
),
'borders' => array(
'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border top dengan garis tipis
'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border right dengan garis tipis
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border bottom dengan garis tipis
'left' => array('style' => PHPExcel_Style_Border::BORDER_THIN) // Set border left dengan garis tipis
)
);
// Buat sebuah variabel untuk menampung pengaturan style dari isi tabel
$style_row = array(
'alignment' => array(
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER // Set text jadi di tengah secara vertical (middle)
),
'borders' => array(
'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border top dengan garis tipis
'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border right dengan garis tipis
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), // Set border bottom dengan garis tipis
'left' => array('style' => PHPExcel_Style_Border::BORDER_THIN) // Set border left dengan garis tipis
)
);
$excel->setActiveSheetIndex(0)->setCellValue('A1', "DATA REKAP INVOICE PPDB SMK AL-MUHTADIN DEPOK"); // Set kolom A1 dengan tulisan "DATA SISWA"
$excel->getActiveSheet()->mergeCells('A1:S1'); // Set Merge Cell pada kolom A1 sampai E1
$excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(TRUE); // Set bold kolom A1
$excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(15); // Set font size 15 untuk kolom A1
$excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); // Set text center untuk kolom A1
// Buat header tabel nya pada baris ke 3
$excel->setActiveSheetIndex(0)->setCellValue('A3', "NO."); // Set kolom A3 dengan tulisan "NO"
$excel->setActiveSheetIndex(0)->setCellValue('B3', "NO. PEND"); // Set kolom B3 dengan tulisan "NO.PEND"
$excel->setActiveSheetIndex(0)->setCellValue('C3', "NAMA LENGKAP"); // Set kolom C3 dengan tulisan "NAMA"
$excel->setActiveSheetIndex(0)->setCellValue('D3', "SEKOLAH ASAL"); // Set kolom E3 dengan tulisan "SEKOLAH"
$excel->setActiveSheetIndex(0)->setCellValue('E3', "KOMPETENSI");
$excel->setActiveSheetIndex(0)->setCellValue('F3', "GELOMBANG");
$excel->setActiveSheetIndex(0)->setCellValue('G3', "TGL. INVOICE");
$excel->setActiveSheetIndex(0)->setCellValue('H3', "NO. INVOICE");
$excel->setActiveSheetIndex(0)->setCellValue('I3', "BIAYA PPDB");
$excel->setActiveSheetIndex(0)->setCellValue('J3', "POT. GEL");
$excel->setActiveSheetIndex(0)->setCellValue('K3', "POT. DP");
$excel->setActiveSheetIndex(0)->setCellValue('L3', "POT. YATIM");
$excel->setActiveSheetIndex(0)->setCellValue('M3', "POT. SPP");
$excel->setActiveSheetIndex(0)->setCellValue('N3', "POT. KEMBAR");
$excel->setActiveSheetIndex(0)->setCellValue('O3', "POT. YAYASAN");
$excel->setActiveSheetIndex(0)->setCellValue('P3', "POT. SKTM");
$excel->setActiveSheetIndex(0)->setCellValue('Q3', "POT. LAINNYA");
$excel->setActiveSheetIndex(0)->setCellValue('R3', "BIAYA KETENTUAN");
$excel->setActiveSheetIndex(0)->setCellValue('S3', "PETUGAS INVOICE");
// Apply style header yang telah kita buat tadi ke masing-masing kolom header
$excel->getActiveSheet()->getStyle('A3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('B3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('C3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('D3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('E3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('F3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('G3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('H3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('I3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('J3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('K3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('L3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('M3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('N3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('O3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('P3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('Q3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('R3')->applyFromArray($style_col);
$excel->getActiveSheet()->getStyle('S3')->applyFromArray($style_col);
// Panggil function view yang ada di invoice_model untuk menampilkan semua data invoicenya
$invoice = $this->invoice_model->ViewUrut();
$no = 1; // Untuk penomoran tabel, di awal set dengan 1
$numrow = 4; // Set baris pertama untuk isi tabel adalah baris ke 4
foreach($invoice as $data){ // Lakukan looping pada variabel invoice
$excel->setActiveSheetIndex(0)->setCellValue('A'.$numrow, $no);
$excel->setActiveSheetIndex(0)->setCellValue('B'.$numrow, $data->no_pendaftaran);
$excel->setActiveSheetIndex(0)->setCellValue('C'.$numrow, $data->nama_lengkap);
$excel->setActiveSheetIndex(0)->setCellValue('D'.$numrow, $data->sekolah_asal);
$excel->setActiveSheetIndex(0)->setCellValue('E'.$numrow, $data->kd_kompetensi);
$excel->setActiveSheetIndex(0)->setCellValue('F'.$numrow, $data->gelombang);
$excel->setActiveSheetIndex(0)->setCellValue('G'.$numrow, $data->tgl_invoice);
$excel->setActiveSheetIndex(0)->setCellValue('H'.$numrow, $data->no_invoice);
$excel->setActiveSheetIndex(0)->setCellValue('I'.$numrow, $data->biaya);
$excel->setActiveSheetIndex(0)->setCellValue('J'.$numrow, $data->pot_gel);
$excel->setActiveSheetIndex(0)->setCellValue('K'.$numrow, $data->pot_dp);
$excel->setActiveSheetIndex(0)->setCellValue('L'.$numrow, $data->pot_yatim);
$excel->setActiveSheetIndex(0)->setCellValue('M'.$numrow, $data->pot_spp);
$excel->setActiveSheetIndex(0)->setCellValue('N'.$numrow, $data->pot_kembar);
$excel->setActiveSheetIndex(0)->setCellValue('O'.$numrow, $data->pot_yayasan);
$excel->setActiveSheetIndex(0)->setCellValue('P'.$numrow, $data->pot_sktm);
$excel->setActiveSheetIndex(0)->setCellValue('Q'.$numrow, $data->pot_lain);
$excel->setActiveSheetIndex(0)->setCellValue('R'.$numrow, $data->ketentuan);
$excel->setActiveSheetIndex(0)->setCellValue('S'.$numrow, $data->operator);
// Apply style row yang telah kita buat tadi ke masing-masing baris (isi tabel)
$excel->getActiveSheet()->getStyle('A'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('B'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('C'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('D'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('E'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('F'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('G'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('H'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('I'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('J'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('K'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('L'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('M'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('N'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('O'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('P'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('Q'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('R'.$numrow)->applyFromArray($style_row);
$excel->getActiveSheet()->getStyle('S'.$numrow)->applyFromArray($style_row);
$no++; // Tambah 1 setiap kali looping
$numrow++; // Tambah 1 setiap kali looping
}
// Set width kolom
$excel->getActiveSheet()->getColumnDimension('A')->setWidth(5); // Set width kolom A
$excel->getActiveSheet()->getColumnDimension('B')->setWidth(12); // Set width kolom B
$excel->getActiveSheet()->getColumnDimension('C')->setWidth(35); // Set width kolom C
$excel->getActiveSheet()->getColumnDimension('D')->setWidth(35); // Set width kolom D
$excel->getActiveSheet()->getColumnDimension('E')->setWidth(13); // Set width kolom E
$excel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$excel->getActiveSheet()->getColumnDimension('G')->setWidth(13);
$excel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
$excel->getActiveSheet()->getColumnDimension('I')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('J')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('K')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('L')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('M')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('N')->setWidth(15);
$excel->getActiveSheet()->getColumnDimension('O')->setWidth(15);
$excel->getActiveSheet()->getColumnDimension('P')->setWidth(12);
$excel->getActiveSheet()->getColumnDimension('Q')->setWidth(15);
$excel->getActiveSheet()->getColumnDimension('R')->setWidth(18);
$excel->getActiveSheet()->getColumnDimension('S')->setWidth(18);
// Set height semua kolom menjadi auto (mengikuti height isi dari kolommnya, jadi otomatis)
$excel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1);
// Set orientasi kertas jadi LANDSCAPE
$excel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
// Set judul file excel nya
$excel->getActiveSheet(0)->setTitle("Data Rekap Invoice PPDB");
$excel->setActiveSheetIndex(0);
// Proses file excel
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="Data Rekap Invoice PPDB.xlsx"'); // Set nama file excel nya
header('Cache-Control: max-age=0');
$write = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$write->save('php://output');
}
}
/* End of file Pendaftar.php */
/* Location: ./application/controllers/Pendaftar.php */