<?php include("includes/head.php");?>
<link rel="stylesheet" href="scripts/amcharts4/charts.css" />
<script src="scripts/amcharts4/core.js"></script>
<script src="scripts/amcharts4/charts.js"></script>
<script src="scripts/amcharts4/themes/animated.js"></script>
<script src="scripts/amcharts4/plugins/forceDirected.js"></script>
<style>
/*search box css start here*/
.search-sec {
	background: #1A4668;
	padding: 2rem;
}
.search-slt {
	display: block;
	width: 100%;
	font-size: 0.875rem;
	line-height: 1.5;
	color: #55595c;
	background-color: #fff;
	background-image: none;
	border: 1px solid #ccc;
	height: calc(3rem + 2px) !important;
	border-radius:0;
}
.wrn-btn {
	width: 100%;
	font-size: 14px;
	font-weight: 400;
	text-transform: capitalize;
	height: calc(3rem + 2px) !important;
	border-radius:0;
}
</style>
<?php 
$searchedQuery = "";
$searchedDept = "";
$searchedDeptFile = "";

if(!empty($_POST['searching']))
{
	if(!empty($_POST['department_id']) && !empty($_POST['file_id']))
	{
		$depts = $_POST['department_id'];
		$files = $_POST['file_id'];
		
		//--------------------------------
		$selQry_depts_src = "SELECT * FROM ".TBL_DEPARTMENTS." WHERE id='$depts'";
		$deptsSrcInfo =  $con->getSingleRow($selQry_depts_src, __FILE__,__LINE__);
		
		$selQry_files_src = "SELECT * FROM ".TBL_FILES." WHERE id='$files'";
		$filesSrcInfo =  $con->getSingleRow($selQry_files_src, __FILE__,__LINE__);
		
		$searchedDept = $deptsSrcInfo["name"];
		$searchedDeptFile = $filesSrcInfo["name"];
		//--------------------------------
		
		$searchedQuery = " AND sh_stakeholders_depts_files.dept_id IN(".$depts.") AND sh_stakeholders_depts_files.file_id IN(".$files.")";
	}
	elseif(!empty($_POST['department_id']))
	{
		$depts = $_POST['department_id'];
		$searchedQuery = " AND sh_stakeholders_depts_files.dept_id IN(".$depts.") ";
		
		//--------------------------------
		$selQry_depts_src = "SELECT * FROM ".TBL_DEPARTMENTS." WHERE id='$depts'";
		$deptsSrcInfo =  $con->getSingleRow($selQry_depts_src, __FILE__,__LINE__);
		
		$searchedDept = $deptsSrcInfo["name"];
		//--------------------------------
	}
}
//echo $searchedQuery;
?>
<body>
<!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
<!-- Header top area start-->
<?php include("includes/header.php");?>
<!-- Header top area end-->
<!-- Menu area start-->
<?php include("includes/navigation.php");?>
<!-- Menu area end-->
<!-- Data table area Start-->
<div class="admin-dashone-data-table-area mg-b-40" style="min-height:800px;">
  <div class="tab-content view-mail-ov-mg-t-100" style="width:98%; margin-left:10px; margin-right:10px;">
    <div class="tab-pane fade in zoomInDown shadow-reset active">
      <div class="sparkline12-list shadow-reset">
        <div class="sparkline8-hd">
          <h1>Stakeholders</h1>
          <div class="sparkline8-outline-icon" style="position:relative !important; text-align:right;">
            <?php if(isset($_GET['mode']) && $_GET['mode']=='Edit'){?>
            <!--<button class="btn btn-sm btn-success login-submit-cs" type="button" onClick="javascript: addCategory();">Add New Category</button>
            <a href="sh-overview.php">
            <button class="btn btn-sm btn-primary login-submit-cs" type="button" title="Click to Remove Edit Mode">Remove Edit Mode</button>
            </a>&nbsp;-->
            <?php }else{?>
            <!-- <a href="sh-overview.php?mode=Edit">
            <button class="btn btn-sm btn-success login-submit-cs" type="button" title="Click to show Edit Mode">Edit Mode</button>
            </a>&nbsp;-->
            <?php }?>
            <!--<a href="sh-overview.php?mode=Priority">
            <button class="btn btn-sm btn-primary login-submit-cs" type="button">View Priority Stakeholders</button>
            </a>&nbsp;-->
            <a href="dashboard.php">
            <button class="btn btn-sm btn-danger login-submit-cs" type="button">Back to Dashboard</button>
            </a>&nbsp; </div>
        </div>
        <div class="sparkline8-graph" style="height:1800px !important;">
          <div class="containersss bootstrap snippet">
            <div class="row">
              <div id="searchFilter">
                <section class="search-sec">
                  <div class="container">
                    <form action="#" method="post" novalidate="novalidate">
                      <input type="hidden" name="searching" value="Y">
                      <div class="row">
                        <div class="col-lg-12">
                          <div class="row">
                            <?php if(isset($_GET['mode']) && $_GET['mode']=='Edit'){?>
                            <div class="col-lg-2 col-md-3 col-sm-12 p-0">
                              <select class="form-control search-slt" name="department_id" id="department_id">
                                <option value="">Select Departments</option>
                                <?php 
								  //--------------- Category Info ----------
								  $srno = 0;
								  								  
								  if($_SESSION['userGroupID']==1 or $_SESSION['userGroupID']==2){								  
								    $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." ORDER BY name";
								  }else{
								      $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." where status='1' and id IN(".$userDeptAccess.") ORDER BY name";
								  }
								  //$deptsInfo =  $con->getMultiRow($selQry_depts, __FILE__,__LINE__);
								  $totDeptsListings = count($deptsInfo);
									if($totDeptsListings>0)
									{
										for($dept=0;$dept<$totDeptsListings;$dept++)
										{
											$srno++;
								  //----------------------------------------
								?>
                                <option value="<?php echo $deptsInfo[$dept]['id'];?>" <?php if(!empty($_POST['department_id']) && $_POST['department_id']==$deptsInfo[$dept]['id']){?>selected <?php }?>><?php echo $deptsInfo[$dept]['name'];?></option>
                                <?php }
								}?>
                              </select>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-12 p-0">
                              <select class="form-control search-slt" name="file_id" id="file_id">
                                <option value="">Select Files</option>
                              </select>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0">
                              <button type="submit" class="btn btn-primary wrn-btn">Search</button>
                            </div>
                            <?php if(isset($_GET['mode']) && $_GET['mode']=='Priority'){?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php">
                              <button type="button" class="btn btn-warning wrn-btn" >Clear Priority Filter</button>
                              </a> </div>
                            <?php }else{?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php?mode=Priority">
                              <button type="button" class="btn btn-primary wrn-btn" >Priority Stakeholders</button>
                              </a> </div>
                            <?php }?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0">
                              <button class="btn btn-success wrn-btn" type="button" onClick="javascript: addCategory();">Add Category</button>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php">
                              <button type="button" class="btn btn-primary wrn-btn">Remove Edit Mode</button>
                              </a> </div>
                            <?php }else{?>
                            <div class="col-lg-3 col-md-3 col-sm-12 p-0">
                              <select class="form-control search-slt" name="department_id" id="department_id">
                                <option value="">Select Departments</option>
                                <?php 
								  //--------------- Category Info ----------
								  $srno = 0;
								  								  
								  if($_SESSION['userGroupID']==1 or $_SESSION['userGroupID']==2){								  
								    $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." ORDER BY name";
								  }else{
								      $selQry_depts = "SELECT * FROM ".TBL_DEPARTMENTS." where status='1' and id IN(".$userDeptAccess.") ORDER BY name";
								  }
								  $deptsInfo =  $con->getMultiRow($selQry_depts, __FILE__,__LINE__);
								  $totDeptsListings = count($deptsInfo);
									if($totDeptsListings>0)
									{
										for($dept=0;$dept<$totDeptsListings;$dept++)
										{
											$srno++;
								  //----------------------------------------
								?>
                                <option value="<?php echo $deptsInfo[$dept]['id'];?>" <?php if(!empty($_POST['department_id']) && $_POST['department_id']==$deptsInfo[$dept]['id']){?>selected <?php }?>><?php echo $deptsInfo[$dept]['name'];?></option>
                                <?php }
								}?>
                              </select>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-12 p-0">
                              <select class="form-control search-slt" name="file_id" id="file_id">
                                <option value="">Select Files</option>
                              </select>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0">
                              <button type="submit" class="btn btn-primary wrn-btn">Search</button>
                            </div>
                            <?php if(isset($_GET['mode']) && $_GET['mode']=='Priority'){?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php">
                              <button type="button" class="btn btn-warning wrn-btn" >Clear Priority Filter</button>
                              </a> </div>
                            <?php }else{?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php?mode=Priority">
                              <button type="button" class="btn btn-primary wrn-btn" >Priority Stakeholders</button>
                              </a> </div>
                            <?php }?>
                            <div class="col-lg-2 col-md-2 col-sm-12 p-0"> <a href="sh-overview.php?mode=Edit">
                              <button type="button" class="btn btn-primary wrn-btn">Edit Mode</button>
                              </a> </div>
                            <?php }?>
                          </div>
                        </div>
                      </div>
                    </form>
                  </div>
                </section>
              </div>
            </div>
            <div class="row">
              <div style="text-align:left; margin-left:50px;">
                <ul>
                  <li type="circle" style="color:#FF0000;font-size: 1.2em;">Resistant</li>
                  <li type="circle" style="color:#FF9933;font-size: 1.2em;">Neutral</li>
                  <li type="circle" style="color:#00FF00;font-size: 1.2em;">Supportive</li>
                </ul>
              </div>
              <div style="text-align:center;">
                <h1><?php echo !empty($orgsInfo['name'])?$orgsInfo['name']:'';?>&nbsp;<?php echo !empty($searchedDept)?" - ".$searchedDept:'';?>&nbsp;<?php echo !empty($searchedDeptFile)?" - ".$searchedDeptFile:'';?>
                <?php if(!empty($_GET['mode']) && $_GET['mode']=='Priority'){echo " - Priority Stakeholders";}?>
                </h1>
              </div>
              <div id="chartdiv"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
