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

/beta/inventory/changeOwner.asp

http://github.com/khaneh/Orders
ASP | 316 lines | 267 code | 37 blank | 12 comment | 39 complexity | 05591a36c9e815a360e1025c39a32a99 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><% 
  2'Inventory (5)
  3PageTitle= "������ ������"
  4SubmenuItem=11
  5if not Auth(5 , "B") 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'-----------------------------------------------------------------------------------------------------
 14'------------------------------------------------------------------------------------- Submit Trnasfer
 15'-----------------------------------------------------------------------------------------------------
 16if request("submit")="������" then
 17
 18	itemName	= sqlSafe(request.form("itemName"))
 19	itemID		= clng(request.form("itemID"))
 20	fromID		= clng(request.form("fromID"))
 21	toID		= clng(request.form("toID"))
 22	qtty		= cdbl(request.form("qtty"))
 23	accountName = sqlSafe(request.form("accountName"))
 24	comments	= sqlSafe(left(request.form("comments"),220))	' Max Size of the field is 250
 25	
 26	errorFound=false
 27	mySQL="SELECT SUM(sumQtty) AS sumQtty, AccountID FROM (SELECT SUM((CONVERT(tinyint, InventoryLog.IsInput) - .5) * 2 * InventoryLog.Qtty) AS sumQtty, InventoryLog.owner AS AccountID FROM InventoryLog WHERE (InventoryLog.ItemID = " & itemID & ") AND (InventoryLog.voided = 0) GROUP BY InventoryLog.owner) DERIVEDTBL GROUP BY AccountID HAVING (SUM(sumQtty) <> 0) AND (DERIVEDTBL.AccountID = " & fromID & ")"
 28	set RSS = Conn.Execute(mySQL)
 29	if not RSS.eof then
 30		currentQtty=cdbl(RSS("sumQtty"))
 31		if currentQtty < qtty then errorFound=true
 32	else
 33		errorFound=true
 34	end if
 35	RSS.close
 36
 37	if errorFound then
 38		Conn.close
 39		response.redirect "?errMsg="&Server.URLEncode("������ ���� ����.")
 40	end if
 41
 42	mySql="INSERT INTO InventoryLog (ItemID, RelatedID, logDate, Qtty, owner, CreatedBy, IsInput, comments, type) VALUES ("& itemID & ", -5 ,N'"& shamsiToday() & "', "& qtty & ", "& fromID & ", "& session("id") & ", 0, N'������ �� ����  " & toID & " (" & comments & ")', 5 )"
 43	conn.Execute mySql
 44	
 45	mySql="INSERT INTO InventoryLog (ItemID, RelatedID, logDate, Qtty, owner, CreatedBy, IsInput, comments, type) VALUES ("& itemID & ", -5 ,N'"& shamsiToday() & "', "& qtty & ", "& toID & ", "& session("id") & ", 1, N'������ �� ����  " & fromID & " (" & comments & ")', 5 )"
 46	conn.Execute mySql
 47	
 48	if fromID = "-1" then fromName = "���� �ǁ � ���" else fromName = fromID
 49	if toID = "-1" then toName = "���� �ǁ � ���" else toName = toID
 50
 51	response.write "<br><br>" 
 52	call showAlert ("������ " & qtty & " ��� " & itemName & " �� ���� " & fromName & " �� ���� " & toName & " ����� ��." , CONST_MSG_INFORM)
 53	response.end
 54
 55'-----------------------------------------------------------------------------------------------------
 56'--------------------------------------------------------------------------------------- Trnasfer Form
 57'-----------------------------------------------------------------------------------------------------
 58elseif request("submit")="�����" then
 59	
 60	if not isNumeric(request("oldItemID")) then
 61		response.write "<br>���!" 
 62		response.end
 63	end if 
 64
 65	set RSS=Conn.Execute ("SELECT * from inventoryItems where oldItemID = " & request("oldItemID") )
 66	id = RSS("id")
 67	set RSS=Conn.Execute ("SELECT SUM(DERIVEDTBL.sumQtty) AS sumQttys, DERIVEDTBL.AccountID, dbo.Accounts.AccountTitle FROM (SELECT SUM((CONVERT(tinyint, dbo.InventoryLog.IsInput) - .5) * 2 * dbo.InventoryLog.Qtty) AS sumQtty,  dbo.InventoryLog.owner AS AccountID FROM dbo.InventoryLog WHERE (dbo.InventoryLog.ItemID = " & id & " and dbo.InventoryLog.voided=0) GROUP BY dbo.InventoryLog.owner) DERIVEDTBL left outer JOIN dbo.Accounts ON DERIVEDTBL.AccountID = dbo.Accounts.ID GROUP BY DERIVEDTBL.AccountID, dbo.Accounts.AccountTitle having SUM(DERIVEDTBL.sumQtty)<>0")	
 68	%><BR><BR>
 69	<FORM METHOD=POST ACTION="?" onsubmit="return checkValidation();">
 70	<CENTER><H3>������</H3>	</CENTER>
 71	<TABLE align=center width=70%>
 72	<TR height=30>
 73		<TD align=left valign=top>��� ����:</TD>
 74		<TD align=right valign=top><b><%=request("accountName")%> <INPUT TYPE="hidden" name="itemName" value="<%=request("accountName")%>"><INPUT TYPE="hidden" name="itemID" value="<%=id%>"></b></TD>
 75	</TR>
 76	<TR>
 77		<TD align=left valign=top>�� ����: </TD>
 78		<TD align=right valign=top>
 79		
 80		<TABLE dir=rtl align=center width=100%>
 81		<TR bgcolor="eeeeee">
 82			<TD><INPUT TYPE="radio" NAME="" disabled></TD>
 83			<TD><SMALL>���</SMALL></A></TD>
 84			<TD align=center><!A HREF="default.asp?s=1"><SMALL>����� ����</SMALL></A></TD>
 85			<TD align=center><!A HREF="default.asp?s=3"><SMALL>�����</SMALL></A></TD>
 86		</TR>
 87		<%
 88		tmpCounter=0
 89		Do while not RSS.eof
 90			tmpCounter = tmpCounter + 1
 91			if tmpCounter mod 2 = 1 then
 92				tmpColor="#FFFFFF"
 93				tmpColor2="#FFFFBB"
 94			Else
 95				tmpColor="#FFFFFF"
 96				tmpColor2="#FFFFBB"
 97				'tmpColor="#DDDDDD"
 98				'tmpColor2="#EEEEBB"
 99			End if 
