<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%@ LANGUAGE = "VBScript" %>
<%Response.Buffer = False%>
<!-- #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
Set Corrv = Server.CreateObject("ADODB.Recordset") ' seteas el recordset
'Set Corrv = dbsql5.Execute("SELECT * FROM tblcurrent") ' lo ejecutas 

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 

'xdate2="20220821"
 layer=weekday(date()-1)
 hractual=hour(Now)
 minactual=minute(now)

''''''''''''''''''''''''''''''''''''''
If xdate>xdate2 Then
  'response.write (ErrorNo1)
  mensaje1=ErrorNo1
'''''''''''

else

 if Date_ini="" or Date_ini=null then
  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

''''''''''''''''''''''''''''''''''''''

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="es">

<head>
<meta http-equiv="refresh" content="297">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Report Corrugator I, II</title>
<meta name="author" content="<%= Developer%>">  
<link href="css/style.css" rel="stylesheet" media="screen">

<meta charset="utf-8">
  <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">
<!--
.style1 {
	font-size: x-large;
	font-weight: bold;
}
.style2 {color: #008000}
.style3 {color: #F07800}
.style4 {color: #133D88}
.style5 {font-size: 10}
.style7 {
	color: #FF0000;
	font-weight: bold;
	font-size: large;
}
-->
</style>
<style type="text/css">
.th2 {     font-size: 14px;     font-weight: bold;     padding: 1px;     background: #3399FF;
     border-top: 1px solid #aabcfe;    border-bottom: 1px solid #fff; color: #fff; }
.td1 {    padding: 1px;     background: #AADFFF;     border-bottom: 1px solid #fff;
     color: #669;    border-top: 1px solid transparent; }
.td2 {    padding: 1px;     background: #84D1FF;     border-bottom: 1px solid #fff;
     color: #000;    border-top: 1px solid transparent; }
.td3 {    padding: 1px;     background: #0033cc;     border-bottom: 1px solid #fff;
     color: #fff;    border-top: 1px solid transparent; }

.style6 {color: #0000FF}


</style>
</head>
<body>

<form method="Post" action="reportcorrugatormail_all2022.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><%=response.write(now)%>
    </td>
   </tr>
   
   <tr>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   </tr>
  </table>
</form>
<%
header
 if minactual>50 and minactual<56 then                    '       ********** minuto 50

%>
<p>
  <%

'''''''''''calcula
 Date_end2=cdate(Date_end)+1
 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_end2), 2)
 strmonth2 = Right("00" & Month(Date_end2), 2)
 stryear2 = Right("00" & Year(Date_end2), 4)
 fechainicial = CStr(stryear + strmonth + strday)
 fechafinal = CStr(stryear2 + strmonth2 + strday2)
 'fechainicial = "20220302"
 'fechafinal = "20220303"
 
  response.write(fechainicial)&" FI "
  response.write(fechafinal)&" Ff "

%>
<center>
<span class="style8">Production Corrugator Machine</span><br>
<span class="style8">Date: <%=Date_ini%> To: <%=Date_end%> Generated: <%=time%></span>
</center>
<%    

'************** Inventory
'lturno=0
Dim Rsinven1, Rsinven2, rswip, Rsmachine
Dim Sqlinven1, sqlinven2, sqlwip

