PageRenderTime 46ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/chronique/CustWhereAlloc.php

http://chronique.googlecode.com/
PHP | 161 lines | 134 code | 23 blank | 4 comment | 18 complexity | df17852184b977841b1cce5e09c0978c MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /* $Id: CustWhereAlloc.php 4740 2011-11-06 03:12:31Z daintree $*/
  3. include('includes/session.inc');
  4. $title = _('Customer How Paid Inquiry');
  5. include('includes/header.inc');
  6. echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">';
  7. echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
  8. echo '<p class="page_title_text">
  9. <img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' .
  10. _('Customer Where Allocated'). '" alt="" />' . $title . '
  11. </p>
  12. <table class="selection">
  13. <tr>
  14. <td>' . _('Type') . ':</td>
  15. <td><select tabindex="1" name="TransType"> ';
  16. $sql = "SELECT typeid, typename FROM systypes WHERE typeid = 10 OR typeid=12";
  17. $resultTypes = DB_query($sql,$db);
  18. while ($myrow=DB_fetch_array($resultTypes)){
  19. if (isset($_POST['TransType'])){
  20. if ($myrow['typeid'] == $_POST['TransType']){
  21. echo '<option selected value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
  22. } else {
  23. echo '<option value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
  24. }
  25. } else {
  26. echo '<option value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
  27. }
  28. }
  29. echo '</select></td>';
  30. if (!isset($_POST['TransNo'])) {$_POST['TransNo']='';}
  31. echo '<td>'._('Transaction Number').':</td>
  32. <td><input tabindex="2" type="text" name="TransNo" maxlength="10" size="10" value="'. $_POST['TransNo'] . '" /></td>
  33. </tr>
  34. </table>
  35. <br />
  36. <div class="centre">
  37. <input tabindex="3" type="submit" name="ShowResults" value="' . _('Show How Allocated') . '" />
  38. </div>';
  39. if (isset($_POST['ShowResults']) AND $_POST['TransNo']==''){
  40. echo '<br />';
  41. prnMsg(_('The transaction number to be queried must be entered first'),'warn');
  42. }
  43. if (isset($_POST['ShowResults']) AND $_POST['TransNo']!=''){
  44. /*First off get the DebtorTransID of the transaction (invoice normally) selected */
  45. $sql = "SELECT debtortrans.id,
  46. ovamount+ovgst AS totamt,
  47. currencies.decimalplaces AS currdecimalplaces,
  48. debtorsmaster.currcode
  49. FROM debtortrans INNER JOIN debtorsmaster
  50. ON debtortrans.debtorno=debtorsmaster.debtorno
  51. INNER JOIN currencies
  52. ON debtorsmaster.currcode=currencies.currabrev
  53. WHERE type='" . $_POST['TransType'] . "'
  54. AND transno = '" . $_POST['TransNo']."'";
  55. $result = DB_query($sql , $db);
  56. if (DB_num_rows($result)==1){
  57. $myrow = DB_fetch_array($result);
  58. $AllocToID = $myrow['id'];
  59. $CurrCode = $myrow['currcode'];
  60. $CurrDecimalPlaces = $myrow['currdecimalplaces'];
  61. $sql = "SELECT type,
  62. transno,
  63. trandate,
  64. debtortrans.debtorno,
  65. reference,
  66. debtortrans.rate,
  67. ovamount+ovgst+ovfreight+ovdiscount as totalamt,
  68. custallocns.amt
  69. FROM debtortrans
  70. INNER JOIN custallocns
  71. ON debtortrans.id=custallocns.transid_allocfrom
  72. WHERE custallocns.transid_allocto='". $AllocToID."'";
  73. $ErrMsg = _('The customer transactions for the selected criteria could not be retrieved because');
  74. $TransResult = DB_query($sql, $db, $ErrMsg);
  75. if (DB_num_rows($TransResult)==0){
  76. prnMsg(_('There are no allocations made against this transaction'),'info');
  77. } else {
  78. echo '<br />
  79. <table class="selection">';
  80. echo '<tr>
  81. <th colspan="6">
  82. <div class="centre">
  83. <font size=3 color="blue"><b>'._('Allocations made against invoice number') . ' ' . $_POST['TransNo'] . '<br />'._('Transaction Total').': '. locale_number_format($myrow['totamt'],$CurrDecimalPlaces) . ' ' . $CurrCode . '</font></b>
  84. </div>
  85. </th>
  86. </tr>';
  87. $TableHeader = '<tr>
  88. <th>' . _('Type') . '</th>
  89. <th>' . _('Number') . '</th>
  90. <th>' . _('Reference') . '</th>
  91. <th>' . _('Ex Rate') . '</th>
  92. <th>' . _('Amount') . '</th>
  93. <th>' . _('Alloc') . '</th>
  94. </tr>';
  95. echo $TableHeader;
  96. $RowCounter = 1;
  97. $k = 0; //row colour counter
  98. $AllocsTotal = 0;
  99. while ($myrow=DB_fetch_array($TransResult)) {
  100. if ($k==1){
  101. echo '<tr class="EvenTableRows">';
  102. $k=0;
  103. } else {
  104. echo '<tr class="OddTableRows">';
  105. $k++;
  106. }
  107. if ($myrow['type']==11){
  108. $TransType = _('Credit Note');
  109. } else {
  110. $TransType = _('Receipt');
  111. }
  112. echo '<td>' . $TransType . '</td>
  113. <td>' . $myrow['transno'] . '</td>
  114. <td>' . $myrow['reference'] . '</td>
  115. <td>' . $myrow['rate'] . '</td>
  116. <td class="number">' . locale_number_format($myrow['totalamt'],$CurrDecimalPlaces) . '</td>
  117. <td class="number">' . locale_number_format($myrow['amt'],$CurrDecimalPlaces) . '</td>
  118. </tr>';
  119. $RowCounter++;
  120. If ($RowCounter == 12){
  121. $RowCounter=1;
  122. echo $TableHeader;
  123. }
  124. //end of page full new headings if
  125. $AllocsTotal +=$myrow['amt'];
  126. }
  127. //end of while loop
  128. echo '<tr>
  129. <td colspan="5" class="number">'._('Total allocated').'</td>
  130. <td class="number">' . locale_number_format($AllocsTotal,$CurrDecimalPlaces) . '</td>
  131. </tr>
  132. </table>';
  133. } // end if there are allocations against the transaction
  134. } //got the ID of the transaction to find allocations for
  135. }
  136. echo '</form>';
  137. include('includes/footer.inc');
  138. ?>