<!--#include file="conn.asp"-->

<% 
if session("login")<>"1" then
response.Redirect("login.asp") 
end if

 %>
    
<%

if request.QueryString("ac")="photo" then
response.write("<script language='javascript'>javascript:history.go(-1);location.reload();</script>")
response.End()
end if
if request.QueryString("ac")="addpedido" and request.QueryString("Articuloid")<>""  then

if request.Form("cantidad")="" then
response.write("<script language='javascript'>alert('错误：数量不能为空！\nError:Cantidad en vacio!');")   
response.write("javascript:history.go(-1);</script>")
response.End()
end if

if request.Form("DocumentoNo")="" then
response.write("<script language='javascript'>alert('错误：请先新建一张Pedido！\nError:Por favor,Anadir un pedido primero！');")   
response.write("javascript:history.go(-1);window.android.playFailed();</script>")
response.End()
end if

conn.open Str
sql = "select MAX(ordenno) AS MaxordenNo from pedidoproveedorarticulo where DocumentoNo= '"&request.Form("DocumentoNo")&"' "
set rs = conn.execute(sql)

if not(rs.bof and rs.eof) then
MaxordenNo=RS("MaxordenNo")
else
MaxordenNo=0
end if

sql2 = "select * from articulo where ArticuloID = '"&request.QueryString("ArticuloID")&"'"
set rs2 = conn.execute(sql2)

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

if not(rs.bof and rs.eof) then
response.write("<script language='javascript'>alert('此产品已存在本叫货单！\nArticulo Ya Esta En El Pedido!');")   
response.write("javascript:history.go(-1);window.android.playFailed();</script>")
response.End()

else

set add=conn.execute("insert pedidoproveedorarticulo (DocumentoNo,ArticuloID,CodigoBarra,NombreES,NombreCN,Precio,Cantidad,Descuento,Comentario,Temporal,OrdenNo)values('"& request.Form("DocumentoNo") &"','"& rs2("ArticuloID") &"','"& rs2("CodigoBarra") &"','"& rs2("NombreES") &"','"& rs2("NombreCN") &"','"& rs2("PrecioCoste") &"','"& request.Form("cantidad") &"',0,0,0,'"& MaxordenNo+1 &"' )") 
response.write("<script language='javascript'>alert('添加成功！\nCorrecto!');")   
response.write("javascript:history.go(-1);window.android.playSuccess();</script>")
response.End()
end if

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








if request.QueryString("ac")="cambiastock" and request.Form("stock")="" then
response.write("<script>alert('错误:新库存不能为空！\nError:No puede dejar EL STOCK en blanco!');window.location.href='?get=stock';window.android.playFailed();</script>")   
response.end() 
end if

if request.QueryString("ac")="cambiastock" and request.Form("stock")<>"" then

if request.Form("stock")>1000 then
 response.write("<script>alert('错误:库存数量不能超过1000！\nError:cantidad Stock superior 1000!');javascript:history.go(-1);window.android.playFailed();</script>")   
response.end() 
end if

conn.open Str

if request.QueryString("at")="no" then
set addstock=conn.execute("insert into stock (ArticuloID,stock)values('"& request.QueryString("ArticuloID") &"',0)")
end if

set sql=conn.execute("update stock set stock='"& request.Form("stock") &"' where articuloid='"&request.QueryString("articuloid")&"'" ) 
 conn.close
 response.write("<script>alert('库存修改成功！\nStock cambiado!');window.location.href='?get=good';window.android.playSuccess();</script>")   
response.end() 

end if

%>
<% 
if request.QueryString("get")="" and request.QueryString("ac")=""  then
 %>
 <table width="100%"  height="50" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center">
      <p class="STYLE2">&nbsp;</p>
      <p class="STYLE2">&nbsp;</p>
      <p class="STYLE2">商贸通移动版 </p>
      <p class="STYLE2">V2.4</p>
	  <p class="STYLE2">海梦电脑科技</p>
	  <p class="STYLE2">666666501/666666909</p>
    </div></td>
  </tr>
</table>
<% 
end if %>

