<%@ page errorPage="errorPage.jsp" language="java" session="true" contentType="text/html;charset=ISO-8859-2" %>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="com.etixpert.evolution.gui.servlets.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.etixpert.evolution.gui.servlets.*"%>
<%@ include file="header.jsp" %>
<%@ include file="check.jsp" %>
<%!
public String getVal(String name, HttpSession session) {
	Map m = (Map)session.getAttribute("article_list.jsp");
	if (m == null) return "";
	String[] vals = (String[])m.get(name);
	if (vals != null && vals.length>0 && vals[0] != null) return vals[0];
	return "";
}
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link href="main.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!-- JavaScript code hiding

	var okb = true

	function simpleLink(origLink) {
		parent.mainFrame.location = origLink;
	}

	function link(origLink){
		if (top.mainFrame.document.forms.length == 0) {
			simpleLink(origLink);
			return;
		}
		else {
			if (top.mainFrame.document.forms[0].saveState == null) {
				simpleLink(origLink); 
				return;
			}
			top.mainFrame.document.forms[0].saveState.value = top.mainFrame.self.location.pathname;
			top.mainFrame.document.forms[0].link.value = origLink;
			top.mainFrame.document.forms[0].submit();
		}
	}

	function isEmpty(inputVal) {
		if (inputVal == null || inputVal == "") {
			return true
		}
		return false
	}
	
	function isPosInt(inputStr) {
		
		for (var i=0; i<inputStr.length; i++) {
			var oneChar = inputStr.charAt(i)
			if (((oneChar < "0") || (oneChar > "9"))) {
				return false
			}
		}
		return true;
	}
	
	function isValid(inputVal) {
		if (isEmpty(inputVal)) return false
		if (isPosInt(inputVal)) return true
		return false
	}
	
	function val(field, inputVal) {
		//gField = eval("window.mainFrame.document.forms[0]."+field.name)
		if (isEmpty(field.value)) {
			field.value = '0'
			okb = true;
			return true;
		}
		
		if (!isPosInt(field.value)) {
			alert('Bitte nur ganze Zahlen eingeben!')
			//field.value = inputVal
			field.focus()
			field.select()
			
			okb = false;
			return false
		}
		else {
			okb = true
			return true
		}
	}
	
	function check() {
		if (okb) return true;
		okb = true;
		return false;
	}
// -->
</SCRIPT>
</head>
<body>
<form action="process/article_supplier_list.jsp" method="post">
<input type="hidden" name="saveState"/>
<input type="hidden" name="link" value="process/article_supplier_list.jsp"/>
<input type="hidden" name="distID"/>
<input type="hidden" name="levelID"/>
<input type="hidden" name="pageAction">
<input type="hidden" name="artId">
<jsp:include page="MenuHelper.jsp">
	<jsp:param name="self_id" value="none"/>
	<jsp:param name="parent_id" value="4400"/>	
</jsp:include>
  <table width="800" border="0" cellpadding="0" cellspacing="0" id="userDetailsTable" class="normal">
    <!--DWLayoutTable-->
    <tr> 
      <td height="30" colspan="2" valign="top" id="userTableContentTitles"><!--DWLayoutEmptyCell-->&nbsp;</td>
      <td width="40">&nbsp;</td>
      <td colspan="4" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    </tr>
    <tr> 
      <td height="30" valign="top" id="userTableContentTitles">&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2" valign="top" id="userTableContentFields"><a onClick="return check();" href="javascript:top.mainFrame.document.forms[0].pageAction.value='article_supplier_save';link('process/article_supplier_list.jsp')"><fmt:message key="SAVE_SUPPLIER"/></a></td>
      <td></td>
      <td valign="top" id="userTableContentTitles">&nbsp;</td>
      <td>&nbsp;</td>
      <td valign="top" id="userTableContentTitles"><a href="javascript:top.mainFrame.document.forms[0].pageAction.value='article_supplier_reload';link('process/article_supplier_list.jsp')"><fmt:message key="RELOAD_SUPPLIER"/></a></td>
    </tr>
	<%
		if (session.getAttribute("SUPPLIER_ADDED")!=null) {
	%>
	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="5" id="userTableContentMainTitles2">
			<%
			java.util.ArrayList ret = (java.util.ArrayList)session.getAttribute("SUPPLIER_ADDED");
			
			for (int i=0; i<ret.size(); i++) {
				String[] sa = (String[])ret.get(i);
				out.print(LocaleSupport.getLocalizedMessage(pageContext,"SUPPLIER_UPDATED", new Object[]{sa[0], sa[1]}));
				out.print("<br>");
				}
				
			%>
				
		</td>
	</tr>
	<%
		}
		session.removeAttribute("SUPPLIER_ADDED");
	%>
</table>
<table width="800" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr> 
    <td width="800" height="30">&nbsp;</td>
  </tr>
  <tr>
    <td height="142" align="center" valign="top">
      <DIV STYLE="overflow: auto; width: 820px; height: 500px;
            border-left: 0px gray solid; border-bottom: 0px gray solid;
            padding:0px; margin: 0px; margin-left: 10px;">
          <table width="800" border="1" id="mainTable" class="sortable">
		<%=FormHelper.generateArticleSupplierListHeader(pageContext)%>
       <% 
       String[] res = FormHelper.generateArticleSupplierListRows(session);
       out.print(res[0]);
       String count = res[1];%>
       </tr></table></div>
      </td>
  </tr>
  <tr>
    <td height="78">&nbsp;</td>
  </tr>
</table>
<input type="hidden" name="count" value="<%=count%>"/>  
</form>
</body>
</html>
