PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/inventory/NewItem.asp

http://github.com/khaneh/Orders
ASP | 222 lines | 186 code | 18 blank | 18 comment | 13 complexity | 2a729103aea1685a9436fd1a2f128ad2 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Inventory (5)
  3PageTitle= " ����� ����� ����"
  4SubmenuItem=4
  5if not Auth(5 , 4) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<%
 12'-----------------------------------------------------------------------------------------------------
 13'------------------------------------------------------------------------- Submit a new Inventory Item
 14'-----------------------------------------------------------------------------------------------------
 15if request.form("Submit")="��� ������ ����" then
 16	catItem = request.form("catItem") 
 17	ItemName = request.form("ItemName") 
 18	OldItemID = request.form("OldItemID") 
 19	ownerAcc = request.form("ownerAcc") 
 20	costingMethod = request.form("cost") 
 21	Minim = request.form("Minim") 
 22	qtty = request.form("qtty") 
 23	Unit = request.form("Unit") 
 24	outByOrder = request.form("outByOrder")
 25	
 26	if outByOrder="on" then
 27		outByOrder = 1
 28	else
 29		outByOrder =0
 30	end if
 31
 32	response.write "<BR><BR><TABLE align=center style='border: solid 2pt black'><TR><TD>"
 33	response.write  "<li> �� ���� ���� = " & catItem& "<br>"
 34	response.write  "<li> ��� ���� = " & ItemName& "<br>"
 35	'response.write  "<li> ���� ���� = " 
 36	'if ownerAcc=-1 then 
 37	'response.write 	"���� �ǁ � ���<br>"
 38	'else
 39	'response.write 	"����� ���� "& ownerAcc & "<br>"
 40	'end if
 41	response.write  "<li> �� ���� = " & OldItemID& "<br>"
 42	response.write  "<li> ���� ���� ����� = " & costingMethod& "<br>"
 43	response.write  "<li> ����� ������ = " & Minim& "<br>"
 44	response.write  "<li> ����� = " & qtty& "<br>"
 45	if outByOrder=1 then
 46		response.write  "<li> ���� �� ���� �����"
 47	end if
 48	response.write  "<li> ���� = " & Unit& "<br>"
 49	response.write "</TD></TR></TABLE>"
 50
 51	mySql="INSERT INTO InventoryItems (OldItemID, owner, Name, Minim, Qtty, Unit, costingMethod,outByOrder) VALUES ("& OldItemID & ", "& ownerAcc & ",N'"& ItemName & "', "& Minim & ", 0, N'"& Unit & "','"& costingMethod & "', "& outByOrder & " )"	
 52	conn.Execute mySql
 53
 54	set RS4 = conn.Execute ("SELECT * FROM InventoryItems where OldItemID=" & OldItemID & " and Name=N'" & ItemName & "'") 
 55
 56	if RS4.EOF then
 57		response.write "<br><br>���! ���� ������ ���. ������ ��� ���� �� �� ���� ����� ���� Ȑ����."
 58		response.end
 59	end if
 60
 61	ItemID = RS4("id")
 62	RS4.close
 63
 64	mySql="INSERT INTO InventoryItemCategoryRelations (Item_ID, Cat_ID) VALUES ("& ItemID & ", "& catItem & ")"	
 65	conn.Execute mySql
 66
 67	'if Qtty <> 0 then
 68		mySql="INSERT INTO InventoryLog (ItemID, RelatedID, logDate, Qtty, owner, CreatedBy, IsInput, type) VALUES ("& ItemID & ", -4 ,N'"& shamsiToday() & "', "& Qtty & ", -1 , "& session("id") & ", 1 , 4)"
 69		conn.Execute mySql
 70	'end if
 71
 72	response.write "<center><br>����� ��� �� ������ ������ ��.</center>"
 73response.end
 74
 75end if
 76%>
 77
 78<%
 79'-----------------------------------------------------------------------------------------------------
 80'--------------------------------------------------------------------------------------- New Item Form
 81'-----------------------------------------------------------------------------------------------------
 82%>
 83<SCRIPT LANGUAGE="JavaScript">
 84<!--
 85function hideIT()
 86{
 87//alert(document.all.aaa2.value)
 88if(document.all.aaa2.value==2) 
 89	{
 90		document.all.aaa1.style.visibility= 'visible'
 91		document.all.ownerAcc.value = ""
 92		document.all.ownerAcc.focus()
 93	}
 94	else
 95	{
 96		document.all.aaa1.style.visibility= 'hidden'
 97		document.all.ownerAcc.value = "-1"
 98	}
 99}
