<!doctype html>
<html><head>
<meta charset="UTF-8">
<title>DEVIS</title>

	

	<link rel="stylesheet" href="textedit.css" media="all" />
	<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
	<script src="js/jquery-2.1.0.min.js"></script>
	<script type="text/javascript" src="js/jquery.tablednd.js"></script>
	<script src="js/jquery-ui.js"></script>
	<script src="js/jquery.ui.touch-punch.js"></script>
  
    <meta name="viewport" content="width=device-width, initial-scale=1">
  
<script src="js/bootstrap.min.js"></script>
    

<script src="js/jquery.redirect.js"></script>
  
<link rel="stylesheet" href="css/bootstrap.csss" >
<link rel="stylesheet" href="css/font-awesome.css" >
    
    
    
	<script src="/js/moment.js"></script>
	<script src="/js/jquery.redirect.js"></script>
	<!-- <script src="/js/swap.js"></script> -->
	
	</head>
    
   
	
    
<body onLoad="calculload()">
		 	
	
	
		<?php

		$NumeroIndexDevisP=$_POST['dnumdevis'];
		$NumeroIdxClient=$_POST['didxcli'];
	//	print "<br>".$NumeroIndexDevisP;	
	//	print "<br>".$NumeroIdxClient;	

// on se connecte à notre base pour devis

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

// 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";
$sql = "SELECT * FROM tete WHERE idx=".$NumeroIndexDevisP." ";
//$sql = "SELECT * FROM tete WHERE idx=".intval($_POST['idxcli'])." ";
//print "<br>".$sql;	
			// print "<br>".$sql;	
			 
					// $sql = "UPDATE\n". "  `data`\n"." SET\n". " societe = \'testoooyeahhh\'\n". "WHERE\n". " id = 3";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
		
$NUM=$row["num"];
$IDX=$row["idx"];
$DATE=$row["date"];
$OBJETT=$row["objet"];
$IDXCLI=$row["idxcli"];
$MEMO=$row["memo"];
$ETATC=$row["etat"];		
		$NumeroIdxClient=$row["idxcli"];;
$CHANTIER=$row["chantier"];
$TVA=$row["tva"];
$BANQUE=$row["banque"];
$REMARQUE=$row["remarque"];

    } 
    
	
	} else {
   // echo "0 results";
}

//$sql = "INSERT INTO data (societe,nom1,nom2,nom3,nom4,nom5,titre,ac1,ac2,o1,o2,o3,mail,tel,gsm,pub,jour)
//VALUES ('$SOC' , '$NOM1', '$NOM2', '$NOM3', '$NOM4', '$NOM5', '$TITRE', '$AC1', '$AC2', '$O1', '$O2', '$O3', '$MAIL', '$TEL', '$GSM', '$PUB', //'$today')";

    // recupération données salaires

    $sql = "SELECT * FROM solaire WHERE idxdevis=".$NumeroIndexDevisP." ";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
		
$PANNEAUX=$row["panneaux"];
$MARQUEP=$row["marquepanneaux"];
$MO=$row["MO"];
$PUISSANCE=$row["puissance"];
$MARQUEINDULEUR=$row["marqueonduleur"];
$CABLE=$row["cable"];
$TYPETOIT=$row["typetoit"];		
$PENTE=$row["pente"];;
$AZIMUT=$row["azimut"];
$COEF=$row["coef"];
$PERTEPANNEAU=$row["pertepanneaux"];
$DIFFICULTE=$row["difficulte"];
$RecValeur=$row["reception"];
$PRIXPANN=$row["prixpanneaux"];
$PRIXONDUL=$row["prixonduleur"];
$CompteurElec=$row["compteur"];
$GrapSol = array($row["r1"],$row["r1"],$row["r2"],$row["r3"],$row["r4"],$row["r5"],$row["r6"],$row["r7"],$row["r8"],$row["r9"],$row["r10"],$row["r11"],$row["r12"],$row["r13"],$row["r14"],$row["r15"],$row["r16"],$row["r17"],$row["r18"],$row["r19"],$row["r20"],$row["r21"],$row["r22"],$row["r23"],$row["r24"]);
    } 
    
	
	} else {
   // echo "0 results";
}
    
    
    
    
$conn->close();
		
		?>
	
		
<?php		
		
				
		// on se connecte aux client ******************************************
		
$SOC=" ";
$NOM1=" ";
$NOM2=" ";
$NOM3=" ";
$NOM4=" ";
$NOM5=" ";
$TITRE=" ";
$PUB=" ";
$AC1=" ";
$AC2=" ";
$O1=" ";
$O2=" ";
$O3=" ";
$MAIL=" ";
$GSM=" ";
$TEL=" ";
$SIDXCLI=" ";

// on se connecte à notre base pour client

$servername = "localhost:8889";
$username = "test";
$password = "test";
$dbname = "Clients";

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

$SIDXCLI = htmlentities($_POST['idxcli']);
	// print "dans la boite<br>";

    
	

					 $sql = "SELECT * FROM data";
$sql = "SELECT * FROM data WHERE id=".$NumeroIdxClient." ";
//$sql = "SELECT * FROM data WHERE id=".intval($_POST['idxcli'])." ";
//print "<br>".$sql;		
		
					// $sql = "UPDATE\n". "  `data`\n"." SET\n". " societe = \'testoooyeahhh\'\n". "WHERE\n". " id = 3";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
		
$SOC=$row["societe"];
$NOM1=$row["nom1"];
$NOM2=$row["nom2"];
$NOM3=$row["nom3"];
$NOM4=$row["nom4"];
$NOM5=$row["nom5"];
$TITRE=$row["titre"];
$PUB=$row["pub"];
$AC1=$row["ac1"];
$AC2=$row["ac2"];
$O1=$row["o1"];
$O2=$row["o2"];
$O3=$row["o3"];
$MAIL=$row["mail"];
$GSM=$row["gsm"];
$TEL=$row["tel"];
$SIDXCLI =$row["id"];
        //echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. " - idx: " . $row["id"]. " " . $row["nom2"]. "<br>";
		//echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. "  " . $row["nom2"]. "<br>";
    } 
    
	
	} else {
   // echo "0 results";
}

//$sql = "INSERT INTO data (societe,nom1,nom2,nom3,nom4,nom5,titre,ac1,ac2,o1,o2,o3,mail,tel,gsm,pub,jour)
//VALUES ('$SOC' , '$NOM1', '$NOM2', '$NOM3', '$NOM4', '$NOM5', '$TITRE', '$AC1', '$AC2', '$O1', '$O2', '$O3', '$MAIL', '$TEL', '$GSM', '$PUB', //'$today')";


