-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathkargo-takip-sms-settings.php
262 lines (216 loc) · 12 KB
/
kargo-takip-sms-settings.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
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
<?php
include('kobikom-helper.php');
function kargoTR_sms_setting_page(){
$sms_provider = get_option('sms_provider');
$NetGsm_UserName = get_option('NetGsm_UserName');
$NetGsm_Password = get_option('NetGsm_Password');
$NetGsm_Header = get_option('NetGsm_Header');
$NetGsm_sms_url_send = get_option('NetGsm_sms_url_send');
//kobikom
$Kobikom_ApiKey = get_option('Kobikom_ApiKey');
$Kobikom_option_Header = get_option('Kobikom_Header');
//get sms template kargoTr_sms_template
$sms_template = get_option('kargoTr_sms_template');
?>
<div class="wrap">
<h1>Kargo Takip Türkiye</h1>
<form method="post" action="options.php">
<?php settings_fields( 'kargoTR-settings-group' ); ?>
<?php do_settings_sections( 'kargoTR-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row" style="width:50%">
<?php _e( 'Otomatik SMS Gönderilsin mi ? Gönderilmesini istiyorsanız firma seçin', 'kargoTR' ) ?>
</th>
<td>
<input type="radio" id="yokSms" <?php if( $sms_provider == 'no' ) echo 'checked'?>
name="sms_provider" value="no">
<label for="yokSms">Yok</label><br>
</td>
<td>
<input type="radio" id="NetGSM" <?php if( $sms_provider == 'NetGSM' ) echo 'checked'?>
name="sms_provider" value="NetGSM">
<label for="NetGSM">NetGSM</label><br>
</td>
<td>
<input type="radio" id="NetGSM" <?php if( $sms_provider == 'Kobikom' ) echo 'checked'?>
name="sms_provider" value="Kobikom">
<label for="Kobikom">Kobikom</label><br>
</td>
</tr>
<tr class="netgsm" <?php if( $sms_provider != 'NetGSM' ) echo 'style="display:none"'?>>
<th scope="row" style="width:50%">
<hr>
</th>
<td>
<hr>
</td>
<td>
<hr>
</td>
</tr>
<tr valign="top" class="netgsm" <?php if( $sms_provider != 'NetGSM' ) echo 'style="display:none"'?>>
<th scope="row" style="width:25%">
<?php _e( 'NetGSM Bilgileriniz <br> Abone numarasının başında 0 olmadan giriniz orneğin 212xxxxxx <br> Şifrenizide girdikten sonra kaydedin eğer şifre ve abone numaranız dogruysa <br> Sms baslıklarınız çıkacaktır <br> Lütfen başlık seçip kaydedin tekrardan', 'kargoTR' ) ?>
</th>
<td>
<label for="NetGsm_UserName" class="label-bold">Abone Numarası </label> <br>
<input type="text" id="NetGsm_UserName" name="NetGsm_UserName"
value="<?php echo esc_attr($NetGsm_UserName); ?>">
</td>
<td>
<label for="NetGSM" class="label-bold">NetGSM Şifresi</label> <br>
<input type="password" id="NetGSM" name="NetGsm_Password"
value="<?php echo __($NetGsm_Password);?>">
<br>
</td>
</tr>
<tr valign="top" class="netgsm" <?php if ($sms_provider != 'NetGSM') echo 'style="display:none"'?>>
<th scope="row" style="width:25%"></th>
<td>
<label for="NetGsm_Header" class="label-bold">SMS Başlığınız </label> <br>
<?php
if ($NetGsm_Password && $NetGsm_UserName) {
$netGsm_Header_get = kargoTR_get_netgsm_headers($NetGsm_UserName,$NetGsm_Password);
if (!$netGsm_Header_get) {
echo 'NetGSM kullanici adi veya sifreniz yanlis';
} else {
echo '<select name="NetGsm_Header" id="NetGsm_Header">';
foreach ($netGsm_Header_get as $key => $value) {
if ($NetGsm_Header == $value) {
echo '<option selected value="'.$value.'">'.$value.'</option>';
} else {
echo '<option value="'.$value.'">'.$value.'</option>';
}
}
echo '</select>';
}
}
?>
</td>
<td>
<?php
if ($NetGsm_Password && $NetGsm_UserName) {
$NetGSM_packet_info = kargoTR_get_netgsm_packet_info($NetGsm_UserName,$NetGsm_Password);
$NetGSM_credit_info = kargoTR_get_netgsm_credit_info($NetGsm_UserName,$NetGsm_Password);
if ($NetGSM_packet_info) {
echo '<b>Kalan Paketleriniz :</b> <br> '.__($NetGSM_packet_info);
}
if ($NetGSM_credit_info) {
echo '<b>Kalan Krediniz :</b> <br> '.esc_attr($NetGSM_credit_info) .' TL';
}
}
?>
</td>
</tr>
<tr class="Kobikom" <?php if( $sms_provider != 'Kobikom' ) echo 'style="display:none"'?>>
<th scope="row" style="width:40%">
<hr>
</th>
<td>
<hr>
</td>
<td>
<hr>
</td>
</tr>
<tr valign="top" class="Kobikom" <?php if( $sms_provider != 'Kobikom' ) echo 'style="display:none"'?>>
<th scope="row" style="width:25%">
<?php _e( 'Kobikom Bilgileriniz <br> Kobikom API adresinizi girmeniz gerekmektedir.', 'kargoTR' ) ?>
</th>
<td>
<label for="Kobikom_ApiKey" class="label-bold">Kobikom API key anahtariniz</label> <br>
<textarea type="text" id="Kobikom_ApiKey" name="Kobikom_ApiKey" rows="6" ><?php echo esc_attr($Kobikom_ApiKey); ?></textarea>
</td>
</tr>
<tr valign="top" class="Kobikom" <?php if ($sms_provider != 'Kobikom') echo 'style="display:none"'?>>
<th scope="row" style="width:25%"></th>
<td>
<label for="KobiKom_Header" class="label-bold">SMS Başlığınız </label> <br>
<?php
if ($Kobikom_ApiKey) {
$KobiKom_get_Headers = kargoTR_get_kobikom_headers($Kobikom_ApiKey);
if (!$KobiKom_get_Headers) {
echo 'Kobikom Api Keyiniz yanlis';
} else {
echo '<select name="Kobikom_Header" id="Kobikom_Header">';
foreach ($KobiKom_get_Headers as $key => $value) {
if ($Kobikom_option_Header == $value['title']) {
echo '<option selected value="'.$value['title'].'">'.$value['title'].'</option>';
} else {
echo '<option value="'.$value['title'].'">'.$value['title'].'</option>';
}
}
echo '</select>';
}
}
?>
</td>
<td>
<?php
if ($Kobikom_ApiKey){
$KobiKom_get_Credit = kargoTR_get_kobikom_balance($Kobikom_ApiKey);
echo "Kobikom Paketleriniz : <br> <hr>";
if ($KobiKom_get_Credit) {
foreach ($KobiKom_get_Credit as $key => $value) {
echo $value['name'] . ' : <br> Kalan Kredi ' . $value['amount'] . ' SMS <br> Paketin Son Kullanma Tarihi : ' . $value['finished_at'] . '<br>';
}
}else
{
echo "Kobikom Api Keyiniz yanlis";
}
}
?>
</td>
</tr>
<tr valign="top">
<td>
<label for="sms_template" class="label-bold">SMS Şablonu</label> <br>
Buradan istediğiniz şekilde sms şablonu oluşturabilirsiniz. <br>
<b>Örnek Şablon</b> : <br>
Merhaba {customer_name} <br>
{order_id} nolu siparişiniz kargoya verildi. <br>
Kargo şirketiniz : {company_name} <br>
Kargo takip numaranız : {tracking_number} <br>
Kargo takip linkiniz : {tracking_url} <br>
İyi günler dileriz.<br>
<br>
<b>Not : </b> <br>
<b>{customer_name} : Müşteri adı</b> <br>
<b>{order_id} : Sipariş numarası</b> <br>
<b>{company_name} : Kargo Şirket adı</b> <br>
<b>{tracking_number} : Kargo takip numarası</b> <br>
<b>{tracking_url} : Kargo takip linki</b> <br>
</td>
<td colspan="2">
<textarea type="text" id="sms_template" style="width:100%" name="kargoTr_sms_template" rows="6" ><?php echo esc_attr($sms_template); ?></textarea>
</td>
</tr>
</table>
<?php submit_button(); ?>
<script>
jQuery(document).ready(function ($) {
$('input[type=radio][name=sms_provider]').change(function () {
if (this.value == 'no') {
$('.netgsm').hide();
} else if (this.value == 'NetGSM') {
$('.netgsm').show(2000);
$('.Kobikom').hide();
}
else if (this.value == 'Kobikom') {
$('.Kobikom').show(2000);
$('.netgsm').hide();
}
});
})
</script>
<style>
.label-bold {
text-align: center;
font-weight: bold;
}
</style>
</form>
</div>
<?php
}