<?php
/* ADMIN CHECK */
			$admin_word = "admin";	

include('r_dbc.php');

$sql = "SELECT pid as pidx,desc_project from ccprojects where pid in (".$usprojects.") and pid != '".$pid."' order by pid";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
      while($row = mysqli_fetch_assoc($result)) {
		$pidx 				= $row["pidx"];
		$desc_project 		= $row["desc_project"];
		}
} 
mysqli_close($conn);


?>

<?php
/* GEOCHART CHECK */
include('r_dbc.php');

$sql = "SELECT geochart_region from ccprojects where pid = '".$pid."'";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
      while($row = mysqli_fetch_assoc($result)) {
		$geochart_region 	= $row["geochart_region"];		
		}
} 
mysqli_close($conn);


?>

<?php	
// EXPENSES DESC MANAGER
include('r_dbc.php');
$sqlmid = "select desc_manager
			from ccmanager_id 
			where pid='".$pid."' 
			and expenses = 1";

$resultmid = mysqli_query($conn, $sqlmid);

if (mysqli_num_rows($resultmid) > 0) {
      while($rowmid = mysqli_fetch_assoc($resultmid)) {
		$desc_manager_expenses		= $rowmid["desc_manager"];
    }
} 
mysqli_close($conn);
?>

<?php	
// PLANNED MANAGER
include('r_dbc.php');
$sqlmid = "select desc_manager
			from ccmanager_id 
			where pid='".$pid."' 
			and expenses = 3";

$resultmid = mysqli_query($conn, $sqlmid);

if (mysqli_num_rows($resultmid) > 0) {
      while($rowmid = mysqli_fetch_assoc($resultmid)) {
		$desc_manager_planned		= $rowmid["desc_manager"];
    }
} 
mysqli_close($conn);
?>

<?php
// MIDS
include('r_dbc.php');

$mixcnt = 0;
$sql = "SELECT menu_order,mid,desc_manager,expenses from ccmanager_id where pid = '".$pid."' and delta_col=0 order by mid";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
      while($row = mysqli_fetch_assoc($result)) {
		$menu_order		= $row["menu_order"];
		$midx 			= $row["mid"];
		$desc_managerx 	= $row["desc_manager"];
		$expensesx 		= $row["expenses"];		
		
	  if ($menu_order == 1) { $mid1 = $midx; $desc_manager1 = $desc_managerx; }
	  if ($menu_order == 2) { $mid2 = $midx; $desc_manager2 = $desc_managerx; }
	  if ($menu_order == 3) { $mid3 = $midx; $desc_manager3 = $desc_managerx; }	  
	  if ($menu_order == 4) { $mid4 = $midx; $desc_manager4 = $desc_managerx; }	  
	  if ($menu_order == 5) { $mid5 = $midx; $desc_manager5 = $desc_managerx; }	  
	  if ($menu_order == 6) { $mid6 = $midx; $desc_manager6 = $desc_managerx; }	  
	  if ($menu_order == 7) { $mid7 = $midx; $desc_manager7 = $desc_managerx; }	  
	  if ($menu_order == 8) { $mid8 = $midx; $desc_manager8 = $desc_managerx; }	  
	  if ($menu_order == 9) { $mid9 = $midx; $desc_manager9 = $desc_managerx; }	  

	}
} 
mysqli_close($conn);

?>


<?php

// AVAILABLE ONLY FOR ADMINISTRATORS
$admin_word = "admin";


$menu_line = "menu.php?pid=".$pid."&xuid=".$xuid."&lang=".$lang;

// FORMS COLUMN

$form1 = "<span style='color:".$menu_color_forms."'><i class='fas fa-coins'></i></span>				<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid1&xfdc=$xfdc' class='text-decoration-none' > $desc_manager1 </a>";
$form2 = "<span style='color:".$menu_color_forms."'><i class='fas fa-file-invoice'></i></span>		<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid2&xfdc=$xfdc' class='text-decoration-none' > $desc_manager2 </a>";
$form3 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid3&xfdc=$xfdc' class='text-decoration-none' > $desc_manager3 </a>";
$form4 = "<span style='color:".$menu_color_forms."'><i class='fas fa-business-time'></i></i></span>	<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid4&xfdc=$xfdc' class='text-decoration-none' > $desc_manager4 </a>";
$form5 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid5&xfdc=$xfdc' class='text-decoration-none' > $desc_manager5 </a>";
$form6 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid6&xfdc=$xfdc' class='text-decoration-none' > $desc_manager6 </a>";
$form7 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid7&xfdc=$xfdc' class='text-decoration-none' > $desc_manager7 </a>";
$form8 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid8&xfdc=$xfdc' class='text-decoration-none' > $desc_manager8 </a>";
$form9 = "<span style='color:".$menu_color_forms."'><i class='fas fa-chart-line'></i></span>			<a href='nf_manager.php?pid=$pid&xuid=$xuid&lang=$lang&mid=$mid9&xfdc=$xfdc' class='text-decoration-none' > $desc_manager9 </a>";