100//-->
101</SCRIPT>
102
103<BR>
104<FORM METHOD=POST ACTION="NewItem.asp">
105<TABLE border=0 align=center>
106<TR>
107	<TD colspan=2 align=center><H3>���� ������� ����</H3></TD>
108</TR>
109<TR>
110	<TD align=left>��� ����</TD>
111	<TD align=right>
112		<SELECT NAME="catItem" style='font-family: tahoma,arial ; font-size: 9pt; font-weight: bold' size="1"  onchange='check(this);'>
113		<option value="-1">���� ���� ���� </option>
114		<option value="-1">------------------</option>
115		<%
116			set RS4 = conn.Execute ("SELECT * FROM InventoryItemCategories")
117			while not (RS4.eof) %>
118				<OPTION value="<%=RS4("ID")%>"<%
119				'if trim(catItem1) = trim(RS4("ID")) then
120				'response.write " selected "
121				'end if
122				%>>* <%=RS4("Name")%> </option>
123				<%	
124				RS4.MoveNext
125			wend
126			RS4.close
127			%>
128		</SELECT>
129	</TD>
130</TR>
131<tr>
132	<td align="left">�����</td>
133	<td align="right"></td>
134</tr>
135<TR>
136	<TD align=left>��� ����</TD>
137	<TD align=right><INPUT TYPE="text" NAME="ItemName" size=64></TD>
138</TR>
139<TR>
140	<TD align=left>�� ����</TD>
141	<TD align=right><INPUT TYPE="text" NAME="OldItemID"></TD>
142</TR>
143<!--TR>
144	<TD align=left>������</TD>
145	<TD align=right>
146	<SELECT NAME="aaa2"  onchange="hideIT()" >
147	<option value=1>���� �ǁ � ���</option>
148	<option value=2>������ (����� ����)</option>
149
150	</SELECT></TD>
151</TR>
152<TR>
153	<TD align=left></TD>
154	<TD align=right><span name="aaa1" id="aaa1" style="visibility:'hidden'">
155	<INPUT TYPE="text" NAME="ownerAcc" value="-1"></span></TD>
156</TR>
157<TR>
158	<TD align=left></TD>
159	<TD align=right height=20></TD>
160</TR>
161<TR>
162	<TD align=left>���� �������</TD>
163	<TD align=right><INPUT TYPE="radio" NAME="cost" checked value="AVRG">����� <BR>
164	<INPUT TYPE="radio" NAME="cost"  value="LIFO">LIFO <BR>
165	<INPUT TYPE="radio" NAME="cost" value="FIFO">FIFO</TD>
166</TR>
167<TR>
168	<TD align=left></TD>
169	<TD align=right height=20></TD>
170</TR-->
171<TR>
172	<TD align=left>����� ������</TD>
173	<TD align=right><INPUT TYPE="hidden" NAME="ownerAcc"  value="-1"><INPUT TYPE="hidden" NAME="cost" value="FIFO"><INPUT TYPE="text" NAME="Minim" value=0></TD>
174</TR>
175<TR>
176	<TD align=left>����� ����</TD>
177	<TD align=right><INPUT TYPE="text" NAME="qtty" value=0></TD>
178</TR>
179<TR>
180	<TD align=left>���� ������ ����</TD>
181	<TD align=right><INPUT TYPE="text" NAME="Unit" value="���"</TD>
182</TR>
183<TR>
184	<TD align=left><INPUT TYPE="checkbox" NAME="outByOrder"></TD>
185	<TD align=right>���� �� ���� �����</TD>
186</TR>
187<TR>
188	<TD align=left></TD>
189	<TD align=right height=20>
190	<BR><INPUT TYPE="submit" NamE="submit" value="��� ������ ����"onclick="return validateForm()">
191	</TD>
192</TR>
193</TABLE>
194</FORM>
195
196<SCRIPT LANGUAGE="JavaScript">
197<!--
198function validateForm(){ 
199if (document.all.ItemName.value=="" || document.all.catItem.value=="" || document.all.OldItemID.value=="")
200	{
201		alert("���! ��� ���� �� ���� ���")
202		return false
203	}
204}
205
206function check(src){ 
207	badCode = false;
208	if (window.XMLHttpRequest) {
209		var objHTTP=new XMLHttpRequest();
210	} else if (window.ActiveXObject) {
211		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
212	}
213	objHTTP.open('GET','xml_MaxID4newItems.asp?id='+src.value,false)
214	objHTTP.send()
215	tmpStr = unescape(objHTTP.responseText)
216	document.all.OldItemID.value=tmpStr;
217}
218//-->
219</SCRIPT>
220
221
222<!--#include file="tah.asp" -->