<%@ 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 (x)
<% '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&"
") nreq="%" nmoneda="%" set Rscompras=dbsql.execute("select a.crp_id, a.bal_date, right(a.bal_date,6) bal_day, a.jaje_seq, a.bal_seq, a.bal_sub, (select cust_nm from stb010t where cust_cd = a.cust_cd ) cust_nm, c.jaje_nm, c.jaje_danwi, a.cust_cd, a.bal_qty, a.nap_date, a.bal_price, a.bal_amt, a.bal_kind, case a.money_chk when '1' then 'Dollar' when '2' then 'Peso' end money_chk, a.po_no, a.terms, a.attn, a.note1, a.note2, a.user_nm, a.prt_chk, a.ship_cust, a.ship_addr1, a.ship_addr2, a.ship_addr3, a.ship_tel, a.ship_fax, a.vat_class, b.ipgo_qty, b.ipgo_date, (select code_nm from sta010t(nolock) where major_cd = '9020' and minor_cd = a.class) class, case c.jaje_kind when '' then '' else (select code_nm from sta010t where major_cd = '9200' and minor_cd = c.jaje_kind) end jaje_kind_nm, case c.proc_cd when '' then '' else (select code_nm from sta010t where major_cd = '9300' and minor_cd = c.proc_cd) end proc_nm, a.r_no1, a.r_no2, a.r_no3, substring(a.req_indate,5,2) + substring(a.req_indate,7,2) + substring(a.req_indate,1,4) req_indate from mtd011t a(nolock) left outer join ( select crp_id, bal_Date, bal_seq, bal_sub, po_no, ipgo_qty, ipgo_date from mtd020t(nolock) ) b on a.crp_id = b.crp_id and a.bal_date = b.bal_date and a.bal_seq = b.bal_seq and a.bal_sub = b.bal_sub and a.po_no = b.po_no, mtd010t c(nolock) where a.jaje_seq = c.jaje_seq and a.bal_date between '" & cfechai & "' and '" & cfechaf & "' and a.cust_cd like '%' and a.po_no like '%' and a.jaje_seq like '%' and c.jaje_kind like '%' and isnull(c.proc_cd,'000') like '%' and (a.r_no1 like '%' or a.r_no2 like '%' or a.r_no3 like '%') and a.money_chk like '%' and a.prt_chk like '%' order by a.bal_date, a.bal_seq, a.bal_sub ") npo2="" nitem=0 If not Rscompras.EOF Then Rscompras.movefirst 'response.write("TO: 2") Do While Not Rscompras.EOF npo1=(Rscompras("po_no")&Rscompras("jaje_seq")&Rscompras("bal_sub")) if isnull(Rscompras("bal_qty")) then cbalqty=0 else cbalqty=cint(Rscompras("bal_qty")) end if if isnull(Rscompras("ipgo_qty")) then cipgoqty=0 else if isnumeric(Rscompras("ipgo_qty")) then cipgoqty =cdbl(Rscompras("ipgo_qty")) end if end if if (cipgoqty-cbalqty)=0 then lfondo="#DFFFDF" end if if (cipgoqty-cbalqty)>0 then lfondo="#FFDBB7" end if if (cipgoqty-cbalqty)<0 then lfondo="#FFDBDB" end if 'if npo1<>npo2 then %> <% lfechapo=(mid(Rscompras("bal_day"),3,2)&"/"&mid(Rscompras("bal_day"),5,2)&"/"&"20"&mid(Rscompras("bal_day"),1,2)) %> <% lfechadel=(mid(Rscompras("nap_date"),1,2)&"/"&mid(Rscompras("nap_date"),3,2)&"/"&mid(Rscompras("nap_date"),5,4)) %> <% lfechareq=(mid(Rscompras("req_indate"),1,2)&"/"&mid(Rscompras("req_indate"),3,2)&"/"&mid(Rscompras("req_indate"),5,4)) %> <% do while (Rscompras("po_no")&Rscompras("jaje_seq")&Rscompras("bal_sub"))=npo1 if not isnull(Rscompras("ipgo_date")) then lfecharec=(mid(Rscompras("ipgo_date"),5,2)&"/"&mid(Rscompras("ipgo_date"),7,2)&"/"&mid(Rscompras("ipgo_date"),1,4)) else lfecharec="" end if %> <% rscompras.movenext if rscompras.eof then exit do end if loop %> <% 'else %> <% 'end if nitem=nitem+1 'rscompras.movenext Loop end if Rscompras.close end if %>
Purchase report
PO Date P/O Vendor Kind Code Description Plant QTY DATE Currency U/P Amount No Req Request Date Note Requester Rec Qty In Date
<%=lfechapo%> <%=Rscompras("po_no")%> <%=Rscompras("cust_nm")%> <%=Rscompras("jaje_kind_nm")%> <%=Rscompras("jaje_seq")%> <%=Rscompras("jaje_nm")%> <%=Rscompras("class")%> <%=Rscompras("bal_qty")%><%=lfechadel%> <%=Rscompras("money_chk")%> <%=Rscompras("bal_price")%> <%=Rscompras("bal_amt")%> <%=Rscompras("r_no1")%> <%=Rscompras("r_no2")%> <%=Rscompras("r_no3")%><%=lfechareq%> <%=Rscompras("note1")%> <%=Rscompras("note2")%><%=Rscompras("ipgo_qty")%> <%=lfecharec%>
Total: <%=nitem%>