<% 
if request.QueryString("ac")="" and request.QueryString("get")="good" or request.QueryString("get")=" " then
 %>
 <table width="100%"  height="100" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center"><span class="STYLE2">产品查询</span>
        <br />
        <div align="center" class="STYLE15">CONSULTA DE PRODUCTO </div>
    		 <br /><form id="form2" name="form2" method="post" action="index.asp?ac=c&get=good">
<%
Randomize 
codenew=Int((9999999999 * Rnd) + 1111111111)
 %>
<input name="key" type="hidden" value="<%= "808"&codenew %>" />
<div align="center">
<INPUT type=image width="40px;"src="img/barcode.jpg" border=0 name="Submit3" onClick="this.form2.submit()"  /> 
</div>
</form>
 </div>
 
 
 </td>
  </tr>
</table>
<form id="form1" name="form1" method="post" action="?ac=c&get=good">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <label>
        <div align="center">
          <p>
            <input name="key" type="text" id="key" style=" width:90%;height:60px; font-size:24px;" autofocus="autofocus" autocomplete="off"  value="<%= request.QueryString("key") %>" />
          </p>
        </div>
      <div align="center">
	  <br />
	   <INPUT type=image height="50" width="50" src="img/BUSCA.png" border=0 name="Submit2" onClick="this.form.submit()" autocomplete="off" /> 
      </div>
      </td>
  </tr>
</table>
</form>
<% end if %>

<% 
if request.QueryString("ac")="c" and request.Form("key")="" or request.Form("key")="0" and request.QueryString("get")="good" then
 response.write("<script>window.location.href='?get=good';</script>")   
response.End()
end if

if request.QueryString("ac")="c"  and request.Form("key")<>""  and request.QueryString("get")="good" then
 conn.open Str
If op1 = "1" And Len(request.Form("key")) >= 4 Then
    sql = "SELECT articulo.*, IFNULL(stock.stock, 0) AS stock, IF(stock.ArticuloID IS NOT NULL, 'yes', 'no') AS at FROM articulo LEFT JOIN stock ON articulo.ArticuloID = stock.ArticuloID WHERE articulo.ArticuloID LIKE '%" & request.Form("key") & "%' OR articulo.Codigobarra LIKE '%" & request.Form("key") & "%' OR FIND_IN_SET('%" & request.Form("key") & "%', REPLACE(articulo.multicodigo, ' ', ','))"
Else
    sql = "SELECT articulo.*, IFNULL(stock.stock, 0) AS stock, IF(stock.ArticuloID IS NOT NULL, 'yes', 'no') AS at FROM articulo LEFT JOIN stock ON articulo.ArticuloID = stock.ArticuloID WHERE articulo.ArticuloID = '" & request.Form("key") & "' OR articulo.Codigobarra = '" & request.Form("key") & "' OR FIND_IN_SET('" & request.Form("key") & "', REPLACE(articulo.multicodigo, ' ', ','))"
End If
Set rs = conn.execute(sql)

 %>
 <table width="100%" height="80" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<span class="STYLE2">产品查询</span><br />
<span class="STYLE14">CONSULTA DE ARTICULO</span><br />
<span class="STYLE2"><%= request.Form("key") %></span>
</td>
  </tr>
</table>
<form id="form1" name="form1" method="post" action="?ac=c&get=good">
<table width="100%"  height="50" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <label>
        <input name="key" type="text" id="key" style=" width:98%;height:30px;" autofocus="autofocus" align="right" autocomplete="off" value="<%= request.QueryString("key") %>"/>
      </label></td>
		<td width="5%">
	  <INPUT type=image height="30" width="30" src="img/BUSCA.png" border=0 name="Submit" onClick="this.form.submit()" autocomplete="off" /></td>
  </tr>
</table>
</form>




 <% if rs.eof then
 %>
 
<div align="center" style=" height:100%;font-size:18px">
  <p>无此产品/No hay Producto</p>
  <p><a href="add.asp?ac=anadir&articuloid=<%= request.Form("key") %>"/><img src="img/jia1.png" width="50" height="58" /></a></p>
  </div>
  <script>
  window.android.playFailed();
  </script>