$conn->close();
					 
		
		
		
	?>			
	
    
    
    
    
	
		
		 
				  
		
    
    			 <div class="gencont">
	
	
	
	
	  <div id="company">
		<h2 class="name">Ypsoroof - Ipsotoit</h2>
        <h2 class="name2">135 rue montavaux, 7080, Frameries </h2>
        <h2 class="name2">065/793325. Entr.:BE0443870515</h2>
		  <h2 class="name2">Banque CPH IBAN:BBE75</h2>
		   <h2 class="name2">Compte: BE92 1262 1506 3723</h2>
      <!--  <div><a href="mailto:info@ypsoroof.com">info@ypsoroof.com</a></div> -->
      </div>
        
		  <div id="client">
			
        <!--   <div class="to">CLIENT:</div> -->
            <h2 class="name"><?php echo $SOC ?></h2>
			<div class="address"><?php echo $TITRE.$NOM1 ?></div>
            <div class="address"><?php echo $NOM2 ?></div>
			<div class="address"><?php echo $NOM3 ?></div>
			<div class="address"><?php echo $NOM4?></div>
			<div class="address"><?php echo $NOM5?></div>
	
		   </div>		
                     
                      <?php
				  switch ($ETATC) {
    case 0:
        echo " <div id='etatcom' style='display:none'>  ";
        break;
    case 1:
        echo " <div id='etatcom' style='display:block'>  En commande";
        break;
    case 2:
        echo " <div id='etatcom' style='display:block'>  En facturation";
        break;
	case 3:
        echo " <div id='etatcom' style='display:block'>  Clôturée";
		break;
	case 4:
       echo "<div id='etatcom' style='display:block'>  Brouillon";
        break;
}
		?>	  </div>
                     
	<div style="clear:both"></div>
      <style>
     #solaireOffre {
  position: absolute;
  left:0px;
  top  :100px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 520px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 8px;
  background-color: transparent;
  color:#2c2b2b;
   
}
        </style>   
		<div id="solaireOffre">	 
			  <div id="invoice" style="background-color: transparent;"><br>
         Devis N°<?php echo $NUM ?>
				 
         
		 
            </div>  </div>
       <style>
#solaire {
  position: absolute;
  right:85px;
  top  :580px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 620px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: 1.4em;
   color:#F0F1F6;
   
}
#solaireBox{
  position: absolute;
  right:85px;
  top  :310px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 620px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: transparent;
    font-size: 4em;
    text-align: center;
color:#F0F1F6;
   z-index: 10;
}
           #solaireBoxLine{
  position: absolute;
  right:85px;
  top  :395px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 620px;
    height: 2px;
  border-style: solid;
  border: 0px solid rgba(4,98,246,1.00);
  border-radius: 8px;
  background-color: #49549E;
    font-size: 4em;
    text-align: center;
  color:#2c2b2b;
    z-index: 9;
}
             #solaireBoxLayer{
  position: absolute;
  left:15px;
  top  :720px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 764px;
    height: 350px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: rgba(255,255,255,0.85);
    font-size: 4em;
    text-align: center;
  color:#2c2b2b;
    z-index: 0;
}
           
           
           #solaireBoxLine2
           {
  position: absolute;
  right:85px;
  top  :430px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 620px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: transparent;
    font-size: 3em;
    text-align: center;
  color:#F0F1F6;
  
}
           
                   #solaireBoxCol1
           {
  position: absolute;
  left:45px;
  top  :750px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 220px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: transparent;
    font-size: 1.2em;
    text-align: justify;
               font-weight: bold; 
  color:#F0F1F6;
               color:#555555;
   z-index: 1;
}
                             #solaireBoxCol2
           {
  position: absolute;
  right:285px;
  top  :750px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 220px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: transparent;
    font-size: 1.2em;
    text-align: justify;
               font-weight: bold; 
  color:#F0F1F6;
               color:#555555;
  
}
                             #solaireBoxCol3
           {
  position: absolute;
  right:45px;
  top  :750px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 220px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
  background-color: transparent;
    font-size: 1.2em;
    text-align: justify;
               font-weight: bold; 
  color:#3F4368;
            
   color:#555555;
  
}
    </style>
   
    
   
     <div id="solaireBoxLine"></div>
    <div id="solaireBoxLayer"></div>
    <div id="solaireBoxLine2">Installation de panneaux solaires</div>
     <div id="solaireBox">Le photovoltaïque  <br><br></div>
     <div id="solaire" style="text-align: justify;">Votre projet en quelques chiffres : 
    <?php echo $PANNEAUX; ?> panneaux d'une puissance totale de <?php echo $PUISSANCE; ?> Wc installés sur une toiture <?php echo $TYPETOIT; ?>.
         
         </div>
    
    <div id="solaireBoxCol3">  <p style=" text-align:center;font-weight: bold;margin-top: -10px;"><img src="idea.png" width="45" height="45"></p><p style=" font-weight: bold;margin-top: -10px;text-align:center;">Efficacité :</p>
        <p style="  font-size: 0.8em;font-weight: normal;">Les technologies sont en perpétuelles ameliorations et il est important pour nous que vous disposiez de la technologie adaptée à vos demandes. Notre équipe vous proposera la solution la plus intéressante pour votre profil.</p>

</div>
    
    <div id="solaireBoxCol2"> <p style=" text-align:center;font-weight: bold;margin-top: -10px;"><img src="technical-service-van.png" width="45" height="45"></p><p style=" font-weight: bold;margin-top: -10px;text-align:center;">Notre service :</p>
         <p style="  font-size: 0.8em;font-weight: normal;">Nous répondons à vos demandes le plus rapidement possible et nous vous conseillons dans vos demarches pour un avenir plus vert. </p>

</div>
    
    
    <div id="solaireBoxCol1"> <p style=" text-align:center;font-weight: bold;margin-top: -10px;"><img src="coins.png" width="45" height="45"></p> <p style=" font-weight: bold;margin-top: -10px;text-align:center;">Vos avantages : </p>
        <p style="  font-size: 0.8em;font-weight: normal;">Vous produisez votre propre électricité à partir d’une source d’énergie inépuisable et gratuite tout en étant certain d’avoir une quantité d’électricité garantie pour votre propre consommation à un prix fixe! </p>
