Selasa, 21 Januari 2020

PHP Code Promethe









Code sbb:

<?php
$pro="simpan";
$tanggal=WKT(date("Y-m-d"));
?>
<link type="text/css" href="<?php echo "$PATH/base/";?>ui.all.css" rel="stylesheet" /> 
<script type="text/javascript" src="<?php echo "$PATH/";?>jquery-1.3.2.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.core.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/i18n/ui.datepicker-id.js"></script>
 
  <script type="text/javascript">
      $(document).ready(function(){
        $("#tanggal").datepicker({
dateFormat  : "dd MM yy",     
          changeMonth : true,
          changeYear  : true
        });
      });
    </script> 

<script type="text/javascript">
function PRINT(){
win=window.open('penilaian/print.php','win','width=1000, height=400, menubar=0, scrollbars=1, resizable=0, location=0, toolbar=0, param1=0'); }
</script>
<script language="JavaScript">
function buka(url) {window.open(url, 'window_baru', 'width=800,height=600,left=320,top=100,resizable=1,scrollbars=1');}
</script>

<h4 class="blue">
<i class="ace-icon fa fa-check bigger-110"></i>
<div id="faq-list-1" class="panel-group accordion-style1 accordion-style2">

   <h3>Data Penilaian</h3>

<table width="100%" border="0" class="table table-striped table-bordered table-hover">
  <tr bgcolor="#036">
    <th width="3%"><center>No</th>
    <th width="30%"><center>Siswa</th>
    <th width="15%"><center><?php echo $nparam1;?></th>
    <th width="15%"><center><?php echo $nparam2;?></th>
    <th width="15%"><center><?php echo $nparam3;?></th>
    <th width="15%"><center><?php echo $nparam4;?></th>
    <th width="15%"><center><?php echo $nparam5;?></th>
  </tr>
<?php
  $sv="select * from `$tbpenilaian` where kode_periode='$kode_periodeaktif' order by `kode_penilaian` asc";
  $qv=mysqli_query($conn,$sv);
  $jumv=mysqli_num_rows($qv);
  $i=0;
  $no=1;
    while($dv=mysqli_fetch_array($qv)){                       
                $kode_kelas=$dv["kode_kelas"];               
                $namakelas=getKelas($conn,$dv["kode_kelas"]);
$kode_penilaian=$dv["kode_penilaian"];

$KN[$i]=$dv["kode_penilaian"];

$nis=$dv["nis"];
$nama=getSiswa($conn,$dv["nis"]);

$arNis[$i]=$nis;
$arNama[$i]=$nama;
$keterangan=$dv["keterangan"];
$aparam1[$i]=$dv["param1"];
$aparam2[$i]=$dv["param2"];
$aparam3[$i]=$dv["param3"];
$aparam4[$i]=$dv["param4"];
$aparam5[$i]=$dv["param5"];

$anis[$i]=$dv["nis"];
$anama[$i]=$nis;

$VP[0][$i]=getV1($aparam1[$i]);
$VP[1][$i]=getV2($aparam2[$i]);
$VP[2][$i]=getV3($aparam3[$i]);
$VP[3][$i]=getV4($aparam4[$i]);
$VP[4][$i]=getV5($aparam5[$i]);


$color="#dddddd";
if($no %2==0){$color="#eeeeee";}

echo"<tr bgcolor='$color'>
<td>$no</td>
<td>$nis</td>
<td>".$aparam1[$i]."</td>
<td>".$aparam2[$i]."</td>
<td>".$aparam3[$i]."</td>
<td>".$aparam4[$i]."</td>
<td>".$aparam5[$i]."</td>
</tr>";
$no++;
$i++;
}

            ?> 
   </table><br />
 
<!---------------------------------------------------------------------- -->

 <h3>Data Normalisasi</h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">
  <tr bgcolor="#036">
    <th width="3%"><center>No</th>
    <th width="30%"><center>Siswa</th>
    <th width="15%"><center><?php echo $nparam1;?></th>
    <th width="15%"><center><?php echo $nparam2;?></th>
    <th width="15%"><center><?php echo $nparam3;?></th>
    <th width="15%"><center><?php echo $nparam4;?></th>
    <th width="15%"><center><?php echo $nparam5;?></th>
  </tr>