<!-- Data table area End-->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <!--<div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title"></h4>
            </div>-->
      <div class="modal-body"> </div>
      <div class="modal-footer">
        <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="myModal" role="dialog" style="width: 1100px !important; left: 33% !important;">
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update Category Color</h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
      </div>
    </div>
  </div>
</div>
<!-- Footer Start-->
<?php include("includes/footer.php");?>
<!-- Footer End-->
<script>
am4core.useTheme(am4themes_animated);

var chart = am4core.create("chartdiv", am4plugins_forceDirected.ForceDirectedTree);
var networkSeries = chart.series.push(new am4plugins_forceDirected.ForceDirectedSeries());
var nodesTemplate = networkSeries.nodes.template;

//chart.legend = new am4charts.Legend();

<?php if(isset($_GET['mode']) && $_GET['mode']=='Edit'){?>
chart.dataSource.url = "get-chart-data.php";
chart.dataSource.parser = new am4core.JSONParser();
//chart.dataSource.parser.options.emptyAs = 0;
<?php }elseif(isset($_GET['mode']) && $_GET['mode']=='Priority'){?>
chart.data = [
  {
    name: "",
	id: "",	
	value: "5000",
	title:"Click to expand!",
	x: am4core.percent(50),
    y: am4core.percent(50),
	image: "<?php echo isset($orgsInfo['logo'])?"uploads/organizations/".$orgsInfo['logo']:'';?>",
    fixed: true,
	//color: "green",
	off: true,
    children: [
	<?php 
	  //--------------- Category Info ----------
	  $category_counter = 0;
	  $selQry_cat = "SELECT * FROM ".TBL_CATEGORIES." WHERE status='1' ORDER BY category_title";
	  $catInfo =  $con->getMultiRow($selQry_cat, __FILE__,__LINE__);
	  $totSHCatListings = count($catInfo);
		if($totSHCatListings>0)
		{
			for($shcat=0;$shcat<$totSHCatListings;$shcat++){
				$category_counter++;
				//----------------------------------------
				$selQry_sh = "SELECT * FROM ".TBL_STAKEHOLDERS." WHERE category_id='".$catInfo[$shcat]['category_id']."' AND status='1' AND is_high_priority='1' $searchedQuery ORDER BY name";
				/*$selQry_sh = "SELECT DISTINCT(".TBL_STAKEHOLDERS.".id),".TBL_STAKEHOLDERS.".* FROM ".TBL_STAKEHOLDERS." 
				INNER JOIN ".TBL_STAKEHOLDERS_DEPTS_FILES." ON (".TBL_STAKEHOLDERS.".id = ".TBL_STAKEHOLDERS_DEPTS_FILES.".stakerholder_id)
				WHERE ".TBL_STAKEHOLDERS.".category_id='".$catInfo[$shcat]['category_id']."' AND ".TBL_STAKEHOLDERS.".STATUS='1' AND ".TBL_STAKEHOLDERS.".is_high_priority='1'
				$searchedQuery ORDER BY ".TBL_STAKEHOLDERS.".name;";*/
				$shInfo =  $con->getMultiRow($selQry_sh, __FILE__,__LINE__);
				$totSHListings = count($shInfo);
				//----------------------------------------  
	?>
      {
        name: "<?php echo $catInfo[$shcat]['category_title'];?>",
		value: "<?php echo isset($catInfo[$shcat]['category_influence'])?$catInfo[$shcat]['category_influence']:'500';?>",
		id: "<?php echo $catInfo[$shcat]['category_id'];?>",
		title:"<?php echo $catInfo[$shcat]['category_title'];?> (<?php echo $totSHListings;?>)",
		off: true,
		type: "Cat",
		color:"<?php echo !empty($catInfo[$shcat]['category_orientation'])?$catInfo[$shcat]['category_orientation']:'#a9b7af';?>",
		<?php if( $totSHListings>0 ){}else{?>
		togglable: false,
		<?php }?>
        children: [
		  <?php
			$shsrno = 0;
			if($totSHListings>0)
			{
				for($shh=0;$shh<$totSHListings;$shh++){ 
					$shsrno++;
		  ?>
		  	{ name: "<?php echo $shInfo[$shh]['abbreviation'];?>",id:"<?php echo $shInfo[$shh]['id'];?>",title:"<?php echo $shInfo[$shh]['name'];?>", type: "SH", value: "<?php echo $totSHListings;?>",url: "sh-card.php?sid=<?php echo $shInfo[$shh]['id'];?>",color:"<?php echo !empty($shInfo[$shh]['sh_current_orientation'])?$shInfo[$shh]['sh_current_orientation']:'#a9b7af';?>"},
		  <?php }
		  }else{?>
		  	{ name: "",title:"", value: ""}
		  <?php }?>
		]
      },
	  <?php }
	  }?>
    ]
  }
];
<?php }else{?>
chart.data = [
  {
    name: "",
	id: "",	
	value: "5000",
	title:"Click to expand!",
	x: am4core.percent(50),
    y: am4core.percent(50),
	image: "<?php echo isset($orgsInfo['logo'])?"uploads/organizations/".$orgsInfo['logo']:'';?>",
    fixed: true,
	//color: "green",
	off: true,
    children: [
	<?php 
	  //--------------- Category Info ----------
	  $category_counter = 0;
	  $selQry_cat = "SELECT * FROM ".TBL_CATEGORIES." WHERE status='1' ORDER BY category_title";
	  $catInfo =  $con->getMultiRow($selQry_cat, __FILE__,__LINE__);
	  $totSHCatListings = count($catInfo);
		if($totSHCatListings>0)
		{
			for($shcat=0;$shcat<$totSHCatListings;$shcat++){
				$category_counter++;
				//----------------------------------------
				//$selQry_sh = "SELECT * FROM ".TBL_STAKEHOLDERS." WHERE category_id='".$catInfo[$shcat]['category_id']."' AND status='1' $searchedQuery ORDER BY name";				
				$selQry_sh = "SELECT DISTINCT(".TBL_STAKEHOLDERS.".id),".TBL_STAKEHOLDERS.".* FROM ".TBL_STAKEHOLDERS." 
				LEFT JOIN ".TBL_STAKEHOLDERS_DEPTS_FILES." ON (".TBL_STAKEHOLDERS.".id = ".TBL_STAKEHOLDERS_DEPTS_FILES.".stakerholder_id)
				WHERE ".TBL_STAKEHOLDERS.".category_id='".$catInfo[$shcat]['category_id']."' 
				AND ".TBL_STAKEHOLDERS.".STATUS='1'
				$searchedQuery 
				ORDER BY ".TBL_STAKEHOLDERS.".name;";
				$shInfo =  $con->getMultiRow($selQry_sh, __FILE__,__LINE__);
				$totSHListings = count($shInfo);
				//----------------------------------------
	?>
      {
        name: "<?php echo $catInfo[$shcat]['category_title'];?>",
		value: "<?php echo isset($catInfo[$shcat]['category_influence'])?$catInfo[$shcat]['category_influence']:'500';?>",
		id: "<?php echo $catInfo[$shcat]['category_id'];?>",
		title:"<?php echo $catInfo[$shcat]['category_title'];?> (<?php echo $totSHListings;?>)",
		off: true,
		type: "Cat",
		color:"<?php echo !empty($catInfo[$shcat]['category_orientation'])?$catInfo[$shcat]['category_orientation']:'#a9b7af';?>",
		<?php if( (!isset($_GET['mode'])) && ($totSHListings>0) ){}else{?>
		togglable: false,
		<?php }?>
        children: [
		  <?php
			$shsrno = 0;
			if($totSHListings>0)
			{
				for($shh=0;$shh<$totSHListings;$shh++){ 
					$shsrno++;
		  ?>
		  	{ name: "<?php echo $shInfo[$shh]['abbreviation'];?>",id:"<?php echo $shInfo[$shh]['id'];?>",title:"<?php echo $shInfo[$shh]['name'];?>", type: "SH", value: "<?php echo $totSHListings;?>",url: "sh-card.php?sid=<?php echo $shInfo[$shh]['id'];?>",color:"<?php echo !empty($shInfo[$shh]['sh_current_orientation'])?$shInfo[$shh]['sh_current_orientation']:'#a9b7af';?>"},
		  <?php }
		  }else{?>
		  	{ name: "",title:"", value: ""}
		  <?php }?>
		]
      },
	  <?php }
	  }?>
    ]
  }
];
<?php }?>