</div>
    
    
     <img src= "logofacsol2c.png" height="1110" width="794" style="page-break-after: always;margin-top: 0px;margin-bottom: 0px;">
   
    
    <script src="js/jscolor.js"></script>
    <style>
        .couleurcolonne {
background-color: #b0d3f5;
           
}
         .couleurFondscolonne1 {
background-color: #D0E4F9;
            
}
         .couleurFondscolonne2 {
background-color: #93C3F1;
            
             
}
        
    </style>
    
    
    
			 <div class="gencont" >
	
		<div id="logo" onClick="myFunction() "><img src= "logofacsol1.png" width="794"></div>	
		
	
	  <div id="company">
		<h2 class="name">Ypsoroof - Ipsotoit</h2>
        <h2 class="name2">135 rue montavaux, 7080, Frameries </h2>
        <h2 class="name2">065/793325. Entr.:BE0443870515</h2>
		  <h2 class="name2">Banque CPH IBAN:BBE75</h2>
		   <h2 class="name2">Compte: BE92 1262 1506 3723</h2>
      <!--  <div><a href="mailto:info@ypsoroof.com">info@ypsoroof.com</a></div> -->
      </div>
        
		  <div id="client">
			
        <!--   <div class="to">CLIENT:</div> -->
            <h2 class="name"><?php echo $SOC ?></h2>
			<div class="address"><?php echo $TITRE.$NOM1 ?></div>
            <div class="address"><?php echo $NOM2 ?></div>
			<div class="address"><?php echo $NOM3 ?></div>
			<div class="address"><?php echo $NOM4?></div>
			<div class="address"><?php echo $NOM5?></div>
	
		   </div>	
                 
                  <?php
				  switch ($ETATC) {
    case 0:
        echo " <div id='etatcom' style='display:none'>  ";
        break;
    case 1:
        echo " <div id='etatcom' style='display:block'>  En commande";
        break;
    case 2:
        echo " <div id='etatcom' style='display:block'>  En facturation";
        break;
	case 3:
        echo " <div id='etatcom' style='display:block'>  Clôturée";
		break;
	case 4:
       echo "<div id='etatcom' style='display:block'>  Brouillon";
        break;
}
		?>	  </div>
                 
	<div style="clear:both"></div>
        
			<div id="solaireOffre">	 
			  <div id="invoice" style="background-color: transparent;"><br>
         Devis N°<?php echo $NUM ?>
				 
          <div id="datestyle" class="date" style="border-bottom: 1px solid black; border-left: 4px  solid #EFD61E; max-width:300px;background-color: transparent;" contenteditable="true" ><?php echo $DATE ?> </div>
		 
            </div>  </div>
                 
                 
	<div style="clear:both"></div>
			
    
    
	<table  cellspacing="0" cellpadding="-1" width="794px" border="0" valign="top" style="border-collapse: collapse;margin-top: -4px;">
		<tbody >
			<tr >  
			<td width='20px' valign='top' align='left' class='couleurcolonne' style="border-bottom: 1px solid black"> <div class='colh couleurcolonne'  contenteditable='false' style=' max-width: 20px;  '></div> </td>
			<td  width='512px' valign='top' align='left' class='couleurFondscolonne1' style="border-bottom: 1px solid black"> <div class='colh couleurFondscolonne1'  id='oobjet' contenteditable='true' style=' max-width: 512px;  '><?php echo $OBJETT?></div> </td>
			<td width='60px' valign='bottom' align='center' class='couleurFondscolonne2' style="border-bottom: 1px solid black" > <div class='colh couleurFondscolonne2'  contenteditable='true' style='max-width: 60px;  '>QT</div> </td>
				<td width='65px' valign='bottom' align='center' class='couleurFondscolonne1' style="border-bottom: 1px solid black" ><div class='colh couleurFondscolonne1'  contenteditable='true' style=' max-width: 65px;  '>PU</div> </td>
		
		<td width='40px' valign='bottom' align='center' class='couleurFondscolonne2' style="border-bottom: 1px solid black;"> <div class='colh couleurFondscolonne2'  contenteditable='true' style=' max-width: 40px; '>UM</div> </td> 
		
			<td width='95px' valign='bottom' align='center' class='couleurcolonne'  style="border-bottom: 1px solid black"> <div class='colh couleurcolonne'   contenteditable='false' style=' max-width: 95px;  '>TOT</div> </td>
		</tr>
		</tbody>
		</table>	
		
	<div style="clear:both"></div>

	
	
	
	
	
	
		<table id="table-2"  cellspacing="0" cellpadding="-1" width="794px" border="0" valign="top" style="border-collapse: collapse;" >
		
		 <tbody id="items_table">
			 
		
			 
	<?php
		
				                            // on se connecte à notre base pour ligne devis

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

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

$sql = "SELECT * FROM corps WHERE numidxdevis= '".$NumeroIndexDevisP."' ORDER BY ordre ";
//$sql = "SELECT * FROM Modele WHERE type=".intval($_POST['idxm'])." ";
					// $sql = "UPDATE\n". "  `data`\n"." SET\n". " societe = \'testoooyeahhh\'\n". "WHERE\n". " id = 3";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
	$ii=0;
    while($row = $result->fetch_assoc()) {
		
$DES=$row["des"];
$QT=$row["qt"];
$UNITE=trim($row["um"]);
$PRIX=$row["pu"];
		
$ii++;
		

        print"<tr class='yes' id='".$ii."'  >";  
		print"<td width='20px' valign='top' align='left' class='couleurcolonne' > <div class='col couleurcolonne' id='ligne1' contenteditable='false' style=' max-width: 20px; '>".$ii."</div> </td>";
		
		print"<td  width='512px' valign='top' align='left' class='couleurFondscolonne1'> <div class='col couleurFondscolonne1'  id='descriptionligne' contenteditable='true' style='max-width: 512px;  '>".$DES."</div> </td>"; 
		
        print"<td width='60px' valign='top' align='right' class='couleurFondscolonne2' > <div class='col couleurFondscolonne2' id='qtcalc' contenteditable='true' style='max-width: 60px;  '>".$QT."</div> </td> ";
			
		print"<td width='65px' valign='top' align='right' class='couleurFondscolonne1' ><div class='col couleurFondscolonne1' id='prixcalc' style='font-size: 1.5em;' contenteditable='true' style='max-width: 65px;  '>".$PRIX."</div> </td> ";
		
		print"<td width='40px' valign='top' align='center' class='couleurFondscolonne2'  > <div class='col couleurFondscolonne2' id='umcalc' contenteditable='true' style='max-width: 40px; '>".$UNITE."</div> </td>"; 
		
			print"<td width='95px' valign='top' align='right' class='couleurcolonne'> <div class='col couleurcolonne' id='soustotal'   contenteditable='false' style='max-width: 95px;  '>€</div> </td>"; 
		
		print "</tr>";
	   	
		
	   	
    } 
    
	
	} else {
  //  echo "0 results";
}



$conn->close();
	
	
		?>
	
	
	
	
	
	
	
		
			
			</tbody>
	
		</table>	
	
	
	<table  cellspacing="0" cellpadding="-1" width="794px" border="0" valign="top" style="border-collapse: collapse;">
  <tbody>
    <tr class="elastic">
		<td width="20px" class='couleurcolonne' >&nbsp; </td> 
		<td width="512px" class='couleurFondscolonne1'>&nbsp; </td> 
		<td width="60px"  class='couleurFondscolonne2'>&nbsp; </td> 
		<td width="65px"  class='couleurFondscolonne1'>&nbsp; </td> 
		<td width="40px"  class='couleurFondscolonne2'>&nbsp; </td> 
		<td width="95px"  class='couleurcolonne'>&nbsp; </td> 
     
    </tr>
  </tbody>
</table>
	
	
	
	
	
	
	<table  cellspacing="0" cellpadding="0" width="794px" border="0" valign="top" >
		
		<tbody>
				<tr>  
			
			<td rowspan="2" style="border-top: 1px solid black;" width="460px" height="60px" valign="top"align="left" class="couleurcolonne"> <div class="colt couleurcolonne" id="cchantier" contenteditable="true" style="max-width: 520px;  "><?php echo $CHANTIER ?></div> </td> 
			<td style="border-top: 1px solid black; border-bottom:  1px solid black;" colspan="4" width="100px" height="28px" valign="top" align="right" class="couleurcolonne" ><div class="colt couleurcolonne" id="totalhtval" contenteditable="false" style=" max-width: 100px;">TOTAL HTVA</div> </td> 
			<td width="95px" valign="top" align="right" class="couleurcolonne"> <div class="colt couleurcolonne" id="totalhtva" contenteditable="false" style=" max-width: 95px;  ">100.985,25€</div> </td> 
			
		</tr>
		
				<tr> 
			
		 <td style="border-bottom: 1px solid black;" colspan="4" width="460px" height="28px" valign="top"align="right" class="couleurcolonne"> <div class="colt couleurcolonne " id="tauxtva" contenteditable="true" style="max-width: 520px;  "><?php echo $TVA ?></div> </td> 
			
			<td width="95px" valign="top" align="right" class="couleurcolonne"> <div class="colt couleurcolonne" id="totaltva" contenteditable="false" style=" max-width: 95px;  ">100.985,25€</div> </td> 
		</tr>
				<tr>  
			
			<td style="border-bottom:  1px solid black;"  colspan="4"  width="520px" height="28px" valign="top"align="left" class="couleurcolonne"> <div class="colt couleurcolonne" id="banque" contenteditable="true" style=" max-width: 580px; font-size: 0.8em;'  "><?php echo $BANQUE ?></div> </td> 
					
		
					<td style="border-bottom: 1px solid black;"   width="100px" valign="top" align="right" class="couleurcolonne" ><div class="colt couleurcolonne" contenteditable="false" style=" max-width: 100px;  ">TOTAL TVAC</div> </td> 
			<td style="border-bottom:  1px solid black;" width="95px" valign="top" align="right" class="couleurcolonne"> <div class="colt couleurcolonne" id="totaltvac" contenteditable="false" style="max-width: 95px;  ">100.985,25€</div> </td> 
			 
		</tr>
			
			
		
			
		</tbody>
	
		</table>	
	

	<script type="text/javascript">
    function inline_sprintlist_ondrop(table, row) {
        var result = $(table).parent().find('.result'),
            pre = $('<pre class="prettyprint">');

        result.html(pre.text($.tableDnD.jsonize(true)));
        prettyPrint();
//            pre.text($(table).tableDnD.jsonize())
//        return true;
        //// '<div class="indent">&nbsp;</div>',
    }
