Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sibiling
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Syaifur
sibiling
Commits
442731c8
Commit
442731c8
authored
Sep 05, 2024
by
syaifurplus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix import dapodik guru dan siswa
parent
8b70fdcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
169 additions
and
2 deletions
+169
-2
ImportDapodikController.php
...Http/Controllers/Admin/Import/ImportDapodikController.php
+167
-1
web.php
routes/web.php
+2
-1
No files found.
app/Http/Controllers/Admin/Import/ImportDapodikController.php
View file @
442731c8
...
...
@@ -16,7 +16,7 @@ use App\Models\Perpus\SekolahModel;
class
ImportDapodikController
extends
Controller
{
public
function
importDapodik
()
public
function
importDapodik
Guru
()
{
$dataGuruTemp
=
DapodikGuruModel
::
select
([
'nama'
,
'nip'
,
'jenis_ptk'
,
'hp'
,
'email'
,
...
...
@@ -101,4 +101,170 @@ class ImportDapodikController extends Controller
'hasil'
=>
$importResults
,
]);
}
public
function
importDapodikSiswa
()
{
$dataPesertaDidik
=
DapodikSiswaModel
::
select
([
'nama'
,
'nisn'
,
'tempat_lahir'
,
'tanggal_lahir'
,
'agama'
,
'alamat'
,
'rt'
,
'rw'
,
'dusun'
,
'kelurahan'
,
'kecamatan'
,
'kode_pos'
,
'jenis_tinggal'
,
'telepon'
,
'hp'
,
'email'
,
'nama_ayah'
,
'pekerjaan_ayah'
,
'rombel_saat_ini'
])
->
get
();
$importResults
=
[
'berhasil'
=>
0
,
'gagal'
=>
0
];
$importResults
=
[
'import_tingkat'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'import_jurusan'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'import_index'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'import_siswa'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'import_siswa_mutasi'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
'import_siswa_ortu'
=>
[
'berhasil'
=>
0
,
'gagal'
=>
0
],
];
$sekolah
=
DB
::
table
(
'perpus_sekolah'
)
->
where
(
'id'
,
1
)
->
first
();
// dummy
$dataPesertaDidik
->
map
(
function
(
$peserta
)
use
(
&
$importResults
,
$sekolah
)
{
try
{
list
(
$kelas
,
$jurusan
,
$kodeKelas
)
=
explode
(
'-'
,
$peserta
->
rombel_saat_ini
);
$kelasId
=
DB
::
table
(
'dummy_perpus_kelas'
)
->
where
(
'nama'
,
$kelas
)
->
value
(
'id'
);
if
(
!
$kelasId
)
{
$kelasId
=
DB
::
table
(
'dummy_perpus_kelas'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'nama'
=>
$kelas
,
]);
$importResults
[
'import_tingkat'
][
'berhasil'
]
++
;
}
$jurusanId
=
DB
::
table
(
'dummy_perpus_jurusan'
)
->
where
(
'nama'
,
$jurusan
)
->
value
(
'id'
);
if
(
!
$jurusanId
)
{
$jurusanId
=
DB
::
table
(
'dummy_perpus_jurusan'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'nama'
=>
$jurusan
,
]);
$importResults
[
'import_jurusan'
][
'berhasil'
]
++
;
}
$kelasKodeId
=
DB
::
table
(
'dummy_perpus_kelasKode'
)
->
where
([
[
'nama'
,
'='
,
$kodeKelas
],
[
'idPSekolah'
,
'='
,
1
],
// dummy
[
'idPJurusan'
,
'='
,
$jurusanId
],
[
'idPKelas'
,
'='
,
$kelasId
],
])
->
value
(
'id'
);
if
(
!
$kelasKodeId
)
{
$kelasKodeId
=
DB
::
table
(
'dummy_perpus_kelasKode'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'idPJurusan'
=>
$jurusanId
,
'idPKelas'
=>
$kelasId
,
'nama'
=>
$kodeKelas
,
]);
$importResults
[
'import_index'
][
'berhasil'
]
++
;
}
$existingSiswa
=
DB
::
table
(
'dummy_siswa'
)
->
where
(
'nisn'
,
$peserta
->
nisn
)
->
first
();
if
(
!
$existingSiswa
)
{
$alamatLengkap
=
$peserta
->
alamat
.
', RT: '
.
(
$peserta
->
rt
??
'-'
)
.
', RW: '
.
(
$peserta
->
rw
??
'-'
)
.
', Dusun: '
.
(
$peserta
->
dusun
??
'-'
)
.
', Kelurahan: '
.
(
$peserta
->
kelurahan
??
'-'
)
.
', Kecamatan: '
.
(
$peserta
->
kecamatan
??
'-'
)
.
', Kode Pos: '
.
(
$peserta
->
kode_pos
??
'-'
);
$idMTempat
=
$this
->
getTempatId
(
$peserta
->
jenis_tinggal
);
$idMAgama
=
$this
->
getAgamaId
(
$peserta
->
agama
);
$siswaId
=
DB
::
table
(
'dummy_siswa'
)
->
insertGetId
([
'idPSekolah'
=>
1
,
// dummy
'idPKKode'
=>
$kelasKodeId
,
'idMAgama'
=>
$idMAgama
,
'idPPeriode'
=>
$sekolah
->
idPPeriode
,
'idMStatus'
=>
1
,
'nisn'
=>
$peserta
->
nisn
??
'-'
,
'nama'
=>
$peserta
->
nama
,
'lahir_tanggal'
=>
$peserta
->
tanggal_lahir
,
'lahir_tempat'
=>
$peserta
->
tempat_lahir
,
'idPPKelas'
=>
$kelasId
,
'idPPStatus'
=>
1
,
'idMTempat'
=>
$idMTempat
,
'email'
=>
$peserta
->
email
??
'-'
,
'telp'
=>
$peserta
->
hp
??
$peserta
->
telepon
??
'-'
,
'alamat'
=>
$alamatLengkap
,
]);
$importResults
[
'import_siswa'
][
'berhasil'
]
++
;
DB
::
table
(
'dummy_siswa_mutasi'
)
->
insert
([
'idSiswa'
=>
$siswaId
,
'idPKKode'
=>
$kelasKodeId
,
'idPPeriode'
=>
$sekolah
->
idPPeriode
,
'idMStatus'
=>
1
,
]);
$importResults
[
'import_siswa_mutasi'
][
'berhasil'
]
++
;
$idMPekerjaan
=
$this
->
getPekerjaanId
(
$peserta
->
pekerjaan_ayah
);
DB
::
table
(
'dummy_ortu'
)
->
insert
([
'idPSekolah'
=>
1
,
'idSiswa'
=>
$siswaId
,
'idMPekerjaan'
=>
$idMPekerjaan
,
'nama'
=>
$peserta
->
nama_ayah
,
'alamat'
=>
$alamatLengkap
,
]);
$importResults
[
'import_siswa_ortu'
][
'berhasil'
]
++
;
}
}
catch
(
\Exception
$e
)
{
$importResults
[
'import_tingkat'
][
'gagal'
]
++
;
$importResults
[
'import_jurusan'
][
'gagal'
]
++
;
$importResults
[
'import_index'
][
'gagal'
]
++
;
$importResults
[
'import_siswa'
][
'gagal'
]
++
;
$importResults
[
'import_siswa_mutasi'
][
'gagal'
]
++
;
$importResults
[
'import_siswa_ortu'
][
'gagal'
]
++
;
}
});
return
response
()
->
json
(
$importResults
);
}
private
function
getTempatId
(
$jenisTinggal
)
{
$tempatMapping
=
[
'Bersama orang tua'
=>
1
,
'Wali'
=>
2
,
'Asrama'
=>
3
,
'Kost'
=>
4
,
];
return
$tempatMapping
[
$jenisTinggal
]
??
1
;
}
private
function
getAgamaId
(
$agama
)
{
$agamaMapping
=
[
'Islam'
=>
1
,
'Kristen'
=>
2
,
'Budha'
=>
3
,
'Konghucu'
=>
4
,
'Katolik'
=>
5
,
'Hindu'
=>
6
,
'Lainnya'
=>
0
];
return
$agamaMapping
[
$agama
]
??
0
;
}
private
function
getPekerjaanId
(
$pekerjaan
)
{
$pekerjaanMapping
=
[
'Guru'
=>
1
,
'Dosen'
=>
2
,
'PNS/TNI/POLRI'
=>
3
,
'BUMN'
=>
4
,
'Swasta'
=>
5
,
'Wiraswasta'
=>
6
,
];
if
(
!
isset
(
$pekerjaanMapping
[
$pekerjaan
]))
{
$idPekerjaan
=
DB
::
table
(
'master_pekerjaan'
)
->
insertGetId
([
'nama'
=>
$pekerjaan
,
]);
return
$idPekerjaan
;
}
return
$pekerjaanMapping
[
$pekerjaan
];
}
}
\ No newline at end of file
routes/web.php
View file @
442731c8
...
...
@@ -29,7 +29,8 @@ Route::get('admin/dashboard', 'Admin\DashboardController@index')->name('dashboar
Route
::
middleware
([
'login:1,2'
])
->
group
(
function
()
{
Route
::
get
(
'/import-dapodik'
,
'Admin\Import\ImportDapodikController@importDapodik'
);
Route
::
get
(
'/import-dapodik-guru'
,
'Admin\Import\ImportDapodikController@importDapodikGuru'
);
Route
::
get
(
'/import-dapodik-siswa'
,
'Admin\Import\ImportDapodikController@importDapodikSiswa'
);
Route
::
prefix
(
'admin/master/sekolah'
)
->
group
(
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment