<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php 
	include "common/config.php";
	include "include/head.php";
	$act  = $_REQUEST['act'];
	$id_provinsi  = $_REQUEST['id_provinsi'];
	$sql = mysql_fetch_array(mysql_query("select * from tbl_provinsi where id_provinsi = '$id_provinsi'"));
	$kode_provinsi = $sql['kode_provinsi'];
	$nama_provinsi = $sql['nama_provinsi'];
	if($act == 1)
	{
		$id_provinsi  = $_REQUEST['id_provinsi'];
		$nama  = $_REQUEST['nama'];
		if($nama ==  "")
		{
		?>
				<script language="javascript">
                alert("Input Nama Province");
                document.location="edit_provinsi.php?id_provinsi=<?php echo $id_provinsi; ?>";
                </script>
		<?php	
		}
		else
		{
			$insert = mysql_query("update tbl_provinsi set nama_provinsi='$nama',user_update = '$USERNAME' where id_provinsi='$id_provinsi'");
			if($insert)
			{
				?>
				<script language="javascript">
                alert("Edit Province Success");
                document.location="edit_provinsi.php?id_provinsi=<?php echo  $id_provinsi; ?>";
                </script>
				<?php
			}
			else
			{
				?>
				<script language="javascript">
                alert("Edit Province Failed");
                document.location="edit_provinsi.php?id_provinsi=<?php echo $id_provinsi; ?>";
                </script>
				<?php	
			}
		}
	}
	?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-th"></i> Edit Province</h1>
</div>

<!--<ol class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Bread</a></li>
  <li><a href="#">Crumbs</a></li>
  <li class="active">Example</li>
</ol>-->
          <div class="main-content">
            <div class="row">
                <div class="widget">
                  <div class="widget-content-white glossed">
                    <div class="padded">
                      <form method="post" action="edit_provinsi.php?act=1&id_provinsi=<?php echo $id_provinsi; ?>" role="form" class="form-horizontal">
                        <div class="form-group">
                          <label class="col-md-4 control-label">Kode Province</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="kode" id="kode" value="<?php echo $kode_provinsi; ?>"  readonly="readonly" >
                          </div>
                        </div>
                         <div class="form-group">
                          <label class="col-md-4 control-label">Nama Province</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="nama" id="nama" value="<?php echo $nama_provinsi; ?>">
                          </div>
                        </div>
                   
                        <div class="form-group">
                          <div class="col-md-offset-4 col-md-8">
                            <button type="submit" class="btn btn-default">Submit</button>
                            <button type="reset" class="btn btn-default">Reset</button>
                          </div>
                        </div>
                      </form>
                    </div>
                    </div>
                    </div>
                    </div>
                    </div>
                   

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>

</html>