<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file="dbsinil1.inc" -->
<!-- #include file="config.inc" -->
<!-- #include file="functions.inc" -->
<% 
on error resume next
%>
<%
Session.Timeout = 120
Server.ScriptTimeout = 5000
busca=request.QueryString("busca")
doc=request.QueryString("doc")
origen=request.QueryString("origen")
Date_ini=Request.Form("Date_ini")
Date_end=Request.Form("Date_end")
lvende=Request.Form("cvende")
criterio22=Request.Form("criterio22")
if criterio22="" then
 xcriterio22=" Todos "
end if

xday = Right("00" & Day(Date), 2)
xmonth = Right("00" & Month(Date), 2)
xyear = Right("00" & Year(Date), 4)
xdate=xyear&xmonth&xday 
Dim Rsfore0 
Dim Sqlfore0
  Dim objCDO
 Dim Conf
 Dim Fields

set Rsfore0=dbsql3.execute("SELECT * FROM forecast WHERE id=49")
 '************** Transfer
 xday2 = Right("00" & Rsfore0("month"), 2)
 xmonth2 = Right("00" & Rsfore0("forecast"), 2)
 xyear2 = Right("00" & Rsfore0("year"), 4)
 xdate2=xyear2&xmonth2&xday2 

''''''''''''''''''''''''''''''''''''''
If xdate>xdate2 Then
  response.write (ErrorNo1)
  mensaje=ErrorNo1
  
'''''''''''
 Set cdoConfig = CreateObject("CDO.Configuration")

 With cdoConfig.Fields
  .Item(cdoSendUsingMethod) = 2
  .Item(cdoSMTPServer) = "mail.shinwoousa.com"
  '"64.87.26.218"
  .Item(cdoSMTPauthenticate)=1
  .Item(cdoSendUsername)="sechevarria@shinwoousa.com"
   .Item(cdoSendPassword)="Sergio586*"
  .Item(cdoSMTPServerport)=587
  .Update
 End With

  Set cdoMessage = CreateObject("CDO.Message")
  Set Fields = Nothing
 Set objCDO = Nothing
 Set Conf = Nothing
  With cdoMessage
    Set .Configuration = cdoConfig
    .From = "sechevarria@shinwoousa.com"
    .To = correo
    .cc = "avaldez@shinwoousa.com;jmontano@shinwoousa.com;sgallegos@shinwoousa.com;ysalazar@shinwoousa.com;yvizcarra@shinwoousa.com;jamesoh@shinwoousa.com;jmedina@shinwoousa.com;dvilchis@shinwoousa.com;jguzman@shinwoousa.com;mahernandez@shinwoousa.com;ehernandez@shinwoousa.com;abecerra@shinwoousa.com;ikejung@shinwoousa.com"
    .bcc = "sistemas@shinwoousa.com"
     if acthora=7  or acthora=14 then 
      .Subject = "sending Automatic - Corr 2"
	 else
      .Subject = "sending Automatic - Corr 2"
	 end if
    '.TextBody = "Esta es una Prueba de envio automatico ASECO-Sergio"
    .HTMLBody= mensaje
    '.AddAttachment (archivopdf)
    '.AddAttachment (archivoxml)
    .Send
  End With
   
  Set cdoMessage = Nothing
  Set cdoConfig = Nothing
  
  
 else

if Date_ini="" or Date_ini=null then
 'Date_ini=date()-(day(date()))+1
 Date_ini=date()
 Date_end=date()
 lhora=right("00"&hour(time),2)
  lmin=right("00"&minute(time),2)
  ltime=lhora&lmin
  if ltime<"0659" then
   Date_ini=date()-1
   Date_end=date()-1
  end if
end if
Date_end3=cdate(Date_end) + 1
'response.write(Date_end)

dia1=right("00"&day(Date_ini),2)
mes1=right("00"&month(Date_ini),2)
anno1=right("00"&year(Date_ini),4)
'Date_inii=cdate(dia1+"/"+mes1+"/"+anno1)
cfechai=cdbl(anno1+mes1+dia1)

dia2=right("00"&day(Date_end3),2)
mes2=right("00"&month(Date_end3),2)
anno2=right("00"&year(Date_end3),4)
'cfechaf=cdate((dia2+"/"+mes2+"/"+anno2))
cfechaf=cdbl(anno2+mes2+dia2)

'''''''''''calcula
 strday = Right("00" & Day(Date_ini), 2)
 strmonth = Right("00" & Month(Date_ini), 2)
 stryear = Right("00" & Year(Date_ini), 4)
 strday2 = Right("00" & Day(Date_end3), 2)
 strmonth2 = Right("00" & Month(Date_end3), 2)
 stryear2 = Right("00" & Year(Date_end3), 4)
 fechainicial = CStr(stryear + strmonth + strday)
 fechafinal2 = CStr(stryear2 + strmonth2 + strday2)

