<?php
    $ruta = "../";
    require_once "../include/bd_pdo.php";
    global $db;
    if(isset($_POST['lectura']))
        $ver = $_POST['lectura'];
    if(isset($_POST['editar']))
        $editar = $_POST['editar'];
    foreach($editar as $edit){
        $edit_separado = explode("_", $edit);
        $completo[]=$edit_separado;
    }
    $db->query("SELECT fd_permiso()");
    foreach($ver as $lectura){
        $igual=false;
        $ver_separado = explode("_", $lectura);
        foreach($completo as $comp){
            if($ver_separado[0] == $comp[0] && $ver_separado[1] == $comp[1]){
                $igual=true;
                break;
            }
        }
        if(!$igual)
            $completo[]=$ver_separado;
    }
    foreach($completo as $actual){

        $db->insert('permiso', [
            'pagina_id' => $actual['0'],
            'rol_id' => $actual['1'],
            'permiso_tipo' => $actual['2'],
        ]);
    }
    header("Location: ../permisos.php");
    exit();
?>