<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
	<script src="/js/jquery-2.1.0.min.js"></script>
	<script src="/js/jquery.redirect.js"></script>
	<script type="text/javascript">   
function Redirect() 
{  
	

$.redirect('textegenconfac.php', {'dnumdevis': document.getElementById("dnumdevis").value , 'didxcli': document.getElementById("didxcli").value });

	
} 
//document.write("You will be redirected to a new page in 5 seconds"); 
setTimeout('Redirect()', 500);   
</script>
	
	<style>
	
.attente{
	width:110px;
	height:110px;
	position:absolute;
	left:50%;
	top:50%;
	margin:-75px 0 0 -135px;
}
	</style>
	<img class="attente" src="spinner.gif">
	<?php 

	$debug=1;

 $myboxes = $_POST['DES'];
 $myboxes1 = $_POST['QTE'];  
 $myboxes2 = $_POST['PRIX']; 
 $myboxes3 = $_POST['UNITE'];  
 $myboxes4 = $_POST['ORDRELIGNE'];  
	$NumeroIndexDevis=$_POST['dnum'];
	$NumeroIdxClient=$_POST['didxcli'];
	
 $ordl = $_POST['ligne'];
 $RechIdx = $_POST['dnum'];	
	
	if ($debug==1)   { 
	print "idex devis ".$_POST['dnum']; //numeros idxdevis
	print "<br> Idx client ".$_POST['didxcli'];
	print "<br> date devis ".$_POST['ddate'];
	print "<br> Objet ".$_POST['object'];
	print "<br> chantier ".$_POST['dchantier'];
	print "<br> tva ".$_POST['dtva'];
	print "<br> banque ".$_POST['dbanque'];
	print "<br> Remarque ".$_POST['dremarque'];
	print "<br> Memo ".$_POST['dmemo'];
	
	} 
	if ($debug==1)   { 
	print "<br>ligne devis insertion ".$ordl; 
	print "<br>ligne devis insertion ".$_POST['ligne']; 
	print "<br>index devis ".$RechIdx."  <br>";
		}
	
	//update tete
	
$DDNUM=$_POST['devisnum'];
$DDATE=$_POST["ddate"];
$DOBJET=$_POST["object"];
$DIDXCLI=$_POST["didxcli"];
$DCHANTIER=$_POST["dchantier"];
$DTVA=$_POST["dtva"];
$DBANQUE=$_POST["dbanque"];
$DREMARQUE=$_POST["dremarque"];
$MEMO=$_POST['dmemo'];
$MONTANTHTVA=$_POST['total'];
$ETATC=$_POST['etat'];
		
					 
				
			        // on se connecte à notre base devis

$servername = "localhost:8889";
$username = "root";
$password = "root";
$dbname = "facture";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

 //$sql = "SELECT * FROM tete";
	$DCHANTIER=str_replace("'","\'",$DCHANTIER);
	$DOBJET=str_replace("'","\'",$DOBJET);
	$MEMO=str_replace("'","\'",$MEMO);
	$DREMARQUE=str_replace("'","\'",$DREMARQUE);
//$sql = "UPDATE tete SET num='$DNUM', date='$DDATE', objet='$DOBJET', idxcli='$DIDXCLI', chantier='$DCHANTIER', tva='$DTVA', banque='$DBANQUE', remarque='$DREMARQUE',memo='$MEMO',live='1',montant='$MONTANTHTVA',etat='$ETATC' WHERE idx='$NumeroIndexDevis' ";
	$sql = "UPDATE tete SET remarque='$DREMARQUE' WHERE idx='$NumeroIndexDevis' ";
		 
if ($debug==1)   { print $sql;  print "<br>"; } 
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {

        //echo "Num: " . $row["dnum"]. " - Date: " . $row["ddate"]. " - Objet: " . $row["objet"]. " Idex" . $row["didxcli"]. "<br>";
		//echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. "  " . $row["nom2"]. "<br>";
    } 
	
	
	
	} else {
   if ($debug==1)   { echo "0 results";} 
}

$conn->close();
			 
	
	
	
	

	
?>
	
			<form method = "post" action = "textegenconfac.php">	

			<input type="hidden" size="60" name="dnumdevis" id="dnumdevis" value="<?php echo $NumeroIndexDevis; ?>" > 
		
       		<input type="hidden" size="60" name="didxcli" id="didxcli" value="<?php echo $NumeroIdxClient; ?>" >
			
			<input type = "hidden" type = "submit" id = "update" value = "suivant"><br> 
	

<body>
</body>
</html>