<?php include 'sesion_user.php';?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Panel</title>





<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> 

<link href="http://radioshosting.com/css/delalora4new.css" rel="stylesheet">

<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css"/>

<link rel="stylesheet" href="http://ejemplo.radiosnet.com.ar/css/font-awesome.min.css"/>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>



<body onload="document.forms['form14']['busqueda'].focus()">



<div class="container-fluid">





<div class="row">



<div class="col-lg-3 col-md-3 col-sm-12" style="background-color: #C8C8C8;">





<?php 

include 'nav.php';?>



</div>



<div class="col-lg-9 col-md-9 col-sm-12">

<?php include 'inc_buscar.php';?>





<hr />

<B></B><br />

Hoy es <?php echo date(d)?>/<?php echo date(m) ?>/<?php echo date(Y) ?><hr />







<?php 

$ID_venta = (int)$_POST['ID_venta'];

$ID_cliente = (int)$_POST['ID_cliente'];



include 'concha.php';



mysql_connect("$host","$usuario","$contra");



mysql_select_db ("$basedatos");



$sql = "SELECT * FROM `ventas` WHERE ID = '$ID_venta' LIMIT 1";



$consulta = mysql_query ($sql);



while ($row = mysql_fetch_array($consulta))



{

$ID_venta = $row["ID"];

$ID_venta_real = $row["ID"];

$fecha = $row["fecha"];

$total = $row["total"];

$usuario = $row["usuario"];



$ano = substr($fecha, 0,4);

$mes = substr($fecha, 4,2);

$dia = substr($fecha, 6,2);

$hora = substr($fecha, 8,2);

$min = substr($fecha, 10,2);





$total_new = $total * - 1;

$total_caja_new = $total_caja - $total;



$total_caja_fiado_new = $total_caja_fiado + $total;



}

mysql_free_result($consulta);







mysql_connect("localhost","$usuario","$contra");

$sSQL="INSERT INTO `caja` (`ID`, `detalle`, `monto`, `total_caja`, `fecha`) VALUES (NULL, 'MOV de caja a fiado cliente $ID_cliente numero venta: $ID_venta', '$total_new', '$total_caja_new', CURRENT_TIMESTAMP);";

mysql_db_query("$basedatos",$sSQL);





mysql_connect("localhost","$usuario","$contra");

$sSQL="INSERT INTO `caja_fiado` (`ID`, `detalle`, `monto`, `total_caja`, `fecha`, `ID_cliente`) VALUES (NULL, 'MOV de caja a fiado cliente $ID_cliente numero venta: $ID_venta', '$total', '$total_caja_fiado_new', CURRENT_TIMESTAMP, '$ID_cliente');";

mysql_db_query("$basedatos",$sSQL);





$sSQL="UPDATE `ventas` SET `forma_pago` = 'fiado' WHERE `ventas`.`ID` = '$ID_venta';";

mysql_db_query("$basedatos",$sSQL);









?>







<?

include 'concha.php';



mysql_connect("$host","$usuario","$contra");



mysql_select_db ("$basedatos");





$sql = "SELECT * FROM `ID_ventas` LIMIT 1";









$consulta = mysql_query ($sql);



while ($row = mysql_fetch_array($consulta))



{





$ID_venta = $row["ID"];



}



mysql_free_result($consulta);









?>

<?php 





$A = date(Y); 

$M = date(m); 

$D = date(d);   

$HORA = date(H);

$MIN = date(i);







$fecha = "$A$M$D$HORA$MIN";





mysql_connect("localhost","$usuario","$contra");

mysql_db_query("$basedatos","





INSERT INTO `ventas` (`ID`, `fecha`, `hora`, `total`, `usuario`, `forma_pago`) VALUES ('$ID_venta', '$fecha', '$hora', '$total_new', '$user_con', 'fiado');



");





mysql_db_query("$basedatos","





INSERT INTO `movimientos` (`ID`, `ID_venta`, `ID_articulo`, `precio`, `cantidad`, `detalle`) VALUES (NULL, '$ID_venta', '0', '$total', '$cantidad', 'caja a fiado MOV. N° $ID_venta_real');



");



?>

<?



$masuno = $ID_venta + 1;



$sSQL="UPDATE `ID_ventas` SET `ID` = '$masuno'";

mysql_db_query("$basedatos",$sSQL);





?>





MOV. N° <?php echo $ID_venta ?> creado.

<br />

<br />



TRANSFERENCIA $ <?php echo $total  ?> DE CAJA A CAJA-FIADO<br />





</div>

</div>



</div>







    



  <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>

  

  

  <script type="text/javascript">window.setInterval(function(){

  $('.grid').isotope({

  itemSelector: '.grid-item'

});

}, 2000);

</script>



<script language=javascript>

function ventanaSecundaria56 (URL){

   window.open(URL,"ventana1","width=600,height=500,scrollbars=NO")

}

  </script>

</body>

</html>

