PageRenderTime 27ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/bank/submitDraft.asp

http://github.com/khaneh/Orders
ASP | 327 lines | 263 code | 35 blank | 29 comment | 28 complexity | 9901a45bc1accce3ed0730b8c59fa99f MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Bank (10 [=A])
  3PageTitle= "��� ����� ����"
  4SubmenuItem=4
  5if not Auth("A" , 4) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<style>
 12	.GenInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; text-align:right; }
 13	.GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 14</style>
 15
 16<BR><BR>
 17<%
 18'-----------------------------------------------------------------------------------------------------
 19'---------------------------------------------------------------------------------- Submit Transaction
 20'-----------------------------------------------------------------------------------------------------
 21if request("act")="submit" then
 22
 23	ON ERROR RESUME NEXT
 24		errorFound=	false
 25		CustomerID=		clng(request.form("CustomerID"))
 26		Amount=			cdbl(text2value(request.form("Amount")))
 27		bank =			cint(request.form("Bank"))
 28		ReceiptNo =		clng(request.form("ReceiptNo"))
 29		Reason=			cint(request.form("Reason"))
 30
 31		if Err.Number<>0 then
 32			Err.clear
 33			errorFound=	true
 34			errorMsg=	Server.URLEncode("���!")
 35		end if
 36
 37		if NOT errorFound then
 38			effectiveDate=	sqlSafe(request.form("ReceiptDate"))
 39
 40			'---- Checking wether CustomerID is valid 
 41			mySQL="SELECT ID FROM Accounts WHERE (ID="& CustomerID & ")"
 42			Set RS1=Conn.execute(mySQL)
 43			if RS1.eof then
 44				conn.close
 45				response.redirect "?errMsg=" & Server.URLEncode("���!<br>����� ���� ["& CustomerID & "] ���� �����.")
 46			end if
 47			RS1.close
 48			'----
 49
 50			'---- Checking wether EffectiveDate is valid in current open GL
 51			if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then
 52				errorFound=	true
 53				errorMsg=	Server.URLEncode("���!<br>����� ���� ��� ����� ����.")
 54			end if 
 55			'----
 56			'----- Check GL is closed
 57			if (session("IsClosed")="True") then
 58				'Conn.close
 59				errorFound=true
 60				errorMsg=Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 61			end if 
 62			'----
 63			'-------- Finding SYS and firstGLAccount for the selected Reason
 64			mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
 65			Set RS1=Conn.execute(mySQL)
 66			if RS1.eof then
 67				errorFound=	true
 68				errorMsg=	Server.URLEncode("���!")
 69			else
 70				Sys=			RS1("Acron")
 71				firstGLAccount=	RS1("GLAccount")
 72			end if
 73			RS1.close
 74
 75			'-------- Finding GLAccount for the selected bank 
 76			'---- CheqStatus = 2 means 'vosool shode'
 77			mySQL = "SELECT BankerCheqStatusGLAccountRelation.GLAccount, Bankers.Name FROM BankerCheqStatusGLAccountRelation INNER JOIN Bankers ON BankerCheqStatusGLAccountRelation.Banker = Bankers.ID WHERE (Bankers.ID="& bank & ") AND (Bankers.IsBankAccount = 1) AND (BankerCheqStatusGLAccountRelation.GL = '"& openGL & "') AND (BankerCheqStatusGLAccountRelation.CheqStatus = 2)"
 78			Set RS1 = Conn.Execute(mySQL)
 79			if RS1.eof then
 80				conn.close
 81				response.redirect "?errMsg=" & Server.URLEncode("���!<br>���� ���� ���� �����.")
 82			else
 83				BankName=	RS1("Name")
 84				GLAccount=	RS1("GLAccount")
 85			end if
 86			RS1.close
 87			'--------
 88
 89		end if
 90		if Err.Number<>0 then
 91			Err.clear
 92			errorFound=	true
 93			errorMsg=	Server.URLEncode("���!")
 94		end if
 95	ON ERROR GOTO 0
 96	if errorFound then
 97		conn.close
 98		response.redirect "?errMsg=" & Server.URLEncode("���!")
 99	end if
