Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /***********************/
- //FILE: form inputan
- /***********************/
- session_start;
- include 'config/fungsi_simpan.php';
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- *,td,th,input {font-family:Verdana,arial,sans-serif;}
- .frame { margin: 1em; border: 1px solid #ccc; }
- .tdku, .th { padding: 10px; margin-left:10px;}
- .button {color:#ffffff;background-color:#066;
- padding:5px 7px;border:1px solid #033;
- width:auto;}
- </style>
- <SCRIPT TYPE="text/javascript">
- function numbersonly(myfield, e, dec){
- var key;
- var keychar;
- if (window.event)
- key = window.event.keyCode;
- else if (e)
- key = e.which;
- else
- return true;
- keychar = String.fromCharCode(key);
- // control keys
- if ((key==null) || (key==0) || (key==8) ||
- (key==9) || (key==13) || (key==27) )
- return true;
- // numbers
- else if ((("0123456789").indexOf(keychar) > -1))
- return true;
- // decimal point jump
- else if (dec && (keychar == "."))
- {
- myfield.form.elements[dec].focus();
- return false;
- }
- else
- return false;
- }
- //-->
- </SCRIPT>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Rekap Absen Baru</title>
- <!-- popup calendar -->
- <link rel="stylesheet" href="dhtmlgoodies_calendar.css" media="screen"></link>
- <script type="text/javascript" src="dhtmlgoodies_calendar.js"></script>
- <!-- end popup calendar -->
- <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
- <script type="text/javascript">
- $(function(){
- $('#tanggal_lahir').datepicker();
- });
- function gantiTanggal(value){
- document.getElementById('ambiltanggal').value = document.getElementById('f_tanggal').value;
- }
- </script>
- <link href="tabelnya.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <h3>Rekap Data Baru</h3>
- <p>
- <?php
- include "config/konek.php";
- $terakhir= "SELECT * FROM bulan ORDER BY id DESC LIMIT 1";
- $ambilTerakhir = mysql_query($terakhir);
- $tampilTerakhir = mysql_fetch_array($ambilTerakhir);
- $terakhir1= "SELECT * FROM staff WHERE status='OK'";
- $ambilTerakhir1 = mysql_query($terakhir1);
- if(!isset($_REQUEST['keterangan'])){
- $tampilTerakhir1 = mysql_fetch_array($ambilTerakhir1);
- }
- ?>
- </p>
- <form id="form1" name="form1" method="post" action="simpan_tanggal.php">
- <table width="900" cellspacing="0" cellpadding="0" class="frame" >
- <tr>
- <td height="35" colspan="8" align="left" valign="middle">
- Tanggal
- <input name="tanggal" type="text" id="f_tanggal" value="" size="14"
- placeholder="masukan tanggal" />
- <img src="images/calendar.gif" alt="" width="24" height="12"
- style="cursor:pointer"
- onclick="displayCalendar(document.getElementById('f_tanggal'),'dd-mm-yyyy',this)" />
- <input type="submit" name="btn" id="btn" value="Submit" />
- Tanggal input terakhir <?php echo $tampilTerakhir['tanggal']; ?>
- <?php
- if($_POST['ok1']){
- $_SESSION['oke']="Last Saved";
- echo $_SESSION['oke'];
- }
- ?>
- </td>
- </tr>
- </table>
- </form>
- <form action="simpan_absen.php" method="post">
- <table width="900" cellspacing="0" cellpadding="0" class="frame" >
- <tr>
- <th width="28" height="35">No</th>
- <th width="165">Nama</th>
- <th width="105">Jabatan / Divisi</th>
- <th width="102"> Jam Masuk</th>
- <th width="102">Jam Keluar</th>
- <th width="170"><label for="nama_proyek">Keterangan</label></th>
- </tr>
- <?php
- $ket=array('Hadir','Sakit','Izin','Cuti','Tanpa Keterangan','Tugas Luar');
- $query = "SELECT * FROM persons order by id LIMIT 100";
- $hasil = mysql_query($query);
- while($data = mysql_fetch_array($hasil))
- {
- ?>
- <tr>
- <td height="40" align="center"><?php echo $data[id];?></td>
- <td>
- <?php echo $data[nama];?>
- <input name="nama[]" type="hidden" value="<?php echo $data[nama];?>" />
- </td>
- <td>
- <?php echo $data['jabatan']; ?>
- <input name="jabatan[]" type="hidden" value="<?php echo $data['jabatan']; ?>" />
- </td>
- <td>
- jam
- <input name="jam1[]" type="text" value="" size="2" maxlength="2"
- onkeypress="return numbersonly(this, event)" />
- menit
- <input name="menit1[]" type="text" value="" size="2" maxlength="2"
- onkeypress="return numbersonly(this, event)" />
- </td>
- <td>
- <label for="jam_keluar">
- jam
- <input name="jam2[]" type="text" value="" size="2" maxlength="2" />
- menit
- <input name="menit2[]" type="text" value="" size="2" maxlength="2"
- onkeypress="return numbersonly(this, event)" />
- </label>
- </td>
- <td>
- <label for="keterangan"></label>
- <select name="keterangan[]" id="keterangan">
- <?php
- $i=0;
- foreach($ket as $k){
- echo "<option value='".++$i."'>$k</option>\n";
- }
- ?>
- </select>
- <input name="tanggal[]" type="hidden" id="tanggal"
- value="<?php echo $tampilTerakhir['tanggal']; ?>" />
- </td>
- </tr>
- <?php $no++;}?>
- <tr>
- <td colspan="6">
- <input type="submit" value="Simpan" id="tombyol" name="ok1" class="button"/>
- </td>
- </tr>
- </table>
- </form>
- <script type="text/javascript">
- function display_alert()
- {
- alert("Data Deleted" );
- }
- </script>
- </body>
- </html>
- <?php
- /***********************/
- //FILE : simpan_absen.php
- /***********************/
- session_start();
- include "conn.php";
- $jam_masuk = $_POST["jam1"];
- $menit_masuk = $_POST["menit1"];
- $jam_keluar = $_POST["jam2"];
- $menit_keluar= $_POST["menit2"];
- $tanggal = $_POST['tanggal'];
- $nama = $_POST['nama'];
- $jabatan = $_POST['jabatan'];
- $jam_masuk = $_POST['jam_masuk'];
- $jam_keluar = $_POST['jam_keluar'];
- $keterangan = $_POST['keterangan'];
- $num = count($nama);
- $sql = "INSERT INTO `seamolec`.`staff`
- (`tanggal`,`nama`,`jabatan`,`jam_masuk`,`jam_keluar`,`total_jam`,
- `hadir`,`izin`,`sakit`,`cuti`,`tugasluar`,`tanpaketerangan`,`status`)
- VALUES ";
- $jam_in=array();
- $jam_out=array();
- $total_jam=array();
- for($i=0;$i<$num;$i++){
- if($menit_keluar[$i] < $menit_masuk[$i])
- {
- $jam_keluar[$i] -= 1;
- $menit_keluar[$i] += 60;
- }
- $jam_in[$i] = "{$jam_masuk[$i]}{$menit_masuk[$i]}";
- $jam_out[$i] = "{$jam_keluar[$i]}{$menit_keluar[$i]}";
- $total_jam[$i] = ($jam_keluar[$i] - $jam_masuk[$i] - 1)."".($menit_keluar[$i] - $menit_masuk[$i]);
- $values="('{$tanggal[$i]}',
- '{$nama[$i]}',
- '{$jabatan[$i]}',
- '{$jam_in[$i]}',
- '{$jam_out[$i]}',
- '{$total_jam[$i]}',
- ".(($keterangan)=="1"?"'1'","NULL").",
- ".(($keterangan)=="2"?"'1'","NULL").",
- ".(($keterangan)=="3"?"'1'","NULL").",
- ".(($keterangan)=="4"?"'1'","NULL").",
- ".(($keterangan)=="5"?"'1'","NULL").",
- ".(($keterangan)=="6"?"'1'","NULL").",
- 'OK')";
- }
- $sql.=implode(",",$values);
- $result=mysql_query($sql);
- require "rekap_baru.php";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement