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

/beta/config.asp

http://github.com/khaneh/Orders
ASP | 441 lines | 328 code | 57 blank | 56 comment | 34 complexity | 05cefc20ab34fe3f2b2e9ef55503412b MD5 | raw file
  1<!--#include file="version.asp" -->
  2<%
  3' Remember to Check "Enable Parent Paths" in:
  4'		IIS > Home Directory > Configuration > Options
  5
  6Response.CacheControl="no-cache"
  7Response.AddHeader "pragma", "no-cache"
  8Response.Expires= -1
  9orderFolder="C://myfile/"
 10'---------------------------------------------
 11'------------------------------- Check Session 
 12'---------------------------------------------
 13if (session("ID")="") then
 14	response.cookies("OldURL") = Request.ServerVariables("URL")
 15	'response.cookies("OldForm") = request.form
 16	session.abandon
 17	response.redirect "/login.asp?err="& server.URLEncode("���� ���� ��� ���� ���� ���� ����� ����")
 18end if
 19
 20'---------------------------------------------
 21'------------------------------- DB Connection
 22'---------------------------------------------
 23
 24'***** NOTE: If conStr changed, you should change it in Home/errHandler.asp too
 25'conStr="DRIVER={SQL Server};SERVER=(local);DATABASE=sefareshat;UID=sefadmin; PWD=5tgb;"
 26conStr = "Provider=SQLNCLI10.1;Persist Security Info=False;User ID=sefadmin;Initial Catalog=jame;Data Source=.\sqlexpress;PWD=5tgb;"
 27Set conn = Server.CreateObject("ADODB.Connection")
 28conn.ConnectionTimeout = 180
 29conn.open conStr
 30conn.CommandTimeout = 120 
 31
 32'---------------------------------------------
 33'---------------------------- Check GL Routine
 34'---------------------------------------------
 35dim OpenGL
 36
 37if Session("OpenGL")="" then
 38	response.write "���! ��� ���� ���� ����."
 39	response.end
 40
 41else
 42	OpenGL = Session("OpenGL")
 43	OpenGLName = Session("OpenGLName")
 44	FiscalYear = Session("FiscalYear")
 45end if
 46
 47
 48'---------------------------------------------
 49'--------------------------- Check Permissions
 50'---------------------------------------------
 51function Auth(menuID, subMenuID)
 52	pr = session("Permission")
 53
 54	if (pr="") then
 55		response.cookies("OldURL") = Request.ServerVariables("URL")
 56		session.abandon
 57		response.redirect "/login.asp?err="& server.URLEncode("���� ���� ��� ���� ���� ���� ����� ����")
 58	end if
 59
 60	st = inStr(pr,"#"&menuID)
 61	
 62	if subMenuID >= "A" then 
 63		subMenuID_int = cint(asc(subMenuID)-55)
 64	else
 65		subMenuID_int = cint(subMenuID)
 66	end if
 67
 68	Auth = false
 69	if st > 0 then
 70		en = inStr(st+1, pr, "#")
 71		sm = inStr(st+2, pr, subMenuID)
 72		if subMenuID_int = 0 or ((sm <> 0) and (en > sm or en = 0 )) then
 73			Auth = true
 74		end if		
 75	end if
 76end function
 77
 78'---------------------------------------------
 79'--------------------------------- Access Deny
 80'---------------------------------------------
 81function NotAllowdToViewThisPage()
 82	response.redirect "top.asp?errmsg=" & Server.URLEncode("��� ���� �� ���� ��� ���� ������.")
 83end function
 84
 85'---------------------------------------------
 86'-------------------------------------- Darsad
 87'---------------------------------------------
 88function Pourcent(input1,input2)
 89	if input2=0 then
 90		result="-"
 91	else
 92		result=round(input1/input2 * 100)
 93	end if
 94	Pourcent=result
 95end function
 96
 97'---------------------------------------------
 98'------------------------------------ SQL Safe
 99'---------------------------------------------
