<%
Option Explicit
Session.LCID = 2058
'***** SI NO HA INICIADO SESION ***
If Session("Mybussiness") = "" then
Response.redirect("default.asp")
Else
Session.Timeout = 1200
'******* EN CASO DE ERROR ****
Err.Clear
On Error Resume Next
'*** REMPLAZA
Function Sanea(Texto)
Sanea = Replace(Texto, "'", "''")
End Function
%>
<!DOCTYPE html>
<HTML>
<HEAD>
<meta charset="ISO-8859-1" />
<TITLE>SISTEMA MIM <%= Session("Mybussiness") %> USUARIO: <%= Session("MyName") %></TITLE>
<link href="css/Modulo5.css" rel="stylesheet" />
<link href="css/GestorC.css" rel="stylesheet" />
<link href="css/Buscador.css" rel="stylesheet" />
<link href="css/IndicadorA.css" rel="stylesheet" />
<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>
<%
'***** Variables a la base de datos ****
Dim Cn1
Dim Rs11, Rs12, Rs13, Rs14, Rs15, Rs16, Rs17, Rs18
Dim Sql11, Sql12, Sql13, Sql14, Sql15, Sql16, Sql17, Sql18
Dim ImporteA, TcambioA, Clacli, Factura, Saldo, Mpago, FacturaA, Vpago, MonedaD, TcambioD, ImpDoc, Documento, FechaP, Tpago
Documento = Session.sessionid
Factura = Request("Factura")
FacturaA = Request("FacturaA")
ImporteA = Request("ImporteA")
Mpago = Request("Mpago")
TcambioA = Request("TcambioA")
Vpago = Request("Vpago")
MonedaD = Request("MonedaD")
ImpDoc = Request("ImpDoc")
FechaP = Request("FechaP")
Tpago = Request("Tpago")
'***** Conexion a la Base de Datos
Set Cn1 = Server.CreateObject( "ADODB.Connection" )
Cn1.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID="& Session("MyName") &";PWD="& Session("MyPass") &";Database="& Session("Mybussiness") &""
'***** Conexion A la Tabla Empresa ****
Set Rs11 = Server.CreateObject("ADODB.Recordset")
Sql11="Select * from Empresa;"
Rs11.Open Sql11,Cn1,1,2
If TcambioA = "" then
TcambioA = 1
Else
TcambioA = TcambioA
End If
If ImporteA = "" then
ImporteA = 0
Else
ImporteA = ImporteA
End If
If ImpDoc = "" then
ImpDoc = ImporteA
Else
ImpDoc = Vpago
End If
IF Isnull(Mpago) or Mpago = "" then
Mpago = "PUE"
Else
Mpago = Mpago
End IF
If FacturaA = "" Or Isnull(FacturaA) then
FacturaA = 0
Else
FacturaA = FacturaA
End If
IF Isnull(FechaP) or FechaP = "" then
FechaP = Date()
Else
FechaP = FechaP
End IF
If Isnull(Tpago) or Tpago = "" then
Tpago = 7
Else
Tpago = Tpago
End If
Set Rs13 = Server.CreateObject("ADODB.Recordset")
Sql13="Select * from MetodoPago Where ClaveMP = '"& Sanea(Mpago) &"';"
Rs13.Open Sql13,Cn1,1,2
Set Rs18 = Server.CreateObject("ADODB.Recordset")
Sql18="Select Numcxcc, Descxcc " &_
"From Cxccon where Tipcxcc = 'A' and Stacxcc='A' and Numcxcc = "& Tpago &";"
Rs18.Open Sql18,Cn1,1,2
%>
<Header>
<%= Rs11("Nombre") %><br>
<%= Rs11("Direccion") %>, <%= Rs11("colonia") %><br>
<%= Rs11("Poblacion") %>
</header>
<SECTION>
<!--#include file="Cxcm.asp"-->
</SECTION>
<SECTION>
<CENTER>
<Br><Br>
<B>***** APLICACION DE SALDOS A FAVOR *****</B>
<BR><br>
<%
Dim ColorFila, Fila
Clacli = Request("Clacli")
%>
<div id="page">
<Form action="CxcApli.asp" method="post">
<Table Id="TablaOpc">
<Tr>
<Td>
Documento <input tabindex="1" type="text" placeholder="Saldo A favor" Title="Factura" name="Factura" Size="10" id="TablaOpc" value="<%= Factura %>" onChange="javascript:this.value=this.value.toUpperCase();">
</Td>
<td>Metodo Pago</Td>
<Td Size="10" id="TablaOpc">
<%
'****** TABLA DE Monedas ****
Set Rs12 = Server.CreateObject("ADODB.Recordset")
Sql12="Select ClaveMP, DescripcionMP " &_
"From MetodoPago;"
Rs12.Open Sql12,Cn1,1,2
If Rs12.EOF Then
Else
%>
<SELECT NAME="MPago" tabindex="2" class="Tableneg">
<option value=<%= Rs13("ClaveMP") %> Selected><%= Rs13("ClaveMP") %></Option>
<%
Do While Not Rs12.EOF
%>
<OPTION value="<%= Rs12("ClaveMP") %>"> <%= Rs12("ClaveMP") %> </Option>
<%
Rs12.Movenext
Loop
%>
</Select>
<%
End If
%>
</Td>
<Td>Tcambio:
<input tabindex="3" type="Text" placeholder="TcambioA" name="TcambioA" align="right" id="TablaOpc" value="<%= Formatnumber(TcambioA,2) %>" Size="4px">
</Td>
<Td>
<input type="Hidden" name="ImporteA" value="<%= ImporteA %>" >
<button tabindex="5" type="submit" name="Buscar" id="Buscar"/>Buscar</button>
</Td>
</Tr>
</Table>
</Form>
<%
If (Isnull(Factura) or Factura = "") Then
Else
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Select regcxcg, Clacli, Nomcli, Movcxcg, Nfacxcg, frecxcg, salcxcg, Desdiv, Abrdiv, Moncxcg, Tcacxcg From Clientes, cxcgen, Monedas " &_
"where NfaCxcg like '" & Factura & "' " &_
"and Clacli = clicxcg and Moncxcg = Cladiv and salcxcg <= - 1 ;"
Rs14.open Sql14,Cn1,1,2
Clacli = Rs14("Clacli")
Saldo = Rs14("Salcxcg")
MonedaD = Rs14("Moncxcg")
TcambioD = Rs14("Tcacxcg")
FechaP = Rs14("Frecxcg")
If Rs14.EOF Then
%>
<br><br>
<B>***** NO SE ENCONTRARON REGISTROS *****</B>
<BR>
<%
Else
%>
<B>Importe Saldo= <%= ImporteA%><b>
<Br>
<form action="CxcApliUp.asp" method="post">
<Table Id="TablaOpc">
<Tr>
<Td>Factura:
<input tabindex="6" type="Text" placeholder="FacturaA" name="FacturaA" size="5px" id="TablaOpc" value="<%= FacturaA %>" required/>
</Td>
<Td>Imp SA:
<input tabindex="7" type="Text" placeholder="ImporteA" name="SaldoF" size="8px" id="TablaOpc" value="<%= Vpago%>" disabled=»disabled»><%=Rs14("Abrdiv")%>
<Td>
<input type="Hidden" name="Factura" value="<%= Factura %>" >
<input type="Hidden" name="TcambioA" value="<%= TcambioA %>" >
<input type="Hidden" name="Vpago" value="<%= Vpago %>" >
<input type="Hidden" name="Clacli" value="<%= Clacli %>" >
<input type="Hidden" name="Mpago" value="<%= Mpago %>" >
<input type="Hidden" name="MonedaD" value="<%= MonedaD %>" >
<input type="Hidden" name="TcambioD" value="<%= TcambioD %>" >
<input type="Hidden" name="ImporteA" value="<%= cdbl(Saldo)%>" >
<button tabindex="5" type="submit" name="Buscar" id="Buscar"/>Buscar</button>
</Td>
</Tr>
</Form>
</Table>
<%
End If
End If
%>
</SECTION>
<bR>
</DIV>
<%
If ImporteA = 0 then
%>
<%
Else
%>
<div Id="Resultados">
<%
'***** Conexion A la tabla temporal ****
Set Rs15 = Server.CreateObject("ADODB.Recordset")
Sql15="Select * from Cobdtem, Clientes, monedas " &_
"where SesCobtem = "& Documento &" and CliCobtem = Clacli and Clacli = '"& Clacli &"' and Cladiv = MonCobtem order by RegCobtem;"
Rs15.Open Sql15,Cn1,1,2
If Rs15.EOf Then
Else
%>
<Table Class="TablaRes" Width="800px">
<Tr>
<Td width="5" colspan="2" Align="left">Factura</Td>
<Td width="5" colspan="2" Align="Left">Nombre Cliente</Td>
<Td width="5" colspan="2" Align="Right">Saldo Doc</Td>
<Td width="5" colspan="2"Align="Right">Saldo Aplicar</Td>
<Td width="5" colspan="2" Align="Right">Per/Gan</Td>
<Td width="5" colspan="2" Align="Right" >Accion</Td>
</Tr>
</Table>
<Table Class="Partidas" Width="800px">
<%
Dim Pergam, ColorL
Do While Not Rs15.Eof
If cdbl(Rs15("PerganCobtem")) < 0 then
ColorL = "#FC1A03"
Else
ColorL = "#000000"
End If
%>
<Tr>
<form action="CxcApliMod.asp" method="post" name="AddGestor" id="AgregaGC">
<Td width="1" colspan="2" Align="Left"Id="CxcFactura" >
<a href="CxcHistdet.asp?Documento=<%= Rs15("FacCobtem") %>&Cliente=<%= Rs15("CliCobtem") %>"
onclick="NewWindow(this.href,'Recibir','800','600','yes');return false;"><%= Rs15("FacCobtem") %></a>
</Td>
<Td width="5" colspan="2" Align="Left"><%= Rs15("Nomcli") %> </Td>
<Td width="10" colspan="2" Align="Left"><%= Formatnumber(Rs15("SalCobtem")) %> - <%=Rs15("Abrdiv")%> </Td>
<Td width="10" colspan="2" Align="Left"><input Type="text" placeholder="ImporteR" Title="ImporteR" name="ImporteR" id="ImporteR" Size="7" value="<%= Rs15("ImpaCobtem") %>"></Td>
<Td width="10" colspan="2" Align="Left" Style="color:<%= ColorL %>"><%= Formatnumber(Rs15("PerganCobtem")) %> </Td>
<Td width="5" colspan="2" Align="Right">
<input type="Hidden" name="Factura" value="<%= Factura %>" >
<input type="Hidden" name="FacturaA" value="<%= FacturaA %>" >
<input type="Hidden" name="ImporteA" value="<%= ImporteA %>" >
<input type="Hidden" name="TcambioA" value="<%= TcambioA %>" >
<input type="Hidden" name="TcambioD" value="<%= TcambioD %>" >
<input type="Hidden" name="Vpago" value="<%= Vpago %>" >
<input type="Hidden" name="MonedaD" value="<%= MonedaD %>" >
<input type="Hidden" name="FechaP" value="<%= FechaP %>" >
<input type="Hidden" name="Mpago" value="<%= Mpago %>" >
<input type="Hidden" name="Tpago" value="<%= Tpago %>" >
<input type="Hidden" name="Clacli" value="<%= Clacli %>" >
<input type="hidden" placeholder="RegistroP" Title="RegistroP" name="RegistroP" id="RegistroP" Size="2" Style="Text-Align:Right" value="<%= Rs15("RegCobtem") %>">
<input type="image" src="Icon/Modifica.gif" value="Accesar" Title="Modificar">
</td>
<Td width="5">
</FORM>
<a href="Cxcaplidel.asp?regi=<%= Rs15("RegCobtem") %>&Vpago=<%=Vpago%>&ImporteA=<%=ImporteA%>&TcambioA=<%=TcambioA%>&FacturaA=<%=FacturaA%>&Factura=<%=Factura%>&FechaP=<%=FechaP%>&Mpago=<%=Mpago%>&Clacli=<%=Clacli%>">
<img src="Icon/Elimina.gif"></a> </Td>
</tr>
<%
Rs15.Movenext
Loop
%>
</Table>
</div>
<SECTION >
<form action="CxcApligen.asp" method="post" name="AddGestor" id="AgregaGC">
<Table id="Comprobante">
<Tr>
<Td>Tipo de pago:</Td>
<Td>Destino:</Td>
</TR>
<Tr>
<Td >
<%
'****** TABLA Tpago ****
Set Rs16 = Server.CreateObject("ADODB.Recordset")
Sql16="Select Numcxcc, Descxcc " &_
"From Cxccon where Tipcxcc = 'A' and Stacxcc='A';"
Rs16.Open Sql16,Cn1,1,2
If Rs16.EOF Then
Else
%>
<SELECT NAME="Tpago" tabindex="2">
<option value=<%= Rs18("Numcxcc") %> Selected><%= Rs18("Numcxcc") %> -<%= Rs18("Descxcc") %></Option>
<%
Do While Not Rs16.EOF
%>
<OPTION value="<%= Rs16("Numcxcc") %>"> <%= Rs16("Numcxcc") %> - <%= Rs16("Descxcc") %> </Option>
<%
Rs16.Movenext
Loop
%>
</Select>
<%
End If
%>
</Td>
<Td >
<%
'****** TABLA Destino ****
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17 = "select IdBan, ConBan, CtaBan From Bancos where StaBan='A'"
Rs17.Open Sql17,cn1,1,2
If Rs17.EOF Then
Else
%>
<SELECT NAME="Tdestino" tabindex="3">
<%
Do While Not Rs17.EOF
%>
<OPTION value="<%= Rs17("IdBan") %>"> <%= Rs17("IdBan") %> - <%= Rs17("ConBan") %> - <%=Rs17("CtaBan")%></Option>
<%
Rs17.Movenext
Loop
%>
</Select>
<%
End If
%>
</Td>
<Td>
<input tabindex="4" type="Text" placeholder="Observaciones" Title="Observaciones" name="Observaciones" size="10px" id="Observaciones" value="">
</Td>
</Tr>
<Tr>
<Td Colspan="4" Align="Center">
<input type="Hidden" name="Factura" value="<%= Factura %>" >
<input type="Hidden" name="FacturaA" value="<%= FacturaA %>" >
<input type="Hidden" name="TcambioA" value="<%= TcambioA %>" >
<input type="Hidden" name="Vpago" value="<%= Vpago %>" >
<input type="Hidden" name="Clacli" value="<%= Clacli %>" >
<input type="Hidden" name="Mpago" value="<%= Mpago %>" >
<input type="Hidden" name="MonedaD" value="<%= MonedaD %>" >
<input type="Hidden" name="TcambioD" value="<%= TcambioD %>" >
<input type="Hidden" name="FechaP" value="<%= FechaP %>" >
<input type="Hidden" name="ImporteA" value="<%= ImporteA %>" >
<button tabindex="5" type="submit" name="Grabar" id="Grabar"/>Aplicar</button><br><br></Td>
</Tr>
</Table>
</form>
</SECTION>
<%
End If
%>
</SECTION>
<% End If %>
<%
If Err.Number <> 0 Then
%>
<br><br>
Número de Error: <%= Err.Number %><BR>
Descripción: <%= Err.Description %><BR>
Origen: <%= Err.Source %><BR>
Linea: <%= Err.Line %><BR>
<br>
<%
Else
'****** FIN DE LOS ERRORES ***
End If
%>
</BODY>
</HTML>
<%
'FIN DE SESION
End If
%>