forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectGLAccount.php
200 lines (169 loc) · 6.76 KB
/
SelectGLAccount.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
include('includes/session.php');
$Title = _('Search GL Accounts');
$ViewTopic = 'GeneralLedger';
$BookMark = 'GLAccountInquiry';
include('includes/header.php');
$msg='';
unset($Result);
if (isset($_POST['Search'])){
if (mb_strlen($_POST['Keywords']>0) AND mb_strlen($_POST['GLCode'])>0) {
$msg=_('Account name keywords have been used in preference to the account code extract entered');
}
if ($_POST['Keywords']=='' AND $_POST['GLCode']=='') {
$SQL = "SELECT chartmaster.accountcode,
chartmaster.accountname,
chartmaster.group_,
CASE WHEN accountgroups.pandl!=0 THEN '" . _('Profit and Loss') . "' ELSE '" . _('Balance Sheet') ."' END AS pl
FROM chartmaster,
accountgroups,
glaccountusers
WHERE glaccountusers.accountcode = chartmaster.accountcode
AND glaccountusers.userid='" . $_SESSION['UserID'] . "'
AND glaccountusers.canview=1
AND chartmaster.group_=accountgroups.groupname
ORDER BY chartmaster.accountcode";
}
elseif (mb_strlen($_POST['Keywords'])>0) {
//insert wildcard characters in spaces
$SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%';
$SQL = "SELECT chartmaster.accountcode,
chartmaster.accountname,
chartmaster.group_,
CASE WHEN accountgroups.pandl!=0
THEN '" . _('Profit and Loss') . "'
ELSE '" . _('Balance Sheet') . "' END AS pl
FROM chartmaster,
accountgroups,
glaccountusers
WHERE glaccountusers.accountcode = chartmaster.accountcode
AND glaccountusers.userid='" . $_SESSION['UserID'] . "'
AND glaccountusers.canview=1
AND chartmaster.group_ = accountgroups.groupname
AND accountname " . LIKE . "'". $SearchString ."'
ORDER BY accountgroups.sequenceintb,
chartmaster.accountcode";
} elseif (mb_strlen($_POST['GLCode'])>0){
if (!empty($_POST['GLCode'])) {
echo '<meta http-equiv="refresh" content="0; url=' . $RootPath . '/GLAccountInquiry.php?Account=' . $_POST['GLCode'] . '&Show=Yes">';
exit;
}
$SQL = "SELECT chartmaster.accountcode,
chartmaster.accountname,
chartmaster.group_,
CASE WHEN accountgroups.pandl!=0 THEN '" . _('Profit and Loss') . "' ELSE '" . _('Balance Sheet') ."' END AS pl
FROM chartmaster,
accountgroups,
glaccountusers
WHERE glaccountusers.accountcode = chartmaster.accountcode
AND glaccountusers.userid='" . $_SESSION['UserID'] . "'
AND glaccountusers.canview=1
AND chartmaster.group_=accountgroups.groupname
AND chartmaster.accountcode >= '" . $_POST['GLCode'] . "'
ORDER BY chartmaster.accountcode";
}
if (isset($SQL) and $SQL!=''){
$Result = DB_query($SQL);
if (DB_num_rows($Result) == 1) {
$AccountRow = DB_fetch_row($Result);
header('location:' . $RootPath . '/GLAccountInquiry.php?Account=' . $AccountRow[0] . '&Show=Yes');
exit;
}
}
} //end of if search
$TargetPeriod = GetPeriod(date($_SESSION['DefaultDateFormat']));
if (!isset($AccountID)) {
echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for General Ledger Accounts') . '</p>
<br />
<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<div>
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if(mb_strlen($msg)>1){
prnMsg($msg,'info');
}
echo '<table class="selection">
<tr>
<td>' . _('Enter extract of text in the Account name') .':</td>
<td><input type="text" name="Keywords" size="20" maxlength="25" /></td>
<td><b>' . _('OR') . '</b></td>';
$SQLAccountSelect="SELECT chartmaster.accountcode,
chartmaster.accountname,
chartmaster.group_
FROM chartmaster
INNER JOIN glaccountusers ON glaccountusers.accountcode=chartmaster.accountcode AND glaccountusers.userid='" . $_SESSION['UserID'] . "' AND glaccountusers.canview=1
INNER JOIN accountgroups ON chartmaster.group_=accountgroups.groupname
ORDER BY accountgroups.sequenceintb, accountgroups.groupname, chartmaster.accountcode";
$ResultSelection=DB_query($SQLAccountSelect);
$OptGroup = '';
echo '<td><select name="GLCode">';
echo '<option value="">' . _('Select an Account Code') . '</option>';
while ($MyRowSelection=DB_fetch_array($ResultSelection)){
if ($OptGroup != $MyRowSelection['group_']) {
echo '<optgroup label="' . $MyRowSelection['group_'] . '">';
$OptGroup = $MyRowSelection['group_'];
}
if (isset($_POST['GLCode']) and $_POST['GLCode']==$MyRowSelection['accountcode']){
echo '<option selected="selected" value="' . $MyRowSelection['accountcode'] . '">' . $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8', false) . '</option>';
} else {
echo '<option value="' . $MyRowSelection['accountcode'] . '">' . $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8', false) . '</option>';
}
}
echo '</select></td>';
echo ' </tr>
</table>
<br />';
echo '<div class="centre">
<input type="submit" name="Search" value="' . _('Search Now') . '" />
<input type="submit" name="reset" value="' . _('Reset') .'" />
</div>';
if (isset($Result) and DB_num_rows($Result)>0) {
echo '<br /><table class="selection">';
$TableHeader = '<tr>
<th>' . _('Code') . '</th>
<th>' . _('Account Name') . '</th>
<th>' . _('Group') . '</th>
<th>' . _('Account Type') . '</th>
<th>' . _('Inquiry') . '</th>
<th>' . _('Edit') . '</th>
</tr>';
echo $TableHeader;
$j = 1;
while ($MyRow=DB_fetch_array($Result)) {
printf('<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td><a href="%s/GLAccountInquiry.php?Account=%s&Show=Yes&FromPeriod=%s&ToPeriod=%s"><img src="%s/css/%s/images/magnifier.png" title="' . _('Inquiry') . '" alt="' . _('Inquiry') . '" /></td>
<td><a href="%s/GLAccounts.php?SelectedAccount=%s"><img src="%s/css/%s/images/maintenance.png" title="' . _('Edit') . '" alt="' . _('Edit') . '" /></a>
</tr>',
htmlspecialchars($MyRow['accountcode'],ENT_QUOTES,'UTF-8',false),
htmlspecialchars($MyRow['accountname'],ENT_QUOTES,'UTF-8',false),
$MyRow['group_'],
$MyRow['pl'],
$RootPath,
$MyRow['accountcode'],
$TargetPeriod,
$TargetPeriod,
$RootPath,
$Theme,
$RootPath,
$MyRow['accountcode'],
$RootPath,
$Theme);
$j++;
if ($j == 12){
$j=1;
echo $TableHeader;
}
//end of page full new headings if
}
//end of while loop
echo '</table>';
}
//end if results to show
echo '</div>
</form>';
} //end AccountID already selected
include('includes/footer.php');
?>