<!--#include file="conn.asp"-->
<% 
if session("login")<>"1" then
response.write("<script>alert('未登录或者登陆超时，请重新登陆！');window.location.href='login.asp';</script>")   
response.end() 
end if

if request.QueryString("ac")="preprint" and request.QueryString("DocumentoNo")<>"" then
conn.open Str
sql = "select COUNT(*) AS totallinea from pedidoproveedorarticulo where Cantidad<>Comentario and DocumentoNo="&request.QueryString("DocumentoNo")&""
set rs = conn.execute(sql)

if  Cint(rs("totallinea"))<>0 then
response.Redirect("?ac=print&DocumentoNo="&request.QueryString("DocumentoNo")&"")
else
response.write("<script>alert('无订货信息，无需打印！\n Sin DATOS,No va impremir!');window.location.href='?';window.android.playFailed();</script>")   
response.end() 
end if

conn.close
rs.close
set rs=nothing
end if
if request.QueryString("ac")="print" and request.QueryString("DocumentoNo")<>"" then
conn.open Str 
sql = "select *,empleado.nombre as empleado,proveedor.nombrees as proveedor from pedidoproveedor,proveedor,empleado where pedidoproveedor.Empresaid = proveedor.Empresaid and pedidoproveedor.operadorid = empleado.empleadoid order by pedidoproveedor.DocumentoNo desc "	
set rs = conn.execute(sql)
fecha=rs("fecha")
proveedor=rs("proveedor")
empleado=rs("empleado")
rs.close
set rs=nothing

sql = "select *,SUM(precio*cantidad) as total,COUNT(*) AS totallinea,SUM(cantidad) as cantidadtotal from pedidoproveedorarticulo where Cantidad<>Comentario and DocumentoNo="&request.QueryString("DocumentoNo")&""
set rs = conn.execute(sql)
totallinea=rs("totallinea")
cantidadtotal=rs("cantidadtotal")
rs.close
set rs=nothing

sql = "select * from pedidoproveedorarticulo where Cantidad<>Comentario and DocumentoNo="&request.QueryString("DocumentoNo")&""
set rs = conn.execute(sql)



%>
<table width="100%"  height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><p><span class="STYLE2" style="font-size: 24px; font-weight: bold">供应商进货单据-订货单</span><span style="font-size: 24px; font-weight: bold"><br />
       Pedido Proveedor</span><span style="font-size: 24px"><br />
      </span></p>
    </td>
 </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="left" style="font-size: 24px; font-weight: bold">Proveedor:<%= proveedor %></div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="left" style="font-weight: bold; font-size: 24px">Fecha:<%= fecha %><br />
      NO.:<%= request.QueryString("DocumentoNo") %><br />Operador:<%= empleado %>
    </div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
  <tr>
    <td width="30%"  height="30"><div align="center" style="font-size: 24px">
      <div align="left">产品<br />
        </div>
    </div></td>
    <td height="30" colspan="2">
    <div align="center" style="font-size: 22px">订货数<br />
    </div></td>
  </tr>
  <tr>
    <td  height="30" colspan="3"><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
 
<%
       while not rs.eof
	   
	   X=cstr(rs("Cantidad"))
	IF rs("Comentario")="" THEN
	Y=0
	ELSE
	Y=cstr(rs("Comentario"))
	END IF
   %>
  <tr>
    <td colspan="3" height="40px"  valign="bottom" ><span style="font-size: 24px"><%= rs("NombreES") %><%= rs("nombrecn") %></span></td>
  </tr>
  <tr>
    <td width="30%"><div align="left" style="font-size: 24px"><%= rs("ArticuloID") %></div></td>
    <td colspan="2"><div align="center" style="font-size: 24px"><%= X %></div></td>
  </tr>
	
	<% 
  rs.movenext
  wend
  rs.close
  conn.close
  set rs=nothing 
