<?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_shape  = $_REQUEST['id_shape'];
	$fetch = mysql_fetch_array(mysql_query("select * from tbl_cblb"));
	$cb = $fetch['cbprice'];
	$lb = $fetch['lbprice'];
	
	if($act == 1)
	{
		$cbprice  = $_REQUEST['cbprice'];
		$lbprice  = $_REQUEST['lbprice'];
		$sql = mysql_query("select * from tbl_cblb");
		if(($cbprice ==  "") or ($lbprice ==  ""))
		{
		?>
				<script language="javascript">
                alert("Please Input CB and LB Price");
                document.location="master_cblb.php";
                </script>
		<?php	
		}
		else
		{
			if(mysql_num_rows($sql) > 0)
			{
				$insert = mysql_query("update tbl_cblb set cbprice = '$cbprice', lbprice = '$lbprice',user_update = '$USERNAME'");
			}
			else
			{
				$insert = mysql_query("insert tbl_cblb (cbprice,lbprice,user_update) values ('$cbprice','$lbprice','$USERNAME')");
			}
			if($insert)
			{
				?>
				<script language="javascript">
                alert("Change Success");
                document.location="master_cblb.php";
                </script>
				<?php
			}
			else
			{
				?>
				<script language="javascript">
                alert("Change Failed");
                document.location="master_cblb.php";
                </script>
				<?php	
			}
		}
	}
	?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-th"></i> Master CB and LB Price</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="master_cblb.php?act=1" role="form" class="form-horizontal">
                        <div class="form-group">
                          <label class="col-md-4 control-label">CB Price</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="cbprice" id="cbprice" value="<?php echo $cb; ?>">
                          </div>
                        </div>
                        <div class="form-group">
                          <label class="col-md-4 control-label">LB Price</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="lbprice" id="lbprice" value="<?php echo $lb; ?>">
                          </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>