<?php echo '</div><!-- /content -->'. //echo to avoid "closing tag matches nothing" warning
'</div><!-- /container -->';?>
<div id="modalWindow"><div id="modalBackground" onclick="ui.closeModalBox()"></div><div id="modalContent"></div></div>
<script type="text/javascript">
let menu;
if(currentUser){
menu={
	sections:[
	  	{ label:'Access', column:1, items:[
	  		{ label:'My profile', url:'/user/'+userId },
			{ label:'Log out '+currentUser["fullname"], onclick:'Login.logOut()' }
	  	]},
		{ label:'Screens', column:4, items:[
			{ label:'Find screens', url:'/screen' },
        	{ label:'Add standard screen', url:'/screen/create' }
        ]},
        { label:'Plates', column:5, items:[
        	{ label:'Find plates', url:'/plate' },
            { label:'Add a plate', url:'/plate/create' }
		]},
		{ label:'Plate types', column:5, items:[
			{ label:'Find plate types', url:'/platetype' },
			{ label:'Add a plate type', url:'/platetype/create' }
		]},		
		{ label:'Fishing &amp; Shipping', column:3, items:[
			{ label:'Crystal fishing', url:'/containercontent/create' },
			{ label:'Shipments', url:'/shipment' },
			{ label:'New shipment', url:'/shipment/create' }
		]}
	]
};

<?php if(session::isAdmin()){ ?>

menu.sections.push({ label:'Users',column:1, items:[
        { label:'Find users', url:'/user' },
        { label:'Add a user', url:'/user/create' }
    ]});

<?php 
}

if(session::canCreateUsergroups() || session::isAdmin()){
    ?>

	menu.sections.push({ label:'Usergroups',column:1, items:[
		{ label:'Find usergroups', url:'/usergroup' },
		{ label:'Add a usergroup', url:'/usergroup/create' }
	]});

<?php }

try{if(session::isTechnician() || session::isShipper() || session::isAdmin()){ ?>
menu.sections.push({
    label: 'Containers', column: 3, items: [
        {label: 'Find containers', url: '/container'},
        {label: 'Add a container', url: '/container/create'},
        {label: 'Find types', url: '/containertype'},
        {label: 'Add a type', url: '/containertype/create'},
        {label: 'Find categories', url: '/containercategory'},
        {label: 'Add a category', url: '/containercategory/create'}
    ]
});
<?php } else { ?>
menu.sections.push({
    label: 'Containers', column: 3, items: [
        {label: 'Find containers', url: '/container'},
        {label: 'Find types', url: '/containertype'},
        {label: 'Find categories', url: '/containercategory'},
    ]
});
<?php }}catch (NotFoundException $e) {} ?>

menu.sections.push({ label:'Projects',column:1, items:[
        { label:'Find projects', url:'/project' },
        <?php if(session::isAdmin() || session::canCreateProjects()){ ?>
        { label:'Add a project', url:'/project/create' }
        <?php }?>
    ]});

<?php if(session::isAdmin()){ ?>

    menu.sections.push({ label:'Admin',column:1, items:[
        { label:'Configure default homepage', url:'/homepagedefaultbrick' },
        { label:'Configure IceBear', url:'/config' },
        { label:'View log files', url:'/Log' }
    ]});

<?php } ?>

} //end if(currentUser)


function showMenu(){
    if(!currentUser){ return false; }
	let box=ui.modalBox({
		title:'Main menu',
		content:''
	});
	for(let i=1;i<=5;i++){
		let col=document.createElement("div");
		col.className="menucolumn col"+i;
		box.appendChild(col);
	}
	menu.sections.forEach(function(s){
		let out='<div class="menusection"><h3>'+s.label+'</h3>';
		s.items.forEach(function(i){
			out+='<a ';
			if(i.url){ 
				out+='href="'+i.url+'"'; 
			} else if(i.onclick){ 
				out+='href="#" onclick="'+i.onclick+';return false"'; 
			}
			out+='>'+i.label+'</a>';
		});
		out+='</div>';
		document.getElementById("modalBox").querySelector(".col"+s.column).innerHTML+=out;
	});
}

Login.authTimeoutSeconds=<?php echo 60*config::get('auth_timeout_mins'); ?>;
Login.startAuthTimer();
</script>
<?php echo '</body></html>'; //echo to avoid "closing tag matches nothing" warning