PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/AR/InvoicePrintFormInput.asp

http://github.com/khaneh/Orders
ASP | 326 lines | 306 code | 12 blank | 8 comment | 23 complexity | 899e20afaa173e6a1ea71e085a8637c9 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'AR (6)
  3PageTitle="���� ������"
  4SubmenuItem=1
  5if not (Auth(6 , 1) OR Auth(6 , 4)) then NotAllowdToViewThisPage()
  6%>
  7<!--#include file="top.asp" -->
  8<!--#include File="../include_farsiDateHandling.asp"-->
  9<!--#include File="../include_JS_InputMasks.asp"-->
 10
 11<%
 12function ShowErrorMessage(msg)
 13	response.write "<table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ��� ! <br>"& msg & "<br></td></tr></table><br>"
 14end function
 15
 16function Link2Trace(OrderNo)
 17	Link2Trace="<A HREF='../order/TraceOrder.asp?act=show&order="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
 18end function
 19
 20%>
 21<style>
 22	Table { font-size: 9pt;}
 23	.InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
 24	.InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 25	.InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; text-align:right;}
 26	.InvRowInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; direction:LTR; text-align:right;}
 27	.InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 28	.InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
 29	.InvGenInput  { font-family:tahoma; font-size: 9pt; border: none; }
 30	.InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 31</style>
 32<SCRIPT LANGUAGE="JavaScript">
 33<!--
 34var selectedRow=-1;
 35function selectAndDelete(rowNo){
 36	if (selectedRow==rowNo){
 37		delAndShiftUp(rowNo);
 38		document.getElementById("InvoiceLines").getElementsByTagName("TR")[selectedRow].getElementsByTagName("TD")[0].setAttribute("bgColor","");
 39		selectedRow=-1
 40		calcAndCheck()
 41	}
 42	else{
 43		if (selectedRow != -1)
 44			document.getElementById("InvoiceLines").getElementsByTagName("TR")[selectedRow].getElementsByTagName("TD")[0].setAttribute("bgColor","");
 45		document.getElementById("InvoiceLines").getElementsByTagName("TR")[rowNo].getElementsByTagName("TD")[0].setAttribute("bgColor","red");
 46		selectedRow=rowNo;
 47	}
 48}
 49function delAndShiftUp(rowNo){
 50	for (i=rowNo;i<9;i++){
 51		document.getElementsByName("Descriptions")[i].value=document.getElementsByName("Descriptions")[i+1].value
 52		document.getElementsByName("Qttys")[i].value=document.getElementsByName("Qttys")[i+1].value
 53		document.getElementsByName("Units")[i].value=document.getElementsByName("Units")[i+1].value
 54		document.getElementsByName("Fees")[i].value=document.getElementsByName("Fees")[i+1].value
 55		document.getElementsByName("Prices")[i].value=document.getElementsByName("Prices")[i+1].value
 56	}
 57}
 58function setPrice(src){
 59	if (src.name=="Qttys" || src.name=="Fees"){
 60		src.value=val2txt(txt2val(src.value))
 61		rowNo=src.parentNode.parentNode.rowIndex;
 62		tmpFee=txt2val(document.getElementsByName("Fees")[rowNo].value);
 63		tmpQtty=txt2val(document.getElementsByName("Qttys")[rowNo].value);
 64		tmpPrice= tmpFee * tmpQtty;
 65		document.getElementsByName("Prices")[rowNo].value = val2txt(parseInt(tmpPrice));
 66	}
 67	else if (src.name=="Discount"){
 68		src.value=val2txt(txt2val(src.value))
 69	}
 70	calcAndCheck()
 71}
 72function calcAndCheck(){
 73	var total=0;
 74	var payable;
 75	for(i=0;i<10;i++){
 76		total+=txt2val(document.getElementsByName("Prices")[i].value)
 77	}
 78	document.getElementsByName("TotalPrice")[0].value=val2txt(total)
 79	payable=total-txt2val(document.getElementsByName("Discount")[0].value);
 80	document.getElementsByName("Payable")[0].value=val2txt(payable)
 81	if(document.getElementsByName("Payable")[0].value==document.getElementsByName("MustBe")[0].value){
 82		document.getElementsByName("Payable")[0].style.backgroundColor='#00FF00';
 83	}
 84	else{
 85		document.getElementsByName("Payable")[0].style.backgroundColor='#FF0000';
 86	}
 87}
 88//-->
 89</SCRIPT>
 90<%
 91response.end()
 92if request("act")="getPrintForm" then
 93	if isnumeric(request("invoice")) then
 94		InvoiceID=clng(request("invoice"))
 95		mySQL="SELECT * FROM Invoices WHERE (ID='"& InvoiceID & "')"
 96		Set RS1 = conn.Execute(mySQL)
 97		if RS1.eof then
 98			conn.close
 99			response.redirect "?errmsg=" & Server.URLEncode("������ ���� ���.")
