Struktur ulang: memindahkan sistem ke folder public untuk Nginx
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class Formdaftar extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
//panggil model
|
||||
$this->load->model('siswamodel');
|
||||
$this->load->model('peserta_model');
|
||||
$this->load->model('pendaftar_model');
|
||||
|
||||
//proteksi halaman
|
||||
$this->simple_login->check_login();
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$peserta = $this->peserta_model->listing();
|
||||
$total = $this->peserta_model->total();
|
||||
$query = $this->db->get('setting'); // Mengambil data dari tabel 'setting'
|
||||
$result = $query->row(); // Mengambil baris pertama sebagai objek
|
||||
$tahun_pelajaran = $result->kelas_tahun;
|
||||
$tp = $result->tp;
|
||||
|
||||
// Ambil nomor pendaftaran terakhir dari tabel data_siswa
|
||||
$this->db->select_max('no_pendaftaran');
|
||||
$this->db->where('tahun_pelajaran', $tp);
|
||||
$query_last_number = $this->db->get('data_siswa');
|
||||
$result_last_number = $query_last_number->row();
|
||||
$last_registration_number = $result_last_number->no_pendaftaran;
|
||||
|
||||
// Mengambil nomor urut terakhir dalam format angka
|
||||
if ($last_registration_number) {
|
||||
// Mengambil nomor urut terakhir dari nomor pendaftaran terakhir
|
||||
$last_registration_number_urut = substr($last_registration_number, -3);
|
||||
$last_registration_number_urut_numeric = (int)$last_registration_number_urut;
|
||||
} else {
|
||||
$last_registration_number_urut_numeric = 0; // Jika tidak ada pendaftar sebelumnya, nomor urut dimulai dari 0
|
||||
}
|
||||
|
||||
// Menghitung nomor urut pendaftaran berikutnya
|
||||
$next_registration_number_urut = $last_registration_number_urut_numeric + 1;
|
||||
|
||||
// Format nomor pendaftaran berikutnya
|
||||
$nomor_pendaftaran = $tahun_pelajaran . sprintf("%03d", $next_registration_number_urut);
|
||||
|
||||
|
||||
|
||||
$data = array( 'title' => 'Form Pendaftaran - Data Keseluruhan Pendaftar [ '.$total->total.' ]',
|
||||
'peserta' => $peserta,
|
||||
'nodaftar' => $nomor_pendaftaran,
|
||||
'content' => 'formdaftar/index'
|
||||
);
|
||||
$this->load->view('layout/wrapper', $data, FALSE);
|
||||
}
|
||||
|
||||
|
||||
public function edit($no_pendaftaran)
|
||||
{
|
||||
$inp = $this->input;
|
||||
$data = array( 'no_pendaftaran' => $no_pendaftaran,
|
||||
'status' => $inp->post('status'));
|
||||
$this->siswamodel->edit($data);
|
||||
}
|
||||
|
||||
public function tambah() {
|
||||
$query = $this->db->get('setting'); // Mengambil data dari tabel 'setting'
|
||||
$result = $query->row(); // Mengambil baris pertama sebagai objek
|
||||
// Ambil data yang dikirimkan dari form
|
||||
$nisn = $this->input->post('nisn');
|
||||
$sepatu = $this->input->post('sepatu');
|
||||
$no_pendaftaran = $this->input->post('no_pendaftaran');
|
||||
$nama_lengkap = $this->input->post('nama_lengkap');
|
||||
$jkelamin = $this->input->post('jkelamin');
|
||||
$agama = $this->input->post('agama');
|
||||
$kemeja = $this->input->post('kemeja');
|
||||
$celana = $this->input->post('celana');
|
||||
$tempat_lahir = $this->input->post('tempat_lahir');
|
||||
$tgl_lahir = $this->input->post('tgl_lahir');
|
||||
$no_hp = $this->input->post('no_hp');
|
||||
$sekolah_asal = $this->input->post('sekolah_asal');
|
||||
$nama_ayah = $this->input->post('nama_ayah');
|
||||
$tlp_ayah = $this->input->post('tlp_ayah');
|
||||
$nama_ibu = $this->input->post('nama_ibu');
|
||||
$tlp_ibu = $this->input->post('tlp_ibu');
|
||||
$alamat_ayah = $this->input->post('alamat_ayah');
|
||||
$kd_kompetensi = $this->input->post('kd_kompetensi');
|
||||
$sekolah_lain = $this->input->post('sekolah_lain');
|
||||
$jurusan = "";
|
||||
if ($kd_kompetensi == "TJKT") {
|
||||
$jurusan= "Teknik Jaringan Komputer & Telekomunikasi";
|
||||
} elseif ($kd_kompetensi == "MPLB") {
|
||||
$jurusan= "Manajemen Perkantoran & Layanan Bisnis";
|
||||
} elseif ($kd_kompetensi == "ANIMASI") {
|
||||
$jurusan= "Animasi";
|
||||
} else {
|
||||
$jurusan = "Kuliner";
|
||||
}
|
||||
|
||||
$sekolah = !empty($sekolah_asal) ? $sekolah_asal : $sekolah_lain;
|
||||
|
||||
// Lakukan validasi data jika diperlukan
|
||||
// Siapkan data untuk dimasukkan ke dalam basis data
|
||||
$data = array(
|
||||
'no_pendaftaran' => $no_pendaftaran,
|
||||
'nisn' => $nisn,
|
||||
'sepatu' => $sepatu,
|
||||
'kompetensi' => $jurusan,
|
||||
'nama_lengkap' => $nama_lengkap,
|
||||
'jkelamin' => $jkelamin,
|
||||
'agama' => $agama,
|
||||
'kemeja' => $kemeja,
|
||||
'celana' => $celana,
|
||||
'tempat_lahir' => $tempat_lahir,
|
||||
'tgl_lahir' => $tgl_lahir,
|
||||
'no_hp' => $no_hp,
|
||||
'sekolah_asal' => $sekolah,
|
||||
'nama_ayah' => $nama_ayah,
|
||||
'tlp_ayah' => $tlp_ayah,
|
||||
'nama_ibu' => $nama_ibu,
|
||||
'tlp_ibu' => $tlp_ibu,
|
||||
'alamat_siswa' => $alamat_ayah,
|
||||
'kd_kompetensi' => $kd_kompetensi,
|
||||
'tahun_pelajaran' => $result->tp,
|
||||
'gelombang' => $result->gelombang,
|
||||
'status' => 'Belum Tes',
|
||||
);
|
||||
|
||||
// Simpan data ke dalam basis data
|
||||
$this->db->insert('data_siswa', $data);
|
||||
if (!empty($sekolah_lain)) {
|
||||
$datas = array(
|
||||
'nm_sekolah' => $sekolah_lain,
|
||||
);
|
||||
$this->db->insert('sekolah', $datas);
|
||||
|
||||
}
|
||||
|
||||
// Tambahkan logika untuk menangani jika data berhasil disimpan atau tidak
|
||||
if ($this->db->affected_rows() > 0) {
|
||||
// Data berhasil disimpan
|
||||
$this->session->set_flashdata('sukses', 'Data Calon Siswa Telah Ditambahkan, Silahkan lakukan Transaki Biaya Tes..!');
|
||||
redirect(base_url('biayaformulir'),'refresh');
|
||||
} else {
|
||||
// Data gagal disimpan
|
||||
echo "Gagal menyimpan data calon siswa. Silakan coba lagi.";
|
||||
}
|
||||
}
|
||||
|
||||
// Fungsi untuk menghasilkan nomor pendaftaran baru
|
||||
private function generate_nomor_pendaftaran() {
|
||||
// Tambahkan logika untuk menghasilkan nomor pendaftaran baru sesuai dengan kebutuhan Anda
|
||||
// ...
|
||||
return $nomor_pendaftaran;
|
||||
}
|
||||
|
||||
|
||||
//Delete user
|
||||
public function delete($no_pendaftaran)
|
||||
{
|
||||
$data = array('no_pendaftaran' => $no_pendaftaran);
|
||||
//proses hapus
|
||||
$this->siswamodel->delete($data);
|
||||
//notifikasi
|
||||
$this->session->set_flashdata('sukses', 'Data nilai telah dihapus');
|
||||
redirect(base_url('nilai'),'refresh');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user