<?php
  $no=1;
for($j=0;$j<$i;$j++){
$color="#dddddd";
if($no %2==0){$color="#eeeeee";}

echo"<tr bgcolor='$color'>
<td>$no</td>
<td>$nis</td>
<td>".$VP[0][$j]."</td>
<td>".$VP[1][$j]."</td>
<td>".$VP[2][$j]."</td>
<td>".$VP[3][$j]."</td>
<td>".$VP[4][$j]."</td>
</tr>";
$no++;
}

            ?> 
 </table> </br>

<!---------------------------------------------------------------------- -->



 <h3>Data Normalisasi'</h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">

<?php
echo"<tr><td>";
for($j=0;$j<$i;$j++){
echo"<td>".$anis[$j];
}
echo"</tr>";

for($k=0;$k<5;$k++){
echo"<tr><td>";
for($j=0;$j<$i;$j++){
echo"<td>".$VP[$k][$j]."</td>";
}
echo"</tr>";          
}
?>
             
 </table> </br>

<!---------------------------------------------------------------------- -->
<?php
for($k=0;$k<$i;$k++){
for($j=0;$j<$i;$j++){
$COBA[$k][$j]=0;
}
}

for($m=0;$m<$i;$m++){
?>
 <h3>Data Normalisasi' <?php echo "$m - ".($m+1);?></h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">

<?php

for($k=0;$k<5;$k++){
echo"<tr><td>";
for($j=0;$j<$i;$j++){
$SEL[$k][$j]=($VP[$k][$m]-$VP[$k][$j]);
if($SEL[$k][$j]>0){$HA[$m][$k][$j]=1;}
else{$HA[$m][$k][$j]=0;;}

if($m==$j){}
else{
echo"<td>".$SEL[$k][$j]."<td bgcolor='#cccccc'>".$HA[$m][$k][$j]."</td>";
$COBA[$m][$j]+=$HA[$m][$k][$j];
}            

}//j
echo"</tr>";
}//k

?>           
 </table> </br>
<?php
}
?>
<!---------------------------------------------------------------------- -->


 <h3>Data Hasil</h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">

<?php
         


for($k=0;$k<$i;$k++){
echo"<tr><td>";
for($j=0;$j<$i;$j++){
echo"<td>".$COBA[$k][$j]."</td>";
$KA[$k]+=$COBA[$k][$j];
$BA[$k]+=$COBA[$j][$k];
}
echo"</tr>";          
}

?>
             
 </table> </br>

<!---------------------------------------------------------------------- -->


 <h3>Hasil</h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">
<?php
echo"<tr><td>No<td>Nis<td>Nama Siswa<td>LF<td>EF<td>SUM</tr>";
for($k=0;$k<$i;$k++){
$KABA[$k]=$KA[$k]+$BA[$k];
echo"<tr><td>".($k+1)."<td>".$arNis[$k]."<td>".$arNama[$k]."<td>".$KA[$k]."<td>".$BA[$k]."<td>".$KABA[$k]."</tr>";
}
?>
</table>



<?php

  $size = count($arNis);
    for ($i=0; $i<$size; $i++) {
        for ($j=0; $j<$size-1-$i; $j++) {
            if ($KABA[$j+1] > $KABA[$j]) {
                swap($KABA, $j, $j+1);
swap($BA, $j, $j+1);
swap($KA, $j, $j+1);
swap($arNama, $j, $j+1);
swap($arNis, $j, $j+1);
swap($aparam5, $j, $j+1);
swap($KN, $j, $j+1);
            }
        }
    }

