PageRenderTime 28ms CodeModel.GetById 13ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/beta/Inquiry/MemoInput.asp

http://github.com/khaneh/Orders
ASP | 254 lines | 227 code | 18 blank | 9 comment | 17 complexity | 0f4387e4b4f2034a5d64023a55ddc8b6 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'AR (6)
  3PageTitle="���� ���"
  4SubmenuItem=2
  5if not Auth(6 , 2) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<%
 12function Link2Trace(OrderNo)
 13	Link2Trace="<A HREF='../order/orderEdit.asp?e=n&radif="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
 14end function
 15
 16%>
 17<HTML>
 18<HEAD>
 19<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
 20<meta http-equiv="Content-Language" content="fa">
 21<style>
 22	.MmoTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; direction: right-to-left;}
 23	.MmoMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
 24	.MmoMainTableTH { background-color: #C3C300;}
 25	.MmoMainTableTR { background-color: #CCCC88; border: 0; }
 26	.MmoRowInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 27	.MmoRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 28	.MmoHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 29	.MmoHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 30	.MmoHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
 31	.MmoGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
 32	.GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 33</style>
 34<TITLE>���� ���</TITLE>
 35</HEAD>
 36<SCRIPT LANGUAGE="JavaScript">
 37<!--
 38var okToProceed=false;
 39var currentRow=null;
 40//-->
 41</SCRIPT>
 42<BODY bgcolor="#F0F0F0">
 43<font face="tahoma">
 44<%
 45
 46if request("act")="submitsearch" then
 47	if request("CustomerNameSearchBox") <> "" then
 48		SA_TitleOrName=request("CustomerNameSearchBox")
 49		SA_Action="return true;"
 50		SA_SearchAgainURL="MemoInput.asp"
 51		SA_StepText="��� ��� : ������ ����"
 52%>
 53		<FORM METHOD=POST ACTION="MemoInput.asp?act=getMemo">
 54		<!--#include File="include_SelectAccount.asp"-->
 55		</FORM>
 56<%
 57	end if
 58elseif request("act")="selectOrder" then
 59	if request("selectedCustomer") <> "" then
 60		SO_Customer=request("selectedCustomer")
 61		SO_Action="return true;"
 62		SO_StepText="��� ��� :"
 63%>
 64		<FORM METHOD=POST ACTION="MemoInput.asp?act=getMemo">
 65		<!--#include File="include_SelectOrder.asp"-->
 66		</FORM>
 67<%
 68	end if
 69elseif request("act")="getMemo" then
 70	customerID=request("selectedCustomer")
 71
 72	mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
 73	Set RS1 = conn.Execute(mySQL)
 74	AccountNo=RS1("ID")
 75	customerName=RS1("AccountTitle")
 76	
 77	creationDate=shamsiToday()
 78	creationTime=time
 79'	creationTime=Hour(creationTime)&":"&Minute(creationTime)
 80'	if instr(creationTime,":")<3 then creationTime="0" & creationTime
 81'	if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
 82
 83%><BR><BR><BR>
 84	<div align=center dir='rtl'><B>��� ����� : ���� ������� ���</B>
 85	</div>
 86<!--  ���� ������� ��� -->
 87	<br>
 88	<input type="hidden" Name='tmpDlgArg' value=''>
 89		<table class="MmoMainTable" Cellspacing="1" Cellpadding="5" Width="500" align="center">
 90		<FORM METHOD=POST ACTION="MemoInput.asp?act=submitMemo" onsubmit="if (document.all.AccountTitle.value=='') return false;">
 91			<tr class="MmoMainTableTH">
 92			<TD colspan="10"><TABLE class="MmoTable" Border="0" Width="100%" Cellspacing="1" Cellpadding="0"><TR>
 93				<TD align="left">����:</TD>
 94				<TD align="right" width="5">
 95					<INPUT class="MmoGenInput" disabled TYPE="text" value="<%=customerID%>" maxlength="5" size="5" tabIndex="1">
 96				</TD>
 97				<TD align="right">
 98					<INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><%=CustomerName%>.
 99				</TD>
100				<TD align="left">�����:</TD>
101				<TD><TABLE class="MmoTable">
102					<TR>
103						<TD dir="LTR">
104							<INPUT class="MmoGenInput" style="text-align:left;" NAME="MemoDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>" onblur="acceptDate(this)">
105						</TD>
106						<TD dir="RTL"><%=weekdayname(weekday(date))%></TD>
107					</TR>
108					</TABLE></TD>
109				</TR></TABLE></TD>
110			</tr>
111			<tr class="MmoMainTableTH" height="25">
112				<TD> ��� ��� </TD>
113				<TD> ������/�������� </TD>
114				<TD> ��� </TD>
115				<TD> ����� </TD>
116			</tr>
117			<tr class="MmoMainTableTR">
118				<TD valign="top">
119				<SELECT class="MmoRowInput" NAME="MemoType">
120				<%
121				mySQL="SELECT * FROM AXMemoTypes WHERE Display=1"
122				Set RS1=conn.execute(mySQL)
123				while not RS1.eof
124				%>
125					<OPTION Value="<%=RS1("ID")%>"><%=RS1("Name")%></OPTION>
126				<%
127				RS1.moveNext
128				wend
129				%>
130				</SELECT>
131				</TD>
132				<TD valign="top">
133				<SELECT class="MmoRowInput" NAME="IsCredit">
134					<OPTION Value="0">������</OPTION>
135					<OPTION Value="1" selected >��������</OPTION>
136				</SELECT>
137				</TD>
138				<TD valign="top"><TEXTAREA class="MmoRowInput" dir="RTL" NAME="Description" ROWS="3" COLS="30"></TEXTAREA></TD>
139				<TD valign="top"><INPUT class="MmoRowInput" Dir="LTR" NAME="Amount" TYPE="text" size="15" onblur="setPrice(this);" onKeyPress="return mask(this);"></TD>
140			</tr>
141		</table><br>
142		<TABLE class="MmoTable" align=center Border="0" Cellspacing="5" Cellpadding="1">
143		<tr>
144			<td align='center' bgcolor="#000000"><INPUT class="MmoGenInput" style="text-align:center" TYPE="button" value="�����" onclick="submit();"></td>
145			<td align='center' bgcolor="#000000"><INPUT class="MmoGenInput" style="text-align:center" TYPE="button" value="������" onclick="window.location='MemoInput.asp';"></td>
146		</tr>
147		</TABLE>
148		</FORM>
149		<SCRIPT LANGUAGE="JavaScript">
150		<!--
151//			document.all.CashAmount.focus();
152		//-->
153		</SCRIPT>
154
155<%elseif request("act")="submitMemo" then
156
157	ON ERROR RESUME NEXT
158		MemoDate=	sqlSafe(request.form("MemoDate"))
159		CustomerID=	clng(request.form("CustomerID"))
160		Amount=		cdbl(text2value(request.form("Amount")))
161		Description=sqlSafe(request.form("Description"))
162		MemoType=	cint(request.form("MemoType"))
163
164		IsCredit=	cbool(request.form("IsCredit"))
165		if IsCredit then IsCredit=1 else IsCredit=0 end if
166		if Err.Number<>0 then
167			Err.clear
168			conn.close
169			response.redirect "top.asp?errMsg=" & Server.URLEncode("���!")
170		end if
171	ON ERROR GOTO 0
172
173	'---- Checking wether EffectiveDate is valid in current open GL
174	if (MemoDate < session("OpenGLStartDate")) OR (MemoDate > session("OpenGLEndDate")) then
175		Conn.close
176		response.redirect "?act=getMemo&selectedCustomer="& CustomerID & "&errMsg=" & Server.URLEncode("���!<br>����� ���� ��� �� ������ ��� ���� ���� ����.")
177	end if 
178	'----
179
180	creationDate=	shamsiToday()
181
182	GLAccount=		"91001"	'This must be changed... (Sales A)
183	firstGLAccount=	"13003"	'This must be changed... (Business Debitors)
184
185	mySQL="INSERT INTO ARMemo (CreatedDate, CreatedBy, Account, Type, IsCredit, Description, Amount) VALUES (N'" &_
186	MemoDate & "', '"& session("ID") & "', '"& CustomerID & "', '"& MemoType & "', '"& IsCredit & "', N'"& Description & "', '"& Amount & "');SELECT @@Identity AS NewMemo"
187	Set RS1 = conn.Execute(mySQL).NextRecordSet
188	MemoID=RS1("NewMemo")
189	RS1.close
190
191	'**************************** Creating ARItem for Memo  ****************
192	'*** Type = 3 means ARItem is a Memo
193	
194	mySQL="INSERT INTO ARItems (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, IsCredit, Type, Link, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount) VALUES ('" &_
195	GLAccount & "', '"& OpenGL & "', '"& firstGLAccount & "', '"& CustomerID & "', N'"& MemoDate & "', '"& IsCredit & "', '3', '"& MemoID & "', '"& Amount & "', N'"& creationDate & "', '"& session("ID") & "', '"& Amount & "')"	
196	conn.Execute(mySQL)
197	'***------------------------- Creating ARItem for Memo  ----------------
198	if IsCredit then
199		mySQL="UPDATE Accounts SET ARBalance = ARBalance + '"& Amount & "' WHERE (ID='"& CustomerID & "')"
200	else
201		mySQL="UPDATE Accounts SET ARBalance = ARBalance - '"& Amount & "' WHERE (ID='"& CustomerID & "')"
202	end if
203	conn.Execute(mySQL)
204	conn.close
205	response.redirect "AccountReport.asp?act=showMemo&sys=AR&memo=" & MemoID &"&msg=" & Server.URLEncode("������� ��� ��.")
206else%>
207<!-- ����� ���� ��� ���� -->
208	<FORM METHOD=POST ACTION="MemoInput.asp?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;"><BR><BR>
209	<div dir='rtl'>&nbsp;<B>��� ��� : ����� ���� ��� ����</B>
210		<INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
211		<INPUT class="GenButton" TYPE="submit" value="�����"><br>
212	</div>
213	</FORM>
214	<SCRIPT LANGUAGE="JavaScript">
215	<!--
216		document.all.CustomerNameSearchBox.focus();
217	//-->
218	</SCRIPT>
219<%
220end if
221conn.Close
222%>
223</font>
224</BODY>
225</HTML>
226<% if request("act")="getMemo" then %>
227<script language="JavaScript">
228<!--
229function delRow(rowNo){
230	chqTable=document.getElementById("ChequeLines");
231	theRow=chqTable.getElementsByTagName("tr")[rowNo];
232	chqTable.removeChild(theRow);
233
234	for (rowNo=0; rowNo < document.getElementsByName("ChequeNos").length; rowNo++){
235		chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0].innerText= rowNo+1;
236	}
237}
238
239function setPrice(src){
240	src.value=val2txt(txt2val(src.value));
241}
242
243function mask(src){ 
244	var theKey=event.keyCode;
245	if (theKey==13){
246		return true;
247	}
248	else if (theKey < 48 || theKey > 57) { // 0-9 are acceptible
249		return false;
250	}
251}
252//-->
253</script>
254<%end if%>