{extends file="config.tpl"}

{block name="content"}
<form method="POST" action="{$modulelink}&amp;page=addendum" enctype='multipart/form-data' autocomplete="off">
    <div class="row">
        <div class="col-md-12">
            <h2><i class="fas fa-plus-square"></i> Addendum</h2>

            <div class="row">
                <div class="form-group col-md-12">
                    <div class="radio">
                        <label>
                            <input type="radio" name="addendum_show" value="pdf"{if $config.addendum_show eq 'pdf'} checked{/if}>
                            Append PDF file
                        </label>
                    </div>
                    <div class="radio">
                        <label>
                            <input type="radio" name="addendum_show" value="text"{if $config.addendum_show eq 'text'} checked{/if}>
                            Append text
                        </label>
                    </div>
                    <div class="radio">
                        <label>
                            <input type="radio" name="addendum_show" value="nothing"{if !$config.addendum_show or $config.addendum_show eq 'nothing'} checked{/if}>
                            Append nothing
                        </label>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-3">
                    <h4 class="mb-3">PDF files</h4>
                    <div class="row">
                        {foreach $templates as $template}
                            <div class="col-md-12">
                                <div class="thumbnail">
                                    <a href="{$modulelink}&amp;page=preview-addendum&amp;locale={$template}" target="_blank">
                                        <img src="{$modulelink}&amp;page=thumb&amp;template={$template}&amp;thumb=1&amp;type=addendum" style="border: 1px solid #eee;">
                                    </a>
                                    <div class="caption">
                                        <h5>{$langs[$template]} <small><a href="{$modulelink}&amp;page=addendum&amp;deltpl={$template}"><i class="fas fa-trash-alt" title="Delete"></i></a></small></h5>
                                        <div class="radio">
                                            <label>
                                                <input type="radio" name="addendum_default" value="{$template}"{if $config.addendum_default eq $template} checked{/if}>
                                                Default fallback
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {/foreach}
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="thumbnail">
                                <div class="caption">
                                    <div class="form-group col-md-12">
                                        <label for="template_upload">Upload PDF file</label>
                                        <input type="file" class="form-control" name="template_upload"/>
                                    </div>
                                    <div class="form-group col-md-12">
                                        <label for="template_language">for language</label>
                                        <select class="form-control" name="template_language">
                                            {foreach $langs as $locale => $lang}
                                                <option value="{$locale}"{if $lang eq 'English'} selected{/if}>{$lang}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-9">
                    <h4 class="mb-3">
                        Text
                    </h4>
                    <div class="row">
                        <div class="form-group col-md-3">
                            <label for="addendum_position_x">Position</label>
                            <div class="input-group">
                                <span class="input-group-addon">X</span>
                                <input type="number" step="0.1" pattern="\d+" class="form-control" name="addendum_position_x" value="{$config.addendum_position_x}" required>
                                <span class="input-group-addon">mm</span>
                            </div>
                        </div>
                        <div class="form-group col-md-3">
                            <label for="addendum_position_y">&nbsp;</label>
                            <div class="input-group">
                                <span class="input-group-addon">Y</span>
                                <input type="number" step="0.1" pattern="\d+" class="form-control" name="addendum_position_y" value="{$config.addendum_position_y}" required>
                                <span class="input-group-addon">mm</span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group col-md-12">
                            <label for="addendum_text">Text</label>
                            <textarea class="tinymce form-control" rows="12" name="addendum_text">{$config.addendum_text}</textarea>
                            {include file="editor.tpl"}
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <hr class="mb-4">
                </div>
            </div>
            <hr class="mb-4">
        </div>
    </div>

    <div class="btn-group" role="group" aria-label="...">
        <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Save</button>
    </div>

</form>

{/block}
