<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
 include("db.php");
   $get_id=$_GET['id'];
    
    
   
  $information_sql="select * from `havale` where id='$get_id'";
  $information_query= $db->query($information_sql);
  $information_row=$information_query->fetch_array();
  
  $retrive_customerName=$information_row['customerName'];
  $retriveid_fname=$information_row['fname'];
  $retrive_id_cart=$information_row['id_cart'];
  $retrive_telephone=$information_row['telephone'];
  $retrive_address=$information_row['address'];
  $retrive_description=$information_row['description'];
  $retrive_image=$information_row['image'];
  
?>  
<html>
<head>
	<title>ویرایش اطلاعات مشتری</title>
	 
	<link rel="stylesheet" type="text/css" href="../css/style.css">
   <script src="dist/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="dist/sweetalert.css">  
</head>
<body>

	<div id="wrap">
		 
		<div id="contentt">
			 
			<div id="menu">
				<?php  //include("menu.php") ;   ?>
			</div>
		    <div id="matlab" >
			<div id="title"><p>ویرایش اطلاعات شخصی حواله مشتری</p> </div>
			<div id="picture" >
					<table border="0" width="400px">
						<tr>
							<td style="width:180px;"><img src="../customerPicthre/<?php echo $retrive_image  ?>.jpg" width="330px" height="460px">  </td>
							<td > </td>
						</tr>
					</table>
			   </div>
		    	<form method="post" action="">
               <table border="0"   id="rgistera_cart" width="800px" class="font">
		    		<tr>
						 
		    			<th style="width:150px">نام مشتری </th>
						<td style="width:250px" ><input type="text" name="customerName"   value='<?php  echo $retrive_customerName;   ?>'></td>
						 
							 
						 </td>
		    		</tr>
					<tr>
						 
		    			<th style="width:150px">تخلص</th>
						<td style="width:250px" ><input type="text" name="fname"   value='<?php  echo $retriveid_fname;   ?>'></td>
						 
							 
						 </td>
		    		</tr>
					
					<tr>
						 
		    			<th style="width:150px">شماره تذکره  </th>
						<td style="width:250px" ><input type="text" name="id_cart"   value='<?php  echo $retrive_id_cart;   ?>'></td>
						 
							 
						 </td>
		    		</tr>
					<tr>
						 
		    			<th style="width:150px">شماره تماس </th>
						<td style="width:250px" ><input type="text" name="telephone"   value='<?php  echo $retrive_telephone;   ?>'></td>
						 
							 
						 </td>
		    		</tr>
					<tr>
						 
		    			<th style="width:150px">آدرس </th>
						<td style="width:250px" ><input type="text" name="address"   value='<?php  echo $retrive_address;   ?>'></td>
						 
							 
						 </td>
		    		</tr>
					 
					<tr>
						 
		    			<th style="width:150px">توضیحات</th>
						<td style="width:250px"><textarea rows="3" cols="23"  name="description"  ><?php echo $retrive_description;  ?></textarea></td>
						 
		    		</tr>
					<tr>
					 
		    			<th style="width:150px"> </th>
						<td style="width:230px"> 
						    <input type="submit" id="save"   name="save"  value="ذخیره">
							<input type="submit" id="back"   name="back"  value="انصراف">
							
						</td>
						<td style="width:300px;"> </td> 
		    		</tr>
                    
		    	</table>
		    	 
				</form>
		    </div>


		</div>
		 
	</div>
</body>
</html>
<?php
if($_POST['back']){
  header("location:../add_customer.php");
}
if($_POST['save']){
 $customerName=$_POST['customerName'];
 
 $fname=$_POST['fname'];
 
 $id_cart=$_POST['id_cart'];
 
 $telephone=$_POST['telephone'];
  
 $address=$_POST['address'];
   
 $description=$_POST['description'];
 echo "<br>";
 
	   //.....................................................Estimate
	   $checkExistingSql="select * from havale where customerName='$customerName' and fname='$fname' and id_cart='$id_cart' and telephone='$telephone' and address='$address'   ";
	   $checkExistingQuery=$db ->query($checkExistingSql);
	   $checkExistingRow=$checkExistingQuery ->fetch_array();
	   $checkExisting=$checkExistingRow['customerName'];
	 
		if(isset($checkExisting)){
	 
		echo' <script>
					sweetAlert("اخطار...", "اطلاعات وارده در سیستم موجود است", "error");
			   </script>'; 
			 die;
		}
	   //....................................................End of Estimate
	   //....................................................Update Measure
	   $updateCustomer_sql="update `havale` set customerName='$customerName',fname='$fname',id_cart='$id_cart',telephone='$telephone',description='$description' where id='$get_id'";
	   $updateCustomer_query= $db ->query($updateCustomer_sql);
	     			
				  
		 echo' <script>
					 
					
				   swal("ذخیره موفق!", "اطلاعات وارده با موفقیت ثبت سیستم شد", "success")
				</script>';
	   echo '<meta http-equiv="refresh" content ="1; url=../havale_Customer.php" >';
	  echo  "<span style='color: #FFF'>Your Change Done</span>";
	   die;
	   //..................................................................
		
	 
		 
}



?>