{extends "[shared]/frame.tpl"}

{block "content"}
   <div class="board-gdpr">
      <div class="container">

         <h3>{translate_type type='gdpr'}</h3>

         <div class="panel panel-default">
            <div class="panel-body">
               <form name="form_active" method="post" action="">
                  <div class="form-group form-group-flex row">

                     <div class="col-md-1 box">
                        {print_toggle name="gdpr][enable" value={$dbcfg.gdpr.enable}}
                     </div>
                     <div class="col-md-3 control-label">
                        <h4>{'active'|translate}</h4>
                     </div>
                     <div class="col-md-2 box">
                        <button type="submit" class="btn btn-primary disabled" name="acn" value="UpdateStatus" title="">Uložit</button>
                     </div>
                     <script>
                        $('[name="data[gdpr][enable]"]').on('change', function() {
                           $(this).closest('.form-group').find('button.disabled').removeClass('disabled');
                        })
                     </script>
                  </div>
               </form>

               <h1 class="h4 main-panel-title">{'gdpr_checklist'|translate:'gdpr'}</h1>
               {foreach $body.checklist as $check}
                  {if $check.ok}
                     <div class="alert alert-success">{$check.name}: {$check.message}</div>
                  {else}
                     <div class="alert alert-danger">{$check.name}: {$check.message}</div>
                  {/if}
               {/foreach}
            </div>
         </div>

         <div class="panel panel-default">
            <div class="panel-body">
               <h1 class="h4 main-panel-title">Aktivace souhlasů</h1>

               <form name="form_agreements" method="post" action="" class="agreements-form">
                  <div class="form-group form-group-flex row">
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="cookie_bar][enable" value={$dbcfg.cookie_bar.enable}}
                        <label class="control-label m-l-2">{'show'|translate}</label>
                     </div>

                     {if ($cfg.Path.smarty_tpl.theme == "x" or isSuperuser()) and !$cfg.Modules.components}
                        <div class="col-md-6 d-flex align-center">
                           {print_toggle name="cookie_bar][focus" value=$dbcfg.cookie_bar.focus}
                           <label class="control-label m-l-2">{'show_focus'|translate}</label>

                           {if isSuperuser() and $cfg.Path.smarty_tpl.theme != "x"}
                              <span class="glyphicon glyphicon-flash m-l-1" style="color: #aab2bd;" title="Vidí pouze superadmin"></span>
                           {/if}
                        </div>
                     {else}
                        <input type="hidden" name="data[cookie_bar][focus]" value="{$dbcfg.cookie_bar.focus}">

                     {/if}
                  </div>
                  {* todo přesunout jinam ? *}
                  <div class="form-group form-group-flex row">
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="cookie_bar][show_reject_btn" value=$dbcfg.cookie_bar.show_reject_btn}

                        <div class="control-label m-l-2">
                           <label style="position: relative; padding-right: 20px;">{'show_reject_btn'|translate}
                              <a class="help-tip" data-toggle="tooltip"
                                 title="{'show_reject_btn_tooltip'|translate}"
                                 style="margin-top: -9px;"><i class="bi bi-question-circle"></i></a>
                           </label>
                        </div>
                     </div>
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="cookie_bar][focus_close" value=$dbcfg.cookie_bar.focus_close}

                        <div class="control-label m-l-2">
                           <label style="position: relative; padding-right: 20px;">{'focus_close'|translate}</label>
                        </div>
                     </div>
                  </div>
                  <div class="form-group form-group-flex row">
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="cookie_bar][preselect" value=$dbcfg.cookie_bar.preselect|default:"Y"}
                        <label class="control-label m-l-2">{'preselect'|translate}</label>
                     </div>
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="cookie_bar][send" value={$dbcfg.cookie_bar.send}}

                        <div class="control-label m-l-2">
                           <label style="position: relative; padding-right: 20px;">
                              {'send'|translate}
                              <a class="help-tip" data-toggle="tooltip"
                                 title="Po zapnutí začne Google Analytics, Google Tag Manager a další upravovat svoje chování podle udělených souhlasů. Například bez uděleného souhlasu bude GA měřit pouze v anonymním režimu."
                                 style="margin-top: -9px;"><i class="bi bi-question-circle"></i></a>
                           </label>
                        </div>
                     </div>
                  </div>
                  <div class="form-group form-group-flex row">
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="newsletter][enable" value={$dbcfg.newsletter.enable}}

                        <div class="control-label m-l-2">
                           <label style="position: relative; padding-right: 20px;">{'newsletter'|translate}
                              <a class="help-tip" data-toggle="tooltip"
                                 title="Je-li dotazování vypnuto, zákazník bude při objednání přihlášen k newsletteru automaticky (v rámci tzv. oprávněného zájmu)."
                                 style="margin-top: -9px;"><i class="bi bi-question-circle"></i></a>
                           </label>
                        </div>
                     </div>
                     <div class="col-md-6 d-flex align-center">
                        {print_toggle name="consent][enable" value={$dbcfg.consent.enable}}

                        <div class="control-label m-l-2">
                           <label style="position: relative; padding-right: 20px;">{'consent'|translate}</label>
                        </div>
                     </div>
                  </div>
                  <div class="row">
                     <div class="col-md-2 col-md-push-10">
                        <button type="submit" class="btn btn-primary btn-block" name="acn" value="UpdateStatus" title="">Uložit</button>
                     </div>
                  </div>
               </form>
            </div>
         </div>

         <div class="panel panel-default">
            <div class="panel-body">
               <h1 class="h4 main-panel-title">{'gdpr_agreements'|translate:'gdpr'}</h1>
               <form name="form_agreements" method="post" action="" class="agreements-form">
                  {foreach $body.agreements as $agreement}
                     <div class="form-group form-group-flex row">
                        <div class="col-md-3 text-right">
                           <label>{$agreement.name}</label>
                        </div>
                        <div class="col-md-3">
                           <select class="selecter" name="data[{$agreement.label}]" style="display: none;">
                              <option value=""> ---</option>
                              {foreach $body.html_pages as $html_page}
                                 {$selected = ''}
                                 {if ($html_page.id==$agreement.selected_page)}
                                    {$selected = 'selected'}
                                 {/if}
                                 <option value="{$html_page.id}" {$selected}>{$html_page.name}</option>
                              {/foreach}
                           </select>
                        </div>
                        {if $agreement.selected_page}
                           <div class="col-md-5">
                              <a href="/{'redir'|translate_shop:'SEO_URL'}/?type=page&id={$agreement.selected_page}" class="help-block"
                                 target="_blank">Zobrazit <span class="glyphicon glyphicon-new-window"></span></a>
                           </div>
                        {else}
                           <div class="col-md-5 status-warning">
                              <p><span class="glyphicon glyphicon-warning-sign"></span> Je třeba nastavit {$agreement.name}</p>
                           </div>
                        {/if}
                     </div>
                  {/foreach}

                  <div class="row">
                     <div class="col-md-2 col-md-push-10">
                        <button type="submit" class="btn btn-primary btn-block" name="acn" value="UpdateAgreements" title="">Uložit</button>
                     </div>
                  </div>
               </form>

            </div>
         </div>
         <div class="panel panel-default">
            <div class="panel-body">
               <h1 class="h4 main-panel-title">{'users_data'|translate:'gdpr'}</h1>

               <p class="m-b-2">Zde můžete vygenerovat všechna shromážděná data o konkrétním zákazníkovi a odeslat mu je na e-mail.</p>
               <form name="form_user_data" method="post" action="launch.php?s=board.php&type=gdpr">
                  <div class="form-group form-group-flex row">
                     <div class="col-md-2 text-right">
                        <label>E-mail zákazníka</label>
                     </div>
                     <div class="col-md-3">
                        <input type="text" class="form-control input-sm" name="email" size="30" maxlength="100" value=""
                               placeholder="email"/>
                     </div>
                     <div class="col-md-5">
                        <button type="submit" class="btn btn-primary" name="acn" value="SendUserData"
                                title="Odeslat emailem">{'export_users_data'|translate:'gdpr'}</button>
                     </div>
                  </div>
               </form>
               {if $user_data}
                  <div class="panel" id="#user_data">
                     <div class="panel-heading collapsed {if $OkStr}row-green{/if} {if $ErrStr}row-red{/if}" data-toggle="collapse"
                          data-target="#user_data-collapse">
                        {$OkStr}
                        {$ErrStr}
                        <i class="glyphicon glyphicon-minus-sign"></i>
                     </div>
                     <div class="panel-collapse collapse symbol-collapse" id="user_data-collapse">
                        <textarea class="col-md-12" rows="15" name="user_data" readonly>{json_encode($user_data, 256+128)}</textarea>
                        <!-- JSON_UNESCAPED_UNICODE => 256; JSON_PRETTY_PRINT => 128; -->
                     </div>
                  </div>
               {/if}
            </div>
         </div>
      </div>
   </div>
{/block}
