function mod_tickets_destruct type mod_tickets die function mod_ticket

  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
function mod_tickets_destruct(){
$("a[type='mod_tickets']").die();
}
function mod_tickets_init(request){
$('#tickets_table_block').show(300);
tickets_indicator.set_count(false);
var modul_core = new mod_tickets_core ();
setTimeout(modul_core.tickets_table_init,150);
$("a[type='mod_tickets']").live('click',function (){
var obj = $(this);
switch(obj.attr('id')) {
case 'read_tickets':
modul_core.read_tickets(obj.attr('ticket'));
navig_bar(eval('({"'+LANG.field_mod_tickets+'":"tickets","'+obj.text().replace(/(")/g,'"')+'":""})'));
break;
case 'add_ticket':
modul_core.add_ticket();
break;
case 'new_ticket':
modul_core.new_ticket();
break;
case 'close_ticket':
modul_core.close_ticket(obj.attr('ticket_id'));
break;
case 'cancel_ticket':
$.fancybox.close();
break;
}
});
}
function mod_tickets_core(){
var hendl = this;
this.new_ticket = function () {
var Cq = new Cquery(true);
Cq.url = PANEL + 'tickets/new/';
Cq.request(function (request){
if (request.tickets_stat) {
show_form (request.tpl,450,383,false);
var sel_obj = $("#category");
var tmp = '<option value="">'+LANG.field_sel_val+'</option>';
$.each(request.category, function(id, val) {
tmp += '<option value="'+id+'">'+val+'</option>';
});
sel_obj.empty().append(tmp);
var sel_obj = $("#priority");
var tmp = '<option value="">'+LANG.field_sel_val+'</option>';
$.each(request.priority, function(id, val) {
tmp += '<option value="'+id+'">'+val+'</option>';
});
sel_obj.empty().append(tmp);
$('#new_ticket_send').click(function (){
var elem = [];
var error = false;
elem[0] = $('#category option:selected');
elem[1] = $('#priority option:selected');
elem[2] = $('#them');
elem[3] = $('#message');
$.each(elem, function(id, obj) {
if(obj.val() == '') {
obj.parents('.sepH_c').addClass('error');
error = true;
}else {
obj.parents('.sepH_c').removeClass('error');
}
});
if (!error) {
$.fancybox.close();
Cq.url = PANEL + 'tickets/new/';
Cq.data = 'category='+elem[0].val()+'&priority='+elem[1].val()+'&them='+encodeURIComponent(elem[2].val())+'&message='+encodeURIComponent(elem[3].val());
Cq.request(function(request){
if(request.tickets_stat){
$('#tickets_table').dataTable().fnDestroy();
$('#tickets_table tbody').html('<tr><td colspan="5"></td></tr>');
hendl.tickets_table_init();
}else{
alert('err');
}
});
Cq.init();
}
});
}
});
Cq.init();
}
this.add_ticket = function () {
var Cq = new Cquery(true);
Cq.url = PANEL + 'tickets/add/';
Cq.request(function (request){
if (request.tickets_stat) {
show_form (request.tpl,450,227,false);
$('#ticket_send').click(function (){
var message = $('#message');
if(message.val() == '') {
message.parents('.sepH_c').addClass('error');
}else {
message.parents('.sepH_c').removeClass('error');
$.fancybox.close();
Cq.url = PANEL + 'tickets/add/';
Cq.data = 'message='+encodeURIComponent(message.val());
Cq.request(function(request){
if(request.tickets_stat){
hendl.read_tickets(request.ticket_id);
}else{
alert('err555');
}
});
Cq.init();
}
});
}
});
Cq.init();
}
this.read_tickets = function (ticket_id) {
var Cq = new Cquery(true);
Cq.url = PANEL + 'tickets/read/';
Cq.data = 'ticket_id='+ticket_id;
Cq.request(function (request){
if(request.tickets_stat){
tickets_indicator.set_count(request.head.count_new);
var ticket = '';
var tmp = '';
$.each(request.data, function(key, val){
ticket += '<div class="sepH_b"><div class="dp100"><h5 class="sepH_a">#'+val.noid+(val.reply==0?' User: '+request.head.user:' Support: '+val.reply)+' '+val.created+'</h5><pre>'+val.text+'</pre></div></div>';
});
$('#main_content').html('<div class="formEl_a"><fieldset class="sepH_b"><legend>'+request.head.category+' - '+request.head.them+'</legend>'+ticket+
(request.head.status!=0?'<a class="btn btn_a fr sepV_a" id="close_ticket" type="mod_tickets" ticket_id="'+ticket_id+'">'+LANG.btn_close_ticket+'</a>':'')+
'<a class="btn btn_a fr sepV_a" id="add_ticket" type="mod_tickets">'+LANG.btn_write+'</a></fieldset></div>');
}
});
Cq.init();
}
this.close_ticket = function (ticket_id) {
var Cq = new Cquery(true);
Cq.url = PANEL + 'tickets/close/';
Cq.data = 'ticket_id='+ticket_id;
Cq.request(function(request){
if(request.tickets_stat){
$('#tickets').trigger('click');
}else{
alert('err');
}
});
Cq.init();
}
this.tickets_table_init = function (){
$('#tickets_table').dataTable({
'sPaginationType': 'full_numbers',
'iDisplayLength':10,
'bProcessing': true,
'bServerSide': true,
"bFilter": false,
'sAjaxSource': PANEL+'tickets/tickets_table/',
'sCookiePrefix':'pref_',
'fnServerData': function (sSource,aoData,fnCallback) {
$.ajax({"dataType":'json',"type":"POST","url":sSource,"data":aoData,"success":fnCallback});
},
"fnCookieCallback": function (sName, oData, sExpires, sPath) {
oData.aaSearchCols = [];
oData.abVisCols = [];
oData.sFilter = '';
oData.iStart = 0;
oData.iEnd = 0;
return sName+"="+encodeURIComponent (JSON.stringify(oData))+"; expires=" + sExpires +"; path=" + sPath;
},
'bRetrieve': true,
'bStateSave': true,
'bDestroy':true,
'aaSorting': [[ 0, 'desc' ]],
'oLanguage': {'sUrl': PANEL_HOST+'lib/datatables/lang/'+LANG_NAME+'.lng'},
'aoColumns': [
{'sType': 'string'},
{'bSortable': false},
{'bSortable': false,'sWidth': '25%','fnRender':function(oObj){
return '<a id="read_tickets" ticket="'+oObj.aData[2][0]+'" type="mod_tickets">'+oObj.aData[2][1]+'</a>';
}},
{'sType': 'string','sWidth': '12%','fnRender':function(oObj){
var marker = new Array('ok_bg','alert_bg','error_bg');
return '<span class="notification '+marker[oObj.aData[3][0]]+'">'+oObj.aData[3][1]+'</span>';
}},
{'sType': 'html','fnRender':function(oObj){
var marker = new Array('ok_bg','alert_bg','error_bg','info_bg');
return '<span class="notification '+marker[oObj.aData[4][0]]+'">'+oObj.aData[4][1]+'</span>';
}}
],
});
}
}