/beta/AP/verify.asp
ASP | 229 lines | 179 code | 32 blank | 18 comment | 20 complexity | 46e9c7640e03d0d14e9bf7294a5c6876 MD5 | raw file
1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><% 2'AP (7) 3PageTitle= " ����� ������" 4SubmenuItem=2 5if not Auth(7 , 2) then NotAllowdToViewThisPage() 6 7%> 8<!--#include file="top.asp" --> 9<!--#include File="../include_farsiDateHandling.asp"--> 10<!--#include File="../include_JS_InputMasks.asp"--> 11<% 12'----------------------------------------------------------------------------------------------------- 13'-------------------------------------------------------------------------------------- Submit Payment 14'----------------------------------------------------------------------------------------------------- 15if request.form("Submit")="�����" then 16 17 'Check for permission for APPROVING the Voucher 18 if NOT Auth(7 , 2) then NotAllowdToViewThisPage() 19 20 ON ERROR RESUME NEXT 21 VouchID = clng(request("VouchID")) 22 if Err.Number<>0 then 23 Err.clear 24 conn.close 25 response.redirect "top.asp?errMsg=" & Server.URLEncode("����� ������ ���� ����� ����.") 26 end if 27 ON ERROR GOTO 0 28 29 set RSV=Conn.Execute ("SELECT * FROM Vouchers WHERE (id="& VouchID & ") and Verified = 0" ) 30 if RSV.EOF then 31 response.redirect "?errMsg=" & Server.URLEncode("���!<br>���� ������� ����� ���� �� ���� ����� ��� ���.") 32 end if 33 TotalPrice = RSV("TotalPrice") 34 VendorID = RSV("VendorID") 35 totalVat = RSV("totalVat") 36 37 effectiveDate = RSV("EffectiveDate") 38 39 '---- Checking wether EffectiveDate is valid in current open GL 40 if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then 41 Conn.close 42 response.redirect "?errMsg=" & Server.URLEncode("���!<br>����� ���� ��� ������ ����� �� ��� ���� ���� ��� ����.<br><br> �� ����� ���� ������ �� ��� ���� �� ��� ���� ��� ��.") 43 end if 44 '---- 45 '----- Check GL is closed 46 if (session("IsClosed")="True") then 47 Conn.close 48 response.redirect "?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.") 49 end if 50 '---- 51 Conn.Execute ("UPDATE Vouchers SET Verified = 1 WHERE (id = "& VouchID & ")") 52 Conn.Execute ("UPDATE Accounts SET APBalance=APBalance+"& TotalPrice & " WHERE (ID = "& VendorID & ")") 53 54 creationDate= shamsiToday() 55 creationTime= CurrentTime10() 56 57 GLAccount= "89099" 'This must be changed... (Misc. Purchase) 58 firstGLAccount= "41001" 'This must be changed... (Business Creditors) 59 60 '*** Type = 6 means APItem is a Voucher 61 62 conn.Execute("INSERT INTO APItems (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, IsCredit, Type, Link, AmountOriginal, createdDate, creationTime, CreatedBy, RemainedAmount, Vat) VALUES (" &_ 63 GLAccount & ", '"& OpenGL & "', '"& firstGLAccount & "', '"& VendorID & "', N'"& EffectiveDate & "', 1, 6, '"& VouchID & "', '"& TotalPrice & "', N'"& creationDate & "', N'"& creationTime & "', '"& session("ID") & "', '"& TotalPrice & "', '" & totalVat & "')" ) 64 65 Conn.close 66 response.redirect "AccountReport.asp?act=showVoucher&voucher="& VouchID 67 68end if 69 70'----------------------------------------------------------------------------------------------------- 71'-------------------------------------------------------------------------------- Show Voucher Details 72'----------------------------------------------------------------------------------------------------- 73if request("VouchID") <> "" then 74 response.write "<br><br>" 75 call showAlert("������� ��� ���� ���.<br><br>��� ������ ����� �� ��� ���� �� ����� .<br><br>���� ���� �� �� �� �� ���� �� ��� ���� ����� ��� ��� �� �� ����� �� ���� ���� Ȑ����. <br><br>��� ����� �� ����.<br><br>���� �� <A HREF='AccountReport.asp?act=showVoucher&voucher="& request("VouchID") & "'><B>�����</B></A> �� �����." , CONST_MSG_ALERT) 76 response.end 77end if 78 79'----------------------------------------------------------------------------------------------------- 80'------------------------------------------------------------------------------------------------ Main 81'----------------------------------------------------------------------------------------------------- 82 83'mySQL="SELECT DRV.OrdDate AS OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status, SUM(InvoiceLines.Price - InvoiceLines.Discount - InvoiceLines.Reverse) AS SalePrice, COUNT(InvoiceLines.Price) AS COUNT FROM (SELECT VoucherLines.*, PurchaseOrders.OrdDate, InvoiceOrderRelations.Invoice AS Invoice, InvoiceItems.ID AS InvoiceItem, PurchaseOrders.status FROM InvoiceItems RIGHT OUTER JOIN InvoiceOrderRelations INNER JOIN PurchaseRequests INNER JOIN PurchaseRequestOrderRelations ON PurchaseRequests.ID = PurchaseRequestOrderRelations.Req_ID ON InvoiceOrderRelations.[Order] = PurchaseRequests.Order_ID RIGHT OUTER JOIN PurchaseOrders ON PurchaseRequestOrderRelations.Ord_ID = PurchaseOrders.ID ON InvoiceItems.RelatedInventoryItemID = PurchaseOrders.TypeID FULL OUTER JOIN Vouchers INNER JOIN VoucherLines ON Vouchers.id = VoucherLines.Voucher_ID ON PurchaseOrders.ID = VoucherLines.RelatedPurchaseOrderID WHERE (PurchaseOrders.Status <> 'CANCEL') AND (Vouchers.Verified=0)) DRV LEFT OUTER JOIN InvoiceLines ON DRV.Invoice = InvoiceLines.Invoice AND DRV.InvoiceItem = InvoiceLines.Item GROUP BY DRV.OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status ORDER BY DRV.OrdDate" 84' S A M 85mySQL="SELECT DRV.ID, DRV.OrdDate AS OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status, SUM(InvoiceLines.Price - InvoiceLines.Discount - InvoiceLines.Reverse + InvoiceLines.Vat) AS SalePrice, COUNT(InvoiceLines.Price) AS COUNT FROM (SELECT Vouchers.ID, Voucherlines.RelatedPurchaseOrderID, Voucherlines.LineTitle, Voucherlines.Qtty, Voucherlines.Price, PurchaseOrders.OrdDate, InvoiceOrderRelations.Invoice AS Invoice, InvoiceItems.ID AS InvoiceItem, PurchaseOrders.status FROM InvoiceItems RIGHT OUTER JOIN InvoiceOrderRelations INNER JOIN PurchaseRequests INNER JOIN PurchaseRequestOrderRelations ON PurchaseRequests.ID = PurchaseRequestOrderRelations.Req_ID ON InvoiceOrderRelations.[Order] = PurchaseRequests.Order_ID RIGHT OUTER JOIN PurchaseOrders ON PurchaseRequestOrderRelations.Ord_ID = PurchaseOrders.ID ON InvoiceItems.RelatedInventoryItemID = PurchaseOrders.TypeID FULL OUTER JOIN Vouchers INNER JOIN VoucherLines ON Vouchers.id = VoucherLines.Voucher_ID ON PurchaseOrders.ID = VoucherLines.RelatedPurchaseOrderID WHERE (PurchaseOrders.Status <> 'CANCEL') AND (Vouchers.Verified = 0)) DRV LEFT OUTER JOIN InvoiceLines ON DRV.Invoice = InvoiceLines.Invoice AND DRV.InvoiceItem = InvoiceLines.Item GROUP BY DRV.ID, DRV.OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status ORDER BY DRV.OrdDate DESC, DRV.ID" 86 87set RSS=Conn.Execute (mySQL) '"SELECT * FROM Vouchers WHERE (Verified = 0)" ) 88%> 89<BR><BR><BR> 90<style> 91 .myTbl td {direction: LTR; text-align:right;} 92 .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; } 93</style> 94<FORM METHOD=POST ACTION="AccountReport.asp?act=showVoucher"> 95<TABLE dir=rtl style="border:2 solid #333399;" align=center width="90%"> 96 <TR bgcolor="#eeeeee" height=25> 97 <TD align=center colspan=7><B>��������� ����� ����</B></TD> 98 </TR> 99 <TR bgcolor="#eeeeee" height=25> 100 <TD width=10> # </TD> 101 <TD><INPUT TYPE="radio" NAME="" disabled></TD> 102 <TD width=120>������� </TD> 103 <TD>����� ������ </TD> 104 <TD>���� </TD> 105 <TD width=60>����� ���� </TD> 106 <TD> 107 <input style='width:120pt;border:0pt;background:transpanrent;font-size:7pt' value='���� �� ������'> 108 <input style='width:25pt;border:0pt;background:transpanrent;font-size:7pt' value='�����'> 109 <input style='width:35pt;border:0pt;background:transpanrent;font-size:7pt' value='����'> 110 <input style='width:35pt;border:0pt;background:transpanrent;font-size:7pt' value='���� ����'> 111 </TD> 112 </TR> 113 <TR bgcolor="#5555BB" height="2"> 114 <TD colspan=7></TD> 115 </TR> 116 <% 117 tmpCounter=0 118 119 Do while not RSS.eof 120 tmpCounter = tmpCounter + 1 121 122 if tmpCounter mod 2 = 1 then 123 tmpColor="#FFFFFF" 124 tmpColor2="#FFFFBB" 125 Else 126 tmpColor="#DDDDDD" 127 tmpColor2="#EEEEBB" 128 End if 129 130 DisableFlag = "" 131 vouchLines = "<table class='myTbl' >" 132 133 Do 134 Voucher= RSS("ID") 135 136 mySQL="SELECT Vouchers.Title, Vouchers.Number, Vouchers.TotalPrice, Vouchers.comment, Vouchers.CreationDate, Vouchers.VendorID, Accounts.AccountTitle FROM Vouchers INNER JOIN Accounts ON Vouchers.VendorID = Accounts.ID WHERE (Vouchers.ID = "& Voucher & ")" 137 set RST=Conn.Execute (mySQL) 138 139 Comment = RST("Comment") 140 VoucherTitle = RST("title") 141 VoucherPrice = RST("totalPrice") 142 CreationDate = RST("CreationDate") 143 Vendor = RST("VendorID") 144 AccountTitle = RST("AccountTitle") 145 number = RST("Number") 146 147 RST.close 148 149 vouchLines = vouchLines & "<tr><td><input readonly onclick='window.open(""../purchase/outServiceTrace.asp?od=" & RSS("RelatedPurchaseOrderID") & """,""_blank"","""")' type='' style='width:120pt;border:0pt;background:transpanrent;background:transpanrent;font:7pt blue;cursor:hand' value='" & RSS("LineTitle") & "'></td></a><td style='width:25pt;font-size:7pt;'>" & RSS("qtty") & "</td><td><input readonly type='' style='width:35pt;border:0pt;background:transpanrent;font-size:7pt;cursor:hand' value='" & Separate(RSS("price")) & "'></td><td> " 150 if trim(" " & RSS("Invoice"))="" then 151 vouchLines = vouchLines & "<span disabled style='font-size:7pt'>������ ����</span>" 152 else 153 vouchLines = vouchLines & "<span style='font-size:7pt'><A HREF='../AR/AccountReport.asp?act=showInvoice&invoice="& RSS("Invoice")& "' target='_blank'>" & Separate(RSS("SalePrice")) 154 if RSS("count") > 1 then 155 vouchLines = vouchLines & " (" & RSS("count") & " ���)" 156 end if 157 if trim(RSS("SalePrice"))="" or isnull(RSS("SalePrice")) then 158 vouchLines = vouchLines & "������ ����" 159 end if 160 vouchLines = vouchLines & "</A></span>" 161 end if 162 vouchLines = vouchLines & "</tr>" 163 if RSS("status") <> "OK" then DisableFlag=" disabled" 164 RSS.moveNext 165 if NOT RSS.eof then 166 nextVoucher=RSS("ID") 167 else 168 nextVoucher=-1 169 end if 170 Loop While Voucher= nextVoucher AND NOT RSS.eof 171 172 vouchLines = vouchLines & "</table>" 173 %> 174 175 <TR bgcolor="<%=tmpColor%>" <%=DisableFlag%> Title="<% 176 if Comment<>"-" then 177 response.write "�����: " & Comment 178 else 179 response.write "����� �����" 180 end if 181 %>"> 182 <TD><INPUT TYPE="hidden" name=color1 value="<%=tmpColor%>"><INPUT TYPE="hidden" name=color2 value="<%=tmpColor2%>"><A target="_blank" HREF="AccountReport.asp?act=showVoucher&voucher=<%=Voucher%>"><%=Voucher%></A></TD> 183 <TD><INPUT TYPE="radio" NAME="voucher" VALUE="<%=Voucher%>" onfocus="setColorFocus(this)" onblur="setColorBlur(this)" id="<%=tmpCounter-1%>"></TD> 184 <TD><%=AccountTitle%></TD> 185 <TD><%=VoucherTitle%></TD> 186 <TD dir=LTR align=right><%=Separate(VoucherPrice)%></TD> 187 <TD align=left><span dir=ltr><%=CreationDate%></span></TD> 188 <TD><%=vouchLines%></TD> 189 </TR> 190 <% 191 Loop 192 %> 193</TABLE> 194<br> 195<br> 196<center><INPUT TYPE="submit" Name="Submit" Value="������ ���� �����" class="inputBut" style="width:150px;" tabIndex="14"> 197</form> 198</center> 199 200 201<SCRIPT LANGUAGE="JavaScript"> 202<!-- 203function setColorFocus(obj){ 204 ii=parseInt(obj.id) 205 theTR = obj.parentNode.parentNode 206 theTR.setAttribute("bgColor",document.getElementsByName("color2")[ii].value) 207} 208 209function setColorBlur(obj){ 210 ii=parseInt(obj.id) 211 theTR = obj.parentNode.parentNode 212 theTR.setAttribute("bgColor",document.getElementsByName("color1")[ii].value) 213} 214 215/*function setColor(obj) 216{ 217 for(i=0; i<document.all.voucher.length; i++) 218 { 219 theTR = document.all.voucher[i].parentNode.parentNode 220 theTR.setAttribute("bgColor","<%=AppFgColor%>") 221 } 222 theTR = obj.parentNode.parentNode 223 theTR.setAttribute("bgColor","#FFFFFF") 224}*/ 225 226//--> 227</SCRIPT> 228 229<!--#include file="tah.asp" -->