//networkSeries.maxLevels = 1;

networkSeries.dataFields.value = "value";
networkSeries.dataFields.name = "name";
networkSeries.dataFields.id = "id";
networkSeries.dataFields.children = "children";
networkSeries.dataFields.fixed = "fixed";
networkSeries.dataFields.color = "color";
networkSeries.dataFields.collapsed = "off";
networkSeries.dataFields.togglable = "togglable";

networkSeries.nodes.template.outerCircle.filters.push(new am4core.DropShadowFilter());
networkSeries.nodes.template.expandAll = false;
networkSeries.nodes.template.togglable = true;
networkSeries.nodes.template.label.hideOversized = true;
networkSeries.nodes.template.label.truncate = true;
networkSeries.nodes.template.tooltipText = "{title}";
networkSeries.nodes.template.fillOpacity = 1;
networkSeries.nodes.template.label.text = "[bold]{name}";//{name}: [bold]{value}[/]
networkSeries.nodes.template.propertyFields.x = "x";
networkSeries.nodes.template.propertyFields.y = "y";
networkSeries.nodes.template.propertyFields.minRadius = "minRadius";
networkSeries.nodes.template.propertyFields.url = "url";
networkSeries.nodes.template.propertyFields.togglable = "togglable";
networkSeries.nodes.template.urlTarget = "_blank";

