<?php require "php/cabecera3.inc";

	echo "<br><center><h1>Confirmación de pago</h1></center><br>";
		
	$resultado = mysqli_query($conexion, "SELECT * FROM ecomm_usuarios WHERE ID= $_SESSION[usuario]");
	$dtuser = mysqli_fetch_array($resultado);
		
		$suma = 0;
			for($i = 0;$i< $_SESSION['contador'];$i++){
				$peticion = "SELECT * FROM tabla_altaproducto WHERE CUENTA='$IDS' AND SKU='".$_SESSION['producto'][$i]."'";
				$resultado = mysqli_query($conexion, $peticion);
				while($fila = mysqli_fetch_array($resultado)){
					$total = $fila['COSTOECOM']*$_SESSION['numb'][$i];
					$suma += $total;
				}
			}
			
	echo "<CENTER><DIV STYLE='WIDTH:100%;'><TABLE ID='CHECKOUT' class='example table-stripeclass:alternate' style='border:none;width:100%;table-layout:fixed;margin:auto;' STYLE='WIDTH:100%'><THEAD><TR><TH>Nombre</TH><TH>Límite de credito</TH><TH>Adeudo total actual</TH><TH>Monto de la transacción</TH><TH>Credito restante</TH></TR></THEAD><TBODY>";
	echo "<tr><td>$dtuser[NOMBRE]</td><td>$ $dtuser[CREDITO]</td><td>$ $dtuser[ADEUDO]</td><td>$ $suma</td><td>$ ".($dtuser['CREDITO']-$dtuser['ADEUDO']-$suma)."</td></tr>";
	echo "</TBODY><TFOOT><tr><TD COLSPAN='5' id='PRECTOTAL'></TD></tr></TFOOT></TABLE></DIV></CENTER><BR><BR><CENTER><table>";

	echo "<tr><td style='text-align:center;'><form action='okcred.php' method='post'><input type='hidden' name='IDS' value='$IDS'><input type='hidden' name='confirmed' value='ok'><input type='hidden' name='ct' value='$suma'><input type='submit' class='btn' value='Confirmar'></form></td></tr>";

	echo "<tr><td  style='text-align:center;'><a href='myc.php?IDS=$IDS'><button class='btn'> Cancelar </button></a></td></tr></table></CENTER>";

	mysqli_close($conexion);
	
require "php/pie.inc" ?>