576 lines
32 KiB
PHP
576 lines
32 KiB
PHP
<?php
|
|
|
|
namespace Tests\Concerns;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
/**
|
|
* Tiruan DB SIAKAD lama (koneksi `untan`) di SQLite memori dan login lewat provider `legacy`.
|
|
* f_encr() didaftarkan sebagai fungsi SQLite: geser +5 per karakter plus penanda chr(5), seperti aslinya.
|
|
*
|
|
* Akun: 1 staf fakultas, 2 dosen, 3 superuser dibekukan, 4 pegawai tanpa otoritas, 5 mahasiswa, 6 superuser.
|
|
* Tabel nilai dibuat kosong; isi dengan seedLegacyGrades() bila perlu.
|
|
*/
|
|
trait FakesLegacyDatabase
|
|
{
|
|
/** Hasil f_maxsks tiruan. */
|
|
protected int $legacyMaxSks = 24;
|
|
|
|
protected static function legacyEncode(string $value): string
|
|
{
|
|
return implode('', array_map(fn (string $char): string => chr(ord($char) + 5), str_split($value))).chr(5);
|
|
}
|
|
|
|
protected function useLegacyDatabase(): void
|
|
{
|
|
config([
|
|
'database.connections.untan' => ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => ''],
|
|
'auth.guards.web.provider' => 'legacy',
|
|
]);
|
|
DB::purge('untan');
|
|
Auth::forgetGuards();
|
|
|
|
$pdo = DB::connection('untan')->getPdo();
|
|
$functions = [
|
|
'f_encr' => [fn (?string $value): ?string => $value === null ? null : static::legacyEncode($value), 1],
|
|
'f_maxsks' => [fn (...$args): int => $this->legacyMaxSks, 4],
|
|
'f_inputlirs_new' => [fn (...$args): string => $this->fakeInputLirs(...$args), 10],
|
|
'f_hapuslirs' => [fn (...$args): string => $this->fakeHapusLirs(...$args), 6],
|
|
];
|
|
foreach ($functions as $name => [$callback, $arity]) {
|
|
method_exists($pdo, 'createFunction') ? $pdo->createFunction($name, $callback, $arity) : $pdo->sqliteCreateFunction($name, $callback, $arity);
|
|
}
|
|
|
|
$this->createLegacySchema();
|
|
$this->seedLegacyData();
|
|
}
|
|
|
|
private function createLegacySchema(): void
|
|
{
|
|
$schema = Schema::connection('untan');
|
|
|
|
$schema->create('t_account', function (Blueprint $table) {
|
|
$table->integer('iduser')->primary();
|
|
$table->string('username', 50)->unique();
|
|
$table->string('passwd', 50);
|
|
$table->integer('identitas');
|
|
$table->smallInteger('jenis');
|
|
$table->smallInteger('status')->default(0);
|
|
$table->timestamp('lastlogin')->nullable();
|
|
// cip dan tanggal NOT NULL seperti DB asli.
|
|
$table->string('cname', 20)->nullable();
|
|
$table->string('cip', 20)->default('10.0.0.1/32');
|
|
$table->string('uname', 15)->nullable();
|
|
$table->timestamp('tanggal')->useCurrent();
|
|
});
|
|
$schema->create('t_pegawai', function (Blueprint $table) {
|
|
$table->integer('idpegawai')->primary();
|
|
$table->string('nip');
|
|
$table->string('nipnasional')->nullable();
|
|
$table->string('nidn')->nullable();
|
|
$table->string('nama');
|
|
$table->string('gelardepan')->nullable();
|
|
$table->string('gelarbelakang')->nullable();
|
|
$table->string('email')->nullable();
|
|
$table->smallInteger('kelamin')->nullable();
|
|
$table->string('hp')->nullable();
|
|
$table->string('telepon')->nullable();
|
|
$table->smallInteger('statusaktif')->default(1);
|
|
$table->smallInteger('idstatuspegawai')->nullable();
|
|
});
|
|
$schema->create('t_mahasiswa', function (Blueprint $table) {
|
|
$table->integer('idmahasiswa')->primary();
|
|
$table->string('nim');
|
|
$table->string('nama');
|
|
$table->string('email_mhs')->nullable();
|
|
$table->integer('idangkatan')->nullable();
|
|
$table->integer('idprogdi')->nullable();
|
|
$table->integer('idprogram')->nullable();
|
|
$table->integer('idkurikulum')->nullable();
|
|
$table->integer('idpa')->nullable();
|
|
$table->smallInteger('stataktif')->default(1);
|
|
$table->smallInteger('jalur_masuk')->nullable();
|
|
});
|
|
$schema->create('t_angkatanmhs', function (Blueprint $table) {
|
|
$table->integer('idangkatan')->primary();
|
|
$table->integer('tahun');
|
|
$table->smallInteger('semester')->nullable();
|
|
});
|
|
$schema->create('t_periodekuliah', function (Blueprint $table) {
|
|
$table->integer('idperiode')->primary();
|
|
$table->char('thakad', 9);
|
|
$table->smallInteger('semester');
|
|
$table->smallInteger('perkuliahan');
|
|
});
|
|
$schema->create('t_mastermk', function (Blueprint $table) {
|
|
$table->integer('idmastermk')->primary();
|
|
$table->string('namamk');
|
|
});
|
|
$schema->create('t_matakuliah', function (Blueprint $table) {
|
|
$table->integer('idmatakuliah')->primary();
|
|
$table->integer('idmastermk')->nullable();
|
|
$table->string('kodemk');
|
|
$table->string('namamk');
|
|
$table->smallInteger('sks');
|
|
$table->smallInteger('semester')->nullable();
|
|
$table->double('nilailulus')->nullable();
|
|
$table->smallInteger('tipe')->nullable();
|
|
});
|
|
$schema->create('t_transkrip', function (Blueprint $table) {
|
|
$table->increments('idtranskrip');
|
|
$table->integer('idmahasiswa');
|
|
$table->integer('idmatakuliah');
|
|
$table->double('nilaimutu')->nullable();
|
|
$table->string('nilaihuruf')->nullable();
|
|
});
|
|
$schema->create('t_jadwal', function (Blueprint $table) {
|
|
$table->integer('idjadwal')->primary();
|
|
$table->integer('idmatakuliah');
|
|
$table->integer('idperiode');
|
|
$table->string('kelas')->default('A');
|
|
$table->smallInteger('kapasitas')->default(0);
|
|
$table->boolean('flag_cetak')->default(false);
|
|
$table->integer('idprogdi')->nullable();
|
|
});
|
|
$schema->create('t_kst', function (Blueprint $table) {
|
|
$table->increments('idkst');
|
|
$table->integer('idmahasiswa');
|
|
$table->integer('idjadwal');
|
|
$table->integer('idmatakuliah');
|
|
$table->integer('idperiode');
|
|
$table->double('nilaitotal')->nullable();
|
|
$table->double('nilaimutu')->nullable();
|
|
$table->string('nilaihuruf')->nullable();
|
|
$table->smallInteger('stat')->nullable()->default(0);
|
|
$table->string('cname', 20)->nullable();
|
|
$table->string('uname', 20)->nullable();
|
|
$table->timestamp('tanggal')->nullable();
|
|
$table->unique(['idmahasiswa', 'idmatakuliah', 'idperiode']);
|
|
});
|
|
// KRS: periode aktif prodi, masa pengisian, registrasi, kurikulum, dan detail jadwal kelas.
|
|
$schema->create('t_periodekuliahaktif', function (Blueprint $table) {
|
|
$table->integer('idprogdi');
|
|
$table->integer('idperiode');
|
|
});
|
|
$schema->create('t_periodelirs', function (Blueprint $table) {
|
|
$table->increments('idperiodelirs');
|
|
$table->integer('idprogdi');
|
|
$table->integer('idperiode');
|
|
$table->integer('idangkatan');
|
|
$table->date('mulai');
|
|
$table->date('selesai');
|
|
});
|
|
$schema->create('t_histori_mahasiswa', function (Blueprint $table) {
|
|
$table->increments('idhistori');
|
|
$table->integer('idmahasiswa');
|
|
$table->integer('idperiode');
|
|
$table->smallInteger('stat_akd_akhir')->nullable();
|
|
$table->double('ips')->nullable();
|
|
});
|
|
$schema->create('t_kurikulum', function (Blueprint $table) {
|
|
$table->integer('idkurikulum')->primary();
|
|
$table->integer('idprogdi');
|
|
$table->integer('idprogram');
|
|
});
|
|
$schema->create('t_jadwalkurikulum', function (Blueprint $table) {
|
|
$table->increments('idjadwalkurikulum');
|
|
$table->integer('idjadwal');
|
|
$table->integer('idkurikulum');
|
|
});
|
|
$schema->create('t_jadwaltemu', function (Blueprint $table) {
|
|
$table->increments('idjadwaltemu');
|
|
$table->integer('idjadwal');
|
|
$table->smallInteger('hari');
|
|
$table->time('mulai');
|
|
$table->time('selesai');
|
|
});
|
|
$schema->create('t_ruang', function (Blueprint $table) {
|
|
$table->integer('idruang')->primary();
|
|
$table->string('namaruang');
|
|
});
|
|
$schema->create('t_jadwalruangkuliah', function (Blueprint $table) {
|
|
$table->increments('idjadwalruang');
|
|
$table->integer('idjadwaltemu');
|
|
$table->integer('idruang');
|
|
});
|
|
$schema->create('t_jadwaldosen', function (Blueprint $table) {
|
|
$table->increments('idjadwaldosen');
|
|
$table->integer('idjadwal');
|
|
$table->integer('iddosen');
|
|
$table->smallInteger('dosenke')->default(1);
|
|
});
|
|
$schema->create('t_dosen', function (Blueprint $table) {
|
|
$table->integer('idpegawai')->primary();
|
|
$table->integer('idjabatanfungsional')->nullable();
|
|
$table->integer('idprogdi')->nullable();
|
|
});
|
|
$schema->create('t_statuspegawai', function (Blueprint $table) {
|
|
$table->smallInteger('idstatuspegawai')->primary();
|
|
$table->string('statuspegawai');
|
|
});
|
|
$schema->create('t_jabatanbagian', function (Blueprint $table) {
|
|
$table->integer('idjabatanbagian')->primary();
|
|
$table->integer('idbagian');
|
|
});
|
|
$schema->create('t_jabatanpegawai', function (Blueprint $table) {
|
|
$table->increments('idjabatan');
|
|
$table->integer('idpegawai');
|
|
$table->integer('idjabatanbagian');
|
|
$table->smallInteger('aktif')->default(1);
|
|
});
|
|
$schema->create('t_jabatanfungsional', function (Blueprint $table) {
|
|
$table->integer('idjabatanfungsional')->primary();
|
|
$table->string('jabatan');
|
|
});
|
|
$schema->create('t_otoritas', function (Blueprint $table) {
|
|
$table->integer('idotoritas')->primary();
|
|
$table->string('otoritas');
|
|
});
|
|
$schema->create('t_otoritasuser', function (Blueprint $table) {
|
|
$table->increments('idotoritasuser');
|
|
$table->integer('iduser');
|
|
$table->integer('idotoritas');
|
|
});
|
|
$schema->create('t_unituser', function (Blueprint $table) {
|
|
$table->increments('idunituser');
|
|
$table->integer('iduser');
|
|
$table->integer('idfak')->nullable();
|
|
$table->integer('idprogdi')->nullable();
|
|
});
|
|
$schema->create('t_bagian', function (Blueprint $table) {
|
|
$table->integer('idbagian')->primary();
|
|
$table->integer('idbagian_induk')->default(0);
|
|
$table->smallInteger('idjenisbagian')->nullable();
|
|
$table->string('namabagian');
|
|
});
|
|
$schema->create('t_jenisprogram', function (Blueprint $table) {
|
|
$table->integer('idprogram')->primary();
|
|
$table->string('program');
|
|
});
|
|
$schema->create('t_jalurmasuk', function (Blueprint $table) {
|
|
$table->integer('idjalur_siakad')->primary();
|
|
$table->string('nama_jalur_masuk');
|
|
});
|
|
$schema->create('t_stat_akademik', function (Blueprint $table) {
|
|
$table->integer('idstat_akd')->primary();
|
|
$table->string('status_akademik');
|
|
});
|
|
$schema->create('t_jenjangprogdi', function (Blueprint $table) {
|
|
$table->integer('idjenjang')->primary();
|
|
$table->string('kdjenjang');
|
|
$table->char('kode', 1);
|
|
});
|
|
// Data prodi PDDIKTI: jenjang per prodi (idbagianuntan); bisa ganda seperti di DB asli.
|
|
$schema->create('pdpt_tmst_program_studi', function (Blueprint $table) {
|
|
$table->string('kode_program_studi');
|
|
$table->integer('idbagianuntan')->nullable();
|
|
$table->char('kode_jenjang_pendidikan', 1)->nullable();
|
|
});
|
|
}
|
|
|
|
private function seedLegacyData(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$pegawai = fn (int $id, string $nip, string $nama, string $depan = '', string $belakang = '', ?string $nidn = null): array => [
|
|
'idpegawai' => $id, 'nip' => $nip, 'nipnasional' => null, 'nidn' => $nidn, 'nama' => $nama,
|
|
'gelardepan' => $depan, 'gelarbelakang' => $belakang, 'email' => null,
|
|
];
|
|
$account = fn (int $id, string $username, string $password, int $identitas, int $jenis, int $status = 0): array => [
|
|
'iduser' => $id, 'username' => static::legacyEncode($username), 'passwd' => static::legacyEncode($password),
|
|
'identitas' => $identitas, 'jenis' => $jenis, 'status' => $status,
|
|
];
|
|
|
|
$db->table('t_pegawai')->insert([
|
|
$pegawai(10, '198001012005011001', 'Budi Santoso', 'Dr.', ', S.T., M.T.'),
|
|
$pegawai(11, '197501012000031002', 'Siti Aminah', '', 'M.Pd.', '0001017501'),
|
|
$pegawai(12, '196001011990011001', 'Akun Beku'),
|
|
$pegawai(13, '199001012015011001', 'Tanpa Otoritas'),
|
|
$pegawai(14, '197001011995011001', 'Admin Pusat'),
|
|
]);
|
|
$db->table('t_angkatanmhs')->insert(['idangkatan' => 150, 'tahun' => 2019, 'semester' => 1]);
|
|
$db->table('t_mahasiswa')->insert(['idmahasiswa' => 500, 'nim' => 'D1041191001', 'nama' => 'Rina Lestari', 'email_mhs' => null, 'idangkatan' => 150, 'idprogdi' => 21]);
|
|
$db->table('t_jabatanfungsional')->insert(['idjabatanfungsional' => 3, 'jabatan' => 'Lektor']);
|
|
$db->table('t_dosen')->insert(['idpegawai' => 11, 'idjabatanfungsional' => 3]);
|
|
$db->table('t_otoritas')->insert([['idotoritas' => 7, 'otoritas' => 'Staff Fakultas'], ['idotoritas' => 1, 'otoritas' => 'Administrator Pusat']]);
|
|
$db->table('t_otoritasuser')->insert([['iduser' => 1, 'idotoritas' => 7], ['iduser' => 3, 'idotoritas' => 1], ['iduser' => 6, 'idotoritas' => 1]]);
|
|
// t_jenisbagian: 1 fakultas, 2 jurusan, 3 program studi.
|
|
$db->table('t_bagian')->insert([
|
|
['idbagian' => 5, 'idbagian_induk' => 0, 'idjenisbagian' => 1, 'namabagian' => 'Fakultas Teknik'],
|
|
['idbagian' => 20, 'idbagian_induk' => 5, 'idjenisbagian' => 2, 'namabagian' => 'Teknik Elektro'],
|
|
['idbagian' => 21, 'idbagian_induk' => 20, 'idjenisbagian' => 3, 'namabagian' => 'Teknik Informatika'],
|
|
]);
|
|
$db->table('t_unituser')->insert(['iduser' => 1, 'idfak' => 5, 'idprogdi' => null]);
|
|
|
|
$db->table('t_account')->insert([
|
|
$account(1, '198001012005011001', 'rahasia-staf', 10, 0),
|
|
$account(2, '197501012000031002', 'rahasia-dosen', 11, 0),
|
|
$account(3, '196001011990011001', 'rahasia-beku', 12, 0, status: 1),
|
|
$account(4, '199001012015011001', 'rahasia-pegawai', 13, 0),
|
|
$account(5, 'D1041191001', 'rahasia-mhs', 500, 1),
|
|
$account(6, '197001011995011001', 'rahasia-super', 14, 0),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Nilai mahasiswa 500 (angkatan 2019 ganjil): 2019/2020 Ganjil (362), Genap (365), Genap pendek (366).
|
|
*
|
|
* Dihitung: Algoritma A (3), Basis Data B (2), Jaringan Komputer B+ (3), Etika Profesi C (3, batas lulus 2,25).
|
|
* Algoritma diulang di semester pendek dengan C: transkrip memakai A. Tidak dihitung: Kalkulus (belum terbit),
|
|
* Skripsi (tipe 2 tanpa nilai), Statistika (batal), dan nilai mahasiswa 501.
|
|
* KHS: IPS 362 = 3,60; 365 = 1,95 (Kalkulus dihitung 0); 366 = 2,00. Transkrip: 11 SKS, lulus 8, IPK 3,07.
|
|
*/
|
|
protected function seedLegacyGrades(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
|
|
$db->table('t_periodekuliah')->insertOrIgnore([
|
|
['idperiode' => 362, 'thakad' => '2019/2020', 'semester' => 1, 'perkuliahan' => 1],
|
|
['idperiode' => 365, 'thakad' => '2019/2020', 'semester' => 2, 'perkuliahan' => 1],
|
|
['idperiode' => 366, 'thakad' => '2019/2020', 'semester' => 2, 'perkuliahan' => 2],
|
|
]);
|
|
|
|
$courses = [
|
|
// id => [kode, nama, sks, tipe, batas lulus, master]
|
|
1 => ['IF101', 'Algoritma', 3, 0, 1, 1],
|
|
2 => ['IF102', 'Basis Data', 2, 0, 1, 2],
|
|
3 => ['IF201', 'Jaringan Komputer', 3, 0, 1, 3],
|
|
4 => ['IF202', 'Kalkulus', 2, 0, 1, 4],
|
|
5 => ['IF900', 'Skripsi', 6, 2, 1, 5],
|
|
6 => ['IF203', 'Statistika', 3, 0, 1, 6],
|
|
7 => ['IF301', 'Etika Profesi', 3, 0, 2.25, 7],
|
|
8 => ['IF999', 'Nilai Mahasiswa Lain', 3, 0, 1, 8],
|
|
9 => ['IF101P', 'Algoritma', 3, 0, 1, 1],
|
|
];
|
|
foreach ($courses as $id => [$kode, $nama, $sks, $tipe, $lulus, $master]) {
|
|
$db->table('t_mastermk')->insertOrIgnore(['idmastermk' => $master, 'namamk' => $nama]);
|
|
$db->table('t_matakuliah')->insert([
|
|
'idmatakuliah' => $id, 'idmastermk' => $master, 'kodemk' => $kode, 'namamk' => $nama,
|
|
'sks' => $sks, 'semester' => $id, 'nilailulus' => $lulus, 'tipe' => $tipe,
|
|
]);
|
|
}
|
|
|
|
// idjadwal = idmatakuliah
|
|
foreach ([1 => 362, 2 => 362, 3 => 365, 4 => 365, 5 => 365, 6 => 365, 7 => 366, 8 => 365, 9 => 366] as $id => $periode) {
|
|
$db->table('t_jadwal')->insert(['idjadwal' => $id, 'idmatakuliah' => $id, 'idperiode' => $periode, 'flag_cetak' => $id !== 4]);
|
|
}
|
|
|
|
$kst = fn (int $mhs, int $mk, int $periode, ?float $total, ?float $mutu, ?string $huruf, int $stat = 3): array => [
|
|
'idmahasiswa' => $mhs, 'idjadwal' => $mk, 'idmatakuliah' => $mk, 'idperiode' => $periode,
|
|
'nilaitotal' => $total, 'nilaimutu' => $mutu, 'nilaihuruf' => $huruf, 'stat' => $stat,
|
|
];
|
|
$db->table('t_kst')->insert([
|
|
$kst(500, 1, 362, 85, 4, 'A'),
|
|
$kst(500, 2, 362, 72.5, 3, 'B'),
|
|
$kst(500, 3, 365, 78, 3.25, 'B+'),
|
|
$kst(500, 4, 365, 91, 4, 'A'),
|
|
$kst(500, 5, 365, null, null, null),
|
|
$kst(500, 6, 365, 88, 4, 'A', stat: 2),
|
|
$kst(500, 7, 366, 60, 2, 'C'),
|
|
$kst(500, 9, 366, 61, 2, 'C'),
|
|
$kst(501, 8, 365, 95, 4, 'A'),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* KRS mahasiswa 500 pada periode aktif prodi 21: 2020/2021 Ganjil (368), kurikulum 900, dosen PA Siti Aminah.
|
|
*
|
|
* Sudah diambil: 301 Sistem Basis Data (3 SKS, menunggu) dan 302 Pemrograman Web (3 SKS, disetujui, sudah bernilai).
|
|
* Tersedia: 303 Kecerdasan Buatan (penuh, kuota 2), 304 Jaringan Lanjut (2 SKS), 305 Kerja Praktik (4 SKS),
|
|
* 306 Kelas Bentrok (2 SKS, ditolak f_inputlirs_new tiruan). 307 hanya untuk kurikulum prodi lain.
|
|
*/
|
|
protected function seedLegacyKrs(bool $open = true, bool $registered = true): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
|
|
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['idprogram' => 1, 'idkurikulum' => 900, 'idpa' => 11]);
|
|
$db->table('t_periodekuliah')->insert(['idperiode' => 368, 'thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1]);
|
|
$db->table('t_periodekuliahaktif')->insert(['idprogdi' => 21, 'idperiode' => 368]);
|
|
$db->table('t_periodelirs')->insert([
|
|
'idprogdi' => 21, 'idperiode' => 368, 'idangkatan' => 150,
|
|
'mulai' => now()->subDays($open ? 3 : 20)->toDateString(),
|
|
'selesai' => now()->addDays($open ? 3 : -10)->toDateString(),
|
|
]);
|
|
$db->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 500, 'idperiode' => 368, 'stat_akd_akhir' => $registered ? 1 : 0]);
|
|
$db->table('t_kurikulum')->insert([['idkurikulum' => 900, 'idprogdi' => 21, 'idprogram' => 1], ['idkurikulum' => 901, 'idprogdi' => 99, 'idprogram' => 1]]);
|
|
|
|
$classes = [
|
|
// idjadwal => [kode, nama, sks, kapasitas, kurikulum]
|
|
301 => ['IF311', 'Sistem Basis Data', 3, 40, 900],
|
|
302 => ['IF312', 'Pemrograman Web', 3, 0, 900],
|
|
303 => ['IF313', 'Kecerdasan Buatan', 3, 2, 900],
|
|
304 => ['IF314', 'Jaringan Lanjut', 2, 30, 900],
|
|
305 => ['IF315', 'Kerja Praktik', 4, 0, 900],
|
|
306 => ['IF316', 'Kelas Bentrok', 2, 0, 900],
|
|
307 => ['EK101', 'Kelas Prodi Lain', 3, 0, 901],
|
|
];
|
|
foreach ($classes as $id => [$kode, $nama, $sks, $kapasitas, $kurikulum]) {
|
|
$db->table('t_matakuliah')->insert(['idmatakuliah' => $id, 'kodemk' => $kode, 'namamk' => $nama, 'sks' => $sks, 'tipe' => 0]);
|
|
$db->table('t_jadwal')->insert(['idjadwal' => $id, 'idmatakuliah' => $id, 'idperiode' => 368, 'kelas' => 'A', 'kapasitas' => $kapasitas]);
|
|
$db->table('t_jadwalkurikulum')->insert(['idjadwal' => $id, 'idkurikulum' => $kurikulum]);
|
|
}
|
|
|
|
$db->table('t_ruang')->insert([['idruang' => 1, 'namaruang' => 'Lab Komputer 1'], ['idruang' => 2, 'namaruang' => 'B.2.1']]);
|
|
$db->table('t_jadwaltemu')->insert([
|
|
['idjadwaltemu' => 1, 'idjadwal' => 301, 'hari' => 1, 'mulai' => '07:30:00', 'selesai' => '09:10:00'],
|
|
['idjadwaltemu' => 2, 'idjadwal' => 304, 'hari' => 3, 'mulai' => '10:00:00', 'selesai' => '11:40:00'],
|
|
]);
|
|
$db->table('t_jadwalruangkuliah')->insert([['idjadwaltemu' => 1, 'idruang' => 1], ['idjadwaltemu' => 2, 'idruang' => 2]]);
|
|
$db->table('t_jadwaldosen')->insert([['idjadwal' => 301, 'iddosen' => 11, 'dosenke' => 1], ['idjadwal' => 304, 'iddosen' => 10, 'dosenke' => 1]]);
|
|
|
|
$kst = fn (int $mhs, int $jadwal, int $stat, ?string $huruf = null): array => [
|
|
'idmahasiswa' => $mhs, 'idjadwal' => $jadwal, 'idmatakuliah' => $jadwal, 'idperiode' => 368, 'stat' => $stat, 'nilaihuruf' => $huruf,
|
|
];
|
|
$db->table('t_kst')->insert([$kst(500, 301, 0), $kst(500, 302, 1, 'B'), $kst(501, 303, 1), $kst(502, 303, 1)]);
|
|
}
|
|
|
|
/**
|
|
* Ringkasan dashboard operator (akun 1) untuk prodi 21 Teknik Informatika dan 22 Teknik Sipil.
|
|
* Periode aktif 2020/2021 Ganjil (368); sebelumnya 2019/2020 Genap (365, 2 aktif). 371 belum berjalan, 366 pendek.
|
|
*
|
|
* Periode 368, semua prodi: aktif 3 (500, 502, 510), IPS rerata 3,00 dari 2 mahasiswa, baru 3 (angkatan 2020),
|
|
* lulus 1 (505), cuti 1 (501), belum berstatus 2 (503 tanpa histori, 511 histori kosong; 504 angkatan 2021 tidak dihitung).
|
|
* KRS: 3 dari 3 aktif sudah mengisi, 1 menunggu (500); masa pengisian hanya untuk prodi 21 (dibuka).
|
|
* Kelas: 602 tanpa jadwal dan nilai belum terbit; 603 hanya peserta batal; 604 tugas akhir tanpa jadwal.
|
|
*/
|
|
/**
|
|
* Pegawai untuk Portal > Pegawai (butuh seedLegacyOverview: akun 1 memegang prodi 21 dan 22, fakultas 5).
|
|
* Dalam cakupan: 11 Siti (dosen prodi 21, PA mahasiswa 500), 20 Andi (dosen prodi 22, tidak aktif),
|
|
* 21 Dewi (staf, jabatan aktif di fakultas 5), 24 Lina (dosen prodi 21). Di luar: 22 (prodi lain), 23 (jabatan lama).
|
|
*/
|
|
protected function seedLegacyEmployees(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
|
|
$db->table('t_statuspegawai')->insert([
|
|
['idstatuspegawai' => 1, 'statuspegawai' => 'tanpa status'],
|
|
['idstatuspegawai' => 2, 'statuspegawai' => 'Tetap'],
|
|
['idstatuspegawai' => 3, 'statuspegawai' => 'Tidak Tetap'],
|
|
]);
|
|
$db->table('t_pegawai')->where('idpegawai', 11)->update(['kelamin' => 2, 'hp' => '081234567890', 'email' => 'siti@untan.ac.id', 'idstatuspegawai' => 2]);
|
|
$db->table('t_pegawai')->insert([
|
|
['idpegawai' => 20, 'nip' => '198502022010121001', 'nama' => 'Andi Wijaya', 'gelardepan' => '', 'gelarbelakang' => 'S.T., M.Eng.', 'nidn' => '0002028501', 'kelamin' => 1, 'hp' => '', 'telepon' => null, 'statusaktif' => 0, 'idstatuspegawai' => 3],
|
|
['idpegawai' => 21, 'nip' => '199003032015032001', 'nama' => 'Dewi Kartika', 'gelardepan' => null, 'gelarbelakang' => null, 'nidn' => null, 'kelamin' => 2, 'hp' => ' ', 'telepon' => '0561-123456', 'statusaktif' => 1, 'idstatuspegawai' => null],
|
|
['idpegawai' => 22, 'nip' => '197001012000011099', 'nama' => 'Joko Prodi Lain', 'gelardepan' => null, 'gelarbelakang' => null, 'nidn' => null, 'kelamin' => 1, 'hp' => null, 'telepon' => null, 'statusaktif' => 1, 'idstatuspegawai' => 2],
|
|
['idpegawai' => 23, 'nip' => '196501011990011023', 'nama' => 'Rudi Mantan', 'gelardepan' => null, 'gelarbelakang' => null, 'nidn' => null, 'kelamin' => 1, 'hp' => null, 'telepon' => null, 'statusaktif' => 1, 'idstatuspegawai' => 2],
|
|
['idpegawai' => 24, 'nip' => 'lina', 'nama' => 'Lina', 'gelardepan' => null, 'gelarbelakang' => null, 'nidn' => null, 'kelamin' => 0, 'hp' => null, 'telepon' => null, 'statusaktif' => 3, 'idstatuspegawai' => 1],
|
|
]);
|
|
$db->table('t_dosen')->where('idpegawai', 11)->update(['idprogdi' => 21]);
|
|
$db->table('t_dosen')->insert([['idpegawai' => 20, 'idprogdi' => 22], ['idpegawai' => 22, 'idprogdi' => 99], ['idpegawai' => 24, 'idprogdi' => 21]]);
|
|
$db->table('t_jabatanbagian')->insert([['idjabatanbagian' => 1, 'idbagian' => 5], ['idjabatanbagian' => 2, 'idbagian' => 5]]);
|
|
$db->table('t_jabatanpegawai')->insert([
|
|
['idpegawai' => 21, 'idjabatanbagian' => 1, 'aktif' => 1],
|
|
['idpegawai' => 23, 'idjabatanbagian' => 2, 'aktif' => 0],
|
|
]);
|
|
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['idpa' => 11]);
|
|
}
|
|
|
|
protected function seedLegacyOverview(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
|
|
$db->table('t_bagian')->insert(['idbagian' => 22, 'idbagian_induk' => 5, 'idjenisbagian' => 3, 'namabagian' => 'Teknik Sipil']);
|
|
$db->table('t_unituser')->insert([['iduser' => 1, 'idfak' => 5, 'idprogdi' => 21], ['iduser' => 1, 'idfak' => 5, 'idprogdi' => 22]]);
|
|
// insertOrIgnore: 365 dan 366 juga dibuat seedLegacyGrades().
|
|
$db->table('t_periodekuliah')->insertOrIgnore([
|
|
['idperiode' => 365, 'thakad' => '2019/2020', 'semester' => 2, 'perkuliahan' => 1],
|
|
['idperiode' => 366, 'thakad' => '2019/2020', 'semester' => 2, 'perkuliahan' => 2],
|
|
['idperiode' => 368, 'thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1],
|
|
['idperiode' => 371, 'thakad' => '2020/2021', 'semester' => 2, 'perkuliahan' => 1],
|
|
]);
|
|
$db->table('t_periodekuliahaktif')->insert([['idprogdi' => 21, 'idperiode' => 368], ['idprogdi' => 22, 'idperiode' => 368]]);
|
|
$db->table('t_periodelirs')->insert([
|
|
'idprogdi' => 21, 'idperiode' => 368, 'idangkatan' => 150,
|
|
'mulai' => now()->subDays(3)->toDateString(), 'selesai' => now()->addDays(3)->toDateString(),
|
|
]);
|
|
$db->table('t_angkatanmhs')->insert([['idangkatan' => 160, 'tahun' => 2020, 'semester' => 1], ['idangkatan' => 170, 'tahun' => 2021, 'semester' => 1]]);
|
|
|
|
$db->table('t_jenisprogram')->insert([['idprogram' => 1, 'program' => 'Reguler A'], ['idprogram' => 2, 'program' => 'Reguler B']]);
|
|
$db->table('t_jalurmasuk')->insert([['idjalur_siakad' => 1, 'nama_jalur_masuk' => 'SNMPTN'], ['idjalur_siakad' => 3, 'nama_jalur_masuk' => 'MANDIRI']]);
|
|
$db->table('t_jenjangprogdi')->insert([['idjenjang' => 2, 'kdjenjang' => 'S1', 'kode' => 'C'], ['idjenjang' => 1, 'kdjenjang' => 'D3', 'kode' => 'E']]);
|
|
$db->table('pdpt_tmst_program_studi')->insert([
|
|
['kode_program_studi' => '55201', 'idbagianuntan' => 21, 'kode_jenjang_pendidikan' => 'C'],
|
|
['kode_program_studi' => '55201L', 'idbagianuntan' => 21, 'kode_jenjang_pendidikan' => 'C'],
|
|
]);
|
|
$db->table('t_stat_akademik')->insert([
|
|
['idstat_akd' => 0, 'status_akademik' => 'Alpa Kuliah'], ['idstat_akd' => 1, 'status_akademik' => 'Aktif'],
|
|
['idstat_akd' => 2, 'status_akademik' => 'Cuti'], ['idstat_akd' => 3, 'status_akademik' => 'Lulus'],
|
|
]);
|
|
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['idprogram' => 1, 'jalur_masuk' => 1]);
|
|
|
|
// idmahasiswa => [idprogdi, idangkatan, stataktif, idprogram, jalur]; 506 mengundurkan diri (stataktif 3).
|
|
$students = [
|
|
501 => [21, 150, 1, 1, 1], 502 => [21, 160, 1, 1, 3], 503 => [21, 150, 1, 2, 3], 504 => [21, 170, 1, 1, 1],
|
|
505 => [21, 150, 2, 1, 1], 506 => [21, 150, 3, 1, 1], 510 => [22, 160, 1, 1, 1], 511 => [22, 160, 1, 1, 1],
|
|
];
|
|
foreach ($students as $id => [$prodi, $angkatan, $stat, $program, $jalur]) {
|
|
$db->table('t_mahasiswa')->insert([
|
|
'idmahasiswa' => $id, 'nim' => 'X'.$id, 'nama' => 'Mahasiswa '.$id, 'idprogdi' => $prodi,
|
|
'idangkatan' => $angkatan, 'stataktif' => $stat, 'idprogram' => $program, 'jalur_masuk' => $jalur,
|
|
]);
|
|
}
|
|
|
|
$histori = fn (int $mhs, int $periode, ?int $stat, ?float $ips = null): array => ['idmahasiswa' => $mhs, 'idperiode' => $periode, 'stat_akd_akhir' => $stat, 'ips' => $ips];
|
|
$db->table('t_histori_mahasiswa')->insert([
|
|
// IPS 365 belum direkap.
|
|
$histori(500, 365, 1), $histori(505, 365, 1),
|
|
$histori(500, 368, 1, 3.5), $histori(501, 368, 2), $histori(502, 368, 1, 0), $histori(505, 368, 3),
|
|
$histori(510, 368, 1, 2.5), $histori(511, 368, null),
|
|
]);
|
|
|
|
// idjadwal = idmatakuliah => [idprogdi, tipe, terbit, punya jadwal temu]
|
|
foreach ([601 => [21, 0, true, true], 602 => [22, 0, false, false], 603 => [21, 0, false, false], 604 => [21, 2, true, false]] as $id => [$prodi, $tipe, $terbit, $temu]) {
|
|
$db->table('t_matakuliah')->insert(['idmatakuliah' => $id, 'kodemk' => 'MK'.$id, 'namamk' => 'Kelas '.$id, 'sks' => 2, 'tipe' => $tipe]);
|
|
$db->table('t_jadwal')->insert(['idjadwal' => $id, 'idmatakuliah' => $id, 'idperiode' => 368, 'idprogdi' => $prodi, 'flag_cetak' => $terbit]);
|
|
if ($temu) {
|
|
$db->table('t_jadwaltemu')->insert(['idjadwal' => $id, 'hari' => 1, 'mulai' => '07:30:00', 'selesai' => '09:10:00']);
|
|
}
|
|
}
|
|
|
|
$kst = fn (int $mhs, int $jadwal, int $stat): array => ['idmahasiswa' => $mhs, 'idjadwal' => $jadwal, 'idmatakuliah' => $jadwal, 'idperiode' => 368, 'stat' => $stat];
|
|
$db->table('t_kst')->insert([$kst(500, 601, 0), $kst(502, 601, 1), $kst(502, 604, 1), $kst(510, 602, 1), $kst(501, 603, 2)]);
|
|
}
|
|
|
|
/** Tiruan f_inputlirs_new: jadwal 306 bentrok (pesan bergaya lama dengan "\n" literal); lainnya disisipkan. */
|
|
private function fakeInputLirs(mixed $idmahasiswa, mixed $idprogdi, mixed $idperiode, mixed $idjadwal, mixed $unused, mixed $kode, mixed $nama, mixed $kelas, mixed $cname, mixed $uname): string
|
|
{
|
|
if ((int) $idjadwal === 306) {
|
|
return ' - 1. Jadwal Matakuliah Bentrok Dengan Sistem Basis Data ( Senin 07:30 - 09:10 ).\n';
|
|
}
|
|
|
|
$db = DB::connection('untan');
|
|
$db->table('t_kst')->insert([
|
|
'idmahasiswa' => (int) $idmahasiswa,
|
|
'idjadwal' => (int) $idjadwal,
|
|
'idmatakuliah' => (int) $db->table('t_jadwal')->where('idjadwal', $idjadwal)->value('idmatakuliah'),
|
|
'idperiode' => (int) $idperiode,
|
|
'cname' => $cname,
|
|
'uname' => $uname,
|
|
'tanggal' => now(),
|
|
]);
|
|
|
|
return 'Data berhasil di inputkan';
|
|
}
|
|
|
|
/** Tiruan f_hapuslirs (act 0): hanya milik sendiri dan belum bernilai; '' berarti berhasil. */
|
|
private function fakeHapusLirs(mixed $idkst, mixed $idmahasiswa, mixed ...$unused): string
|
|
{
|
|
$db = DB::connection('untan');
|
|
$row = $db->table('t_kst')->where('idkst', $idkst)->first();
|
|
|
|
if ($row === null || (int) $row->idmahasiswa !== (int) $idmahasiswa) {
|
|
return 'Tidak Boleh Menghapus LIRS Mahasiswa Lain !';
|
|
}
|
|
|
|
if ($row->nilaihuruf !== null || $row->nilaimutu !== null) {
|
|
return 'Tidak Boleh Menghapus LIRS ini !';
|
|
}
|
|
|
|
$db->table('t_kst')->where('idkst', $idkst)->delete();
|
|
|
|
return '';
|
|
}
|
|
}
|