-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconf_prices.php
More file actions
109 lines (105 loc) · 7.18 KB
/
conf_prices.php
File metadata and controls
109 lines (105 loc) · 7.18 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
<?php
/*
* OSCLass – software for creating and publishing online classified
* advertising platforms
*
* Copyright (C) 2010 OSCLASS
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<?php
$conn = getConnection();
if (Params::getParam('plugin_action') == 'done') {
$pub_prices = Params::getParam("pub_prices");
$pr_prices = Params::getParam("pr_prices");
$pr_pl_prices = Params::getParam("pr_pl_prices");
foreach ($pr_prices as $k => $v) {
$conn->osc_dbExec("REPLACE INTO %st_paypal_prices (fk_i_category_id, f_publish_cost, f_premium_cost, f_premium_plus_cost) VALUES ('%d', %s, %s, %s)", DB_TABLE_PREFIX, $k, $pub_prices[$k] == '' ? 'NULL' : $pub_prices[$k], $v == '' ? 'NULL' : $v, $pr_pl_prices[$k] == '' ? 'NULL' : $pr_pl_prices[$k]);
}
}
$categories = Category::newInstance()->toTreeAll();
$prices = $conn->osc_dbFetchResults("SELECT * FROM %st_paypal_prices", DB_TABLE_PREFIX);
$cat_prices = array();
foreach ($prices as $p) {
$cat_prices[$p['fk_i_category_id']]['f_publish_cost'] = $p['f_publish_cost'];
$cat_prices[$p['fk_i_category_id']]['f_premium_cost'] = $p['f_premium_cost'];
$cat_prices[$p['fk_i_category_id']]['f_premium_plus_cost'] = $p['f_premium_plus_cost'];
}
?>
<div id="settings_form" style="border: 1px solid #ccc; background: #eee; ">
<div style="padding: 20px;">
<div style="float: left; width: 100%;">
<fieldset>
<legend><?php _e('Paypal Options', 'paypalplus'); ?></legend>
<div style="float: left; width: 100%;">
<form name="paypal_form" id="paypal_form" action="<?php echo osc_admin_base_url(true); ?>" method="POST" enctype="multipart/form-data" >
<input type="hidden" name="page" value="plugins" />
<input type="hidden" name="action" value="renderplugin" />
<input type="hidden" name="file" value="<?php echo osc_plugin_folder(__FILE__); ?>conf_prices.php" />
<input type="hidden" name="plugin_action" value="done" />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width:300px;"><?php _e('Category Name', 'paypalplus'); ?></td>
<td style="width:175px;"><?php echo sprintf(__('Publish fee (%s)', 'paypal'), osc_get_preference('currency', 'paypalplus')); ?></td>
<td style="width:175px;"><?php echo sprintf(__('Premium fee (%s)', 'paypal'), osc_get_preference('currency', 'paypalplus')); ?></td>
<td style="width:175px;"><?php echo sprintf(__('Premium Plus fee (%s)', 'paypal'), osc_get_preference('currency', 'paypalplus')); ?></td>
</tr>
<?php foreach ($categories as $c) { ?>
<tr>
<td>
<?php echo $c['s_name']; ?>
</td>
<td>
<input style="width:150px;text-align:right;" type="text" name="pub_prices[<?php echo $c['pk_i_id'] ?>]" id="pub_prices[<?php echo $c['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$c['pk_i_id']]) ? $cat_prices[$c['pk_i_id']]['f_publish_cost'] : ''; ?>" />
</td>
<td>
<input style="width:150px;text-align:right;" type="text" name="pr_prices[<?php echo $c['pk_i_id'] ?>]" id="pr_prices[<?php echo $c['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$c['pk_i_id']]) ? $cat_prices[$c['pk_i_id']]['f_premium_cost'] : ''; ?>" />
</td>
<td>
<input style="width:150px;text-align:right;" type="text" name="pr_pl_prices[<?php echo $c['pk_i_id'] ?>]" id="pr_pl_prices[<?php echo $c['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$c['pk_i_id']]) ? $cat_prices[$c['pk_i_id']]['f_premium_plus_cost'] : ''; ?>" />
</td>
</tr>
<?php foreach ($c['categories'] as $cc) { ?>
<tr>
<td>
<?php echo $cc['s_name']; ?>
</td>
<td>
<input style="width:150px;text-align:right;" type="text" name="pub_prices[<?php echo $cc['pk_i_id'] ?>]" id="pub_prices[<?php echo $cc['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$cc['pk_i_id']]) ? $cat_prices[$cc['pk_i_id']]['f_publish_cost'] : ''; ?>" /></td>
<td><input style="width:150px;text-align:right;" type="text" name="pr_prices[<?php echo $cc['pk_i_id'] ?>]" id="pr_prices[<?php echo $cc['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$cc['pk_i_id']]) ? $cat_prices[$cc['pk_i_id']]['f_premium_cost'] : ''; ?>" /></td>
<td><input style="width:150px;text-align:right;" type="text" name="pr_pl_prices[<?php echo $cc['pk_i_id'] ?>]" id="pr_pl_prices[<?php echo $cc['pk_i_id'] ?>]" value="<?php echo isset($cat_prices[$cc['pk_i_id']]) ? $cat_prices[$cc['pk_i_id']]['f_premium_plus_cost'] : ''; ?>" /></td>
</tr>
</tr>
<?php } ?>
<?php } ?>
</table>
<button type="submit" style="float: right;"><?php _e('Update', 'paypalplus'); ?></button>
</form>
</div>
</fieldset>
</div>
<div style="clear:both;">
<div style="float: left; width: 100%;">
<fieldset>
<legend><?php _e('Help', 'paypalplus'); ?></legend>
<h3><?php _e('Setting up your fees', 'paypalplus'); ?></h3>
<p>
<?php _e('You could set up different prices for each category', 'paypalplus'); ?>. <?php _e('If the price of a category is left empty, the default value will be applied', 'paypalplus'); ?>.
</p>
</fieldset>
</div>
<div style="clear: both;"></div>
</div>
</div>