$(document).ready(function()
{
getRG1();
getRG2();
$('#ddRedirect').change(function() {
window.location = $(this).val();
});
$('#treeui').tree({
checkbox: true,
url: 'https://cis.sbmoffshore.com/sites/XBS/SiteAssets/XBS/pages/tree_data1.dat',
onClick: function(node)
{
alert("click" + node.text);
},
onDblClick: function(node) {
alert("dbclick" + node.text);
},
onCheck: function(node) {
alert("check" + node.text);
}
});
$('#treePBS').tree(
{
checkbox: true,
url: 'https://cis.sbmoffshore.com/sites/XBS/SiteAssets/XBS/pages/tree_data1.dat',
onClick: function(node)
{
if(node.text !='PRODUCT')
{
addTab(node.text, "http://www.google.co.uk");
}
},
// onDblClick: function(node)
// {
// alert("dbclick" + node.text);
// },
// onCheck: function(node)
// {
// alert("check" + node.text);
// }
});
});
function showcontent(language)
{
addTab(language, 'http://www.w3.org/');
}
function addTab(title, url)
{
if ($('#tt').tabs('exists', title))
{
$('#tt').tabs('select', title);
}
else
{
//var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
var content = document.getElementById("dg");
$('#tt').tabs('add', {
title:title,
content:content,
closable: true
});
}
}
function getRG1(){
$.ajax({
async: true,
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ResourceGroupStructure')/items",
method: "GET",
headers:{
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data)
{
data = data.d.results;
console.log(data);
$.each(data,function(index,value)
{
var html = "<tr><td>"+ value.Title +"</td><td>"+value.Label+"</td><td>"+value.Code2+"</td><td>"+value.Label3+"</td><td>"+value.Code4+"</td><td>"+value.Label5+"</td><td>"+value.Code6+"</td><td>"+value.Definition+"</td><td>"+value.Code7+"</td><td>"+value.Definition8+"</td></tr>";
$('#StructureList tbody').append(html);
});
// Setup - add a text input to each header cell
$('#StructureList thead th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
// DataTable
var table = $('#StructureList').DataTable({
dom: 'Blfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
initComplete: function () {
// Apply the search
this.api().columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
}
});
},
error: function(error){
console.log(JSON.stringify(error));
}
})
}
function getDC2(){
$.ajax({
async: true,
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('SBM_DocumentClassLevel2')/items",
method: "GET",
headers:{
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data)
{
data = data.d.results;
console.log(data);
$.each(data,function(index,value)
{
var html = "<tr><td>"+ value.Title +"</td><td>"
+ value.Document_x0020_Class_x0020_Level+"</td><td>"
+ value.Name1+"</td><td>"
+ value.Description+"</td><td>"
+ value.CDR_x0020__x002d__x0020_Code+"</td><td>"
+ value.CFIHOS_x0020__x002d__x0020_ID+"</td><td>"
+ value.Confidentiality_x0020_Rating_x00+"</td><td>"
+ value.Process_x0020_Safety_x0020_Dossi+"</td><td>"
+ value.As_x002d_built_x0020_Category_x0+"</td><td>"
+ value.Retention_x0020_Time_x0020__x002+"</td><td>"
+ value.Client_x0020_Review_x0020__x002d+"</td><td>"
+ value.Classification_x0020_Review_x002+"</td><td>"
+ value.Gate_x0020_Approved_x0020_Docume+"</td><td>"
+ value.Nb_x0020_Weeks_x0020_Before_x002+"</td><td>"
+ value.VDB_x0020_Destination_x0020__x00+"</td><td>"
+ value.Paper_x0020_Copy_x0020_Required_+"</td></tr>";
$('#DC2List tbody').append(html);
});
// Setup - add a text input to each header cell
$('#DC2List thead th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
// DataTable
var table = $('#DC2List').DataTable({
dom: 'Blfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
initComplete: function () {
// Apply the search
this.api().columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
}
});
},
error: function(error){
console.log(JSON.stringify(error));
}
})
}
function edit(value){
$.ajax({
async: true,
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Employee')/GetItemByID("+value+")",
method: "GET",
headers:{
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data){
console.log(data.d.EmployeeName);
eName = $('#txtempnames').val(data.d.EmployeeName);
eDesg = $('#txtdesignations').val(data.d.Designation);
eEmail= $('#txtemails').val(data.d.Email);
eMobile = $('#txtmobiles').val(data.d.Mobile);
eBloodGroup = $('#txtbloodgrps').val(data.d.BloodGroup);
eComAddress = $('#txtaddresss').val(data.d.CommunicationAddress);
eEmergency = $('#txtemergencys').val(data.d.EmergencyContact);
},
error: function(error){
console.log(JSON.stringify(error));
}
})
uId = value;
}
function update(uId){
var eName = $('#txtempnames').val();
var eDesg = $('#txtdesignations').val();
var eEmail= $('#txtemails').val();
var eMobile = $('#txtmobiles').val();
var eBloodGroup = $('#txtbloodgrps').val();
var eComAddress = $('#txtaddresss').val();
var eEmergency = $('#txtemergencys').val();
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Employee')/items("+ uId +")",
method: "POST",
data: JSON.stringify({
'__metadata':{'type': 'SP.Data.EmployeeListItem'},
'EmployeeName' : eName,
'Designation': eDesg,
'Email': eEmail,
'Mobile': eMobile,
'BloodGroup': eBloodGroup,
'CommunicationAddress': eComAddress,
'EmergencyContact': eEmergency
}),
headers:{
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method":"MERGE"
},
success: function(data){
swal( "Item Updated successfully", "success");
if ($.fn.DataTable.isDataTable('#subsiteList')) {
$('#subsiteList').DataTable().destroy();
}
$('#subsiteList tbody').empty();
getItems();
},
error: function(error){
console.log(JSON.stringify(error));
}
})
}
function deleteItem(value){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Employee')/items("+ value +")",
method: "POST",
headers:{
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method":"DELETE"
},
success: function(data){
swal("Deleted!", "Item Deleted successfully", "success");
if ($.fn.DataTable.isDataTable('#subsiteList')) {
$('#subsiteList').DataTable().destroy();
}
$('#subsiteList tbody').empty();
getItems();
},
error: function(error){
console.log(JSON.stringify(error));
}
})
}
Comments