if ($desc_manager2 == '') { $form2 = ""; }
if ($desc_manager3 == '') { $form3 = ""; }
if ($desc_manager4 == '') { $form4 = ""; }
if ($desc_manager5 == '') { $form5 = ""; }
if ($desc_manager6 == '') { $form6 = ""; }
if ($desc_manager7 == '') { $form7 = ""; }
if ($desc_manager8 == '') { $form8 = ""; }
if ($desc_manager9 == '') { $form9 = ""; }

$form10 = "<td class='w1-animate-opacity'></td>";
$form11 = "<td class='w1-animate-opacity'></td>";
$form12 = "<td class='w1-animate-opacity'></td>";


// REPORTS COLUMN

$rep1 = "<span style='color:".$menu_color_reports."'><i class='far fa-calendar-alt'></i></span>	<a href='r_calendar.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 	 	class='text-decoration-none' target=_blank >".$n_calendar."</a>";
$rep2 = "<span style='color:".$menu_color_reports."'><i class='far fa-file-alt'></i></span>		<a href='r_centers.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' target=_blank >".$n_centers_totals."</a>";
$rep3 = "<span style='color:".$menu_color_reports."'><i class='far fa-file-alt'></i></span>		<a href='r_categs.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' target=_blank >".$n_categs_totals."</a>";
$rep4 = "<span style='color:".$menu_color_reports."'><i class='far fa-file-alt'></i></span>		<a href='r_center_totals.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' class='text-decoration-none' target=_blank >".$r_center_totals."</a>";
$rep5 = "<span style='color:".$menu_color_reports."'><i class='far fa-file-alt'></i></span>		<a href='r_categ_totals.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 	class='text-decoration-none' target=_blank >".$r_categ_totals."</a>";

// AVAILABLE IN PREMIUM VERSION
if ($rabio_premium == 1) {
$rep6 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_centers.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$z_r_centers."</a>";
$rep7 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_categs.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 			class='text-decoration-none' 	target=_blank >".$z_r_categs."</a>";
$rep8 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_center_one.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_centers." ".$desc_manager_reps."</a>";
$rep9 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_categ_one.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_categs." ".$desc_manager_reps."</a>";
$rep10 = "<span style='color:".$menu_color_reports_premium."'><i class='fas fa-tags'></i></span>		<a href='z_r_filter_tags.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 	class='text-decoration-none' 	target=_blank >".$n_tags." ".$desc_manager_reps."</a>";
$rep11 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_invoice.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 	class='text-decoration-none' 	target=_blank >".$n_invoice." ".$nreport."</a>";

// CLASSES AVAILABLE ONLY FOR ADMINISTRATORS
if (strpos($usrole, $admin_word) !== false) {
$rep12 = "<span style='color:".$menu_color_reports_premium."'><i class='far fa-file-alt'></i></span>		<a href='z_r_project.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_project_info."</a>";
}
}
elseif (strpos($usrole, $admin_word) == false) {
$rep12 = "<td class='w2-animate-opacity'></td>";
}	

// VIEWS COLUMNS