100
101		%>
102		<TR bgcolor="<%=tmpColor%>" height=25 style="cursor:hand" onclick="this.getElementsByTagName('input')[0].click();this.getElementsByTagName('input')[0].focus();">
103			<TD><INPUT TYPE="radio" NAME="fromID" value="<%=RSS("AccountID")%>"></TD>
104			<TD><%
105			if RSS("AccountID")="-1" then
106				response.write "���� �ǁ � ���" 
107			else
108				response.write RSS("AccountTitle")
109			end if %></TD>
110			<TD  align=center dir=ltr><%
111			if RSS("AccountID")="-1" then
112				response.write "-"
113			else
114				response.write RSS("AccountID")
115			end if %></TD>
116			<TD align=center dir=ltr><%=RSS("sumQttys")%></TD>
117		</TR>
118			  
119		<% 
120		RSS.moveNext
121		Loop
122		%>
123		</TABLE><br>
124		</TD>
125	</TR>
126	<TR height=30>
127		<TD align=left valign=top>�� ����: </TD>
128		<TD align=right valign=top>
129		<SELECT NAME="aaa2"  onchange="hideIT()">
130		<option value=1 >���� �ǁ � ���</option>
131		<option value=2>������ (����� ����)</option>
132
133		</SELECT>
134		<span name="aaa1"  id="aaa1" style="visibility:'hidden'">
135		<input type="hidden" Name='tmpDlgArg' value=''>
136		<input type="hidden" Name='tmpDlgTxt' value=''>
137		<INPUT  dir="LTR"  TYPE="text" NAME="toID" maxlength="10" size="13"  value="-1" onKeyPress='return mask(this);' onBlur='check(this);'> &nbsp;&nbsp; <INPUT TYPE="text" NAME="accountName" size=30 readonly  value="<%=accountName%>" style="background-color:transparent">
138		</span><br></TD>
139	</TR>
140	<TR height=30>
141		<TD align=left  valign=top>�����:</TD>
142		<TD align=right valign=top><INPUT dir=ltr TYPE="text" NAME="qtty" size=25 value="<%=preQtty%>" ><!onKeyPress="return maskNumber(this);" ><br><br></TD>
143	</TR>
144	<TR>
145		<TD align=left valign=top>�������</TD>
146		<TD align=right>
147			<TEXTAREA NAME="comments" ROWS="4" COLS="" style="width:100%"></TEXTAREA><br><br>
148		</TD>
149	</TR>
150	<TR>
151		<TD align=left valign=top></TD>
152		<TD align=center valign=top><INPUT TYPE="submit" name="submit" value="������"></TD>
153	</TR>
154	</TABLE>
155	</FORM>
156<SCRIPT LANGUAGE="JavaScript">
157<!--
158function checkValidation(){
159	found = false;
160	len = document.getElementsByName('fromID').length
161	for (i = 0; i <len; i++) {
162		if (document.getElementsByName('fromID')[i].checked) {
163			found = true;
164		}
165	}
166	if ( !found )
167	{
168		alert('���� ���� �� ������ ����');
169		document.getElementsByName('fromID')[0].focus()
170		return false;
171	}
172
173	if( !(parseFloat(document.getElementsByName('qtty')[0].value)>0) )
174	{
175		alert('����� �� ���� ����');
176		document.getElementsByName('qtty')[0].focus();
177		return false;
178	}
179
180	if(document.getElementsByName('comments')[0].value.length>220)
181	{
182		alert('��� ���� ������� ���� ��� \n\n������ 220 (������ 4 �� ��) �� ����� ����');
183		document.getElementsByName('comments')[0].focus();
184		return false;
185	}
186
187	return true;
188}
189
190var dialogActive=false;
191
192function mask(src){ 
193	var theKey=event.keyCode;
194
195	if (theKey==13){
196		event.keyCode=9
197		dialogActive=true
198		document.all.tmpDlgArg.value="#"
199		document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ������:"
200		var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
201		if (document.all.tmpDlgTxt.value !="") {
202			var myTinyWindow = window.showModalDialog('../ar/dialog_selectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
203			dialogActive=false
204			if (document.all.tmpDlgArg.value!="#"){
205				Arguments=document.all.tmpDlgArg.value.split("#")
206				src.value=Arguments[0];
207				document.all.accountName.value=Arguments[1];
208			}
209		}
210	}
211}
212
213function check(src){ 
214	if (!dialogActive){
215		badCode = false;
216		if (window.XMLHttpRequest) {
217			var objHTTP=new XMLHttpRequest();
218		} else if (window.ActiveXObject) {
219			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
220		}
221		objHTTP.open('GET','../accounting/xml_CustomerAccount.asp?id='+src.value,false)
222		objHTTP.send()
223		tmpStr = unescape(objHTTP.responseText)
224		document.all.accountName.value=tmpStr;
225		}
226}
227
228function hideIT()
229{
230//alert(document.all.aaa2.value)
231if(document.all.aaa2.value==2) 
232	{
233		document.all.aaa1.style.visibility= 'visible'
234		document.all.toID.value = ""
235		document.all.toID.focus()
236	}
237	else
238	{
239		document.all.aaa1.style.visibility= 'hidden'
240		document.all.toID.value = "-1"
241	}
242}
243
244//-->
245</SCRIPT>
246	<%
247
248	response.end
249end if
250
251
252'-----------------------------------------------------------------------------------------------------
253'------------------------------------------------------------------------------ Search Form
254'-----------------------------------------------------------------------------------------------------
255
256
257if request("catItem") = "" then
258	%><BR>
259	<FORM METHOD=POST ACTION=""><BR><center>
260		<INPUT TYPE="hidden" name="radif" value="-1">
261		<input type="hidden" Name='tmpDlgArg' value=''>
262		<input type="hidden" Name='tmpDlgTxt' value=''>
263		 �� ���� �� ���� ����:   &nbsp;&nbsp;&nbsp;<INPUT  dir="LTR"  TYPE="text" NAME="oldItemID" maxlength="10" size="13"   onKeyPress='return mask(this);' onBlur='check(this);'> &nbsp;&nbsp; <INPUT TYPE="text" NAME="accountName" size=30 readonly  value="<%=accountName%>" style="background-color:transparent">
264		&nbsp;&nbsp;<INPUT TYPE="submit" Name="Submit" Value="�����"  style="width:80px;" tabIndex="14">
265		</center>
266	</FORM>
267	<SCRIPT LANGUAGE="JavaScript">
268	<!--
269	document.all.oldItemID.focus()
270	var dialogActive=false;
271
272	function mask(src){ 
273		var theKey=event.keyCode;
274
275		if (theKey==13){
276			event.keyCode=9
277			dialogActive=true
278			document.all.tmpDlgArg.value="#"
279			document.all.tmpDlgTxt.value="����� �� ������� �����"
280			var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
281			if (document.all.tmpDlgTxt.value !="") {
282				var myTinyWindow = window.showModalDialog('dialog_selectInvItem.asp?act=select&name='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
283				dialogActive=false
284				if (document.all.tmpDlgArg.value!="#"){
285					Arguments=document.all.tmpDlgArg.value.split("#")
286					src.value=Arguments[0];
287					document.all.accountName.value=Arguments[1];
288				}
289			}
290		}
291	}
292
293	function check(src){ 
294		if (!dialogActive){
295			badCode = false;
296			if (window.XMLHttpRequest) {
297				var objHTTP=new XMLHttpRequest();
298			} else if (window.ActiveXObject) {
299				var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
300			}
301			objHTTP.open('GET','xml_InventoryItem.asp?id='+src.value,false)
302			objHTTP.send()
303			tmpStr = unescape(objHTTP.responseText)
304			document.all.accountName.value=tmpStr;
305			}
306	}
307
308
309	//-->
310	</SCRIPT>
311
312	<%
313end if
314%>
315
316	<!--#include file="tah.asp" -->