'response.write(fechainicial&" ")
'response.write("FF "&fechafinal)
%>
traer los datos
<html> 

<head>
<meta http-equiv="refresh" content="3600">
<title>Report Corrugator II</title>
<meta name="author" content="<%= Developer%>">  
<link href="css/style.css" rel="stylesheet" media="screen">

<meta charset="utf-8">
  <title>datepicker demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<script type="text/javascript">
$(document).ready(function() {
   $("#datepicker").datepicker();
   $("#datepicker2").datepicker();
});
</script>

<style type="text/css">
<!--
.style8 {font-size: 18pt}
.style16 {
	font-size: 16px;
	font-weight: bold;
}
.style18 {
	font-size: 16;
	font-weight: bold;
	color: #FF0000;
}
-->
</style>
</head>
<body>

<%

set strConexao = CreateObject("ADODB.Connection") ' seteas la conexion
'strConexao.Open("DRIVER=Firebird/InterBase� driver; UID=SYSDBA;PWD=MOLRA; DBNAME=\\desktop-6psmf8k\firebird_db\CARDBOARD20.fdb")

strConexao.Open("DRIVER=Firebird/InterBase(r) driver;UID=SYSDBA;PWD=molra; DBNAME=192.168.0.201:C:\PAUL\data\CARDBOARD20.FDB")

  'Dim objCDO
  'Dim Conf
  'Dim Fields
'''''''''''

If Err.Number <> 0 then

 'HandleError Err.Description
   response.write("No DATE created")
   mensaje="Can't connect to Database. C2 Not running."

'*********************
 correo="ilkim@shinwoousa.com;inwans@shinwoousa.com"
  'Dim objCDO
  'Dim Conf
  'Dim Fields
'''''''''''
  Set cdoConfig = CreateObject("CDO.Configuration")

  With cdoConfig.Fields
   .Item(cdoSendUsingMethod) = 2
   .Item(cdoSMTPServer) = "mail.shinwoousa.com"
   '"64.87.26.218"
   .Item(cdoSMTPauthenticate)=1
   .Item(cdoSendUsername)="sechevarria@shinwoousa.com"
   .Item(cdoSendPassword)="Sergio586*"
   .Item(cdoSMTPServerport)=587
   .Update
  End With

   Set cdoMessage = CreateObject("CDO.Message")
   Set Fields = Nothing
   Set objCDO = Nothing
   Set Conf = Nothing
   With cdoMessage
     Set .Configuration = cdoConfig
     .From = "sechevarria@shinwoousa.com"
    .To = correo
	'.cc = "jamesoh@shinwoousa.com"
    .cc = "avaldez@shinwoousa.com;jmontano@shinwoousa.com;yvizcarra@shinwoousa.com;jamesoh@shinwoousa.com;jmedina@shinwoousa.com; lramirez@shinwoousa.com; asaldana@shinwoousa.com;dvilchis@shinwoousa.com;mahernandez@shinwoousa.com;ehernandez@shinwoousa.com;ikejung@shinwoousa.com"
    
	 .bcc = "sechevarria@shinwoousa.com"
      if acthora=7  or acthora=14 then 
       .Subject = "sending Automatic - Corr 2"
	  else
       .Subject = "sending Automatic - Corr 2"
	  end if
    '.TextBody = "Esta es una Prueba de envio automatico ASECO-Sergio"
     .HTMLBody= mensaje
	'.HTMLBody="hola"
    '.AddAttachment (archivopdf)
    '.AddAttachment (archivoxml)
     .Send
   End With
   
   Set cdoMessage = Nothing
   Set cdoConfig = Nothing

else

'abrir la base, fijate que esta en el directorio que la tienes ...
Set Corr2 = Server.CreateObject("ADODB.Recordset") ' seteas el recordset
'Set Corr2 = strConexao.Execute("SELECT * FROM PCSIN where jobymd between '" & fechainicial & "' and '" & fechafinal2 & "' and STAT='T' order by JOBYMD,JOBJO,STIME")
Set Corr2 = strConexao.Execute("SELECT * FROM PCSIN where LEFT(STIME,8) between '" & fechainicial & "' and '" & fechafinal2 & "' and STAT='T' order by STIME,Etime") ' lo ejecutas
 ' lo ejecutas