%>
    <tr>
      <td colspan="3" class="STYLE18" style="font-weight: bold"><div align="left" style="font-size: 24px">
      <div align="center">-------------------------------------</div>
    </div></td>
    </tr>
  <tr>
    <td colspan="2" class="STYLE18" style="font-weight: bold;font-size: 24px;">
        <div align="left">Linea:<%= totallinea %></div></td>
    <td class="STYLE18" style="font-weight: bold;font-size: 24px;"><div align="left">Cant.T:<%= cantidadtotal %></div></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
  <tr>
    <td height="200" valign="top"><span style="font-size: 24px">FIRMA OPERADOR </span></td>
  </tr>
  <tr>
    <td><div align="left" style="font-size: 24px">
      <div align="center"><strong>-------------------------------------</strong></div>
    </div></td>
  </tr>
</table>
<% 
response.End()
end if %> 
 
<% if request.QueryString("ac")="" then  %>
<table width="100%"  height="100" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<span class="STYLE2">订货单</span><br />
<span class="STYLE14"></span>Pedido A Proveedor<br />
<span class="STYLE2"><%= request.Form("key") %></span>
</td>
 </tr>
</table>

<%



conn.open Str
if session("PoderStockSalida")="-1" then
sql = "select * from pedidoproveedor order by DocumentoNo  desc limit 20 "
else
sql = "select * from pedidoproveedor  where OperadorId='"&session("Empleadoid") &"' order by DocumentoNo  desc limit 20"
end if
set rs = conn.execute(sql)


 %>
 
</table>
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="25%" align="center">
      <div align="center"></td>
    <td width="75%" align="center"><div align="right"><a href="?ac=check&ac2=addnt"><img src="img/jia.png" width="25" height="25" border="0"  /></a></div></td>
  </tr>
</table>
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
   <tr>
    <td width="20%" height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">单号</span><br /><span class="Menu2"> Numero</span></div></td>
    <td width="20%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">时间</span><br /><span class="Menu2"> Fecha</span></div></td>
    <td width="20%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">供货商</span><br /><span class="Menu2"> Proveedor</span></div></td>
    <td width="20%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">操作员</span><br /><span class="Menu2"> Operador</span></div></td>
	<td width="10%" colspan="2" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">操作</span><br /><span class="Menu2"> OBRA</span></div></td>
   </tr>
 
<%
       while not rs.eof
	   
if rs("EmpresaID")<>"" then
sql = "select * from proveedor where EmpresaID= '"&rs("EmpresaID")&"'"
set rs3 = conn.execute(sql)
NombreES=rs3("NombreES")
rs3.close
set rs3=nothing 
end if

sql = "select * from Empleado where EmpleadoID = '"&rs("operadorID")&"'"
set rs4 = conn.execute(sql)
empleado=rs4("Nombre")
rs4.close
set rs4=nothing 


   %>
  
  <tr>
    <td width="20%"  background="img/bj35.png"><div align="center"><%= rs("DocumentoNo") %></div></td>
    <td width="20%" height="35"  background="img/bj35.png"><div align="center"><%= rs("fecha") %></div></td>
    <td width="20%" height="35"  background="img/bj35.png"><div align="center"><%= NombreES %></div></td>
    <td width="20%" height="35"  background="img/bj35.png"><div align="center"><%= empleado %></div></td>
	<% if rs("bloqueado")="-1" and session("PoderStockSalida")="-1" then 
	%>
	<td width="30" height="35" background="img/bj35.png"></td>
    <td width="30" background="img/bj35.png"><div align="center"><a href="?ac=ver&DocumentoNo=<%= rs("DocumentoNo") %>"/><img src="img/biji.png" width="20" height="18" border="0" /></a></div></td>
	<%  
	elseIF  rs("bloqueado")="-1" AND  session("PoderStockSalida")<>"-1" then
	
	 %>
	<td width="30" height="35" background="img/bj35.png"></td>
    <td width="30" background="img/bj35.png"><div align="center"><a href="?ac=ver2&DocumentoNo=<%= rs("DocumentoNo") %>"/><img src="img/bd.jpg" width="20" height="20" border="0" /></a></div></td>
	<% ELSE %> 
	<td width="30" height="35" background="img/bj35.png">
    <div align="center">