<?php if(isset($_GET['mode']) && $_GET['mode']=='Edit'){?>		
	nodesTemplate.events.on("hit", function(ev) {
  
		  //alert("clicked on ", ev.target);
		  var node_name = ev.target.dataItem.dataContext.name;
		  var node_id = ev.target.dataItem.dataContext.id;
		  var node_type = ev.target.dataItem.dataContext.type;
		  
		  if(node_type=='Cat')
		  {	
			//$(this).removeData('bs.modal');
			
			var dataURL = "sh-update-overview-category.php?catid="+node_id;
			$(".modal-body").html("");
			$('.modal-body').load(dataURL,function(){	
				$('#myModal').modal({show:true});
			});
		  }
		  // zoom to an object
		  //ev.target.series.chart.zoomToMapObject(ev.target);
		 
		  // get object info
		  //console.log(ev.target.dataItem.dataContext.name);
		  
 	});
<?php }?>

networkSeries.links.template.strokeWidth = 2;
networkSeries.links.template.strokeOpacity = 1;
networkSeries.links.template.distance = 1.3;

networkSeries.fontSize = 10;

<?php if(isset($_GET['mode']) && $_GET['mode']=='Edit'){?>	
networkSeries.minRadius = am4core.percent(3);
networkSeries.centerStrength = 0.9;
networkSeries.manyBodyStrength = -70;
<?php }else{?>	
//networkSeries.minRadius = am4core.percent(3);
networkSeries.minRadius = am4core.percent(1.5);
networkSeries.centerStrength = 0.5;
networkSeries.manyBodyStrength = -25;
<?php }?>	