<% 
else
while not rs.eof
 %>
  <form id="form3" name="form3" method="post" action="?ac=cambiastock&articuloid=<%= rs("articuloid") %>&at=<%= rs("at") %>">
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <td  height="35" colspan="5" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">产品详情</span><br /><span class="Menu2">PRODUCTO</span></div></td>
    </tr>
  <tr>
    <td width="40" background="img/bg60.png">&nbsp;</td>
    <td width="50%" height="60" background="img/bg60.png"><div align="center" style="font-size:16px; font-weight:bold;"><%= left(rs("nombrees"),24) %></div></td>
    <td width="40" background="img/bg60.png">    
    <td width="50%" height="60" colspan="2" background="img/bg60.png"><div align="center" style="font-size:16px; font-weight:bold;">
	
	<% 
	
	if ventamode="1" then
	precio=rs("preciodetalle")
	else
	precio=rs("preciomayor")
	end if
	
	
	
	if billetecode="1" then
	precioxs=" "&formatnumber(precio,2,-1,-1,0)
	else
	precioxs=precio
	end if
	
	if EName2IgualEName1="0" then
name1=left(rs("nombrees"),EName1MAX)
name2=left(rs("nombrecn"),EName2MAX)
else
name1=left(rs("nombrees"),EName1MAX)
name2=mid(rs("nombrees"),EName1MAX+1,EName2MAX)
end if

if isnull(rs("UnidadNombre")) or rs("UnidadNombre")="" then
UnidadNombre="Litro/Kg"
else
UnidadNombre=rs("UnidadNombre")
end if

if isnull(rs("VolumenPeso")) or rs("VolumenPeso")="0" then
nota1=nota
else
nota1=UnidadNombre&":"&formatnumber(1/formatnumber(rs("VolumenPeso"),2,-1,-1,0)*formatnumber(precio,2,-1,-1,0),2,-1,-1,0)&billete
end if

if notaxs="1" then
notaprint=nota
end if

if notaxs="2" then
notaprint=date()
end if

if notaxs="3" then
notaprint=nota1
end if

if notaxs="4" then
notaprint=rs("SITIOENALMACEN")
end if




if MAYORCONDOSPRECIOS="1" and ventamode<>"1" then
	response.Write(precioxs&billete&"/"&formatnumber(rs("preciodetalle"),2,-1,-1,0)&billete)
	else
	response.Write(precioxs&billete)
	end if
	
	
	
	
if Printidocodigo="2" and rs("Codigobarra")<>"" then
code=rs("Codigobarra")
else
code=rs("ArticuloID")
end if
	 %>
		
	</div>   </tr>
  <tr>
    <td width="40" background="img/bg60.png">&nbsp;</td>
    <td height="60" background="img/bg60.png"><div align="center" style="font-size:16px; font-weight:bold;"><%= rs("articuloid") %><BR/><%= rs("CODIGOBARRA") %></div></td>
    <td width="40" background="img/bg60.png">&nbsp;</td>
    <td height="60" colspan="2" background="img/bg60.png"><div align="center">
      <input name="stock"  type="number"/ step="0.01" min="0" oninput="value=value.replace(/[^\d]/g,'')" id="stock" value="<%= rs("stock") %>"  style="width:50px; height:35px; font-size:16Px; border:hidden; text-align:center; font-weight:bold;"   autocomplete="off" />
    </div></td>
</td>
  </tr>
</table>
	
 </form>
  <div align="center">
    <% 
Randomize 
codes=Int((9999999999 * Rnd) + 1111111111)
 %>
    <input id="BtnShow<%= codes %>" type="button" value="︾" style="border:none; width:100%; height:30px;background-color:<%= bgcolor %>;opacity:<%= opacity %>;" class="Menu1" onClick="MenuShow<%= codes %>()" />
</div>
<div id="DivMenu<%= codes %>" style="display:none; width:100%;" Align="center">

	<% 
	
if modelo="0" and style="1"  then
tipo="1"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="2"  then
tipo="9"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="3"  then
tipo="13"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="80"  then
tipo="10"
papel="普通80MM连续纸"
papeles="Papel 80MM Continuo"
end if

if modelo="1" and style="13" then
tipo="6"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if

