[% USE raw %]
[% USE Koha %]
[% USE KohaDates %]
[% USE AdditionalContents %]
[% PROCESS 'i18n.inc' %]
[% PROCESS 'html_helpers.inc' %]
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET consentview = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title
    >[% FILTER collapse %]
 [% t("Your consents") | html %]
 &rsaquo; [% PROCESS 'library_name_title' %]
 [% END %]</title
>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
[% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-patron-consent' %]
[% INCLUDE 'masthead.inc' %]

<main class="main">
 [% WRAPPER breadcrumbs %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-user.pl">[% patron.firstname | html %] [% patron.surname | html %]</a>
 [% END %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Tus consentimientos</span>
 [% END %]
 [% END #/ WRAPPER breadcrumbs %]

 <div class="container-fluid">
 <div class="row">
 <div class="col-lg-2">
 <div id="navigation"> [% INCLUDE 'navigation.inc' IsPatronPage=1 %] </div>
 </div>
 <div class="col-lg-10 order-first order-md-first order-lg-2">
 <div id="patronconsents" class="maincontent">
 <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
 [% INCLUDE 'csrf-token.inc' %]
 <input type="hidden" name="op" value="cud-save" />
 <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
 <h1>Tus consentimientos</h1>
 [% FOREACH consent IN consents %]
 [% SET consent_type = consent.type %]
 [% IF consent_type == 'GDPR_PROCESSING' %]
 <legend><h2>Consentimiento de la política de privacidad</h2></legend>
 <div class="alert alert-warning">
 <p>Para mantenerlo conectado, necesitamos su consentimiento para procesar datos personales tal y como se especifica en la política de privacidad enlazada a continuación.</p>
 <p>Si seleccionar quitar su consentimiento <strong>eliminaremos su cuenta</strong> dentro de un tiempo razonable, y debería cerrar la sesión ahora.</p>
 </div>
 <p>Estoy de acuerdo con su tratamiento de mis datos personales como se describe en el <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') | url %]">política de privacidad</a>.</p>
 [% ELSIF consent_types.$consent_type %]
 [% SET consent_title = ( consent_types.$consent_type.title.$lang || consent_types.$consent_type.title.en ) %]
 [% SET consent_desc  = ( consent_types.$consent_type.description.$lang || consent_types.$consent_type.description.en ) %]
 <legend><h2>[% consent_title | html %]</h2></legend>
 <p>[% consent_desc | html %]</p>
 <p>¿Está de acuerdo?</p>
 [% ELSE %]
 <legend><h2>Consentimiento para [% consent_type | html %]</h2></legend>
 <p>¿Está de acuerdo?</p>
 [% END %]
 <fieldset>
 [% IF consent.given_on %]
 <label><input type="radio" name="check_[% consent_type | html %]" value="1" checked="checked" /> Sí</label><br />
 <label><input type="radio" name="check_[% consent_type | html %]" value="0" /> No</label>
 [% ELSIF consent.refused_on %]
 <label> <input type="radio" name="check_[% consent_type | html %]" value="1" /> Sí</label><br />
 <label><input type="radio" name="check_[% consent_type | html %]" value="0" checked="checked" /> No </label>
 [% ELSE %]
 <label><input type="radio" name="check_[% consent_type | html %]" value="1" /> Sí</label><br />
 <label><input type="radio" name="check_[% consent_type | html %]" value="0" /> No</label>
 [% END %]
 [% IF consent.given_on %]
 <p class="consent_info"><strong>Su consentimiento fue registrado en [% consent.given_on | html %].</strong></p>
 [% ELSIF consent.refused_on %]
 <p class="dissent_info"><strong>Registramos que no ha consentido [% consent.refused_on | html %].</strong></p>
 [% END %]
 </fieldset>
 [% END %]
 <fieldset class="action">
 <input class="btn btn-primary" id="saveconsent" type="submit" value="Guardar" />
 </fieldset>
 </form>
 </div>
 <!-- / #patronconsents -->
 </div>
 <!-- / .col-lg-10 -->
 </div>
 <!-- / .row -->
 </div>
 <!-- / .container-fluid -->
</main>
<!-- / .main -->

[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
 <script>
        $(document).ready(function () {
            // Initially no choice is made or no change, so disable button
            $("#saveconsent").prop("disabled", true);

            $("input[type='radio']").click(function () {
                $("#saveconsent").prop("disabled", false);
                var v = $(this).val();
                // If former registration info present, toggle
                if (v == 1) {
                    $(this).siblings(".consent_info").show();
                    $(this).siblings(".dissent_info").hide();
                } else {
                    $(this).siblings(".consent_info").hide();
                    $(this).siblings(".dissent_info").show();
                }
            });
        });
    </script>
[% END %]
