-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodify_payment_methods.php
More file actions
322 lines (275 loc) · 13.8 KB
/
Copy pathmodify_payment_methods.php
File metadata and controls
322 lines (275 loc) · 13.8 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
/*
Copyright (C) 2007 - 2021, Christoph Marti
Copyleft 2021- Christian M. Stefan, Florian Meerwinck
LICENCE TERMS:
This module is free software. You can redistribute it and/or modify it
under the terms of the GNU General Public License - version 2 or later,
as published by the Free Software Foundation: http://www.gnu.org/licenses/gpl.html.
DISCLAIMER:
This module is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
require('../../config.php');
// Include WB admin wrapper script
require(WB_PATH.'/modules/admin.php');
require_once(WB_PATH.'/modules/bakery/functions.php');
// Look for language file
if (LANGUAGE_LOADED) {
require_once __DIR__.'/languages/EN.php';
if (file_exists($sFile = __DIR__.'/languages/'.LANGUAGE.'.php')) {
require_once $sFile;
}
}
// Check installed payment methods and load new ones
require_once __DIR__.'/payment_methods/load.php';
// Get selected payment method
$payment_method = isset($_GET['payment_method']) ? strip_tags($_GET['payment_method']) : 'advance';
?>
<script language="javascript" type="text/javascript">
function mod_bakery_select_payment_method_b() {
document.getElementsByName("reload")[0].value = "true";
document.modify.submit();
}
</script>
<form name="modify" action="<?=WB_URL; ?>/modules/bakery/save_payment_methods.php" method="post" style="margin: 0;">
<input type="hidden" name="section_id" value="<?=$section_id; ?>" />
<input type="hidden" name="page_id" value="<?=$page_id; ?>" />
<input type="hidden" name="update_payment_method" value="<?=$payment_method; ?>" />
<input type="hidden" name="reload" value="false" />
<table cellpadding="2" cellspacing="0" border="0" align="center" width="98%">
<tr>
<td colspan="5"><h2><?=$TXT_BAKERY['SELECT_PAYMENT_METHODS']; ?></h2></td>
</tr>
<tr>
<td>
<input type="button" value="<?=$MENU['HELP']; ?>" onclick="javascript: window.open('<?=WB_URL; ?>/modules/bakery/help.php?page_id=<?=$page_id; ?>§ion_id=<?=$section_id; ?>&payment_method=<?=$payment_method; ?>#email','bar','top=50,left=50,width=800,height=600');" style="width: 100px;" />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?=$TXT_BAKERY['PAYMENT_METHODS']; ?>:</b></td>
<td colspan="4">
<?php
// LOAD ALL PAYMENT METHODS, DISPLAY CHECKBOXES AND GENERATE A DROP DOWN MENU
// **************************************************************************
// Initialize vars
$sPaymentMethodOptions = '';
$sPaymentMethodTitle = '';
// Get content of payment methods table
$aPaymentMethods = $database->get_array(
"SELECT `pm_id`, `active`, `directory`, `name`
FROM `{BXT}_payment_methods`
ORDER BY `pm_id` ASC"
);
if (is_array($aPaymentMethods)) {
// Generate html table with checkboxes
$i = 0;
$num_col = 3;
?>
<ul>
<?php
// Loop through payment methods
foreach ($aPaymentMethods as $rec) {
$rec = array_map('lazystrip', $rec);
$pm_id = $rec['pm_id'];
$active = $rec['active'];
$directory = $rec['directory'];
$name = $rec['name'];
// Get localized payment method name or fall back to english version
unset($TXT_BAKERY[$payment_method]);
$payment_method_name = $name;
$no_include = true;
// Look for payment method language files
if (LANGUAGE_LOADED) {
// Default english
if (file_exists($sFile = __DIR__.'/payment_methods/'.$directory.'/languages/EN.php')) {
include_once $sFile;
$no_include = false;
}
// Current language
if (file_exists($sFile = __DIR__.'/payment_methods/'.$directory.'/languages/'.LANGUAGE.'.php')) {
include_once $sFile;
$no_include = false;
}
// Warning if no language file has been found at all and skip this method
// Probably the payment method directory is missing
if ($no_include) {
echo '<p style="color: red;"><b>Failed to include language files.</b><br />The payment method "'.$name.'" is not available. Make sure the requested payment method directory and associated files exist on your server.</p>';
continue;
}
if (!empty($TXT_BAKERY[$payment_method]['NAME'])) {
$payment_method_name = $TXT_BAKERY[$payment_method]['NAME'];
}
elseif (!empty($TXT_BAKERY[$payment_method]['TITLE'])) {
$payment_method_name = $TXT_BAKERY[$payment_method]['TITLE'];
}
}
$sChecked = $active ? ' checked' : '';
// Generate list of checkboxes
?><li>
<label><input type="checkbox" <?=$sChecked?> name="payment_methods[<?=$pm_id?>]" value="<?=$directory?>">
<img src="<?=get_url_from_path( __DIR__.'/payment_methods/'.$directory)?>/icon.png" title="<?=strtoupper($directory)?>"> <?=$payment_method_name?>
</label>
<input type="hidden" name="all_payment_methods[]" value="<?=$pm_id?>" /></li>
<?php
// Generate select options for modifying payment methods
$sPaymentMethodOptions .= '<option value="'.$directory.'"';
if ($payment_method == $directory) {
$sPaymentMethodOptions .= ' selected="selected"';
$sPaymentMethodTitle = $payment_method_name;
}
$sPaymentMethodOptions .= '>'.$payment_method_name.'</option>'."\n";
}
}
?>
</ul>
</td>
</tr>
<tr valign="bottom">
<td colspan="5" height="65" valign="bottom"><h2><?=$TEXT['MODIFY'].' '.$TXT_BAKERY['PAYMENT_METHOD'].' «'.$sPaymentMethodTitle; ?>»</h2></td>
</tr>
<tr>
<td width="30%" align="right"><strong><?=$TEXT['PLEASE_SELECT']; ?>:</strong></td>
<td colspan="4">
<select name='modify_payment_method' style='width: 98%' onchange='mod_bakery_select_payment_method_b()'>
<?=$sPaymentMethodOptions; ?>
</select>
</td>
</tr>
<?php
// CURRENT PAYMENT METHOD SETTINGS
// *******************************
// Get data of current payment method for modification
$no_setting = true;
$setting_table = '';
$setting_info = '';
unset($TXT_BAKERY[$payment_method]);
$query_payment_methods = $database->query("SELECT * FROM {BXT}_payment_methods WHERE directory = '$payment_method' LIMIT 1");
if ($query_payment_methods->numRows() > 0) {
$fetch_payment_methods = $query_payment_methods->fetchRow();
$fetch_payment_methods = array_map('lazystrip', $fetch_payment_methods);
$cust_email_subject = $fetch_payment_methods['cust_email_subject'];
$cust_email_body = $fetch_payment_methods['cust_email_body'];
$shop_email_subject = $fetch_payment_methods['shop_email_subject'];
$shop_email_body = $fetch_payment_methods['shop_email_body'];
// Look for payment method language file
if (LANGUAGE_LOADED) {
include __DIR__.'/payment_methods/'.$payment_method.'/languages/EN.php';
if (file_exists($sFile = __DIR__.'/payment_methods/'.$payment_method.'/languages/'.LANGUAGE.'.php')) {
include $sFile;
}
}
// Generate textareas
for ($i = 1; $i <= 6; $i++) {
$field = $fetch_payment_methods['field_'.$i];
$txt_index = strtoupper($field);
$value = $fetch_payment_methods['value_'.$i];
if (!empty($field) && $field != 'invoice_template' && $field != 'invoice_alert' && $field != 'reminder_alert' ) {
$no_setting = false;
$setting_table .= ''
. '<tr>'
. '<td width="30%" align="right" valign="top">'
. $TXT_BAKERY[$payment_method][$txt_index].':'
. '</td>'
. '<td colspan="4">'
. '<textarea name="update[value_'.$i.']" rows="3" style="width: 98%;">'.$value.'</textarea>'
. '</td>'
. '</tr>';
}
// Special input fields for the invoice and reminder alert
elseif ($field == 'invoice_alert' || $field == 'reminder_alert') {
$setting_table .= '<tr>
<td width="30%" align="right">'.$TXT_BAKERY[$payment_method][$txt_index].':</td>
<td colspan="4">
<input type="text" maxlength="3" name="update[value_'.$i.']" style="width: 30px; text-align: right;" value="'.$value.'" /> '.$TXT_BAKERY['DAYS'].'</td>
</tr>';
}
// Special textarea for invoice template
elseif ($field == 'invoice_template') {
$setting_table .= '
<tr valign="bottom">
<td width="30%" height="32" align="right">
<strong>'.$TXT_BAKERY['LAYOUT'].' '.$TXT_BAKERY['SETTINGS'].':</strong>
</td>
</tr>
<tr>
<td width="30%" align="right" valign="top">
'.$TXT_BAKERY[$payment_method]['TXT_INVOICE_TEMPLATE'].':
</td>
<td colspan="4">
<textarea name="update[value_4]" style="width: 98%; height: 100px;">'.htmlentities($value).'</textarea>
</td>
</tr>
';
}
}
// If no payment method setting has been set
$setting_info = $no_setting ? $TXT_BAKERY['NO_PAYMENT_METHOD_SETTING'] : ' ';
}
// Show payment method header
echo '<tr valign="bottom">';
echo '<td width="30%" height="32" align="right"><strong>'.$TXT_BAKERY['SETTINGS'].':</strong></td>';
echo '<td height="32" colspan="4">'.$setting_info.'</td>';
echo '</tr>';
// Show payment method textareas
echo $setting_table;
// Show payment method notice if exists
if (isset($TXT_BAKERY[$payment_method]['NOTICE']) && !empty($TXT_BAKERY[$payment_method]['NOTICE'])) {
echo '<tr valign="top">';
echo '<td width="30%" height="32" align="right"><strong>'.$TXT_BAKERY['NOTICE'].':</strong></td>';
echo '<td height="32" colspan="4"><p style="width: 97%; margin: 0; padding: 3px; border: solid 1px #FFD700; background-color: #FFFFDD;">'.$TXT_BAKERY[$payment_method]['NOTICE'].'</p></td>';
echo '</tr>';
}
// Emails to customer and shop ?>
<tr valign="bottom">
<td width="30%" height="32" align="right">
<strong><?=$TXT_BAKERY['EMAIL']; ?>:</strong>
</td>
</tr>
<tr>
<td width="30%" align="right">
<?=$TXT_BAKERY['EMAIL_SUBJECT'].' '.$TXT_BAKERY['CUSTOMER']; ?>:
</td>
<td colspan="4">
<input type="text" name="update[cust_email_subject]" style="width: 98%" value="<?=$cust_email_subject; ?>" />
</td>
</tr>
<tr>
<td width="30%" align="right" valign="top">
<?=$TXT_BAKERY['EMAIL_BODY'].' '.$TXT_BAKERY['CUSTOMER']; ?>:
</td>
<td colspan="4">
<textarea name="update[cust_email_body]" style="width: 98%; height: 80px;"><?=$cust_email_body; ?></textarea>
</td>
</tr>
<tr>
<td width="30%" align="right">
<?=$TXT_BAKERY['EMAIL_SUBJECT'].' '.$TXT_BAKERY['SHOP']; ?>:
</td>
<td colspan="4">
<input type="text" name="update[shop_email_subject]" style="width: 98%" value="<?=$shop_email_subject; ?>" />
</td>
</tr>
<tr>
<td width="30%" align="right" valign="top">
<?=$TXT_BAKERY['EMAIL_BODY'].' '.$TXT_BAKERY['SHOP']; ?>:
</td>
<td colspan="4">
<textarea name="update[shop_email_body]" style="width: 98%; height: 80px;"><?=$shop_email_body; ?></textarea>
</td>
</tr>
</table>
<br />
<table width="98%" align="center" cellpadding="0" cellspacing="0" class="mod_bakery_submit_row_b">
<tr valign="top">
<td height="30" align="left">
<input name="save" type="submit" value="<?=$TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" /></td>
<td height="30" align="right">
<input type="button" value="<?=$TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?=ADMIN_URL; ?>/pages/modify.php?page_id=<?=$page_id; ?>';" style="width: 100px; margin-top: 5px;" /> </td>
</tr>
</table>
</form>
<?php
$admin->print_footer();// Print admin footer