<?php
session_start();
require_once('../conexion.php');
include "../include/sesiones.php";

$clie_id=$_POST['clie_id'];
$tar=mysqli_query($con,"SELECT count(tar_id) as tarifas FROM tarifas where empresa='$empresa'") ;
$tar=mysqli_fetch_array($tar);
$tarifas=$tar['tarifas'];
if ($tarifas>1)
{
	$sql=mysqli_query($con,"DELETE FROM seriales_temp WHERE usuario='$usu_id'") or die(mysqli_error($con));
	$sql=mysqli_query($con,"DELETE FROM venta_detalle_sabores_temp where usuario='$usu_id'") or die(mysqli_error($con));
	$sql=mysqli_query($con,"DELETE FROM venta_detalle_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));

	$sql=mysqli_query($con,"DELETE FROM venta_detalle_combo_sabores_temp where usuario='$usu_id'") or die(mysqli_error($con));
	$sql=mysqli_query($con,"DELETE FROM venta_detalle_combo_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));

	$sql=mysqli_query($con,"DELETE FROM cliente_venta_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));
	$sql=mysqli_query($con,"DELETE FROM retencion_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));

	$regis=mysqli_query($con,"INSERT into cliente_venta_temp (cvt_clie_id,usuario,empresa)
	VALUES ('$clie_id','$usu_id','$empresa')") or die(mysqli_error($con));
}
else
{
	$sql=mysqli_query($con,"DELETE FROM cliente_venta_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));
	$sql=mysqli_query($con,"DELETE FROM retencion_temp where usuario='$usu_id' and empresa='$empresa'") or die(mysqli_error($con));

	$regis=mysqli_query($con,"INSERT into cliente_venta_temp (cvt_clie_id,usuario,empresa)
	VALUES ('$clie_id','$usu_id','$empresa')") or die(mysqli_error($con));
}
?>