Guest User

Sample Code Implementation

a guest
Dec 18th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.31 KB | None | 0 0
  1.     <?php include "include/conn.php";
  2.     $tanggal;
  3.     $ttl1='15-12-2015';
  4.     $ttl2='17-12-2015';
  5.     $jam_selesai='20.30';
  6.     ?>
  7. <?php
  8. list($tgl1, $bln1, $thn1) = explode('-', $ttl1);
  9. ?>
  10. <?php
  11. list($tgl2, $bln2, $thn2) = explode('-', $ttl2);
  12. ?>
  13. <?php
  14. $fields=abs(gregoriantojd($bln1,$tgl1,$thn1 )-gregoriantojd($bln2,$tgl2,$thn2))+1;
  15. ?>
  16.  
  17. <div class="container-fluid">
  18.                 <!-- Page Heading -->
  19.                
  20. <div class="col-lg-12">
  21.                        
  22.                         <?php $status=$_GET['status'];
  23.                         if ($status=='ubah'){
  24.                             $nama='ubah';
  25.                             $col='warning';
  26.                         }else{
  27.                             $nama='simpan';
  28.                             $col='success';
  29.                         }
  30.                     ?>
  31. <div class="panel panel-<?php echo $col;?> bayang">
  32. <div class="panel-footer">
  33. <?php echo $ttl1 ?> s/d <?php echo $ttl2 ?>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="row">
  38. <div class="col-lg-12">
  39.                        
  40. <?php if ($jam_selesai=='15.45'){
  41. $waktus = array(
  42.     '08:00-08:45',
  43.     '08:45-09:30',
  44.     '09.30-10.15',
  45.     '10.15-10.30',
  46.     '10.30-11.15',
  47.     '11.15-12.00',
  48.     '12.00-13.00',
  49.     '13.00-13.45',
  50.     '13.45-14.30',
  51.     '14.30-15.15',
  52.     '15.15-15.45',
  53. );
  54. }
  55. elseif ($jam_selesai=='19.00'){
  56. $waktus = array(
  57.     '08:00-08:45',
  58.     '08:45-09:30',
  59.     '09.30-10.15',
  60.     '10.15-10.30',
  61.     '10.30-11.15',
  62.     '11.15-12.00',
  63.     '12.00-13.00',
  64.     '13.00-13.45',
  65.     '13.45-14.30',
  66.     '14.30-15.15',
  67.     '15.15-15.45',
  68.     '15.45-16.30',
  69.     '16.30-17.15',
  70.     '17.15-18.00',
  71.     '18.00-19.00',
  72. );
  73. }
  74. else{
  75. $waktus = array(
  76.     '08:00-08:45',
  77.     '08:45-09:30',
  78.     '09.30-10.15',
  79.     '10.15-10.30',
  80.     '10.30-11.15',
  81.     '11.15-12.00',
  82.     '12.00-13.00',
  83.     '13.00-13.45',
  84.     '13.45-14.30',
  85.     '14.30-15.15',
  86.     '15.15-15.45',
  87.     '15.45-16.30',
  88.     '16.30-17.15',
  89.     '17.15-18.00',
  90.     '18.00-19.00',
  91.     '19.00-19.45',
  92.     '19.45-20.30',
  93. );
  94. }
  95. ?>
  96. <script type="text/javascript">
  97. function check(element)
  98. {
  99.   d=document;
  100.   drops = d.getElementsByName('modul[]').length;
  101.   opts = 99;
  102.   for (i=1;i<drops+1;i++)
  103.   {
  104.     if (element.id != 'drop'+i && element.value != '0')
  105.     {
  106.       for (z=0;z<opts;z++)
  107.       {
  108.         if (d.getElementById('drop'+i).options[z].value == element.value)
  109.         {
  110.           d.getElementById('drop'+i).options[z] = null;
  111.           break;
  112.         }
  113.       }
  114.     }
  115.   }
  116. }
  117. </script>
  118. <form enctype="multipart/form-data" action="input_jadual.php" method="post">
  119. <table  class="table table-striped table-bordered" width="100%" cellspacing="0" border="1">
  120.             <thead>
  121.             <tr>
  122.                 <th width="10">No</th>
  123.                 <th width="60"><center>Time</center></th>
  124. <?php
  125. $begin = new DateTime($ttl1);
  126. $end = new DateTime($ttl2);
  127. $end = $end->modify( '+1 day' );
  128. $interval = new DateInterval('P1D');
  129. $daterange = new DatePeriod($begin, $interval ,$end);
  130. $dayList = array(
  131.     'Sunday' => 'Minggu',
  132.     'Monday' => 'Senin',
  133.     'Tuesday' => 'Selasa',
  134.     'Wednesday' => 'Rabu',
  135.     'Thursday' => 'Kamis',
  136.     'Friday' => 'Jumat',
  137.     'Saturday' => 'Sabtu'
  138. );
  139. foreach($daterange as $date){
  140.     $tgl=$date->format("d-m-Y");
  141.     $hariss = date('l', strtotime($tgl));
  142.     $haris=$dayList[$hariss];
  143.     if ($haris=='Minggu'){
  144.         $warna='red';
  145.         $dis='disabled';
  146.      }else{
  147.         $warna='';
  148.         $dis='';
  149.      }
  150.     ?>
  151. <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>
  152. <?php  } ?>
  153.             </tr>
  154.             </thead>
  155.             <tbody>
  156. <?php $nos=1; $arrlength = count($waktus); for($x = 0; $x < $arrlength; $x++) { ?>
  157. <?php if ($waktus[$x]=='12.00-13.00'){
  158.                         ?>
  159.                         <tr disabled>
  160.                             <td class="data" align="center"><?php echo $nos;?></td>
  161.                             <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
  162.                             <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
  163.                             <td class="data" align="center">
  164.                             <i>Istirahat, Sholat & Makan</i>
  165.                             </td>
  166.                             <?php } ?>
  167.                         </tr>
  168.                         <?php } elseif ($waktus[$x]=='10.15-10.30'){
  169.                         ?>
  170.                         <tr disabled>
  171.                             <td class="data" align="center"><?php echo $nos;?></td>
  172.                             <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
  173.                             <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
  174.                             <td class="data" align="center">
  175.                             <i>Coffee Break</i>
  176.                             </td>
  177.                             <?php } ?>
  178.                         </tr>
  179.                         <?php } elseif ($waktus[$x]=='15.15-15.45'){
  180.                         ?>
  181.                         <tr disabled>
  182.                             <td class="data" align="center"><?php echo $nos;?></td>
  183.                             <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
  184.                             <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
  185.                             <td class="data" align="center">
  186.                             <i>Coffee Break</i>
  187.                             </td>
  188.                             <?php } ?>
  189.                         </tr>
  190.                         <?php } elseif ($waktus[$x]=='18.00-19.00'){
  191.                         ?>
  192.                         <tr disabled>
  193.                             <td class="data" align="center"><?php echo $nos;?></td>
  194.                             <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
  195.                             <?php $no=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
  196.                             <td class="data" align="center">
  197.                             <i>Istirahat, Sholat & Makan</i>
  198.                             </td>
  199.                             <?php } ?>
  200.                         </tr>
  201. <?php
  202.      }else{
  203. ?>
  204. <tr>
  205. <td class="data" align="center"><?php echo $nos;?></td>
  206.                 <td class="data" align="center"><input type="hidden" name="waktu[]" value="<?php echo $waktus[$x];?>"/><?php echo $waktus[$x];?></td>
  207.                 <?php $noz=1; for($i = 0; $i < (is_numeric($fields)?$fields:1); $i++) { ?>
  208. <?php $random = (rand()%500);
  209. if ($nos==1){
  210.    $angka=$noz;
  211. }
  212.  elseif ($nos==2){
  213.    $angka=$fields+$noz;
  214. }
  215.   elseif ($nos==3){
  216.    $angka=$fields*2+$noz;
  217. }
  218.   elseif ($nos==4){
  219.    $angka=$fields*3+$noz;
  220. }
  221.   elseif ($nos==5){
  222.    $angka=$fields*3+$noz;
  223. }
  224.   elseif ($nos==6){
  225.    $angka=$fields*4+$noz;
  226. }
  227.   elseif ($nos==7){
  228.    $angka=$fields*6+$noz;
  229. }
  230.   elseif ($nos==8){
  231.    $angka=$fields*5+$noz;
  232. }
  233.   elseif ($nos==9){
  234.    $angka=$fields*6+$noz;
  235. }
  236.   elseif ($nos==10){
  237.    $angka=$fields*7+$noz;
  238. }
  239.   elseif ($nos==11){
  240.    $angka=$fields*10+$noz;
  241. }
  242.   elseif ($nos==12){
  243.    $angka=$fields*8+$noz;
  244. }
  245.   elseif ($nos==13){
  246.    $angka=$fields*9+$noz;
  247. }
  248.   elseif ($nos==14){
  249.    $angka=$fields*10+$noz;
  250. }
  251.   elseif ($nos==15){
  252.    $angka=$fields*14+$noz;
  253. }
  254.   elseif ($nos==16){
  255.    $angka=$fields*11+$noz;
  256. }
  257.   elseif ($nos==17){
  258.    $angka=$fields*12+$noz;
  259. }
  260.  ?>
  261.  
  262.         <td class="data" align="center">
  263.         <select name="modul[]" id="drop<?php echo $angka ?>" onchange="check(this); myDisable();">
  264.            <option value="0">Lanjutan</option>
  265.            <option value="FISIKA">FISIKA(3 hours)</option>
  266.            <option value="GEOGRAPHIC">GEOGRAPHIC(4 hours)</option>
  267.            <option value="MATEMATIKA">MATEMATIKA(5 hours)</option>
  268.            <?php
  269.              include 'include/conn.php';
  270.              $select=mysql_db_query(@$db,"select nama_modul,jp from modul where nama_pelatihan='$nama_pelatihan'",@$koneksi);
  271.              while($row=mysql_fetch_array($select))
  272.              {
  273.                  $jp=$row['jp'];
  274.               echo "<option value='".$row['nama_modul']."'>".$row['nama_modul']."(".$row['jp'].")</option>";
  275.              }
  276.            ?>
  277.          </select>
  278. <script>
  279. function myDisable() {
  280. a=1;
  281. b=3;
  282.     for (i=1;i<3;i++){
  283.           posi=a+b*i;
  284.           document.getElementById('drop'+posi).disabled = true;
  285. } }
  286. </script>
  287.         </div>
  288.          </td>
  289.         <?php $noz++; } ?>
  290. </tr>
  291. <?php
  292.      }
  293.     ?>
  294.  
  295. <?php $nos++; } ?>
  296. <input type="hidden" name="code" value="<?php echo $code ?>"/>
  297. <input type="hidden" name="bidang_diklat" value="<?php echo $bidang_diklat; ?>"/>
  298. <input type="hidden" name="nama_pelatihan" value="<?php echo $nama_pelatihan ?>"/>
  299. <input type="hidden" name="ttl1" value="<?php echo $ttl1 ?>"/>
  300. <input type="hidden" name="ttl2" value="<?php echo $ttl2 ?>"/>
  301. <input type="hidden" name="lokasi" value="<?php echo $lokasi ?>"/>
  302. <input type="hidden" name="status" value="final"/>
  303. </tbody>
  304. </table>
  305. </form>
  306. <br>
  307. </div>
  308. </div>
  309. </div>
Add Comment
Please, Sign In to add comment