<%@ LANGUAGE = "VBScript" %> <% 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") cmes=Request.Form("cmes") canno=Request.Form("canno") if cmes="" then cmes=month(date) canno=year(date) end if criterio22=Request.Form("criterio22") if criterio22="" then xcriterio22=" Todos " end if lspace=" " apostrofe="'" if Date_ini="" or Date_ini=null then Date_ini=date()-(day(date()))+1 Date_end=date() end if '''''''''''calcula layer=weekday(date()-1) If layer = 1 Then Date_ini=date()-3 Date_end=date()-3 else if layer=7 then Date_ini=date()-2 Date_end=date()-2 else Date_ini=date()-1 Date_end=date()-1 end if end if strday = Right("00" & Day(Date_ini), 2) strmonth = Right("00" & Month(Date_ini), 2) stryear = Right("00" & (Year(Date_ini) - 1), 4) strday2 = Right("00" & Day(Date_end), 2) strmonth2 = Right("00" & Month(Date_end), 2) stryear2 = Right("00" & (Year(Date_end) - 1), 4) fechainicial2 = Cstr(stryear + strmonth + strday) fechafinal2 = Cstr(stryear2 + strmonth2 + strday2) lperiod1 = stryear & "-" & strmonth & "-" & strday lperiod2 = stryear2 & "-" & strmonth2 & "-" & strday2 period1 = lperiod1 period2 = lperiod2 '************** Transfer strday = Right("00" & Day(date), 2) strmonth = Right("00" & Month(date), 2) stryear = Right("00" & Year(date), 4) strday2 = Right("00" & Day(date+1), 2) strmonth2 = Right("00" & Month(date)+1, 2) stryear2 = Right("00" & Year(date+1), 4) lmonth = Month(Date)-1 'lmonth =4 If lmonth = 1 Or lmonth = 3 Or lmonth = 5 Or lmonth = 7 Or lmonth = 8 Or lmonth = 10 Or lmonth = 0 Then ldiasmes = 31 End If If lmonth = 2 Then ldiasmes = 29 End If If lmonth = 4 Or lmonth = 6 Or lmonth = 9 Or lmonth = 11 Then ldiasmes = 30 End If lmonth1 = Month(Date) 'lmonth1 = 5 If lmonth1 = 1 Or lmonth1 = 3 Or lmonth1 = 5 Or lmonth1 = 7 Or lmonth1 = 8 Or lmonth1 = 10 Or lmonth1 = 12 Then ldiasmes1 = 31 End If If lmonth1 = 2 Then ldiasmes1 = 29 End If If lmonth1 = 4 Or lmonth1 = 6 Or lmonth1 = 9 Or lmonth1 = 11 Then ldiasmes1 = 30 End If strmesini = Right("00" & lmonth, 2) strday2 = Right("00" & ldiasmes, 2) lfecinicio= CStr(canno & strmonth & "01") lfecfinal= CStr(canno & strmonth & strday) lfecinicial=CStr(right("00"&year(date),4)+right("00"&month(date),2) + "01") 'lfecinicio 'lfecfinal 'Set rsvende = Server.CreateObject("ADODB.RecordSet") xtipo="VENDEDOR" 'rsvende.CursorType = adOpenDynamic 'set rsvende=dbsql.execute("SELECT major_cd, minor_cd, code_nm FROM sta010t WHERE (((major_cd)='9001')) ORDER BY minor_cd") %> Report FG List
       
Period:  
         
<% header if busca="" or busca=null then origen=doc end if d="/" ctipomov1="FACTURA" ctipomov2="REMISION" sla="/" cero1="00" cero2="0000" 'lfecinicio= "20160501" 'lfecfinal= "20160601" 'lfecinicial="20160501" response.write("FROM: "&lfecinicial&" ") 'response.write(lfecinicio&" ") response.write("TO: "&lfecfinal&"
") ReDim SalesDias(ldiasmes1,40) ReDim Trucking(ldiasmes1,5) Dim Rstrans Dim sqltrans 'set Rstrans=dbsql.execute("select b.local_cd, (select code_nm from sta010t(nolock) where major_cd = '9016' and minor_cd = b.local_cd) local_nm, right(a.real_trans ,6) trans_date,b.cust_cd, (select cust_nm from stb010t(nolock) where cust_cd = b.cust_cd) cust_nm, b.item, b.ord_no, a.pallet_cnt, b.qty prod_qty, b.price, c.mae_m2, round(b.qty * b.price,3) prod_amt, round(c.mae_m2 * b.qty,0) prod_m2, (select code_nm from sta010t(nolock) where major_cd = '2004' and minor_cd = a.trans_class) work_gubun, case isnull(b.loc_no,'') when '' then '' else (select code_nm from sta010t(nolock) where major_cd = '9160' and minor_cd = b.loc_no) end loc_no, a.trans_time, right(a.prt_date,6) prt_day,d.item_class, 1 cnt from bar_code a(nolock), inout_table b(nolock), boa010t c(nolock), stb040t d(nolock) where a.bar_code = b.bar_code and b.class = '1' and b.prod_flag = '1' and a.chk_bit = '1' and a.crp_id = '10' and b.local_cd like '%' and a.goods_class = c.goods_class and a.ord_date = c.ord_date and a.ord_seq = c.ord_seq and c.cust_cd = d.cust_cd and c.good_cd = d.good_cd and a.real_trans between '" & lfecinicio & "' and '" & lfecfinal & "' and b.cust_cd like '%' and b.item like '%' and a.trans_class like '%' and b.loc_no like '%' and d.item_class like '%' order by a.real_trans , a.trans_time, b.cust_cd, b.item, b.ord_no,b.local_cd, a.trans_class, case when a.trans_date <> a.real_trans then '1' else '0' end , a.pallet_cnt") set Rstrans=dbsql.execute("select a.cust_cd, max(b.cust_nm) cust_nm, max(a.good_nm) item, sum(case a.local_cd when '1' then a.sales_qty else 0 end ) qty1, sum(case a.local_cd when '1' then a.sales_amt else 0 end ) amt1, sum(case a.local_cd when '2' then a.sales_qty else 0 end ) qty2, sum(case a.local_cd when '2' then a.sales_amt else 0 end ) amt2, sum(case a.local_cd when '3' then a.sales_qty else 0 end ) qty3, sum(case a.local_cd when '3' then a.sales_amt else 0 end ) amt3, sum(case a.local_cd when '4' then a.sales_qty else 0 end ) qty4, sum(case a.local_cd when '4' then a.sales_amt else 0 end ) amt4, sum(a.sales_qty) sales_qty, sum(a.sales_amt) sales_amt, (a.good_date) sales_date from sal020t a(nolock), stb010t b(nolock), stb040t c(nolock) where a.cust_cd = b.cust_cd and a.cust_cd = c.cust_cd and a.good_cd = c.good_cd and a.crp_id = '10' and a.good_date between '" & lfecinicio & "' and '" & lfecfinal & "' and a.cust_cd like '%' and b.sale_cd like '%' and a.local_cd like '%' and (a.sales_class like '1' or a.sales_class like '6') and a.po_no like '%' and a.pack_no like '%' and a.good_nm like '%' and a.chk_tit like '%' and c.item_class like '%' group by a.good_date,a.cust_cd, a.good_nm order by a.good_date,a.cust_cd, a.good_nm ") If Rstrans.EOF And Rstrans.BOF Then response.write("No existen datos") ExisteUsuario = False Msg = "No records exist for this date." Style = vbDefaultButton2 Title = "Msg from System" Help = "" ctxt = 1000 'Response = MsgBox(Msg, Style, Title, Help, ctxt) Else lsamsungqty=0 lsamq1=0 lsamq2=0 lsammt1=0 lsammt2=0 lsama1=0 lsama2=0 lsamsungqty1s=0 lsamsungqty2s=0 lsamsungqty3s=0 lsamsungqty4s=0 lsamsungm2=0 lsamsungm21s=0 lsamsungm22s=0 lsamsungm23s=0 lsamsungm24s=0 lsamsungamt=0 lotherqty=0 lotherm2=0 lotheramt=0 lTotalQty = 0 lTotalM2 = 0 lTotalAmt =0 lOBxQty=0 lOBxM2=0 lOBxAmt=0 lqty12=0 lqty2s=0 lqty3s=0 lm21s=0 lm22s=0 lm23s=0 lsamvb=0 lOTsamsungqty=0 lsamfull=0 lsamsunginbqty=0 lsamprint=0 lsamspot=0 ltop5qty=0 %> <% Rstrans.MoveFirst ltransdate1=Rstrans("sales_date") 'ltranstime1=Rstrans("trans_time") lcte=0 'response.write("hora: "&Rstrans("trans_time")) Do While Not Rstrans.EOF %> <% lTotalQty = lTotalQty+ cdbl(Rstrans("sales_qty")) 'litemclass="00" 'litemclass=Rstrans("item_class") 'response.write(" Cte "& Rstrans("cust_cd")) if Rstrans("cust_cd")="20001" then 'CTE lcte=1 lsamsungqty=lsamsungqty+ cdbl(Rstrans("sales_qty")) lsamsungm2= lsamsungm2+ cdbl(localm2) 'lsamsungamt= lsamsungamt+ cdbl(Rstrans("amt1")) if litemclass="03" then lsamvb=lsamvb+ cdbl(Rstrans("sales_qty")) else ''''''''''''''''''''********* O/B SAMSUNG set Rsinven2=cnn.execute("select * from SamsungItems where good_nm='" & Rstrans("item") & "'") if not Rsinven2.eof then 'RS rsinven2.movefirst ltypeBox=rsinven2("Note_4") ltypeBox2=rsinven2("Note_5") 'response.write(" typeBox "& rsinven2("Note_5")) if rsinven2("Note_5")= "INBOX / PAD" or rsinven2("Note_5")= "NA" or rsinven2("Note_5")= "FULL LITHO" or rsinven2("Note_5")= "PRINTING" or rsinven2("Note_5")= "SPOT" then if rsinven2("Note_5")= "INBOX / PAD" then 'PAD lSamsunginbqty = lSamsunginbqty + cdbl(Rstrans("sales_qty")) end if if rsinven2("Note_5")= "NA" then 'PAD lOTSamsungqty = lOTSamsungqty + cdbl(Rstrans("sales_qty")) 'litemx=rsinven2("Note_5")&"ot" end if if rsinven2("Note_5")= "FULL LITHO" then lSamfull = lSamfull + cdbl(Rstrans("sales_qty")) END IF if rsinven2("Note_5")= "PRINTING" then lSamprint = lSamprint + cdbl(Rstrans("sales_qty")) END IF if rsinven2("Note_5")= "SPOT" then lSamspot = lSamspot + cdbl(Rstrans("sales_qty")) end if else lOTSamsungqty = lOTSamsungqty + cdbl(Rstrans("sales_qty")) end if 'PAD else lOTSamsungqty = lOTSamsungqty + cdbl(Rstrans("sales_qty")) litemx="no" end if 'RS Rsinven2.Close Set Rsinven2 = Nothing '''''''''''''''''''''*********O/B SAMSUNG end if else if Rstrans("cust_cd")="20029" or Rstrans("cust_cd")="20240" or Rstrans("cust_cd")="20058" or Rstrans("cust_cd")="20558" or Rstrans("cust_cd")="20555" or Rstrans("cust_cd")="20564" then ltop5qty= ltop5qty+ cdbl(Rstrans("sales_qty")) else lotherqty= lotherqty+ cdbl(Rstrans("sales_qty")) end if litemx="No samsung" end if 'CTE 'response.write(" Qty "& Rstrans("sales_qty")) ltotwh1 = ltotwh1 + cdbl(Rstrans("qty1")) ltotwh2 = ltotwh2 + cdbl(Rstrans("qty2")) ltotwh3 = ltotwh3 + cdbl(Rstrans("qty3")) ltotwh4 = ltotwh4 + cdbl(Rstrans("qty4")) Rstrans.MoveNext if not Rstrans.eof then ltransdate2=Rstrans("sales_date") 'ltranstime2=Rstrans("trans_time") end if if (ltransdate1<>ltransdate2 ) or Rstrans.eof then xdia=int(right(ltransdate1,2)) SalesDias(xdia,0)=xdia SalesDias(xdia,1)=lsamsungqty SalesDias(xdia,2)=lsamsungm2 SalesDias(xdia,3)=lsamsungamt SalesDias(xdia,4)=lotherqty SalesDias(xdia,5)=lotherm2 SalesDias(xdia,6)=lotheramt SalesDias(xdia,7)=lTotalQty 'SalesDias(xdia,8)=lTotalM2 SalesDias(xdia,9)=lTotalAmt SalesDias(xdia,10)=lsamfull SalesDias(xdia,11)=lsamsunginbqty SalesDias(xdia,12)=lsamprint SalesDias(xdia,13)=lsamspot SalesDias(xdia,14)=ltop5qty SalesDias(xdia,15)=lm23s+lm24s SalesDias(xdia,21)=lsamvb SalesDias(xdia,22)=lOTsamsungqty lsamsungqty=0 lsamsungm2=0 lsamsungamt=0 lqty1s=0 lqty2s=0 lqty3s=0 lqty4s=0 lm2=0 lm21s=0 lm22s=0 lm23s=0 lm24s=0 lgamt=0 lotherqty=0 lotherm2=0 lotheramt=0 lTotalQty = 0 lTotalM2 = 0 lTotalAmt =0 ltransdate1=ltransdate2 lsamvb=0 lOTsamsungqty=0 lsamq2=0 lsammt1=0 lsammt2=0 lsama1=0 lsama2=0 lOBxqty=0 lOBxM2=0 lOBxAmt=0 lOBxqtybd3=0 lOBxprodbd1=0 lOBxprodbd3=0 lsamfull=0 lsamsunginbqty=0 lsamprint=0 lsamspot=0 ltop5qty=0 else end if 'end if Loop End If %>
Date: Cte Item WH1   WH2   WH3   WH4   Totay Qty
<%=Rstrans("sales_date") %> <%=Rstrans("cust_cd") %> <%=Rstrans("item") %> <%=Rstrans("qty1")%>   <%=Rstrans("qty2")%>   <%=Rstrans("qty3")%>   <%=Rstrans("qty4")%>   <%=Rstrans("sales_qty")%>
      <%=ltotwh1%>   <%=ltotwh2%>   <%=ltotwh3%>   <%=ltotwh4%>   <%=(ltotwh1+ltotwh2+ltotwh3+ltotwh4)%>
