<?php
session_start();
if (session_is_registered('id_admin'))
{
?>
<script type="text/javascript" src="jquery.js"></script>
<script>
function suggest(inputString){
if(inputString.length == 0) {
$('#suggestions').fadeOut();
} else {
$('#country').addClass('load');
$.post("autosuggest.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions').fadeIn();
$('#suggestionsList').html(data);
$('#country').removeClass('load');
}
});
}
}
function fill(thisValue) {
$('#country').val(thisValue);
setTimeout("$('#suggestions').fadeOut();", 100);
}
function fill2(thisValue) {
$('#kode').val(thisValue);
setTimeout("$('#suggestions').fadeOut();", 100);
}
</script>
<style>
#result {
height:20px;
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
color:#333;
padding:5px;
margin-bottom:10px;
background-color:#FFFF99;
}
#country{
padding:3px;
border:1px #CCC solid;
font-size:12px;
}
.suggestionsBox {
position: absolute;
left: 0px;
top:40px;
margin: 26px 0px 0px 0px;
width: 200px;
padding:0px;
background-color:#999999;
border-top: 3px solid #999999;
color: #fff;
}
.suggestionList {
margin: 0px;
padding: 0px;
}
.suggestionList ul li {
list-style:none;
margin: 0px;
padding: 6px;
border-bottom:1px dotted #666;
cursor: pointer;
}
.suggestionList ul li:hover {
background-color: #FC3;
color:#000;
}
ul {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#FFF;
padding:0;
margin:0;
}
.load{
background-image:url(loader.gif);
background-position:right;
background-repeat:no-repeat;
}
#suggest {
position:relative;
}
</style>
<body onLoad="document.form.elements['notel'].focus();">
<div class="post">
<div class="entry">
<h2 align="center"><strong>Input Data PSB</strong></h2>
<p align="center"> </p>
<p>
<form action="?<?php echo paramEncrypt('page=./setup/psb2')?>" method="post" name="form">
<table>
<tr>
<td>No Telefon</td><td><input type="text" name="notel" size="15" value="<?php echo isset($_POST['notel']) ? $_POST['notel'] : '';?>"/>
<div style="color:red"><?php echo isset($error['notel']) ? $error['notel'] : '';?></div></td>
</tr>
<tr>
<td>Nama Pelanggan</td><td><input type="text" name="nama" size="30" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : '';?>"/>
<div style="color:red"><?php echo isset($error['nama']) ? $error['nama'] : '';?></div> </td>
</tr>
<tr>
<td>Alamat</td><td><input type="text" name="alamat" size="55" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : '';?>"/>
<div style="color:red"><?php echo isset($error['alamat']) ? $error['alamat'] : '';?></div></td>
</tr>
<tr>
<td>id</td><td><input type="text" name="id" size="35"/></td>
</tr>
<tr>
<td>state</td><td><input type="text" name="state" size="25" value="Jawa Tengah" readonly="readonly"/></td>
</tr>
<tr>
<td>city</td><td><input type="text" name="city" size="35" value="Tegal" readonly="readonly"/></td>
</tr>
<tr>
<td>No HP</td><td><input type="text" name="hp" size="25"/></td>
</tr>
<tr>
<td>Tanggal Akhir ID</td><td><input type="text" name="tgl_akhir" size="25"/></td>
</tr>
<tr>
<td>info dari :</td><td><select name='sales'>
<option value='....'>pilih kebawah</option>
<option value='plasa'>plasa Telkom</option>
<option value='iklan'>iklan tv / koran</option>
<option value='147'>telkom 147</option>
<option value='sofyan'>sofyan</option>
<option value='darmo'>darmo</option>
<option value='christofer'>christofer</option>
<option value='heri'>heri</option>
</select>
</td></tr>
<tr>
<td>Paket :</td><td><select name='paket'>
<option value='....'>pilih kebawah</option>
<option value='mail'>mail</option>
<option value='chat'>Chat</option>
<option value='socialia'>Socialia</option>
<option value='Load'>Load</option>
<option value='family'>Family</option>
<option value='Executive'>Executive</option>
<option value='biz'>Biz</option>
</select>
</td></tr>
<tr>
<td>Keterangan</td><td><input type="text" name="keterangan" size="25"/></td>
</tr>
<tr>
<td>Tanggal</td>
<td colspan="2"><input type="text" name="tanggal_transaksi" size="15" value="<?php if(empty($_POST['tanggal_transaksi'])){ echo $tanggal;}else{ echo
$_POST['tanggal_transaksi']; }?>"/>
<a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.postform.tanggal_transaksi);return false;"
><img src="calender/calender.jpeg" alt="" name="popcal" width="34" height="29" border="0" align="absmiddle" id="popcal" /></a>
</td>
</tr>
<tr>
<td><input type="submit" value="Simpan" /></td>
</tr>
</table>
</form>
<br />
<!---MENAMPILKAN TABEL PERKIRAAN--->
<a href="./laporan~pdf/psb~pdf.php" target="_blank" title=" Tampilkan dalam file pdf">
<img src="images/pdf-icon.jpeg" border="0"/>
</a>
<table class="datatable">
<tr>
<th>No Telefon</th><th>Nama Pelanggan</th><th>Alamat</th><th>Tanggal Transaksi</th>
</tr>
<?php
$query=mysql_query("select * from data order by tanggal_transaksi asc");
while($row=mysql_fetch_array($query)){
?>
<tr>
<td align="center"><?php echo $row['notel'];?></td><td><?php echo $row['nama'];?></td>
<td align="right"><?php echo $row['alamat'];?></td><td><?php echo $row['tanggal_transaksi'];?></td>
</tr>
<?php
}
?>
</table>
</p>
</div>
</div>
</body>
<?php
if($_POST){
$notel=$_POST['notel'];
$nama=ucwords($_POST['nama']);
$alamat=$_POST['alamat'];
$id=$_POST['id'];
$city=$_POST['city'];
$state=$_POST['state'];
$hp=$_POST['hp'];
$tgl_akhir=$_POST['tgl_akhir'];
$sales=$_POST['sales'];
$paket=$_POST['paket'];
$keterangan=$_POST['keterangan'];
$tanggal_transaksi=$_POST['tanggal_transaksi'];
$error = array();
if(empty($nama)){
$error['nama'] = 'Nama tidak boleh kosong';
}
if(empty($notel)){
$error['notel'] = 'Email tidak boleh kosong';
}
if(empty($alamat)){
$error['alamat'] = 'Alamat tidak boleh kosong';
}
if(empty($error)){$query=mysql_query("insert into data (notel,nama,alamat,id,city,state,hp,tgl_akhir,sales,paket,keterangan,tanggal_transaksi)
values
('$notel','$nama','$alamat','$id','$city','$state','$hp','$tgl_akhir','$sales','$paket','$keterangan','$tanggal_transaksi')");
}
if($query){
?><script language="javascript">document.location.href="?<?php echo paramEncrypt('page=./setup/psb2')?>"</script><?php
}else{
echo mysql_error();
}
}else{
unset($_POST['notel']);
}
?>
<?php
}else{
echo "Forbidden Access!";
}
?>
<?php
include "connect.php";
$result = mysql_query("SELECT a.no_urut,a.nomer_surat,a.nomer_agenda,a.perihal,a.tgl_surat,
a.tgl_terima,b.nama_pengirim FROM surat_masuk a,pengirim b
WHERE a.id_pengirim=b.id_pengirim ");
?>
<!DOCTYPE html>
<html>
<head>
<title>DataTables</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="media/js/jquery.js" type="text/javascript"></script>
<script src="media/js/jquery.dataTables.js" type="text/javascript"></script>
<script src="media/js/jquery.ui.dialog.js" type="text/javascript"></script>
<script src="media/js/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
<style type="text/css">
@import "media/css/demo_table_jui.css";
@import "media/themes/smoothness/jquery-ui-1.8.4.custom.css";
@import "media/css/demos.css";
</style>
<style>
*{
font-family: arial;
}
th.hide{
display: none;
}
td.no_urutCell{
display: none;
}
}
</style>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#datatables').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[2, "desc"]],
"bJQueryUI":true
});
$("#waiting").hide();
$( "#dialog-edit" ).dialog({
autoOpen: false,
resizable: false,
height: 200,
width: 350,
modal: true,
buttons: {
"Update": function() {
var
ano_urut = $("#no_urutedit").html();
anomer_surat = $("#nomer_suratedit").val();
anomer_agenda = $("input#nomer_agendaedit").val();
aperihal = $("input#perihaledit").val();
atgl_surat = $("input#tgl_suratedit").val();
atgl_terima = $("input#tgl_terimaedit").val();
anama_pengirim = $("input#nama_pengirimedit").val();
aact= 'edit';
$.ajax({
type: "POST",
url: "postdata.php",
data: {"no_urut":ano_urut,"nomer_surat":anomer_surat,"nomer_agenda":anomer_agenda,"perihal":aperihal,
"tgl_surat":atgl_surat,"tgl_terima":atgl_terima,"nama_pengirim":anama_pengirim,"act":aact},
timeout: 10000,
beforeSend: function(){},
complete: function(){},
cache: false,
success: function(result){
if (result=='success'){
//ubah isi data table sesuai dengan perubahan yang terjadi
objRow.find(".nomer_suratCell").html($("input#nomer_suratedit").val());
objRow.find(".nomer_agendaCell").html($("input#nomer_agendaedit").val());
objRow.find(".perihalCell").html($("input#perihaledit").val());
objRow.find(".tgl_suratCell").html($("input#tgl_suratedit").val());
objRow.find(".tgl_terimaCell").html($("input#tgl_terimaedit").val());
objRow.find(".nama_pengirimCell").html($("input#nama_pengirimedit").val());
$("#waiting").hide();
}else{alert(result);}
},
error: function(error){$("#waiting").hide();alert('request timeout, please try again.');}
}
);
$("#waiting").show();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
<!--Akhir dari inisialisasi dialog jQuery-->
})
function EditData(obj){
var no_urut = obj.parent().parent().find(".no_urutCell").html();
nomer_surat = obj.parent().parent().find(".nomer_suratCell").html();
nomer_agenda = obj.parent().parent().find(".nomer_agendaCell").html();
perihal = obj.parent().parent().find(".perihalCell").html();
tgl_surat = obj.parent().parent().find(".tgl_suratCell").html();
tgl_terima = obj.parent().parent().find(".tgl_terimaCell").html();
nama_pengirim = obj.parent().parent().find(".nama_pengirimCell").html();
$("#no_urutedit").empty().append(no_urut);
$("input#nomer_suratedit").val(nomer_surat);
$("input#nomer_agendaedit").val(nomer_agenda);
$("input#perihaledit").val(perihal);
$("input#tgl_suratedit").val(tgl_surat);
$("input#tgl_terimaedit").val(tgl_terima);
$("input#nama_pengirimedit").val(nama_pengirim);
objRow = obj.parent().parent(); //simpan object row
$( "#dialog-edit" ).dialog("open");
}
</script>
</head>
<body>
<div>
<table id="datatables" class="display">
<thead>
<tr>
<th class="hide">No.</th>
<th width="100">No Surat</th>
<th width="100">No Agenda</th>
<th width="200">Perihal</th>
<th width="50">Tgl Surat</th>
<th width="50">Tgl Terima</th>
<th width="150">Pengirim</th>
<th width="50">Pilihan</th>
</tr>
</thead>
<tbody>
<?php
while ($baris = mysql_fetch_array($result)){
echo "<tr>
<td class='no_urutCell'>".$baris['no_urut']."</td>
<td class='nomer_suratCell'>".$baris['nomer_surat']."</td>
<td class='nomer_agendaCell'>".$baris['nomer_agenda']."</td>
<td class='perihalCell'>".$baris['perihal']."</td>
<td class='tgl_suratCell'>".$baris['tgl_surat']."</td>
<td class='tgl_terimaCell'>".$baris['tgl_terima']."</td>
<td class='nama_pengirimCell'>".$baris['nama_pengirim']."</td>
<td align='right'>
<a class='edit' href='#' onClick='EditData($(this))'>Edit</a>
</td>
</tr>";
}
?>
</tbody>
</table>
<div id="dialog-edit" title="Edit Data Karyawan">
<form>
<table border="0">
<tr>
<td><label for="no_urut">No.</label></td>
<td><div id="no_urutedit"></div></td>
</tr>
<tr>
<td><label for="nomer_surat">Nomer Surat</label></td>
<td><input type="text" name="nomer_suratedit" id="nomer_suratedit" value="" class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="nomer_agenda">Nomer Agenda</label></td>
<td><input type="text" name="nomer_agendaedit" id="nomer_agendaedit" value="" class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="perihal">Perihal</label></td>
<td><input type="text" name="perihaledit" id="perihaledit" value="" class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="tgl_surat">Tgl Surat</label></td>
<td><input type="text" name="tgl_surat" id="tgl_suratedit" value="" class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="tgl_terima">Tgl Diterima</label></td>
<td><input type="text" name="tgl_terimaedit" id="tgl_terimaedit" value="" class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="nama_pengirim">Pengirim</label></td>
<td><select name="pengirim" id="pengirim">
<option>--Pilih--</option>
<?php
// query untuk menampilkan daftar pengirim
$query = "SELECT a.nama_pengirim,b.id_pengirim FROM pengirim a, surat_masuk b WHERE no_urut=$baris";
$hasil = mysql_query ($query);
while ($data = mysql_fetch_array ($hasil))
{
$selected = '';
if($data['id_pengirim'] == $baris){
$selected = 'selected="selected"';
}
echo '<option value="'.$data['id_pengirim'].'" '.$selected.'>'.$data['nama_pengirim'].'</option>';
}
?>
</select></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
<?
$conn = mysql_connect("localhost","root","root");
$db = mysql_select_db("db_sisipan",$conn);
if(isset($sisip)){
$selek = mysql_query("SELECT * FROM tb_sisipan WHERE id >= '$urutan'");
while($my = mysql_fetch_array($selek)){
mysql_query("UPDATE tb_sisipan SET urut = urut+1 WHERE id = $my[id] ");
}
mysql_query("INSERT INTO tb_sisipan(nama, urut) VALUES('$nama','$urutan')");
}
?>
<form id="form1" name="form1" method="post" action="">
NAMA
<label for="nama"></label>
<input type="text" name="nama" id="nama" />
<br />
URUT
<input type="text" name="urutan" id="urutan" />
<input type="submit" name="sisip" id="sisip" value="SISIPKAN !" />
</form>
<table width="361" border="0" cellpadding="2" cellspacing="2">
<tr align="center" bgcolor="#CCCCCC">
<td width="50">NO</td>
<td width="176">NAMA</td>
<td width="113">URUTAN</td>
</tr>
<?
$q = mysql_query("SELECT * FROM tb_sisipan ORDER BY urut ASC");
while ($d = mysql_fetch_array($q)){
?>
<tr>
<td align="center"><? echo "$d[id]"; ?></td>
<td><? echo "$d[nama]"; ?></td>
<td align="center"><? echo "$d[urut]"; ?></td>
</tr>
<? } ?>
</table>