Aspx File:
<%-- _lcid="1033" _version="15.0.4420" _dal="1" --%>
<%-- _LocalBinding --%>
<%@ Page language="C#" MasterPageFile="../_catalogs/masterpage/NGO-SMIL_Master/NGO-SMIL_Master.master" meta:progid="SharePoint.WebPartPage.Document" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
NGO Document Library System
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<!--<link rel="stylesheet" type="text/css" href="../SiteAssets/Scripts/bootstrap/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="../SiteAssets/Scripts/bootstrap/bootstrap-select.min.css"/>-->
<script type="text/javascript" src="../SiteAssets/Scripts/jquery.min.js?ver=2.0"></script>
<script src="../SiteAssets/Scripts/jquery-ui.js?ver=2.0" type="text/javascript"></script>
<link href="../SiteAssets/Style/jquery-ui.css?ver=2.0" rel="stylesheet" type="text/css" />
<script src="/_layouts/15/sp.runtime.debug.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.debug.js" type="text/javascript"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script src="/_layouts/15/SP.UI.Dialog.js" type="text/javascript"></script>
<script src="../SiteAssets/Scripts/NGO_SMIL_Main_Report.js?ver=2.0" type="text/javascript"></script>
<script src="../SiteAssets/Scripts/jClocksGMT.js" type="text/javascript"></script>
<script src="../SiteAssets/Scripts/mone_browserinfo_plugin.js" type="text/javascript"></script>
<link href="../SiteAssets/Style/NGO_SMIL.css" type="text/css" rel="stylesheet" />
<meta name="GENERATOR" content="Microsoft SharePoint" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="CollaborationServer" content="SharePoint Team Web Site" />
<style type="text/css">
overflow-y: scroll;
</style>
<style>
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #DA2128;
width: 80px;
height: 80px;
-webkit-animation: spin 2s linear infinite;
animation: spin 4s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(80deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(80deg); }
100% { transform: rotate(360deg); }
}
</style>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server"
ControlId="SmallSearchInputBox"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
<SharePoint:ProjectProperty Property="Description" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<iframe id="txtArea1" style="display:none"></iframe>
<div style="display:none;position:absolute;margin-top: 160px;margin-left: 610px;" class="loader">Please <br> Wait.....</div>
<!--<div class="loading" align="center" style="position:absolute" id="modalSending">
<img style="width: 55px;
margin-top: 250px;
margin-left: 409px;" src="../SiteAssets/loading.gif" />
</div>-->
<div id="CompanyView" style="display:none" class="company-view">
<!--Body Section -->
<div class="body-container">
<div class="body-section">
<div class="body-box">
<!--Heading -->
<h1 style="text-align: center;" id="hd1FolderTitle">NGO
Document Library Report</h1>
<!--Ends Heading -->
<!--Drag Files -->
<!--Ends Drag Files -->
<!--Start Dropdown---!-->
<div style="border-width: 1px; border-style: ridge; border-color: #D1D3D4; " id="resFilter">
<table id="tableFilter" >
<tr>
<td>
<div id="filter">
<div class="controls_title" style="font-weight: bold; font-size: 13px; padding-bottom:5px;">
<span style="margin-right:8px;">Select an Entity :</span><span>
<select style="width: 200px;" id="ddlCompanyName" name="CompanyName">
<option value="Select">--Select--</option>
</select></span></div>
</div>
</td>
<td>
<div id="Year">
<div class="controls_title" style="font-weight: bold; font-size: 13px; padding-bottom:5px;">
<span style="margin-right:8px;">Select a Year :</span><span>
<select style="width: 200px;" id="ddlYear" name="CompanyName">
<option value="2016-2017">2016-2017</option>
<option value="2016-2018">2016-2018</option>
</select></span>
<input type="button" id="btnsubmit" class="btnClass" title="Go" onclick="" name="Go" value="Go">
</div>
</div>
</td>
<td>
<span>Search : </span><input type="text" id="txtSearch" style="width: 350px" />
</td>
<td>
<!--style="background-color: #6d6e71;color: #FFF;padding: .5em .75em;margin-top: -3px;height: 28px;"-->
<input type="button" style="padding: .5em .75em;margin-top: -3px;height: 28px;" id="btnExporttoExcel" class="btnClass" title="Export To Excel" onclick="fnExcelReport()" name="Export To Excel" value="Export To Excel">
</td>
<td> <input id="idprint" style="padding: .5em .75em;margin-top: -3px;height: 28px;" value="Print" class="btnClass" onclick="return PrintDocument('responsiveGrid');" type="button"/>
</td>
</tr>
</table>
</div>
<!-- End Dropdown---!-->
<!--Table -->
<!--<div id="responsiveGrid" class="" style="max-height: 350px; overflow: auto;">-->
<!---- Imp Point Set padding in default.css and style="min-height: 330px;">-->
<div id="responsiveGrid" style="display:none" class="" style="min-height: 345px;" >
<table width="100%" class="table" id="tablepaging" >
<thead>
<tr valign="top">
<th style="border: 1px solid #e6e7e8" width="32" align="left" scope="col"><strong>Sr.No.</strong></th>
<th style="border: 1px solid #e6e7e8" align="left"><strong>Name of NGO<br> Entity</strong></th>
<th style="border: 1px solid #e6e7e8" align="left"><strong> Country</strong></th>
<th style="border: 1px solid #e6e7e8" align="left"><strong>Z-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>A-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>B-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>C-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>D-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>E-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>F-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>G-NGO</strong></th>
<th style="border: 1px solid #e6e7e8" ><strong>H-NGO</strong></th>
</tr>
</thead>
<tbody class="metro-tile metro-tile-small metro-tile-purple" id="tbodycontent">
</tbody>
</table>
</div>
<div id="pageNavPosition" style="padding-top: 1px" align="center">
</div>
</div>
</div>
</div>
<!--Ends Body Section -->
</div>
<asp:HiddenField ID="ipAdrressHiden" runat="server"></asp:HiddenField>
<input type="text" id="lblMessage" title="No Record Found" value="No Record Found" style="display:none;"/>
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e)
{
//HttpContext.Current.Response.Write("hello");
GetUser_IP();
}
protected void GetUser_IP()
{
string ipaddress;
ipaddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
{
ipaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
ipAdrressHiden.Value=ipaddress;
}
</script>
<!--Start Helpdesk Email Section -->
</asp:Content>
JS File :
var NoRecord = "No Record Found";
var vrNewDocumentListGUID = '08C96C6F-AEE0-4BD9-9C89-7305DB0B9FBC';
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct",
"Nov", "Dec"
];
var LibraryNameForUpdate='NGO';
var statusApproved = 'Approved';
var statusRejected = "Rejected";
var statusPending = "Pending";
/************************************************************************************************************************************************/
/******************************Document Ready function******************************************************************************************************************/
// Function to execute when page loads.
$(document).ready(function() {
//Get the watermark in search text box
var watermark = 'Search Item';
$('#txtSearch').blur(function () {
if ($(this).val().length == 0)
$(this).val(watermark).addClass('watermark');
}).focus(function () {
if ($(this).val() == watermark)
$(this).val('').removeClass('watermark');
}).val(watermark).addClass('watermark');
//ExecuteOrDelayUntilScriptLoaded(BindDropDown,'sp.js');
ServerrelativeURL = location.protocol + '//' + location.host;
BrowserUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
updateClock();
init();
BindDropDown();
$('.home_bg').addClass('remove_home_bg');
$('.home_bg').removeClass('home_bg');
$("#CompanyView").css("display", "block");
$("#welcomeContentTiles").css("display", "none");
// Start Search Opration
$("#btnsubmit").click(function ()
{
if($('#ddlCompanyName').val()=='Select')
{
alert('Please select right option!!');
$('#responsiveGrid').hide()
$('.loader').hide();
return false;
}
else
{
$('.loader').show();
getFolderAllDocumentsItems($('#ddlCompanyName').val());
}
});
// End Search Opration
$('#txtSearch').keyup(function () {
SearchGridData();
});
});
//ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
function updateClock() {
var vrDate = new Date();
var count = 0;
$('#clock_digital1').jClocksGMT({
offset: (vrDate.getTimezoneOffset() / 60) * (-1),
digital: true
});
$('#clock_analog1').jClocksGMT({
offset: (vrDate.getTimezoneOffset() / 60) * (-1),
analog: true
});
}
function BindDropDown() {
var glbData = '';
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('NGO/')/Folders/?$filter=Name ne 'Forms'",
type: "Get",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose"
},
data: JSON.stringify({
query: {
__metadata: {
type: "SP.CamlQuery"
},
ViewXml: "<View><Query><Where><Neq><FieldRef Name='FileLeafRef' /><Value Type='File'>Forms</Value></Neq></Where></Query><ViewFields /><QueryOptions /></View>"
}
}),
success: function(data) {
$.each(data.d.results, function(key, value) {
$("#ddlCompanyName").append("<option value=" + value.Name + ">" + value.Name+ "</option>");
});
},
error: function(error) {
alert(JSON.stringify(error));
}
});
/* $("#ddlCompanyName").change(function(){
$('#responsiveGrid').show()
var companyname = this.value;
if(companyname=='Select')
{
alert('Please select right option!!');
$('#responsiveGrid').hide()
return false;
}
else
{
getFolderAllDocumentsItems(companyname)
}
});*/
}
function getFolderAllDocumentsItems(folderName) {
$('.loading').show();
var glbData = '';
var resultGridHtml = '';
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('NGO/" + folderName +" ')/Folders?$orderby=Name&$expand=ListItemAllFields,ListItemAllFields/ParentList",
type: "Get",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose"
},
success: function(data) {
glbData = data;
BindFolderAllDocumentsItems(glbData, folderName);
},
error: function(error) {
alert(JSON.stringify(error));
}
});
}
/************************************************************************************************************************************************/
function BindFolderAllDocumentsItems(data, folderName) {
var resultGridHtml = '';
var vrListGUID = '';
var vrShowIndex = 1;
var vrAuthorId = '';
var vrEditorId = '';
var vrSrNo = 1;
$.each(data.d.results, function(key, value) {
if (value.Name != "Forms") {
var FolderPath=value.ServerRelativeUrl.substring(15) + '/' + $('#ddlYear').val();
var LastFolderName= GetAllFoldersofRootFolders(FolderPath);
var splitLastFolderName=LastFolderName.split('/');
if(splitLastFolderName.length>=9)
{
var Col1=FolderPath+ "/" + splitLastFolderName[0];
var Col2=FolderPath+ "/" + splitLastFolderName[1];
var Col3=FolderPath+ "/" + splitLastFolderName[2];
var Col4=FolderPath+ "/" + splitLastFolderName[3];
var Col5=FolderPath+ "/" + splitLastFolderName[4];
var Col6=FolderPath+ "/" + splitLastFolderName[5];
var Col7=FolderPath+ "/" + splitLastFolderName[6];
var Col8=FolderPath+ "/" + splitLastFolderName[7];
var Col9=FolderPath+ "/" + splitLastFolderName[8];
resultGridHtml += '<tr>';
resultGridHtml += '<td align="center" valign="middle"><span title="Sr.No."><b>' + vrSrNo + '</b></span></td>';
resultGridHtml += '<td valign="middle" folderPath=\'' + value.ServerRelativeUrl.substring(1) + '\' >'+ value.Name +'</td>';
resultGridHtml += '<td valign="middle" >India</td>';
resultGridHtml += '<td id="row'+vrSrNo+'col1" class="FolderName" folderPath=\'' + Col1 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col2" class="FolderName" folderPath=\'' + Col2 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col3" class="FolderName" folderPath=\'' + Col3 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col4" class="FolderName" folderPath=\'' + Col4 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col5" class="FolderName" folderPath=\'' + Col5 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col6" class="FolderName" folderPath=\'' + Col6 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col7" class="FolderName" folderPath=\'' + Col7 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col8" class="FolderName" folderPath=\'' + Col8 + '\' align="center" valign="middle"></td>';
resultGridHtml += '<td id="row'+vrSrNo+'col9" class="FolderName" folderPath=\'' + Col9 + '\' align="center" valign="middle"></td>';
resultGridHtml += '</tr>';
vrSrNo++;
}
}
});
if (resultGridHtml.length == 0) {
var resultGridHtml = '';
resultGridHtml += '<tr>';
resultGridHtml += '<td colspan="12" align="center" valign="middle">' + NoRecord + '</td>';
resultGridHtml += '</tr>';
}
$("#tbodycontent").html(resultGridHtml);
$("#CompanyView").css("display", "block");
$("#welcomeContentTiles").css("display", "none");
$('#responsiveGrid').show()
$('.loader').hide();
// Code For File Count in Folder
$('#tablepaging tr td.FolderName').each(function() {
var path=$(this).attr('folderPath') //Do your work
//var totalCount=GetAllFileCountInParticularFolder(path,this);
GetAllFileCountInParticularFolder(path,this);
})
}
function GetAllFoldersofRootFolders(FolderPath)
{
var lastFoltehrPath="";
//alert(FolderPath);
$.ajax(
{
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('NGO/" + FolderPath +" ')/Folders?$orderby=Name&$expand=ListItemAllFields,ListItemAllFields/ParentList",
method: "GET",
async: false,
headers: {
"ACCEPT": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function (data)
{
$.each(data.d.results, function(){
if(lastFoltehrPath=="")
{
lastFoltehrPath=this.Name;
}
else
{
lastFoltehrPath=lastFoltehrPath + "/" + this.Name;
}
});
},
error: function (data)
{
//alert("Error occured." + data);
}
});
return lastFoltehrPath;
}
/************************************************************Start Getting Approved File count ************************************************************************************/
function GetAllFileCountInParticularFolder(folderName,element)
{ debugger;
var TotalfileCountApprval=0;
var TotalfileCountPending=0;
var dataFlagApprval=true;
var dataFlagPending=true;
var NoRecord=true;
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('NGO/" + folderName + "/')/Files?$orderby=Title&$expand=ListItemAllFields,ListItemAllFields/ParentList", //?$expand=Files",
type: "Get",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose"
},
success: function(dataresult) {
$.each(dataresult.d.results, function(key, value) {
NoRecord=false;
if (value.Name != "Forms")
{
if(value.ListItemAllFields["OData__ModerationStatus"] == 0)
{
dataFlagApprval=false;
TotalfileCountApprval+=1;
}
else if(value.ListItemAllFields["OData__ModerationStatus"] == 2)
{
dataFlagPending=false;
TotalfileCountPending+=1;
}
}
});
if((dataFlagApprval==false)||(dataFlagPending==false))
{
var strApp='<span title="' + statusApproved + '" class="' + statusApproved .toLowerCase() + '-icon"><b>' + statusApproved + '</b></span> <span style="position: absolute;">('+TotalfileCountApprval+')</span> <span title="' + statusPending + '" class="' + statusPending .toLowerCase() + '-icon"><b>' + statusPending + '</b></span> <span style="position: absolute;">('+TotalfileCountPending+')</span>';
$(element).append(strApp);
}
},
error: function(error) {
}
});
if(NoRecord==true)
{
var strApp='<span><b>--</b></span>';
$(element).append(strApp);
}
}
function fnExcelReport()
{
var tab_text="<table border='2px'><tr bgcolor='#D1D3D4'>";
var textRange; var j=0;
tab = document.getElementById('tablepaging'); // id of table
for(j = 0 ; j < tab.rows.length ; j++)
{
tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
//tab_text=tab_text+"</tr>";
}
tab_text=tab_text+"</table>";
tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1.document.open("txt/html","replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
Ram=txtArea1.document.execCommand("SaveAs",true,"NGO_Report.xls");
}
else //other browser not tested on IE 11
Ram= window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
return (Ram);
}
function PrintDocument(divName) {
var printcontents = document.getElementById(divName).innerHTML;
var originablecontents = document.body.innerHTML;
document.body.innerHTML = printcontents;
window.print();
document.body.innerHTML = originablecontents;
}
function SearchGridData() {
var counter = 0;
//Get the search text
var searchText = $('#txtSearch').val().toLowerCase();
//Hide No record found message
$('#lblMessage').hide();
//Hode all the rows of gridview
$('#tablepaging tr:has(td)').hide();
if (searchText.length > 0) {
//Iterate all the td of all rows
$('#tablepaging tr:has(td)').children().each(function () {
var cellTextValue = $(this).text().toLowerCase();
//Check that text is matches or not
if (cellTextValue.indexOf(searchText) >= 0) {
$(this).parent().show();
counter++;
}
});
if (counter == 0) {
//Show No record found message
// alert('No Record Found');
$('#lblMessage').show();
}
}
else {
//Show All the rows of gridview
$('#tablepaging tr:has(td)').show();
}
}
No comments:
Post a Comment