100
101	creationDate=	shamsiToday()
102	comment=		sqlSafe(request.form("comment"))
103
104	if comment <> "" then comment = " (" & comment & ")"
105
106	if instr(BankName,"(")>0 then
107		BankName=left(BankName,instr(BankName,"(")-1)
108	end if
109
110	theDescription = "����� ��� ��� �� ���� "& ReceiptNo & " "& BankName & " ���� �� "& customerID & comment
111
112	' ######################################################### 
113	'					INSERTING RECEIPT  ...
114	' #########################################################
115
116	'	CHQAMOUNT ...
117	CHQAMOUNT =0
118	'	CHQQTTY must be Receipt Qtty of Cheques
119	CHQQTTY =0
120	DepositAmount = 0 
121
122	mySQL="INSERT INTO Receipts (CreatedDate, sys, CreatedBy, EffectiveDate, Number, Customer, CashAmount, DepositAmount, ChequeAmount, ChequeQtty, TotalAmount) VALUES (N'" &_
123	creationDate & "', '"& sys & "' , '"& session("ID") & "', N'" & effectiveDate & "', '"& ReceiptNo & "', '"& CustomerID & "', '"& amount & "', '"& DepositAmount & "', '"& CHQAMOUNT & "', '"& CHQQTTY & "', '"& amount & "');SELECT @@Identity AS NewReceipt"
124
125	set RS1 = Conn.execute(mySQL).NextRecordSet
126	ReceiptID=RS1("NewReceipt")
127	RS1.close
128
129	' ######################################################### 
130	'					INSERTING CASH  ...
131	' #########################################################
132	mySQL="INSERT INTO ReceivedCash (Receipt, Amount, Banker, Description) VALUES ('"&_
133			ReceiptID & "', '" & amount & "', '" & bank & "', N'"& theDescription & "')"
134	conn.Execute(mySQL)
135
136	chequeCount=0
137	totalChequeAmount=0
138
139	'**************************** Creating Item for Receipt  ****************
140	'*** Type = 2 means Item is a Receipt
141	ItemType =  2  
142
143	mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, Link, Reason, CreatedDate, CreatedBy, Type, IsCredit, AmountOriginal, RemainedAmount) VALUES ('"&_
144	GLAccount & "', '"& OpenGL & "', "& firstGLAccount & ", "& customerID & ", N'"& effectiveDate & "', "& ReceiptID & ", "& Reason & ", N'"& creationDate & "' , "& session("id") & ", "& ItemType & ", 1,  "& Amount & ","& Amount & ")"
145	conn.Execute(mySQL)
146	'***------------------------- Creating Item for Receipt  ----------------
147
148	Conn.Execute ("UPDATE Accounts SET "& sys & "Balance="& sys & "Balance+"& Amount & "  WHERE (ID = "& customerID & ")")	
149
150	Conn.Execute ("UPDATE Bankers SET CurrentBalance=CurrentBalance+"& amount & " WHERE ID="& bank ) 
151
152	response.redirect "../"& sys & "/AccountReport.asp?act=showReceipt&sys="& sys & "&receipt=" & ReceiptID &"&msg="& Server.URLEncode("����� ��� ��.<br><a href='../bank/submitDraft.asp'>��Ґ�� �� ������ �����</a>")
153
154'-----------------------------------------------------------------------------------------------------
155'----------------------------------------------------------------------------- Input a new GL Memo Doc
156'-----------------------------------------------------------------------------------------------------
157elseif request("act")="" then
158
159%>
160<input type="hidden" Name='tmpDlgArg' value=''>
161<input type="hidden" Name='tmpDlgTxt' value=''>
162<FORM METHOD=POST ACTION="?act=submit" onsubmit="return isEmpty()">
163<TABLE align=center style="border:1pt solid white">
164<TR>
165	<TD colspan='2'>
166		<TABLE width='100%' cellpadding='5'>
167		<TR>
168			<TD bgcolor=white>�����: </TD>
169<%
170			mySQL="SELECT * FROM AXItemReasons WHERE Display=1 ORDER BY ID"
171			set RS1=conn.execute(mySQL)
172			while not RS1.eof
173%>				<TD bgcolor=white><INPUT TYPE="radio" NAME="Reason" value="<%=RS1("ID")%>" <% if reason=RS1("ID") then response.write "checked "%>><%=RS1("Name")%><br><span style='font-size:7pt;width:100%;text-align:left;'> <%="[" & RS1("GLAccount") & "]"%> </span></TD>
174<%				RS1.movenext
175			wend
176%>		
177		</TR>
178		</TABLE>
179	</TD>
180</TR>
181<TR>
182	<TD>
183		�����:  
184	</TD>
185	<TD>
186		<INPUT class="GenInput" style='direction:LTR;text-align:left;' NAME="ReceiptDate" TYPE="text" maxlength="10" size="10" value="" onblur="acceptDate(this)">
187	</TD>
188</TR>
189<TR>
190	<TD>
191		����� ����� :
192	</TD>
193	<TD>
194		<INPUT class="GenInput" style='direction:LTR;text-align:left;' NAME="ReceiptNo" TYPE="text" size="10" > 
195	</TD>
196</TR>
197<TR>
198	<TD>
199		���� ����� :
200	</TD>
201	<TD>
202		<INPUT TYPE="text" NAME="amount" class='GenInput' style='width:170px;direction:LTR;text-align:left;' onKeyPress="return maskNumber(this);" onBlur="$(this).val(echoNum($(this).val()));"> ���� 
203	</TD>
204</TR>
205<TR>
206	<TD>
207		�� ���� ������ �����:
208	</TD>
209	<TD>
210		<table width='100%' border=0>
211		<tr>
212			<td width=75><INPUT TYPE="text" NAME="customerID" class='GenInput' style='width:70px;direction:LTR;text-align:left;' maxlength="10" onKeyPress='return mask(this);' onBlur='check(this);'></td>  
213			<td><INPUT TYPE="text" NAME="accountName" size=28 readonly  value="<%=accountName%>" style="background-color:transparent"></td>  
214		</tr>  
215		</table>
216	</TD>
217</TR>
218<TR>
219	<TD>
220		��� ���� :
221	</TD>
222	<TD>
223		<select name="Bank" class=inputBut style="width:250; ">
224		<option value="-1">������ ����</option>
225		<option value="-1">---------------------------------</option>
226		<% set RSV=Conn.Execute ("SELECT * FROM Bankers WHERE (IsBankAccount = 1 AND isActive=1)") 
227		Do while not RSV.eof
228		%>
229			<option value="<%=RSV("id")%>"><%=RSV("Name")%> </option>
230		<%
231		RSV.moveNext
232		Loop
233		RSV.close
234		%>
235		</select>
236	</TD>
237</TR>
238<TR>
239	<TD>
240		�����: 
241	</TD>
242	<TD>
243		<textarea NAME='comment' cols='30' class='GenInput' style='width:250px;'></textarea>
244	</TD>
245</TR>
246<TR>
247	<TD colspan='2' height='2' ><hr></TD>
248</TR>
249<TR>
250	<TD colspan='2' align='center'>
251		<INPUT TYPE="submit" value="��� �����" class='GenButton'><br><br>
252	</TD>
253</TR>
254</TABLE>
255</FORM>
256<BR><BR>
257
258<SCRIPT LANGUAGE="JavaScript">
259<!--
260
261var dialogActive=false;
262
263function mask(src){ 
264	var theKey=event.keyCode;
265
266	if (theKey==32){
267		event.keyCode=9
268		dialogActive=true
269		document.all.tmpDlgArg.value="#"
270		document.all.tmpDlgTxt.value="����� �� ��� ���� :"
271		window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
272		if (document.all.tmpDlgTxt.value !="") {
273			window.showModalDialog('../AR/dialog_SelectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value), document.all.tmpDlgArg, 'dialogHeight:400px; dialogWidth:700px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
274			dialogActive=false
275			if (document.all.tmpDlgArg.value!="#"){
276				Arguments=document.all.tmpDlgArg.value.split("#")
277				src.value=Arguments[0];
278				document.all.accountName.value=Arguments[1];
279			}
280		}
281	}
282}
283
284function check(src){ 
285	if (!dialogActive){
286		badCode = false;
287		if (window.XMLHttpRequest) {
288			var objHTTP=new XMLHttpRequest();
289		} else if (window.ActiveXObject) {
290			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
291		}
292		objHTTP.open('GET','../accounting/xml_CustomerAccount.asp?id='+src.value,false)
293		objHTTP.send()
294		tmpStr = unescape(objHTTP.responseText)
295		//document.all['A1'].innerText= objHTTP.status
296		//document.all['A2'].innerText= objHTTP.statusText
297		//document.all['A3'].innerText= objHTTP.responseText
298		document.all.accountName.value=tmpStr;
299		}
300}
301
302
303
304function isEmpty()
305{
306	ReceiptNo = document.all.ReceiptNo.value
307	CusID = document.all.customerID.value
308	amount = document.all.amount.value
309	Bank = document.all.Bank.value
310	if(CusID=="" || amount=="" || Bank==-1)
311		{
312		alert("���! ��� ���� �� ���� ���")
313		return false
314		}
315	else
316		{
317		str = "��� ������"
318		return confirm(str)
319		}
320	
321}
322//-->
323</SCRIPT>
324<% 
325end if
326%>
327<!--#include file="tah.asp" -->