|
|
- <?php
- include "koneksi.php";
-
-
-
- $data = new \stdClass();
-
- $arr = array();
- $arr1 = array();
-
- $nim = $_POST['nim'];
-
-
- //-------------------------------------------Get Mahasiswa----------------------------------------------
- $sql = "select * from vw_info_mhs_perwalian where nim = '$nim'";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $mahasiswa[] = $myRow;
- }
-
- $angkatan = $mahasiswa[0]['angkatan'];
- //------------------------------------------------------------------------------------------------------
-
-
-
- //-------------------------------------Cek Kampus----------------------------------------------------
- $sql = "select bol_jimbaran from mhs_mf where str_nim = '$nim'";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $isJimbaran_a[] = $myRow;
- }
-
- $isJimbaran = $isJimbaran_a[0]['bol_jimbaran'];
-
- if ($isJimbaran == 1){
- $max = 25;
- }else{
- $max = 35;
- }
- //------------------------------------------------------------------------------------------------------
-
-
-
- //-------------------------------------Cek Kelas Malam----------------------------------------------------
-
- $sql = "select * from kelas_malam where str_t_ajaran ='2018/2019' and bol_semester = '1' and str_nim = '$nim'";
- $rs=odbc_exec($conn,$sql);
-
- if (odbc_fetch_array( $rs ) == null)
- $ismalam = '0';
- else
- $ismalam = '1';
- //------------------------------------------------------------------------------------------------------
-
-
-
-
- //-------------------------------------Cek karyawan----------------------------------------------------
- $sql = "select bol_sts_kelas from mhs_mf where str_nim = '$nim'";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $karyawan[] = $myRow;
- }
-
- if ($karyawan[0]['bol_sts_kelas'] == '1'){
- $ismalam = '1';
- }else if ($karyawan[0]['bol_sts_kelas'] == '3'){
- $ismalam = '1';
- }else{
- $ismalam = '0';
- }
- //------------------------------------------------------------------------------------------------------
-
-
-
-
- //------------------------------------------Show Shcedules----------------------------------------------
- if ($angkatan == '2018'){
- $sql = "select A.str_kd_perwalian,A.tgl_perwalian,A.str_jam_perwalian,str_angkatan,C.jml
- from perwalian_jadual A inner join SESI_2018_OFF C
- on A.str_kd_perwalian = C.str_kd_perwalian
- where A.str_thn_ajaran='2018/2019' and A.bol_semester='1' and A.bol_malam = '$ismalam' and A.bol_jimbaran = '$isJimbaran'
- and jml <'$max' and A.str_angkatan = '$angkatan'";
-
- $rs=odbc_exec($conn,$sql);
- $count = 0;
- while($myRow = odbc_fetch_array( $rs )){
- array_push($arr, $myRow['jml']);
- array_push($arr1, $myRow['str_kd_perwalian']);
- }
-
- }else{
- $sql = "select A.str_kd_perwalian,A.tgl_perwalian,A.str_jam_perwalian,str_angkatan,C.jml
- from perwalian_jadual A inner join SESI_2018_OFF C
- on A.str_kd_perwalian = C.str_kd_perwalian
- where A.str_thn_ajaran='2018/2019' and A.bol_semester='1' and A.bol_malam = '$ismalam' and A.bol_jimbaran = '$isJimbaran' and A.tgl_perwalian = '2019/02/13'
- and jml <='150' and (A.str_angkatan = '$angkatan' or A.str_angkatan = '9999')";
-
- $rs=odbc_exec($conn,$sql);
- $count = 0;
- while($myRow = odbc_fetch_array( $rs )){
- array_push($arr, $myRow['jml']);
- array_push($arr1, $myRow['str_kd_perwalian']);
- }
- }
-
- //------------------------------------------------------------------------------------------------------
-
-
- //------------------------------------------Selection Sort----------------------------------------------
- for($i=0; $i<count($arr)-1; $i++) {
- $min = $i;
- for($j=$i+1; $j<count($arr); $j++) {
- if ($arr[$j]<$arr[$min]) {
- $min = $j;
- }
- }
- $backup_old_data_right_value = $arr[$min];
- $arr[$min] = $arr[$i];
- $arr[$i] = $backup_old_data_right_value;
-
- $backup_old_data_right_value = $arr1[$min];
- $arr1[$min] = $arr1[$i];
- $arr1[$i] = $backup_old_data_right_value;
- }
- //------------------------------------------------------------------------------------------------------
-
- //============================================================================================================
- //============================================================================================================
- //============================================================================================================
- //============================================================================================================
-
- //-------------------------------------------Cek Jadwal Kosong----------------------------------------------
- $sql = "select * from perwalian_mhs where str_nim = '$nim' and str_semester = (select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1'))";
- $rs=odbc_exec($conn,$sql);
-
- if (odbc_fetch_array( $rs ) == null){
- echo ("insert");
-
- //-------------------------------------------Get Romawi----------------------------------------------
- $sql = "select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1') as semester_romawi";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $romawi_a[] = $myRow;
- }
-
- $romawi = $romawi_a[0]['semester_romawi'];
- //---------------------------------------------------------------------------------------------------
-
-
- //-------------------------------------------Get Bol Semester----------------------------------------
- $sql = "select dbo.wGetBolSemester('$romawi') as bol_semester";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $bol_semester_a[] = $myRow;
- }
-
- $bol_semester = $bol_semester_a[0]['bol_semester'];
- //---------------------------------------------------------------------------------------------------
-
-
- //-------------------------------------------Get Semester--------------------------------------------
- $sql = "select dbo.xSinakGetSemesterMahasiswa1('$nim','2018/2019','1') as semester";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $semester_a[] = $myRow;
- }
-
- $semester = $semester_a[0]['semester'];
- //---------------------------------------------------------------------------------------------------
-
-
- //---------------------------------------------Insert-------------------------------------------------
- $sql = "insert into perwalian_mhs (str_nim, str_thn_ajaran, str_semester, bol_semester, num_no_perwalian, str_angkatan, str_kd_smt, str_kd_perwalian, num_urut, bol_cetak, tgl_perwalian, str_jam_perwalian, str_kd_perwalian_history, str_token_perwalian)
- VALUES ('$nim', '2018/2019', '$romawi', '$bol_semester','0', '$angkatan', '$semester', '$arr1[0]', '0', '0', '', '', '', '')";
-
- if(odbc_exec($conn,$sql))
- $data = 'ok';
- else
- $data = 'fail';
- }else{
- echo ("update");
- //-------------------------------------------Get Romawi----------------------------------------------
- $sql = "select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1') as semester_romawi";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $romawi_a[] = $myRow;
- }
-
- $romawi = $romawi_a[0]['semester_romawi'];
- //---------------------------------------------------------------------------------------------------
-
-
- //-------------------------------------------Get Bol Semester----------------------------------------
- $sql = "select dbo.wGetBolSemester('$romawi') as bol_semester";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $bol_semester_a[] = $myRow;
- }
-
- $bol_semester = $bol_semester_a[0]['bol_semester'];
- //---------------------------------------------------------------------------------------------------
-
-
- //-------------------------------------------Get Semester--------------------------------------------
- $sql = "select dbo.xSinakGetSemesterMahasiswa1('$nim','2018/2019','1') as semester";
- $rs=odbc_exec($conn,$sql);
-
- while($myRow = odbc_fetch_array( $rs )){
- $semester_a[] = $myRow;
- }
-
- $semester = $semester_a[0]['semester'];
- //---------------------------------------------------------------------------------------------------
-
- //--------------------------------------------Update-------------------------------------------------
- $sql = "UPDATE perwalian_mhs
- SET str_nim = '$nim', str_thn_ajaran = '2018/2019', str_semester = '$romawi', bol_semester = '$bol_semester', num_no_perwalian = '0', str_angkatan = '$angkatan', str_kd_smt = '$semester', str_kd_perwalian = '$arr1[0]', num_urut = '0', bol_cetak = '0', tgl_perwalian = '', str_jam_perwalian='', str_kd_perwalian_history=''
- where str_nim = '$nim' and str_semester = '$romawi'";
-
- if(odbc_exec($conn,$sql))
- $data = 'ok';
- else
- $data = 'fail';
- }
-
- header("location:http://192.168.137.21:8080/api/index.html");
-
-
- ?>
|