</script>




	<script type="text/javascript">
	
    $(document).ready(function() {
        // Initialise the first table (as before)
        $("#table-1").tableDnD();
        // Make a nice striped effect on the table
        table_2 = $("#table-2");
        //table_2.find("tr:even").addClass("alt");
        // Initialise the second table specifying a dragClass and an onDrop function that will display an alert
        table_2.tableDnD({
            onDragClass: "myDragClass",
            onDrop: function(table, row) {
                var rows = table.tBodies[0].rows;
                var debugStr = "Row dropped was "+row.id+". New order: ";
                for (var i=0; i<rows.length; i++) {
                    debugStr += rows[i].id+" ";
					
                }
                $(table).parent().find('.result').text(debugStr);
				
				//alert("ok");
				calcul();
				
				
				
				
            },
            onDragStart: function(table, row) {
                $(table).parent().find('.result').text("Started dragging row "+row.id);
            }
        });

        $('#table-3').tableDnD({
            onDragStart: function(table, row) {
                $(table).parent().find('.result').text('');
            },
            onDrop: function(table, row) {
                $('#AjaxResult').load("server/ajaxTest.php?"+$.tableDnD.serialize())
                        .parent().find('.result').html($('<p>').append('Result of $.tableDnD.serialize() is url encoded: ')
                        .append($('<pre class="prettyprint">').text($.tableDnD.serialize()))
                        .append(' Which looks like this when decoded (decodeURI): ')
                        .append($('<pre class="prettyprint">').text(decodeURI($.tableDnD.serialize()))));
                prettyPrint();
            }
        });

        $('#table-4').tableDnD(); // no options currently

        $('#table-5').tableDnD({
            onDragStart: function(table, row) {
                $(table).parent().find('.result').text('');
            },
            onDrop: function(table, row) {
                var data = $(table).tableDnDSerialize();
                $(table).parent().find('.result').append(
                        $('<strong>').text('The urlencoded serialized string:'))
                        .append($('<pre class="prettyprint">').text(data))
                        .append($('<strong>').text('Which looks like this through decodeURIComponent:'))
                        .append($('<pre class="prettyprint">').text(decodeURIComponent(data)));
                prettyPrint();
            },
            dragHandle: ".dragHandle"
        });

        $("#table-5 ").find("tr").hover(function() {
            $(this.cells[0]).addClass('showDragHandle');
        }, function() {
            $(this.cells[0]).removeClass('showDragHandle');
        });

        $('#table-7').tableDnD({
            hierarchyLevel: 4,
            onDragStart: function(table, row) {
                $(table).parent().find('.result').text('');
            },
            onDrop: function(table, row) {
                $(table).parent().find('.result').append(
                        $('<strong>').text('JSON.stringify result of $.tableDnD.tableData()'))
                        .append($('<pre class="prettyprint">').text($.tableDnD.jsonize(true)));
                prettyPrint();
                $.post("server/ajaxJSONTest.php", $.tableDnD.jsonize(), function (data) {
                    $('#table-7-response').html('<br>'+ data);
                });
            }
        });

        $('.toggle-json6').toggle(function() {
          $(this).text('Show JSON');
          $('json6').hide();
          return false;
        },
        function() {
          $(this).text('Hide JSON');
          $('json6').show();
          return false;
        });
        $('.toggle-json7').toggle(function() {
                $(this).text('Show JSON');
                $('json7').hide();
                return false;
              },
              function() {
                $(this).text('Hide JSON');
                $('json7').show();
                return false;
              });

        $('#radio-button-test').tableDnD();

    });
</script>
	

		
	
	<br>
	<p></p>
  
		
</div>

		
	
    			 <div class="gencont" style="margin-top: 28px;">
	
	
	
	
	  <div id="company">
		<h2 class="name">Ypsoroof - Ipsotoit</h2>
        <h2 class="name2">135 rue montavaux, 7080, Frameries </h2>
        <h2 class="name2">065/793325. Entr.:BE0443870515</h2>
		  <h2 class="name2">Banque CPH IBAN:BBE75</h2>
		   <h2 class="name2">Compte: BE92 1262 1506 3723</h2>
      <!--  <div><a href="mailto:info@ypsoroof.com">info@ypsoroof.com</a></div> -->
      </div>
        
		  <div id="client">
			
        <!--   <div class="to">CLIENT:</div> -->
            <h2 class="name"><?php echo $SOC ?></h2>
			<div class="address"><?php echo $TITRE.$NOM1 ?></div>
            <div class="address"><?php echo $NOM2 ?></div>
			<div class="address"><?php echo $NOM3 ?></div>
			<div class="address"><?php echo $NOM4?></div>
			<div class="address"><?php echo $NOM5?></div>
	
		   </div>		
            
                       <?php
				  switch ($ETATC) {
    case 0:
        echo " <div id='etatcom' style='display:none'>  ";
        break;
    case 1:
        echo " <div id='etatcom' style='display:block'>  En commande";
        break;
    case 2:
        echo " <div id='etatcom' style='display:block'>  En facturation";
        break;
	case 3:
        echo " <div id='etatcom' style='display:block'>  Clôturée";
		break;
	case 4:
       echo "<div id='etatcom' style='display:block'>  Brouillon";
        break;
}
		?>	  </div>
                     
	<div style="clear:both"></div>
    
              		<div id="solaireOffre">	 
			  <div id="invoice" style="background-color: transparent;"><br>
         Devis N°<?php echo $NUM ?>
				 
         
		 
            </div>  </div>       
                     
                <img src= "logofacsol2c.png" height="1100" width="794" style="margin-top: 0px;">       
                     
     <script src="js/chart.min.js"></script>
		<style>
		 .finances {
  position: absolute;
  left:200px;
  top  :240px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 400px;
  border-syle: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: 1.5em;
   color:#F0F1F6;
   
}
            		 .financesdetail {
  position: absolute;
  left:80px;
  top  :280px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 610px;
  border-syle: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: 0.9em;
   color:#F0F1F6;
text-align: justify;
   
}
  .col1Grap {
  position: absolute;
  left:80px;
  top  :350px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 300px;
  border-syle: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: 1.0em;
   color:#F0F1F6;
   
}
            .col2Grap {
  position: absolute;
  right:35px;
  top  :350px;
  text-align: left;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 300px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: 1.0em;
   color:#F0F1F6;
   
}
              .conditonscalculs {
  position: absolute;
  left:10px;
  top  :670px;
  text-align: center;
  padding-top: 10px;
  border-bottom: 0px solid #AAAAAA;
  width: 770px;
  border-style: solid;
  border: 0px solid rgba(144,187,255,1.00);
  border-radius: 2px;
   background-color: transparent;
 font-size: .8em;
   color:#F0F1F6;
   
}
    </style>
   
     <div class="conditonscalculs"  >Calculs réalisés avec une perte de production de panneau de <?php echo $PERTEPANNEAU/100;?>%/an et un coût d'augmentation d'électricité de 5%.</div>
    <div id="solaireBoxLayer"> <canvas id="line-chart" width="600" height="250" style="background-image: url(/img/);" ></canvas></div>
    <div class="finances">Aspects financiers et de rentabilité.<br></div>
   
      <div class="financesdetail"><?php echo $COEF ?></div> 
    
    
    <div class="col1Grap">
      <?php 
          echo "(Inves)Année : 1 = 0 €<br>";
    for ($i = 1; $i <= 12; $i++) {
         $Encours=$i; $Encours++;
        if ($AZIMUT>$GrapSol[$i])  {
   echo "(Inves)Année : ".$Encours." = ".number_format($GrapSol[$i], 2, ',', ' ')." €<br>"; }  else { 
        echo "(Gains)Année : ".$Encours." = ".number_format($GrapSol[$i], 2, ',', ' ')." €<br>";
        }      
}    
         ?> 
    </div>
    <div class="col2Grap">
     <?php 
         
    for ($i = 13; $i <= 24; $i++) {
           $Encours=$i; $Encours++;
        if ($AZIMUT>$GrapSol[$i])  {
   echo "(Inves)Année : ".$Encours." = ".number_format($GrapSol[$i], 2, ',', ' ')." €<br>"; }  else { 
        echo "(Gains)Année : ".$Encours." = ".number_format($GrapSol[$i], 2, ',', ' ')." €<br>";
        }         
}    
  
         ?> 
    </div>
    
  
             
      
    
	


    
    
	
	<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'>

	<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 150px;
  background-color: #AAAAAA;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
 font-size: 15px;
  /* Position the tooltip */
  position: absolute;
  top: 25px;
  left:  10px;
  z-index: 1;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
        
