<?php
	include_once("../../core.php");
	include_once($docroot."/config.inc.php");
	include_once($docroot."/lib/user_check.php");
	include_once($docroot."/lib/permissions_check.php");
	
	switch( $html->form('op', 'post') ){
		case "add":
			if( $permessi[$module_name] == 'rw' ){
				$descrizione = $html->form('descrizione', 'post');
				$rs = $dbo->query("insert into zz_modules set name='".$descrizione."' , `default` = 1 , `enabled` = 1 ,  type='Menu'");
				$id_record = $dbo->last_inserted_id();
				array_push( $_SESSION['infos'], "Nuova voce di menu creata!" );
			
			}
			break;
		case "update":
			if( $permessi[$module_name] == 'rw' ){
				
				$parent = $html->form('parent', 'post');
				$order = $html->form('order', 'post');
				$location = $html->form('location', 'post');
				$nome = $html->form('name', 'post');				
				$icon = $html->form('icon', 'post');
				( $_POST['enabled'] == 'on' ) ? $enabled=1 : $enabled=0;								
				$query = "UPDATE zz_modules SET  icon=\"".$icon."\" , parent=\"".$parent."\" , `order`=\"".$order."\" , enabled=\"".$enabled."\"  WHERE id=\"".$id_record."\" ";
				$rs = $dbo->query( $query );
				array_push( $_SESSION['infos'], "Informazioni salvate correttamente!" );
				
			}
			break;

		case "delete":
			if( $permessi[$module_name] == 'rw' ){
				
			}
			break;

		
	}
?>