<a href="javascript:if(confirm('确实要删除该行吗?\nEstás seguro eliminar esta linea ?'))location='?ac=delt&DocumentoNo=<%=rs("DocumentoNo")%>'"><img src="img/del.png" width="20" height="20" border="0" /></a></div>
	</td>
    <td width="30" background="img/bj35.png"><div align="center"><a href="?ac=check&DocumentoNo=<%= rs("DocumentoNo") %>"/><img src="img/labi.png" width="20" height="20" border="0" /></a></div></td>
	<% end if %>
  </tr>
  
<% 
  rs.movenext
  wend
  rs.close
  conn.close
  set rs=nothing 
end if %>
</table>
<!----分界线---->
<% 
 if request.QueryString("ac")="add" and request.QueryString("DocumentoNo")<>"" and request.Form("key")="" then
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
end if


if request.QueryString("ac")="add" and request.QueryString("DocumentoNo")<>"" and request.Form("key")<>"" then


conn.open Str
sql = "select MAX(ordenno) AS MaxordenNo from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' "
set rs = conn.execute(sql)
if not(rs.bof and rs.eof) then
MaxordenNo=RS("MaxordenNo")
else
MaxordenNo=0
end if
set rs=nothing 
 
 
sql2 = "select * from articulo where ArticuloID = '"&request.Form("key")&"'or Codigobarra = '"&request.Form("key")&"'"
set rs2 = conn.execute(sql2)
  
if rs2.bof and rs2.eof then 
response.write("<script language='javascript'>alert('无此产品！\nArticulo no hay!');")   
response.write("javascript:history.go(-1);window.android.playFailed();</script>")
response.End()

end if

sql="select * from pedidoproveedorarticulo where ArticuloID='"&request.Form("key")&"' and  DocumentoNo='"&request.QueryString("DocumentoNo")&"' "
set rs = conn.execute(sql)

if not(rs.bof and rs.eof) then