'''''''''''''''''''''''''''''''''''''''
lq=" select GOL,JIJG,JANG,WPOK,QTY,PQTY,SUJUNO,JOBYMD,CUST,BOX_NM,eqty,jtime,dtime,JOBJO,STIME,Etime,sdate,Edate from SHPSOUT(nolock) where jobymd between '" & fechainicial & "' and '" & fechafinal & "' order by JOBYMD,JOBJO "
response.write(lq)
set Rscorr=dbsqlcorr.execute("select GOL,JIJG,JANG,WPOK,QTY,PQTY,SUJUNO,JOBYMD,CUST,BOX_NM,eqty,jtime,dtime,JOBJO,STIME,Etime,sdate,Edate,slsc from SHPSOUT(nolock) where jobymd between '" & fechainicial & "' and '" & fechafinal & "' order by JOBYMD,JOBJO,sdate,STIME,Etime")

lturno1="1"
lturno2="1"
 'mensaje1=mensaje1&" <font color='#FF0000'><strong> Su licencia esta proxima a vencerse. Es necesario renovarla. </strong></font> <br>"
 'mensaje1=mensaje1&" <strong><font color='#FF0000'> Your license is about to expire. You need to renew it. </font></strong> <br><br>"
 mensaje2=mensaje2&"<strong>Hourly Status of Corrugator 1 & 2 </strong><br>"

  mensaje1=mensaje1&"<strong>Hourly Status of Corrugator 1 & 2 </strong>"
  mensaje1=mensaje1&"<table border='1'>"
  mensaje1=mensaje1&" <tr><td colspan='17' class='style8'><div align='center'><strong> CORRUGATOR I </strong></div></td>"
  mensaje1=mensaje1&" </tr>"
  mensaje1=mensaje1&"  <tr bgcolor='#FFDDCC'>"
  mensaje1=mensaje1&"    <td align='center' width='20' bgcolor='#FFDDCC' class='tool_button style17'><strong>ST</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='100' bgcolor='#FFDDCC' class='tool_button style17'><strong>TIME</strong></td>"
  mensaje1=mensaje1&"	 <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>CUSTOMER</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>BOX ITEM</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>WO NO.</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>COMBINATION</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>L</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>W</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>WO</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>WO2</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>Out</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#FFDDCC' class='tool_button style17'><strong>Prod</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#FFDDCC' class='tool_button style17'><strong>Prod 2</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#FFDDCC' class='tool_button style17'><strong>+/-</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#FFDDCC' class='tool_button style17'><strong>% Dif</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#FFDDCC' class='tool_button style17'><strong>M</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='61' bgcolor='#FFDDCC' class='tool_button style17'><strong>M2</strong></td>"
  mensaje1=mensaje1&"  </tr>"

       TOTPROD2=0
       TOTML2=0
       TOTM22=0
xactualizado=0
 If Rscorr.EOF And Rscorr.BOF Then
   response.Write("  No records exist for corr. this date.  ")
 Else

'   mensaje1=" <strong> TRANSFER (Samsung OB)</strong> <br><br>"
 
  TOTML=0
  TOTM2=0
  Rscorr.movefirst
  Do While Not Rscorr.EOF
       lehora1=mid(Rscorr("ETIME"),1,2)
	   lehora2=mid(Rscorr("ETIME"),4,2)
	   lehora3=mid(Rscorr("ETIME"),7,2)
       shoran=mid(RsCORR("STIME"),1,2)&mid(RsCORR("STIME"),4,2)&mid(RsCORR("STIME"),7,2)

	   lhend=lehora1&lehora2&lehora3
	   lsdate1=mid(Rscorr("sdate"),1,4)
	   lsdate2=mid(Rscorr("sdate"),6,2)
	   lsdate3=mid(Rscorr("sdate"),9,2)
	   lsdate=lsdate1&lsdate2&lsdate3
	   response.write(Rscorr("jobymd"))
   if (lsdate<fechainicial and lhend<"065000") or (lsdate>fechainicial and shoran>"065000") or trim(Rscorr("jobymd"))=fechafinal then
     response.write(" FI: "&lsdate&" etime: "&Rscorr("etime")&" x "&lhend)
     response.write(" skip ")
     if trim(Rscorr("jobymd"))=fechafinal then

     end if
	   RsCORR.MoveNext
   else
       lstime=Rscorr("STIME")
    if left(Rscorr("JOBJO"),1)="A" then
	  if Rscorr("jtime")>25000 then
	   lstime="06:50:00"
       ehora1=int(mid(Rscorr("ETIME"),1,2))*3600
	   ehora2=int(mid(Rscorr("ETIME"),4,2))*60
	   ehora3=int(mid(Rscorr("ETIME"),7,2))
	   hend=ehora1+ehora2+ehora3
	   Tiempo2=hend-24600
      else
       Tiempo2 = Rscorr("jtime")
      end if	
	  'response.write(" 1 ")
	 else
	   lstime=Rscorr("STIME")
	   Tiempo2 = Rscorr("jtime")
	   	  'response.write(" 2 ")
	 end if
	 lout=mid(Rscorr("SLSC"),instr(Rscorr("SLSC"),"/")-1,1)
	 'if instr(Rscorr("SLSC"),"/")>0 then
	 '  response.write(" lout: "&Rscorr("SLSC"))
	 'end if
    'lturno1=Rscorr("JOBJO")
	lstimex=mid(lstime,1,5)
    mensaje1=mensaje1&"  <tr>"
    mensaje1=mensaje1&"    <td align='center' class='xl67'>"&Rscorr("JOBJO")&"</td>"
    mensaje1=mensaje1&"    <td class='xl67'>"&lstimex&"</td>"
    mensaje1=mensaje1&"	   <td class='xl68'>"& left(Rscorr("CUST"),10)&"</td>"
    mensaje1=mensaje1&"    <td class='xl68'>"& left(Rscorr("BOX_NM"),10)&" </td>"
    mensaje1=mensaje1&"    <td class='xl68'>"& Rscorr("SUJUNO")&" </td>"
    mensaje1=mensaje1&"    <td align='center' class='xl68'>"& Rscorr("JIJG")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("JANG")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("WPOK")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("QTY")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("QTY")*(lout)&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"&lout&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("PQTY")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("PQTY")*(lout)&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& Rscorr("PQTY")-Rscorr("QTY")&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber(((Rscorr("PQTY")-Rscorr("QTY"))/Rscorr("QTY"))*100,1)&" % </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber((Rscorr("JANG")*Rscorr("PQTY")/1000),0)&" </td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber((Rscorr("JANG")*Rscorr("WPOK")*Rscorr("PQTY")/1000000),0) &"</td>"
    totsh1=Rscorr("JOBJO")
totalTiempo = Rscorr("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)
Downtime = hores&":"&right("00"&minuts,2)
 
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)
Worktime = hores2&":"&right("00"&minuts2,2)

    mensaje1=mensaje1&"  </tr>"
 
    TOTTARGET=TOTTARGET+Rscorr("QTY")
    TOTWOc1=TOTWOc1+(Rscorr("QTY")*(lout))
    TOTPROD=TOTPROD+Rscorr("PQTY")
	TotDif=TotDif+int(Rscorr("PQTY")-Rscorr("QTY"))
    TOTPROD3=TOTPROD3+(Rscorr("PQTY")*(lout))
    TOTML=TOTML+(Rscorr("JANG")*Rscorr("PQTY")/1000)
    TOTM2=TOTM2+(Rscorr("JANG")*Rscorr("WPOK")*Rscorr("PQTY")/1000000)
    TOTbad=TOTbad+Rscorr("eQTY")
    TOTjtime=TOTjtime+Tiempo2
    TOTdtime=TOTdtime+Rscorr("dtime")
	TOTITEMS=TOTITEMS+1
	TOTITEMS2=TOTITEMS2+1
	
	   TOTTARGET2=TOTTARGET2+cdbl(Rscorr("QTY"))
	   TOTWO2=TOTWO2+(cdbl(Rscorr("QTY"))*(lout))
       TOTPROD2=TOTPROD2+cdbl(Rscorr("PQTY"))
	   TotDif2=TotDif2+int(Rscorr("PQTY")-Rscorr("QTY"))
       TOTPROD32=TOTPROD32+(Rscorr("PQTY")*(lout))
       TOTML2=TOTML2+(Rscorr("JANG")*Rscorr("PQTY")/1000)
       TOTM22=TOTM22+(Rscorr("JANG")*Rscorr("WPOK")*Rscorr("PQTY")/1000000)
	   TOTbad2=TOTbad2+cdbl(Rscorr("eQTY"))
	   TOTjtime2=TOTjtime2+cdbl(Tiempo2)
       TOTdtime2=TOTdtime2+cdbl(Rscorr("dtime"))
	
  RsCORR.MoveNext
	
	if not RsCORR.eof then
         shora2=int(mid(RsCORR("STIME"),1,2)&mid(RsCORR("STIME"),4,2)&mid(RsCORR("STIME"),7,2))
		 Ehora2=int(mid(RsCORR("ETIME"),1,2)&mid(RsCORR("ETIME"),4,2)&mid(RsCORR("ETIME"),7,2))
		 'response.write(" sh "&shora2)
		 'response.write(" eh "&ehora2)
		 
 	     if shora2>064959 and shora2<152000 then
 	      lturno2="1"
	     end if
	     if shora2>151959 and shora2<232000 then
	      lturno2="2"
		  'response.write(" t2x "&ehora2)
	     end if
	     if shora2>231959 or shora2<065000 then
	      lturno2="3"
	     end if
		  if shora2<065000 and Ehora2>064959 then
		    'response.write(" t20 "&ehora2)
		    shora1x=int(mid(RsCORR("STIME"),1,2))*3600
	        shora2x=int(mid(RsCORR("STIME"),4,2))*60
	        shora3x=int(mid(RsCORR("STIME"),7,2))
	        hstartx=shora1x+shora2x+shora3x
	        ehora1x=int(mid(RsCORR("ETIME"),1,2))*3600
	        ehora2x=int(mid(RsCORR("ETIME"),4,2))*60
	        ehora3x=int(mid(RsCORR("ETIME"),7,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
		   'response.write(RsCORR("STIME")&" ")
		   'response.write(RsCORR("ETIME")&" ")
		  if (RsCORR("STIME")<"15:20:00" and RsCORR("ETIME")>"15:19:59") then
		   'response.write(" t21 "&ehora2)
 	       shn1=int(mid(RsCORR("STIME"),1,2))*3600
	       shn2=int(mid(RsCORR("STIME"),4,2))*60
	       shn3=int(mid(RsCORR("STIME"),7,2))
	       hstn=shn1+shn2+shn3
	       ehn1=int(mid(RsCORR("ETIME"),1,2))*3600
	       ehn2=int(mid(RsCORR("ETIME"),4,2))*60
	       ehn3=int(mid(RsCORR("ETIME"),7,2))
	       hend2n=ehn1+ehn2+ehn3
		   if (shora2<"152000" and Ehora2>"151959") then
	        'Shift2=67800
			Shift2=55200
	        Sec1n=int(Shift2-hstn)
	        Sec2n=int(hend2n-Shift2)
		    if Sec1n>Sec2n then
		     lturno2="1"
		    else
		     lturno2="2"
		    end if
			'response.write(" t2 "&Sec2n)
		   end if
          end if
		   ledate=mid(RsCORR("Edate"),1,4)&mid(RsCORR("Edate"),6,2)&mid(RsCORR("Edate"),9,2)
		   lsdate=mid(RsCORR("Sdate"),1,4)&mid(RsCORR("Sdate"),6,2)&mid(RsCORR("Sdate"),9,2)

		  if (RsCORR("STIME")<"23:20:00" and RsCORR("ETIME")>"23:19:59") or (RsCORR("STIME")<"23:20:00" and ledate>lsdate)  then
 	         shn1=int(mid(RsCORR("STIME"),1,2))*3600
	         shn2=int(mid(RsCORR("STIME"),4,2))*60
	         shn3=int(mid(RsCORR("STIME"),7,2))
	         hstn=shn1+shn2+shn3
	         ehn1=int(mid(RsCORR("ETIME"),1,2))*3600
	         ehn2=int(mid(RsCORR("ETIME"),4,2))*60
	         ehn3=int(mid(RsCORR("ETIME"),7,2))
			 if ledate>lsdate then
	           hend2n=ehn1+ehn2+ehn3+86400
			 else
			   hend2n=ehn1+ehn2+ehn3
			 end if

 		     Shift3=84000
	         Sec1n3=int(Shift3-hstn)
	         Sec2n3=int(hend2n-Shift3)
		     if Sec1n3>Sec2n3 then
		      lturno2="2"
		     else
		      lturno2="3"
			 end if
          end if
		 'lturno2=Rscorr("JOBJO")
    end if	
	
   if lturno1<>lturno2 or RsCorr.eof then
     if TOTML2>0 and (TOTjtime2+TOTdtime2)>0 then
	  lspeedtot2=int(TOTML2/((TOTjtime2)/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)
       if lturno1="1" then
	     lshift="1st"
	   end if
	   if lturno1="2" then
	     lshift="2nd"
	   end if
	   if lturno1="3" then
	     lshift="3rd"
	   end if

     mensaje1=mensaje1&"  <tr>"
     mensaje1=mensaje1&"    <td class='xl68'>&nbsp;</td>"
     mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>Total Shift "& lshift &"</strong></td>"
	 mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>AVG Speed</strong></td>"
     mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(lspeedtot2,0) &"</strong></td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>"&FORMATNUMBER(TOTTARGET2,0) &"</td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>"&FORMATNUMBER(TOTWO2,0) &"</td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
     mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD2,0)&"</strong></DIV></td>"
     mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD32,0)&"</strong></DIV></td>"
     mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TotDif2,0)&"</strong></DIV></td>"
     mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
     mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML2,0) &"</strong></DIV></td>"
     mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM22,0) &"</strong></DIV></td>"
     mensaje1=mensaje1&"  </tr>"
     actfecha=mid(fechainicial,3,6)
    if lturno1="1" then
     set rsactprod=dbsql3.execute("update datagraph set c1s1lm="& TOTML2 &",c1s1m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=1
    end if
    if lturno1="2" then
     set rsactprod=dbsql3.execute("update datagraph set c1s2lm="& TOTML2 &",c1s2m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=2
    end if
    if lturno1="3" then
     set rsactprod=dbsql3.execute("update datagraph set c1s3lm="& TOTML2 &",c1s3m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=2
    end if

     TOTTARGETs=0
     TOTPRODs=0
     TOTMLs=0
     TOTM2s=0
	 TOTITEMS2=0
	 
	 lturno1=lturno2
	   TOTTARGET2=0
	   TOTWO2=0
	   TOTTARGET32=0
       TOTPROD2=0
       TOTPROD32=0
	   TotDif2=0
       TOTML2=0
       TOTM22=0
	   TOTbad2=0
	   TOTjtime2=0
       TOTdtime2=0
   end if
  end if
  'lturno1=lturno2
  end if    'si etime<065000
  LOOP
 END IF
 rscorr.close
''''''''''''''''''''''''    FIN rscorr
 Tiempod = TOTdtime
 hores3 = int((Tiempod/3600))
 aux3 = int(Tiempod-(3600*hores3))
 minuts3 = int(aux3/60)
 segons3 = Tiempod-hores3*3600-minuts3*60
 totdt = hores3&":"&right("00"&minuts3,2)

 Tiempow = totjtime
 hores4 = int((Tiempow/3600))
 aux4 = int(Tiempow-(3600*hores4))
 minuts4 = int(aux4/60)
 segons4 = Tiempow-hores4*3600-minuts4*60
 totwt = hores4&":"&right("00"&minuts4,2)

 mensaje1=mensaje1&"  <tr>"
 mensaje1=mensaje1&"    <td class='xl68'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>TOTAL</strong></td>"
 mensaje1=mensaje1&"    <td colspan='2' align='right' class='xl68'><strong>"& formatnumber(TOTITEMS,0) &"</strong></td>"
 mensaje1=mensaje1&"    <td class='xl68'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>"&FORMATNUMBER(TOTTARGET,0) &"</td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>"&FORMATNUMBER(TOTWOc1,0) &"</td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD,0)&"</strong></DIV></td>"
 mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD3,0)&"</strong></DIV></td>"
 mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TotDif,0)&"</strong></DIV></td>"
 mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
 mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML,0) &"</strong></DIV></td>"
 mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM2,0) &"</strong></DIV></td>"
 mensaje1=mensaje1&"  </tr>"
 mensaje1=mensaje1&"</TABLE><br>"
 if xactualizado=0 then
     actfecha=mid(fechainicial,3,6)
     set rsactprod=dbsql3.execute("update datagraph set c1s1lm=0,c1s1m2=0,c1s2lm=0,c1s2m2=0 where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
 end if


''''''''''''''''''**************************corr 2
  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
  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), 2)
   strday2 = Right("00" & Day(Date_end3), 2)
   strmonth2 = Right("00" & Month(Date_end3), 2)
   stryear2 = Right("00" & Year(Date_end3), 2)
   fechainicial = CStr(stryear + strmonth + strday)
   fechafinal2 = CStr(stryear2 + strmonth2 + strday2)

 ' set strConexao = CreateObject("ADODB.Connection") ' seteas la conexion
 ' strConexao.Open("DRIVER=Firebird/InterBase(r) driver;UID=SYSDBA;PWD=molra; DBNAME=192.168.0.201:C:\PAUL\data\CARDBOARD20.FDB")
 Set dbsql5 = Server.CreateObject("ADODB.Connection")
 'strsql5="DRIVER={SQL Server};SERVER=192.168.0.201;UID=sa;PWD=Shinwoo*2021;DATABASE=CARDBOARD20"
 strsql5="DRIVER={SQL Server};SERVER=192.168.1.194;UID=sa;PWD=Shin*20;DATABASE=CARDBOARD20"
 dbsql5.open strsql5

 If Err.Number <> 0 then
   response.write(" No DATE created ")
   mensaje="Can't connect to Database. C2 Not running."
   mensaje1=mensaje1&"<br><br>Can't connect to Database. C2 Not running."
 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 LEFT(STIME,8) between '" & fechainicial & "' and '" & fechafinal2 & "' and STAT='T' order by STIME,Etime") ' lo ejecutas
  Set Corr2 = dbsql5.Execute("SELECT * FROM PCSIN where (jobymd between '" & fechainicial & "' and '" & fechafinal2 & "') and left(STAT,1)='T'  order by jobymd, jobjo,stime,etime") ' lo ejecutas 
  lq=" SELECT * FROM PCSIN where (jobymd between '" & fechainicial & "' and '" & fechafinal2 & "') and left(STAT,1)='T'  order by jobymd, jobjo,stime,etime "
  response.write(lq)
  lturno1="1"
  lturno2="1"
 
  mensaje1=mensaje1&"<table border='1'>"
  mensaje1=mensaje1&" <tr><td colspan='17' class='style8'><div align='center'><strong> CORRUGATOR 2</strong></div></td>"
  mensaje1=mensaje1&" </tr>"
  mensaje1=mensaje1&"  <tr bgcolor='#AAFFAA'>"
  mensaje1=mensaje1&"    <td align='center' width='20' bgcolor='#AAFFAA' class='tool_button style17'><strong>ST</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='107' bgcolor='#AAFFAA' class='tool_button style17'><strong>TIME</strong></td>"
  mensaje1=mensaje1&"	 <td align='center' width='115' bgcolor='#AAFFAA' class='tool_button style17'><strong>CUSTOMER</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='115' bgcolor='#AAFFAA' class='tool_button style17'><strong>BOX ITEM</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>WO NO.</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='195' bgcolor='#AAFFAA' class='tool_button style17'><strong>COMBINATION</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>L</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>W</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>WO</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>WO2</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>Out</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#AAFFAA' class='tool_button style17'><strong>Prod</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#AAFFAA' class='tool_button style17'><strong>Prod 2</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#AAFFAA' class='tool_button style17'><strong>+/-</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='55' bgcolor='#AAFFAA' class='tool_button style17'><strong>% Dif</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='50' bgcolor='#AAFFAA' class='tool_button style17'><strong>M</strong></td>"
  mensaje1=mensaje1&"    <td align='center' width='61' bgcolor='#AAFFAA' class='tool_button style17'><strong>M2</strong></td>"
  mensaje1=mensaje1&"  </tr>"  

    TOTPROD=0
    TOTML=0     
    TOTM2=0
	TOTITEMS=0
    TotDifc22=0
    TotDifc2=0
  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
    TOTPROD3=0
    TOTML2=0
    TOTM22=0
	TOTbad2=0
	TOTjtime2=0  
    TOTdtime2=0
    corr2.movefirst
    'lturno1=Corr2("JOBJO")
    lturno1="1"
    lturno2="1"
    letime2="06:50"
	pqtyant=0
   Do While Not corr2.EOF
     lanterior=0
	 if mid(Corr2("STIME"),1,8)>"220227" then
	  lanterior=1
	 end if
	 ltargetn=0
     if lanterior=1 then
      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   'f
        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                                      'F
	  
      if (mid(Corr2("STIME"),1,8)=fechafinal2) then   'G
	    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                                          'G
	    
	  end if  ''''''''''''Fin de proceso anterior  
       ''''''''''''' Proceso nuevo
       xturnox=Corr2("jobjo")
       lfecha1=corr2("jobymd")
	   
	   if corr2("jobymd")<"220228" then
	   	 if xturnox="A" or xturnox="C" or xturnox="" then
	       xTurno="1"
	     end if
	     if xturnox="B" or xturnox="D" then
	       xTurno="2"
	     end if
	   else
	   	 if xturnox="A" or xturnox="" or xturnox="1" then
	       xTurno="1"
	     end if
	     if xturnox="B" or xturnox="2" then
	       xTurno="2"
	     end if
	     if xturnox="C" or xturnox="3" then
	       xTurno="3"
	     end if
	   end if


     'if lestado=1 then
	   response.write(" lestado1= "&lestado)
        '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
       'lm=int(cdbl(Corr2("Jang"))*(cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))))/cdbl(Corr2("Pokno"))/1000
       'lm2=int((cdbl(Corr2("Jang"))*cdbl(Corr2("WPOK")))*(cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))))/cdbl(Corr2("Pokno"))/1000000
	   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)
	    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)
        lstime=mid(Corr2("stime"),10,5)
        if lstime="" or isnull(lstime) then
		  lstime=mid(Corr2("etime"),10,8)
          lstime=letime2
        end if
		
        if corr2("JOBSEQ")=1 then
         TOTTARGET=TOTTARGET+cdbl(corr2("pQTY"))
         TOTWOc2=TOTWOc2+(cdbl(corr2("pQTY"))*cdbl(corr2("PokNo")))
         TOTTARGET2=TOTTARGET2+cdbl(corr2("pQTY"))
         TOTWO22=TOTWO22+(cdbl(corr2("pQTY"))*cdbl(corr2("PokNo")))
		 pqtyant=cdbl(corr2("pQTY"))
		else
		 if pqtyant>0 and corr2("ROWMOVEKEY")="D" then
          TOTTARGET=TOTTARGET+cdbl(corr2("QTY"))-pqtyant
          TOTWOc2=TOTWOc2+((cdbl(corr2("QTY"))-pqtyant)*cdbl(corr2("PokNo")))
          TOTTARGET2=TOTTARGET2+cdbl(corr2("QTY"))-pqtyant
          TOTWO22=TOTWO22+((cdbl(corr2("QTY"))-pqtyant)*cdbl(corr2("PokNo")))
		  'pqtyant=0
		 else
          TOTTARGET=TOTTARGET+cdbl(corr2("QTY"))
          TOTWOc2=TOTWOc2+(cdbl(corr2("QTY"))*cdbl(corr2("PokNo")))
          TOTTARGET2=TOTTARGET2+cdbl(corr2("QTY"))
          TOTWO22=TOTWO22+(cdbl(corr2("QTY"))*cdbl(corr2("PokNo")))
		 end if
		end if 
		
		'lstime=mid(Corr2("etime"),10,8)
        letime=mid(Corr2("etime"),10,5)
 	    mensaje1=mensaje1&"  <tr>"
	    mensaje1=mensaje1&"    <td align='center' class='xl68'>"& corr2("JOBJO")&" </td>"
        mensaje1=mensaje1&"    <td class='xl67' width='80'>"&lstime&" "&letime&"</td>"
        mensaje1=mensaje1&"	  <td class='xl68'>"& left(corr2("CUST"),10)&"</td>"
        mensaje1=mensaje1&"    <td class='xl68'>"& left(corr2("BOXName"),10)&" </td>"
        mensaje1=mensaje1&"    <td class='xl68'>"& corr2("SUJUNO")&" </td>"
        mensaje1=mensaje1&"    <td align='center' class='xl68'>"& corr2("BEHAP")&" </td>"
        mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("JANG")&" </td>"
        mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("WPOK")&" </td>"
		if corr2("JOBSEQ")=1 then
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("PQTY")&" </td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& int(cdbl(corr2("PQTY"))*cdbl(corr2("PokNo")))&"</td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("PokNo")&" </td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))&" </td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& (cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY")))*corr2("PokNo")&" </td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("PQTY"))&" </td>"
         mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber(((cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("PQTY")))/cdbl(corr2("PQTY")))*100,1)&" % </td>"
		 ltargetn=cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("PQTY"))
		else
		 if pqtyant>0 and corr2("ROWMOVEKEY")="D" then
	      mensaje1=mensaje1&"    <td class='xl68' align='right'>"& int(cdbl(corr2("QTY"))-cdbl(pqtyant))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& int((cdbl(corr2("QTY"))-cdbl(pqtyant))*cdbl(corr2("PokNo")))&"</td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("PokNo")&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& (cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY")))*cdbl(corr2("PokNo"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-(cdbl(corr2("QTY"))-cdbl(pqtyant))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'> 0 </td>"
		   ltargetn=cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-(cdbl(corr2("QTY"))-cdbl(pqtyant))
		   pqtyant=0
		 else
	      mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(corr2("QTY"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& int(cdbl(corr2("QTY"))*cdbl(corr2("PokNo")))&"</td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& corr2("PokNo")&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& (cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY")))*cdbl(corr2("PokNo"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("QTY"))&" </td>"
          mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber(((cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("QTY")))/cdbl(corr2("QTY")))*100,1)&" % </td>"
		  ltargetn=cdbl(Corr2("PQTY"))-cdbl(Corr2("PREPQTY"))-cdbl(corr2("QTY"))
		 end if
	
		end if
        mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber(lm,0)&" </td>"
        mensaje1=mensaje1&"    <td class='xl68' align='right'>"& formatnumber(lm2,0) &"</td>"
        mensaje1=mensaje1&"  </tr>"	
		totsh=corr2("JOBJO")
		
		
         TOTPROD=TOTPROD+cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY"))
         TOTPRODq=TOTPRODq+((cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY")))*cdbl(corr2("PokNo")))
		 TotDifc2=TotDifc2+cdbl(ltargetn)
		 TotDifc22=TotDifc22+cdbl(ltargetn)
		 
         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"))
         TOTPROD2=TOTPROD2+cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY"))
         TOTPROD3=TOTPROD3+((cdbl(corr2("PQTY"))-cdbl(Corr2("PREPQTY")))*cdbl(corr2("PokNo")))
         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                                          'J
           if lanterior=1 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
           end if
		   
 	       if corr2("jobjo")="A" or corr2("jobjo")="C" then
 	        lturno2="1"
	       end if
	       if corr2("jobjo")="B" or corr2("jobjo")="D" then
	        lturno2="2"
	       end if
		   if corr2("jobymd")<"220228" then
	         if corr2("jobjo")="A" or corr2("jobjo")="C" then
	          lturno2="1"
	         end if
	         if corr2("jobjo")="B" or corr2("jobjo")="D" then
	          lturno2="2"
	         end if
	       else
	   	     if corr2("jobjo")="1" then
	          lturno2="1"
	         end if
	         if corr2("jobjo")="2" then
	          lturno2="2"
	         end if
	         if corr2("jobjo")="3" then
	          lturno2="3"
	         end if
           end if
           lfecha2=corr2("jobymd")
         end if	                                            'J
  
        if Corr2.eof or lturno1<>lturno2 or lfecha1<>lfecha2 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)
	        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)
	       if lturno1="1" then
	        lshift=xturnox
	       end if
	       if lturno1="2" then
	        lshift=xturnox
	       end if

	        mensaje1=mensaje1&"  <tr>"
            mensaje1=mensaje1&"    <td class='xl67'>&nbsp;</td>"
            mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>Total Shift "& totsh &"</strong></td>"
            mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>AVG Speed</strong></td>"
            mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(lspeedtot2,0) &"</strong></td>"
            mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
            mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
            mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(TOTTarget2,0) &"</strong></td>"
            mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(TOTWO22,0) &"</strong></td>"
            mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
            mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD2,0)&"</strong></DIV></td>"
            mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD3,0)&"</strong></DIV></td>"
            mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TotDifc22,0)&"</strong></DIV></td>"
            mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
            mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML2,0) &"</strong></DIV></td>"
            mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM22,0) &"</strong></DIV></td>"
            mensaje1=mensaje1&"  </tr>"
		    if totsh="1" then
     set rsactprod=dbsql3.execute("update datagraph set c2s1lm="& TOTML2 &",c2s1m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=1
    end if
    if totsh="2" then
     set rsactprod=dbsql3.execute("update datagraph set c2s2lm="& TOTML2 &",c2s2m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=2
    end if
    if totsh="3" then
     set rsactprod=dbsql3.execute("update datagraph set c2s3lm="& TOTML2 &",c2s3m2="& TOTM22 &" where fecha="&actfecha&" and areaprod='C1'")
     set rsactprod= nothing
     xactualizado=2
    end if
	
			
	        lturno1=lturno2
	        TOTTARGET2=0
	      TOTTARGET2q=0
          TOTPROD2q=0
	        TOTWO22=0
            TOTPROD2=0
			TotDifc22=0
            TOTPROD3=0
            TOTML2=0
            TOTM22=0
	        TOTbad2=0
	        TOTjtime2=0
            TOTdtime2=0
            lfecha1=lfecha2
          end if
        end if
	 'else
	 '	   response.write(" lestado0= "&lestado)
	 ' CORR2.MoveNext
     'end if 
         letime2=letime
   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)

   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)
   
    mensaje1=mensaje1&"  <tr>"
    mensaje1=mensaje1&"    <td class='xl67'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td colspan='2' class='xl68'><strong>TOTAL </strong></td>"
    mensaje1=mensaje1&"    <td colspan='2' align='right' class='xl68'><strong>"& formatnumber(TOTITEMS,0) &"</strong></td>"
    mensaje1=mensaje1&"    <td class='xl68'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(TOTTarget,0) &"</strong></td>"
    mensaje1=mensaje1&"    <td align='right' class='xl68'><strong>"& formatnumber(TOTWOc2,0) &"</strong></td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPROD,0)&"</strong></DIV></td>"
    mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTPRODq,0)&"</strong></DIV></td>"
    mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TotDifc2,0)&"</strong></DIV></td>"
    mensaje1=mensaje1&"    <td class='xl68' align='right'>&nbsp;</td>"
    mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTML,0) &"</strong></DIV></td>"
    mensaje1=mensaje1&"    <td align='right' bgcolor='#D2D2D2' class='xl68'><div align='right' class=style15><strong>"&FORMATNUMBER(TOTM2,0) &"</strong></DIV></td>"
    mensaje1=mensaje1&"  </tr>"
  end if

  mensaje1=mensaje1&"</TABLE>"
 
 End if
    comillas=chr(34)
    mensaje1=mensaje1&"<br><br>"
    mensaje1=mensaje1&"<a href="& comillas &"http://192.168.0.196:81/resultgraphtrans.asp"& comillas &">View Graphic (intranet)</a><br><br>"
    mensaje1=mensaje1&"<a href="& comillas &"http://201.140.172.134:81/resultgraphtrans.asp"& comillas &">View Graphic (Outside Sinil/mobile phone)</a>"
    mensaje1=mensaje1&"<br><br>"

'''''''''''''''''************************ corr 2 fin
 end if  'minutos

