Parcourir la source

first commit

master
panda il y a 5 ans
révision
db64db9875
3 fichiers modifiés avec 307 ajouts et 0 suppressions
  1. +238
    -0
      getmhs.php
  2. +51
    -0
      index.html
  3. +18
    -0
      koneksi.php

+ 238
- 0
getmhs.php Voir le fichier

@ -0,0 +1,238 @@
<?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");
?>

+ 51
- 0
index.html Voir le fichier

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<link rel="stylesheet" href="theme.css" type="text/css">
<link rel="icon" href="images/dpaon_logo.ico">
</head>
<style>
.divider-medium {
height: 200px;
}
.divider-small {
height: 100px;
}
</style>
<body class="" style="background-position:right center;background-size:cover;background-repeat:no-repeat;">
<nav class="navbar navbar-expand-md bg-primary navbar-dark">
<div class="container">
<a class="navbar-brand" href="dashboard.php">
<b>&nbsp&nbspSISTEM PENJADWALAN PERWALIAN</b>
</a>
</div>
</nav>
<div class="divider-small"></div>
<div class="p-3 align-self-center">
<h4 class="text-center p-3">Masukan NIM Untuk Memberi Jadwal</h4>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="p-1">
<form method="post" action="/api/getmhs.php">
<div class="input-group mb-3">
<div class="input-group input-group-lg">
<input type="text" name="nim" value="" class="form-control" name="nim" placeholder="Ketikkan NIM Mahasiswa disini..." >
</div>
</div>
<br>
<button type="submit" class="btn btn-primary btn-block btn-md">submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

+ 18
- 0
koneksi.php Voir le fichier

@ -0,0 +1,18 @@
<?php
// header('Access-Control-Allow-Origin: *');
// header('Access-Control-Request-Method: POST');
$server = "192.168.0.5";
$user = "crosario";
$password = "b4tl3f13ld@db";
$database = "SINAK";
// Microsoft SQL Server using the SQL Native Client 10.0 ODBC Driver - allows connection to SQL 7, 2000, 2005 and 2008
$conn = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);
// if ($connection)
// echo "mau";
// else
// echo "tidak";
?>

Chargement…
Annuler
Enregistrer