100		end if
101	else
102		response.redirect "?errmsg=" & Server.URLEncode("����� ������ ���� ���� ��� ����.")
103	end if
104
105	customerID=		RS1("Customer")
106	creationDate=	RS1("CreatedDate")
107	totalPrice=		cdbl(RS1("totalPrice"))
108	totalDiscount=	cdbl(RS1("totalDiscount"))+cdbl(RS1("totalReverse"))
109	totalReceivable=cdbl(RS1("totalReceivable"))
110	totalVat =		cdbl(RS1("totalVat"))
111	Voided=			RS1("Voided")
112	Issued=			RS1("Issued")
113	Approved=		RS1("Approved")
114	isReverse=		RS1("IsReverse")
115	IsA=			RS1("IsA")
116	InvoiceNo=		RS1("Number")
117
118	if isReverse then
119		'Check for permission for EDITTING Rev. Invoice
120		if not Auth(6 , 5) then NotAllowdToViewThisPage()
121		itemTypeName="�ǘ��� �ѐ��"
122		HeaderColor="#FF9900"
123	else
124		'Check for permission for EDITTING Invoice
125		if not Auth(6 , 3) then NotAllowdToViewThisPage()
126		itemTypeName="�ǘ���"
127		HeaderColor="#C3C300"
128	end if
129
130	if Voided then
131		Conn.close
132		response.redirect "AccountReport.asp?act=showInvoice&invoice="& InvoiceID & "&errmsg=" & Server.URLEncode("��� ������ ���� ��� ���.")
133	elseif Issued then
134		if Auth(6 , "A") then
135			' Has the Priviledge to change the Invoice
136			response.write "<BR>"
137			call showAlert ("��� ������ ���� ��� ���.<br>�э�� �� ��� ����� ����� �� ��� �ǘ��� �� ����� �����<br>������ �Ԙ��� ������� �� �� �����Ͽ",CONST_MSG_INFORM) 
138		else
139			Conn.close
140			response.redirect "AccountReport.asp?act=showInvoice&invoice="& InvoiceID & "&errmsg=" & Server.URLEncode("��� ������ ���� ��� ���.")
141		end if
142	end if 
143
144	mySQL="SELECT ID,AccountTitle,Address1,Tel1,PostCode1,EconomicalCode FROM Accounts WHERE (ID='"& customerID & "')"
145	Set RS1 = conn.Execute(mySQL)
146	customerName=RS1("AccountTitle")
147	customerAddress=RS1("Address1")
148	customerTel=RS1("Tel1")
149	customerPostCode=RS1("PostCode1")
150	customerEcCode=RS1("EconomicalCode")
151
152	RS1.close
153
154'	response.end
155
156	creationDate=shamsiToday()
157'	creationTime=Hour(creationTime)&":"&Minute(creationTime)
158'	if instr(creationTime,":")<3 then creationTime="0" & creationTime
159'	if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
160
161%>
162<!-- ���� ������� ������ -->
163	<br>
164	<input type="hidden" Name='tmpDlgArg' value=''>
165	<input type="hidden" Name='tmpDlgTxt' value=''>
166	<table Border="0" align="center" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
167	<FORM METHOD=POST ACTION="?act=submitPrintForm">
168	<tr bgcolor='#C3C300'>
169		<td align="left"><TABLE>
170			<TR>   
171				<TD align="left">�����:</td>
172				<TD dir="LTR">
173					<INPUT class="InvGenInput" NAME="InvoiceDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>"></td>
174					<INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>">
175				<TD dir="RTL"><%=weekdayname(weekday(date))%></td>
176			</TR>  
177			</TABLE>
178		</td>
179	</tr>
180	<tr bgcolor='#C3C300'>
181		<td>
182			<TABLE border="0" width="100%" >
183			<TR>   
184				<TD align="left">��� ������:</TD>
185				<TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="CustomerName" rows="1" cols="50"><%=CustomerName%></TEXTAREA></TD>
186				<TD align="left">����� �������:</TD>
187				<TD><INPUT class="InvGenInput" style="border:1 solid black;width:100px;direction:LTR;text-align:left;" NAME="customerEcCode" TYPE="text" size="10" value="<%=customerEcCode%>"></TD>
188			</TR>  
189			<TR>   
190				<TD align="left">�����:</TD>
191				<TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="customerAddress" rows="2" cols="50"><%=customerAddress%></TEXTAREA></TD>
192				<TD align="left">�� ����:</TD>
193				<TD><INPUT class="InvGenInput" style="border:1 solid black;width:100px;" NAME="customerPostCode" TYPE="text" size="10" value="<%=customerPostCode%>"></TD>
194			</TR>  
195			<TR>   
196				<TD align="left">����:</TD>
197				<TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="customerTel" rows="1" cols="50"><%=customerTel%></TEXTAREA></TD>
198				<TD align="left">����� ����:</TD>
199				<TD align=left><INPUT TYPE="radio" NAME="Cash" Value="1">����  <INPUT TYPE="radio" NAME="Cash" Value="0" checked>�������</TD>
200			</TR>  
201			</TABLE>
202		</td>
203	</tr>
204	<tr bgcolor='#CCCC88'>
205		<td><div>
206			<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
207			<TR bgcolor='#CCCC88'>
208				<TD align='center' width="25px"> # </td>
209				<TD><INPUT class="InvHeadInput2" readOnly TYPE="text" value="��� �����" size="65" ></TD>       
210				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" value="�����" size="6"></TD> <!--S A M-->  
211				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value="���� ����" size="10"></TD>        
212				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value="���� ����" size="15"></TD>
213				<td><INPUT class="InvHeadInput" readonly TYPE="text" value="������" size="7"></td><!--S A M-->
214				<TD><INPUT class="InvHeadInput2" readOnly TYPE="text" Value="����" size="20"></TD>      
215			</TR>
216			</TABLE></div>
217		</td>
218	</tr>
219	<tr bgcolor='#CCCC88'>
220		<td>
221			<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
222			<TBODY id="InvoiceLines">
223<%		
224		Dim Descriptions(10)
225		Dim Qttys(10)
226		Dim Units(10) ' Allways empty!
227		Dim Fees(10)
228		Dim Prices(10)
229		i=0
230		mySQL="SELECT * FROM InvoiceLines left outer join invoiceItems on InvoiceLines.item = invoiceItems.ID WHERE (Invoice='"& InvoiceID & "') "
231		Set RS1 = conn.Execute(mySQL)
232		Do While NOT RS1.eof AND i<10
233			i=i+1
234			Descriptions(i)=RS1("Description")
235			Qttys(i)=Separate(RS1("AppQtty"))
236			if RS1("AppQtty") <> 0 then 
237				Fees(i)=Separate(RS1("Price")/RS1("AppQtty")) 
238			else 
239				Fees(i)="0"
240			end if
241			Prices(i)=Separate(RS1("Price"))
242			RS1.moveNext
243		Loop
244		RS1.close
245
246		for i=1 to 10
247%>
248			<TR bgcolor='#F0F0F0'>
249				<TD align='center' width="25px" onclick="selectAndDelete(this.parentNode.rowIndex);"><%=i%></TD>
250				<TD><INPUT class="InvRowInput2" TYPE="text" Name="Descriptions" value="<%=Descriptions(i)%>" size="65"></TD>
251				<TD><INPUT class="InvRowInput"  TYPE="text" Name="Qttys" value="<%=Qttys(i)%>" size="6" onBlur="setPrice(this);"></TD>   
252				<TD><INPUT class="InvRowInput"  TYPE="text" Name="Units" Value="<%=Units(i)%>" size="10"></TD>        
253				<TD><INPUT class="InvRowInput"  TYPE="text" Name="Fees" Value="<%=Fees(i)%>" size="15" onBlur="setPrice(this);"></TD>        
254				<td><INPUT class="InvRowInput"  TYPE="text" Name="Vat" value="<%Vat(i)%>" size="7" onBlur="this.value=val2txt(txt2val(this.value));calcAndCheck();"></td>
255				<TD><INPUT class="InvRowInput3" TYPE="text" Name="Prices" Value="<%=Prices(i)%>" size="20" onBlur="this.value=val2txt(txt2val(this.value));calcAndCheck();"></TD>      
256			</TR>
257<%
258		next
259%>
260			</Tbody>
261			</TABLE>
262		</td>
263	</tr>
264	<tr bgcolor='#CCCC88'>
265		<td colspan="10"><div>
266			<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#CCCC88">
267			<TR bgcolor='#CCCC88'>
268				<TD align='center' width="24px"></td>
269				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>       
270				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>   
271				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>        
272				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value="��� ��:" style="text-align:left;" size="15"></TD>        
273				<TD style="border:1 solid black;"><INPUT class="InvRowInput2" readOnly TYPE="text" Name="TotalPrice" Value="<%=Separate(totalPrice)%>" size="20"></TD>      
274			</TR>
275			<TR bgcolor='#CCCC88'>
276				<TD align='center' width="24px"></td>
277				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>       
278				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>   
279				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>        
280				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value="�����:" style="text-align:left;" size="15"></TD>        
281				<TD style="border:1 solid black;"><INPUT class="InvRowInput3" TYPE="text" Name="Discount" Value="<%=Separate(totalDiscount)%>" size="20" onBlur="setPrice(this);"></TD>      
282			</TR>
283			<tr bgcolor="#CCCC88">
284				<TD align='center' width="24px"></td>
285				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>       
286				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>   
287				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>  
288				<TD><INPUT class="InvHeadInput" readonly TYPE="text" Value="������ �� ���� ������:" style="text-align:left" size="15"></TD>
289				<TD style="border:1 solid black;"><INPUT style="color:gray;" readonly TYPE="text" NAME="totalVat" value="<%=Separate(totalVat)%>" size="20"></TD>
290			</td>
291			<TR bgcolor='#CCCC88'>
292				<TD align='center' width="24px"></td>
293				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>       
294				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>   
295				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>        
296				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value="���� ������:" style="text-align:left;" size="15"></TD>        
297				<TD style="border:1 solid black;"><INPUT class="InvRowInput3" readOnly TYPE="text" Name="Payable" Value="<%=Separate(totalReceivable)%>" size="20"></TD>      
298			</TR>
299			<TR bgcolor='#CCCC88'>
300				<TD></td>
301				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>       
302				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>   
303				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>        
304				<TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="15"></TD>        
305				<TD><INPUT class="InvHeadInput3" style="color:gray;" readOnly TYPE="text" Name="MustBe" Value="<%=Separate(totalReceivable)%>" size="20"></TD>      
306			</TR>
307			</TABLE></div>
308		</td>
309	</tr>
310	<tr>
311		<td align='center'><INPUT class="InvGenButton" TYPE="button" value="������" onclick="calcAndCheck();"></td>
312	</tr>
313	</table>
314	</FORM>
315	<br>
316	<SCRIPT LANGUAGE="JavaScript">
317	<!--
318//		document.getElementsByName("Items")[0].focus();
319		calcAndCheck();
320	//-->
321	</SCRIPT>
322<%
323end if
324conn.Close
325%>
326<!--#include file="tah.asp" -->