<?php 
/********************************************************************************* 
 *  This file is part of Sentrifugo.
 *  Copyright (C) 2014 Sapplica
 *   
 *  Sentrifugo is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Sentrifugo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Sentrifugo.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Sentrifugo Support <support@sentrifugo.com>
 ********************************************************************************/
?>

<?php if(!empty($this->orgData)) { ?>

 <style>
	#ifrDiv{ z-index:1000;position:absolute;border:1px solid red;top:200px;left:200px;}	
	.jOrgChart .node .deptclass{ background-color:red !important; }
  </style>
<div id = "grayout"></div>

	<ul id="org" style="display:none;">
		<li class="orgunit">
			  <i></i><p><?php echo $this->orgData['organisationname'];?></p>
			  <?php if((!empty($this->unitData) && $this->unitData[0]['id'] != '0') || !empty($this->deptData)) 
				{ ?>
				  <ul>
					<?php for($i=0;$i<sizeof($this->unitData);$i++) 
					{ 
						if($this->unitData[$i]['id'] != 0)
						{
							?>
						<li class="bunitclass">
							<i></i><p><?php echo $this->unitData[$i]['unitname']; ?></p>
							<ul>
							<?php for($j=0;$j<sizeof($this->deptData);$j++) 
							{
								if($this->deptData[$j]['unitid'] == $this->unitData[$i]['id']) 
								{	?>
									<li class="deptclass"><i></i><p><?php echo $this->deptData[$j]['deptname'];?></p></li>
							<?php
								}
							}   ?>
							</ul>
						</li>
					<?php
						}					
					}	?>
					<?php if($this->nobu == 'exists') { ?>
					<li><ul>
					<?php 
					
					for($i=0;$i<sizeof($this->unitData);$i++) 
					{ 
						if($this->unitData[$i]['id'] == 0)
						{
							?>									
							<?php for($j=0;$j<sizeof($this->deptData);$j++) 
							{
								if($this->deptData[$j]['unitid'] == $this->unitData[$i]['id']) 
								{	?>
									<li class="deptclass"><i></i><p><?php echo $this->deptData[$j]['deptname'];?></p></li>
							<?php
								}
							}  
						}					
					}	?>
					</ul></li>
					<?php }?>
				  </ul>
		<?php 	} ?>
		</li>
	</ul>
<script type='text/javascript'>
jQuery(document).ready(function() {    
	$('#grayout').slimScrollHorizontal({
									  alwaysVisible: false,
									  start: 'left',
									  position: 'bottom',
									 
									}).css({ background: '#ccc', paddingBottom: '10px' });
	$("div.node").each(function(){
		var text = $(this).text();
		text = $.trim(text);
		var subtext = text.substring(0,30);
		$(this).html(subtext);
		$(this).attr("title",$.trim(text));
	});
	$("#org").jOrgChart();
});

</script>

<?php } else { ?>
<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>Organization Information is not added yet.</div>
<?php } ?>