-
Notifications
You must be signed in to change notification settings - Fork 5
/
post_update_order.php
175 lines (155 loc) · 4.33 KB
/
post_update_order.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
<!doctype html>
<?php
session_start();?>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Modal form</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
body {
font-size: 62.5%;
}
label, input {
display:block;
}
input.text {
margin-bottom:12px;
width:95%;
padding: .4em;
}
fieldset {
padding:0;
border:0;
margin-top:25px;
}
h1 {
font-size: 1.2em;
margin: .6em 0;
}
div#users-contain {
width: 350px;
margin: 20px 0;
}
div#users-contain table {
margin: 1em 0;
border-collapse: collapse;
width: 100%;
}
div#users-contain table td, div#users-contain table th {
border: 1px solid #eee;
padding: .6em 10px;
text-align: left;
}
.ui-dialog .ui-state-error {
padding: .3em;
}
.validateTips {
border: 1px solid transparent;
padding: 0.3em;
}
</style>
<script>
$(function() {
var order_id = $( "#order_id" ),
field_name = $( "#field_name_id" ),
field_value = $( "#field_value_id" ),
email = $( "#email" ),
password = $( "#password" ),
allFields = $( [] ).add( name ).add( email ).add( password ),
tips = $( ".validateTips" );
function updateTips( t ) {
tips
.text( t )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );
}
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false;
} else {
return true;
}
}
function checkRegexp( o, regexp, n ) {
if ( !( regexp.test( o.val() ) ) ) {
o.addClass( "ui-state-error" );
updateTips( n );
return false;
} else {
return true;
}
}
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Call SDK": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
$.post("call_post_update_order.php", { order_id: order_id.val(),
field_name: field_name.val(),
field_value: field_value.val() })
.done(function(data) {
$("#response").html(data);
});
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#btn-parameters" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
});
</script>
</head>
<body>
<div id="dialog-form" title="Parameters Dialog Box">
<p class="validateTips">Please provide order id: e.g. <b>SD13097689151254</b></p>
<form>
<fieldset>
<label for="order_id">Order Id</label>
<input type="text" name="order_id" id="order_id" class="text ui-widget-content ui-corner-all" />
<label for="field_name_id">Field name eg. <b>shippaid</b></label>
<input type="text" name="field_name" id="field_name_id" class="text ui-widget-content ui-corner-all" />
<label for="field_value_id">Field value eg. <b>15.00</b></label>
<input type="text" name="field_value" id="field_value_id" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
<h1><?=isset($_SESSION['username'])? "Logged in user:" . $_SESSION['username']:"Please authenticate"?></h1>
<br />
<button id="btn-parameters">Click here to provide parameters</button>
<div id="users-contain" class="ui-widget">
<h1>API Response:</h1>
<div id=response> </div>
<br> <br>
<h1>Source Code:</h1>
<pre style="font-size:12px;">
$token = isset($_SESSION['token'])?$_SESSION['token']:'';
echo "---- Update order ----<br>";
$order = array('order' => $_REQUEST['order_id'], $_REQUEST['field_name'] => $_REQUEST['field_value']);
$result = SureDone_Store::update_order($order, $token, isset($_SESSION['username'])?$_SESSION['username']:'');
print_r($result);
</pre>
</div>
</body>
</html>