[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
administrator
/
[
Home
]
File: sp_e.php
<?php require_once("../lib/konek.php"); require_once("../lib/konfigurasi_semua.php"); require_once("../lib/cur.php"); require_once("../lib/function_tanggal.php"); //konfigurasi nama file $thisForm = "view.php"; $actionForm = "action.php"; //actionnya if($_POST["sp_id"]) $spId = $_POST["sp_id"]; if($_POST["mode"]) $mode = $_POST["mode"]; if($_GET["mode"]) { $mode = "edit"; } if($_GET["id"]) { $spId = $_GET["id"]; $sql = "select * from hrd_sp where sp_id = ".$spId; $qId = mysql_query($sql); $dataUser = mysql_fetch_array($qId); $_POST["sp_id"] = $dataUser["sp_id"]; $_POST["sp_no"] = $dataUser["sp_no"]; $_POST["id_pgw"] = $dataUser["id_pgw"]; $_POST["sp_tgl"] = date_db($dataUser["sp_tgl"]); $_POST["sp_isi"] = $dataUser["sp_isi"]; $_POST["sp_ke"] = $dataUser["sp_ke"]; } if($_POST["btnSimpan"] || $_POST["btnUpdate"] || $_POST["btnApply"] || $_POST["btnApply2"]) { if($_POST["btnSimpan"] || $_POST["btnApply"]) { $sql = "select sp_id from hrd_sp where sp_no = '".$_POST["sp_no"]."'"; } if($_POST["btnUpdate"] || $_POST["btnApply2"]) { $sql = "select sp_id from hrd_sp where sp_id <> ".$_POST["sp_id"]." and sp_no = '".$_POST["sp_no"]."'"; } $Qrs_cek = mysql_query($sql); $datacek = mysql_fetch_array($Qrs_cek); if($datacek) $hint[0] = "Kode ".$_POST["sp_no"]." sudah ada"; if(!$_POST["sp_no"]) { $stat_err = true; } if(!$datacek && $stat_err!=true) { if($_POST["btnSimpan"] || $_POST["btnApply"]) { $sql = "select max(sp_id) as id from hrd_sp"; $Qrs = mysql_query($sql); $id = mysql_fetch_array($Qrs); $spId = $id["id"]+1; } if($_POST["btnUpdate"] || $_POST["btnApply2"]) { $spId = $_POST["sp_id"]; } $nmTable = "hrd_sp"; $tbField[0] = "sp_id"; $tbField[1] = "sp_no"; $tbField[2] = "id_pgw"; $tbField[3] = "sp_tgl"; $tbField[4] = "sp_isi"; $tbField[5] = "sp_tgl_ms"; $tbField[6] = "sp_wkt_ms"; $tbField[7] = "id_user"; $tbField[8] = "sp_ke"; $tbIsi[0] = $spId; $tbIsi[1] = "'".$_POST["sp_no"]."'"; $tbIsi[2] = "'".$_POST["id_pgw"]."'"; $tbIsi[3] = "'".date_db($_POST["sp_tgl"])."'"; $tbIsi[4] = "'".$_POST["sp_isi"]."'"; $tbIsi[5] = "'".$skr."'"; $tbIsi[6] = "'".$wkt."'"; $tbIsi[7] = $_SESSION["hrd-id"]; $tbIsi[8] = "'".$_POST["sp_ke"]."'"; if($_POST["btnSimpan"] || $_POST["btnApply"]) { for($start=0, $jumField=count($tbField); $start<$jumField; $start++) { if($start!=0) { $nmField = $nmField.",".$tbField[$start]; }else{ $nmField = $tbField[$start]; } } for($start=0, $jumIsi=count($tbIsi); $start<$jumIsi; $start++) { if($start!=0) { $isiField = $isiField.",".$tbIsi[$start]; }else{ $isiField = $tbIsi[$start]; } } $sql = "insert ".$nmTable." (".$nmField.") values(".$isiField.")"; } if($_POST["btnUpdate"] || $_POST["btnApply2"]) { for($start=0, $end=count($tbIsi); $start<$end; $start++) { if($start!=0) { $isiField = $isiField.",".$tbField[$start]."=".$tbIsi[$start]; }else{ $isiField = $tbField[$start]."=".$tbIsi[$start]; } } $sql = "update ".$nmTable." set ".$isiField." where ".$tbField[0]." = ".$tbIsi[0]; } $Qrs = mysql_query($sql); //echo $sql; if($Qrs) { $mode = "edit"; } if($_POST["btnSimpan"] || $_POST["btnUpdate"]) { header("location:sp_v.php"); }else{ $_POST["sp_id"] = $spId; } } } if($_POST["btnKembali"]) { header("location:sp_v.php"); } //end ?> <html> <head> <title><?php echo $header;?></title> </head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!--meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"--> <link rel="stylesheet" type="text/css" href="<?php echo $dir_lib;?>/lib-style.css"> <script language="JavaScript" type="text/javascript" src="<?php echo $dir_lib;?>/ew.js"></script> <script language="JavaScript" type="text/javascript" src="<?php echo $dir_lib;?>/func_curr.js"></script> <script language="JavaScript" type="text/javascript" src="<?php echo $dir_lib;?>/elements.js"></script> <!-- calendar stylesheet --> <link rel="stylesheet" type="text/css" media="all" href="<?php echo $dir_lib;?>/jscalendar/css/calendar-system.css" title="calendar-system" /> <!-- calendar script --> <script type="text/javascript" src="<?php echo $dir_lib;?>/jscalendar/calendar.js"></script> <script type="text/javascript" src="<?php echo $dir_lib;?>/jscalendar/lang/calendar-en.js"></script> <script type="text/javascript" src="<?php echo $dir_lib;?>/jscalendar/calendar-setup.js"></script> <!-- end --> <body> <form name="frmEdit" method="POST" action="sp_e.php"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="2" align="left" valign="middle" bgcolor="#000000" height="28"> <font face="Verdana, Arial, Helvetica, sans-serif" size="4" color="white"> <?php echo $header;?></font> </td> </tr> <tr> <td colspan="2" align="left" bgcolor="#DEDBE7" height="20"> <?php include("menu_atas.php"); ?> </td> </tr> <tr> <td colspan="2"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr valign="middle" height="50"> <td height="50" width="10"> </td> <td height="50" width="300"> </td> <td height="50" width="100"> </td> <td> <?php echo $defFont;?> </font> </td> <td height="50" width="5"> </td> <td height="50" width="48" align="center"> <input type="image" name="btnKembali" value="btnKembali" src="<?php echo $dir_img;?>/cancel_f2.png"> </td> <td height="50" width="5"> </td> <td height="50" width="48" align="center"> <input type="image" name="<?php if($mode=="edit") { ?>btnApply2<?php }else{ ?>btnApply<?php } ?>" value="<?php if($mode=="edit") { ?>btnApply2<?php }else{ ?>btnApply<?php } ?>" src="<?php echo $dir_img;?>/apply_f2.png"> </td> <td height="50" width="5"> </td> <td height="50" width="50" align="center"> <input type="image" name="<?php if($mode=="edit") { ?>btnUpdate<?php }else{ ?>btnSimpan<?php } ?>" value="<?php if($mode=="edit") { ?>btnUpdate<?php }else{ ?>btnSimpan<?php } ?>" src="<?php echo $dir_img;?>/save_f2.png"> </td> </tr> <tr bgcolor="#FFF8DC" valign="middle"> <td width="10"> </td> <td width="300"> </td> <td width="100"> </td> <td> </td> <td width="5"> </td> <td width="48" align="center" onmouseover="this.style.backgroundColor='#FF6666'" onmouseout="this.style.backgroundColor='#FFF8DC'"> <?php echo $defFont;?>Batal</font> </td> <td width="5"> </td> <td width="48" align="center" onmouseover="this.style.backgroundColor='#FF6666'" onmouseout="this.style.backgroundColor='#FFF8DC'"> <?php echo $defFont;?>Apply</font> </td> <td width="5"> </td> <td width="50" align="center" onmouseover="this.style.backgroundColor='#FF6666'" onmouseout="this.style.backgroundColor='#FFF8DC'"> <?php echo $defFont;?>Simpan</font> </td> </tr> </table> </td> </tr> </table> <table border="0" cellspacing="0" cellpadding="0" width="100%" align="left"> <tr bgcolor="#FFF8DC"> <td align="right" width="35%"><?php echo $defFont;?>No Surat Peringatan <?php echo $tFont;?></td> <td width="65%"> <input size="35" maxlength="255" type="teks" name="sp_no" value="<?php echo $_POST["sp_no"];?>" class="textField" onKeyDown="return tabOnEnter_select(this, event);"> <input type="hidden" name="sp_id" value="<?php echo $_POST["sp_id"];?>"> <input type="hidden" name="mode" value="<?php echo $mode;?>"> <?php if(!$_POST["sp_no"]) echo "*";?> </td> </tr> <tr bgcolor="#FFF8DC"> <td align="right"><?php echo $defFont;?>Tanggal SP <?php echo $tFont;?></td> <td> <input onKeyDown="return tabOnEnter_select_with_button(this, event);" type="text" class="textField" name="sp_tgl" id ="sp_tgl" size="10" maxlength="10" value="<?php echo $_POST["sp_tgl"];?>"/> <img src="../img/b_calendar.png" width="16" height="16" align="middle" id="img_sp_tgl" style="cursor: pointer; border: 0px solid white;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''" /><?php echo $defFont;?>(tanggal-bulan-tahun)<?php if(!$_POST["sp_tgl"]) echo "*";?> </td> </tr> <tr bgcolor="#FFF8DC"> <td align="right"><?php echo $defFont;?>Penerima <?php echo $tFont;?></td> <td> <?php $sql = "select pgw_id,pgw_nama,jab_pgw_nama from hrd_pgw a left join hrd_jabatan_pegawai b on a.id_jab_pgw = jab_pgw_id order by pgw_nama"; $rs = mysql_query($sql); ?> <select name="id_pgw" class="textField"> <option value="0" <?php if($_POST["id_pgw"] == "") echo "selected";?>>-- Pilih --</option> <?php while($dataJab2=mysql_fetch_array($rs)) {?> <option value="<?php echo $dataJab2["pgw_id"];?>" <?php if($_POST["id_pgw"] ==$dataJab2["pgw_id"]) echo "selected";?>><?php echo $dataJab2["pgw_nama"];?></option> <?php } ?> </select> </td> </tr> <tr bgcolor="#FFF8DC"> <td align="right"><?php echo $defFont;?>Isi <?php echo $tFont;?></td> <td> <textarea name="sp_isi" class="textField" cols="75" rows="10"><?php echo $_POST["sp_isi"];?></textarea> </td> </tr> <tr bgcolor="#FFF8DC"> <td align="right"><?php echo $defFont;?>Ke- <?php echo $tFont;?></td> <td> <input onKeyDown="return tabOnEnter_select_with_button(this, event);" type="text" class="textField" name="sp_ke" id ="sp_ke" size="1" maxlength="1" value="<?php echo $_POST["sp_ke"];?>"/> </td> </tr> <tr bgcolor="#FFF8DC"> <td align="right"><?php echo $defFont;?> <?php echo $tFont;?></td> <td> </td> </tr> <tr> <td colspan="2"> <font color="yellow"> <?php if($stat_err==true || $hint) echo "Periksa lagi inputan yang bertanda (*)";?><br> <?php if($stat_err==true) echo "<i>Ada field yang belum terisi. Silahkan mengisi terlebih dahulu</i><br>";?> <?php for($start=0, $end=count($hint); $start<$end; $start++) {?> <i><?php echo $defFont;?><?php echo $hint[$start];?> <?php echo $tFont;?></i> <?php } ?> <?php echo $tFont;?> </td> </tr> </table> </form> <script type="text/javascript"> Calendar.setup({ inputField : "sp_tgl", // id of the input field ifFormat : "<?=$formatCal;?>", // format of the input field showsTime : false, // will display a time selector button : "img_sp_tgl", // trigger for the calendar (button ID) singleClick : true, // double-click mode step : 1 // show all years in drop-down boxes (instead of every other year as default) }); </script> </body> </html>