/jibas/anjungan/psb/psb.input.js

https://github.com/wildanm/Jibas · JavaScript · 292 lines · 247 code · 39 blank · 6 comment · 16 complexity · c31666e2628223980cb88986c6b5ad65 MD5 · raw file

  1. psb_changeDepartemen = function() {
  2. //alert('Get Proses');
  3. var dept = $("#psb_departemen").val();
  4. $.ajax({
  5. url : 'psb/psb.input.ajax.php?op=getTambahanData&dept='+dept,
  6. type: 'get',
  7. success : function(html) {
  8. $('#psb_divTambahanData').html(html);
  9. }
  10. });
  11. $.ajax({
  12. url : 'psb/psb.input.ajax.php?op=setProsesPsb&dept='+dept,
  13. type: 'get',
  14. success : function(html) {
  15. $('#psb_divProses').html(html);
  16. var proses = $("#psb_proses").val();
  17. //alert('Get Kelompok with Proses ' + proses);
  18. $.ajax({
  19. url : 'psb/psb.input.ajax.php?op=setKelompokPsb&proses='+proses,
  20. type: 'get',
  21. success : function(html) {
  22. $('#psb_divKelompok').html(html);
  23. }
  24. });
  25. //alert('Get Sumbangan with Proses ' + proses);
  26. $.ajax({
  27. url : 'psb/psb.input.ajax.php?op=setSumbanganPsb&proses='+proses,
  28. type: 'get',
  29. success : function(html) {
  30. $('#psb_divSumbangan').html(html);
  31. }
  32. });
  33. //alert('Get Nilai Ujian with Proses ' + proses);
  34. $.ajax({
  35. url : 'psb/psb.input.ajax.php?op=setUjianPsb&proses='+proses,
  36. type: 'get',
  37. success : function(html) {
  38. //alert(html.length);
  39. $('#psb_divNilaiUjian').html(html);
  40. }
  41. });
  42. }
  43. });
  44. }
  45. psb_changeProses = function() {
  46. var proses = $("#psb_proses").val();
  47. $.ajax({
  48. url : 'psb/psb.input.ajax.php?op=setKelompokPsb&proses='+proses,
  49. type: 'get',
  50. success : function(html) {
  51. $('#psb_divKelompok').html(html);
  52. }
  53. })
  54. }
  55. psb_changeTahunLahirSiswa = function() {
  56. var y = $("#psb_thnlahir").val();
  57. var m = $("#psb_blnlahir").val();
  58. $.ajax({
  59. url : 'psb/psb.input.ajax.php?op=setTglLahirSiswa&y='+y+'&m='+m,
  60. type: 'get',
  61. success : function(html) {
  62. $('#psb_divTglLahirSiswa').html(html);
  63. }
  64. })
  65. }
  66. psb_changeBulanLahirSiswa = function() {
  67. var y = $("#psb_thnlahir").val();
  68. var m = $("#psb_blnlahir").val();
  69. $.ajax({
  70. url : 'psb/psb.input.ajax.php?op=setTglLahirSiswa&y='+y+'&m='+m,
  71. type: 'get',
  72. success : function(html) {
  73. $('#psb_divTglLahirSiswa').html(html);
  74. }
  75. })
  76. }
  77. psb_changeTanggalLahirSiswa = function() {
  78. }
  79. psb_CopyAlamat = function() {
  80. var alamat = $.trim($("#psb_alamatsiswa").val());
  81. if (alamat.length == 0)
  82. return;
  83. $("#psb_alamatortu").val(alamat);
  84. $("#psb_alamatsurat").val(alamat);
  85. }
  86. psb_changeTahunLahirAyah = function() {
  87. var y = $("#psb_thnlahirayah").val();
  88. var m = $("#psb_blnlahirayah").val();
  89. $.ajax({
  90. url : 'psb/psb.input.ajax.php?op=setTglLahirAyah&y='+y+'&m='+m,
  91. type: 'get',
  92. success : function(html) {
  93. $('#psb_divTglLahirAyah').html(html);
  94. }
  95. })
  96. }
  97. psb_changeBulanLahirAyah = function() {
  98. var y = $("#psb_thnlahirayah").val();
  99. var m = $("#psb_blnlahirayah").val();
  100. $.ajax({
  101. url : 'psb/psb.input.ajax.php?op=setTglLahirAyah&y='+y+'&m='+m,
  102. type: 'get',
  103. success : function(html) {
  104. $('#psb_divTglLahirAyah').html(html);
  105. }
  106. })
  107. }
  108. psb_changeTanggalLahirAyah = function() {
  109. }
  110. psb_changeTahunLahirIbu = function() {
  111. var y = $("#psb_thnlahiribu").val();
  112. var m = $("#psb_blnlahiribu").val();
  113. $.ajax({
  114. url : 'psb/psb.input.ajax.php?op=setTglLahirIbu&y='+y+'&m='+m,
  115. type: 'get',
  116. success : function(html) {
  117. $('#psb_divTglLahirIbu').html(html);
  118. }
  119. })
  120. }
  121. psb_changeBulanLahirIbu = function() {
  122. var y = $("#psb_thnlahiribu").val();
  123. var m = $("#psb_blnlahiribu").val();
  124. $.ajax({
  125. url : 'psb/psb.input.ajax.php?op=setTglLahirIbu&y='+y+'&m='+m,
  126. type: 'get',
  127. success : function(html) {
  128. $('#psb_divTglLahirIbu').html(html);
  129. }
  130. })
  131. }
  132. psb_changeTanggalLahirIbu = function() {
  133. }
  134. psb_changeJenjangSekolah = function() {
  135. var jenjang = $("#psb_dep_asal").val();
  136. $.ajax({
  137. url : 'psb/psb.input.ajax.php?op=setAsalSekolah&jenjang='+jenjang,
  138. type: 'get',
  139. success : function(html) {
  140. $('#psb_divAsalSekolah').html(html);
  141. }
  142. })
  143. }
  144. psb_changeAsalSekolah = function() {
  145. var sekolah = $("#psb_sekolah").val();
  146. if (sekolah == -1)
  147. {
  148. $("#psb_inputsekolah").val(1);
  149. $("#psb_newsekolah").css('visibility', 'visible');
  150. }
  151. else
  152. {
  153. $("#psb_inputsekolah").val(0);
  154. $("#psb_newsekolah").css('visibility', 'hidden');
  155. }
  156. }
  157. psb_ValidateInput = function() {
  158. $proses = $("#psb_proses").val();
  159. $kelompok = $("#psb_kelompok").val();
  160. if ($proses == -1 || $kelompok == -1)
  161. {
  162. alert("Belum ada data Proses atau Kelompok PSB!");
  163. return false;
  164. }
  165. return Validator.CheckLength($("#psb_nama"), "Nama Siswa", 4, 255) &&
  166. Validator.CheckLength($("#psb_panggilan"), "Nama Panggilan Siswa", 4, 100) &&
  167. Validator.CheckLength($("#psb_tmplahir"), "Tempat Kelahiran Siswa", 4, 100) &&
  168. Validator.CheckLength($("#psb_urutananak"), "Urutan Anak", 1, 3) &&
  169. Validator.CheckNumber($("#psb_urutananak"), "Urutan Anak") &&
  170. Validator.CheckInteger($("#psb_urutananak"), "Urutan Anak", 1, 100) &&
  171. Validator.CheckLength($("#psb_jumlahanak"), "Jumlah Anak", 1, 3) &&
  172. Validator.CheckNumber($("#psb_jumlahanak"), "Jumlah Anak") &&
  173. Validator.CheckInteger($("#psb_jumlahanak"), "Jumlah Anak", 1, 100) &&
  174. Validator.CompareValue($("#psb_urutananak"), "Urutan Anak", $("#psb_jumlahanak"), "Jumlah Anak", "<=") &&
  175. Validator.CheckLength($("#psb_jkandung"), "Jumlah Saudara Kandung", 1, 3) &&
  176. Validator.CheckNumber($("#psb_jkandung"), "Jumlah Saudara Kandung") &&
  177. Validator.CheckInteger($("#psb_jkandung"), "Jumlah Saudara Kandung", 0, 100) &&
  178. Validator.CheckLength($("#psb_jtiri"), "Jumlah Saudara Tiri", 1, 3) &&
  179. Validator.CheckNumber($("#psb_jtiri"), "Jumlah Saudara Tiri") &&
  180. Validator.CheckInteger($("#psb_jtiri"), "Jumlah Saudara Tiri", 0, 100) &&
  181. Validator.CheckLength($("#psb_bahasa"), "Bahasa Sehari-hari", 5, 50) &&
  182. Validator.CheckLength($("#psb_alamatsiswa"), "Alamat", 10, 255) &&
  183. Validator.CheckLength($("#psb_kodepos"), "Kode Pos", 5, 7) &&
  184. Validator.CheckNumber($("#psb_kodepos"), "Kode Pos") &&
  185. Validator.CheckLength($("#psb_jarak"), "Jarak ke Sekolah", 1, 4) &&
  186. Validator.CheckNumber($("#psb_jarak"), "Jarak ke Sekolah") &&
  187. Validator.CheckNumber($("#psb_telponsiswa"), "Telpon Siswa") &&
  188. Validator.CheckNumber($("#psb_hpsiswa"), "Handphone Siswa") &&
  189. Validator.CheckEmail($("#psb_emailsiswa"), "Email Siswa") &&
  190. ($('#psb_inputsekolah').val() == 1 ? Validator.CheckLength($('#psb_newsekolah'), "Nama Asal Sekolah", 10, 100) : true) &&
  191. Validator.CheckNumber($("#psb_berat"), "Berat Badan Siswa") &&
  192. Validator.CheckNumber($("#psb_tinggi"), "Tinggi Badan Siswa") &&
  193. Validator.CheckLength($("#psb_namaayah"), "Nama Ayah", 5, 100) &&
  194. Validator.CheckLength($("#psb_namaibu"), "Nama Ayah", 5, 100) &&
  195. Validator.CheckLength($("#psb_tmplahirayah"), "Tempat Lahir Ayah", 5, 100) &&
  196. Validator.CheckLength($("#psb_tmplahiribu"), "Tempat Lahir Ibu", 5, 100) &&
  197. Validator.CheckRupiah($("#psb_penghasilanayah"), "Penghasilan Ayah") &&
  198. Validator.CheckRupiah($("#psb_penghasilanibu"), "Penghasilan Ibu") &&
  199. Validator.CheckEmail($("#psb_emailayah"), "Email Ayah") &&
  200. Validator.CheckEmail($("#psb_emailibu"), "Email Ibu") &&
  201. Validator.CheckNumber($("#psb_telponortu"), "Telpon Orangtua") &&
  202. Validator.CheckNumber($("#psb_hportu"), "Handphone Orangtua") &&
  203. Validator.CheckNumber($("#psb_hportu2"), "Handphone Orangtua") &&
  204. Validator.CheckNumber($("#psb_hportu3"), "Handphone Orangtua") &&
  205. Validator.CheckRupiah($("#psb_sum1"), "Sumbangan PSB") &&
  206. Validator.CheckRupiah($("#psb_sum2"), "Sumbangan PSB") &&
  207. Validator.CheckNumber($("#psb_ujian1"), "Nilai Ujian") &&
  208. Validator.CheckNumber($("#psb_ujian2"), "Nilai Ujian") &&
  209. Validator.CheckNumber($("#psb_ujian3"), "Nilai Ujian") &&
  210. Validator.CheckNumber($("#psb_ujian4"), "Nilai Ujian") &&
  211. Validator.CheckNumber($("#psb_ujian5"), "Nilai Ujian") &&
  212. Validator.CheckNumber($("#psb_ujian6"), "Nilai Ujian") &&
  213. Validator.CheckNumber($("#psb_ujian7"), "Nilai Ujian") &&
  214. Validator.CheckNumber($("#psb_ujian8"), "Nilai Ujian") &&
  215. Validator.CheckNumber($("#psb_ujian9"), "Nilai Ujian") &&
  216. Validator.CheckNumber($("#psb_ujian10"), "Nilai Ujian") &&
  217. confirm('Data sudah benar?');
  218. }
  219. psb_Simpan = function() {
  220. if (!psb_ValidateInput())
  221. return;
  222. var data = "";
  223. var inputs = $('#psb_form :input:not([type=radio],[type=checkbox])');
  224. inputs.each(function() {
  225. if (data != "")
  226. data += "&";
  227. data += this.name + "=" + $(this).val();
  228. });
  229. inputs = $('#psb_form :input[type=radio]:checked');
  230. inputs.each(function() {
  231. if (data != "")
  232. data += "&";
  233. data += this.name + "=" + $(this).val();
  234. });
  235. inputs = $('#psb_form :input[type=checkbox]:checked');
  236. inputs.each(function() {
  237. if (data != "")
  238. data += "&";
  239. data += this.name + "=" + $(this).val();
  240. });
  241. $.ajax({
  242. type: 'POST',
  243. url: 'psb/psb.input.save.php',
  244. data: data,
  245. success: function(html) {
  246. $('#psb_content').html(html);
  247. },
  248. error: function(xhr, options, error) {
  249. $('#psb_content').html(xhr.responseText);
  250. //alert(xhr.responseText);
  251. }
  252. });
  253. }