Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

237 rindas
8.7 KiB

pirms 5 gadiem
  1. <?php
  2. include "koneksi.php";
  3. $data = new \stdClass();
  4. $arr = array();
  5. $arr1 = array();
  6. $nim = $_POST['nim'];
  7. //-------------------------------------------Get Mahasiswa----------------------------------------------
  8. $sql = "select * from vw_info_mhs_perwalian where nim = '$nim'";
  9. $rs=odbc_exec($conn,$sql);
  10. while($myRow = odbc_fetch_array( $rs )){
  11. $mahasiswa[] = $myRow;
  12. }
  13. $angkatan = $mahasiswa[0]['angkatan'];
  14. //------------------------------------------------------------------------------------------------------
  15. //-------------------------------------Cek Kampus----------------------------------------------------
  16. $sql = "select bol_jimbaran from mhs_mf where str_nim = '$nim'";
  17. $rs=odbc_exec($conn,$sql);
  18. while($myRow = odbc_fetch_array( $rs )){
  19. $isJimbaran_a[] = $myRow;
  20. }
  21. $isJimbaran = $isJimbaran_a[0]['bol_jimbaran'];
  22. if ($isJimbaran == 1){
  23. $max = 25;
  24. }else{
  25. $max = 35;
  26. }
  27. //------------------------------------------------------------------------------------------------------
  28. //-------------------------------------Cek Kelas Malam----------------------------------------------------
  29. $sql = "select * from kelas_malam where str_t_ajaran ='2018/2019' and bol_semester = '1' and str_nim = '$nim'";
  30. $rs=odbc_exec($conn,$sql);
  31. if (odbc_fetch_array( $rs ) == null)
  32. $ismalam = '0';
  33. else
  34. $ismalam = '1';
  35. //------------------------------------------------------------------------------------------------------
  36. //-------------------------------------Cek karyawan----------------------------------------------------
  37. $sql = "select bol_sts_kelas from mhs_mf where str_nim = '$nim'";
  38. $rs=odbc_exec($conn,$sql);
  39. while($myRow = odbc_fetch_array( $rs )){
  40. $karyawan[] = $myRow;
  41. }
  42. if ($karyawan[0]['bol_sts_kelas'] == '1'){
  43. $ismalam = '1';
  44. }else if ($karyawan[0]['bol_sts_kelas'] == '3'){
  45. $ismalam = '1';
  46. }else{
  47. $ismalam = '0';
  48. }
  49. //------------------------------------------------------------------------------------------------------
  50. //------------------------------------------Show Shcedules----------------------------------------------
  51. if ($angkatan == '2018'){
  52. $sql = "select A.str_kd_perwalian,A.tgl_perwalian,A.str_jam_perwalian,str_angkatan,C.jml
  53. from perwalian_jadual A inner join SESI_2018_OFF C
  54. on A.str_kd_perwalian = C.str_kd_perwalian
  55. where A.str_thn_ajaran='2018/2019' and A.bol_semester='1' and A.bol_malam = '$ismalam' and A.bol_jimbaran = '$isJimbaran'
  56. and jml <'$max' and A.str_angkatan = '$angkatan'";
  57. $rs=odbc_exec($conn,$sql);
  58. $count = 0;
  59. while($myRow = odbc_fetch_array( $rs )){
  60. array_push($arr, $myRow['jml']);
  61. array_push($arr1, $myRow['str_kd_perwalian']);
  62. }
  63. }else{
  64. $sql = "select A.str_kd_perwalian,A.tgl_perwalian,A.str_jam_perwalian,str_angkatan,C.jml
  65. from perwalian_jadual A inner join SESI_2018_OFF C
  66. on A.str_kd_perwalian = C.str_kd_perwalian
  67. 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'
  68. and jml <='150' and (A.str_angkatan = '$angkatan' or A.str_angkatan = '9999')";
  69. $rs=odbc_exec($conn,$sql);
  70. $count = 0;
  71. while($myRow = odbc_fetch_array( $rs )){
  72. array_push($arr, $myRow['jml']);
  73. array_push($arr1, $myRow['str_kd_perwalian']);
  74. }
  75. }
  76. //------------------------------------------------------------------------------------------------------
  77. //------------------------------------------Selection Sort----------------------------------------------
  78. for($i=0; $i<count($arr)-1; $i++) {
  79. $min = $i;
  80. for($j=$i+1; $j<count($arr); $j++) {
  81. if ($arr[$j]<$arr[$min]) {
  82. $min = $j;
  83. }
  84. }
  85. $backup_old_data_right_value = $arr[$min];
  86. $arr[$min] = $arr[$i];
  87. $arr[$i] = $backup_old_data_right_value;
  88. $backup_old_data_right_value = $arr1[$min];
  89. $arr1[$min] = $arr1[$i];
  90. $arr1[$i] = $backup_old_data_right_value;
  91. }
  92. //------------------------------------------------------------------------------------------------------
  93. //============================================================================================================
  94. //============================================================================================================
  95. //============================================================================================================
  96. //============================================================================================================
  97. //-------------------------------------------Cek Jadwal Kosong----------------------------------------------
  98. $sql = "select * from perwalian_mhs where str_nim = '$nim' and str_semester = (select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1'))";
  99. $rs=odbc_exec($conn,$sql);
  100. if (odbc_fetch_array( $rs ) == null){
  101. echo ("insert");
  102. //-------------------------------------------Get Romawi----------------------------------------------
  103. $sql = "select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1') as semester_romawi";
  104. $rs=odbc_exec($conn,$sql);
  105. while($myRow = odbc_fetch_array( $rs )){
  106. $romawi_a[] = $myRow;
  107. }
  108. $romawi = $romawi_a[0]['semester_romawi'];
  109. //---------------------------------------------------------------------------------------------------
  110. //-------------------------------------------Get Bol Semester----------------------------------------
  111. $sql = "select dbo.wGetBolSemester('$romawi') as bol_semester";
  112. $rs=odbc_exec($conn,$sql);
  113. while($myRow = odbc_fetch_array( $rs )){
  114. $bol_semester_a[] = $myRow;
  115. }
  116. $bol_semester = $bol_semester_a[0]['bol_semester'];
  117. //---------------------------------------------------------------------------------------------------
  118. //-------------------------------------------Get Semester--------------------------------------------
  119. $sql = "select dbo.xSinakGetSemesterMahasiswa1('$nim','2018/2019','1') as semester";
  120. $rs=odbc_exec($conn,$sql);
  121. while($myRow = odbc_fetch_array( $rs )){
  122. $semester_a[] = $myRow;
  123. }
  124. $semester = $semester_a[0]['semester'];
  125. //---------------------------------------------------------------------------------------------------
  126. //---------------------------------------------Insert-------------------------------------------------
  127. $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)
  128. VALUES ('$nim', '2018/2019', '$romawi', '$bol_semester','0', '$angkatan', '$semester', '$arr1[0]', '0', '0', '', '', '', '')";
  129. if(odbc_exec($conn,$sql))
  130. $data = 'ok';
  131. else
  132. $data = 'fail';
  133. }else{
  134. echo ("update");
  135. //-------------------------------------------Get Romawi----------------------------------------------
  136. $sql = "select dbo.xSinakGetSemesterMahasiswa2('$nim','2018/2019','1') as semester_romawi";
  137. $rs=odbc_exec($conn,$sql);
  138. while($myRow = odbc_fetch_array( $rs )){
  139. $romawi_a[] = $myRow;
  140. }
  141. $romawi = $romawi_a[0]['semester_romawi'];
  142. //---------------------------------------------------------------------------------------------------
  143. //-------------------------------------------Get Bol Semester----------------------------------------
  144. $sql = "select dbo.wGetBolSemester('$romawi') as bol_semester";
  145. $rs=odbc_exec($conn,$sql);
  146. while($myRow = odbc_fetch_array( $rs )){
  147. $bol_semester_a[] = $myRow;
  148. }
  149. $bol_semester = $bol_semester_a[0]['bol_semester'];
  150. //---------------------------------------------------------------------------------------------------
  151. //-------------------------------------------Get Semester--------------------------------------------
  152. $sql = "select dbo.xSinakGetSemesterMahasiswa1('$nim','2018/2019','1') as semester";
  153. $rs=odbc_exec($conn,$sql);
  154. while($myRow = odbc_fetch_array( $rs )){
  155. $semester_a[] = $myRow;
  156. }
  157. $semester = $semester_a[0]['semester'];
  158. //---------------------------------------------------------------------------------------------------
  159. //--------------------------------------------Update-------------------------------------------------
  160. $sql = "UPDATE perwalian_mhs
  161. 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=''
  162. where str_nim = '$nim' and str_semester = '$romawi'";
  163. if(odbc_exec($conn,$sql))
  164. $data = 'ok';
  165. else
  166. $data = 'fail';
  167. }
  168. header("location:http://192.168.137.21:8080/api/index.html");
  169. ?>