End If   ' licencia expirada

 response.write(mensaje1)
 
 If Err.Number <> 0 then
  HandleError Err.Description
 End If

 Sub HandleError
   response.write("No DATE created")
 End Sub
  if minactual>50 and minactual<56 then                    '       ********** minuto 50

'*********************
 correo="ilkim@shinwoousa.com"
'correo="sistemas@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)="Sheko*2019*"
  '.Item(cdoSMTPServerport)=587
  .Item(cdoSMTPServerport)= 465
  .Item(cdoSMTPusessl)= 1
  .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 ="bruno.kim@shinwoousa.com;avaldez@shinwoousa.com;sgallegos@shinwoousa.com;jsyc300@shinwoousa.com;vincent.shin@shinwoousa.com;asaldana@shinwoousa.com;lramirez@shinwoousa.com;planning3@shinwoousa.com;planeacion2@shinwoousa.com;rgarcia@shinwoousa.com"
	.bcc = "sistemas@shinwoousa.com"
    .Subject = "sending Automatic - Corr I, II 3s"
    .HTMLBody = mensaje1
    '.AddAttachment (archivopdf)
    '.AddAttachment (archivoxml)
    .Send
  End With
   
  Set cdoMessage = Nothing
  Set cdoConfig = Nothing
  ''termina envio de correo
  end if
'response.Redirect("reportdailytransfer.asp?msg=enviado!")
%>

</center>
</div>
</body>
</html>
<%

Rsfore0.Close
Set Rsfore0 = Nothing
'''''''''''''

%>