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

/beta/admin/BankerMng.asp

http://github.com/khaneh/Orders
ASP | 255 lines | 226 code | 20 blank | 9 comment | 39 complexity | 91acd2e97920696e5d283a6b68b64401 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2' Admin
  3PageTitle="������ �������"
  4SubmenuItem=7
  5%>
  6<!--#include file="top.asp" -->
  7<BR><BR><BR><CENTER>
  8<%
  9function sqlSafeNoEnter (s)
 10  st=s
 11  st=replace(St,"'","`")
 12  st=replace(St,chr(34),"`")
 13  st=replace(St,vbCrLf," ")
 14  sqlSafeNoEnter=st
 15end function
 16
 17'-----------------------------------------------------------------------------------------------------
 18'---------------------------------------------------------------------------------- Submit New or Edit
 19'-----------------------------------------------------------------------------------------------------
 20if request("act")="submitBanker" then
 21
 22	id = sqlSafeNoEnter(request.form("id"))
 23	bname = sqlSafeNoEnter(request.form("bname"))
 24	Responsible = sqlSafeNoEnter(request.form("Responsible"))
 25
 26	if request.form("IsBankAccount")="on" then
 27		IsBankAccount=1
 28	else
 29		IsBankAccount=0
 30	end if
 31
 32	if request.form("id") = "" then
 33		Conn.Execute ("INSERT INTO Bankers ([Name], IsBankAccount,  Responsible, LastCheckedDate, LastCheckedBy) VALUES ("&_
 34		"N'"& bname & "', '"& IsBankAccount & "','"& Responsible & "' , N'0', 0) ")
 35		'response.write "<B>������ ��</B><BR>"
 36		set rsv=conn.execute ("select max(id) as maxID from Bankers where [Name]=N'" & bname & "'")
 37		id = rsv("maxID")
 38	else
 39		Conn.Execute ("UPDATE Bankers SET [name]=N'"& sqlSafeNoEnter(request.form("bname"))& "', [IsBankAccount]='"& IsBankAccount & "', [Responsible]='"& Responsible & "' WHERE ([ID]='"& id & "')")
 40		'response.write "<B>�� ��� �� </B><BR>"
 41		Conn.Execute ("DELETE FROM BankerCheqStatusGLAccountRelation where (Banker = " & id & ") and GL = "  & OpenGL)
 42	end if
 43
 44	for i=1 to request.form("GLaccounts").count 
 45		if not request.form("GLaccounts")(i) = "" then 
 46			Conn.Execute ("INSERT INTO BankerCheqStatusGLAccountRelation  (Banker, CheqStatus, GLAccount, GL) VALUES (" & id & ", " & request.form("GLaccountsID")(i) & "," & request.form("GLaccounts")(i) & "," & OpenGL & ")")	
 47		end if
 48	next
 49
 50end if
 51
 52'-----------------------------------------------------------------------------------------------------
 53'--------------------------------------------------------------------- Add a new banker & Bankers List
 54'-----------------------------------------------------------------------------------------------------
 55EDITFLAG = false
 56
 57if request("id") <> "" and isnumeric(request("id")) then 
 58	id = request("id")
 59	EDITFLAG = true
 60	set rsv=conn.execute ("SELECT Bankers.ID, Bankers.Name, Bankers.IsBankAccount, Bankers.CurrentBalance, Users.ID, Bankers.Responsible, Users.RealName FROM Bankers INNER JOIN Users ON Bankers.Responsible = Users.ID WHERE Bankers.ID=" & id ) 
 61	if rsv.eof then
 62		EDITFLAG = false
 63	else
 64		BankerName = rsv("Name")
 65		ID = rsv("ID")
 66		IsBankAccount = rsv("IsBankAccount") 
 67	end if
 68	rsv.close			
 69end if
 70
 71%>
 72<TABLE width=80%>
 73<TR>
 74	<TD valign=top style="border:solid 1pt white">
 75		<TABLE border=0 width=100%>
 76		<form method=post action="?act=submitBanker">
 77		<TR bgcolor=white><TD align=center ><SPAN name="setGLsSpan" id="setGLsSpan">
 78		<% if EDITFLAG then%>
 79		������ ������� 
 80		<% else %>
 81		������   ����� ����	
 82		<% end if %>
 83		</SPAN></TD></TR>
 84		<TR>
 85			<TD align=center>
 86					<BR>
 87					���: <INPUT TYPE="hidden" name="id" value="<%=id%>"><input type="text" name="bname" value="<%=BankerName%>" size=35>&nbsp;&nbsp;&nbsp;
 88					����� ������: 
 89								<select name="Responsible" class="custgeninput" style="width:90; font-family:tahoma; width:123;">
 90									<option value=""> ������ ���� </option>
 91									<option value="">---------------------</option>
 92								<% set rsv=conn.execute ("SELECT * FROM Users WHERE Display=1 ORDER BY RealName") 
 93								do while not rsv.eof
 94								%>
 95									<option value="<%=rsv("ID")%>" <%
 96									if ID = rsv("ID") and not ID="" then
 97										response.write "selected" 
 98									end if 
 99									%>><%=rsv("realname")%></option>