.btstsb {
    background-color: #AAAAAA;
    border: none;
    color: white;
    padding: 2px 2px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 24px;
	border-radius: 1px;
	 -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
    text-align: center;
	
	
}
.btstsb:hover {
    background-color: #EFD61E;
    color: white;
	}
       
.fancy-checkbox input[type="checkbox"],
.fancy-checkbox .checked {
    display: none;
}

.fancy-checkbox input[type="checkbox"]:checked ~ .checked
{
    display: inline-block;
}

.fancy-checkbox input[type="checkbox"]:checked ~ .unchecked
{
    display: none;
}
        
        
</style>
	
	
<script>
 var canvas = document.getElementById("line-chart");
var ctx = canvas.getContext('2d');
var chartType = 'line';
var myBarChart;

// Global Options:
Chart.defaults.global.defaultFontColor = 'grey';
Chart.defaults.global.defaultFontSize = 16;
Chart.defaults.global.elements.point.radius=0;
var data = {
  labels: [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11","12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23","24","25"],
  datasets: [{
    label: "Production en €",
    lineTension: 0,       
    fill: false,
     borderColor: "blue", // The main line color
     data: [0,<?php echo $GrapSol[1];?>,<?php echo $GrapSol[2];?>,<?php echo $GrapSol[3];?>,<?php echo $GrapSol[4];?>,<?php echo $GrapSol[5];?>,<?php echo $GrapSol[6];?>,<?php echo $GrapSol[7];?>,<?php echo $GrapSol[8];?>,<?php echo $GrapSol[9];?>,<?php echo $GrapSol[10];?>,<?php echo $GrapSol[11];?>,<?php echo $GrapSol[12];?>,<?php echo $GrapSol[13];?>,<?php echo $GrapSol[14];?>,<?php echo $GrapSol[15];?>,<?php echo $GrapSol[16];?>,<?php echo $GrapSol[17];?>,<?php echo $GrapSol[18];?>,<?php echo $GrapSol[19];?>,<?php echo $GrapSol[20];?>,<?php echo $GrapSol[21];?>,<?php echo $GrapSol[22];?>,<?php echo $GrapSol[23];?>,<?php echo $GrapSol[24];?> ],
    spanGaps: true,
  },
       { 
        data: [<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>,<?php echo $AZIMUT;?>],
        label: "Couts €",
           lineTension: 0,       
        borderColor: "#F30505",
           spanGaps: true,
        fill: false
      }      
            ]
};
        

var options = {
 scales: {
        yAxes: [{
          scaleLabel: {
            display: true,
            labelString: 'Sommes € cumulés'
          }
        }],
        xAxes: [{
          scaleLabel: {
            display: true,
            labelString: 'Années'
          }
        }] },

        
  title: {
    fontSize: 30,
    display: true,
    text: 'Graphique : rentabilité et investissement sur 25 ans.',
    backgroundColor: "transparent",
    position: 'top'
  }
};

init();

function init() {
  // Chart declaration:
  myBarChart = new Chart(ctx, {
    type: chartType,
    data: data,
    options: options
  });
    
         
}

    function addData() {
      myBarChart.data.labels[12] ="2017";
      myBarChart.data.labels[13] ="2018";
      myBarChart.data.datasets[0].data[12] = 500;
      myBarChart.data.datasets[0].data[13] = 600;
      myBarChart.update();
    }

    function adjust2016() {
      myBarChart.data.datasets[0].data[11] = 300;
      myBarChart.update();
    }
            
    
    
    
    </Script>








	
	
<div id="mydiv">
  <div id="mydivheader">Outils</div>
  <p>Memo</p>
  
	<div class='memo' style="color:white;" contenteditable="true"><?php echo $MEMO ?> </div>
	<br>
    
	 <label style="float:left;margin-left: 15px;" class="fancy-checkbox"><input type="checkbox" style="float:left;" name="etat" value="4" <?php if ($ETATC==4) { print" checked "; }?> ></input><i class="far fa-circle unchecked"></i>
        <i class="fas fa-check-circle checked"></i> Brouillon</label><br>
    
	 <label style="float:left;;margin-left: 15px;" class="fancy-checkbox"><input type="checkbox" style="float:left;" name="efface"><i class="far fa-circle unchecked"></i>
        <i class="fas fa-check-circle checked"></i> Efface la ligne au click</label><br><br>
	
	
   
	<div style="background-color: #AAAAAA; min-height: 40px; margin: auto;" >
<button class="pst tooltip btstsb"   ><i class='far fa-save fa-500px'></i><span class="tooltiptext">Enregistrer</span> </button>	
<button class="bld tooltip btstsb"  ><i class='fas fa-bold fa-500px'></i><span class="tooltiptext">Gras</span> </button> 
<button class="itl tooltip btstsb" ><i class='fas fa-italic fa-500px'></i><span class="tooltiptext">Italique</span> </button>
<button class="UpZ tooltip btstsb" >+</button>	
<button class="SmZ tooltip btstsb" >-</button>	
<button class="udr tooltip btstsb" ><i class="fas fa-underline"></i><span class="tooltiptext">Souligner</span> </button>
    </div>
      
    
    	<div style="background-color: #AAAAAA; min-height: 40px;" >
<button class="clone tooltip btstsb" ><i class='fas fa-clone fa-500px'></i><span class="tooltiptext">Cloner</span> </button>
<button class="swp tooltip btstsb"   ><i class='far fa-plus-square fa-500px'></i><span class="tooltiptext">Ajouter</span> </button>
<button class="swpgar tooltip btstsb"><i class="fas fa-user-check"></i><span class="tooltiptext">Garanties</span> </button>
<button class="cond tooltip btstsb"  ><i class="fas fa-list"></i><span class="tooltiptext">Conditions generales</span> </button>
<button class="lettre tooltip btstsb" ><i class="fas fa-mail-bulk"></i><span class="tooltiptext">Lettre</span> </button><br>
<button class="Recalcul tooltip btstsb" ><i class="fas fa-calculator"></i><span class="tooltiptext">Recalcul</span> </button><br>
    
 <!-- ////// ********************** Change la page de couleurs ********************************************************************************* 
            <button class="jscolor {valueElement:'chosen-value', onFineChange:'setTextColor(this)'}">
		Pick text color
	</button>
<button class="jscolor {valueElement:'chosen-value', onFineChange:'setTextColor2(this)'}">
		Pick text color
	</button>
            <button class="jscolor {valueElement:'chosen-value', onFineChange:'setTextColor3(this)'}">
		Pick text color
	</button>
	HEX value: <input id="chosen-value" value="000000">

    
	<script>
	function setTextColor(picker) {
		// document.getElementsByClassName('couleurcolonne')[0].style.backgroundColor  = '#' + picker.toString()
        $('.couleurcolonne').css('background-color', '#' + picker.toString());
	}
        function setTextColor2(picker) {
		 $('.couleurFondscolonne1').css('background-color', '#' + picker.toString());
	}
        function setTextColor3(picker) {
		 $('.couleurFondscolonne2').css('background-color', '#' + picker.toString());
	}
	</script>
     
           --> 
            
    </div>
  
    <br>
    
	
	<p>---</p>
	
              <button class="maison btstsb" style="width: 100%;" ><i class="fas fa-home"></i><span class="tooltiptext">Accueil</span> </button><br>
	           
	
</div>

	
	
	
	
	
	</div>
	
	
<script type="text/javascript">  
			
 $( function() {
     $("#mydiv").draggable().css("position", "fixed");
  } );
		 $("#mydiv").draggable()
  .click(function() {
    $(this).draggable({ disabled: false });
}).dblclick(function() {
    $(this).draggable({ disabled: true });
});
	
	
	
	</script>	
		


  
	
<script type="text/javascript">   
	

	
	function formatnombre(valeur,decimal) {
        
        
	valeur=valeur.replace(',','.');	
	valeur=valeur.replace(' ','');		
	valeurnb=parseFloat(valeur);
        	
                 if (isNaN(valeurnb)) {
                   valeur='   ';      
                  // alert("nan");
                       return valeur;  
                    } 
                
        
	valeurnb=format((parseFloat(valeurnb)),decimal);
    valeur=valeurnb.toString();
	valeur=valeur.replace('.',',');		
	if (parseFloat(valeurnb)<0) {valeur=""+valeur;}
     if (parseFloat(valeurnb)==0) {valeur="0";}
		//alert(valeur);
	return valeur;
}
			
	
		function format(valeur,decimal) {
	separateur=" " ;
// formate un chiffre avec 'decimal' chiffres après la virgule et un separateur
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	return val_format;
}
			
  $("div.col#prixcalc").blur(function() {	
	  //	alert("ok"+$(this).html());
	 // $( "p:last" ).text( "Contient: " +$(this).html()) ;
 $(this).html(formatnombre($(this).html(),2));
 });
	

	
	$(".UpZ").on('click',function(){
	document.execCommand('fontSize', false,  '3')
  var a = $("#textarea").html();

});
			$(".SmZ").on('click',function(){
	document.execCommand('fontSize', false,  '2')
  var a = $("#textarea").html();

});
$(".bld").on('click',function(){
	document.execCommand('bold');
	
  var a = $("#textarea").html();

});

$(".itl").on('click',function(){
	document.execCommand('italic');
  var a = $("#textarea").html();
	
});
	$(".udr").on('click',function(){
	document.execCommand('underline');
  var a = $("#textarea").html();
	
});
	
	$(".cond").on('click',function(){
		$.redirect('textegencon.php', {'dnumdevis':<?php echo $NumeroIndexDevisP ?>,'didxcli':<?php echo $NumeroIdxClient ?>});
	
	});
	
		$(".lettre").on('click',function(){
		$.redirect('textelettre.php', {'dnumdevis':<?php echo $NumeroIndexDevisP ?>,'didxcli':<?php echo $NumeroIdxClient ?>});
	
	});
	
	
		$(".clone").on('click',function(){
		$.redirect('listecli3.php', {'dnumdevis':<?php echo $NumeroIndexDevisP ?>,'didxcli':<?php echo $NumeroIdxClient ?>});
	
	});
	
	$(".maison").on('click',function(){
		$.redirect('index.html', {});
	
	});
    
    $(".Recalcul").on('click',function(){
		$.redirect('solairecalcM.php', {'dnumdevis':<?php echo $NumeroIndexDevisP ?>,'idxcli':<?php echo $NumeroIdxClient ?>});
	
	});
	
	
	
	$(".pst").on('click',function(){
		var des = Array();
		var desln = Array();
		var qtdes = Array();
		var pudes = Array();
		var umdes = Array();
		var ordredes = Array();
		
		var maxbcl=0;
//$(".col-container").find("div.col").each(function(i, v){
	//	$("#ligne").each(function(i, v){
		$("div.col").each(function(i, v){
        des[i] = $(this).html();
			ordredes[i]=i;
			
			
})
		maxbcl=des.length;
//alert(maxbcl);
		
		i=-6;
		var cptattrib=-1;
		for (var i=0;i < maxbcl;i+= 6) {
			cptattrib++;
			ordredes[cptattrib]=des[i];
			desln[cptattrib]=des[i+1];
			qtdes[cptattrib]=des[i+2];
			pudes[cptattrib]=des[i+3];
			umdes[cptattrib]=des[i+4];
			
			
			//alert(desln[cptattrib]+'  '+cptattrib);
		
		}
	//	
		
		
		//alert(des[0]);
		//alert(des[1]);

	//	$.redirect('testpostrec.php', {'DES': des, 'QTE':qtdes, 'PRIX':pudes, 'UNITE':umdes', 'ORDRELIGNE':ordredes,'dnum':?php echo $NumeroIndexDevisP ?>,'didxcli':<php echo // $NumeroIdxClient ?> });

		//	$.redirect('testpostrec.php', {'DES': desln, 'QTE': qtdes, 'PRIX':pudes, 'UNITE':umdes, 'ORDRELIGNE': ordredes,
		//								   && 'dnum':?php echo $NumeroIndexDevisP ?>,'didxcli':?php echo $NumeroIdxClient ?>,'dnum':?php echo $NUM ?>,  
		//								   && 'ddate':$("div.date").html(),'object':$("div.colh#oobjet").html(),'dchantier':$("div.colt#cchantier").html(),
		//								   && 'dtva':$("div.colt#tauxtva").html(),'dbanque': $("div.colt#banque").html(),'montant': $("div.colt#totalhtva").html() });
		var ETATMENU=$( "input[type=checkbox][name=etat]:checked" ).val();
		if (ETATMENU ==4)
    		{ETATMENU=4;	}else {ETATMENU=0;}
		//
		var xnum=<?php echo chr(34).$NUM.chr(34) ?>;
		//alert( xnum );	
		
		$.redirect('testpostrec.php', {'DES': desln, 'QTE': qtdes, 'PRIX':pudes, 'UNITE':umdes, 'ORDRELIGNE': ordredes,'dnum':<?php echo $NumeroIndexDevisP ?>,'didxcli':<?php echo $NumeroIdxClient ?>,'ddate':$("div.date").html(),'object':$("div.colh#oobjet").html(),'dchantier':$("div.colt#cchantier").html(),'dtva':$("div.colt#tauxtva").html(),'dbanque': $("div.colt#banque").html(),'montant': $("div.colt#totalhtva").html(),'devisnum': xnum ,'dmemo': $("div.memo").html(),'etat':ETATMENU });
		
		
//alert($("div.memo").html());		
		
	});
	
	
	
	cptlign=2;
	
	$(".swp").on('click',function(){
		
	
		
		
//var p = $( "div.colt" );
//var position = p.position();
//$( "p:last" ).text( "left: " + position.left + ", top: " + position.top );
		
		cptlign=cptlign+1;
    var itemRow =
       '  <tr class="yes" id="'+cptlign+'" >  '+
		'<td width="17px" valign="top" align="left" class="couleurcolonne" ><div class="col couleurcolonne" id="ligne1" contenteditable="false" style=" max-width: 17px;  ">1</div>  </td> '+
		'<td width="515px" valign="top"align="left" class="couleurFondscolonne1"> <div class="col couleurFondscolonne1"  id="descriptionligne" contenteditable="true" style=" max-width: 515px;  ">F&pose ...</div></td> '+
			'<td class="non couleurFondscolonne2" width="60px" valign="top" align="right"  > <div class="col couleurFondscolonne2" id="qtcalc" contenteditable="true" style="max-width: 60px;"> -</div> </td> '+
			'<td width="65px" valign="top" align="right" class="couleurFondscolonne1" > <div class="col couleurFondscolonne1" id="prixcalc" contenteditable="true" style=" max-width: 65px;  ">-</div></td>'+ 
			'<td width="40px" valign="top" align="center" class="couleurFondscolonne2" > <div class="col couleurFondscolonne2" id="umcalc" contenteditable="true" style=" max-width: 40px;  ">- </div> </td> '+
			'<td width="95px" valign="top" align="right" class="couleurcolonne"><div class="col couleurcolonne" id="soustotal" contenteditable="false" style=" max-width: 95px;  "> &nbsp</div>'+ '</td></tr>';
		
    $("#items_table").append(itemRow);
	//	 $("#items_table").addClass('yes').after(itemRow);

		  $("#table-2").tableDnD();
		
			cpt=1;
			lnt=0;
			$("div.col#ligne1").each(function(i, v){
				if (i=cpt) {
					lnt++;
            $(this).html((lnt));cpt=cpt+6;
				}
			 
			})
		
   		calcul();
		
		
		
		
	
	});
    
    
    	$(".swpgar").on('click',function(){
		
	
		
		
//var p = $( "div.colt" );
//var position = p.position();
//$( "p:last" ).text( "left: " + position.left + ", top: " + position.top );
		
		cptlign=cptlign+1;
    var itemRow =
       '  <tr class="yes" id="'+cptlign+'" >  '+
		'<td width="17px" valign="top" align="left" class="couleurcolonne"  ><div class="col couleurcolonne"  id="ligne1" contenteditable="false" style=" max-width: 17px;  ">1</div>  </td> '+
		'<td width="515px" valign="top"align="left" class="couleurFondscolonne1" > <div class="col couleurFondscolonne1"  id="descriptionligne" contenteditable="true" style=" max-width: 515px;text-align:center; "><font size = "3"><b><i><u><span>Garanties offertes :</span></u></i></b></font><br>Garantie décennale Ipsotoit-Ypsoroof<br>Garantie décennale A.B.E.E.<br>Garantie décennale fabriquant<br>Assurance tous risques "La Federale"</div></td> '+
			'<td class="non couleurFondscolonne2" width="60px" valign="top" align="right" > <div class="col couleurFondscolonne2" id="qtcalc" contenteditable="true" style=" max-width: 60px;  "> &nbsp</div> </td> '+
			'<td width="65px" valign="top" align="right" class="couleurFondscolonne1" > <div class="col couleurFondscolonne1" id="prixcalc" contenteditable="true" style=" max-width: 65px;  ">&nbsp</div></td>'+ 
			'<td width="40px" valign="top" align="center" class="couleurFondscolonne2" > <div class="col couleurFondscolonne2" id="umcalc" contenteditable="true" style=" max-width: 40px;  ">&nbsp </div> </td> '+
			'<td width="95px" valign="top" align="right"class="couleurcolonne" ><div class="col couleurcolonne"  id="soustotal" contenteditable="false" style=" max-width: 95px;  "> &nbsp</div>'+ '</td></tr>';
		
    $("#items_table").append(itemRow);
	//	 $("#items_table").addClass('yes').after(itemRow);

		  $("#table-2").tableDnD();
		
			cpt=1;
			lnt=0;
			$("div.col#ligne1").each(function(i, v){
				if (i=cpt) {
					lnt++;
            $(this).html((lnt));cpt=cpt+6;
				}
			 
			})
		
   		calcul();
		
		
		
		
	
	});
    

	$( "table" ).delegate( "tr", "click", function() {
 //	$( "p:last" ).text( "class: " + $(this).attr('class') +"  "+ $('tr'));
		
		if( $('input[name=efface]').is(':checked') ){
         //alert("la liogne va ettre supprimée");
		
		
		if ($(this).hasClass('yes')) {
		$(this).remove();
			cptlign=cptlign-1;
			var rowCount = $("#items_table tr").length;
			//alert (rowCount);
			
			cpt=6;
		
			
			
			$("div.col#ligne1").each(function(i, v){
				if (i=cpt) {
					lnt++;
            $(this).html((lnt));cpt=cpt+6;	}
			})
			
	
			} 
	        
		calcul();
			
			}
							
});
	
	function comble()
{	
	var p = $( "div.colt" );
        var position = p.position();
        var p1 = $( ".elastic" );
        var position1 = p1.position();
    
		//alert(position1.top);
		
    if (position.top != 950){
		var height = 950-position1.top;//$(window).height();
		$('.elastic').css('height',height);
		//alert(height);
	}
       var position = p.position();
	//	$( "p:last" ).text( "left: " + position.left + ", top:icc " + position.top +"hautreur "+height );	
	
	};
	
	function calcul() {
	//alert("ok");
		
		comble();
		
			cptt=1;
			lnt=0;
			lntt=-1;
		
		var tempqt = Array();
			$("div.col#qtcalc").each(function(i, v){
				 tempqt[i]=$(this).text();
			//	alert(tempqt[i]+' '+i);
				
			})
	 //alert("fin qtcalc");
			var tempprix = Array();
			$("div.col#prixcalc").each(function(i, v){
				 tempprix[i]=$(this).text();
			
                
                tempprix[i]=tempprix[i].replace(' ','');
				//alert(tempqt[i]+' '+i);
				
			})
	// alert("fin prixcalc");

			tothtva=0;
			var tempst = Array();
			$("div.col#soustotal").each(function(i, v){
					//alert("ok");
				//alert(tempqttempqt[i]);
				if (i=cptt) {
					lntt++;
                    
                    //alert(tempqt[lntt]);
                    
                    formatnombre(tempqt[lntt],2);
					tempqt[lntt]=tempqt[lntt].replace(',','.');	
					tempprix[lntt]=tempprix[lntt].replace(',','.');	
					//alert("ok");
					tempst[lntt]=parseFloat(tempqt[lntt])*parseFloat(tempprix[lntt]);
                    
                     if (isNaN(tempst[lntt])) {
                         
                    tempst[lntt]='  '; 
                    $(this).html(tempst[lntt]);cptt=cptt+6;
                         
                    } else {
				    
					tothtva=tothtva+tempst[lntt];
					
					tempst[lntt]=format((parseFloat(tempst[lntt])),2);
    				tempst[lntt]=tempst[lntt].toString();
					tempst[lntt]=tempst[lntt].replace('.',',');		
			        $(this).html(tempst[lntt]+"€");cptt=cptt+6;
                    }
				
                            }
				
			})
 //alert("fin ST");
		//	alert(tothtva);
			temptothtva=tothtva;	
			tothtva=format((parseFloat(tothtva)),2);
			    
    				tothtva=tothtva.toString();
					tothtva=tothtva.replace('.',',');		
				$("div.colt#totalhtva").html(tothtva+"€");
			
			tva=$("div.colt#tauxtva").text();
			var r = /[-+]?[0-9]*\.?[0-9]+/g;
			tva=tva.replace(',','.');
	        tva=(tva.match(r))[0];
			//alert(tva);
			tottva=parseFloat(temptothtva)*(parseFloat(tva)/100);
			temptva=tottva;
			tottva=format((parseFloat(tottva)),2);
			tottva=tottva.toString();
					tottva=tottva.replace('.',',');		
				$("div.colt#totaltva").html(tottva+"€");
			
			tempotottvac=temptva+temptothtva;
			tempotottvac=format((parseFloat(tempotottvac)),2);
			tempotottvac=tempotottvac.toString();
					tempotottvac=tempotottvac.replace('.',',');		
			
			$("div.colt#totaltvac").html(tempotottvac+"€");
			
			//alert(tottva);
		
		    cpt=1;
			lnt=0;
			$("div.col#ligne1").each(function(i, v){
				if (i=cpt) {
					lnt++;
            $(this).html((lnt));cpt=cpt+6;	
				}
			 
			})

					
		   
			// alert("fin calcul");
		
		
			} 
	
	function calculload()
{	calcul();
 
	$("div.col#prixcalc").each(function(i, v){
			//	alert("ok"+$(this).html());
           $(this).html(formatnombre($(this).html(),2));	
			 
			})

} 
	
	
	function myFunction() {
    var x = document.getElementById("mydiv");
    if (x.style.display === "none") {
        x.style.display = "block";
    } else {
        x.style.display = "none";
    }
}
	
	
		
$("div.date").dblclick(function()
 { 
 	var tempdate;
	var today = new Date();
	var dd = today.getDate();
	var mm = today.getMonth()+1; //January is 0!
	var yyyy = today.getFullYear();
	tempdate=$("div.date").html();
	//alert(tempdate);
	tempdate=tempdate.substring(17,tempdate.length);
	// set a variable
     var today = moment().format('DD/MM/YYYY');
	tempdate="Date: "+today+" "+tempdate;
	//alert(tempdate);
	$("div.date").html(tempdate);  
	//alert("ok");
	
  
 });
	var inc=0;
	$("div#tauxtva").dblclick(function()
 { 
 	
		inc=inc+1;
    //alert(inc);  
		switch (inc) {
    case 1:
      			$("div#tauxtva").html("Tva 6%, maison de plus de 10 ans.");
				calcul();
				break;
    case 2:
        			$("div#tauxtva").html("Tva 21%.");
				calcul();
        		break;
    case 3:
					$("div#tauxtva").html("Tva 0%, autoliquidation.");
				calcul();
    			inc=0;
    
}
	
  
 });
    
    $("div#tauxtva").keyup(function()
 { 
 	
	
				calcul();
    		
    

  
 });
    
    
    
    
	

		$.fn.selectText = function(){
    var doc = document;
    var element = this[0];
    //console.log(this, element);
    if (doc.body.createTextRange) {
        var range = document.body.createTextRange();
        range.moveToElementText(element);
        range.select();
    } else if (window.getSelection) {
        var selection = window.getSelection();        
        var range = document.createRange();
        range.selectNodeContents(element);
        selection.removeAllRanges();
        selection.addRange(range);
    }
		};

	
	
	//************************      gestion keyup ***********************************
	
	
			$("div").delegate("#umcalc","keyup",function(e)
	
{
		  
			var tempof = Array();
			$("div.col#umcalc").each(function(i, v){
				tempof[i]=$(this).is(":focus");
				
				//alert(tempof[i]);
				if (tempof[i]=== true) {
					lignecourante=i;}
				// if (!($("div.col#qtcalc").is(":focus"))) {
				//	alert("ok"+i+' '+tempof[i]);	}
				
			})
			
				
        if (e.keyCode == 40) 
        {  
           // alert("bas");
			lignecourante++;
			 $("div.col#umcalc")[lignecourante].focus();
			
		
        }
        if(e.keyCode==38)
        {
           // alert("haut");
			lignecourante--;
			 $("div.col#umcalc")[lignecourante].focus();
			
			
        }
//calcul();
});
	
	
	
	
	
	
	
	
	
	

			$("div").delegate("#descriptionligne","keyup",function(e)
	
{
		  
			var tempof = Array();
			$("div.col#descriptionligne").each(function(i, v){
				tempof[i]=$(this).is(":focus");
				
				//alert(tempof[i]);
				if (tempof[i]=== true) {
					lignecourante=i;}
				// if (!($("div.col#qtcalc").is(":focus"))) {
				//	alert("ok"+i+' '+tempof[i]);	}
			})
			
				
        if (e.keyCode == 40) 
        {  
           // alert("bas");
			lignecourante++;
			 $("div.col#descriptionligne")[lignecourante].focus();
			
		
        }
        if(e.keyCode==38)
        {
           // alert("haut");
			lignecourante--;
			 $("div.col#descriptionligne")[lignecourante].focus();
			
			
        }
//calcul();
});
	
	
		$("div").delegate("#prixcalc","keyup",function(e)
	
{
		
			var tempof = Array();
			$("div.col#prixcalc").each(function(i, v){
				tempof[i]=$(this).is(":focus");
				//alert(tempof[i]);
				if (tempof[i]=== true) {
					lignecourante=i;}
				// if (!($("div.col#qtcalc").is(":focus"))) {
				//	alert("ok"+i+' '+tempof[i]);	}
			})
			
				
        if (e.keyCode == 40) 
        {  
           // alert("bas");
			lignecourante++;
			 $("div.col#prixcalc")[lignecourante].focus();
		
        }
        if(e.keyCode==38)
        {
           // alert("haut");
			lignecourante--;
			 $("div.col#prixcalc")[lignecourante].focus();
			
			
        }
calcul();
});
	
	$("div").delegate("#qtcalc","keyup",function(e)
	
{
		
			var tempof = Array();
			$("div.col#qtcalc").each(function(i, v){
				tempof[i]=$(this).is(":focus");
				//alert(tempof[i]);
				if (tempof[i]=== true) {
					lignecourante=i;}
				// if (!($("div.col#qtcalc").is(":focus"))) {
				//	alert("ok"+i+' '+tempof[i]);	}
			})
			
		//$( "p:last" ).text( "change  " + $(this).text() );
		//calcul();	
		
        if (e.keyCode == 40) 
        {  
           // alert("bas");
			lignecourante++;
			 $("div.col#qtcalc")[lignecourante].focus();
		
        }
        if(e.keyCode==38)
        {
           // alert("haut");
			lignecourante--;
			 $("div.col#qtcalc")[lignecourante].focus();
			
			
        }
calcul();
			//$( "p:last" ).text( "fini  "  );
});
	
	
	
	$("div.col#qtcalc").click( function() {
	 $(this).selectText();
	

 });
	
	$( "div" ).delegate( "#prixcalc", "click", function() {
	  $(this).selectText();
		
	
 });
	
	$( "div" ).delegate( "#umcalc", "click", function() {
	 $(this).selectText();

 });

	
	
			
	</script>
	


 <?php   
         

   // print join(array_map("file_get_contents",
     //                array("solairecalc.html")));
   ?>
    
 
</body>		

</html>
