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