'JOBJO,JOBYMD,  JOBSEQ
lturno1="1"
lturno2="1"
%> 
<%
header
%>


<form method="Post" action="corrugator2mail.asp?busca=ok&origen=<%=origen%>">
<table>
   <tr>
   <td width="54">&nbsp;</td>
   <td width="180">&nbsp;
   </td>
   <td width="146">&nbsp; </td>
   <td width="124">&nbsp;</td>
   <td width="124"> </td>
   </tr>
   <tr>
   <td>Period:</td>
   <td>

   <input type="text" name="Date_ini" id="datepicker" size="20" value="<%=Date_ini%>">

   </td>
   <td><input type="text" name="Date_end" id="datepicker2" size="20" value="<%=Date_end%>">
    </td>
   <td><input type="submit" value="Generate" name="boton1">&nbsp;</td>
   <td>
    </td>
   </tr>
   
   <tr>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td><%=time%></td>
   </tr>
  </table>
</form>


<%
mensaje=mensaje&"<table cellspacing='0' cellpadding='0' border='2'>"
mensaje=mensaje&" <tr><td colspan='17' class='style8'>"& fechainicial &"-"&fechafinal&"<div align='center'> CORRUGATOR 2</div></td>"
mensaje=mensaje&" </tr>"
mensaje=mensaje&"  <tr bgcolor='#AAFFAA'>"
mensaje=mensaje&"    <td width='48' bgcolor='#AAFFAA' class='tool_button style17'>PROD DATE </td>"
mensaje=mensaje&"    <td width='50' bgcolor='#AAFFAA' class='tool_button style17'>Shift</td>"
mensaje=mensaje&"    <td width='50' bgcolor='#AAFFAA' class='tool_button style17'>Start</td>"
mensaje=mensaje&"    <td width='87' bgcolor='#AAFFAA' class='tool_button style17'>ORDER NO.</td>"
mensaje=mensaje&"	<td width='130' bgcolor='#AAFFAA' class='tool_button style17'>CUSTOMER</td>"
mensaje=mensaje&"    <td width='189' bgcolor='#AAFFAA' class='tool_button style17'>BOX ITEM</td>"
mensaje=mensaje&"    <td width='50' bgcolor='#AAFFAA' class='tool_button style17'>FLUTE</td>"
mensaje=mensaje&"    <td width='120' bgcolor='#AAFFAA' class='tool_button style17'>PAPER COMBINATION</td>"
mensaje=mensaje&"    <td width='51' bgcolor='#AAFFAA' class='tool_button style17'>LENGTH</td>"
mensaje=mensaje&"    <td width='67' bgcolor='#AAFFAA' class='tool_button style17'>WIDTH</td>"
mensaje=mensaje&"    <td width='58' bgcolor='#AAFFAA' class='tool_button style17'>TARGET</td>"
mensaje=mensaje&"    <td width='55' bgcolor='#AAFFAA' class='tool_button style17'>PROD QTY</td>"
mensaje=mensaje&"    <td width='50' bgcolor='#AAFFAA' class='tool_button style17'>TOTAL LENGTH (M)</td>"
mensaje=mensaje&"    <td width='61' bgcolor='#AAFFAA' class='tool_button style17'>TOTAL M2</td>"
mensaje=mensaje&"    <td width='61' bgcolor='#AAFFAA' class='tool_button style17'>Bad Qty</td>"
mensaje=mensaje&"    <td width='61' bgcolor='#AAFFAA' class='tool_button style17'>Work Hr</td>"
mensaje=mensaje&"    <td width='61' bgcolor='#FFFF66' class='tool_button style17'>Stop Hr</td>"
mensaje=mensaje&"  </tr>"

 if Not corr2.EOF and Not corr2.BOF then
   TOTML=0
   TOTM2=0
   TOTTARGET=0
   TOTPROD=0
    TOTML=0     
    TOTM2=0
	
	TOTTARGET2=0
    TOTPROD2=0
    TOTML2=0
    TOTM22=0
	TOTbad2=0
	TOTjtime2=0  
    TOTdtime2=0
	TOTITEMS=0
   corr2.movefirst
   'lturno1=Corr2("JOBJO")
   lturno1="1"
   lturno2="1"
  Do While Not corr2.EOF
   lestado=0
   shora=mid(Corr2("STIME"),10,2)&mid(Corr2("STIME"),13,2)&mid(Corr2("STIME"),16,2)
   Ehora=mid(Corr2("ETIME"),10,2)&mid(Corr2("ETIME"),13,2)&mid(Corr2("ETIME"),16,2)
   fecha1=mid(Corr2("STIME"),1,8)
   if (mid(Corr2("STIME"),1,8)=fechainicial and shora<"065000" and Ehora<"065001") then
    CORR2.MoveNext
	lestado=0
   end if
    Sec1=0
	Sec2=0
    if shora<"065000" and Ehora>"064959" then
 	  shora1=int(mid(Corr2("STIME"),10,2))*3600
	  shora2=int(mid(Corr2("STIME"),13,2))*60
	  shora3=int(mid(Corr2("STIME"),16,2))
	 hstart=shora1+shora2+shora3
	  ehora1=int(mid(Corr2("ETIME"),10,2))*3600
	  ehora2=int(mid(Corr2("ETIME"),13,2))*60
	  ehora3=int(mid(Corr2("ETIME"),16,2))
	 hend=ehora1+ehora2+ehora3
	 Shift1=24600
	 Sec1=int(Shift1-hstart)
	 Sec2=int(hend-Shift1)
	 'response.write(" Sec1 "&Sec1)
	 'response.write(" Sec2 "&Sec2)

    end if
    if (mid(Corr2("STIME"),1,8)=fechainicial) then
	 if Sec1>Sec2 then
 	  CORR2.MoveNext
	  lestado=0
	 else
      if Sec1<Sec2 then
	    lestado=1
	    xTurno="1"
	  end if
	 end if
	end if

	  if mid(Corr2("STIME"),1,8)=fechainicial and shora>"064959" then
        lestado=1
		Sec12=0
		Sec13=0
		Sec22=0
		Sec23=0
		if shora<"152000" and Ehora>"151959" then
 	     shora1=int(mid(Corr2("STIME"),10,2))*3600
	     shora2=int(mid(Corr2("STIME"),13,2))*60
	     shora3=int(mid(Corr2("STIME"),16,2))
	     hstart2=shora1+shora2+shora3
	     ehora1=int(mid(Corr2("ETIME"),10,2))*3600
	     ehora2=int(mid(Corr2("ETIME"),13,2))*60
	     ehora3=int(mid(Corr2("ETIME"),16,2))
	     hend2=ehora1+ehora2+ehora3
	     Shift2=55200
	     Sec12=int(Shift2-hstart2)
	     Sec22=int(hend2-Shift2)
        end if
		if shora<"232000" and Ehora>"231959" then
 	     shora1=int(mid(Corr2("STIME"),10,2))*3600
	     shora2=int(mid(Corr2("STIME"),13,2))*60
	     shora3=int(mid(Corr2("STIME"),16,2))
	     hstart3=shora1+shora2+shora3
	     ehora1=int(mid(Corr2("ETIME"),10,2))*3600
	     ehora2=int(mid(Corr2("ETIME"),13,2))*60
	     ehora3=int(mid(Corr2("ETIME"),16,2))
	     hend3=ehora1+ehora2+ehora3
	     Shift3=84000
	     Sec13=int(Shift3-hstart3)
	     Sec23=int(hend3-Shift3)
        end if
		
	   	if shora>"064959" and shora<"151959" then
	     xTurno="1"
	    end if
	    if (shora>"151959" and shora<"232000") or Sec22>Sec12 then
	     xTurno="2"
	    end if
		if Sec22>Sec12 then
		 xTurno="2"
		end if
	    if shora>"231959" or shora<"064959" or Sec23>Sec13 then
	     xTurno="3"
	    end if
	  end if
	  
      if (mid(Corr2("STIME"),1,8)=fechafinal2) then
	   if (shora>"064959") then
        CORR2.MoveNext
	    lestado=0
	   else
	    if Sec1<Sec2 then
		  CORR2.MoveNext
	      lestado=0
	    else
		  lestado=1
	      xTurno="3"
		end if
	   end if
	  end if
	    
      if lestado=1 then
       lm=int(cdbl(Corr2("Jang"))*(cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))))/1000
       lm2=int((cdbl(Corr2("Jang"))*cdbl(Corr2("WPOK")))*(cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))))/1000000
       totalTiempo = cdbl(corr2("dtime"))
       hores = int((totalTiempo/3600))
       aux = int(totalTiempo-(3600*hores))
       minuts = int(aux/60)
       segons = totalTiempo-hores*3600-minuts*60
       Downtime = hores&":"&right("00"&minuts,2)&":"&right("00"&segons,2)
	   
       Tiempo2 = cdbl(corr2("jtime"))
       hores2 = int((Tiempo2/3600))
       aux2 = int(Tiempo2-(3600*hores2))
       minuts2 = int(aux2/60)
       segons2 = Tiempo2-hores2*3600-minuts2*60
       Worktime = hores2&":"&right("00"&minuts2,2)&":"&right("00"&segons2,2)
       lstime=mid(Corr2("stime"),10,8)
       letime=mid(Corr2("etime"),10,8)
 	

     
     mensaje=mensaje&"  <tr>"
     mensaje=mensaje&"    <td class='xl67'>"&mid(Corr2("STIME"),1,8)&"</td>"
	 mensaje=mensaje&"    <td class='xl68'>"& corr2("JOBJO")&" </td>"
     mensaje=mensaje&"    <td class='xl67'>"&lstime&"-"&letime&"</td>"
     mensaje=mensaje&"    <td class='xl68'>"& corr2("SUJUNO")&" </td>"
     mensaje=mensaje&"	  <td class='xl68'>"& corr2("CUST")&"</td>"
     mensaje=mensaje&"    <td class='xl68'>"& corr2("BOXName")&" </td>"
     mensaje=mensaje&"    <td class='xl68'>"& corr2("GOL")&"</td>"
     mensaje=mensaje&"    <td class='xl68'>"& corr2("BEHAP")&" </td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& corr2("JANG")&" </td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& corr2("WPOK")&" </td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& corr2("QTY")&"</td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))&" </td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& formatnumber(lm,0)&" </td>"
     mensaje=mensaje&"    <td class='xl68' align='right'>"& formatnumber(lm2,0) &"</td>"
     mensaje=mensaje&"<td class='xl68' align='right'>"&corr2("EQTY")&" </td>"
     mensaje=mensaje&"<td class='xl68' align='right'>"& worktime&" </td>"
     mensaje=mensaje&"<td class='xl68' align='right'>"& downtime&" </td>"
     mensaje=mensaje&"  </tr>"	
	
      TOTTARGET=TOTTARGET+cdbl(corr2("QTY"))
       TOTPROD=TOTPROD+cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY"))
       TOTML=TOTML+lm       '(corr2("JANG")*corr2("PQTY")/1000)
       TOTM2=TOTM2+lm2      '(corr2("JANG")*corr2("WPOK")*corr2("PQTY")/1000000)
	   TOTbad=TOTbad+cdbl(corr2("eQTY"))
	
       TOTjtime=TOTjtime+cdbl(corr2("jtime"))
       TOTdtime=TOTdtime+cdbl(corr2("dtime"))
	
	   TOTTARGET2=TOTTARGET2+cdbl(corr2("QTY"))
       TOTPROD2=TOTPROD2+cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY"))
       TOTML2=TOTML2+lm       '(corr2("JANG")*corr2("PQTY")/1000)
       TOTM22=TOTM22+lm2      '(corr2("JANG")*corr2("WPOK")*corr2("PQTY")/1000000)
	   TOTbad2=TOTbad2+cdbl(corr2("eQTY"))
	   TOTjtime2=TOTjtime2+cdbl(corr2("jtime"))
       TOTdtime2=TOTdtime2+cdbl(corr2("dtime"))
	   TOTITEMS=TOTITEMS+1
       
	
       CORR2.MoveNext
       if not Corr2.eof then
         shora2=mid(Corr2("STIME"),10,2)&mid(Corr2("STIME"),13,2)&mid(Corr2("STIME"),16,2)
		 Ehora2=mid(Corr2("ETIME"),10,2)&mid(Corr2("ETIME"),13,2)&mid(Corr2("ETIME"),16,2)
 	     if shora2>"064959" and shora2<"152000" then
 	      lturno2="1"
	     end if
	     if shora2>"151959" and shora2<"232000" then
	      lturno2="2"
	     end if
	     if shora2>"231959" or shora2<"065000" then
	      lturno2="3"
	     end if
		  if shora2<"065000" and Ehora2>"064959" then
		    shora1x=int(mid(Corr2("STIME"),10,2))*3600
	        shora2x=int(mid(Corr2("STIME"),13,2))*60
	        shora3x=int(mid(Corr2("STIME"),16,2))
	        hstartx=shora1x+shora2x+shora3x
	        ehora1x=int(mid(Corr2("ETIME"),10,2))*3600
	        ehora2x=int(mid(Corr2("ETIME"),13,2))*60
	        ehora3x=int(mid(Corr2("ETIME"),16,2))
	        hendx=ehora1x+ehora2x+ehora3x
	        Shift1=24600
	        Sec1x=int(Shift1-hstartx)
	        Sec2x=int(hendx-Shift1)
			if Sec2x>Sec1x then
			 lturno2="1"
			end if
		  end if
		 
		  if (shora2<"152000" and Ehora2>"151959") or (shora2<"232000" and Ehora2>"231959") then
 	       shn1=int(mid(Corr2("STIME"),10,2))*3600
	       shn2=int(mid(Corr2("STIME"),13,2))*60
	       shn3=int(mid(Corr2("STIME"),16,2))
	       hstn=shn1+shn2+shn3
	       ehn1=int(mid(Corr2("ETIME"),10,2))*3600
	       ehn2=int(mid(Corr2("ETIME"),13,2))*60
	       ehn3=int(mid(Corr2("ETIME"),16,2))
	       hend2n=ehn1+ehn2+ehn3
		   if (shora2<"152000" and Ehora2>"151959") then
	        Shift2=55200
	        Sec1n=int(Shift2-hstn)
	        Sec2n=int(hend2n-Shift2)
		    if Sec1n>Sec2n then
		     lturno2="1"
		    else
		     lturno2="2"
		    end if
		   end if
		   if (shora2<"232000" and Ehora2>"231959") then
 		    Shift3=84000
	        Sec1n3=int(Shift3-hstn)
	        Sec2n3=int(hend2n-Shift3)
		    if Sec1n3>Sec2n3 then
		     lturno2="2"
		    else
		     lturno2="3"
		    end if
           end if
          end if
	   '  if Corr2("JOBJO")="A" then
	   '   lTurno2="1"
	   '  end if
	   '  if Corr2("JOBJO")="B" then
	   '   lTurno2="2"	
	   '  end if
	   '  if Corr2("JOBJO")="C" then
	   '   lTurno2="3"
	   '  end if
       'lturno2=xTurno
       end if	
	  
	 'end if
	'End if 
   'End if
  'end if

	if Corr2.eof or lturno1<>lturno2 then 
	 if TOTML2>0 and (TOTjtime2+TOTdtime2)>0 then
	  lspeedtot2=int(TOTML2/((TOTjtime2+TOTdtime2)/60))
     else
	  lspeedtot2=0
	 end if
	 if  TOTTARGET2>0 then
	   hores5 = int((TOTjtime2/3600))
       aux5 = int(TOTjtime2-(3600*hores5))
       minuts5 = int(aux5/60)
       segons5 = TOTjtime2-hores5*3600-minuts5*60
       Worktime5 = hores5&":"&right("00"&minuts5,2)&":"&right("00"&segons5,2)
	   
	   hores6 = int((TOTdtime2/3600))
       aux6 = int(TOTdtime2-(3600*hores6))
       minuts6 = int(aux6/60)
       segons6 = TOTdtime2-hores6*3600-minuts6*60
       delaytime5 = hores6&":"&right("00"&minuts6,2)&":"&right("00"&segons6,2)
	 
	  mensaje=mensaje&"  <tr>"
      mensaje=mensaje&"    <td class='xl67'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl67'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68'><strong>Total Shift</strong></td>"
      mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68'>"& formatnumber(TOTITEMS2,0) &"</td>"
      mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68' align='right'>&nbsp;</td>"
      mensaje=mensaje&"    <td class='xl68' align='right'>&nbsp;</td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTTARGET2,0)&"</strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD2,0)&"</strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML2,0) &"&nbsp;M</strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM22,0) &"&nbsp;M2</strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTbad2,0) &"&nbsp;</strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong></strong></DIV></td>"
      mensaje=mensaje&"    <td align='right' bgcolor='FFFF66' class='xl68'><div align='right' class=style15><strong></strong></DIV></td>"
      mensaje=mensaje&"  </tr>"
	  lturno1=lturno2
	   TOTTARGET2=0
       TOTPROD2=0
       TOTML2=0
       TOTM22=0
	   TOTbad2=0
	   TOTjtime2=0
       TOTdtime2=0
	
     end if
    end if
   end if 
 LOOP