// Configure icons
var icon = networkSeries.nodes.template.createChild(am4core.Image);
icon.propertyFields.href = "image";
icon.horizontalCenter = "middle";
icon.verticalCenter = "middle";
icon.width = 90;
icon.height = 419;
</script>
<script type="text/javascript">
function addCategory()
{
	var dataURL = "sh-add-overview-category.php";
	$(".modal-body").html("");
	$('.modal-body').load(dataURL,function()
	{
		$('#myModal').modal({show:true});
	});
}
</script>
<!-- Data table area End-->
<!-- jquery
		============================================ -->
<script src="js/vendor/jquery-1.11.3.min.js"></script>
<!-- bootstrap JS
		============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- notification JS
		============================================ -->
<script src="js/Lobibox.js"></script>
<script src="js/notification-active.js"></script>
<!-- Tree Viewer JS
		============================================ -->
<script src="js/tree-line/jstree.min.js"></script>
<script src="js/tree-line/jstree.active.js"></script>
<script>
$(document).ready(function() {
	
	/*$(".modal").on("hidden.bs.modal", function() {
    	$(".modal-body").html("");//
  	});*/
	
	//department_id,file_id
	
	//------------------ Get Houses ------------
    $( "#department_id" ).change(function() 
      {  
        var did = $(this).val();
        $.ajax({
            url: "get-files-by-departments.php",
            type: 'POST',
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
            data: 'did=' + did,
            success: function(result){
							
                $('#file_id').html('');
                $('#file_id').append('<option value="">---Select Files---</option>');
				
				$.each( JSON.parse(result), function(key, value) { // or use data without  JSON.parse(data) 
					var k = value.file_id;
					var v = value.file_name;
					$('#file_id').append($('<option>', {value:k, text:v}));
				});
				
            },
            error: function()
            {
                 //handle errors
                 //alert('error...');
                 $('#file_id').html('');
                 $('#file_id').append('<option value="">---Select Files---</option>');
            }
        });

      });
      //----------------------------------------
  
} );

function reloadData() {
    
	//var newData = [];
  
    return newData;
}

function loadNewData(newData) 
{	
	chart.dataSource.load();
}
</script>
</body>
</html>