$view1 = "<span style='color:".$menu_color_views."'><i class='fas fa-chart-pie'></i></span>		<a href='dashboard.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' 								class='text-decoration-none' 	target=_blank >$n_adminpanel</a>";
$view2 = "<span style='color:".$menu_color_views."'><i class='fas fa-chart-bar'></i></span>		<a href='r_centers_progress.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_centers_progress." ".$desc_manager_expenses."</a>";
$view3 = "<span style='color:".$menu_color_views."'><i class='fas fa-chart-bar'></i></span>		<a href='r_categs_progress.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_categs_progress." ".$desc_manager_expenses."</a>";
$view4 = "<span style='color:".$menu_color_views."'><i class='fas fa-download'></i></span>		<a href='r_filter_center_chart.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 	class='text-decoration-none' 	target=_blank >".$n_center." ".$desc_manager_expenses." ".$nchart."</a>";
$view5 = "<span style='color:".$menu_color_views."'><i class='far fa-calendar-alt'></i></span>	<a href='r_calendar_view.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$desc_manager_expenses." ".$n_calendar."</a>";
if (isset($desc_manager_planned)) {
$view6 = "<span style='color:".$menu_color_views."'><i class='far fa-chart-bar'></i></span>		<a href='r_gantt_centers.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$title_gantt_centers."</a>";
}
else {
	$view6 = "";
}
// PREMIUM EDITION CHECK HERE FOR VIEWS
if ($rabio_premium == 1) {
$view7 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-download'></i></span>		<a href='z_r_export.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 				class='text-decoration-none' 	target=_blank >".$n_export_rep."</a>";
$view8 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-filter'></i></span>		<a href='z_r_filter_cencat.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$desc_manager_reps." ".$ntotals." ".$nview."</a>";

	
// AVAILABLE ONLY FOR PROJECTS WITH STOCKREP = 1 
if ($stockrep == 1) {
	$view9 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-dolly-flatbed'></i></span>			<a href='z_r_filter_stock_cc.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' class='text-decoration-none' 	target=_blank >".$nstock." ".$nview." ".$n_centers1."</a>";
	$view10 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-dolly-flatbed'></i></span>			<a href='z_r_filter_stock_ct.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' class='text-decoration-none' 	target=_blank >".$nstock." ".$nview." ".$n_categs1."</a>";
}
if ($stockrep == 0) {
	$view9 = "";
	$view10 = "";
}
// AVAILABLE ONLY FOR GEOCHART <> 0
if ($geochart_region <> '0') {
$view11 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-globe-europe'></i></span>			<a href='z_r_geo.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$desc_manager_expenses." ".$n_geochart."</a>";
}
elseif ($geochart_region == '0') {
$view11 = "";
}


}

$view12 = "";



// STRUCTURE COLUMNS
$st_ccgrp 			= "";
$msg_ccgrp 			= "$n_centers_groups";
$msg_ccgrp_class 	= "";
$ficon_ccgrp		= "<span style='color:".$menu_color_struc."'><i class='fas fa-th-list'></i></span>";

$st_cc 				= "";
$msg_cc 			= "$n_centers";
$msg_cc_class 		= "";
$ficon_cc			= "<span style='color:".$menu_color_struc."'><i class='fas fa-list-ul'></i></span>";

$st_catgrp 			= "";
$msg_catgrp 		= "$n_categs_groups";
$msg_catgrp_class 	= "";
$ficon_catgrp		= "<span style='color:".$menu_color_struc."'><i class='fas fa-th-list'></i></span>";

$st_cat 			= "";
$msg_cat 			= "$n_categs";
$msg_cat_class 		= "";
$ficon_cat			= "<span style='color:".$menu_color_struc."'><i class='fas fa-list-ul'></i></span>";



if ($cnt_ccgrp 	== 0) 
	{ 	
		$st_ccgrp 			= "style='color:tomato'"; 	
		$ficon_ccgrp 		= "<span style='color:tomato'><i class='fas fa-exclamation-triangle blink'></i></span>";	
		$msg_ccgrp 			= "$nadd $n_centers_groups";
		$msg_ccgrp_class 	= "class='blink'";
	}
if ($cnt_cc 	== 0) 
	{ 
		$st_cc	 			= "style='color:tomato'"; 	
		$ficon_cc 			= "<span style='color:tomato'><i class='fas fa-exclamation-triangle blink'></i></span>";	
		$msg_cc 			= "$nadd $n_centers";
		$msg_cc_class 		= "class='blink'";		
	}
if ($cnt_catgrp	== 0) 
	{ 
		$st_catgrp 			= "style='color:tomato'"; 	
		$ficon_catgrp 		= "<span style='color:tomato'><i class='fas fa-exclamation-triangle blink'></i></span>";	
		$msg_catgrp			= "$nadd $n_categs_groups";
		$msg_catgrp_class 	= "class='blink'";				
	}
if ($cnt_cat 	== 0) 
	{ 
		$st_cat	 			= "style='color:tomato'"; 	
		$ficon_cat			= "<span style='color:tomato'><i class='fas fa-exclamation-triangle blink'></i></span>";	
		$msg_cat			= "$nadd $n_categs";
		$msg_cat_class 		= "class='blink'";						
	}


