File: /home/imensosw/www/imenso.co/matrix/js/admin_common.js
var app= {};
app.document={docId:"", rowId:"", assignment_no:"", searchText:""};
// app.location = window.location.origin+"/matrix/admin/";
app.location = window.location.origin+"/matrix/admin/";
if(window.location.hostname=="sh018.hostgator.tempwebhost.net")
{
app.location = "http://sh018.hostgator.tempwebhost.net/~a16102wt/matrix/admin/";
}
app.sortData = {column_name:"",order:"",action:"",table_id:"",searchText:""};
$(document).ready(function(){
app.getData();
});
$(document).on('click', '#row_link', function(){
app.document.assignment_no = location.search.split('assignment_no=')[1];
if(app.document.assignment_no)
{
$('#admin_tabs').hide();
}
app.document.docId = $(this).attr('data-doc_id');
app.document.rowId = $(this).attr('data-row_id');
app.clickToDocId();
});
// Sorting for New Assignment
$(document).on('click', '.column_sort_new', function(){
app.sortData.column_name = $(this).attr('id');
app.sortData.order = $(this).data('order');
app.sortData.action = "new_assignment_table_sort";
app.sortData.table_id = "new_assignment_table";
app.getSortTable();
});
// Sorting for Assign to
$(document).on('click', '.column_sort_assign', function(){
app.sortData.column_name = $(this).attr('id');
app.sortData.order = $(this).data('order');
app.sortData.action = "assignment_to_table_sort";
app.sortData.table_id = "assignment_to_table";
app.getSortTable();
});
// Sorting for Assignment Completed
$(document).on('click', '.column_sort_complete', function(){
app.sortData.column_name = $(this).attr('id');
app.sortData.order = $(this).data('order');
app.sortData.action = "assignment_complete_table_sort";
app.sortData.table_id = "assignment_complete_table";
app.getSortTable();
});
// Sorting for Assignment Completed
$(document).on('click', '.column_sort_delete', function(){
app.sortData.column_name = $(this).attr('id');
app.sortData.order = $(this).data('order');
app.sortData.action = "assignment_delete_table_sort";
app.sortData.table_id = "assignment_delete_table";
app.getSortTable();
});
$(document).on('keyup', '#search', function(){
app.sortData.searchText = $(this).val();
if($(this).hasClass('assignment_to'))
{
app.sortData.action = "assignment_to_table_sort";
app.sortData.table_id = "assignment_to_table";
}
else if($(this).hasClass('assignment_complete'))
{
app.sortData.action = "assignment_complete_table_sort";
app.sortData.table_id = "assignment_complete_table";
}
else if($(this).hasClass('assignment_new'))
{
app.sortData.action = "new_assignment_table_sort";
app.sortData.table_id = "new_assignment_table";
}
else if($(this).hasClass('assignment_delete'))
{
app.sortData.action = "assignment_delete_table_sort";
app.sortData.table_id = "assignment_delete_table";
}
app.getSortTable();
});
app.getSortTable = function()
{
app.formData ={
searchText:app.sortData.searchText,
sortorder:app.sortData.order,
sortby:app.sortData.column_name,
action:app.sortData.action,
};
var arrow = "";
if(app.sortData.order=="desc")
{
arrow = ' <span class="glyphicon glyphicon-arrow-down"></span>';
}
else
{
arrow = ' <span class="glyphicon glyphicon-arrow-up"></span>';
}
$.ajax({
url:app.location+"sort.php",
method:"POST",
datatype:"html",
data:{formData:app.formData},
success:function(data)
{
$('#'+app.sortData.table_id).html(data);
//$('#'+app.sortData.column_name+'').append(arrow);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}
app.getData = function(){
if ($('ul.list-group > li').hasClass('done')) {
if(length>0)
{
$('ul.list-group > li.done:first>a').trigger('click');
$('ul.list-group > li.done:first').addClass('active');
}
}
}
app.clickToDocId = function(){
$("#row_iframe").attr("src","../docs/"+app.document.assignment_no+"/"+app.document.docId+".pdf");
$("#rowId").val(app.document.rowId);
$("#docId").val(app.document.docId);
$('ul.list-group > li.active').removeClass('active');
$('ul').find('[data-doc_id="'+app.document.docId+'"]').closest('li').addClass('active');
}