<%@ LANGUAGE = "VBScript" %> <% busca=request.QueryString("busca") doc=request.QueryString("doc") origen=request.QueryString("origen") Date_ini=Request.QueryString("Date_ini") Date_end=Request.QueryString("Date_end") campo=Request.QueryString("campo") if campo="" or campo=null then campo=1 end if if Date_ini="" or Date_ini=null then Date_ini=date()-1 Date_end=date() end if 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_end),2) mes2=right("00"&month(Date_end),2) anno2=right("00"&year(Date_end),4) 'cfechaf=cdate((dia2+"/"+mes2+"/"+anno2)) cfechaf=cdbl(anno2+mes2+dia2) %> <% Response.Buffer = TRUE Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "content-disposition", "inline; filename=ListaCompras"&date()&".xls" %> Reporte Compras Offset
<% 'response.write(" Inicio : "&date_ini) 'response.write("Fin : "&date_fin) 'response.write(" filtro : "&campo) %>
<% if busca="ok" then 'response.write("FROM: "&cfechai&" ") 'response.write("TO: "&cfechaf&"
") if campo=1 then set Rscompras=dbsql2.execute("select a.crp_id, a.bal_date, a.bal_seq, a.bal_sub, a.code,(select cust_nm from stb010t where cust_cd = (a.cust_cd) ) cust_nm, b.desc_note, a.bal_qty, a.nap_date, a.po_no, a1.po_no re_no, a1.ipgo_date, isnull(a1.ipgo_qty,0.00) ipgo_qty, a2.po_no out_no, a2.chul_date, isnull(a2.chul_qty,0.00) chul_qty from mab020t a(nolock) left outer join (select crp_id, bal_date, bal_seq, bal_sub, sum(ipgo_qty) ipgo_qty, max(substring(ipgo_date,5,2) + substring(ipgo_date,7,2) + substring(ipgo_date,1,4)) ipgo_date, max(po_no) po_no from mab030t a1(nolock) group by crp_id, bal_date, bal_seq, bal_sub) a1 on a.crp_id = a1.crp_id and a.bal_date = a1.bal_date and a.bal_seq = a1.bal_seq and a.bal_sub = a1.bal_sub left outer join mab040t a2(nolock) on a.crp_id = a2.crp_id and a.bal_date = a2.bal_date and a.bal_seq = a2.bal_seq and a.bal_sub = a2.bal_sub, mab010t b(nolock) where a.code = b.code and a.crp_id = '10' and a.bal_date between '" & cfechai & "' and '" & cfechaf & "' order by a.po_no, a.bal_date, a.bal_seq, a.bal_sub") end if if campo=2 then set Rscompras=dbsql2.execute("select a.crp_id, a.bal_date, a.bal_seq, a.bal_sub, a.code,(select cust_nm from stb010t where cust_cd = (a.cust_cd) ) cust_nm, b.desc_note, a.bal_qty, a.nap_date, a.po_no, a1.po_no re_no, a1.ipgo_date, isnull(a1.ipgo_qty,0.00) ipgo_qty, a2.po_no out_no, a2.chul_date, isnull(a2.chul_qty,0.00) chul_qty from mab020t a(nolock) left outer join (select crp_id, bal_date, bal_seq, bal_sub, sum(ipgo_qty) ipgo_qty, max(substring(ipgo_date,5,2) + substring(ipgo_date,7,2) + substring(ipgo_date,1,4)) ipgo_date, max(po_no) po_no from mab030t a1(nolock) group by crp_id, bal_date, bal_seq, bal_sub) a1 on a.crp_id = a1.crp_id and a.bal_date = a1.bal_date and a.bal_seq = a1.bal_seq and a.bal_sub = a1.bal_sub left outer join mab040t a2(nolock) on a.crp_id = a2.crp_id and a.bal_date = a2.bal_date and a.bal_seq = a2.bal_seq and a.bal_sub = a2.bal_sub, mab010t b(nolock) where a.code = b.code and a.crp_id = '10' and a.bal_date between '" & cfechai & "' and '" & cfechaf & "' and (isnull(a1.ipgo_qty,0.00)-a.bal_qty)>=0 order by a.po_no, a.bal_date, a.bal_seq, a.bal_sub") end if if campo=3 then set Rscompras=dbsql2.execute("select a.crp_id, a.bal_date, a.bal_seq, a.bal_sub, a.code,(select cust_nm from stb010t where cust_cd = (a.cust_cd) ) cust_nm, b.desc_note, a.bal_qty, a.nap_date, a.po_no, a1.po_no re_no, a1.ipgo_date, isnull(a1.ipgo_qty,0.00) ipgo_qty, a2.po_no out_no, a2.chul_date, isnull(a2.chul_qty,0.00) chul_qty from mab020t a(nolock) left outer join (select crp_id, bal_date, bal_seq, bal_sub, sum(ipgo_qty) ipgo_qty, max(substring(ipgo_date,5,2) + substring(ipgo_date,7,2) + substring(ipgo_date,1,4)) ipgo_date, max(po_no) po_no from mab030t a1(nolock) group by crp_id, bal_date, bal_seq, bal_sub) a1 on a.crp_id = a1.crp_id and a.bal_date = a1.bal_date and a.bal_seq = a1.bal_seq and a.bal_sub = a1.bal_sub left outer join mab040t a2(nolock) on a.crp_id = a2.crp_id and a.bal_date = a2.bal_date and a.bal_seq = a2.bal_seq and a.bal_sub = a2.bal_sub, mab010t b(nolock) where a.code = b.code and a.crp_id = '10' and a.bal_date between '" & cfechai & "' and '" & cfechaf & "' and (isnull(a1.ipgo_qty,0.00)-a.bal_qty)<0 order by a.po_no, a.bal_date, a.bal_seq, a.bal_sub") end if nitem=0 If not Rscompras.EOF Then Rscompras.movefirst 'response.write("TO: 2") Do While Not Rscompras.EOF if isnumeric(Rscompras("bal_qty")) then cbalqty=Rscompras("bal_qty") else cbalqty=0 end if %> <% if cint(Rscompras("ipgo_qty"))-cbalqty=0 then lfondo="#DFFFDF" end if if cint(Rscompras("ipgo_qty"))-cbalqty>0 then lfondo="#FFDBB7" end if if cint(Rscompras("ipgo_qty"))-cbalqty<0 then lfondo="#FFDBDB" end if %> <% nitem=nitem+1 rscompras.movenext Loop end if Rscompras.close end if %>
Purchase VS Receiving report (Offset)
P/O Vendor Description Date QTY In Date Re No In Qty Balance
<%=Rscompras("po_no")%> <%=Rscompras("cust_nm")%> <%=Rscompras("desc_note")%> <%=Rscompras("bal_date")%> <%=Rscompras("bal_qty")%> <%=Rscompras("ipgo_date")%> <%=Rscompras("re_no")%> <%=Rscompras("ipgo_qty")%><%=cint(Rscompras("ipgo_qty"))-cbalqty%>
Total: <%=nitem%>