/beta/cashReg/ReceiptInput.asp
ASP | 847 lines | 736 code | 57 blank | 54 comment | 83 complexity | f44a3437a8e1c27a619bfe89e1dc2930 MD5 | raw file
1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><% 2'CashRegister (9) 3PageTitle="������" 4SubmenuItem=1 5if not Auth(9 , 1) then NotAllowdToViewThisPage() 6 7%> 8<!--#include file="top.asp" --> 9<!--#include File="../include_farsiDateHandling.asp"--> 10<!--#include File="../include_JS_InputMasks.asp"--> 11 12<% 13function Link2Trace(OrderNo) 14 Link2Trace="<A HREF='../order/orderEdit.asp?e=n&radif="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>" 15end function 16 17%> 18<style> 19 .RcpTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; } 20 .RcpMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;} 21 .RcpMainTableTH { background-color: #C3C300;} 22 .RcpMainTableTR { background-color: #CCCC88; border: 0; } 23 .RcpRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;} 24 .RcpRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;} 25 .RcpHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;} 26 .RcpHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;} 27 .RcpHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: right-to-left;} 28 .RcpGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;} 29 .GenTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; } 30 .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; } 31 .GrayOutLine {border: 1px solid gray; } 32</style> 33<SCRIPT LANGUAGE="JavaScript"> 34<!-- 35var okToProceed=false; 36var currentRow=null; 37//--> 38</SCRIPT> 39<!--#include File="../include_UtilFunctions.asp"--> 40<% 41if request("act")="ShowReceipt" then 42 Receipt=clng(request("id")) 43%> 44 <SCRIPT LANGUAGE="JavaScript"> 45 <!-- 46 var status = -1; 47 var timeoutID= 0; 48 function openCashDrawer() 49 { 50 drawerPresent = true; 51 try 52 { 53 document.getElementById('Drawer').OpenUPort(1); 54 } 55 catch(e) 56 { 57 drawerPresent = false; 58 } 59 60 if ( drawerPresent ) 61 { 62 //document.getElementById('Drawer').OpenUPort(1); 63 status = document.getElementById('Drawer').UCashDrawerStatus(1); 64 if (status>-1) 65 { 66 document.getElementById('Drawer').OpenUCashDrawer(1); 67 } 68 //document.getElementById('Drawer').CloseUPort(1); 69 } 70 } 71 function closeCashDrawer() 72 { 73 drawerPresent = true; 74 try 75 { 76 document.getElementById('Drawer').OpenUPort(1); 77 } 78 catch(e) 79 { 80 drawerPresent = false; 81 } 82 83 if ( drawerPresent ) 84 { 85 //document.getElementById('Drawer').OpenUPort(1); 86 document.getElementById('Drawer').OpenUPort(1); 87 // Status: 1:Open, 0:Close 88 while ( document.getElementById('Drawer').UCashDrawerStatus(1)==1 ) 89 { 90 alert('���� ���� ����� �� ������'); 91 } 92 //document.getElementById('Drawer').CloseUPort(1); 93 } 94 } 95 //--> 96 </SCRIPT> 97 98 <OBJECT ID="Drawer" WIDTH="1" HEIGHT="1" CLASSID="CLSID:A46E44C7-AC96-4EFE-B8D7-EE7D67990B6F"> 99 </OBJECT> 100 101 <BR><BR><BR> 102 <CENTER> 103 <% ReportLogRow = PrepareReport ("Receipt.rpt", "Recept_ID", Receipt, "/beta/dialog_printManager.asp?act=Fin") %> 104 <INPUT TYPE="button" value=" �ǁ " Class="GenButton" style="border:1 solid blue;" onclick="openCashDrawer();closeCashDrawer();printThisReport(this,<%=ReportLogRow%>);"> 105 </CENTER> 106 <BR><iframe name=f1 id=f1 src="/CRReports/?Id=<%=ReportLogRow%>" align=center style="width:700; height:410; border-style: none" border=0 FRAMEBORDER=0 scrollbars=no ></iframe> 107 <BR> 108 <BR> 109<% 110 response.end 111end if 112 113mySQL="SELECT * FROM CashRegisters WHERE (IsOpen=1) AND (Cashier='"& session("ID") & "')" 114Set RS1= conn.Execute(mySQL) 115if RS1.eof then 116%><br><br> 117 <TABLE width='70%' align='center'> 118 <TR> 119 <TD align=center bgcolor=#FFBBBB style='border: solid 1pt black'><BR><b>���� <%=CSRName%> ��� ����� ��� ������ � <br><br>�� ��� �� ���� ���� ��� �� ��� ��� <br>������."</b><BR><BR></TD> 120 </TR> 121 </TABLE> 122<% conn.close 123 response.end 124else 125 CashRegID=RS1("ID") 126 theBanker=RS1("Banker") 127 CashRegName=RS1("NameDate") 128 Set RS1=nothing 129end if 130 131if request("act")="submitsearch" then 132 if isnumeric(request("SearchBox")) then 133 orderID=clng(request("SearchBox")) 134 mySQL="SELECT Invoices.Issued, Invoices.Approved, Invoices.ID, Invoices.TotalReceivable, Invoices.Customer FROM InvoiceOrderRelations INNER JOIN Invoices ON InvoiceOrderRelations.Invoice = Invoices.ID WHERE ([Order] = '"& orderID & "')" 135 Set RS1=Conn.Execute(mySQL) 136 if RS1.eof then 137 Conn.close 138 response.redirect "?errmsg=" & Server.URLEncode("��� ����� ���� ������ ���� ���.") 139 else 140 theInvoice=RS1("ID") 141 theCustomer=RS1("Customer") 142 if RS1("Issued") then 143 Conn.close 144 response.redirect "?act=getReceipt&selectedCustomer=" & theCustomer & "&selectedInvoice=" & theInvoice 145 else 146 response.write "<br><br>" 147 148 if RS1("Approved") then 149 extraDesc="<br>(�э�� �� ����� ��� ���)" 150 end if 151 152 call showAlert ("<b>������ ����� �� ��� ����� ���� ���� ���."& extraDesc & " <br>(����: "& Separate(RS1("TotalReceivable")) & ")",CONST_MSG_ALERT) 153 response.write "<Blockquote>" 154 response.write "<br><br>���� �� ���Ͽ<br></b>" 155 response.write "<br><br><li><A target='_blank' HREF='../AR/AccountReport.asp?act=showInvoice&invoice="& theInvoice & "'>���� ��� �����</A>" 156 response.write "<br><br><li><A HREF='?act=getReceipt&selectedCustomer=" & theCustomer & "'>����� �� ���.</A>" 157 if RS1("Approved") then 158 response.write "<br><br><li> ��� ������ �� <A target='_blank' HREF='../AR/InvoiceEdit.asp?act=search&order="& request("SearchBox") & "'>���� �� ���</A> " 159 response.write "� ��� �� �� <A HREF='?act=submitsearch&SearchBox="& request("SearchBox") & "'>����� �� ���.</A>" 160 end if 161 response.write "</Blockquote>" 162 end if 163 end if 164 elseif request("SearchBox") <> "" then 165 SA_TitleOrName=request("SearchBox") 166 SA_Action="return true;" 167 SA_SearchAgainURL="ReceiptInput.asp" 168 SA_StepText="��� ��� : ������ ����" 169%> 170 <FORM METHOD=POST ACTION="?act=getReceipt"> 171 <!--#include File="../AR/include_SelectAccount.asp"--> 172 </FORM> 173<% 174 else 175 response.redirect "?errmsg=" & Server.URLEncode("����� ����� ���� ���� ��� ����.") 176 end if 177elseif request("act")="getReceipt" then 178 if not isnumeric(request("selectedCustomer")) then 179 response.write "EORROR" 180 response.end 181 end if 182 if request("Reason")="" then 183 Reason=1 184 else 185 Reason=cint(request("Reason")) 186 end if 187 if Reason=1 then 188 sys="AR" 189 elseif Reason=2 then 190 sys="AP" 191 else 192 sys="AO" 193 end if 194 195 customerID=clng(request("selectedCustomer")) 196 selectedInvoice=request.queryString("selectedInvoice") 197 mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')" 198 Set RS1 = conn.Execute(mySQL) 199 AccountNo=cdbl(RS1("ID")) 200 customerName=RS1("AccountTitle") 201 202 creationDate=shamsiToday() 203 204%> 205 <br><div dir='rtl'><B>��� ��� : ���� ������� ������ ���</B> 206 </div> 207<!-- ���� ������� ������ ��� --> 208 <hr> 209 <input type="hidden" Name='tmpDlgArg' value=''> 210 <input type="hidden" Name='tmpDlgTxt' value=''> 211 <input type="hidden" id="maxChequeDay" value="<%=rs1("maxChequeDay")%>"/> 212 <input type="hidden" id="maxChequeAmount" value="<%=rs1("maxChequeAmount")%>"/> 213 <input type="hidden" id="customerRemainCheque" /> 214 <FORM METHOD=POST ACTION="?act=submitReceipt" onsubmit="return submitCeck2();" id="form1"> 215 <TABLE Cellspacing="0" Cellpadding="10" align="center"> 216 <TR><TD valign='top'> 217 <table class="RcpMainTable" Cellspacing="1" Cellpadding="0" Width="500" align="center"> 218 <tr class="RcpMainTableTH"> 219 <td colspan="10" align='center' height='25px'>����� <span dir='LTR'><%=CashRegName%></span> - <%=CSRName%> 220 <INPUT TYPE="hidden" Name="CashRegID" Value="<%=CashRegID%>"> 221 </td> 222 </tr> 223 <tr class="RcpMainTableTH"> 224 <td colspan="10"><TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL"><TR> 225 <TD><table> 226 <tr> 227 <td align="left">����:</td> 228 <td align="right"> 229 <span id="customer"> 230 <INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><span><%=CustomerName%></span>. 231 </span></td> 232 </tr> 233 </table></TD> 234 <td><table> 235 <tr> 236 <td>���</td> 237 <td><input name="isA" value="1" type="radio"></td> 238 <td>�</td> 239 <td><input name="isA" value="0" type="radio"></td> 240 <td>��� ������</td> 241 <td><input id="asInvoice" name="isA" value="-1" type="radio" checked="checked"></td> 242 </tr> 243 </table></td> 244 <TD align="left"><table> 245 <tr> 246 <td align="left">�����:</td> 247 <td dir="LTR"> 248 <INPUT class="RcpGenInput date" style="text-align:Left;" NAME="ReceiptDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>" ></td> 249 <td dir="RTL"><%=weekdayname(weekday(date))%></td> 250 </tr> 251 </table></TD> 252 </TR></TABLE> 253 </td> 254 </tr> 255 <tr class="RcpMainTableTR"> 256 <TD colspan="10"><div> 257 <TABLE class="RcpTable" Cellspacing="1" Cellpadding="0" Dir="RTL"> 258 <tr height="40"> 259 <td colspan="2" align="left"> ���� ���: </td> 260 <td colspan="15"><INPUT dir="LTR" class="RcpRowInput2" TYPE="text" Name="CashAmount" size="15" onKeyPress="return maskNumber(this);" onBlur="setPrice(this)"> ���: <INPUT dir="RTL" class="RcpRowInput2" TYPE="text" Name="CashDescription" size="50" ></td> 261 </tr> 262 <tr height="30"> 263 <td colspan="15"> ��: <br></td> 264 </tr> 265 </TABLE></div></TD> 266 </TR> 267 <tr class="RcpMainTableTR"> 268 <TD colspan="10"><div> 269 <TABLE class="RcpTable" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855"> 270 <tr> 271 <td class="RcpHeadInput" align='center' width="25px"> # </td> 272 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" value="����� ��" size="12" tabindex="9999"></td> 273 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" value="�����" size="10" tabindex="9999"></td> 274 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" Value="����" size="10" tabindex="9999"></td> 275 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" Value="���" size="20" tabindex="9999"></td> 276 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" Value="����" size="15" tabindex="9999"></td> 277 </tr> 278 </TABLE></div></TD> 279 </TR> 280 <tr class="RcpMainTableTR"> 281 <TD colspan="10" dir="RTL"><div style="overflow:auto; height:130px;width:500px;"> 282 <TABLE class="RcpTable" Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855"> 283 <Tbody id="ChequeLines"> 284 285<% 286 for i=1 to 1 287 %> 288 <tr bgcolor='#F0F0F0' onclick="currentRow=this.rowIndex;" > 289 <td align='center' width="25px"><%=i%></td> 290 <td dir="LTR"><INPUT class="RcpRowInput" TYPE="text" NAME="ChequeNos" size="12" onKeyPress="return maskNumber(this);"></td> 291 <td dir="LTR"><INPUT class="RcpRowInput" style="text-align:left;" TYPE="text" NAME="ChequeDates" maxlength="10" size="10" onblur="chequeDate(this)"></td> 292 <td dir="RTL"><INPUT class="RcpRowInput" TYPE="text" NAME="Banks" size="10"></td> 293 <td dir="RTL"><INPUT class="RcpRowInput" TYPE="text" NAME="Descriptions" size="20"></td> 294 <td dir="LTR"><INPUT class="RcpRowInput" TYPE="text" NAME="Amounts" size="15" onKeyPress="return maskNumber(this);" onBlur="setPrice(this);"></td> 295 </tr> 296<% 297 next 298%> 299 <!--tr bgcolor='#F0F0F0' onclick="currentRow=this.rowIndex;" > 300 <td colspan="15"> 301 <INPUT class="RcpGenInput" TYPE="button" value="�����" onkeyDown="if(event.keyCode==9) return false;" onClick="addRow(this.parentNode.parentNode.rowIndex);"> 302 </td> 303 </tr--> 304 </Tbody></TABLE></div> 305 </TD> 306 </tr> 307 <tr class="RcpMainTableTR"> 308 <TD colspan="10"><div> 309 <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL"> 310 <tr> 311 <td class="RcpHeadInput" align='center' width="25px"> </td> 312 <td class="RcpHeadInput" colspan=2>�������� ������ ���:</td> 313 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" size="10" tabindex="9999" name="SelectedTotalPrice" onclick="$('input[name=CashAmount]').val($('input[name=SelectedTotalPrice]').val());$('input[name=CashAmount]').focus();"></td> 314 <td class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" Value="���:" size="20" tabindex="9999"></td> 315 <td class="RcpHeadInput"><INPUT class="RcpHeadInput3" readonly dir="LTR" TYPE="text" Name="TotalAmount" Value="" size="15" tabindex="9999"></td> 316 </tr> 317 </TABLE></div></TD> 318 </TR> 319 </table> 320 <TABLE class="RcpTable" Border="0" Cellspacing="5" Cellpadding="1" Dir="RTL"> 321 <tr> 322 <td align='center' bgcolor="#000000"><INPUT class="RcpGenInput" style="text-align:center" TYPE="button" value="�����" onclick="$('#form1').submit();"></td> 323 <td align='center' bgcolor="#000000"><INPUT class="RcpGenInput" style="text-align:center" TYPE="button" value="������" onclick="window.location='';"></td> 324 </tr> 325 </TABLE> 326 </TD> 327 <TD valign='top'> 328 <span style='width:100%;font-size:12pt;text-align:center;background-color:#FFDDDD;border:1px red solid;height:25px;'>���� ��</span><br> 329 <span style='width:100%;font-size:9pt;text-align:center;background-color:#FFDDDD;border:1px red solid;height:25px;'> 330 ����� �� <SELECT NAME="Reason" style='font-family:Tahoma;font-size:8pt;height:25px;width:100px;' onchange="changeSystem();"> 331<% mySQL="SELECT * FROM AXItemReasons WHERE Display=1 ORDER BY ID" 332 Set RS1=Conn.Execute(mySQL) 333 Do while not RS1.eof 334 if Reason = RS1("ID") then 335 ifSelected="selected" 336 else 337 ifSelected="" 338 end if 339 response.write "<OPTION value='"& RS1("ID") & "' "& ifSelected & ">"& RS1("Name") & "</option>" 340 RS1.MoveNext 341 Loop 342%> 343 </SELECT></span> 344 <TABLE class="GenTable" align="center" cellspacing="0" cellpadding="2" dir="RTL" border="3"> 345 <Tbody ID="DebitsTAble"> 346<% '----------------- The Debit Items 347 if Sys="AR" then 348 mySQL="SELECT * From "& Sys & "Items WHERE (Account='"& AccountNo & "' AND IsCredit='0' AND FullyApplied='0') ORDER BY EffectiveDate , Link " 349 Set RS1 = conn.Execute(mySQL) 350 351 if (RS1.eof) then 352 response.write "<tr><td bgcolor=white width=150><br><table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ���� ��� <br></td></tr></table><br></td></tr>" 353 else 354 TotalDebit=0 355 while Not (RS1.EOF) 356 if RS1("Type")=1 then 'invoice 357 set rs2 = conn.Execute("select * from Invoices where id=" & RS1("Link")) 358 if rs2("isA") then 359 isA="(���)" 360 else 361 isA="(�)" 362 end if 363 sourceLink="<a style='text-decoration:none; color:red;' href='../"& Sys & "/AccountReport.asp?act=showInvoice&invoice="& RS1("Link") & "' target='_blank'>" & "������ ����� " & RS1("Link") & isA & "</a>" 364 rs2.close 365 elseif RS1("Type")=2 then 'receipt 366 sourceLink="<a style='text-decoration:none; color:red;' href='../"& Sys & "/AccountReport.asp?act=showReceipt&receipt="& RS1("Link") & "' target='_blank'>" & "������ ����� " & RS1("Link") & "</a>" 367 elseif RS1("Type")=3 then 'memo 368 sourceLink="<a style='text-decoration:none; color:red;' href='../"& Sys & "/AccountReport.asp?act=showMemo&Sys="& Sys & "&memo="& RS1("Link") & "' target='_blank'>" & "��� ����� " & RS1("Link") & "</a>" 369 else ' i dunno 370 sourceLink="<a style='text-decoration:none; color:red;' href='javascript:void(0);'>" & "�� ���� [T:" & RS1("Type")& "] [L:"& RS1("Link") & "]</a>" 371 end if 372 373%> <tr bgcolor="white" valign='top'><td class="GrayOutLine"> 374 <table class='GenTable' cellspacing='4' cellpadding='1' width='100%'> 375 <%if RS1("Type")=1 and clng(RS1("Link"))=clng(selectedInvoice) then%> 376 <tr bgcolor='#FFFFBB'> 377 <td class="GrayOutLine"> 378 <INPUT TYPE="checkbox" checked NAME="DebitItems" value='<%=RS1("ID")%>' onclick="setPrice2(this)"><%=sourceLink%></td> 379 </tr> 380 <%else%> 381 <tr bgcolor='#FFDDDD'> 382 <td class="GrayOutLine"> 383 <INPUT TYPE="checkbox" NAME="DebitItems" value='<%=RS1("ID")%>' onclick="setPrice2(this)"><%=sourceLink%></td> 384 </tr> 385 <%end if%> 386 <tr> 387 <td class="GrayOutLine">�����: <%=Separate(RS1("RemainedAmount"))%><INPUT TYPE="hidden" name="price2" value="<%=RS1("RemainedAmount")%>"></td> 388 </tr> 389 </table></td></tr> 390<% 391 TotalDebit = TotalDebit + cdbl(RS1("RemainedAmount")) 392 RS1.movenext 393 wend 394 end if 395 '----------------- End of The Debit Items 396 end if 397%> 398 </Tbody> 399 </TABLE> 400 401 </TD> 402 </TR> 403 </TABLE> 404 </FORM> 405<SCRIPT LANGUAGE="JavaScript"> 406<!-- 407$(document).ready(function(){ 408 $('input[name=CashAmount]').focus(); 409}); 410 411tmpColor="#FFDDDD" 412tmpColor2="#FFFFBB" 413 414function changeSystem(){ 415 window.location='?act=getReceipt&selectedCustomer=<%=customerID%>&Reason='+document.all.Reason.value; 416} 417 418function setPrice2(obj){ 419 document.getElementById('asInvoice').checked=true; 420 $("#asInvoice").prop("checked",true) 421 a= obj.type 422 ii=parseInt(obj.id) 423 ii = parseInt($(obj).val()); 424 if($(obj).is(":checked")){ 425 var theTR = $(obj).closest("tr"); 426 theTR.prop("bgColor",tmpColor2); 427 } 428 else{ 429 var theTR = $(obj).closest("tr"); 430 theTR.prop("bgColor",tmpColor); 431 } 432 addAllPrice2(); 433} 434function addAllPrice2(){ 435 var totalPrice = 0 ; 436 var va = ""; 437 var description = "���� "; 438 $("input[name=DebitItems]").each(function(i){ 439 if ($(this).is(":checked")){ 440 totalPrice += getNum($($("input[name=price2]")[i]).val()); 441 description += va + $(this).closest("tr").find("a").text(); 442 va = " � "; 443 } 444 }); 445 if (description == "���� ") 446 description = ""; 447 $("input[name=SelectedTotalPrice]").val(echoNum(totalPrice)); 448 $("input[name=CashDescription]").val(description); 449 450} 451 452function submitCeck2(){ 453 if (parseInt($('input[name=TotalAmount]:first').val())==0) return false; 454 if (parseInt($('input[name=SelectedTotalPrice]:first').val())==0) return true; 455 //if (document.all.AccountTitle.value=='') return false; 456 if (parseInt($('input[name=SelectedTotalPrice]:first').val())!=parseInt($('input[name=TotalAmount]:first').val())) 457 return confirm("���� ������� �� ���� ��� ������ ��� ����� ����. ����� �� ���Ͽ"); 458 return true; 459} 460addAllPrice2(); 461//--> 462</SCRIPT> 463 464<% 465elseif request("act")="submitReceipt" then 466 467 ON ERROR RESUME NEXT 468 Reason= cint(request.form("Reason")) 469 CustomerID= clng(request.form("CustomerID")) 470 TotalAmount= cdbl(text2value(request.form("TotalAmount"))) 471 CashAmount= cdbl(text2value(request.form("CashAmount"))) 472 DepositAmount= cdbl(text2value(request.form("DepositAmount"))) 473 if Err.Number<>0 then 474 Err.clear 475 conn.close 476 response.redirect "top.asp?errMsg=" & Server.URLEncode("���!") 477 end if 478 ON ERROR GOTO 0 479 480 mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")" 481 Set RS1=Conn.execute(mySQL) 482 if RS1.eof then 483 conn.close 484 response.redirect "top.asp?errMsg=" & Server.URLEncode("���!") 485 else 486 Sys= RS1("Acron") 487 firstGLAccount= RS1("GLAccount") 488 end if 489 RS1.close 490 491 CashDescription= SqlSafe(request.form("CashDescription")) 492 CashDescription= left(CashDescription,500) ' The Description field in ReceivedCash table in DB is 500 Bytes 493 494 creationDate= shamsiToday() 495 creationTime= CurrentTime10() 496 ' ######################################################### 497 ' Find Receipts Related A or B Invoice or set it as Default in Accounts � 498 ' ######################################################### 499 ' ------ All this added by SAM 500 501 if request("DebitItems").count>0 then 502 if sys="AR" then 503 isAs="" 504 for i=1 to request("DebitItems").count 505 mySQL="select isnull(invoices.IsA,2) as isA from ARItems inner join Invoices on arItems.link=invoices.ID where arItems.type=1 and arItems.id=" & request("DebitItems")(i) 506 set RSSS=conn.Execute(mySQL) 507 if RSSS.eof then 508 isAlast = 2 509 else 510 if RSSS("isA") = "True" then 511 isAlast = 1 512 elseif RSSS("isA") = "False" then 513 isAlast = 0 514 else 515 isAlast = 2 516 end if 517 end if 518 if isAlast =2 then 519 if request("isA")<>"-1" then 520 isA=CInt(request("isA")) 521 else 522 response.redirect "?errMsg=" & server.URLEncode("���! ������ ���� ������ ��� Ȑ� �� ���� �� �") 523 end if 524 else 525 isAs=isAs & CStr(isAlast) 526 end if 527 RSSS.close 528 next 529' response.write isAs 530' response.end 531 if isAlast = 1 then 532 if InStr(isAs,"0")>0 then 533 response.redirect "?errMsg=" & server.URLEncode("���! ������ ��� � � �� ���� ��� ���") 534 else 535 isA=1 536 end if 537 else 538 if InStr(isAs,"1")>0 then 539 response.redirect "?errMsg=" & server.URLEncode("���! ������ ��� � � �� ���� ��� ���") 540 else 541 isA=0 542 end if 543 end if 544 else 545 if request("isA")<>"-1" then 546 isA=CInt(request("isA")) 547 else 548 response.redirect "?errMsg=" & server.URLEncode("���! ��� ���� ���� ���ʡ �������� ����� �� ��� ������ ���� �� �. ���� ��� Ȑ�") 549 end if 550 end if 551 else 552 if request("isA")<>"-1" then 553 isA=CInt(request("isA")) 554 else 555 response.redirect "?errMsg=" & server.URLEncode("���! �� ����� �� ��������ϡ ���� ��� �� � ���� ������ �� ���� ����") 556 end if 557 end if 558' response.write isAs & ", " & isA 559' response.end 560 '########################################################### 561 '########################################################### 562 '########################################################### 563 if isA then 564 GLAccount= "11007" 'This must be changed� (Cashier A) 565 else 566 GLAccount= "11005" 'This must be changed� (Cashier B) 567 end if 568 effectiveDate= sqlSafe(request.form("ReceiptDate")) 569 570 '---- Checking wether EffectiveDate is valid in current open GL 571 if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then 572 Conn.close 573 response.redirect "?act=getReceipt&selectedCustomer="& CustomerID & "&Reason="& Reason & "&errMsg=" & Server.URLEncode("���!<br>����� ���� ��� ����� ����.") 574 end if 575 '---- 576 '----- Check GL is closed 577 if (session("IsClosed")="True") then 578 Conn.close 579 response.redirect "?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.") 580 end if 581 '---- 582 a = TotalAmount 583 TotalAmountLetter = ConvertIT(a) 584 585 ' ######################################################### 586 ' INSERTING RECEIPT � 587 ' ######################################################### 588 589 ' NUMBER must be Receipt Number 590 NUMBER =0 591 ' CHQAMOUNT � 592 CHQAMOUNT =0 593 ' CHQQTTY must be Receipt Qtty of Cheques 594 CHQQTTY =0 595 596' Changed By Kid 821016 597 mySQL="INSERT INTO Receipts (SYS, CreatedDate, CreatedBy, EffectiveDate, Number, Customer, CashAmount, DepositAmount, ChequeAmount, ChequeQtty, TotalAmount, TotalAmountLetter) VALUES ('"& Sys & "', N'" &_ 598 creationDate & "', '"& session("ID") & "', N'" & effectiveDate & "', '"& NUMBER & "', '"& CustomerID & "', '"& CashAmount & "', '"& DepositAmount & "', '"& CHQAMOUNT & "', '"& CHQQTTY & "', '"& TotalAmount & "', N'"& TotalAmountLetter & "');SELECT @@Identity AS NewReceipt" 599 set RS1 = Conn.execute(mySQL).NextRecordSet 600 ReceiptID=RS1("NewReceipt") 601 RS1.close 602 603 ' ######################################################### 604 ' INSERTING CASH � 605 ' ######################################################### 606 mySQL="INSERT INTO ReceivedCash (Receipt, Amount, Banker, Description) VALUES ('"&_ 607 ReceiptID & "', '" & CashAmount & "', '" & theBanker & "', N'"& CashDescription & "')" 608 conn.Execute(mySQL) 609 610 chequeCount=0 611 totalChequeAmount=0 612 613 firstStatus=1 '----------------- FIRST STATUS FOR CHEQUES 614 for i=1 to request.form("ChequeNos").count 615 theChequeNo = text2value(request.form("ChequeNos")(i)) 616 theChequeDate = request.form("ChequeDates")(i) 617 theOriginBank = request.form("Banks")(i) 618 theOriginBank = left(theOriginBank,50) ' The BankOfOrigin field in ReceivedCheques table in DB is 50 Bytes long 619 theDescription = request.form("Descriptions")(i) 620 theAmount = text2value(request.form("Amounts")(i)) 621 if theAmount <> 0 then 622 623 ' ######################################################### 624 ' INSERTING CHEQUES � 625 ' (Note: There is a TRIGGER) 626 ' ######################################################### 627 628 mySQL="INSERT INTO ReceivedCheques (Receipt, ChequeNo, ChequeDate, Description, BankOfOrigin, Amount, LastStatus, LastBanker, LastUpdatedDate, LastUpdatedBy) VALUES ('"&_ 629 ReceiptID & "', N'" & theChequeNo & "', N'" & theChequeDate & "', N'" & theDescription & "', N'" & theOriginBank & "', '" & theAmount & "', '" & firstStatus & "', '" & theBanker & "', N'" & creationDate & "', '" & session("ID") & "')" 630 conn.Execute(mySQL) 631 chequeCount = chequeCount + 1 632 totalChequeAmount = totalChequeAmount + theAmount 633 end if 634 next 635 ' ######################################################### 636 ' CREATING AN ITEM for RECEIPT � 637 ' ######################################################### 638 '*** Type = 2 means Item is a Receipt 639 640 mySQL="INSERT INTO "& Sys & "Items (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, Reason, IsCredit, Type, Link, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount) VALUES ('" &_ 641 GLAccount & "', '"& OpenGL & "', '"& firstGLAccount & "', '"& CustomerID & "', '"& EffectiveDate & "', '"& Reason & "', 1, 2, '"& ReceiptID & "', '"& TotalAmount - DepositAmount & "', N'"& creationDate & "', '"& session("ID") & "', '"& TotalAmount - DepositAmount & "'); SELECT @@Identity AS NewItem;" 642 Set RS1=conn.Execute(mySQL).NextRecordSet 643 theReceiptItem=RS1("NewItem") 644 RS1.close 645 ' ######################################################### 646 ' CREATING ITEMS RELATIONS � 647 ' ######################################################### 648 response.write "<div dir=LTR>selected debit items count :<br>" 649 OnHandAmount = TotalAmount 650 for i = 1 to request.form("DebitItems").count 651 mySQL="SELECT RemainedAmount FROM "& Sys & "Items WHERE (ID='"& request.form("DebitItems")(i) & "')" 652 Set RS1=Conn.execute(mySQL) 653 theAmount=cdbl(RS1("RemainedAmount")) 654 if theAmount > cdbl(OnHandAmount) then theAmount=OnHandAmount 655 OnHandAmount = OnHandAmount - theAmount 656 mySQL="INSERT INTO "& Sys & "ItemsRelations (CreatedDate, CreatedBy, Credit"& Sys & "Item, Debit"& Sys & "Item, Amount) VALUES (N'"& creationDate & "', '"& session("ID") & "', '"& theReceiptItem &"', '"& request.form("DebitItems")(i) &"', '"& theAmount &"')" 657 conn.Execute(mySQL) 658 mySQL="UPDATE "& Sys & "Items SET RemainedAmount=RemainedAmount-'"& theAmount & "' WHERE (ID='"& request.form("DebitItems")(i) & "')" 659 conn.Execute(mySQL) 660 if OnHandAmount=0 then exit for 661 next 662 mySQL="UPDATE "& Sys & "Items SET RemainedAmount='"& OnHandAmount & "' WHERE (ID='"& theReceiptItem & "')" 663 conn.Execute(mySQL) 664 665 mySQL="UPDATE "& Sys & "Items SET FullyApplied=1 WHERE (RemainedAmount=0) AND (voided=0) AND (FullyApplied=0)" 666 conn.Execute(mySQL) 667 ' ######################################################### 668 ' INSERTING RECEIPT INTO CASH REGISTER LINES � 669 ' Note: Inserted CashRegisterLineType is '1' 670 ' That means "Receipt" 671 ' ######################################################### 672 mySQL="INSERT INTO CashRegisterLines (CashReg, [Date], [Time], Type, Link,isA) VALUES ('"& CashRegID & "', N'"& creationDate & "', N'"& creationTime & "', '1', '"& ReceiptID & "', '"& isA &"')" 673' response.write mySQL 674 conn.Execute(mySQL) 675 676 ' ######################################################### 677 ' UPDATING CASH REGISTERS � 678 ' ######################################################### 679 if isA then 680 mySQL="UPDATE CashRegisters SET CashAmountA=CashAmountA+'"& CashAmount & "', ChequeAmount=ChequeAmount+'"& totalChequeAmount & "', ChequeQtty=ChequeQtty+'"& chequeCount & "' WHERE ID='"& CashRegID & "'" 681 else 682 mySQL="UPDATE CashRegisters SET CashAmountB=CashAmountB+'"& CashAmount & "', ChequeAmount=ChequeAmount+'"& totalChequeAmount & "', ChequeQtty=ChequeQtty+'"& chequeCount & "' WHERE ID='"& CashRegID & "'" 683 end if 684 conn.Execute(mySQL) 685 686 '***************************************************************** 687 '*********** Creating Deposit if needed should go here *********** 688 '***************************************************************** 689 690 ' ######################################################### 691 ' UPDATING Account Balance � 692 ' ######################################################### 693 mySQL="UPDATE Accounts SET "& Sys & "Balance = "& Sys & "Balance + '"& TotalAmount - DepositAmount & "' WHERE (ID='"& CustomerID & "')" 694 conn.Execute(mySQL) 695 Conn.close 696 response.redirect "ReceiptInput.asp?act=ShowReceipt&id=" & ReceiptID 697'response.end 698else%> 699<!-- ����� ���� ��� ���� --><BR><BR> 700 <FORM METHOD=POST ACTION="?act=submitsearch" onsubmit="if (document.all.SearchBox.value=='') return false;"> 701 <div dir='rtl'> <B>��� ��� : ����� ���� ��� ���� �� ����� ����� </B> 702 <INPUT TYPE="text" NAME="SearchBox"> 703 <INPUT class="GenButton" TYPE="submit" value="�����"><br> 704 </div> 705 </FORM> 706 <SCRIPT LANGUAGE="JavaScript"> 707 <!-- 708 document.all.SearchBox.focus(); 709 //--> 710 </SCRIPT> 711<% 712end if 713conn.Close 714%> 715<% if request("act")="getReceipt" then %> 716 717<script language="JavaScript"> 718$(document).ready(function(){ 719 $.ajaxSetup({ 720 cache: false 721 }); 722 $.getJSON("/service/json_getAccount.asp", 723 {act:"chequeRemain",account:$("input[name=customerID]").val()}, 724 function (json){ 725 $("#customerRemainCheque").val(json.amount); 726 }); 727}); 728<!-- 729function delRow(rowNo){ 730 chqTable=document.getElementById("ChequeLines"); 731 theRow=chqTable.getElementsByTagName("tr")[rowNo]; 732 chqTable.removeChild(theRow); 733 734 for (rowNo=0; rowNo < document.getElementsByName("ChequeNos").length; rowNo++){ 735 chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0].innerText= rowNo+1; 736 } 737} 738function addRow(rowNo){ 739 chqTable=document.getElementById("ChequeLines"); 740 theRow=chqTable.getElementsByTagName("tr")[rowNo]; 741 newRow=document.createElement("tr"); 742 newRow.setAttribute("bgColor", '#f0f0f0'); 743 744 tempTD=document.createElement("td"); 745 tempTD.innerHTML=rowNo+1 746 tempTD.setAttribute("align", 'center'); 747 tempTD.setAttribute("width", '25'); 748 newRow.appendChild(tempTD); 749 750 tempTD=document.createElement("td"); 751 tempTD.setAttribute("dir", 'LTR'); 752 tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="ChequeNos" size="12" onKeyPress="return maskNumber(this);">' 753 newRow.appendChild(tempTD); 754 755 tempTD=document.createElement("td"); 756 tempTD.setAttribute("dir", 'LTR'); 757 tempTD.innerHTML='<INPUT class="RcpRowInput" style="text-align:left;" TYPE="text" NAME="ChequeDates" maxlength="10" size="10" onblur="chequeDate(this)">' 758 newRow.appendChild(tempTD); 759 760 tempTD=document.createElement("td"); 761 tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="Banks" size="10">' 762 newRow.appendChild(tempTD); 763 764 tempTD=document.createElement("td"); 765 tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="Descriptions" size="20">' 766 newRow.appendChild(tempTD); 767 768 tempTD=document.createElement("td"); 769 tempTD.setAttribute("dir", 'LTR'); 770 tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="Amounts" size="15" onKeyPress="return maskNumber(this);" onBlur="setPrice(this);">' 771 newRow.appendChild(tempTD); 772 773 chqTable.insertBefore(newRow,theRow); 774 775 chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[1].getElementsByTagName("Input")[0].focus(); 776} 777 778function setPrice(src){ 779/* echoNum(src); */ 780 781 if ($(src).attr("name")=="Amounts" && $(src).closest("tr").find("input[name=ChequeNos]").val()==''){ 782 $(src).val(0); 783 } 784 else{ 785 if (!isNaN(echoNum(getNum($(src).val())))) 786 $(src).val(0); 787 else 788 $(src).val(echoNum(getNum($(src).val()))); 789 } 790 if ($("input[name=CashAmount]:first").val()=="NaN") $("input[name=CashAmount]:first").val(0); 791 cashAmount=getNum($("input[name=CashAmount]:first").val()); 792 totalAmount = cashAmount; 793 $("input[name=Amounts]").each(function(i,amount){ 794 if ($(amount).val()!='NaN' && $(amount).val()!='') 795 totalAmount += getNum($(amount).val()); 796 }); 797 $("input[name=TotalAmount]:first").val(echoNum(totalAmount)); 798 if ($(src).attr("name")=="Amounts"){ 799 if ((getNum($(src).val()) + parseInt($("#customerRemainCheque").val())) > getNum($("#maxChequeAmount").val())){ 800 var str="������ �� ������� ���� ��� ���� " + echoNum($("#maxChequeAmount").val()) + " �� ����"; 801 if ( parseInt($("#customerRemainCheque").val())>0) 802 str += " ���� ��� ��� ����� " + echoNum(parseInt($("#customerRemainCheque").val())) + "�������. "; 803 $(src).val("0"); 804 alert(str); 805 $(src).focus(); 806 //$(this).closest("tr").find("input").val(""); 807 } 808 } 809} 810function chequeDate(obj){ 811 var obj=$(obj); 812 obj.attr("title",""); 813 if (obj.val()=="") { 814 obj.attr("title","���� ����� �� ���� ����"); 815 obj.focus(); 816 } 817 else if (obj.val()=="//") { 818 var today = new Date(); 819 obj.val($.format.date(today,"yyyy/MM/dd")); 820 } else { 821 var rege=/^(13)?[7-9][0-9]\/[0-1]?[0-9]\/[0-3]?[0-9]$/; 822 if( rege.test(obj.val()) ) { 823 var SP = obj.val().split("/"); 824 if (SP[0].length == 2) SP[0] = "13" + SP[0] ; 825 if (SP[1].length == 1) SP[1] = "0" + SP[1] ; 826 if (SP[2].length == 1) SP[2] = "0" + SP[2] ; 827 obj.val(SP.join("/")); 828 } 829 if(!rege.test(obj.val())||( SP[0]<'1376' || SP[1]>'12' || SP[2]>'31' )) { 830 obj.attr("title","���� ����� ���� YYYY/MM/DD ����."); 831 obj.focus(); 832 }; 833 } 834 var now = new Date(); 835 var chequeDate = $.jalaliCalendar.jalaliToGregorianStr(obj.val()); 836 var diff = Math.floor((Date( chequeDate ) - Date( now )) / 86400000); 837 if (parseInt($("#maxChequeDay").val())<diff){ 838 alert("��� �� ���� " + $("#maxChequeDay").val() + " ���� ����"); 839 obj.val($.format.date(now,"yyyy/MM/dd")); 840 } 841 842} 843 844//--> 845</script> 846<%end if%> 847<!--#include file="tah.asp" -->