PageRenderTime 37ms CodeModel.GetById 26ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/beta/inventory/report.asp

http://github.com/khaneh/Orders
ASP | 320 lines | 274 code | 33 blank | 13 comment | 50 complexity | e643d05a746e91e4dd64be957a82650c MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Inventory (5)
  3PageTitle= " ����� ���� � ���� �� �����"
  4SubmenuItem=5
  5if not Auth(5 , 5) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<%
 12fromDate = request("fromDate") 
 13toDate = request("toDate") 
 14InRep = request("InRep") 
 15outRep = request("outRep") 
 16
 17if inRep="" then
 18	InRepSt = " "
 19else
 20	InRepSt = "checked"
 21end if
 22
 23if outRep="" then
 24	outRepSt = " "
 25else
 26	outRepSt = "checked"
 27end if
 28
 29if toDate="" or fromDate="" then
 30	toDate = shamsiToday()
 31	fromDate = shamsiDate(Date())
 32	InRepSt = "checked"
 33	outRepSt = "checked"
 34	flag = "first"
 35end if
 36
 37
 38'-----------------------------------------------------------------------------------------------------
 39'------------------------------------------------------------------------------------- Delete Log Line
 40'-----------------------------------------------------------------------------------------------------
 41if request("act") = "del" and isNumeric(request("rowID")) then
 42	rowID = clng(request("rowID"))
 43	desc = request("desc") ' Description : Deletion Reason
 44	if "" & desc = "" then
 45		desc = "-"
 46	else
 47		desc = sqlSafe(desc)
 48	end if
 49
 50	set RSS=Conn.Execute ("SELECT * from InventoryLog where (ID = " & rowID & ") and voided = 0")
 51	if RSS.EOF then
 52		response.write "<br><br>" 
 53		call showAlert ("���! ���� ���� ����� ���� �� ���� ��� ��� ���." , CONST_MSG_ERROR)
 54	else
 55		if rss("gl_update")="1" then 
 56			response.write "<br><br>" 
 57			call showAlert ("���! ���� ��� ��� ���� ��� �������� ���� ���� ���� ���� ���� �� ��� �� ������!." , CONST_MSG_ERROR)
 58		else
 59			type1 = RSS("type")
 60			RelatedID = RSS("RelatedID")
 61			isInput = RSS("isInput")
 62	
 63			if type1 = 1 and not isInput then
 64				Conn.Execute ("UPDATE InventoryPickuplists SET Status = 'new' WHERE (id = " & RelatedID & ")")
 65				response.write "<br><br>" 
 66				call showAlert ("����� ���� ������ �� �� ����� ���� ��Ґ��." , CONST_MSG_INFORM)
 67			end if
 68	
 69			if (not isInput) and (RelatedID > 0) then
 70				set RSB=Conn.Execute ("SELECT id from InventoryLog where (RelatedID = " & RelatedID & " and isInput=0) and voided = 0 ")
 71				Do while not RSB.eof
 72					Conn.Execute ("UPDATE InventoryLog SET Voided =1, VoidedBy =" & session("id") & ", VoidedDate =N'" & shamsiToday() & "', comments = LEFT(comments + '<br>[���� ���: " & desc & "]', 250) WHERE (ID = " & RSB("id") & ")")
 73					RSB.movenext
 74				loop
 75			else
 76				Conn.Execute ("UPDATE InventoryLog SET Voided =1, VoidedBy =" & session("id") & ", VoidedDate =N'" & shamsiToday() & "', comments = LEFT(comments + '<br>[���� ���: " & desc & "]', 250) WHERE (ID = " & rowID & ") AND (voided = 0)")
 77			end if 
 78	
 79			response.write "<br><br>" 
 80			call showAlert ("��� ��� ����� ��." , CONST_MSG_INFORM)
 81			Conn.Execute("update InventoryLog set price=null, pricedQtty=null where isInput=0 and owner=-1 and voided=0 and itemID=" & rss("itemID"))
 82			Conn.Execute("update InventoryLog set pricedQtty = qtty where isInput=1 and owner=-1 and voided=0 and itemID=" & rss("itemID"))
 83			Conn.Execute("delete from InventoryFIFORelations where inID in (select id from InventoryLog where isInput=1 and owner=-1 and voided=0 and itemID=" & rss("itemID")) &")"
 84			Conn.Execute("delete from InventoryFIFORelations where outID in (select id from InventoryLog where isInput=0 and owner=-1 and voided=0 and itemID=" & rss("itemID")) &")"
 85			'Conn.Execute("execute dbo.outFIFO")
 86		end if
 87	end if
 88
 89end if
 90'-----------------------------------------------------------------------------------------------------
 91'---------------------------------------------------------------------- Inventory Transaction Log Form
 92'-----------------------------------------------------------------------------------------------------
 93%>
 94<BR><BR>
 95<FORM METHOD=POST ACTION="report.asp">
 96<TABLE border=0 align=center>
 97<TR>
 98	<TD colspan=5 align=center><H3>����� ������ �����</H3></TD>
 99</TR>
