function fnFormatDetails (oTableQuery, nTrQuery, data ) { var aDataQuery = oTableQuery.fnGetData( nTrQuery ); // var rowIndexQuery = parseInt(aDataQuery[1])-1;//get the index of the clicked row from index-column text value - which is 1 based return buildProjectTreeViewChildrenContent(data); } function Active(indicator){ return indicator > 0? 'No':'Yes'; } function loadTree(){ var projectname = sessionStorage.getItem('projectname'); var projectPriority = sessionStorage.getItem('projectpriority'); var status = sessionStorage.getItem('status'); if (projectname!==null || projectPriority !==null || status!==null){ $("#txtSearch").val(projectname.trim()); $("#priorityTxt").val(projectPriority.trim()); $("#statusOpt").val(status.trim()).change(); searchProjects(projectname.trim(),projectPriority.trim(),status.trim()); } else{ getTreeViewProjects(); } } function loadContentData(data){ sessionStorage.setItem('projects', JSON.stringify(data)); var contentBody = document.getElementById("contentBody"); contentBody.innerHTML = buildProjectTreeViewMainContent(data); RunTableBuilder(); } function getTreeViewProjects(){ $.ajax({ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, Accept : "application/json", contentType: "application/json", method: "GET", url: "projects/treeviewprojects", dataType:'json', success: function(data) { loadContentData(data); }, error: function(xhr,err,thrownError){ alert("Error: "+err + "\nResponse Text: "+xhr.responseText + "\nMessage: "+thrownError + "\nready State: "+xhr.readyState + "\nStatus: "+xhr.status); } }); } function buildProjectTreeViewMainContent(data){ var queryTblRows = ''; for(i = 0; i < data.length; i++){ var project = data[i]; if (project.children > 0){ queryTblRows += "
# | ' + 'Major Tasks | ' + 'Team Members | ' + 'Systems | ' + 'Project Progress | '+ 'Status | ' + 'Active | ' + '#Edit | ' + '|
---|---|---|---|---|---|---|---|---|
# | " +""
+""+ project.name +""
+" " +""+ project.createdDate +" by "+ project.createdBy +"" +" | "
+"" + project.resources.length +" | " +"" + project.systems.length var complete = 0; var taskProgress = 0; if(project.systems != null){ for(j = 0; j < project.tasks.length; j++){ var task = project.tasks[j]; if(task.status === 2){ complete = complete +1; } } } if(project.tasks != null && project.tasks.length > 0){ taskProgress = (complete)/(project.tasks.length)*100; }else{ taskProgress = 0; } //queryTblRows += "" queryTblRows+=" | " +""
+" "
+""
+" "
+""+ taskProgress +"% Complete"
+" | "
+""; var btnStatus = ''; var status = ''; switch(taskProgress){ case 0: btnStatus="danger"; status="Not Started"; break; case 100: btnStatus="success"; status="Complete"; break; default: btnStatus="warning"; status="In Progress"; } queryTblRows += "" +" | " +"" + Active(project.deactivate) +" | "; if (project.deactivate > 0){ queryTblRows += "" +" Activate " +" | "; } else{ queryTblRows += "" +" Deactivate " +" | "; } queryTblRows += "