set updatearticulo=conn.execute("update pedidoproveedorarticulo set OrdenNo='"& MaxordenNo+1 &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and ArticuloID='"&request.Form("key")&"'")
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()



else

set add=conn.execute("insert pedidoproveedorarticulo (DocumentoNo,ArticuloID,CodigoBarra,NombreES,NombreCN,Precio,Cantidad,Descuento,Comentario,Temporal,OrdenNo)values('"& request.QueryString("DocumentoNo") &"','"& rs2("ArticuloID") &"','"& rs2("CodigoBarra") &"','"& rs2("NombreES") &"','"& rs2("NombreCN") &"','"& rs2("PrecioCoste") &"',1,0,0,0,'"& MaxordenNo+1 &"' )") 
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()



end if

   conn.close
  set rs2=nothing 
  set rs=nothing 
 end if

 if request.QueryString("ac")="upEmpresaID" and request.QueryString("DocumentoNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update pedidoproveedor set EmpresaID='"& request.Form("EmpresaID") &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' ")
response.Redirect("?")
response.End()
  conn.close
  set rs=nothing
end if

 if request.QueryString("ac")="mas" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update pedidoproveedorarticulo set Cantidad='"& Cint(request.QueryString("Cantidad"))+1 &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if

if request.QueryString("ac")="menos" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update pedidoproveedorarticulo set Cantidad='"& Cint(request.QueryString("Cantidad"))-1 &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if

if request.QueryString("ac")="accant" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update pedidoproveedorarticulo set Cantidad='"& request.Form("Cantidad") &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if


if request.QueryString("ac")="del" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
sql = "delete from pedidoproveedorarticulo where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"'"
set rs = conn.execute(sql)
response.Redirect("?ac=check&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if


if request.QueryString("ac")="delt" and request.QueryString("DocumentoNo")<>"" then
 conn.open Str

sql = "delete from pedidoproveedor where DocumentoNo='"&request.QueryString("DocumentoNo")&"'"
set rs = conn.execute(sql)

sql = "delete from pedidoproveedorarticulo where DocumentoNo='"&request.QueryString("DocumentoNo")&"'"
set rs = conn.execute(sql)

response.Redirect("?")  
response.End()
  conn.close
  set rs=nothing
end if



conn.open Str
sql = "delete from pedidoproveedorarticulo where cantidad=0"
set rs = conn.execute(sql)
set rs=nothing
conn.close

conn.open Str
sql = "select SUM(cantidad*precio) AS total,SUM(Cantidad) AS cantidadtotal,SUM(Comentario) AS Comentariototal,SUM(Comentario-cantidad) AS diferenciatotal,COUNT(*) AS ArticuloCategoria from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' "
set rs = conn.execute(sql)
total=rs("total")
Cantidadtotal=rs("Cantidadtotal")
ArticuloCategoria=rs("ArticuloCategoria")
Comentariototal=rs("Comentariototal")
diferenciatotal=rs("diferenciatotal")


set rs=nothing

set updatepedidoproveedor=conn.execute("update pedidoproveedor set total='"& total &"',cantidadtotal='"&cantidadtotal &"',OperadorId='"&session("Empleadoid") &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"'")
conn.close

if request.QueryString("ac")="check" then



 %>

<table width="100%"  height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<span class="STYLE2">订货单据</span><br />
	Pedido A Proveedor<br />
<span class="STYLE2"><%= request.Form("key") %></span></td>
 </tr>
  <tr>
    <td height="20" align="center"><div align="center" style="font-weight: bold">单据号码：<%= request.QueryString("DocumentoNo") %></div></td>
  </tr>
</table>
<form id="form1" name="form1" method="post" action="?ac=add&DocumentoNo=<%= request.QueryString("DocumentoNo") %>">
<table width="100%"  height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <label>
        <input name="key" type="text" id="key" style=" width:100%;height:30px;" autofocus="autofocus" align="right" autocomplete="off" required="required" />
      </label></td>
		<td width="5%">
	  <INPUT type=image height="30" width="30" src="img/BUSCA.png" border=0 name="form1" onClick="this.form.submit()" autocomplete="off" /></td>
  </tr>
  <tr>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
</table>
</form>

<% 

conn.open Str

if request.QueryString("ac2")="addnt" then
sql = "select * from pedidoproveedor order by DocumentoNo desc limit 1"
set rs = conn.execute(sql)


If rs.bof and rs.eof  then
TDocumentoNo1=Year(Date())&Right("0" & Month(Date()),2)&"0001"
elseif left(rs("DocumentoNo"),6)<>Year(Date())&Right("0" & Month(Date()),2) then
TDocumentoNo1=Year(Date())&Right("0" & Month(Date()),2)&"0001"
else
sql = "select max(DocumentoNo) as TDocumentoNo  from pedidoproveedor"
set rs = conn.execute(sql)


TDocumentoNo1=Clng(rs("TDocumentoNo"))+1
set rs=nothing
end if


set addnt=conn.execute("insert pedidoproveedor (DocumentoNo,Empresaid,Fechaentrada,fecha,Operadorid)values('"& TDocumentoNo1 &"','1','"& now() &"','"& now() &"','"& session("Empleadoid") &"' )")
response.Redirect("?ac=check&DocumentoNo="&TDocumentoNo1 )
response.End()
set rs=nothing
end if


sql = "select * from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"'  order by OrdenNo desc"
set rs = conn.execute(sql)






sql = "select * from pedidoproveedor where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' "
set rs4 = conn.execute(sql)


 %>


 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="?ac=upEmpresaID&DocumentoNo=<%= request.QueryString("DocumentoNo") %>" method="post" name="form3" id="form3">  
  <tr>
    <td  height="30"><div align="center">供应商 Proveedor：</div></td>
    <td colspan="2">
		 		  <select name="EmpresaID" id="EmpresaID" style=" width:80px;height:25px;">
		<%
if rs4("EmpresaID")<>"" then

 sql3 = "select * from proveedor where EmpresaID= '"&rs4("EmpresaID")&"'"
set rs3 = conn.execute(sql3)
NombreES=rs3("NombreES")
rs3.close
set rs3=nothing 
end if
 %>
 		<option value="<%= rs4("EmpresaID") %>" selected="selected"><%= NombreES %></option>
		
		<%

 sql2 = "select * from proveedor "
set rs2 = conn.execute(sql2)
 %>		

<% 
       while not rs2.eof
   %>
          <option value="<%= rs2("EmpresaID") %>" ><%= left(rs2("NombreES"),20) %></option>
<% 
  rs2.movenext
  wend
  rs2.close
  set rs2=nothing 


%>
	  </select>
		 		  <input name="Submit" type="submit" value="挂单" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" class="Menu1" />	</td>
    <td height="30" colspan="3"><label>
      <div align="center"><a href="javascript:if(confirm('确实要结束该单据吗? 不可修改\nEstás seguro Terminar este Pedido? No modificable'))location='?ac=enviar&DocumentoNo=<%= request.QueryString("DocumentoNo") %>'"><img src="img/dh.png" width="20px" height="20px" border="0" />结束单据</a>        </div>
    </label></td>
    </tr>
  </form>
    <tr>
    <td width="30%"  height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">产品</span><br /><span class="Menu2">PRODUCTO</span></div></td>
    <td width="25%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">数量</span><br /><span class="Menu2">CANT</span></div></td>
    <td width="10%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">库存</span><br /><span class="Menu2">STOCK</span></div></td>
	<td width="7%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">价格</span><br /><span class="Menu2">PRECIO</span></div></td>
	<td width="8%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">小计</span><br /><span class="Menu2">SUMA</span></div></td>
	<td width="15%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">操作</span><br /><span class="Menu2">OBRA</span></div></td>
   </tr>
<%
       while not rs.eof
	   
	   
	   
	    sql8 = "select * from stock where ArticuloID = '"&rs("ArticuloID")&"'"
 set rs8 = conn.execute(sql8)
 
 if rs8.bof and rs8.eof then
stock="0"

else
stock=rs8("stock")

 end if
	   
	   
	   
	  
   %>
    <form id="form2" name="form2" method="post" action="?ac=accant&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>">

  <tr background="img/bg60.png" >
    <td width="30%" height="60" ><div align="center"><span class="STYLE15"><a href="updategood.asp?ac=update&articuloid=<%= rs("ArticuloID")  %>"/><%= rs("NombreES") %></a><br />
    <%= rs("ArticuloID") %></span></div></td>
    <td width="25%" height="60"><div align="center">
      <a href="?ac=menos&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>&Cantidad=<%=rs("Cantidad")%>"/><img src="img/jian1.png" width="15" height="15" /></a>
      <input name="cantidad" type="number"/ id="cantidad"  style=" width:40px;height:20px; font-size:16px; text-align:center" value="<%= rs("Cantidad") %>" maxlength="3" autocomplete="off"  required="required" />
      <a href="?ac=mas&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>&Cantidad=<%=rs("Cantidad")%>"/><img src="img/jia1.png" width="15" height="17" /></a></div></td>
    <td width="10%" height="60"><div align="center"><%= stock %></div></td>
	<td width="7%" height="60"><div align="center"><%= formatnumber(rs("precio"),2,-1,-1,0) %></div></td>
	<td width="8%" height="60"><div align="center"><%= formatnumber(ccur(rs("precio"))*ccur(rs("Cantidad")),2,-1,-1,0)  %></div></td>
	<td width="15%"  height="60" valign="middle"><label>
    <div align="center">
      <input type="image" name="ac" src="img/ac.png" width="20" height="20" onClick="document.form2.submit()">
<a href="javascript:if(confirm('确实要删除该产品吗?\nEstás seguro eliminar esta linea ?'))location='?ac=del&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>'"><img src="img/del.png" width="20" height="20" border="0" /></a></div>
	</label>   </tr>
	</form>
	
	<% 
  rs.movenext
  wend
  rs.close
  conn.close
  set rs=nothing 

%>
    <tr>
    <td width="30%" height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="right"><span class="Menu1">LINEA：<%= ArticuloCategoria %></span></div></td>
    <td width="25%" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">CANTIDAD:<%= cantidadtotal %></span></div></td>
    <td height="35" colspan="4" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" ><div align="center"><span class="Menu1">TOTAL:<%= total %></span></div>  </td>
   </tr>
</table>
<% end if %>
<% 
 if request.QueryString("ac")="mass" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update PedidoProveedorarticulo set Comentario='"& Cint(request.QueryString("Cantidad"))+1 &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=ver&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if

if request.QueryString("ac")="menoss" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update PedidoProveedorarticulo set Comentario='"& Cint(request.QueryString("Cantidad"))-1 &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=ver&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if

if request.QueryString("ac")="accants" and request.QueryString("DocumentoNo")<>"" and request.QueryString("OrdenNo")<>"" then
 conn.open Str
set updatearticulo=conn.execute("update PedidoProveedorarticulo set Comentario='"& request.Form("Cantidad") &"',Precio='"& request.Form("Precio") &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' and  OrdenNo='"&request.QueryString("OrdenNo")&"' ")
response.Redirect("?ac=ver&DocumentoNo="&request.QueryString("DocumentoNo")&"")
response.End()
  conn.close
  set rs=nothing
end if

 %>
<%

conn.open Str 
if request.QueryString("ac")="enviar" then
set updatearticulo=conn.execute("update PedidoProveedor set bloqueado=-1 where DocumentoNo='"&request.QueryString("DocumentoNo")&"' ")
response.write("<script>alert('此账单已确认结束！\n Ya esta Terminado!');window.location.href='?';</script>")   
response.end() 
end if

if request.QueryString("ac")="estado" then
set updatearticulo=conn.execute("update PedidoProveedor set bloqueado='"& request.Form("estado") &"' where DocumentoNo='"&request.QueryString("DocumentoNo")&"' ")
response.write("<script>alert('已修改状态！\n Estado Modificado!');window.location.href='?';</script>")   
response.end() 
end if

if request.QueryString("ac")="ver" and request.QueryString("DocumentoNo")<>"" then
sql2 = "select * from pedidoproveedor where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' "
set rs2 = conn.execute(sql2)


sql = "select * from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' and  articuloid= '"&request.Form("key")&"' order by ordenno desc "
set rs = conn.execute(sql)

if request.Form("key")="" or rs.bof and rs.eof then

sql = "select * from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"'  order by ordenno desc "
set rs = conn.execute(sql)

end if



%>
<table width="100%"  height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<span class="STYLE2">订货单据</span><br />
	Pedido A Proveedor<br />
<span class="STYLE2"><%= request.Form("key") %></span>
</td>
 </tr>
</table>
<form id="form1" name="form1" method="post" action="?ac=ver&DocumentoNo=<%= request.QueryString("DocumentoNo") %>">
<table width="100%"  height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <label>
        <input name="key" type="text" id="key" style=" width:100%;height:30px;" autofocus="autofocus" align="right" autocomplete="off" required="required" />
      </label></td>
		<td width="5%">
	  <INPUT type=image height="30" width="30" src="img/BUSCA.png" border=0 name="form1" onClick="this.form.submit()" autocomplete="off" /></td>
  </tr>
  <tr>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
</table>
</form>


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40%"  height="30"><div align="center"><%= rs2("fecha") %>-<%= request.QueryString("DocumentoNo") %></div></td>
    <td height="30" colspan="4"><form id="form5" name="form5" method="post" action="?ac=estado&DocumentoNo=<%= request.QueryString("DocumentoNo") %>">
	    <label>
	    <div align="center">状态ESTADO：
	      <select name="estado" style="border:hidden;">
	        <% if rs2("bloqueado")="0" then %>
	        <option value="-1" >Aceptado</option>
	        <option value="0" selected="selected">Pendiende</option>
			<% else %>
			<option value="-1" selected="selected" >Aceptado</option>
	        <option value="0" >Pendiende</option>
			<% end if %>
          </select>
	      &nbsp;
	      <input type="submit" name="Submit2" value="OK" />
	    </div>
	    </label>
      </form></td>
  </tr>
  <tr>
    <td width="40%"  height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">产品</span><br /><span class="Menu2"> PRODUCTO</span></div></td>
    <td width="10%" height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">订单数量</span><br /><span class="Menu2"> CANT.PEDIDO</span></div></td>
    <td width="30%" height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">配货数量</span><br /><span class="Menu2"> CANT.ENVIO</span></div></td>
	<td width="10%" height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">差数</span><br /><span class="Menu2"> DIFERENCIA</span></div></td>
	<td width="10%" height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">更新</span><br /><span class="Menu2"> AC</span></div></td>
</tr>
 
<%
       while not rs.eof
	  sql="select * from articulo where articuloid='"&rs("articuloid")&"'"
	  set rsal = conn.execute(sql)
	  
	  if rs("comentario")="" then
	  comentario="0"
	  else
	  comentario=rs("comentario")
	  end if
	  
   %>
  <tr>
    <td width="40%" height="60"  background="img/bg60.png"><div align="center"><span class="STYLE15"><a href="updategood.asp?ac=update&articuloid=<%= rs("ArticuloID")  %>"/><%= rs("NombreES") %></a><br />
    <%= rs("ArticuloID") %><br />
    <%= rsal("SitioEnAlmacen") %></span></div></td>
    <td height="60"  background="img/bg60.png"><div align="center"><%= rs("Cantidad") %></div></td>
	
	<form id="form4" name="form4" method="post" action="?ac=accants&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>">
    <td height="60"  background="img/bg60.png">
   
	<div align="center">
      <a href="?ac=menoss&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>&Cantidad=<%=rs("Comentario")%>"/><img src="img/jian1.png" width="15" height="15" /></a>
      <input name="cantidad" type="number"/ id="cantidad"  style=" width:40px;height:20px; font-size:16px; text-align:center" value="<%= rs("Comentario") %>" maxlength="3" autocomplete="off"  required="required" />
      <a href="?ac=mass&DocumentoNo=<%=request.QueryString("DocumentoNo")%>&OrdenNo=<%=rs("OrdenNo")%>&Cantidad=<%=comentario%>"/><img src="img/jia1.png" width="15" height="15" /></a>&nbsp;      </div>	</td>
	<td height="60"  background="img/bg60.png"><div align="center"><%= Cint(comentario)- Cint(rs("Cantidad")) %></div></td>
	<td height="60"  background="img/bg60.png"><label>
	  <div align="center">
	    <input type="image" name="ac" src="img/ac.png" width="20" height="20" onClick="document.form4.submit()">	  
      </div>
	</label>	</td>
    </form>
</tr>
	
	<% 
  rs.movenext
  wend
  rs.close
  rs2.close
  conn.close
  set rs=nothing 
  set rs2=nothing 
    set rsal=nothing 

%>
  <tr>
    <td width="40%" height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="right" ><span class="Menu1">LINEA：<%= ArticuloCategoria %></span></div></td>
    <td style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center" ><span class="Menu1"><%= cantidadtotal %></span></div></td>
    <td height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" ><div align="center"><span class="Menu1"><%= Comentariototal %></span></div></td>
    <td height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" ><div align="center"><span class="Menu1"><%= Diferenciatotal %></span></div></td>
    <td height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" ></td>
  </tr>
</table>
<% end if %>

<% 


if request.QueryString("ac")="ver2" and request.QueryString("DocumentoNo")<>""  then 

sql2 = "select * from pedidoproveedor where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' "
set rs2 = conn.execute(sql2)
sql = "select * from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"' and  articuloid= '"&request.Form("key")&"' order by ordenno desc "
set rs = conn.execute(sql)

if request.Form("key")="" or rs.bof and rs.eof then

sql = "select * from pedidoproveedorarticulo where DocumentoNo= '"&request.QueryString("DocumentoNo")&"'  order by ordenno desc "
set rs = conn.execute(sql)

end if
%>
<table width="100%"  height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<span class="STYLE2">订货单据</span><br />
	Pedido A Proveedor<br />
<span class="STYLE2"><%= request.Form("key") %></span>
</td>
 </tr>
</table>
<form id="form1" name="form1" method="post" action="?ac=ver2&DocumentoNo=<%= request.QueryString("DocumentoNo") %>">
<table width="100%"  height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <label>
        <input name="key" type="text" id="key" style=" width:100%;height:30px;" autofocus="autofocus" align="right" autocomplete="off" required="required" />
      </label></td>
		<td width="5%">
	  <INPUT type=image height="30" width="30" src="img/BUSCA.png" border=0 name="form1" onClick="this.form.submit()" autocomplete="off" /></td>
  </tr>
  <tr>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
</table>
</form>


<% 
if rs2("bloqueado")="0" then
estado="Pendiende"
else
estado="Aceptado"
end if

 %>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td  height="30"><div align="center"><%= rs2("fecha") %>-<%= request.QueryString("DocumentoNo") %></div></td>
    <td><div align="center"><a href="javascript:if(confirm('确实要打印订货单吗?\nEstás seguro Impremir Pedidos?'))location='?ac=preprint&DocumentoNo=<%=request.QueryString("DocumentoNo")%>'"><img src="img/print.png" width="30" height="30" border="0" /></a></div></td>
  </tr>
  <tr>
    <td  height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">产品</span><br /><span class="Menu2"> PRODUCTO</span></div></td>
    <td  height="30" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">订单数量</span><br /><span class="Menu2"> CANT.PEDIDO</span></div></td>
  </tr>
 
<%
       while not rs.eof
	  sql="select * from articulo where articuloid='"&rs("articuloid")&"'"
	  set rsal = conn.execute(sql)
	  
   %>
  <tr>
    <td height="60"  background="img/bg60.png"><div align="center"><span class="STYLE15"><a href="updategood.asp?ac=update&articuloid=<%= rs("ArticuloID")  %>"/><%= rs("NombreES") %></a><br />
    <%= rs("ArticuloID") %><br /><%= rsal("SitioEnAlmacen") %></span></div></td>
    <td height="60"  background="img/bg60.png"><div align="center"><%= rs("Cantidad") %></div></td>
  </tr>
	
	<% 
  rs.movenext
  wend
  rs.close
  rs2.close
  conn.close
  set rs=nothing 
  set rs2=nothing 
    set rsal=nothing 

%>
  <tr>
    <td height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center" ><span class="Menu1">LINEA：<%= ArticuloCategoria %></span></div></td>
    <td height="35" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center" ><span class="Menu1"><%= cantidadtotal %></span></div></td>
  </tr>
</table>
<% end if %>
<div style="height:100px"/></div>
<!--#include file="fooder.asp"-->