<% Rstrans.Close Set Rstrans = Nothing 'Rsprod.Close ' Set Rsprod = Nothing dbsql.Close Set dbsql = Nothing dbsql2.Close Set dbsql2 = Nothing dbsql3.Close Set dbsql3 = Nothing %>
Sales Sumary List (by day) <% xnumerodias=0 for i=lbound(SalesDias) to ubound(SalesDias) %> <% if SalesDias(i,0)>0 then xnumerodias=xnumerodias+1 end if next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamprint=xtotsamprint+SalesDias(i,12) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamspot=xtotsamspot+SalesDias(i,13) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamfull=xtotsamfull+SalesDias(i,10) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamob=xtotsamob+SalesDias(i,13)+SalesDias(i,12)+SalesDias(i,10) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsaminb=xtotsaminb+SalesDias(i,11) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamot=xtotsamot+SalesDias(i,21)+SalesDias(i,22) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotsamfg=xtotsamfg+SalesDias(i,21)+SalesDias(i,22)+SalesDias(i,13)+SalesDias(i,12)+SalesDias(i,11)+SalesDias(i,10) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotaltop5=xtotaltop5+SalesDias(i,14) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotalothqty=xtotalothqty+SalesDias(i,4) next %> <% for i=lbound(SalesDias) to ubound(SalesDias) %> <% xtotalqty=xtotalqty+SalesDias(i,7) next %>
<%=MonthName(Month(Date), False)%> <%=time()%> QTY
<%=SalesDias(i,0)%>
TOTAL
%
SAMSUNG
Out Box (printing) Sales
<%=formatnumber(SalesDias(i,12),0)%>
<%=formatnumber(xtotsamprint,0)%>
<%=formatnumber(xtotsamprint/xnumerodias,0)%>
Spot Label Sales
<%=formatnumber(SalesDias(i,13),0)%>
<%=formatnumber(xtotsamspot,0)%>
<%=formatnumber(xtotsamspot/xnumerodias,0)%>
Full Litho Sales
<%=formatnumber(SalesDias(i,10),0)%>
<%=formatnumber(xtotsamfull,0)%>
<%=formatnumber(xtotsamfull/xnumerodias,0)%>
OB Total Sales
<%=formatnumber(SalesDias(i,13)+SalesDias(i,12)+SalesDias(i,10),0)%>
<%=formatnumber(xtotsamob,0)%>
<%=formatnumber(xtotsamob/xnumerodias,0)%>
   
   
Inbox Sales
<%=formatnumber(SalesDias(i,11),0)%>
<%=formatnumber(xtotsaminb,0)%>
<%=formatnumber(xtotsaminb/xnumerodias,0)%>
Samsung VB / Others Sales
<%=formatnumber(SalesDias(i,21)+SalesDias(i,22),0)%>
<%=formatnumber(xtotsamot,0)%>
<%=formatnumber(xtotsamot/xnumerodias,0)%>
TOTAL Sales
<%=formatnumber(SalesDias(i,21)+SalesDias(i,22)+SalesDias(i,13)+SalesDias(i,12)+SalesDias(i,11)+SalesDias(i,10),0)%>
<%=formatnumber(xtotsamfg,0)%>
<%=formatnumber(xtotsamfg/xnumerodias,0)%>

Top 5

JBL, DJO, Stephen Gould, BOSE, Plantronics

Sales
<%=formatnumber(SalesDias(i,14),0)%>
<%=formatnumber(xtotaltop5,0)%>
<%=formatnumber(xtotaltop5/xnumerodias,0)%>
OthersOthers QTY Sales
<%=formatnumber(SalesDias(i,4),0)%>
<%=formatnumber(xtotalothqty,0)%>
<%=formatnumber(xtotalothqty/xnumerodias,0)%>
TOTAL Sales
<%=formatnumber(SalesDias(i,7),0)%>
<%=formatnumber(xtotalqty,0)%>
<%=formatnumber(xtotalqty/xnumerodias,0)%>