if modelo="1" and style="18" then
tipo="18"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if

if modelo="1" and style="14" then
tipo="14"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if

 %>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="25%" height="60" ><div align="center">
		
		<% IF op4="1" and session("ClaseID")<>"1" then %>
		<a href="updategood.asp?ac=update&articuloid=<%= rs("articuloid") %>"/><img src="img/labi.png" width="25" height="25" /></a>
		<% end if %>
		<% IF session("ClaseID")="1" then %>
		<a href="updategood.asp?ac=update&articuloid=<%= rs("articuloid") %>"/><img src="img/labi.png" width="25" height="25" /></a>
		<% end if %>
		
		</div></td>
		
        <td width="25%" height="60" ><div align="center"><a href="?ac=photo&code=<%= Code %>"/><img src="img/cam.png" width="25" height="25" /></a></div></td>
		
       <td width="25%" height="60" ><div align="center">
	  <% if tipo="10" then %> 
	   <a href="almacen.asp?ac=print&tipo=<%= tipo %>&articuloid=<%= code %>&preciodetalle=<%= precioxs %>&nombrees=<%= Server.URLEncode(name1)  %>&nota=<%= NOTAprint %>&name2=<%= Server.URLEncode(name2) %>&tiendaname=<%= Server.URLEncode(tiendaname) %>&url=index&billete=<%= billete %>&tiendanamesize=<%= tiendanamesize %>&tiendanamealign=<%= tiendanamealign %>&name1size=<%= name1size %>&name1align=<%= name1align %>&name2size=<%= name2size %>&name2align=<%= name2align %>&preciosize=<%= preciosize %>&precioalign=<%= precioalign %>&fxsize=<%= fxsize %>&fxalign=<%= fxalign %>&notasize=<%= notasize %>&notaalign=<%= notaalign %>&codesize=<%= codesize %>&codealign=<%= codealign %>&billetesize=<%= billetesize %>&billetealign=<%= billetealign %>&codebarwidth=<%= codebarwidth %>&codebarheight=<%= codebarheight %>&fx=<%= fx %>&BilleteAntes=<%= BilleteAntes %>"/><img src="img/print.png" width="25" height="25" /></a>
	   <% else %>
	    <a href="impremir.asp?ac=imp&tipo=<%= tipo %>&articuloid=<%= code %>&preciodetalle=<%= precioxs %>&nombrees=<%= Server.URLEncode(name1)  %>&nota=<%= NOTAprint %>&name2=<%= Server.URLEncode(name2) %>&tiendaname=<%= Server.URLEncode(tiendaname) %>&url=index&billete=<%= billete %>&tiendanamesize=<%= tiendanamesize %>&tiendanamealign=<%= tiendanamealign %>&name1size=<%= name1size %>&name1align=<%= name1align %>&name2size=<%= name2size %>&name2align=<%= name2align %>&preciosize=<%= preciosize %>&precioalign=<%= precioalign %>&fxsize=<%= fxsize %>&fxalign=<%= fxalign %>&notasize=<%= notasize %>&notaalign=<%= notaalign %>&codesize=<%= codesize %>&codealign=<%= codealign %>&billetesize=<%= billetesize %>&billetealign=<%= billetealign %>&codebarwidth=<%= codebarwidth %>&codebarheight=<%= codebarheight %>&fx=<%= fx %>&BilleteAntes=<%= BilleteAntes %>"/><img src="img/print.png" width="25" height="25" /></a>
	  <% end if %> 
	   
	   </div></td>
	   <td width="25%" height="60" ><div align="center"><a href="#" onClick="document.getElementById('form3').submit();"><img src="img/ac.png" width="25" height="25" border="0" /></a></div></td>
      </tr>
    </table>
	
  <form id="form4" name="form4" method="post" action="?ac=addpedido&articuloid=<%= rs("articuloid") %>">
<table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="50%" background="img/bg60.png"><label>
        <div align="center">目标账单：

          <select name="DocumentoNo" id="DocumentoNo">	
            <% 	sql = "select * from pedidoproveedor where operadorid='"&session("Empleadoid")&"' and bloqueado=0 "