100<TR>
101	<TD align=left>�� �����</TD>
102	<TD align=right><INPUT TYPE="text" NAME="fromDate" value="<%=fromDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
103	<TD align=left width=20></TD>
104	<TD align=left>�� �����</TD>
105	<TD align=right><INPUT TYPE="text" NAME="toDate" value="<%=toDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
106</TR>
107
108<TR height=10>
109	<TD colspan=5 align=center></TD>
110</TR>
111
112<TR>
113	<TD align=left></TD>
114	<TD align=right><INPUT TYPE="checkbox" NAME="outRep" <%=outRepSt%>> ���� ����</TD>
115	<TD align=left width=20><INPUT TYPE="checkbox" NAME="InRep" <%=inRepSt%>></TD>
116	<TD align=left>���� ����</TD>
117	<TD align=left><INPUT TYPE="submit" NAME="submit" class=inputBut value="������"></TD>
118</TR>
119
120</TABLE>
121</FORM>
122<%
123if flag = "first" then
124	response.end
125end if
126
127'-----------------------------------------------------------------------------------------------------
128'------------------------------------------------------------------------------------- Transaction Log
129'-----------------------------------------------------------------------------------------------------
130
131if request("submit")="������"then
132
133	%>
134	<TABLE dir=rtl align=center width=95%>
135	<%
136
137	if outRep = "on" then
138'		mySQL="SELECT InventoryLog.ID, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedBy, InventoryLog.VoidedDate, InventoryItems.Unit, InventoryItems.Name, InventoryItems.OldItemID, InventoryLog.logDate, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryLog.type, InventoryLog.CreatedBy, InventoryLog.owner, Users.RealName, Users_1.RealName AS GiveTo FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID INNER JOIN InventoryPickuplists ON InventoryLog.RelatedID = InventoryPickuplists.id INNER JOIN Users Users_1 ON InventoryPickuplists.GiveTo = Users_1.ID WHERE (InventoryLog.logDate >= N'"& fromDate & "' and InventoryLog.logDate <= N'"& toDate & "' and IsInput=0) ORDER BY InventoryLog.ID DESC"
139
140		mySQL="SELECT InventoryLog.ID, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedDate, InventoryItems.Unit, InventoryItems.Name, InventoryItems.OldItemID, InventoryLog.logDate, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryLog.type, InventoryLog.CreatedBy, InventoryLog.owner, Users.RealName, Users_1.RealName AS GiveTo, Users_2.RealName AS VoidedBy, InventoryFIFORelations.inID,InventoryFIFORelations.qtty as inQtty FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID left outer JOIN InventoryPickuplists ON InventoryLog.RelatedID = InventoryPickuplists.id and InventoryLog.RelatedID>0 left outer JOIN Users Users_1 ON InventoryPickuplists.GiveTo = Users_1.ID LEFT OUTER JOIN Users Users_2 ON InventoryLog.VoidedBy = Users_2.ID left outer join InventoryFIFORelations on inventoryLog.id = InventoryFIFORelations.outID WHERE (InventoryLog.logDate >= N'"& fromDate & "') AND (InventoryLog.logDate <= N'"& toDate & "') AND (InventoryLog.IsInput = 0) ORDER BY InventoryLog.ID DESC"
141'response.write mySQL
142		set RSS=Conn.Execute (mySQL)	
143		%>
144		<TR bgcolor="eeeeee" >
145			<TD colspan=9><H4>���� ����</H4></TD>
146		</TR>
147		<TR bgcolor="eeeeee" >
148			<TD>���</TD>
149			<TD>������</TD>
150			<TD width=200>��� ����</TD>
151			<TD>����� </TD>
152			<TD>����</TD>
153			<TD>����� ����</TD>
154			<TD>������</TD>
155			<TD align=center>����� �����</TD>
156			<TD>����</TD>
157		</TR>
158		<%
159		tmpCounter=0
160		Do while not RSS.eof
161			tmpCounter = tmpCounter + 1
162			if tmpCounter mod 2 = 1 then
163				tmpColor="#FFFFFF"
164				tmpColor2="#FFFFBB"
165			Else
166				tmpColor="#DDDDDD"
167				tmpColor2="#EEEEBB"
168			End if 
169
170		%>
171		<TR bgcolor="<%=tmpColor%>" style="height:25pt" <% if RSS("voided") then%> disabled title="��� ��� �� ����� <%=RSS("VoidedDate")%> ���� <%=RSS("VoidedBy")%>"<% end if %>>
172			<TD align=center dir=ltr><small disabled><%=RSS("id")%></small><% if not RSS("voided") then%><A HREF="javascript:confirmDelete(<%=RSS("ID")%>);">X</A> <% end if %></TD>
173			<TD align=right dir=ltr><INPUT TYPE="hidden" name="id" value="<%=RSS("ID")%>"><A HREF="invReport.asp?oldItemID=<%=RSS("oldItemID")%>&logRowID=<%=RSS("ID")%>" target="_blank"><%=RSS("OldItemID")%></A></TD>
174			<TD><% if RSS("voided") then%><div style="position:absolute;width:520;"><hr style="color:red;"></div><% end if %><!A HREF="default.asp?itemDetail=<%=RSS("ID")%>"><span style="font-size:10pt"><%=RSS("Name")%></A></TD>
175			<TD align=right dir=ltr><span style="font-size:10pt"><%=RSS("Qtty")%></span></TD>
176			<TD align=right dir=ltr><%=RSS("Unit")%></TD>
177			<TD dir=ltr><%=RSS("logDate")%></span></TD>
178			<TD><%=RSS("GiveTo")%></TD>
179			<TD align=center><% 
180					if RSS("type")= "2" then
181						response.write "<font color=red><b>����� ������</b></font>"
182					elseif RSS("type")= "5" then
183						response.write "<font color=orang><b>������</b></font>"
184				 else %>
185			<A HREF="default.asp?ed=<%=RSS("RelatedID")%>"><%=RSS("RelatedID")%></A>
186				<% end if %>
187				<% if RSS("owner")<> "-1" and RSS("owner")<> "-2" then
188					response.write " (������ <a href='../CRM/AccountInfo.asp?act=show&selectedCustomer="& RSS("owner") &"' target='_blank'> " & RSS("owner") & "</a>)"
189				 end if %>
190				<% if RSS("comments")<> "-" and RSS("comments")<> "" then
191					response.write " <br><br><B>�����:</B> " & RSS("comments") 
192				 end if 
193				 if not isNull(rss("inID")) then 
194				 	response.write("<br>���� ����� ����" & rss("inQtty") & " �� ���� <b>" & rss("inID") & "</b>")
195				 else
196				 	response.write("<br><b>���� ����� ����!</b>")
197				 end if
198				 %>
199
200			</TD>
201			<TD><%=RSS("RealName")%></TD>
202		</TR>
203			 
204		<% 
205		RSS.moveNext
206		Loop
207	end if
208
209	if inRep = "on" then
210
211		mySQL="SELECT InventoryLog.RelatedInvoiceID, InventoryLog.ID, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedDate, InventoryLog.CreatedBy, InventoryLog.owner, InventoryLog.logDate, InventoryLog.type, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryItems.OldItemID, InventoryItems.Name, InventoryItems.Unit, Users.RealName, Users_1.RealName AS VoidedBy, InventoryFIFORelations.outID, InventoryFIFORelations.qtty as outQtty FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID LEFT OUTER JOIN Users Users_1 ON InventoryLog.VoidedBy = Users_1.ID left outer join InventoryFIFORelations on inventoryLog.id = InventoryFIFORelations.inID WHERE (InventoryLog.logDate >= N'"& fromDate & "') AND (InventoryLog.logDate <= N'"& toDate & "') AND (InventoryLog.IsInput = 1) ORDER BY InventoryLog.ID DESC"
212
213		set RSS=Conn.Execute (mySQL)	
214
215		%>
216		<TR height=50>
217			<TD colspan=9></TD>
218		</TR>
219		<TR bgcolor="eeeeee" >
220			<TD colspan=9><H4>���� ����</H4></TD>
221		</TR>
222		<TR bgcolor="eeeeee" >
223			<TD> ��� </TD>
224			<TD>������</TD>
225			<TD width=200>��� ����</TD>
226			<TD>����� </TD>
227			<TD>����</TD>
228			<TD>����� ����</TD>
229			<TD colspan=2 align=center>�������</TD>
230			<TD>����</TD>
231		</TR>
232		<%
233		tmpCounter=0
234		Do while not RSS.eof
235			tmpCounter = tmpCounter + 1
236			if tmpCounter mod 2 = 1 then
237				tmpColor="#FFFFFF"
238				tmpColor2="#FFFFBB"
239			Else
240				tmpColor="#DDDDDD"
241				tmpColor2="#EEEEBB"
242			End if 
243
244		%>
245		<TR bgcolor="<%=tmpColor%>" style="height:25pt" <% if RSS("voided") then%> disabled title="��� ��� �� ����� <%=RSS("VoidedDate")%> ���� <%=RSS("VoidedBy")%>"<% end if %>>
246			<TD align=center dir=ltr><% if not RSS("voided") then%><A HREF="javascript:confirmDelete(<%=RSS("ID")%>);">X</A> <small disabled><%=RSS("id")%></small><% end if %></TD>
247			<TD align=right dir=ltr><INPUT TYPE="hidden" name="id" value="<%=RSS("ID")%>"><A HREF="invReport.asp?oldItemID=<%=RSS("oldItemID")%>&logRowID=<%=RSS("ID")%>" target="_blank"><%=RSS("OldItemID")%></A</TD>
248			<TD><% if RSS("voided") then%><div style="position:absolute;width:520;"><hr style="color:red;"></div><% end if %><!A HREF="default.asp?itemDetail=<%=RSS("ID")%>"><span style="font-size:10pt"><%=RSS("Name")%></A></TD>
249			<TD align=right dir=ltr><span style="font-size:10pt"><%=RSS("Qtty")%></span></TD>
250			<TD align=right dir=ltr><%=RSS("Unit")%></TD>
251			<TD dir=ltr><%=RSS("logDate")%></span></TD>
252			<TD colspan=2 align=center><% if RSS("type")= "1" and RSS("RelatedID")<> "-1" then
253					%>
254						����� ���� 
255				 <A HREF="../purchase/outServiceTrace.asp?od=<%=RSS("RelatedID")%>"><%=RSS("RelatedID")%></A>
256				 <%
257				 elseif RSS("type")= "2" then
258					response.write "<font color=red><b>����� ������</b></font>"
259				 elseif RSS("type")= "3" then
260					response.write "<font color=green><b>������</b></font> (����� ������ :<font color=green> "& RSS("RelatedInvoiceID") & "</font>)"
261					elseif RSS("type")= "4" then
262						response.write "<font color=blue><b>����� ����� ���� </b></font>"
263					elseif RSS("type")= "5" then
264						response.write "<font color=orang><b>������</b></font>"
265					elseif RSS("type")= "6" then
266						response.write "<font color=#6699CC><b>���� �� �����</b></font>"
267					elseif RSS("type")= "7" then
268						response.write "<font color=#FF9966><b>���� �� ����� ������</b></font>"
269					elseif RSS("type")="9" then 
270						response.write "<font color=#AAAA00><b>���� ������</b></font>"
271				 else 
272					response.write " "
273				 end if	%>
274				 
275				<% if RSS("owner")<> "-1" and RSS("owner")<> "-2" then
276					response.write " (������ <a href='../CRM/AccountInfo.asp?act=show&selectedCustomer="& RSS("owner") &"' target='_blank'> " & RSS("owner") & "</a>)"
277				 end if %>
278				<% if RSS("comments")<> "-" and RSS("comments")<> "" then
279					response.write " <br><br><B>�����:</B> " & RSS("comments") 
280				 end if 
281				 if not isNull(rss("outID")) then 
282				 	response.write("<br>���� ����� ����" & rss("outQtty") & " �� ����<b> " & rss("outID") & "</b>")
283				 else
284				 	response.write("<br><b>���� ����� ����!</b>")
285				 end if
286				 %>
287				 </TD>
288			<TD dir='LTR' align='right'><%=RSS("RealName")%></TD>
289		</TR>
290			 
291<% 
292		RSS.moveNext
293		Loop
294	end if
295%>
296	</TABLE><br>
297	<SCRIPT LANGUAGE="JavaScript">
298	<!--
299	function confirmDelete(rowID){
300		if (confirm('��� ����� ����Ͽ')){
301
302			var desc='';
303			var tmpDlgTxt= new Object();
304			tmpDlgTxt.value = '������ �� ��� �����: ';
305
306			dialogActive=true
307			window.showModalDialog('../dialog_GenInput.asp',tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
308			dialogActive=false
309			desc=tmpDlgTxt.value
310			window.location = "?act=del&rowID=" + rowID + "&desc=" + escape(desc);
311		}
312	}
313	//-->
314	</SCRIPT>
315<%
316
317end if
318%>
319
320<!--#include file="tah.asp" -->