<?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";
?>
<script language="javascript">
function intFormat(n)
{
var
regex = /(\d)((\d{3},?)+)$/;

n = n.split(',').join('');

while(regex.test(n))
{
n = n.replace(regex, '$1,$2');
}

return n;
}

function numFormat(n)
{
var
pointReg = /([\d,\.]*)\.(\d*)$/, f;

if(pointReg.test(n))
{
f = RegExp.$2;
return intFormat(RegExp.$1) + '.' + f;
}
return intFormat(n);
}
</script> 
<?php
	$act  = $_REQUEST['act'];
	$id  = $_REQUEST['id'];
	$inventory = $_REQUEST['inventory'];
	
	if($act == 1)
	{
		$id  = $_REQUEST['id'];
		$description  = $_REQUEST['description'];
		list($d, $e, $f)=split ("[-]", $_REQUEST['inputDate']);
		$datepicker=$f."-".$e."-".$d;
		$price = str_replace(",","", $_REQUEST['price']);
		$currency  = $_REQUEST['currency'];
		$kurs = mysql_fetch_array(mysql_query("select * from tbl_usd order by date_update desc limit 1"));
		$usd = $kurs['usd'];
		$insert = mysql_query("insert into salesservice (id_sales,description,tanggal, price, user_update,idr,currency) values ('$id','$description','$datepicker','$price','$USERNAME','$usd','$currency')");

						if($insert)
						{
						?>
								<script language="javascript">
									 alert("Add Service Sales Success");
									document.location="add_salesdetails.php?act=3&id=<?php echo $id; ?>";
								</script>
						<?php
						}
						else
						{
							?>
								<script language="javascript">
									alert("Add Service Sales Failed");
									document.location="add_salesdetails.php?act=3&id=<?php echo $id; ?>";
								</script>
							<?php
						}
	}
	elseif($act == 2)
	{
		$id_servicesales  = $_REQUEST['id_servicesales'];
		$id  = $_REQUEST['id'];
		$insert = mysql_query("update salesservice set status = 2,user_update = '$USERNAME' where id_servicesales='$id_servicesales'");

						if($insert)
						{
						?>
								<script language="javascript">
									 alert("Delete Service Sales Success");
									document.location="add_salesdetails.php?act=3&id=<?php echo $id; ?>";
								</script>
						<?php
						}
						else
						{
							?>
								<script language="javascript">
									alert("Delete Service Sales Failed");
									document.location="add_salesdetails.php?act=3&id=<?php echo $id; ?>";
								</script>
							<?php
						}
	}
	elseif($act == 3)
	{
		
	?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-shopping-cart"></i>Add Service Sales</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="add_salesdetails.php?act=1&id=<?php echo $id; ?>" role="form" class="form-horizontal">
                        <div class="form-group">
                          <label class="col-md-4 control-label">Services Description</label>
                          <div class="col-md-8">
                           <textarea cols="80" rows="5" name="description" id="description" class="form-control"></textarea>
                          </div>
                          </div>
                          <div class="form-group">
                          <label class="col-md-4 control-label">Currency</label>
                          <div class="col-md-8">
                          <select name="currency" id="currency" class="col-md-4 control-label">
                           <option value="USD">USD</option>
                           <option value="IDR">IDR</option>
                          </select>
                          </div>
                        </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">Price</label>
                          <div class="col-md-8"><input type="text" class="form-control" name="price" id="price"  value="0" >
                          </div>
                        </div>
                        
                          <div class="form-group">
                          <label class="col-md-4 control-label">Pick Up Date</label>
                          <div class="col-md-8">
                             <input type="text" class="inputDate" name="inputDate" id="inputDate" value="<?php echo date('d-m-Y'); ?>">
                          </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>
                       <table class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                      	  <th>Service Description</th>
                          <th>Currency</th>
                     <th>Price</th>
                     <th>Pick Up Date</th>
                     <th>Details</th>
                    </tr>
                  </thead>
                  <tbody>
                   <?php
						$sql = mysql_query("select * from salesservice a
						inner join sales b on a.id_sales = b.id_sales
						where a.status = 1 and a.id_sales  = '$id'
						order by a.tanggal");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_servicesales = $fetch['id_servicesales'];
								list($y, $m, $d)=split ("[-]",$fetch['tanggal']);
								$tanggal=$d."-".$m."-".$y;
								$id_sales = $fetch['id_sales'];
								
					?>
                 <tr class="gradeX">
                     <td><?php echo $fetch['description']; ?></td>
                     <td><?php echo $fetch['currency']; ?></td>
                     <td><?php echo number_format($fetch['price'], 0, ',', ','); ?></td>
                      <td><?php echo $tanggal; ?></td>
                   <td class="actions aligncenter"><a href="add_salesdetails.php?act=2&id_servicesales=<?php echo $id_servicesales; ?>&id=<?php echo $id_sales; ?>">Delete</a></td>
                      
                </tr>
                <?php
						}
						?>
                  </tbody>
                </table>
                 <form class="stdform stdform2" method="post" action="sales.php" name = "frm2">
                     <p class="stdformbutton">
                        	<button class="btn btn-default">Done</button>
                        </p>
                         </form>
                    </div>
                    </div>
                    </div>
                    </div>
                    </div>
                   

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>
 <?php
	}
	elseif($act == 4)
	{
	?>
    <body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-shopping-cart"></i>Add Details Sales</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="add_salesdetails.php?act=5&inventory=<?php echo $inventory; ?>&id=<?php echo $id; ?>" role="form" class="form-horizontal">
                        <div class="form-group">
                          <label class="col-md-4 control-label">Qty</label>
                          <div class="col-md-8">
                           <input type="text" name="qty" id="qty" value="1"  class="form-control"/>
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">Barcode No.</label>
                          <div class="col-md-8"><select name="barcode" id="barcode" class="form-control">
							  <?php
							  					if($inventory == "inventory")
												{
                                             	 $sql3 = "select * from (
												 		select kode_stock,barcodeno,description from inventory_diamond where status_stock=1 and id_status = 3
												 		union all
														select kode_stock,barcodeno,description from inventory_gold where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from  inventory_logam where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from inventory_readyitem where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from inventory_cincin where status_stock=1 and id_status = 3 
														union all
														select kode_stock,barcodeno,description from inventory_mastura where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from inventory_liontin where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from inventory_kerabu where status_stock=1 and id_status = 3 
														union all
														select kode_stock,barcodeno,description from inventory_gkgr where status_stock=1 and id_status = 3
														union all
														select kode_stock,barcodeno,description from inventory_rangka where status_stock=1 and id_status = 3) a
														order by  barcodeno ";
												}
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                        <option value="<?php echo $fetch3['kode_stock']; ?>"><?php echo  $fetch3['barcodeno'];  ?></option>
                                                      <?php
                                              }
                                             ?>
                            </select>
                          </div>
                        </div>
                        
                        <div class="form-group">
                          <div class="col-md-offset-4 col-md-8">
                         <button class="btn btn-default">Next</button>
                          </div>
                        </div>
                      </form>
                        <table class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                      	 <th>Inventory</th>
                      <th>Kode Inventory</th>
                     <th>Barcode</th>
                     <th>Qty</th>
                     <th>Date</th>
                     <th>Price</th>
                     <th>Currency</th>
                     <th>Details</th>
                    </tr>
                  </thead>
                  <tbody>
                 <?php
						$sql = mysql_query("select * from salesdetails a
						inner join sales b on a.id_sales = b.id_sales
						where a.status = 1 and a.id_sales  = '$id'
						order by a.tanggal");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_salesdetails = $fetch['id_salesdetails'];
								list($y, $m, $d)=split ("[-]",$fetch['tanggal']);
								$tanggal=$d."-".$m."-".$y;
								$id_sales = $fetch['id_sales'];
								$kode_stock = $fetch['kode_stock'];
								$price = $fetch['price'];
								
					?>
                 <tr>
                     <td><?php echo $fetch['inventory']; ?></td>
                      <td><?php echo $fetch['kode_stock']; ?></td>
                      <td><?php echo $fetch['barcode']; ?></td>
                     <td><?php echo $fetch['qty']; ?></td>
                      <td><?php echo $tanggal; ?></td>
                      <td><?php  echo number_format($price, 0, ',', ','); ?></td>
                      <td><?php echo $fetch['currency']; ?></td>
                   <td class="actions aligncenter"><a href="add_salesdetails.php?act=7&id_salesdetails=<?php echo $id_salesdetails; ?>&id=<?php echo $id_sales; ?>&inventory=<?php echo $inventory; ?>&kode_stock=<?php echo $kode_stock; ?>">Delete</a></td>
                      
                </tr>
                <?php
						}
						?>
                  </tbody>
                </table>
                 <form class="stdform stdform2" method="post" action="sales.php" name = "frm2">
                     <p class="stdformbutton">
                        	<button class="btn btn-default">Done</button>
                        </p>
                         </form>
                    </div>
                    </div>
                    </div>
                    </div>
                    </div>
                   

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>
<?php
	}
	elseif($act == 5)
	{
			
		$qty = $_REQUEST['qty']; 
		$kode_stock = $_REQUEST['barcode']; //echo $barcode; exit;
		$id = $_REQUEST['id'];
		$inventory = $_REQUEST['inventory'];
		if(($qty == 0) or ($qty == "") )
		{
						?>
								<script language="javascript">
									 alert("Qty must be filled");
									document.location="add_salesdetails.php?act=4&id=<?php echo $id; ?>&inventory=<?php echo $inventory; ?>";
								</script>
						<?php
		}
		if($inventory == "Diamond")
		{
		 $sql3 = "select * from inventory_diamond where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
		}
		elseif($inventory == "Gold")
		{
		 $sql3 = "select * from inventory_gold where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
		}
		elseif($inventory == "LogamMulia")
		{
		 $sql3 = "select * from  inventory_logam where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
		}
		elseif($inventory == "ReadyItem")
		{
		 $sql3 = "select * from inventory_readyitem where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
		}
		elseif($inventory == "Cincin")
												{
                                             	 $sql3 = "select * from inventory_cincin where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
												elseif($inventory == "Mastura")
												{
                                             	 $sql3 = "select * from inventory_mastura where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
												elseif($inventory == "Liontin")
												{
                                             	 $sql3 = "select * from inventory_liontin where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
												elseif($inventory == "Kerabu")
												{
                                             	 $sql3 = "select * from inventory_kerabu where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
												elseif($inventory == "GKGR")
												{
                                             	 $sql3 = "select * from inventory_gkgr where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
												elseif($inventory == "Rangka")
												{
                                             	 $sql3 = "select * from inventory_rangka where status_stock=1 and kode_stock = '$kode_stock' order by barcodeno";
												}
	  	$rs3 = mysql_query($sql3);
		$fetch3 = mysql_fetch_array($rs3);
		$description  = $fetch3['description'];
		$kode_stock  = $fetch3['kode_stock'];
		$barcodeno  = $fetch3['barcodeno'];
		$harga  = mysql_fetch_array(mysql_query("select * FROM tbl_cblb"));
		$lbprice = $harga['lbprice'];
		$cbprice = $harga['cbprice'];
		if($inventory == "Diamond")
		{
		 	$certificate_name  = $fetch3['certificate_name'];
			$loc = "certificate/";
			$all = $loc.$certificate_name; 
		}
		elseif($inventory == "ReadyItem")
		{
			$picture = $fetch3['picture'];
			$loc = "readyitem/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Cincin")
		{
			$picture = $fetch3['picture'];
			$loc = "cincin/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Liontin")
		{
			$picture = $fetch3['picture'];
			$loc = "liontin/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Mastura")
		{
			$picture = $fetch3['picture'];
			$loc = "mastura/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Kerabu")
		{
			$picture = $fetch3['picture'];
			$loc = "kerabu/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "GKGR")
		{
			$picture = $fetch3['picture'];
			$loc = "gkgr/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Rangka")
		{
			$picture = $fetch3['picture'];
			$loc = "rangka/";
			$all = $loc.$picture; 
		}
		elseif($inventory == "Gold")
		{
			$picture = $fetch3['picture'];
			$loc = "gold/";
			$all = $loc.$picture; 
		}
	?>
  <body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-shopping-cart"></i>Add Details Sales</h1>
</div>

          <div class="main-content">
            <div class="row">
                <div class="widget">
                
                    <div class="padded">
                      <form method="post" action="add_salesdetails.php?act=6&inventory=<?php echo $inventory; ?>&id=<?php echo $id; ?>&kode_stock=<?php echo $kode_stock; ?>">
                        <div class="form-group">
                          <label class="col-md-4 control-label">Qty</label>
                          <div class="col-md-8">
                           <input type="text" name="qty" id="qty" value="1"  class="form-control"/>
                          </div>
                          </div>
                            <div class="form-group">
                          <label class="col-md-4 control-label">Barcode No.</label>
                          <div class="col-md-8"><input type="text" name="barcode" id="barcode" class="form-control" value="<?php echo $barcodeno; ?>"  readonly="readonly" />
                          </div>
                        </div>
                         <div class="form-group">
                          <label class="col-md-4 control-label">Item No.</label>
                          <div class="col-md-8"><input type="text" name="barcode" id="barcode" class="form-control" value="<?php echo $kode_stock; ?>"  readonly="readonly" />
                          </div>
                        </div>
                          <div class="form-group">
                          <label class="col-md-4 control-label">Currency</label>
                          <div class="col-md-8">
                          <select name="currency" id="currency" class="form-control">
                           <option value="USD">USD</option>
                           <option value="IDR">IDR</option>
                          </select>
                          </div>
                        </div>
                         <div class="form-group">
                          <label class="col-md-4 control-label">Price</label>
                          <div class="col-md-8"><input type="text" name="price" id="price" class="form-control" onKeyUp="this.value = numFormat(this.value)"  value="<?php  echo $cbprice; ?>"  /><input type="hidden" name="cbprice" id="cbprice" class="form-control" value="<?php  echo $cbprice; ?>"  />
                          </div>
                        </div>
                        <div class="form-group">
                          <label class="col-md-4 control-label">Description</label>
                          <div class="col-md-8"><textarea cols="80" rows="5" name="description" id="description" class="form-control" readonly="readonly"><?php echo $description; ?></textarea>
                          </div>
                        </div>
               
                          
                          <?php
							if($inventory == "Diamond")
							{
						?>
                        
                        <div class="form-group">
							 <label class="col-md-4 control-label">Sertificate</label>
                             <div class="col-md-8">
                              <a class="image" href="<?php echo $all; ?>" >
                            	<strong><?php echo $certificate_name; echo "</br>"; ?></strong></a>
                         
                        </div></div>
                           <?php
							}
							else
							{
						?>   
                             
                         <div class="form-group">
							 <label class="col-md-4 control-label">Picture</label>
                             <div class="col-md-8">
                            <a class="image" href="<?php echo $all; ?>" >
							<img src="<?php echo $all; ?>" alt="" height="69" width="117"/></a>&nbsp;
                        	</div></div>
    				 <?php }?>
						
                           <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" onClick="document.location='javascript:history.back(-1)'">Back</button>
                          </div>
                      </form>
                   </div>
                    </div>
                    </div>
                    </div>
                   

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>
<?php
	}
	elseif($act == 6)
	{
		$id  = $_REQUEST['id'];
		$inventory  = $_REQUEST['inventory'];
		$qty  = $_REQUEST['qty'];
		$barcode  = $_REQUEST['barcode'];
		$cbprice  = $_REQUEST['cbprice'];
		$price = str_replace(",","", $_REQUEST['price']);
		$currency  = $_REQUEST['currency'];
		$datepicker = date('Y-m-d');

		if($inventory == "Diamond")
		{
		 $sql4 = "select * from inventory_diamond where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Gold")
		{
		 $sql4 = "select * from inventory_gold where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "LogamMulia")
		{
		 $sql4 = "select * from  inventory_logam where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "ReadyItem")
		{
		 $sql4 = "select * from inventory_readyitem where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Cincin")
		{
		 $sql4 = "select * from inventory_cincin where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Mastura")
		{
		 $sql4 = "select * from inventory_mastura where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Liontin")
		{
		 $sql4 = "select * from inventory_liontin where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Kerabu")
		{
		 $sql4 = "select * from inventory_kerabu where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "GKGR")
		{
		 $sql4 = "select * from inventory_gkgr where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
		elseif($inventory == "Rangka")
		{
		 $sql4 = "select * from inventory_rangka where status_stock=1 and kode_stock = '$barcode' order by barcodeno";
		}
	  	$rs4 = mysql_query($sql4);
		$fetch4 = mysql_fetch_array($rs4);
		$description  = $fetch4['description'];
		$kode_stock  = $fetch4['kode_stock'];
		$barcodeno  = $fetch4['barcodeno'];
		$kurs = mysql_fetch_array(mysql_query("select * from tbl_usd order by date_update desc limit 1"));
		$usd = $kurs['usd'];
		$insert = mysql_query("insert into salesdetails (id_sales,qty,tanggal, barcode, user_update,inventory,kode_stock,idr,price,currency,cbprice) values ('$id','$qty','$datepicker','$barcodeno','$USERNAME','$inventory','$kode_stock','$usd','$price','$currency','$cbprice')");
		if($inventory == "Diamond")
		{
		 $sql3 = "update inventory_diamond set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Gold")
		{
		 $sql3 = "update inventory_gold set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "LogamMulia")
		{
			$sql3 = "update inventory_logam set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "ReadyItem")
		{
		 $sql3 = "update inventory_readyitem set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Cincin")
		{
		 $sql3 = "update inventory_cincin set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Mastura")
		{
		 $sql3 = "update inventory_mastura set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Liontin")
		{
		 $sql3 = "update inventory_liontin set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Kerabu")
		{
		 $sql3 = "update inventory_kerabu set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "GKGR")
		{
		 $sql3 = "update inventory_gkgr set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Rangka")
		{
		 $sql3 = "update inventory_rangka set id_status=4, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		
		$update = mysql_query($sql3);
					if($insert && $update)
						{
						?>
								<script language="javascript">
									 alert("Add Details Sales Success");
									document.location="add_salesdetails.php?act=4&id=<?php echo $id; ?>&inventory=<?php echo $inventory; ?>";
								</script>
						<?php
						}
						else
						{
							?>
								<script language="javascript">
									alert("Add Details Sales Failed");
									document.location="add_salesdetails.php?act=4&id=<?php echo $id; ?>&inventory=<?php echo $inventory; ?>";
								</script>
							<?php
						}
	}
	elseif($act == 7)
	{
		$id_salesdetails  = $_REQUEST['id_salesdetails'];
		$inventory  = $_REQUEST['inventory'];
		$kode_stock  = $_REQUEST['kode_stock'];
		$id  = $_REQUEST['id'];
		$insert = mysql_query("update salesdetails set status = 2,user_update = '$USERNAME' where id_salesdetails='$id_salesdetails'");
		if($inventory == "Diamond")
		{
		 $sql3 = "update inventory_diamond set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Gold")
		{
		 $sql3 = "update inventory_gold set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "LogamMulia")
		{
			$sql3 = "update inventory_logam set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "ReadyItem")
		{
		 $sql3 = "update inventory_readyitem set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Cincin")
		{
		 $sql3 = "update inventory_cincin set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Mastura")
		{
		 $sql3 = "update inventory_mastura set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Liontin")
		{
		 $sql3 = "update inventory_liontin set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Kerabu")
		{
		 $sql3 = "update inventory_kerabu set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "GKGR")
		{
		 $sql3 = "update inventory_gkgr set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		elseif($inventory == "Rangka")
		{
		 $sql3 = "update inventory_rangka set id_status=3, user_update='$USERNAME' where kode_stock = '$kode_stock'";
		}
		$update = mysql_query($sql3);
						if($insert && $update)
						{
						?>
								<script language="javascript">
									 alert("Delete Sales Details Success");
									document.location="add_salesdetails.php?act=4&id=<?php echo $id; ?>&inventory=<?php echo $inventory; ?>";
								</script>
						<?php
						}
						else
						{
							?>
								<script language="javascript">
									alert("Delete Sales Details Failed");
									document.location="add_salesdetails.php?act=4&id=<?php echo $id; ?>&inventory=<?php echo $inventory; ?>";
								</script>
							<?php
						}
	}
	?>
</html>