set rs3 = conn.execute(sql)

while not rs3.eof
 %>
            
            
            
            <option value="<%= rs3("DocumentoNo") %>"><%= rs3("DocumentoNo") %></option>
            
            
            <% 
  rs3.movenext
  wend
  rs3.close
  set rs3=nothing 
 %>	  
          </select>
          </div>
		</label>		</td>
        <td width="40%" background="img/bg60.png"><div align="center">数量：
          <input name="cantidad"  type="number" id="cantidad"  style="width:50px; height:20px; font-size:12Px; text-align:center; font-weight:bold;" value="1"/ step="0.01" min="0" oninput="value=value.replace(/[^\d]/g,'')"   autocomplete="off" />
        </div></td>
        <td width="10%" background="img/bg60.png"><div align="center"><a href="#" onClick="document.getElementById('form4').submit();"><img src="img/biji.png" width="25" height="25" border="0" /></a></div></td>
      </tr>
    </table>
</form>
	</td>
    </tr>	
	  <tr>
    <td height="50" colspan="3"><div align="center" style="font-size:14px; font-weight:bold;"><br/><%= left(rs("sitioenalmacen"),100) %></div></td>
    </tr>
</table>

</div>

 <script>
 function MenuShow<%= codes %>(){
     var btn=document.getElementById("BtnShow<%= codes %>");
     var div=document.getElementById("DivMenu<%= codes %>");

     if(btn.value.match(/\︾/)){
         btn.value=btn.value.replace(/\︾/,'︽');
         div.style.display='block';
     }
     else{
         btn.value=btn.value.replace(/︽/,'︾');
         div.style.display='none';  
     }
 }
 </script>
<div align="center">
<% if photo="1" then %>
<img src="img.asp?dibujoid=<%= rs("dibujoid") %>" style="width:50%">
<% end if %>
</div>
	<% if op2="1" and request.Form("key")<>"" and session("ClaseID")="1" then %>
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="word-wrap:break-word;word-break:break-all;">
    <tr>
    <td height="35" background="img/bj35.png" ><div align="center" style="font-size:16px; ">进货日期</div></td>
    <td background="img/bj35.png" ><div align="center" style="font-size:16px; ">单号</div></td>
    <td width="80" height="35" background="img/bj35.png" ><div align="center" style="font-size:18px; ">进价</div></td>
    <td width="80" height="35" background="img/bj35.png" ><div align="center" style="font-size:18px; ">数量</div></td>
   </tr>
   <%  
sqls="SELECT * FROM albaranproveedorarticulo LEFT JOIN albaranproveedor ON albaranproveedorarticulo.DocumentoNo = albaranproveedor.DocumentoNo WHERE albaranproveedorarticulo.ArticuloID = '" & rs("articuloid") & "' OR albaranproveedorarticulo.Codigobarra = '" & rs("articuloid") & "' ORDER BY albaranproveedor.fecha DESC "
set rss = conn.execute(sqls)
while not rss.eof%>
    <tr>
    <td height="35" background="img/bj35.png" ><div align="center" style="font-size:16px; "><%= Year(rss("FECHA"))&"-"&Right("00" & Month(rss("FECHA")), 2)&"-"&Right("00" & Day(rss("FECHA")), 2) %></div></td>
    <td background="img/bj35.png" ><div align="center" style="font-size:16px; "><%= rss("DocumentoNo") %></div></td>
    <td width="80" height="35" background="img/bj35.png" ><div align="center" style="font-size:18px; "><%= formatnumber(rss("precio"),2,-1,-1,-1) %></div></td>
    <td width="80" height="35" background="img/bj35.png" ><div align="center" style="font-size:18px; "><%= rss("cantidad") %></div></td>
   </tr>
  
<% 
  rss.movenext
  wend
 rss.close
  set rss=nothing 
  %> 
 </table>
 
 <% end if %>
 
 
 <% 
  rs.movenext
  wend
 rs.close
  conn.close
  set rs=nothing 

%>  
	
<% end if %>	
<% end if %>
  <!--添加产品-->

  <div style="height:100px"/></div>
<!--#include file="fooder.asp"-->