100								<%
101								rsv.movenext
102								loop
103								rsv.close
104								%>
105								</select> &nbsp;&nbsp;&nbsp;
106					���� ����� ���<INPUT TYPE="checkbox" NAME="IsBankAccount" onclick="changeGLsTD()" <%
107					if IsBankAccount then response.write "checked" 
108					%>>
109					<BR><BR>
110			</TD>
111		</TR>
112		<TR>
113			<TD id="setGLsTD" name="setGLsTD">
114			<% if EDITFLAG then %>
115			<% if IsBankAccount then %>
116				<table width=100%>
117				<tr>
118				<% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=1") 
119				do while not rsv.eof 
120					set rsw=conn.execute ("select * from BankerCheqStatusGLAccountRelation WHERE (CheqStatus = " & rsv("id") & ") AND (Banker = " & id & ") and GL=" & openGL) 
121					%>
122					<td align=center><%=rsv("Name")%>
123					<br><INPUT TYPE='text' NAME='GLaccounts' size=7 value='<% if not rsw.eof then response.write rsw("GLAccount")%>'>
124					<INPUT TYPE='hidden'  NAME='GLaccountsID'  value='<%=rsv("id")%>'><br>
125					<% if rsv("IsRcvdChqStatus") then %> (��������) <% else %> (��������)<% end if %>
126					</td><%
127					rsv.movenext
128				loop
129				rsv.close %>
130				</tr></table>			
131			<% else %>
132				<table width=100%>
133				<tr>
134				<% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=0 and IsRcvdChqStatus = 0") 
135				do while not rsv.eof 
136					set rsw=conn.execute ("select * from BankerCheqStatusGLAccountRelation WHERE (CheqStatus = " & rsv("id") & ") AND (Banker = " & id & ") and GL=" & openGL) 
137					%>
138					<td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7 value='<% if not rsw.eof then response.write rsw("GLAccount")%>'>
139					<INPUT TYPE='hidden'  NAME='GLaccountsID'  value='<%=rsv("id")%>'>
140					</td><%
141					rsv.movenext
142				loop
143				rsv.close %>
144				</tr></table>			
145			<% end if %>
146			<% end if %>
147			</TD>
148		</TR>
149		</TABLE>
150		<BR>	
151		<CENTER>
152		<% if EDITFLAG then %>
153		<INPUT TYPE="button" value="����" onclick="window.location='BankerMng.asp'">
154		<% end if %>
155		<INPUT TYPE="submit" name="dokme" <% if EDITFLAG then %>value="������ ������� "<% else %> value="������"<% end if %>></CENTER>
156		<BR>	
157		</TD>
158		</form>
159</TR>
160<TR>
161	<TD><BR><BR>
162		<table id="result" width=100%>
163		<tr style="background-color:white">
164			<td>���</td>
165			<td align=center>����� ������</td>
166			<td align=center>������ ����</td>
167			<td align=center>���� ����� ��ʿ</td>
168		</tr>
169		<%
170		set rsv=conn.execute ("SELECT Bankers.ID as BID, Bankers.Name, Bankers.IsBankAccount,  Bankers.CurrentBalance, Users.ID, Bankers.Responsible, Users.RealName FROM Bankers INNER JOIN Users ON Bankers.Responsible = Users.ID ORDER BY Bankers.ID") 
171		tmpColor2 = "#cccccc"
172		tmpColor = ""
173		do while not rsv.eof
174		%>
175		<a href="?id=<%=rsv("bid")%>">
176		<tr style="cursor:hand" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="copyInfo(this.rowIndex);">
177			<td><INPUT TYPE="hidden" name="idList" value="<%=rsv("id")%>"><%=rsv("Name")%></td>
178			<td><%=rsv("RealName")%> <INPUT TYPE="hidden" name=IDLIST value="<%=rsv("ID")%>"></td>
179			<td><%=rsv("CurrentBalance")%></td>
180			<td align=center><% if rsv("IsBankAccount") then %><INPUT TYPE="checkbox" NAME="isBank" disabled checked><% else %><INPUT TYPE="checkbox" NAME="isBank" disabled><% end if %></td>
181		</tr>
182		<%
183		rsv.movenext
184		loop
185		rsv.close			
186		%>
187		</table>
188		<BR>
189	</TD>
190</TR>
191</TABLE>
192</CENTER>
193<SCRIPT LANGUAGE="JavaScript">
194<!--
195
196s1 = "<table width=100%><tr><% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=1") 
197do while not rsv.eof
198%><td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7><INPUT TYPE='hidden'  NAME='GLaccountsID'  value='<%=rsv("id")%>'><BR><% if rsv("IsRcvdChqStatus") then %> (��������) <% else %> (��������)<% end if %></td><%
199rsv.movenext
200loop
201rsv.close
202%></tr></table>"
203
204s2 = "<table width=100%><tr><% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=0 and IsRcvdChqStatus = 0") 
205do while not rsv.eof
206%><td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7><INPUT TYPE='hidden'  NAME='GLaccountsID'  value='<%=rsv("id")%>'></td><%
207rsv.movenext
208loop
209rsv.close
210%></tr></table>"
211
212
213
214function copyInfo(index){
215	var myObj=document.getElementsByTagName("table").item('result').getElementsByTagName("tr").item(index);
216	document.all.bname.value				=myObj.getElementsByTagName("td").item(0).innerText;
217	document.all.IsBankAccount.checked	=document.getElementsByName("isBank")[index-1].checked;
218	document.all.id.value				=document.getElementsByName("idList")[index-1].value;
219	document.all.Responsible.value				=document.getElementsByName("IDLIST")[index-1].value;
220	document.all.dokme.value = "��� �������"
221	document.all.setGLsSpan.innerText = "������ ������� " + myObj.getElementsByTagName("td").item(0).innerText;
222	if (document.getElementsByName("isBank")[index-1].checked)
223		document.all.setGLsTD.innerHTML = s1;
224	else
225		document.all.setGLsTD.innerHTML = s2;
226	document.all.bname.select();
227	document.all.bname.focus();
228}
229
230
231function changeGLsTD(){
232	if (document.all.IsBankAccount.checked)
233		{
234		s2 = document.all.setGLsTD.innerHTML;
235		document.all.setGLsTD.innerHTML = s1;
236		}
237	else
238		{
239		s1 = document.all.setGLsTD.innerHTML;
240		document.all.setGLsTD.innerHTML = s2;
241		}
242}
243
244
245document.all.bname.focus();
246
247<% if not EDITFLAG then %>
248// by default, new bankers are BankAccount
249document.all.setGLsTD.innerHTML = s1;
250document.all.IsBankAccount.checked =  true ;
251<% end if %>
252
253//-->
254</SCRIPT>
255<!--#include file="tah.asp" -->