You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
233 lines
11 KiB
233 lines
11 KiB
var no_show = (function ($, window, jQuery) {
|
|
var _vars_ = {};
|
|
|
|
return {
|
|
set_vars: function (options) {
|
|
$.extend(_vars_, options || {});
|
|
},
|
|
get_vars : function(){
|
|
return _vars_;
|
|
},
|
|
message_reamining_seats : function(ev,event_schedule_id)
|
|
{
|
|
Helper.help.ajax( app.get_vars().baseurl+"check_remaining_seats/"+event_schedule_id, 'post' ,
|
|
false, function(result){
|
|
app.modal.confirm_box({
|
|
"message" : result.message,
|
|
"_continue" : function() {
|
|
no_show.export_no_show_list(ev,event_schedule_id)
|
|
},
|
|
"id" : "save_confirm_box",
|
|
"className" : "save_confirm_box"
|
|
});
|
|
});
|
|
},
|
|
export_no_show_list : function(ev,event_schedule_id)
|
|
{
|
|
var event = $(ev);
|
|
window.location = app.get_vars().baseurl+"export_noshow/"+event_schedule_id;
|
|
},
|
|
import_no_show_list : function()
|
|
{
|
|
if (typeof FormData !== 'undefined') {
|
|
var eventfiles = document.getElementById("upload_noshow");
|
|
if(eventfiles.files.length >0){
|
|
var file = (eventfiles.files[0].name).split(".");
|
|
|
|
if(file[file.length-1] != "" && (file[file.length-1]=="xlsx" || file[file.length-1] == "xls")) {
|
|
|
|
app.modal.confirm_box({
|
|
"message" : "Êtes-vous sûr de vouloir importer ce fichier?<br/><br><span class='label label-danger' style='font-size: 12px;'>"+app.get_vars()._app.cma_msg.note+"</span>",
|
|
"_continue" : function() {
|
|
var formData = new FormData( $("#form_upload_excel")[0] );
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"import_noshow",
|
|
type : "post",
|
|
data : formData,
|
|
async : false,
|
|
cache : false,
|
|
contentType : false,
|
|
processData : false,
|
|
success: function( result, textStatus, jQxhr )
|
|
{
|
|
if(result.subscribers){
|
|
$("#modal_warnings").modal("show");
|
|
$.each(result.subscribers,function(i,v){
|
|
$(".subscribers_failed").append("<ul><li>"+v+"</li><ul>")
|
|
})
|
|
|
|
$("#modal_warnings").on('hidden.bs.modal', function () {
|
|
$(".subscribers_failed").empty()
|
|
});
|
|
|
|
}
|
|
|
|
if( result.message)
|
|
app._notify(result.mtype, result.message);
|
|
|
|
no_show.get_vars().no_show_table.ajax.reload(null, false);
|
|
|
|
// if( result.mtype =='success' || result.mytpe == "error")
|
|
// {
|
|
// $("#modal_upload_excel").modal('hide')
|
|
// // $("#upload_noshow").val('')
|
|
// }
|
|
// else if( result.error_import == 'true' )
|
|
// {
|
|
$("#upload_noshow").val('')
|
|
$("#modal_upload_excel").modal('hide')
|
|
//}
|
|
|
|
},
|
|
error: function( jqXhr, textStatus, errorThrown )
|
|
{
|
|
console.log( errorThrown );
|
|
}
|
|
});
|
|
},
|
|
"id" : "delete_confirm_box",
|
|
"className" : "delete_confirm_box"
|
|
});
|
|
} else {
|
|
app._notify("warning", "Invalid file format!");
|
|
}
|
|
} else {
|
|
app._notify("warning", "Please select a file to import!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
console.log("Your Browser Don't support FormData API! Use IE 10 or Above");
|
|
}
|
|
},
|
|
show_modal_import : function(e)
|
|
{
|
|
$("#modal_upload_excel").modal("show");
|
|
$("#button_import").off("click").on("click", function(){
|
|
no_show.import_no_show_list();
|
|
})
|
|
},
|
|
update :function(e)
|
|
{
|
|
app.modal.confirm_box({
|
|
"message" : "Are you sure you want to update records?<br/><br><span class='label label-danger' style='font-size: 12px;'>"+app.get_vars()._app.cma_msg.note+"</span>",
|
|
"_continue" : function() {
|
|
Helper.help.ajax( app.get_vars().baseurl+"post_no_show_list/"+event_schedule_id, 'post' ,
|
|
$("form#no_show_form").serialize() , function(result){
|
|
app._notify(result.mtype, result.message);
|
|
if( result.mtype =='success') {
|
|
no_show.get_vars().no_show_table.ajax.reload(null, false);
|
|
}
|
|
if( typeof result._input != "undefined"){
|
|
if(result._input.length > 0){
|
|
$(result._input).focus().select();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
"id" : "delete_confirm_box",
|
|
"className" : "delete_confirm_box"
|
|
});
|
|
},
|
|
load : function(){
|
|
var table = $('#no_show_list').DataTable({
|
|
"responsive": true,
|
|
"processing": true,
|
|
"serverSide": true,
|
|
"bFilter": false,
|
|
"order": [1], //Initial no order.
|
|
"oLanguage": fr_onload_lang.oLanguage,
|
|
"ajax": {
|
|
"url": app.get_vars().baseurl+"get_no_show_list/"+event_schedule_id+"/1",
|
|
"type": "POST"
|
|
},
|
|
"columns": [
|
|
{ "data": "no", orderable : false},
|
|
// { "data": "event_name" },
|
|
// { "data" : "reservation_date"},
|
|
{ "data": "users_name" },
|
|
{ "data": "type" },
|
|
{ "data": "no_of_place"},
|
|
{ "data": "no_show_type", orderable : false, render : function(data, type, full, meta){
|
|
var chk , no_show_type;
|
|
|
|
no_show_type = ( full.no_show_type !== null ) ? full.no_show_type : 0;
|
|
|
|
var textarea = "<input style='width:50px;' type='text' id="+full.registration_id+" class='noshow_chk' name='isattended_"+full.registration_id+"_"+full.type+"' value="+no_show_type+">"
|
|
return '<div class="row-fluid"><div class="span4 offset4 text-center">'+textarea+'</div></div>';
|
|
}},
|
|
{ "data": "comment", orderable : false, render : function(data, type, full, meta){
|
|
|
|
var comment;
|
|
|
|
if( full.comment == null){
|
|
comment = '';
|
|
}else{
|
|
comment = full.comment;
|
|
}
|
|
|
|
var textarea = "<textarea class='no_show_comment' name ='notes_"+full.registration_id+"_"+full.type+"'>"+comment+"</textarea>"
|
|
return '<div class="row-fluid"><div class="span4 offset4 text-center">'+textarea+'</div></div>';
|
|
}}
|
|
],
|
|
"fnDrawCallback" : function(){
|
|
var count_data = $('#no_show_list').DataTable().data().count();
|
|
console.log(count_data);
|
|
if(count_data > 0){
|
|
$("#no_show_upload_button").attr("disabled", false).off('click').on('click', function(e){no_show.update(e);});
|
|
} else {
|
|
$("#no_show_upload_button").attr("disabled", true).off('click');
|
|
}
|
|
},
|
|
"initComplete": function(settings, json) {
|
|
|
|
//add custom button beside searchbox
|
|
$("select[name='no_show_list_length']").css({"padding" : "0"});
|
|
|
|
// $("#no_show_list_").append('<a href="javascript:;" onclick="no_show.show_modal_import(event)"; style="padding: 7px;" ' +
|
|
// 'class="btn btn-primary btn-sm mr-xs">'+
|
|
// '<span class="glyphicon glyphicon-import"></span> Import</a><a onclick="no_show.message_reamining_seats(this,'+event_schedule_id+')" style="padding: 7px;" ' +
|
|
// 'class="btn btn-primary btn-sm mr-xs">'+
|
|
// '<span class="glyphicon glyphicon-export"></span> Export</a>');
|
|
|
|
$("input.noshow_chk").off("change").on("change", function(){
|
|
$this = $(this);
|
|
|
|
if( !$.isNumeric($this.val()) ) {
|
|
$this.val(0) ;
|
|
}
|
|
});
|
|
//fire search filter event
|
|
//app.grid.search_filter("subscribers_list", subscribers_list.get_vars().subscribers);
|
|
|
|
// totalRecords = table.page.info().recordsTotal;
|
|
// (totalRecords === 0)? $("a#no_show_upload_button").attr("disabled",true).removeAttr('onclick') : "";
|
|
|
|
}
|
|
});
|
|
|
|
no_show.set_vars({no_show_table : table});
|
|
|
|
|
|
|
|
},
|
|
select_no_show_table :function()
|
|
{
|
|
$("select.noshow_status").off("change").on("change", function() {
|
|
var type = $(this).val();
|
|
$('#no_show_list').DataTable().ajax.url(app.get_vars().baseurl+"get_no_show_list/"+event_schedule_id+"/"+type);
|
|
$('#no_show_list').DataTable().ajax.reload(null, false);
|
|
Helper.dtable.console_alert("#no_show_list", function(err){
|
|
console.log(err);
|
|
});
|
|
});
|
|
},
|
|
|
|
};//end of return
|
|
// Pass in jQuery.
|
|
})(jQuery, this);
|
|
|
|
$(function() {
|
|
no_show.load();
|
|
no_show.select_no_show_table();
|
|
});
|
|
|