Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //include "include/conn.php";
- $tanggal;
- $ttl1='15-12-2015';
- $ttl2='17-12-2015';
- $jam_selesai='20.30';
- //$ar=array(1,2);echo json_encode($ar);
- ?>
- <?php
- list($tgl1, $bln1, $thn1) = explode('-', $ttl1);
- ?>
- <?php
- list($tgl2, $bln2, $thn2) = explode('-', $ttl2);
- ?>
- <?php
- $fields=abs(gregoriantojd($bln1,$tgl1,$thn1 )-gregoriantojd($bln2,$tgl2,$thn2))+1;
- ?>
- <div class="container-fluid">
- <!-- Page Heading -->
- <div class="col-lg-12">
- <?php $status=isset($_GET['status'])?$_GET['status']:'';
- if ($status=='ubah'){
- $nama='ubah';
- $col='warning';
- }else{
- $nama='simpan';
- $col='success';
- }
- ?>
- <div class="panel panel-<?php echo $col;?> bayang">
- <div class="panel-footer">
- <?php echo $ttl1 ?> s/d <?php echo $ttl2 ?>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12">
- <?php if ($jam_selesai=='15.45'){
- $waktus = array(
- '08:00-08:45',
- '08:45-09:30',
- '09.30-10.15',
- '10.15-10.30',
- '10.30-11.15',
- '11.15-12.00',
- '12.00-13.00',
- '13.00-13.45',
- '13.45-14.30',
- '14.30-15.15',
- '15.15-15.45',
- );
- }
- elseif ($jam_selesai=='19.00'){
- $waktus = array(
- '08:00-08:45',
- '08:45-09:30',
- '09.30-10.15',
- '10.15-10.30',
- '10.30-11.15',
- '11.15-12.00',
- '12.00-13.00',
- '13.00-13.45',
- '13.45-14.30',
- '14.30-15.15',
- '15.15-15.45',
- '15.45-16.30',
- '16.30-17.15',
- '17.15-18.00',
- '18.00-19.00',
- );
- }
- else{
- $waktus = array(
- '08:00-08:45',
- '08:45-09:30',
- '09.30-10.15',
- '10.15-10.30',
- '10.30-11.15',
- '11.15-12.00',
- '12.00-13.00',
- '13.00-13.45',
- '13.45-14.30',
- '14.30-15.15',
- '15.15-15.45',
- '15.45-16.30',
- '16.30-17.15',
- '17.15-18.00',
- '18.00-19.00',
- '19.00-19.45',
- '19.45-20.30',
- );
- }
- ?>
- <script type="text/javascript">
- </script>
- <form enctype="multipart/form-data" action="input_jadual.php" method="post" id='jadwalKu'>
- <table class="table table-striped table-bordered" width="100%" cellspacing="0" border="1">
- <thead>
- <tr>
- <th width="10">No</th>
- <th width="60"><center>Time</center></th>
- <?php
- $begin = new DateTime($ttl1);
- $end = new DateTime($ttl2);
- $end = $end->modify( '+1 day' );
- $interval = new DateInterval('P1D');
- $daterange = new DatePeriod($begin, $interval ,$end);
- $dayList = array(
- 'Sunday' => 'Minggu',
- 'Monday' => 'Senin',
- 'Tuesday' => 'Selasa',
- 'Wednesday' => 'Rabu',
- 'Thursday' => 'Kamis',
- 'Friday' => 'Jumat',
- 'Saturday' => 'Sabtu'
- );
- $noHari=0;
- foreach($daterange as $date){
- $tgl=$date->format("d-m-Y");
- $hariss = date('l', strtotime($tgl));
- $haris=$dayList[$hariss];
- if ($haris=='Minggu'){
- $warna='red';
- $dis='disabled';
- }else{
- $warna='';
- $dis='';
- }
- ?>
- <th><center><input type="hidden" name="hari[]" value="<?php echo $haris; ?>"/><input type="hidden" name="tgl[]" value="<?php echo $tgl; ?>"/><font color="<?php echo $warna; ?>"><?php echo $haris; ?><br><?php echo $tgl; ?></font></center></th>
- <?php
- $noHari++;
- }
- //===============jumlah hari dan jam
- $arrlength = count($waktus);
- echo '<input type=hidden id="hariTotal" value="'.$noHari.'" />';
- echo '<input type=hidden id="jamTotal" value="'.$arrlength.'" />';
- //print_r($daterange);
- ?>
- </tr>
- </thead>
- <tbody>
- <?php
- $nos=1;
- for($x = 0; $x < $arrlength; $x++) { ?>
- <?php if ($waktus[$x]=='12.00-13.00'){
- ?>
- <tr disabled>
- <td class="data" align="center"><?php echo $nos;?></td>
- <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
- <?php
- $no=1;
- for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
- <td class="data" align="center">
- <i>Istirahat, Sholat & Makan</i>
- </td>
- <?php } ?>
- </tr>
- <?php } elseif ($waktus[$x]=='10.15-10.30'){
- ?>
- <tr disabled>
- <td class="data" align="center"><?php echo $nos;?></td>
- <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
- <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
- <td class="data" align="center">
- <i>Coffee Break</i>
- </td>
- <?php } ?>
- </tr>
- <?php } elseif ($waktus[$x]=='15.15-15.45'){
- ?>
- <tr disabled>
- <td class="data" align="center"><?php echo $nos;?></td>
- <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
- <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
- <td class="data" align="center">
- <i>Coffee Break</i>
- </td>
- <?php } ?>
- </tr>
- <?php } elseif ($waktus[$x]=='18.00-19.00'){
- ?>
- <tr disabled>
- <td class="data" align="center"><?php echo $nos;?></td>
- <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
- <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
- <td class="data" align="center">
- <i>Istirahat, Sholat & Makan</i>
- </td>
- <?php } ?>
- </tr>
- <?php
- }else{
- ?>
- <tr>
- <td class="data" align="center"><?php echo $nos;?></td>
- <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
- <?php
- $noz=1;
- for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) {
- $random = (rand()%500);
- if ($nos==1){
- $angka=$noz;
- }
- elseif ($nos==2){
- $angka=$fields+$noz;
- }
- elseif ($nos==3){
- $angka=$fields*2+$noz;
- }
- elseif ($nos==4){
- $angka=$fields*3+$noz;
- }
- elseif ($nos==5){
- $angka=$fields*3+$noz;
- }
- elseif ($nos==6){
- $angka=$fields*4+$noz;
- }
- elseif ($nos==7){
- $angka=$fields*6+$noz;
- }
- elseif ($nos==8){
- $angka=$fields*5+$noz;
- }
- elseif ($nos==9){
- $angka=$fields*6+$noz;
- }
- elseif ($nos==10){
- $angka=$fields*7+$noz;
- }
- elseif ($nos==11){
- $angka=$fields*10+$noz;
- }
- elseif ($nos==12){
- $angka=$fields*8+$noz;
- }
- elseif ($nos==13){
- $angka=$fields*9+$noz;
- }
- elseif ($nos==14){
- $angka=$fields*10+$noz;
- }
- elseif ($nos==15){
- $angka=$fields*14+$noz;
- }
- elseif ($nos==16){
- $angka=$fields*11+$noz;
- }
- elseif ($nos==17){
- $angka=$fields*12+$noz;
- }
- $angka=$x*100 +100+$noz;
- ?>
- <td class="data" align="center">
- <!-- value : {idPelajaran,jam} -->
- <select name="modul[]" id="drop<?php echo $angka ?>" onchange="check(this,<?=$angka;?>); myDisable0(<?=$angka;?>);">
- <option value="0">Lanjutan</option>
- <option value="[3,3]">FISIKA(3 hours)</option>
- <option value="[4,4]">GEOGRAPHIC(4 hours)</option>
- <option value="[5,5]">MATEMATIKA(5 hours)</option>
- <?php
- // include 'include/conn.php';
- // $select=mysql_db_query(@$db,"select nama_modul,jp from modul where nama_pelatihan='$nama_pelatihan'",@$koneksi);
- // while($row=mysql_fetch_array($select))
- $data=array(
- array('id'=>7,'jp'=>"3", "nama_modul"=>"modul 1"),
- array('id'=>8,'jp'=>"2", "nama_modul"=>"modul 2"),
- array('id'=>9,'jp'=>"2", "nama_modul"=>"modul 3"),
- );
- foreach($data as $row)
- {
- $jp=$row['jp'];
- echo "\n\t\t\t\t<option value='[".$row['id'].",".$row['jp']."]'>".$row['nama_modul']."(".$row['jp']." hours)</option>";
- }
- ?>
- </select>
- <!--<?=$angka." $x $fields $noz";?>-->
- </td>
- <?php $noz++; } ?>
- </tr>
- <?php
- }
- ?>
- <?php $nos++; } ?>
- <input type="hidden" name="code" value="<?php echo $code ?>"/>
- <input type="hidden" name="bidang_diklat" value="<?php echo $bidang_diklat; ?>"/>
- <input type="hidden" name="nama_pelatihan" value="<?php echo $nama_pelatihan ?>"/>
- <input type="hidden" name="ttl1" value="<?php echo $ttl1 ?>"/>
- <input type="hidden" name="ttl2" value="<?php echo $ttl2 ?>"/>
- <input type="hidden" name="lokasi" value="<?php echo $lokasi ?>"/>
- <input type="hidden" name="status" value="final"/>
- </tbody>
- </table>
- <input type='reset' />
- </form>
- <br>
- </div>
- </div>
- <script>
- var d=document;
- drops = d.getElementById('jamTotal').value;
- opts = d.getElementById('hariTotal').value;
- for (iJam=1;iJam<=drops;iJam++){
- for (z=1;z<=opts;z++){
- i2=(iJam*100)+z;
- try{
- newValue=d.getElementById('drop'+i2).options[z].value;
- d.getElementById('drop'+i2).disabled = false;
- d.getElementById('drop'+i2).value = null;
- }catch(e){
- ok=0;
- }
- }
- }
- d.getElementById('jadwalKu').reset();
- function myDisable0(posi ) {
- //invalid
- }
- function myDisable(posi,size) {
- //a=1;
- //b=3;
- console.log("pos:"+posi);
- posisi2=posi+100;
- iDisable=size;
- while(iDisable>1){
- try{
- newValue=d.getElementById('drop'+posisi2).options[z].value;
- console.log("id:"+posisi2);
- console.log("val:"+d.getElementById('drop'+posisi2).value);
- iDisable--;
- ok=1;
- }catch(e){
- ok=0;
- }
- if(ok==1){
- document.getElementById('drop'+posisi2).disabled = true;
- d.getElementById('drop'+posisi2).value = null;
- }else{}
- posisi2+=100;
- }
- }
- function check(element,posisi)
- {
- //d.getElementsByName('modul[]').length;
- //opts = 99;
- console.log("id:"+element.id+"|val:"+element.value);
- data = JSON.parse(element.value);
- jamTaken=data[1];
- console.log("drops:"+drops+"|opts:"+opts);
- iComp=0;
- for (iJam=1;iJam<=drops;iJam++){
- for (z=1;z<=opts;z++){
- i2=(iJam*100)+z;
- console.log("i="+iJam+"|z="+z+"|i2="+i2);
- iComp++;
- try{
- newValue=d.getElementById('drop'+i2).options[z].value;
- ok=1;
- }catch(e){
- ok=0;
- }
- if(ok==1){
- if (element.id != 'drop'+i2 && element.value != '0'){
- console.log("i2:"+i2+'|val:'+element.value+"|val2:"+d.getElementById('drop'+i2).options[z].value);
- if (d.getElementById('drop'+i2).options[z].value == element.value){
- d.getElementById('drop'+i2).options[z] = null;
- //break;
- }else{
- console.log( 'i2:'+i2+'|val:'+d.getElementById('drop'+i2).options[z].value);
- }
- }else{
- console.log("i2:"+i2);
- }
- }else{
- console.log('not found '+i2);
- }
- }
- }
- myDisable(posisi,jamTaken);
- /*
- for (iJam=1;iJam<drops+1;iJam++)
- {
- // console.log("i:"+i);
- // if (element.id != 'drop'+i && element.value != '0'){
- // console.log("drop:"+i+'|val:'+element.value);
- for (z=1;z<=opts;z++)
- {
- i2=(iJam*100)+z;
- console.log("i="+iJam+"|z="+z+"|i2="+i2);
- iComp++;
- try{
- newValue=d.getElementById('drop'+i2).options[z].value;
- ok=1;
- }catch(e){
- ok=0;
- }
- if(ok==1){
- if (element.id != 'drop'+i2 && element.value != '0'){
- console.log("i2:"+i2+'|val:'+element.value+"|val2:"+d.getElementById('drop'+i2).options[z].value);
- if (d.getElementById('drop'+i2).options[z].value == element.value)
- {
- d.getElementById('drop'+i2).options[z] = null;
- //break;
- }else{
- console.log( 'i2:'+i2+'val:'+d.getElementById('drop'+i2).options[z].value);
- }
- }else{
- console.log("i2:"+i2);
- }
- }else{
- console.log('not found '+i2);
- }
- }
- }
- */
- console.log("total komponen:"+iComp);
- }
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement