-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqa-donations-payzone-widget.php
125 lines (107 loc) · 4.34 KB
/
qa-donations-payzone-widget.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
<?php
class qa_donations_payzone_widget {
function init_queries($tableslc) {
$tablename=qa_db_add_table_prefix('donators');
if(!in_array($tablename, $tableslc)) {
//require_once QA_INCLUDE_DIR.'qa-app-users.php';
//require_once QA_INCLUDE_DIR.'qa-db-maxima.php';
return 'CREATE TABLE IF NOT EXISTS `'.$tablename.'` (
`date` date NOT NULL,
`userid` int(10) unsigned NOT NULL,
`phone` varchar(25) NOT NULL,
`code` varchar(50) NOT NULL,
`status` varchar(50) NOT NULL,
`amount` int(11) NOT NULL DEFAULT \'0\',
KEY `userid` (`userid`),
KEY `date` (`date`)
)
';
}
}
function allow_template($template)
{
return true;
}
function allow_region($region)
{
return true;
}
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$baseUrl = qa_opt('site_url');
echo '
<script type="text/javascript">
var baseUrl = "'.$baseUrl.'";
$(document).ready(function(){
$("#fader").on("input change", function() {
$("#donation-value").text(this.value);
$("#donation-form").attr("action",baseUrl+"donation/"+this.value+"/");
});
})
</script>
<form method="get" id="donation-form" action="'.$baseUrl.'donation/350">
<label for="fader"><h2 align="center">إدعم موقع محكمتي</h2></label>
<ul class="qa-q-item-tag-list">
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/100" class="donation-link" >100 درهم</a>
</li>
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/200" class="donation-link" >200 درهم</a>
</li>
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/300" class="donation-link" >300 درهم</a>
</li>
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/500" class="donation-link" >500 درهم</a>
</li>
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/1000" class="donation-link" >1000 درهم</a>
</li>
<li class="qa-q-item-tag-item">
<a href="'.$baseUrl.'donation/2000" class="donation-link" >2000 درهم</a>
</li>
</ul>
<div class="separator">
<span class="choose">
أو إختر مبلغا يناسبك <!--Padding is optional-->
</span>
</div>
<input type="range" value="350" min="100" max="2000" step="50" id="fader">
<span id="donation"><b id="donation-value">350</b> درهم</span>
<input type="submit" class="qa-ask-link qa-a-count-zero" value="إدعم">
</form>';
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('payzone_save')) {
qa_opt('payzone_merchant_id', qa_post_text('payzone_merchant_id'));
qa_opt('payzone_merchant_password', qa_post_text('payzone_merchant_password'));
$ok = qa_lang('admin/options_saved');
}
// Create the form for display
$fields = array();
$fields[] = array(
'label' => 'Merchant id',
'tags' => 'NAME="payzone_merchant_id"',
'value' => qa_opt('payzone_merchant_id'),
'type' => 'text');
$fields[]= array(
'label' => 'Merchant password',
'tags' => 'NAME="payzone_merchant_password"',
'value' => qa_opt('payzone_merchant_password'),
'type' => 'text',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="payzone_save"',
),
),
);
}
}