<%
Option Explicit
Session.LCID=2058
%>
<!--#include file="User.asp"-->
<!--#include file="general.asp"-->
<html>
<head>
<title>Grupo MIM</title>
<link rel=stylesheet href="vista.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
</head>
<BODY>
<!--#INCLUDE FILE="BARRA.asp"-->
<div class="normalw" style="position:absolute; top:1px">
<center>
<!--#include file="empresa.asp"--><br>
<hr>
</center>
</div>
<div class="normalw" style="position:absolute; top:1px;">
Bienvenido: <%= nombre %>. <br>
Hora Actual: <%= time %>
</div>
<div style="position:absolute; top:34px; left:1">
<!--#include file="mpro.asp"-->
</div>
<div class="normal" style="position:absolute; top:80px; left:10">
<center>
<b><<<<< POLIZAS DE FACTURACION (DOWNLOAD) >>>>>
<BR>
<hr>
<Form action="PolMfac.asp" name="PolMfac" method="Post">
<TABLE border="0" cellspacing="2" cellpadding="2" class="normal">
<Tr>
<TD align="Left" class="normalw" bgcolor="#006699">Fecha Inicial</td>
<TD align="Left" class="normalw" bgcolor="#006699">Fecha Final</td>
<TD align="Left" class="normalw" bgcolor="#006699">Poliza Inicial</td>
</tr>
<tr>
<Td align="center" class="normal">
<input type="text" class="normalb" Value="<%= date() %>" name="Finicial" size="12" style="text-align:right;" onChange="javascript:this.value=this.value.toUpperCase();">
</Td>
<Td align="center" class="normal">
<input type="text" class="normalb" Value="<%= date() %>" name="FFinal" size="12" style="text-align:right;" onChange="javascript:this.value=this.value.toUpperCase();">
</Td>
<Td align="center" class="normal">
<input type="text" class="normalb" Value="" name="NumeroP" size="7">
</Td>
</Tr>
<Tr>
<Td align="center" class="normal" Colspan="3">
<input type="submit" value="Buscar" class="normalc">
</Td>
</Tr>
</Table>
</Form>
<Hr>
<%
Dim Finicial, Ffinal, NumeroP
Finicial = Request("FInicial")
Ffinal = Request("Ffinal")
NumeroP = Request("NumeroP")
If Finicial = "" and FFinal ="" and NumeroP ="" Then
%>
<<<<< BUSCAR POR FECHA O POR FOLIO >>>>>
<BR>
<%
Else
'------- CODIGO PARA GENERAR LA POLIZA MODELO DEL COFIDI -------->
Dim Cn2
Dim F, Fs
Dim Rs11, Sql11, Rs12, Sql12, Rs13, Sql13
Dim DiaA, LineaA, lineaB, CuentaCoi, Iva, IvaTotal
Dim Anticipo, IVAPEN
Dim CoiDiv, Coianti, COIIVP, COIIPT, COIDIFC
DIM DIFCAM, PERGAN
' para crear archivo texto
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("Polizas\PolCFDFac.xls"), 2, true)
'aqui creas la conexion a la DB y hace el recordset
Set Rs11 = server.CreateObject("ADODB.Recordset")
' para leer la tabla
Sql11 = "select case when monfface = 2 then coacli else coicli end as COACLI, NUMFFACE, ((TOTFFACE - ANTIFFACE) * TCAFFACE) as IMPORTE, " &_
"ANTECOI, (ANTIFFACE/(1 + (IVAFFACE /100)) * TCANTI) AS ANTICIPO, " &_
"'2190-002-000' AS COIIVP, ((ANTIFFACE/(1 + (IVAFFACE /100)) * TCANTI) * (IVAFFACE /100)) AS IVAPEN, " &_
"(ANTIFFACE * TCAFFACE) - (ANTIFFACE * TCANTI) as DIFCAM " &_
"FROM FFACENC, CLIENTES " &_
"WHERE NUMFFACE >= '"& NumeroP &"' AND FECFFACE BETWEEN '"& Finicial &"' AND '"& Ffinal &"' AND CLACLI = CLIFFACE ORDER BY NUMFFACE;"
Rs11.Open Sql11, Cn1, 1, 2
DiaA = Day(date())
If DiaA < 10 Then
DiaA = " " & DiaA
Else
DiaA = DiaA
End If
LineaA = "Facturacion del Dia " & DiaA
LineaB = "."
f.WriteLine("Dr")
f.WriteLine(DiaA)
f.WriteLine(LineaA)
f.WriteLine(LineaB)
Ivatotal = 0
do while not Rs11.EOF
Anticipo = Rs11("Anticipo")
CuentaCoi = Rs11("CoAcli")
CuentaCoi = Cuentacoi & " "
' graba campo de la tabla en archivo texto
f.WriteLine Cuentacoi & "," & 0
f.WriteLine "FACTURA: " & Rs11("Numfface")
f.WriteLine Round(Rs11("Importe"),2)
response.write(Rs11("Numfface"))
response.write("-")
response.write(Anticipo)
response.write("<br>")
If Cdbl(Anticipo) > 0 then
Coianti = Rs11("AntEcoi")
Coianti = Coianti & " "
' graba campo de la tabla en archivo texto
f.WriteLine CoiAnti & "," & 0
f.WriteLine "AMORT ANTI: " & Rs11("Numfface")
f.WriteLine round(Rs11("ANTICIPO"),2)
Difcam = Rs11("Difcam")
If Cdbl(Difcam) < 0 Then
Coidifc = "7010-002-000"
Coidifc = Coidifc & " "
PERGAN = Cdbl(Rs11("difcam")) * -1
f.WriteLine Coidifc & "," & 0
f.WriteLine "GANANCIA CAMBIARIA"
f.WriteLine ""
f.WriteLine Round(pergan,2)
else
Coidifc = "6000-003-000"
Coidifc = Coidifc & " "
PERGAN = Rs11("difcam")
f.WriteLine Coidifc & "," & 0
f.WriteLine "PERDIDA CAMBIARIA"
f.WriteLine Round(pergan,2)
end If
COIIVP = Rs11("COIIVP")
COIIVP = COIIVP & " "
f.WriteLine COIIVP & "," & 0
f.WriteLine "IVA PENDIENTE DE TRANSLADAR"
f.WriteLine Round(Rs11("IVAPEN"),2)
Else
End If
Rs11.movenext
Loop
Set Rs12 = server.CreateObject("ADODB.Recordset")
' para leer la tabla
Sql12 = "select COIVEND, DIVVEND AS DIVISIONES, sum(SUBFFACE * TCAFFACE) AS IMPORTE " &_
"FROM CLIENTES, FFACENC, VENDEDORES " &_
"WHERE CLIFFACE = CLACLI AND VENCLI = CVEVEND " &_
"AND NUMFFACE >= '"& NumeroP &"' AND FECFFACE BETWEEN '"& Finicial &"' AND '"& Ffinal &"' " &_
"GROUP BY DIVVEND, COIVEND " &_
"ORDER BY DIVVEND;"
Rs12.Open Sql12, Cn1, 1, 2
do while not Rs12.EOF
Coidiv = Rs12("Coivend")
CoiDiv = Coidiv & " "
f.WriteLine CoiDiv & "," & 0
f.WriteLine "Venta Division " & Rs12("divisiones")
f.WriteLine ""
f.WriteLine Round(Rs12("Importe"),2)
' cierras la tabla
Rs12.Movenext
loop
Rs12.Close
'******* EL ULTIMO IVA ******
Set Rs13 = server.CreateObject("ADODB.Recordset")
' para leer la tabla
Sql13 = "select '2190-002-000' AS COIIPT, sum(IVTFFACE * TCAFFACE) AS IVAPT " &_
"FROM CLIENTES, FFACENC, VENDEDORES " &_
"WHERE CLIFFACE = CLACLI AND VENCLI = CVEVEND " &_
"AND NUMFFACE >= '"& NumeroP &"' AND FECFFACE BETWEEN '"& Finicial &"' AND '"& Ffinal &"';"
Rs13.Open Sql13, Cn1, 1, 2
do while not Rs13.EOF
COIIPT = Rs13("COIIPT")
COIIPT = COIIPT & " "
f.WriteLine COIIPT & "," & 0
f.WriteLine "IVA PENDIENTE DE TRANSLADAR "
f.WriteLine ""
f.WriteLine Round(Rs13("IVAPT"),2)
' cierras la tabla
Rs13.Movenext
loop
Rs13.Close
set Rs13=nothing
set Rs12=nothing
set Rs11=nothing
f.WriteLine("FIN")
' cierras archivo texto
f.Close
Set f=Nothing
Set fs=Nothing
%>
<A href="Polizas/PolCFDFac.xls">Poliza CFD FACTURAS</a>
<%
End If
%>
</div>
</body>
</html>
<%
End Sub
'Add the chosen course to the cart
Call AddUsuario()
'Display contents of electronic shopping cart
Call DisplayUsuario()
%>