100function sqlSafe (inpStr)
101  tmpStr=inpStr
102  tmpStr=replace(tmpStr,"'","`")
103  tmpStr=replace(tmpStr,"""","`")
104  sqlsafe=tmpStr
105end function
106
107
108'---------------------------------------------
109'---------------------------------- text2value
110'---------------------------------------------
111function text2value(input)
112	result=replace(input,",","")
113	if result="" then
114		text2value=0
115	else
116		text2value=replace(input,",","")
117	end if
118	if input="True" then text2value=1
119	if input="False" then text2value=0
120end function
121
122
123const CONST_MSG_NONE	= -1
124const CONST_MSG_INFORM	= 0
125const CONST_MSG_ALERT	= 1
126const CONST_MSG_ERROR	= 2
127
128'---------------------------------------------
129'-------------------------- SHOW ALERT MESSAGE
130'---------------------------------------------
131sub showAlert( alertMsg , msgStatus )
132	select case msgStatus
133	case -1:
134		response.write "<TABLE width=45% align='center' bgcolor=ffffff style='border: dashed 1px Black'>"
135	case 0:
136		response.write "<TABLE width=45% align='center' bgcolor=ffffff style='border: dashed 1px Blue'>"
137	case 1:
138		response.write "<TABLE width=45% align='center' bgcolor=ffffdd style='border: dashed 1px Red'>"
139	case 2:
140		response.write "<TABLE width=45% align='center' bgcolor=ffeeee style='border: dashed 1px Red'>"
141	case else:
142		response.write "<TABLE width=45% align='center' bgcolor=ffffff style='border: dashed 1px Black'>"
143	end select
144	response.write "<TR>"
145	response.write "<td align=center width='10%'>"
146	response.write "<IMG SRC='../images/alertIcon"& trim(msgStatus) & ".gif' >"
147	response.write "</td>"
148	response.write "<TD align=center><BR>"
149	response.write alertMsg
150	response.write "<BR><BR></TD>"
151	response.write "</TR>"
152	response.write "</TABLE>"
153end sub
154
155'---------------------------------------------
156'-------------- Un-Approve an invoice when its 
157'-------------- related order has been changed
158'---------------------------------------------
159sub UnApproveInvoice(invoiceID,ApprovedBy)
160	MsgTo			=	ApprovedBy
161	msgTitle		=	"Invoice Unapproved"
162	msgBody			=	"��?��� ��� �� ���� ����� ����� ������ �� �� ���� �����ԡ ���� "& session("CSRName") & " ��  ����� ���� ��."
163	RelatedTable	=	"invoices"
164	relatedID		=	invoiceID
165	replyTo			=	0
166	IsReply			=	0
167	urgent			=	1
168	MsgFrom			=	session("ID")
169	MsgDate			=	shamsiToday()
170	MsgTime			=	currentTime10()
171	Conn.Execute ("UPDATE Invoices SET Approved=0 WHERE (ID='"& invoiceID & "')")
172	Conn.Execute ("INSERT INTO Messages (MsgFrom, MsgTo, MsgTime, MsgDate, IsRead, MsgTitle, MsgBody, replyTo, IsReply, relatedID, RelatedTable, urgent) VALUES ( "& MsgFrom & ", "& MsgTo & ", N'"& MsgTime & "', N'"& MsgDate & "', 0, N'"& MsgTitle & "', N'"& MsgBody & "', "& replyTo & ", "& IsReply & ", "& relatedID & ", '"& RelatedTable & "', "& urgent & ")")
173end sub
174
175'---------------------------------------------
176'-------------- Inform CSR that Order Is Ready
177'---------------------------------------------
178sub InformCSRorderIsReady(orderID,CSR)
179	MsgTo			=	CSR
180	msgTitle		=	"Order Is Ready"
181	msgBody			=	"����� ����� ����� ���."
182	RelatedTable	=	"orders"
183	relatedID		=	orderID
184	replyTo			=	0
185	IsReply			=	0
186	urgent			=	3
187	MsgFrom			=	session("ID")
188	MsgDate			=	shamsiToday()
189	MsgTime			=	currentTime10()
190	Conn.Execute ("INSERT INTO Messages (MsgFrom, MsgTo, MsgTime, MsgDate, IsRead, MsgTitle, MsgBody, replyTo, IsReply, relatedID, RelatedTable, urgent) VALUES ( "& MsgFrom & ", "& MsgTo & ", N'"& MsgTime & "', N'"& MsgDate & "', 0, N'"& MsgTitle & "', N'"& MsgBody & "', "& replyTo & ", "& IsReply & ", "& relatedID & ", '"& RelatedTable & "', "& urgent & ")")
191end sub
192
193'---------------------------------------------
194'----------------- Inventory Item Request Deny
195'---------------------------------------------
196sub InformRequestDenied(itemName,CSR)
197	MsgTo			=	CSR
198	msgTitle		=	"Request Denied"
199	msgBody			=	"������� ��� ���� "& itemName & "  �� �� ���. "
200	RelatedTable	=	"NaN"
201	relatedID		=	0
202	replyTo			=	0
203	IsReply			=	0
204	urgent			=	0
205	MsgFrom			=	session("ID")
206	MsgDate			=	shamsiToday()
207	MsgTime			=	currentTime10()
208	Conn.Execute ("INSERT INTO Messages (MsgFrom, MsgTo, MsgTime, MsgDate, IsRead, MsgTitle, MsgBody, replyTo, IsReply, relatedID, RelatedTable, urgent) VALUES ( "& MsgFrom & ", "& MsgTo & ", N'"& MsgTime & "', N'"& MsgDate & "', 0, N'"& MsgTitle & "', N'"& MsgBody & "', "& replyTo & ", "& IsReply & ", "& relatedID & ", '"& RelatedTable & "', "& urgent & ")")
209end sub
210
211'---------------------------------------------
212'------------------------------------ Separate
213'---------------------------------------------
214function Separate(inputTxt)
215
216if (not isnumeric(trim(inputTxt))) or ("" & inputTxt="") then 
217	Separate=inputTxt
218else
219	myMinus=""
220	input=inputTxt
221	t=instr(input, ".")
222	if t>0 then 
223		expPart = mid(input, t+1, 2)
224		input = left(input, t-1)
225	end if
226	if left(input,1)="-" then
227		myMinus="-"
228		input=right(input,len(input)-1)
229	end if
230	if len(input) > 3 then
231		tmpr=right(input ,3)
232		tmpl=left(input , len(input) - 3 )
233		result = tmpr
234		while len(tmpl) > 3
235			tmpr=right(tmpl,3)
236			result = tmpr & "," & result 
237			tmpl=left(tmpl , len(tmpl) - 3 )
238		wend
239		if len(tmpl) > 0 then
240			result = tmpl & "," & result
241		end if 
242	else
243		result = input
244	end if 
245	if t>0 then 
246		result = result & "." & expPart
247	end if
248
249	Separate=myMinus & result
250end if
251end function
252
253
254'------------------------------------------------------------START
255' Convert Digits to Letter ( e.g. 1 --> Yek )
256' Ver 2.0  -    1381-11-7    - Alix
257'---------------------------------------FUNC_1
258Function ConvertIT(inputDigits)
259digits=inputDigits
260if not IsNumeric(digits) then
261	ConvertIT=digits
262else
263	dim radeh(11)
264	radeh(0)=""				'non
265	radeh(1)="����"			'hezar
266	radeh(2)="������"		'milion
267	radeh(3)="�������"		'miliard
268	radeh(4)="������"		'bilion 
269	radeh(5)="�������"		'trilion 
270	radeh(6)="����������"	'quadrilion 
271	radeh(7)="����������"	'quintilion 
272	radeh(8)="����������"	'sextilion 
273	radeh(9)="Ӂ������"		'septilion
274	radeh(10)="���������"	'oktilian 
275	
276	dim nroundn, roundn
277	digits = replace(replace(digits,chr(13),""),chr(10),"")
278	nroundn=(len(digits))/3
279	roundn=fix(nroundn)
280	if not roundn=nroundn then
281		roundn = roundn + 1
282	end if
283	ConvertIT=""
284	for i=0 to roundn-1
285		pr = trim(Convert3dig(right(digits,3)))
286			if trim(pr)<>"" then
287				pr = pr &" "& radeh(i) 
288				if i<>roundn-1 then
289				pr = " � " & pr 
290				end if
291			else
292				pr = " " & pr &" "
293			end if
294		ConvertIT= trim(pr) & " " & trim(ConvertIT)
295		t=len(digits)-3
296		if t<=0 then
297			t = len(digits)
298		end if
299		digits = left(digits, t)
300	next
301	ConvertIT = trim(ConvertIT)
302end if
303End Function
304'---------------------------------------FUNC_2
305Function Convert3dig(digits3)
306	dim yekan(20)
307	yekan(0)=""			'0
308	yekan(1)="��"		'1
309	yekan(2)="��"		'2
310	yekan(3)="��"		'3
311	yekan(4)="����"		'4
312	yekan(5)="���"		'5
313	yekan(6)="��"		'6
314	yekan(7)="���"		'7
315	yekan(8)="���"		'8
316	yekan(9)="��"		'9
317	yekan(10)="��"		'10
318	yekan(11)="�����"	'11
319	yekan(12)="������"	'12
320	yekan(13)="�����"	'13
321	yekan(14)="������"	'14
322	yekan(15)="������"	'15
323	yekan(16)="������"	'16
324	yekan(17)="����"	'17
325	yekan(18)="����"	'18
326	yekan(19)="�����"	'19
327
328	dim dahgan(10)
329	dahgan(0)=""		'0
330	dahgan(1)="��"		'10
331	dahgan(2)="����"	'20
332	dahgan(3)="��"		'30
333	dahgan(4)="���"		'40
334	dahgan(5)="�����"	'50
335	dahgan(6)="���"		'60
336	dahgan(7)="�����"	'70
337	dahgan(8)="�����"	'80
338	dahgan(9)="���"		'90
339
340	dim sadgan(10)
341	sadgan(0)=""		'0
342	sadgan(1)="��"		'100
343	sadgan(2)="�����"	'200
344	sadgan(3)="����"	'300
345	sadgan(4)="������"	'400
346	sadgan(5)="�����"	'500
347	sadgan(6)="����"	'600
348	sadgan(7)="�����"	'700
349	sadgan(8)="�����"	'800
350	sadgan(9)="����"	'900
351
352	n=len(digits3)
353
354	Convert3dig=""
355	a1 = digits3/100
356	if a1>0 then 
357		Convert3dig=Convert3dig & sadgan(int(a1)) & " "
358	end if
359
360	digits3_2=digits3-int(a1)*100
361	if not (digits3_2=0 or a1<1) then 
362		Convert3dig=Convert3dig &  " � "
363	end if
364	
365	if digits3_2>19 then
366		a2 = digits3_2/10
367		if a2>0 then 
368			Convert3dig=Convert3dig & dahgan(int(a2)) & " "
369		end if
370
371		digits3_3=digits3_2-int(a2)*10
372		if not (digits3_3=0 or a2<1) then 
373			Convert3dig=Convert3dig &  " � "
374		end if
375		Convert3dig=Convert3dig & yekan(int(digits3_3)) & " "
376	else
377		a2 = digits3_2
378		if a2>0 then 
379			Convert3dig=Convert3dig & yekan(int(a2)) & " "
380		end if
381	end if
382	
383End Function
384
385function MapURL(path)
386
387     dim rootPath, url
388
389     'Convert a physical file path to a URL for hypertext links.
390
391     rootPath = Server.MapPath("/")
392     url = Right(path, Len(path) - Len(rootPath)+2)
393     MapURL = Replace(url, "\", "/")
394
395end function 
396
397sub ListFolderContents(path)
398
399 dim fs, folder, file, item, url
400
401 set fs = CreateObject("Scripting.FileSystemObject")
402 set folder = fs.GetFolder(path)
403
404'Display the target folder and info.
405
406 Response.Write("<li><b>" & folder.Name & "</b> - " _
407   & folder.Files.Count & " files, ")
408 if folder.SubFolders.Count > 0 then
409   Response.Write(folder.SubFolders.Count & " directories, ")
410 end if
411 Response.Write(Round(folder.Size / 1024) & " KB total." _
412   & "</li>" & vbCrLf)
413
414 Response.Write("<ul style='margin:0px 0px 0px 10px;'>" & vbCrLf)
415
416 'Display a list of sub folders.
417
418 for each item in folder.SubFolders
419   ListFolderContents(item.Path)
420 next
421
422 'Display a list of files.
423
424 for each item in folder.Files
425   url = MapURL(item.path)
426   Response.Write("<li><a href=""myfile/" & url & """>" _
427     & item.Name & "</a> - " _
428     & item.Size & " bytes, " _
429     & "last modified on " & item.DateLastModified & "." _
430     & "</li>" & vbCrLf)
431 next
432
433 Response.Write("</ul>" & vbCrLf)
434
435end sub   
436
437'------------------------------------------------------------ END
438
439
440'<SCRIPT LANGUAGE="JavaScript" src="/beta/jquery-1.5.2.min.js"></SCRIPT>
441%>