$max=$KABA[0];
$ada=1;
for ($i=1; $i<$size; $i++) {
if($KABA[$i]==$max){$ada=$ada+1;}
}
if($ada>1){
for ($i=0; $i<$ada; $i++) {
        for ($j=0; $j<$ada-1-$i; $j++) {
            if ($KABA[$j+1] > $KABA[$j]) {
                swap($KABA, $j, $j+1);
swap($BA, $j, $j+1);
swap($KA, $j, $j+1);
swap($arNama, $j, $j+1);
swap($arNis, $j, $j+1);
swap($aparam5, $j, $j+1);
swap($KN, $j, $j+1);
            }
        }
    }

}
?>



 <h3>Sorting Hasil</h3>
<table width="100%" border="0" class="table table-striped table-bordered table-hover">
<?php

$simpan=process($conn,"delete from tb_hasil where status='0'");

echo"<tr><td>No<td>Nis<td>Nama Siswa<td>LF<td>EF<td>SUM</tr>";
for($k=0;$k<$i;$k++){
$KABA[$k]=$KA[$k]+$BA[$k];
echo"<tr><td>".($k+1)."<td>".$arNis[$k]."<td>".$arNama[$k]."<td>".$KA[$k]."<td>".$BA[$k]."<td>".$KABA[$k]."</tr>";
$kelompok="$kode_periodeaktif" ."_"."$kode_kelas";
$R=$k+1;
$sql="INSERT INTO `tb_hasil` (`id`, `kode_penilaian`, `kode_periode`, `kode_kelas`, `nis`, `LF`, `EF`, `SUM`, `ranking`,`keterangan`,`status`,`kelompok`) VALUES ('', '".$KN[$k]."', '$kode_periodeaktif', '$kode_kelas', '".$arNis[$k]."', '".$KA[$k]."', '".$BA[$k]."', '".$KABA[$k]."', '$R','-','0','$kelompok');";
$simpan=process($conn,$sql);
}
?>
</table>



<?php
function swap(&$arr, $a, $b) {
    $tmp = $arr[$a];
    $arr[$a] = $arr[$b];
    $arr[$b] = $tmp;
}


?>



<a href="?mnu=aplikasi&st=simpan"><input type="button" value="SIMPAN"></a>

</div>


<?php
if(isset($_GET["st"])){
$sql="update `$tbhasil` set status='1'";
$hapus=process($conn,$sql);
if($hapus) {echo "<script>alert('Data hasil berhasil disimpan !');document.location.href='?mnu=hasil';</script>";}
else{echo"<script>alert('Data hasil  gagal disimpan...');document.location.href='?mnu=hasil';</script>";}
}
?>
function getV1($kode){
$v="";
if($kode >=0 && $kode<=2){$v=5;}
elseif($kode >=3 && $kode<=4){$v=4;}
elseif($kode ==5){$v=3;}
elseif($kode ==6 ){$v=2;}
elseif($kode >6 ){$v=1;}
return $v;
}

function getV2($kode){
$v="";
if($kode =="A"){$v=5;}
elseif($kode =="B"){$v=4;}
elseif($kode =="C"){$v=3;}
elseif($kode =="D" ){$v=2;}
elseif($kode =="E"){$v=1;}
return $v;
}
function getV3($kode){
$v="";
if($kode =="A"){$v=5;}
elseif($kode =="B"){$v=4;}
elseif($kode =="C"){$v=3;}
elseif($kode =="D" ){$v=2;}
elseif($kode =="E"){$v=1;}
return $v;
}

function getV4($kode){
$v="";
if($kode >=85 && $kode<=100){$v=5;}
elseif($kode >=75 && $kode<=84){$v=4;}
elseif($kode >=65 && $kode<=74){$v=3;}
elseif($kode >=60 && $kode<=64 ){$v=2;}
elseif($kode <60){$v=1;}
return $v;
}
function getV5($kode){
$v="";
if($kode ==1){$v=5;}
elseif($kode ==2){$v=4;}
elseif($kode ==3){$v=3;}
elseif($kode ==4){$v=2;}
elseif($kode ==5){$v=1;}
return $v;
}

Tidak ada komentar:

Posting Komentar

global_priv WARNING Selalu

 Jika muncul pesan kesalahan: Warning in .\libraries\classes\Dbal\DbiMysqli.php#209  mysqli::query(): (HY000/1034): Index for table 'glo...