'END IF
corr2.close
end if
''''''''''''''''''''''''
 if totitems>0 then
  lspeedtot=int(TOTML/((TOTjtime+TOTdtime)/60))
  Tiempod = TOTdtime
  hores3 = int((Tiempod/3600))
  aux3 = int(Tiempod-(3600*hores3))
  minuts3 = int(aux3/60)
  segons3 = Tiempod-hores3*3600-minuts3*60
  totdt2 = hores3&":"&right("00"&minuts3,2)&":"&right("00"&segons3,2)

  Tiempow = totjtime
  hores4 = int((Tiempow/3600))
  aux4 = int(Tiempow-(3600*hores4))
  minuts4 = int(aux4/60)
  segons4 = Tiempow-hores4*3600-minuts4*60
  totwt2 = hores4&":"&right("00"&minuts4,2)&":"&right("00"&segons4,2)
  
   mensaje=mensaje&"  <tr>"
   mensaje=mensaje&"    <td class='xl67'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl67'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68'><strong>TOTAL </strong></td>"
   mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68'>"& formatnumber(TOTITEMS,0) &"</td>"
   mensaje=mensaje&"    <td class='xl68'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68' align='right'>&nbsp;</td>"
   mensaje=mensaje&"    <td class='xl68' align='right'>&nbsp;</td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTTARGET,0)&"</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD,0)&"</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML,0) &"&nbsp;M</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM2,0) &"&nbsp;M2</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTbad,0) &"&nbsp;</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&TOTwt2 &" hrs</strong></DIV></td>"
   mensaje=mensaje&"    <td align='right' bgcolor='FFFF66' class='xl68'><div align='right' class=style15><strong>"&TOTdt2 &" hrs</strong></DIV></td>"
   mensaje=mensaje&"  </tr>"
 end if

