<%@ 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") campo=Request.Form("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) %> Reporte Compras <% 'response.write("FROM: "&cfechai&" ") 'header if busca="" or busca=null then origen=doc end if %>
       
Period:   Excel
  Todas Recibidas Pendientes

<% 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 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, sum(ipgo_qty) ipgo_qty, max(ipgo_date) ipgo_date from mtd020t(nolock) group by crp_id, bal_Date, bal_seq, bal_sub, po_no) 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 ") 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 ") nitem=0 If not Rscompras.EOF Then Rscompras.movefirst 'response.write("TO: 2") Do While Not Rscompras.EOF 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 cipgoqty =cint(Rscompras("ipgo_qty")) 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 %> <% 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 Rec Qty In Date No Req Request Date Note Requester Balance
<%=Rscompras("bal_day")%> <%=Rscompras("po_no")%> <%=Rscompras("cust_nm")%> <%=Rscompras("jaje_kind_nm")%> <%=Rscompras("jaje_seq")%> <%=Rscompras("jaje_nm")%> <%=Rscompras("class")%> <%=Rscompras("bal_qty")%> <%=Rscompras("nap_date")%> <%=Rscompras("money_chk")%> <%=Rscompras("bal_price")%> <%=Rscompras("bal_amt")%> <%=cipgoqty%> <%=Rscompras("ipgo_date")%> <%=Rscompras("r_no1")%> <%=Rscompras("r_no2")%> <%=Rscompras("r_no3")%> <%=Rscompras("req_indate")%> <%=Rscompras("note1")%> <%=Rscompras("note2")%><%=cipgoqty-cbalqty%>
Total: <%=nitem%>