<%
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">
</head>
<BODY>
<!--#INCLUDE FILE="BARRA.asp"-->
<div class="normalw" style="position:absolute; top:1px">
<center>
<!--#include file="empresa.asp"--><br>
<hr>
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">
<%
Dim Rs11, Sql11, Rs12, Sql12, Rs13, Sql13, Rs14, Sql14, Rs15, Sql15
Dim Rs16, Sql16, Rs17, Sql17, Rs18, Sql18, Rs19, Sql19, Rs20, Sql20
Dim Rs21, Sql21, Rs22, Sql22, Rs23, Sql23, Rs24, Sql24, Rs25, Sql25
Dim Rs26, Sql26, Rs27, Sql27
Dim Almacen, Linea, Sublinea, FechaI, FechaF, MsgF
Almacen = Request("Almacen")
Linea = Request("Linea")
Sublinea = Request("Sublinea")
FechaI = Request("FechaI")
FechaF = Request("FechaF")
MsgF = Request("MsgF")
%>
<center>
<b>**** Reportes de Rotacion de Inventarios *****
<HR>
<Form action="Rotacion.asp" Name="Filtro" method='Post'>
<TABLE Border="0" Cellspacing="1" Cellpadding="2">
<Tr Bgcolor="006699">
<td Class="Normalw"><b>Linea</td>
<td Class="Normalw"><b>Sublinea</td>
<td Class="Normalw"><b>Fecha Inicial:</td>
<td Class="Normalw"><b>Fecha Final:</td>
</tr>
<Tr>
<td Class="Normalw">
<Select NAME="Linea" Class="Normalb">
<%
Set Rs11 = server.CreateObject("ADODB.Recordset")
Sql11 = "Select Clalin, Deslin from Lineas order by Deslin;"
Rs11.open Sql11,Cn1,1,2
Do While Not Rs11.Eof
%>
<Option Value="<%= Rs11("Clalin") %>"> <%= Rs11("Deslin") %></Option>
<%
Rs11.MoveNext
Loop
%>
</select>
<%
Rs11.close
%>
</td>
<td Class="Normalw">
<Select NAME="Sublinea" Class="Normalb">
<%
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12 = "Select Clasli, Dessli from Sublineas order by Dessli;"
Rs12.open Sql12,Cn1,1,2
Do While Not Rs12.Eof
%>
<Option Value="<%= Rs12("Clasli") %>"> <%= Rs12("Dessli") %></Option>
<%
Rs12.MoveNext
Loop
%>
</select>
<%
Rs12.close
%>
</td>
<td Class="Normalw" Align="Center">
<Input Type="Text" Class="Normalb" Name="FechaI" Size="9" Value="<%= Date()-365 %>" Style="Text-Align:Right" OnChange="javascript:this.value=this.value.toUpperCase();">
</td>
<td Class="Normalw" Align="Center">
<Input Type="Text" Class="Normalb" Name="FechaF" Size="9" Value="<%= Date() %>" Style="Text-Align:Right" OnChange="javascript:this.value=this.value.toUpperCase();">
<Input Type="Hidden" Class="Normalb" Name="Almacen" Size="9" Value="<%= Almacen %>" Style="Text-Align:Right" OnChange="javascript:this.value=this.value.toUpperCase();">
</td>
</tr>
<Tr>
<td Class="Normalw" Align="Center" Colspan="3">
<input type="Submit" value="Filtrar" Class="Normalb">
</td>
</tr>
</Table>
</Form>
<%
If Linea = "" or Isnull(Linea) then
%>
***** NO EXISTEN DATOS A REPORTAR *****
<%
Else
Set Rs13 = server.CreateObject("ADODB.Recordset")
Sql13 = "Select Clalin, Deslin from Lineas Where Clalin = "& Linea &" order by Deslin;"
Rs13.Open Sql13,Cn1,1,2
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14 = "Select ClaAlm, Desalm from Almacenes Where Claalm = "& Almacen &" order by Desalm;"
Rs14.Open Sql14,Cn1,1,2
%>
*** Generando Reporte ***<Br>
Linea: <u> <i><%= Rs13("Deslin") %></u></i>
Almacen <u> <i><%= Rs14("desalm") %> </u></i> <br><BR>
<%
Rs14.Close
Rs13.Close
'************ If Para General Los Procedimiento ********
If MsgF = "" or Isnull(MsgF) Then
%>
***** ESPERE A QUE TERMINE EL PROCESO, NO ACTUALIZAR LA PAGINA ******
<%
'****** RECORDSET PARA ELIMINAR LOS REGISTROS DEL USUARIO CON EL QUE SE LOGEO *****
Set Rs15 = server.CreateObject("ADODB.Recordset")
Sql15 = "Delete From Rotacion;"
Cn1.Execute Sql15
Set Rs16 = server.CreateObject("ADODB.Recordset")
Sql16 = "Insert Into Rotacion " &_
"(Almacen, Codigo, Descripcion, Udm, Existencias, Apartados, EmbarqueD, Disponible, Cantxrec, Ventas, Canmin, CanMax, StockMin, StockMax, UsuarioR) " &_
"Select Almmul, Artmul, Desmul, Udminv, Exirmul, Capmul, Embdire, (exirmul-Capmul+Embdire), 0, 0, 0, 0, Smimul, Smamul, '"& Nombre &"' " &_
"From Multialmacen, Inventarios " &_
"where Artmul = Cveinv and almmul = "& Almacen &" " &_
"order by artmul;"
Cn1.Execute Sql16
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17 = "Delete From RotaDet;"
Cn1.Execute Sql17
Set Rs18 = server.CreateObject("ADODB.Recordset")
Sql18 = "Insert Into RotaDet " &_
"(CodigoR, CantidadR, TipoR, UsuarioR) " &_
"Select Codord, Sum(Cpeord), 'XR', '"& Nombre &"' " &_
"From Rotacion, Corddet, Cordenc " &_
"where Codigo = Codord and Almacen = almord and Numord = Numore and Cpeord > 0 and Staore < 2 " &_
"Group by Codord " &_
"Order By Codord;"
Cn1.Execute Sql18
Set Rs19 = server.CreateObject("ADODB.Recordset")
Sql19 = "Insert Into RotaDet " &_
"(CodigoR, CantidadR, TipoR, UsuarioR) " &_
"Select CODFFACD, Sum(CANFFACD-CDEFFACD), 'VS', '"& Nombre &"' " &_
"from FFACDET, FFACENC, Inventarios " &_
"where numfface = nfaffacd and codffacd = cveinv and Tipinv = 0 and almffacd = "& Almacen &" " &_
"and FECFFACE Between '"& FechaI &"' and '"& FechaF &"' and STAFFACE<>'c'"&_
"GROUP BY CODFFACD;"
Cn1.Execute Sql19
Set Rs20 = server.CreateObject("ADODB.Recordset")
Sql20 = "Insert Into Rotadet " &_
"(CodigoR, CantidadR, TipoR, UsuarioR) " &_
"Select Codminv, Sum(canminv), 'VE','"& Nombre &"' " &_
"from Rotacion, Movinv, Movcon " &_
"where Codigo = Codminv and Almacen = Almminv " &_
"and Fecminv Between '"& FechaI &"' and '"& FechaF &"' " &_
"and Tmominv = Cvecim and TipoC = 'VE' " &_
"GROUP BY CODMINV;"
Cn1.Execute Sql20
Set Rs21 = server.CreateObject("ADODB.Recordset")
Sql21 = "Insert Into RotaDet " &_
"(CodigoR, CantidadR, TipoR, UsuarioR) " &_
"Select Codminv, Max(canminv), 'MX', '"& Nombre &"' " &_
"from Rotacion, Movinv, Movcon " &_
"where Codigo = Codminv and Almacen = Almminv " &_
"and Fecminv Between '"& FechaI &"' and '"& FechaF &"' " &_
"and Tmominv = Cvecim and TipoC = 'VS' " &_
"GROUP BY CODMINV;"
Cn1.Execute Sql21
Set Rs22 = server.CreateObject("ADODB.Recordset")
Sql22 = "Insert Into RotaDet " &_
"(CodigoR, CantidadR, TipoR, UsuarioR) " &_
"Select Codminv, Min(canminv), 'MN', '"& Nombre &"' " &_
"from Rotacion, Movinv, Movcon " &_
"where Codigo = Codminv and Almacen = Almminv " &_
"and Fecminv Between '"& FechaI &"' and '"& FechaF &"' " &_
"and Tmominv = Cvecim and TipoC = 'VS' " &_
"GROUP BY CODMINV;"
Cn1.Execute Sql22
Set Rs23 = server.CreateObject("ADODB.Recordset")
Sql23 = "Update Rotacion " &_
"Set Cantxrec = CantidadR " &_
"From Rotadet " &_
"Where Codigo = CodigoR and TipoR = 'XR';"
Cn1.Execute Sql23
Set Rs24 = server.CreateObject("ADODB.Recordset")
Sql24 = "Update Rotacion " &_
"Set Ventas = (Ventas + CantidadR) " &_
"From Rotadet " &_
"Where Codigo = CodigoR and TipoR = 'VS';"
Cn1.Execute Sql24
Set Rs25 = server.CreateObject("ADODB.Recordset")
Sql25 = "Update Rotacion " &_
"Set Ventas = (Ventas - CantidadR) " &_
"From Rotadet " &_
"Where Codigo = CodigoR and TipoR = 'VE';"
Cn1.Execute Sql25
Set Rs26 = server.CreateObject("ADODB.Recordset")
Sql26 = "Update Rotacion " &_
"Set CanMin = (CanMin + CantidadR) " &_
"From Rotadet " &_
"Where Codigo = CodigoR and TipoR = 'MN';"
Cn1.Execute Sql26
Set Rs27 = server.CreateObject("ADODB.Recordset")
Sql27 = "Update Rotacion " &_
"Set CanMax = (CanMax + CantidadR) " &_
"From Rotadet " &_
"Where Codigo = CodigoR and TipoR = 'MX';"
Cn1.Execute Sql27
Response.Redirect("Rotacion.asp?Linea="& Linea &"&Sublinea="& Sublinea &"&Almacen="& Almacen &"&FechaI="& FechaI &"&FechaF="& FechaF &"&MsgF=1")
'************ Si ya se Generaron los Procedimiento entonces Genera el Reporte en Excel *****
Else
%>
***** Reporte Generado ***** <br>
Descargar Archivo en <a Href="Rotaxls.asp">Excel </a><br>
<%
End If
End If
%>
</div>
</body>
</html>
<%
End Sub
'Add the chosen course to the cart
Call AddUsuario()
'Display contents of electronic shopping cart
Call DisplayUsuario()
%>