PageRenderTime 30ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/AP/MemoInput.asp

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