mensaje=mensaje&"</TABLE>"

' End If   ' licencia expirada
'Corr2.Close 
strConexao.Close 
Set strConexao=Nothing 

 '*********************
 correo="ilkim@shinwoousa.com;inwans@shinwoousa.com"
  'Dim objCDO
  'Dim Conf
  'Dim Fields
'''''''''''
  Set cdoConfig = CreateObject("CDO.Configuration")

  With cdoConfig.Fields
   .Item(cdoSendUsingMethod) = 2
   .Item(cdoSMTPServer) = "mail.shinwoousa.com"
   '"64.87.26.218"
   .Item(cdoSMTPauthenticate)=1
   .Item(cdoSendUsername)="sechevarria@shinwoousa.com"
   .Item(cdoSendPassword)="Sergio586*"
   .Item(cdoSMTPServerport)=587
   .Update
  End With

   Set cdoMessage = CreateObject("CDO.Message")
   Set Fields = Nothing
   Set objCDO = Nothing
   Set Conf = Nothing
   With cdoMessage
     Set .Configuration = cdoConfig
     .From = "sechevarria@shinwoousa.com"
    .To = correo
    .cc = "avaldez@shinwoousa.com;jmontano@shinwoousa.com;ysalazar@shinwoousa.com;yvizcarra@shinwoousa.com;jamesoh@shinwoousa.com;jmedina@shinwoousa.com; lramirez@shinwoousa.com; asaldana@shinwoousa.com;dvilchis@shinwoousa.com;mahernandez@shinwoousa.com;ehernandez@shinwoousa.com;ikejung@shinwoousa.com;jsyc300@shinwoousa.com"
    
	 .bcc = "sechevarria@shinwoousa.com"
      if acthora=7  or acthora=14 then 
       .Subject = "sending Automatic - Corr 2"
	  else
       .Subject = "sending Automatic - Corr 2"
	  end if
    '.TextBody = "Esta es una Prueba de envio automatico ASECO-Sergio"
     .HTMLBody= mensaje
	'.HTMLBody="hola"
    '.AddAttachment (archivopdf)
    '.AddAttachment (archivoxml)
     .Send
   End With
   
   Set cdoMessage = Nothing
   Set cdoConfig = Nothing


end if    ' si hay error

%>
</body> 
</html> 
<%
End If
Rsfore0.Close
Set Rsfore0 = Nothing
'''''''''''''

%>