-
Notifications
You must be signed in to change notification settings - Fork 3
/
GLJournalInquiry.php
127 lines (105 loc) · 4.62 KB
/
GLJournalInquiry.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
include ('includes/session.inc');
$title = _('General Ledger Journal Inquiry');
include('includes/header.inc');
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p>';
if (!isset($_POST['Show'])) {
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class="selection">';
echo '<tr><th colspan="3" class="header">' . _('Selection Criteria') . '</th></tr>';
$sql = "SELECT typeno FROM systypes WHERE typeid=0";
$result = DB_query($sql, $db);
$myrow = DB_fetch_array($result);
$MaxJournalNumberUsed = $myrow['typeno'];
echo '<tr>
<td>' . _('Journal Number Range') . ' (' . _('Between') . ' 1 ' . _('and') . ' ' . $MaxJournalNumberUsed . ')</td>
<td>' . _('From') . ':'. '<input type="text" class="number" name="NumberFrom" size="10" maxlength="11" value="1" />'.'</td>
<td>' . _('To') . ':'. '<input type="text" class="number" name="NumberTo" size="10" maxlength="11" value="' . $MaxJournalNumberUsed . '" />'.'</td>
</tr>';
$sql = "SELECT MIN(trandate) AS fromdate,
MAX(trandate) AS todate FROM gltrans WHERE type=0";
$result = DB_query($sql, $db);
$myrow = DB_fetch_array($result);
if (isset($FromDate) and $FromDate != '') {
$FromDate = $myrow['fromdate'];
$ToDate = $myrow['todate'];
} else {
$FromDate=date('Y-m-d');
$ToDate=date('Y-m-d');
}
echo '<tr><td>' . _('Journals Dated Between') . ':</td>
<td>' . _('From') . ':'. '<input type="text" name="FromTransDate" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" value="' . ConvertSQLDate($FromDate) . '" /></td>
<td>' . _('To') . ':'. '<input type="text" name="ToTransDate" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" value="' . ConvertSQLDate($ToDate) . '" /></td>
</tr>';
echo '</table>';
echo '<br /><div class="centre"><button type="submit" name="Show">' . _('Show transactions'). '</button></div>';
echo '</form>';
} else {
$sql="SELECT gltrans.typeno,
gltrans.trandate,
gltrans.account,
chartmaster.accountname,
gltrans.narrative,
gltrans.amount,
gltrans.tag,
tags.tagdescription,
gltrans.jobref
FROM gltrans
INNER JOIN chartmaster
ON gltrans.account=chartmaster.accountcode
LEFT JOIN tags
ON gltrans.tag=tags.tagref
WHERE gltrans.type='0'
AND gltrans.trandate>='" . FormatDateForSQL($_POST['FromTransDate']) . "'
AND gltrans.trandate<='" . FormatDateForSQL($_POST['ToTransDate']) . "'
AND gltrans.typeno>='" . $_POST['NumberFrom'] . "'
AND gltrans.typeno<='" . $_POST['NumberTo'] . "'
ORDER BY gltrans.typeno";
$result = DB_query($sql, $db);
if (DB_num_rows($result)==0) {
prnMsg(_('There are no transactions for this account in the date range selected'), 'info');
} else {
echo '<table class="selection">';
echo '<tr>
<th>' . ('Date') . '</th>
<th>'._('Journal Number').'</th>
<th>'._('Account Code').'</th>
<th>'._('Account Description').'</th>
<th>'._('Narrative').'</th>
<th>'._('Amount').' '.$_SESSION['CompanyRecord']['currencydefault'].'</th>
<th>'._('Tag').'</th>
</tr>';
$LastJournal = 0;
while ($myrow = DB_fetch_array($result)){
if ($myrow['tag']==0) {
$myrow['tagdescription']='None';
}
if ($myrow['typeno']!=$LastJournal) {
echo '<tr><td colspan="8"</td></tr><tr>
<td>'. ConvertSQLDate($myrow['trandate']) . '</td>
<td class="number">'.$myrow['typeno'].'</td>';
} else {
echo '<tr><td colspan="2"></td>';
}
echo '<td>'.$myrow['account'].'</td>
<td>'.$myrow['accountname'].'</td>
<td>'.$myrow['narrative'] .'</td>
<td class="number">'.locale_money_format($myrow['amount'],$_SESSION['CompanyRecord']['currencydefault']).'</td>
<td class="number">'.$myrow['tag'] . ' - ' . $myrow['tagdescription'].'</td>';
if ($myrow['typeno']!=$LastJournal) {
echo '<td class="number"><a href="PDFGLJournal.php?JournalNo='.$myrow['typeno'].'">'._('Print') .'</a></td></tr>';
$LastJournal = $myrow['typeno'];
} else {
echo '<td colspan="1"></td></tr>';
}
}
echo '</table>';
} //end if no bank trans in the range to show
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<br /><div class="centre"><button type="submit" name="Return">' . _('Select Another Date'). '</button></div>';
echo '</form>';
}
include('includes/footer.inc');
?>