<?php
include("../../../functions.inc.php");
include("../functions.inc.php");

dbConnect();

checkLogin('adm');
checkEnteService($_GET['serv']);

//modifico
if(isset($_POST['newnome'])){
	
	$id = intval($_GET['id']);
	
	if(is_empty($_POST['newnome']))
		printMsg("Inserire un valore","danger");

	$result = $mysqli->query("UPDATE gruppi SET grp_nome = ".dbClean($_POST['newnome'])." WHERE ente_id = ".$_SESSION['user']['ente_id']." AND grp_id = ".$id);
	if($result)
		Js("$('#nome_grp_".$id."').html('".entities($_POST['newnome'])."');closeDialog();");
	else
		printMsg("Errore durante il salvataggio",'danger');

	die();	
}


?>
<div>
    <div class="modal-d-title">Modifica</div>
    <form role="form" class="form-horizontal"action="<?php echo $_SERVER['REQUEST_URI'];?>" onSubmit="return post(this,'result_grp_e')">
        <div class="modal-body modal-body-diag">    
            
            <div class="form-group">
                <div class="col-xs-12">
                    <input type="text" maxlength="80" class="form-control" name="newnome" placeholder="inserire un valore" value="<?php echo entities(urldecode($_GET['n']));?>">
                </div>
            </div>
            <div id="result_grp_e"></div>
        </div>
        
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary">Salva</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Annulla</button>
        </div>
    </form>

</div>