$struc1 = "$ficon_ccgrp 	<a href='nf_centersg.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc'	$msg_ccgrp_class	$st_ccgrp 	class='text-decoration-none' >$msg_ccgrp</a>";
$struc2 = "$ficon_cc 		<a href='nf_centers.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' 	$msg_cc_class		$st_cc		class='text-decoration-none' >$msg_cc</a>";
$struc3 = "$ficon_catgrp 	<a href='nf_categsg.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' 	$msg_catgrp_class	$st_catgrp	class='text-decoration-none' >$msg_catgrp</a>";
$struc4 = "$ficon_cat		<a href='nf_categs.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' 		$msg_cat_class		$st_cat	class='text-decoration-none' >$msg_cat</a>";

// PROJECT DESCRIPTION UPDATE AVAILABLE ONLY FOR ADMINISTRATORS
if ($usrole == "admin" || $usrole == "admins") {
	$struc5 = "<span style='color:".$menu_color_struc."'><i class='fas fa-edit'></i></span>	<a href='nf_project.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none' >$nproject</a>";
}
elseif ($usrole != "admin" || $usrole != "admins") {
$struc5 = "<td class='w3-animate-opacity'></td>";
}	

// CLASSES AVAILABLE ONLY FOR ADMINISTRATORS
if (strpos($usrole, $admin_word) !== false) {
	$struc6 = "<span style='color:".$menu_color_struc."'><i class='fas fa-project-diagram'></i></span>	<a href='nf_manid.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none' >$nmanagers</a>";
}
elseif (strpos($usrole, $admin_word) == false) {
$struc6 = "<td class='w3-animate-opacity'></td>";
}	

// USERS AVAILABLE ONLY FOR ADMINISTRATORS
if (strpos($usrole, $admin_word) !== false) {
	$struc7 = "<span style='color:".$menu_color_struc."'><i class='fas fa-user-cog'></i></span>	<a href='nf_users.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none'  >$nusers</a>";
}
elseif (strpos($usrole, $admin_word) == false) {
$struc7 = "<td class='w3-animate-opacity'></td>";
}	

// USERS TO PROJECTS ONLY FOR ADMINISTRATORS
if ($usrole == "admin" || $usrole == "admins") {
	$struc8 = "<span style='color:".$menu_color_struc."'><i class='fas fa-user-plus'></i></span>	<a href='nf_users_projects.php?xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none' target=_blank >$nusers-$nprojects</a>";
}
elseif ($usrole != "admin" || $usrole != "admins") {
$struc8 = "<td class='w3-animate-opacity'></td>";
}	


// USERS TO PROJECTS ONLY FOR ADMINISTRATORS
if ($usrole == "admin" || $usrole == "admins") {
// AVAILABLE IN PREMIUM VERSION
if ($rabio_premium == 1) {	
	$struc9 = "<span style='color:".$menu_color_struc_premium."'><i class='fas fa-user-circle'></i></span>	<a href='z_nf_users_projects_centers.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none' target=_blank >$nusers-$n_centers</a>";
	$struc10 = "<span style='color:".$menu_color_struc_premium."'><i class='far fa-user-circle'></i></span>	<a href='z_nf_users_projects_categs.php?pid=$pid&xuid=$xuid&lang=$lang&xfdc=$xfdc' class='text-decoration-none' target=_blank >$nusers-$n_categs</a>";
}	
}
elseif ($usrole != "admin" || $usrole != "admins") {
$struc9 = "<td class='w3-animate-opacity'></td>";
$struc10 = "<td class='w3-animate-opacity'></td>";
}	

// REPORTS AVAILABLE ONLY FROM SUPER ADMIN
if ( $admins_check == 1) {
$struc11 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-chart-bar'></i></span>		<a href='z_r_views.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$title_views."</a>";	
$struc12 = "<span style='color:".$menu_color_views_premium."'><i class='fas fa-desktop'></i></span>		<a href='z_r_views_admin.php?pid=".$pid."&lang=".$lang."&xuid=".$xuid."&xfdc=".$xfdc."' 		class='text-decoration-none' 	target=_blank >".$n_super_admin_view."</a>";
}
else {
$struc11 = "<td class='w3-animate-opacity'></td>";
$struc12 = "<td class='w3-animate-opacity'></td>";
}	



// $struc11 = "<td class='w3-animate-opacity'></td>";
// $struc12 = "<td class='w3-animate-opacity'></td>";


?>