<%= render 'shared/settings_nav' %>

<%= t('pdf_signature') %>

<%= t('upload_signed_pdf_file_to_validate_its_signature_') %>

<%= form_for '', url: verify_pdf_signature_index_path, method: :post, html: { enctype: 'multipart/form-data' } do |f| %> <%= f.button type: 'submit', class: 'flex' do %>
<%= svg_icon('loader', class: 'w-5 h-5 animate-spin inline') %> <%= "#{t('analyzing')}..." %>
<% end %> <% end %>

<%= t('signing_certificates') %>

<% if can?(:create, @encrypted_config) %> <%= link_to new_settings_esign_path, class: 'btn btn-primary btn-md', data: { turbo_frame: 'modal' } do %> <%= svg_icon('plus', class: 'w-6 h-6') %> <%= t('upload_cert') %> <% end %> <% end %>
<%= render 'alert' %>
<% @pkcs_list.each do |item| %> <% next if item['pkcs'].blank? %> <% end %> <% unless Docuseal.multitenant? %> <%= render 'default_signature_row' %> <% end %>
<%= t('name') %> <%= t('valid_to') %> <%= t('status') %>
<%= item['name'] %> <%= l(item['pkcs'].certificate.not_after.to_date, format: :long, locale: current_account.locale) %> <% if item['status'] == 'default' %> <%= t('default') %> <% elsif can?(:update, @encrypted_config) %> <%= button_to settings_esign_path, method: :put, params: { name: item['name'] }, class: 'btn btn-outline btn-neutral btn-xs whitespace-nowrap', title: t('make_default'), data: { turbo_confirm: t('are_you_sure_') } do %> <%= t('make_default') %> <% end %> <% end %> <% if item['name'] != EsignSettingsController::DEFAULT_CERT_NAME && item['status'] != 'default' && can?(:destroy, @encrypted_config) %> <%= button_to settings_esign_path, params: { name: item['name'] }, method: :delete, class: 'btn btn-outline btn-error btn-xs', title: t('remove'), data: { turbo_confirm: t('are_you_sure_') } do %> <%= t('remove') %> <% end %> <% end %>
<% encrypted_config = EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::TIMESTAMP_SERVER_URL_KEY) %> <% if !Docuseal.multitenant? && can?(:manage, encrypted_config) %>

<%= t('timestamp_server') %>

<%= form_for encrypted_config, url: timestamp_server_index_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4' } do |f| %>
<%= f.label :value, class: 'label' do %> <%= t('timeserver_url') %> <%= svg_icon('info_circle', class: 'w-4 h-4') %> <% end %> <%= f.url_field :value, autocomplete: 'off', class: 'base-input', placeholder: "URL (#{t('optional')})" %>
<%= f.button button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button' %>
<% end %>
<% end %> <% account_config = AccountConfig.where(account: current_account, key: AccountConfig::ESIGNING_PREFERENCE_KEY).first_or_initialize(value: 'single') %> <% if can?(:manage, account_config) %>

<%= t('preferences') %>

<% if can?(:manage, account_config) && (can?(:manage, :personalization_advanced) || !Docuseal.multitenant?) %> <%= form_for account_config, url: account_configs_path, method: :post do |f| %> <%= f.hidden_field :key %>
<%= t('apply_multiple_pdf_digital_signatures_in_the_document_per_each_signer') %> <%= f.check_box :value, { class: 'toggle', checked: account_config.value == 'multiple', onchange: 'this.form.requestSubmit()' }, 'multiple', 'single' %>
<% end %> <% end %> <% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::FLATTEN_RESULT_PDF_KEY) %> <% if can?(:manage, account_config) %> <%= form_for account_config, url: account_configs_path, method: :post do |f| %> <%= f.hidden_field :key %>
<%= t('remove_pdf_form_fillable_fields_from_the_signed_pdf_flatten_form') %> <%= f.check_box :value, { class: 'toggle', checked: account_config.value != false, onchange: 'this.form.requestSubmit()' } %>
<% end %> <% end %> <% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::DOCUMENT_FILENAME_FORMAT_KEY) %> <% if can?(:manage, account_config) %> <%= form_for account_config, url: account_configs_path, method: :post do |f| %> <%= f.hidden_field :key %>
<%= t('document_download_filename_format') %>
<%= f.select :value, [["#{I18n.t('document_name')}.pdf", '{document.name}'], ["#{I18n.t('document_name')} - #{I18n.t(:signed)}.pdf", '{document.name} - {submission.status}'], ["#{I18n.t('document_name')} - name@domain.com.pdf", '{document.name} - {submission.submitters}'], ["#{I18n.t('document_name')} - name@domain.com - #{I18n.l(Time.current.beginning_of_year.in_time_zone(current_account.timezone), format: :short)}.pdf", '{document.name} - {submission.submitters} - {submission.completed_at}']], {}, class: 'base-select', onchange: 'this.form.requestSubmit()' %>
<% end %> <% end %>
<% end %>