-
Notifications
You must be signed in to change notification settings - Fork 1
/
page-tickets.php
247 lines (217 loc) · 7.34 KB
/
page-tickets.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
<?php
/*
* Template Name: Trac Tickets
* Description: a page templage to show a list of tickets.
*/
?>
<?php
get_header();
wp_enqueue_script('jquery.dataTables');
wp_enqueue_style('jquery.dataTables');
wp_enqueue_script('jquery-ui-dialog');
wp_enqueue_style('jquery-ui');
?>
<script type="text/javascript" charset="utf-8">
<!--
/**
* call back function to load details info for a ticket.
* ticket id will pass through the event.
*/
function ticketDetails(event) {
var ticketId = event.data.ticketId;
//alert(ticketId);
jQuery("#ticketDetail").html("<strong>Loading #" + ticketId + " ...</strong>");
jQuery('#mydialog').dialog("open");
var data = {
"action" : "wptc_get_ticket_cb",
"id" : ticketId,
};
jQuery.post('wp-admin/admin-ajax.php', data, function(response) {
// the response is in JSON format, parse it to objects.
res = JSON.parse(response);
alert ('Object Count: ' + res.length);
jQuery("#ticketDetail").html('<strong>Here is ticket: <br/>' + response + '</strong>');
});
}
jQuery(document).ready(function() {
jQuery('#tickets').dataTable( {
"bProcessing": true,
"bServerSide": true,
// trun off the length change drop down.
"bLengthChange" : false,
// turn off filter.
"bFilter" : false,
// turn off sorting.
"bSort" : false,
"iDisplayLength" : 15,
"sAjaxSource": "<?php echo admin_url('admin-ajax.php'); ?>",
"sServerMethod" : "POST",
"fnServerParams" : function (aoData) {
aoData.push(
{"name" : "action",
"value" : "wptc_get_tickets_cb"}
);
},
"fnRowCallback" : function (nRow, aData, iDisplayIndex) {
var column = jQuery('td:eq(0)', nRow);
var href = jQuery('a', column);
var id = href.html();
//alert('id=' + id);
href.attr("href", "ticket?id=" + id);
// this is the event handler way, we can pass
// some data to the handler function.
href.on("clickB", {ticketId: id}, ticketDetails);
href.on("clickA", function() {
var ticketId = jQuery(this).html();
//alert (ticketId);
// set the message on the blank page.
jQuery("#ticketDetail").html("<strong>Loading Ticket #" + ticketId + " ...</strong>");
// open the dialog first.
jQuery('#mydialog').dialog("open");
// get ready the post data.
var data = {
// the call back action.
"action" : "wptc_get_ticket_cb",
"id" : ticketId,
};
// send the AJAX request.
jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", data, function(response) {
//alert(response);
jQuery("#ticketDetail").html('<strong>Here is ticket: <br/>' + response + '</strong>');
});
});
}
} );
jQuery('#mydialog').dialog({
autoOpen: false,
height: 300,
width: 450,
modal: true,
buttons: {
"Save" : function() {
jQuery(this).dialog("close");
}
}
});
} );
jQuery("a[name^='ticket-']").click(function() {
alert('id=' + 123);
});
-->
</script>
<div id="left_column">
<div class='leftnav'>
<div id='sprint-nav' class="widget">
<h2 class='widgettitle'>Sprint Navigation</h2>
<?php wptc_widget_sprint_nav()?>
</div>
</div>
</div>
<div id="right_column">
<h2>Just a testing from </h2>
<p>
<table cellpadding="0" cellspacing="0" border="0" id="tickets">
<thead><th width="18px">ID</th><th>Summary</th><th width="68px">Owner</th><th width="58px">Priority</th><th width="58px">Status</th></thead>
<tbody>
<tr>
<td colspan="4" class="dataTables_empty">Loading data from server</td>
</tr>
</tbody>
<tfoot><th>ID</th><th>Summary</th><th>Owner</th><th>Priority</th><th>Status</th></tfoot>
</table>
</p>
<p></p>
<p><input type="button" onclick="javascript: showVersions()" name="versions" value="versions"/></p>
<script type="text/javascript" charset="utf-8">
<!--
function showVersions() {
var data = {
"action" : 'wptc_get_tickets_cb',
};
jQuery.post('wp-admin/admin-ajax.php', data, function(response) {
alert('got from server: ' + response);
});
}
-->
</script>
<p><button id="testDialog" onclick="javascript: ticketDetails(12)">Test Dialog</button><br/>
</p>
<?php // the dialog to show details about a ticket. ?>
<div id="mydialog" title="For Testing">
<h3>Ticket Summary</h3>
<div id="ticketDetail">
details about the ticket.
<?php // ticket view start?>
<div id="ticket">
<div class="date">
<p>Opened <a class="timeline" href="/trac/egov_opspedia-search/timeline?from=2012-10-22T10%3A58%3A26-04%3A00&precision=second" title="2012-10-22T10:58:26-04:00 in Timeline">4 days</a> ago</p>
</div>
<h2 class="summary searchable">Upgrade Solr to 4.0</h2>
<table class="properties">
<tbody><tr>
<th id="h_reporter">Reported by:</th>
<td headers="h_reporter" class="searchable">
<a href="/trac/egov_opspedia-search/query?status=!closed&reporter=tomsommerville">tomsommerville</a>
</td>
<th id="h_owner">Owned by:</th>
<td headers="h_owner">
<a href="/trac/egov_opspedia-search/query?status=!closed&owner=seanchen">seanchen</a>
</td>
</tr>
<tr>
<th id="h_priority">
Priority:
</th>
<td headers="h_priority">
<a href="/trac/egov_opspedia-search/query?status=!closed&priority=major">major</a>
</td>
<th id="h_milestone">
Milestone:
</th>
<td headers="h_milestone">
<a class="milestone" href="/trac/egov_opspedia-search/milestone/Search%200.1">Search 0.1</a>
</td>
</tr><tr>
<th id="h_component">
Component:
</th>
<td headers="h_component">
<a href="/trac/egov_opspedia-search/query?status=!closed&component=Search+Index">Search Index</a>
</td>
<th id="h_version">
Version:
</th>
<td headers="h_version">
<a href="/trac/egov_opspedia-search/query?status=!closed&version=Sprint+2">Sprint 2</a>
</td>
</tr><tr>
<th id="h_keywords">
Keywords:
</th>
<td headers="h_keywords" class="searchable">
</td>
<th id="h_cc">
Cc:
</th>
<td headers="h_cc" class="searchable">
</td>
</tr>
</tbody></table>
<div class="description">
<h3 id="comment:description">
Description
<a class="anchor" href="#comment:description" title="Link to this section"> ¶</a></h3>
<br style="clear: both">
</div>
</div>
<?php // ticket view end ?>
</div>
</div>
<pre>
<?php
//var_dump(wptc_get_ticket(525));
?>
</pre>
</div> <?php // END right_column ?>
<?php //get_sidebar(); ?>
<?php get_footer(); ?>