/beta/accounting/moeen.asp

http://github.com/khaneh/Orders · ASP · 436 lines · 378 code · 42 blank · 16 comment · 66 complexity · 4621d8eee2a90f61136ba4659039f377 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. Response.Buffer=false
  3. 'Accounting (8)
  4. PageTitle= " "
  5. SubmenuItem=5
  6. if not Auth(8 , "A") then NotAllowdToViewThisPage()
  7. %>
  8. <!--#include file="top.asp" -->
  9. <!--#include File="../include_farsiDateHandling.asp"-->
  10. <!--#include File="../include_JS_InputMasks.asp"-->
  11. <style>
  12. .MoeenTR1 { background-color: #eeeeee; }
  13. .MoeenTR1 td{ width:20pt;border-left:solid 1px black; border-bottom:solid 2 black; font-size:8pt; padding:2px; text-align:center;}
  14. </style>
  15. <%
  16. '-----------------------------------------------------------------------------------------------------
  17. '----------------------------------------------------------------------------------------- Search Form
  18. '------------------------------------------------------------------------------------------ +
  19. '--------------------------------------------------------------------------------------------- Scripts
  20. '-----------------------------------------------------------------------------------------------------
  21. account = request("accountID")
  22. if account <> "" then accountName = request("accountName")
  23. ToAccount = request("ToAccount")
  24. if ToAccount = "" then
  25. ToAccount = account
  26. ToAccountName= accountName
  27. else
  28. ToAccount = request("ToAccount")
  29. ToAccountName= request("ToAccountName")
  30. end if
  31. FromDate = request("FromDate")
  32. ToDate = request("ToDate")
  33. Order = request("Order")
  34. if request("ShowRemained")="on" then
  35. ShowRemained=true
  36. else
  37. ShowRemained=false
  38. end if
  39. 'if account = "" then account = "11011"
  40. 'if accountName = "" then accountName = ""
  41. if FromDate = "" then FromDate = shamsiToday()
  42. if ToDate = "" then ToDate = shamsiToday()
  43. %>
  44. <input type="hidden" Name='tmpDlgArg' value=''>
  45. <input type="hidden" Name='tmpDlgTxt' value=''>
  46. <BR>
  47. <FORM Name="SearchForm" METHOD=POST ACTION="?act=Show" onSubmit="return checkValidation();">
  48. <TABLE style="border:1 solid #330066;" align=center>
  49. <TR>
  50. <TD align=left></TD>
  51. <TD><INPUT dir="LTR" TYPE="text" NAME="accountID" maxlength="5" size="10" value="<%=account%>" onKeyPress='return mask(this);' onBlur='check(this);document.all.ToAccount.value=this.value;check(document.all.ToAccount);'></TD>
  52. <TD><INPUT TYPE="text" NAME="accountName" size=30 readonly value="<%=accountName%>" style="background-color:transparent"></TD>
  53. </TR>
  54. <TR>
  55. <TD align=left> </TD>
  56. <TD><INPUT dir="LTR" TYPE="text" NAME="ToAccount" maxlength="5" size="10" value="<%=ToAccount%>" onKeyPress='return mask(this);' onBlur='check(this);'></TD>
  57. <TD><INPUT TYPE="text" NAME="ToAccountName" size=30 readonly value="<%=ToAccountName%>" style="background-color:transparent"></TD>
  58. </TR>
  59. <TR>
  60. <TD align=left style="cursor:hand" title=" " onclick="subtractOneDay();"> </TD>
  61. <TD><INPUT dir="LTR" TYPE="text" NAME="FromDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=FromDate%>"></TD>
  62. <TD>
  63. <INPUT TYPE="checkbox" NAME="ShowRemained" <%if ShowRemained then response.write "checked"%>> .
  64. </TD>
  65. </TR>
  66. <TR>
  67. <TD align=left style="cursor:hand" title=" " onclick="addOneDay();"> </TD>
  68. <TD><INPUT dir="LTR" TYPE="text" NAME="ToDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=ToDate%>"></TD>
  69. <TD align=center>
  70. <INPUT TYPE="submit" NAME="submit" value="">
  71. <INPUT TYPE="hidden" Name="Order" Value="">
  72. </TD>
  73. </TR>
  74. </TABLE>
  75. </FORM>
  76. <SCRIPT LANGUAGE="JavaScript">
  77. <!--
  78. var dialogActive=false;
  79. function mask(src){
  80. var theKey=event.keyCode;
  81. if (theKey==13 || theKey==32){
  82. event.keyCode=9
  83. dialogActive=true
  84. document.all.tmpDlgArg.value="#"
  85. document.all.tmpDlgTxt.value=" :"
  86. window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
  87. dialogActive=false
  88. if (document.all.tmpDlgTxt.value !="") {
  89. window.showModalDialog('dialog_selectGL.asp?act=select&name='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
  90. if (document.all.tmpDlgArg.value!="#"){
  91. Arguments=document.all.tmpDlgArg.value.split("#")
  92. src.value=Arguments[0];
  93. document.all.accountName.value=Arguments[1];
  94. }
  95. }
  96. }
  97. }
  98. function check(src){
  99. if (!dialogActive){
  100. if (window.XMLHttpRequest) {
  101. var objHTTP=new XMLHttpRequest();
  102. } else if (window.ActiveXObject) {
  103. var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  104. }
  105. objHTTP.open('GET','xml_GLAccount.asp?id='+src.value,false);
  106. objHTTP.send();
  107. tmpStr = unescape( objHTTP.responseText);
  108. if (tmpStr == ' ')
  109. src.value='';
  110. if (src.name=='accountID'){
  111. document.all.accountName.value=tmpStr;
  112. }
  113. else if (src.name=='ToAccount'){
  114. document.all.ToAccountName.value=tmpStr;
  115. }
  116. }
  117. }
  118. function checkValidation(){
  119. try{
  120. box=document.all.accountID;
  121. check(box);
  122. if (box.value==''){
  123. box.style.backgroundColor="red";
  124. alert(" ");
  125. box.style.backgroundColor="";
  126. box.focus();
  127. return false;
  128. }
  129. box=document.all.FromDate;
  130. if (box.value!='' && box.value!=null){
  131. if (!acceptDate(box))
  132. return false;
  133. }
  134. box=document.all.ToDate;
  135. if (box.value!='' && box.value!=null){
  136. if (!acceptDate(box))
  137. return false;
  138. }
  139. }catch(e){
  140. alert(" ");
  141. return false;
  142. }
  143. }
  144. function addOneDay(){
  145. try{
  146. box=document.all.FromDate;
  147. if (box.value!='' && box.value!=null){
  148. if (acceptDate(box)){
  149. year=parseInt(box.value.substring(0,4));
  150. month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
  151. day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
  152. day++;
  153. if (day>31){
  154. day=1;
  155. month++;
  156. }
  157. if (month>12){
  158. month=1;
  159. year++;
  160. }
  161. box.value=''+year+'/'+month+'/'+day;
  162. acceptDate(box);
  163. }
  164. }
  165. box=document.all.ToDate;
  166. if (box.value!='' && box.value!=null){
  167. if (acceptDate(box)){
  168. year=parseInt(box.value.substring(0,4));
  169. month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
  170. day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
  171. day++;
  172. if (day>31){
  173. day=1;
  174. month++;
  175. }
  176. if (month>12){
  177. month=1;
  178. year++;
  179. }
  180. box.value=''+year+'/'+month+'/'+day;
  181. acceptDate(box);
  182. }
  183. document.SearchForm.submit.click();
  184. }
  185. }catch(e){
  186. alert(" ");
  187. return false;
  188. }
  189. }
  190. function subtractOneDay(){
  191. try{
  192. box=document.all.FromDate;
  193. if (box.value!='' && box.value!=null){
  194. if (acceptDate(box)){
  195. year=parseInt(box.value.substring(0,4));
  196. month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
  197. day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
  198. day--;
  199. if (day<1){
  200. day=31;
  201. month--;
  202. }
  203. if (month<1){
  204. month=12;
  205. year--;
  206. }
  207. box.value=''+year+'/'+month+'/'+day;
  208. acceptDate(box);
  209. }
  210. }
  211. box=document.all.ToDate;
  212. if (box.value!='' && box.value!=null){
  213. if (acceptDate(box)){
  214. year=parseInt(box.value.substring(0,4));
  215. month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
  216. day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
  217. day--;
  218. if (day<1){
  219. day=31;
  220. month--;
  221. }
  222. if (month<1){
  223. month=12;
  224. year--;
  225. }
  226. box.value=''+year+'/'+month+'/'+day;
  227. acceptDate(box);
  228. }
  229. document.SearchForm.submit.click();
  230. }
  231. }catch(e){
  232. alert(" ");
  233. return false;
  234. }
  235. }
  236. //-->
  237. </SCRIPT>
  238. <SCRIPT LANGUAGE="JavaScript">
  239. <!--
  240. function sortSubmit(num){
  241. document.SearchForm.Order.value=num;
  242. document.SearchForm.submit.click();
  243. }
  244. //-->
  245. </SCRIPT>
  246. <%
  247. '-----------------------------------------------------------------------------------------------------
  248. '--------------------------------------------------------------------------------------- Search Action
  249. '-----------------------------------------------------------------------------------------------------
  250. if request("act")="Show" then
  251. ' Major Changes By kid 830820
  252. Order=request("Order")
  253. select case Order
  254. case "1":
  255. order=", GLDocID "
  256. case "-1":
  257. order=", GLDocID DESC"
  258. case "2":
  259. order=", GLDocDate"
  260. case "-2":
  261. order=", GLDocDate DESC"
  262. case else:
  263. order=", GLDocDate, IsCredit DESC, Amount"
  264. end select
  265. ' if ShowRemained then
  266. mySQL="SELECT GLAccounts.ID, GLAccounts.Name AS AccountName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLs.ID AS GLID, GLs.Name AS GLname FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL INNER JOIN GLAccountGroups ON GLs.ID = GLAccountGroups.GL AND GLAccountSuperGroups.ID = GLAccountGroups.GLSuperGroup INNER JOIN GLAccounts ON GLs.ID = GLAccounts.GL AND GLAccountGroups.ID = GLAccounts.GLGroup WHERE (GLs.ID = "& OpenGL & ") AND (GLAccounts.ID >= "& account & ") AND (GLAccounts.ID <= "& ToAccount & ") ORDER BY GLAccounts.ID"
  267. ' else
  268. 'mySQL="SELECT GLAccounts.ID, GLAccounts.Name AS AccountName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLs.ID AS GLID, GLs.Name AS GLname FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL INNER JOIN GLAccountGroups ON GLs.ID = GLAccountGroups.GL AND GLAccountSuperGroups.ID = GLAccountGroups.GLSuperGroup INNER JOIN GLAccounts ON GLs.ID = GLAccounts.GL AND GLAccountGroups.ID = GLAccounts.GLGroup INNER JOIN (SELECT DISTINCT GLAccount AS ID FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount >= "& account & ") AND (GLAccount <= "& ToAccount & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "')) UsedAccs ON UsedAccs.ID = GLAccounts.ID WHERE (GLs.ID = "& OpenGL & ") ORDER BY GLAccounts.ID"
  269. 'end if
  270. set rsGLAccs=Conn.Execute (mySQL)
  271. Do While not rsGLAccs.EOF
  272. GLAccount=rsGLAccs("ID")
  273. AccountInfoParams = "&DateFrom=" & FromDate & "&DateTo=" & ToDate
  274. if ShowRemained then AccountInfoParams = AccountInfoParams & "&ShowRemained=on"
  275. %>
  276. <TABLE dir=rtl align=center width=640 cellspacing=0 cellpadding=0 style="border:2 solid #330066;">
  277. <TR bgcolor="#CCCCEE" height="30">
  278. <TD colspan=7>
  279. <A HREF="AccountInfo.asp?OpenGL=<%=rsGLAccs("GLID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("GLname")%></A>
  280. > <A HREF="AccountInfo.asp?act=groups&id=<%=rsGLAccs("SuperGroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("SuperGroupName")%></A>
  281. > <A HREF="AccountInfo.asp?act=account&id=<%=rsGLAccs("GroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("GroupName")%></A>
  282. > <%=rsGLAccs("AccountName")%>
  283. [<%=GLAccount%>]
  284. </TD>
  285. </TR>
  286. <TR bgcolor="black" height="2">
  287. <TD colspan="7" style="padding:0;"></TD>
  288. </TR>
  289. <TR class="MoeenTR1">
  290. <TD style="width:60px;"><A HREF="javaScript:sortSubmit(1);">v</A>&nbsp;&nbsp;<A HREF="javaScript:sortSubmit(-1);">^</A></TD>
  291. <TD style="width:80px;"><A HREF="javaScript:sortSubmit(2);">v</A>&nbsp; &nbsp;<A HREF="javaScript:sortSubmit(-2);">^</A></TD>
  292. <TD style="width:200px;"></TD>
  293. <TD style="width:100px;"></TD>
  294. <TD style="width:100px;"></TD>
  295. <TD style="width:10px;">-</TD>
  296. <TD style="width:100px;border-left:0;"></TD>
  297. </TR>
  298. <%
  299. if ShowRemained then
  300. mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount = "& GLAccount & ") AND (GLDocDate < N'"& FromDate & "') GROUP BY GLAccount"
  301. set RSS=Conn.Execute (mySQL)
  302. if RSS.eof then
  303. debit = 0
  304. credit = 0
  305. else
  306. debit = cdbl(RSS("totalDebit"))
  307. credit = cdbl(RSS("totalCredit"))
  308. end if
  309. RSS.close
  310. remainedAmount = debit - credit
  311. SumCredit = credit
  312. SumDebit = debit
  313. %>
  314. <TR bgcolor="#DDDDDD" height=30>
  315. <TD colspan=3 align=left style="border-left:solid 1px black"><INPUT TYPE="text" style="text-align:left;" value=" <%=replace(FromDate,"/",".")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
  316. <TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(debit)%>&nbsp;</TD>
  317. <TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(credit)%>&nbsp;</TD>
  318. <TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %><% else %><% end if %></TD>
  319. <TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
  320. </TR>
  321. <TR bgcolor="black" height="2">
  322. <TD colspan="7" style="padding:0;"></TD>
  323. </TR>
  324. <%
  325. else
  326. remainedAmount = 0
  327. SumCredit = 0
  328. SumDebit = 0
  329. end if
  330. mySQL="SELECT * FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount = "& GLAccount & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') ORDER BY GLAccount" & order
  331. set RSS=Conn.Execute (mySQL)
  332. tmpCounter=0
  333. Do while not RSS.eof
  334. tmpCounter = tmpCounter + 1
  335. if tmpCounter mod 2 = 1 then
  336. tmpColor="#FFFFFF"
  337. tmpColor2="#FFFFBB"
  338. Else
  339. tmpColor="#DDDDDD"
  340. tmpColor2="#EEEEBB"
  341. End if
  342. debit = 0
  343. credit = 0
  344. if RSS("IsCredit") then
  345. credit = cdbl(RSS("Amount"))
  346. else
  347. debit = cdbl(RSS("Amount"))
  348. end if
  349. remainedAmount = remainedAmount - credit + debit
  350. SumCredit = SumCredit + credit
  351. SumDebit = SumDebit + debit
  352. %>
  353. <TR bgcolor="<%=tmpColor%>" height=30>
  354. <TD style="border-left:solid 1px black"><A HREF="javascript:void(0);" onclick="window.open('GLMemoDocShow.asp?id=<%=RSS("GLDoc")%>')"><%=RSS("GLDocID")%></A></TD>
  355. <TD align=center dir=ltr style="border-left:solid 1px black"><%=RSS("GLDocDate")%></TD>
  356. <TD width=100 style="border-left:solid 1px black">
  357. <INPUt size="70" TYPE="text" value="<%=RSS("Description")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent">
  358. </TD>
  359. <TD dir=ltr align=right style="border-left:solid 1px black"><% if debit<>"0" then %> <%=Separate(debit)%><% end if %> &nbsp;</TD>
  360. <TD dir=ltr align=right style="border-left:solid 1px black"><% if credit<>"0" then %> <%=Separate(credit)%><% end if %> &nbsp;</TD>
  361. <TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %><% else %><% end if %></TD>
  362. <TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
  363. </TR>
  364. <%
  365. RSS.moveNext
  366. Loop
  367. RSS.close
  368. tmpCounter = tmpCounter + 1
  369. if tmpCounter mod 2 = 1 then
  370. tmpColor="#FFFFFF"
  371. tmpColor2="#FFFFBB"
  372. Else
  373. tmpColor="#DDDDDD"
  374. tmpColor2="#EEEEBB"
  375. End if
  376. %>
  377. <TR bgcolor="black" height="2">
  378. <TD colspan="7" style="padding:0;"></TD>
  379. </TR>
  380. <TR bgcolor="<%=tmpColor%>" height=30>
  381. <TD colspan=3 align=left style="border-left:solid 1px black"><INPUT TYPE="text" style="text-align:left;" value=" <%=GLAccount%> <%=replace(ToDate,"/",".")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
  382. <TD dir=ltr align=right style="border-left:solid 1px black"><% if SumDebit<>"0" then response.write Separate(SumDebit)%> &nbsp;</TD>
  383. <TD dir=ltr align=right style="border-left:solid 1px black"><% if SumCredit<>"0" then response.write Separate(SumCredit)%> &nbsp;</TD>
  384. <TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %><% else %><% end if %></TD>
  385. <TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
  386. </TR>
  387. </TABLE><br><br>
  388. <%
  389. rsGLAccs.moveNext
  390. Loop
  391. rsGLAccs.close
  392. Set rsGLAccs = Nothing
  393. end if %>
  394. <!--#include file="tah.asp" -->