-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakepremium.php
More file actions
86 lines (85 loc) · 4.82 KB
/
makepremium.php
File metadata and controls
86 lines (85 loc) · 4.82 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
<?php
if (osc_get_preference('allow_premium', 'paypalplus')) {
// Load Item Information, so we could tell the user which item is he/she paying for
$item = Item::newInstance()->findByPrimaryKey(Params::getParam('itemId'));
if ($item) {
// Check if it's already payed or not
if (!paypalplus_is_premium($item['pk_i_id'])) {
// Item is not paid, continue
$conn = getConnection();
$ppl_category = $conn->osc_dbFetchResult("SELECT f_premium_cost FROM %st_paypal_prices WHERE fk_i_category_id = %d", DB_TABLE_PREFIX, $item['fk_i_category_id']);
if ($ppl_category && isset($ppl_category['f_premium_cost']) && $ppl_category['f_premium_cost'] > 0) {
$category_fee = $ppl_category['f_premium_cost'];
} else {
$category_fee = osc_get_preference('default_premium_cost', 'paypalplus');
}
if ($category_fee > 0) {
?>
<h1><?php _e('Make the ad premium', 'paypalplus'); ?></h1>
<div>
<div style="float:left; width: 50%;">
<label style="font-weight: bold;"><?php _e("Item's title", 'paypalplus'); ?>:</label> <?php echo $item['s_title']; ?><br/>
<label style="font-weight: bold;"><?php _e("Item's description", 'paypalplus'); ?>:</label> <?php echo $item['s_description']; ?><br/>
</div>
<div style="float:left; width: 50%;">
<?php _e("In order to make premium your ad , it's required to pay a fee", 'paypalplus'); ?>.<br/>
<?php echo sprintf(__("The current fee for this category is: %.2f %s", 'paypalplus'), $category_fee, osc_get_preference('currency', 'paypalplus')); ?><br/>
<?php
if (osc_is_web_user_logged_in()) {
$conn = getConnection();
$wallet = $conn->osc_dbFetchResult("SELECT * FROM %st_paypal_wallet WHERE fk_i_user_id = %d", DB_TABLE_PREFIX, osc_logged_user_id());
$bonuscredit = $conn->osc_dbFetchResult("SELECT * FROM %st_paypal_bonus WHERE fk_i_user_id = %d", DB_TABLE_PREFIX, osc_logged_user_id());
$totalcredit = $wallet['f_amount'] + $bonuscredit['f_bonus'];
if ($totalcredit >= $category_fee) {
wallet_button($category_fee, sprintf(__("Premium fee for item %d at %s", "paypalplus"), $item['pk_i_id'], osc_page_title()), $item['fk_i_user_id'] . "|" . $item['pk_i_id'] . "|" . $item['s_contact_email'], "201x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id']);
} else {
paypalplus_button($category_fee, sprintf(__("Premium fee for item %d at %s", "paypalplus"), $item['pk_i_id'], osc_page_title()), $item['fk_i_user_id'] . "|" . $item['pk_i_id'] . "|" . $item['s_contact_email'], "201x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id']);
}
} else {
paypalplus_button($category_fee, sprintf(__("Premium fee for item %d at %s", "paypalplus"), $item['pk_i_id'], osc_page_title()), $item['fk_i_user_id'] . "|" . $item['pk_i_id'] . "|" . $item['s_contact_email'], "201x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id']);
}
?>
</div>
<div style="clear:both;"></div>
<div name="result_div" id="result_div"></div>
<script type="text/javascript">
var rd = document.getElementById("result_div");
</script>
</div>
<?php
} else {
// PRICE IS ZERO!
?>
<h1><?php _e('There was an error', 'paypalplus'); ?></h1>
<div>
<p><?php _e("There's no need to pay the premium fee", 'paypalplus'); ?></p>
</div>
<?php
}
} else {
// ITEM WAS ALREADY PAID! STOP HERE
?>
<h1><?php _e('There was an error', 'paypalplus'); ?></h1>
<div>
<p><?php _e('The item is already a premium ad', 'paypalplus'); ?></p>
</div>
<?php
}
} else {
//ITEM DOES NOT EXIST! STOP HERE
?>
<h1><?php _e('There was an error', 'paypalplus'); ?></h1>
<div>
<p><?php _e('The item doesn not exists', 'paypalplus'); ?></p>
</div>
<?php
}
} else {
// NO NEED TO PAY AT ALL!
?>
<h1><?php _e("There was an error", "paypalplus"); ?></h1>
<br/>
<div><p><?php _e("Premiums ads are not allowed", "paypalplus"); ?></p></div>
<?php
}
?>