1<?php 2// GLJournalInquiry.php 3include ('includes/session.php'); 4$Title = _('General Ledger Journal Inquiry'); 5$ViewTopic = 'GeneralLedger'; 6$BookMark = 'GLJournalInquiry'; 7 8include ('includes/header.php'); 9 10echo '<p class="page_title_text"><img src="' . $RootPath, '/css/', $Theme, '/images/money_add.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . '</p>'; 11 12if (!isset($_POST['Show'])) { 13 echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; 14 echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; 15 16 echo '<table class="selection">'; 17 echo '<tr><th colspan="3">' . _('Selection Criteria') . '</th></tr>'; 18 19 $SQL = "SELECT typeid,systypes.typeno,typename FROM 20 systypes INNER JOIN gltrans ON systypes.typeid=gltrans.type 21 GROUP BY typeid"; 22 $Result = DB_query($SQL); 23 if (DB_num_rows($Result) > 0) { 24 echo '<tr> 25 26 <td>' . _('Transaction Type') . ' </td> 27 <td> <select name="TransType">'; 28 while ($MyRow = DB_fetch_array($Result)) { 29 if (!isset($MaxJournalNumberUsed)) { 30 $MaxJournalNumberUsed = $MyRow['typeno']; 31 } else { 32 $MaxJournalNumberUsed = ($MyRow['typeno'] > $MaxJournalNumberUsed) ? $MyRow['typeno'] : $MaxJournalNumberUsed; 33 } 34 echo '<option value="' . $MyRow['typeid'] . '">' . _($MyRow['typename']) . '</option>'; 35 } 36 echo '</select></td> 37 </tr>'; 38 39 } 40 41 echo '<tr> 42 <td>' . _('Journal Number Range') . ' (' . _('Between') . ' 1 ' . _('and') . ' ' . $MaxJournalNumberUsed . ')</td> 43 <td>' . _('From') . ':' . '<input type="text" class="number" name="NumberFrom" size="10" maxlength="11" value="1" />' . '</td> 44 <td>' . _('To') . ':' . '<input type="text" class="number" name="NumberTo" size="10" maxlength="11" value="' . $MaxJournalNumberUsed . '" />' . '</td> 45 </tr>'; 46 47 $SQL = "SELECT MIN(trandate) AS fromdate, 48 MAX(trandate) AS todate FROM gltrans WHERE type=0"; 49 $Result = DB_query($SQL); 50 $MyRow = DB_fetch_array($Result); 51 if (isset($MyRow['fromdate']) and $MyRow['fromdate'] != '') { 52 $FromDate = $MyRow['fromdate']; 53 $ToDate = $MyRow['todate']; 54 } else { 55 $FromDate = date('Y-m-d'); 56 $ToDate = date('Y-m-d'); 57 } 58 59 echo '<tr><td>' . _('Journals Dated Between') . ':</td> 60 <td>' . _('From') . ':' . '<input type="text" name="FromTransDate" class="date" maxlength="10" size="11" value="' . ConvertSQLDate($FromDate) . '" /></td> 61 <td>' . _('To') . ':' . '<input type="text" name="ToTransDate" class="date" maxlength="10" size="11" value="' . ConvertSQLDate($ToDate) . '" /></td> 62 </tr>'; 63 64 echo '</table>'; 65 echo '<br /><div class="centre"><input type="submit" name="Show" value="' . _('Show transactions') . '" /></div>'; 66 echo '</form>'; 67} else { 68 69 $SQL = "SELECT gltrans.typeno, 70 gltrans.trandate, 71 gltrans.account, 72 chartmaster.accountname, 73 gltrans.narrative, 74 gltrans.amount, 75 gltrans.tag, 76 tags.tagdescription, 77 gltrans.jobref 78 FROM gltrans 79 INNER JOIN chartmaster 80 ON gltrans.account=chartmaster.accountcode 81 LEFT JOIN tags 82 ON gltrans.tag=tags.tagref 83 WHERE gltrans.type='" . $_POST['TransType'] . "' 84 AND gltrans.trandate>='" . FormatDateForSQL($_POST['FromTransDate']) . "' 85 AND gltrans.trandate<='" . FormatDateForSQL($_POST['ToTransDate']) . "' 86 AND gltrans.typeno>='" . $_POST['NumberFrom'] . "' 87 AND gltrans.typeno<='" . $_POST['NumberTo'] . "' 88 ORDER BY gltrans.typeno"; 89 90 $Result = DB_query($SQL); 91 if (DB_num_rows($Result) == 0) { 92 prnMsg(_('There are no transactions for this account in the date range selected'), 'info'); 93 } else { 94 echo '<table class="selection">'; 95 echo '<tr> 96 <th>' . _('Date') . '</th> 97 <th>' . _('Journal Number') . '</th> 98 <th>' . _('Account Code') . '</th> 99 <th>' . _('Account Description') . '</th> 100 <th>' . _('Narrative') . '</th> 101 <th>' . _('Amount') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . '</th> 102 <th>' . _('Tag') . '</th> 103 </tr>'; 104 105 $LastJournal = 0; 106 107 while ($MyRow = DB_fetch_array($Result)) { 108 109 if ($MyRow['tag'] == 0) { 110 $MyRow['tagdescription'] = 'None'; 111 } 112 113 if ($MyRow['typeno'] != $LastJournal) { 114 115 echo '<tr> 116 <td colspan="8"></td> 117 </tr> 118 <tr> 119 <td>' . ConvertSQLDate($MyRow['trandate']) . '</td> 120 <td class="number">' . $MyRow['typeno'] . '</td>'; 121 122 } else { 123 echo '<tr> 124 <td colspan="2"></td>'; 125 } 126 127 // if user is allowed to see the account we show it, other wise we show "OTHERS ACCOUNTS" 128 $CheckSql = "SELECT count(*) 129 FROM glaccountusers 130 WHERE accountcode= '" . $MyRow['account'] . "' 131 AND userid = '" . $_SESSION['UserID'] . "' 132 AND canview = '1'"; 133 $CheckResult = DB_query($CheckSql); 134 $CheckRow = DB_fetch_row($CheckResult); 135 136 if ($CheckRow[0] > 0) { 137 echo '<td>' . $MyRow['account'] . '</td> 138 <td>' . $MyRow['accountname'] . '</td>'; 139 } else { 140 echo '<td>' . _('Others') . '</td> 141 <td>' . _('Other GL Accounts') . '</td>'; 142 } 143 144 echo '<td>' . $MyRow['narrative'] . '</td> 145 <td class="number">' . locale_number_format($MyRow['amount'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td> 146 <td class="number">' . $MyRow['tag'] . ' - ' . $MyRow['tagdescription'] . '</td>'; 147 148 if ($MyRow['typeno'] != $LastJournal and $CheckRow[0] > 0) { 149 if ($_SESSION['Language'] == 'zh_CN.utf8' or $_SESSION['Language'] == 'zh_hk.utf8') { 150 echo '<td class="number"><a href="PDFGLJournalCN.php?JournalNo=' . $MyRow['typeno'] . '&Type=' . $_POST['TransType'] . '">' . _('Print') . '</a></td></tr>'; 151 } else { 152 echo '<td class="number"><a href="PDFGLJournal.php?JournalNo=' . $MyRow['typeno'] . '">' . _('Print') . '</a></td></tr>'; 153 } 154 155 $LastJournal = $MyRow['typeno']; 156 } else { 157 echo '<td colspan="1"></td></tr>'; 158 } 159 160 } 161 echo '</table>'; 162 } //end if no bank trans in the range to show 163 echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; 164 echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; 165 echo '<br /><div class="centre"><input type="submit" name="Return" value="' . _('Select Another Date') . '" /></div>'; 166 echo '</form>'; 167} 168include ('includes/footer.php'); 169?>