{extends file="config.tpl"}

{block name="content"}
<form method="POST" action="{$modulelink}&amp;page=address" autocomplete="off">
    <div class="row">
        <div class="col-md-12">
            <h2><i class="fas fa-address-card"></i> Address box</h2>
            <div class="alert alert-info" role="alert">
                We recommend configuring this so that you can place printed invoices in windowed envelopes for snail mail.
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <h4 class="mb-3">Sender</h4>

            <div class="row">
                <div class="form-group col-md-12">
                    <label for="sender_address">Sender address line</label>
                    <input type="text" class="form-control" name="sender_address" value="{$config.sender_address}">
                    <span class="text-muted">Should be placed in the top part of the envelope address window</span>
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-6 col-lg-4">
                    <label for="sender_font_family">Font family</label>
                    <select name="sender_font_family" class="form-control">
                        {foreach $fonts as $fontFile => $fontName}
                            <option value="{$fontFile}"{if $config.sender_font_family eq $fontFile} selected{/if}>{$fontName}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="form-group col-md-6 col-lg-3">
                    <label for="sender_font_style">Style</label>
                    <select class="form-control" name="sender_font_style">
                        <option value=""{if $config.sender_font_style eq ''} selected{/if}>Plain</option>
                        <option value="B"{if $config.sender_font_style eq 'B'} selected{/if}>Bold</option>
                        <option value="I"{if $config.sender_font_style eq 'I'} selected{/if}>Italic</option>
                        <option value="U"{if $config.sender_font_style eq 'U'} selected{/if}>Underline</option>
                    </select>
                </div>
                <div class="form-group col-md-6 col-lg-3">
                    <label for="sender_font_size">Size</label>
                    <div class="input-group">
                        <input type="number" pattern="\d+" class="form-control" name="sender_font_size" value="{$config.sender_font_size}" required>
                        <span class="input-group-addon">pt</span>
                    </div>
                </div>
                <div class="form-group col-md-6 col-lg-2">
                    <label for="sender_font_color">Color</label>
                    <input type="color" class="form-control" name="sender_font_color" value="{$config.sender_font_color}">
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-6">
                    <label for="sender_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="sender_position_x" value="{$config.sender_position_x}" required>
                        <span class="input-group-addon">mm</span>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="sender_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="sender_position_y" value="{$config.sender_position_y}" required>
                        <span class="input-group-addon">mm</span>
                    </div>
                </div>
            </div>

            <h4 class="mb-3">Recipient</h4>

            <div class="row">
                <div class="form-group col-md-5">
                    <label for="recipient_font_family">Font family</label>
                    <select name="recipient_font_family" class="form-control">
                        {foreach $fonts as $fontFile => $fontName}
                            <option value="{$fontFile}"{if $config.recipient_font_family eq $fontFile} selected{/if}>{$fontName}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="form-group col-md-4">
                    <label for="recipient_font_size">Size</label>
                    <div class="input-group">
                        <input type="number" pattern="\d+" class="form-control" name="recipient_font_size" value="{$config.recipient_font_size}" required>
                        <span class="input-group-addon">pt</span>
                    </div>
                </div>
                <div class="form-group col-md-3">
                    <label for="recipient_font_color">Color</label>
                    <input type="color" class="form-control" name="recipient_font_color" value="{$config.recipient_font_color}">
                </div>
                <div class="form-group col-md-6">
                    <label for="recipient_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="recipient_position_x" value="{$config.recipient_position_x}" required>
                        <span class="input-group-addon">mm</span>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="recipient_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="recipient_position_y" value="{$config.recipient_position_y}" required>
                        <span class="input-group-addon">mm</span>
                    </div>
                </div>
                <div class="form-group col-md-7">
                    <label for="">Show client name</label>
                    <select class="form-control" name="recipient_client_show">
                        <option value="always"{if $config.recipient_client_show eq 'always'} selected{/if}>Always</option>
                        <option value="company"{if $config.recipient_client_show eq 'company'} selected{/if}>When no Company</option>
                        <option value="address2"{if $config.recipient_client_show eq 'address2'} selected{/if}>When no Company or no Address2</option>
                    </select>
                </div>
                <div class="form-group col-md-5">
                    <label for="address_truncate">Truncate each line after</label>
                    <div class="input-group">
                        <input type="number" pattern="\d+" class="form-control" name="address_truncate" value="{$config.address_truncate}" required>
                        <span class="input-group-addon">characters</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <h4 class="mb-3">Address formatting</h4>

            <div class="row">
                <div class="form-group col-md-12">
                    <div class="radio">
                        <label>
                            <input type="radio" name="recipient_format" value="auto"{if $config.recipient_format eq 'auto'} checked{/if}>
                            Automatic (depending on recipient country)
                        </label>
                    </div>
                    <div class="radio">
                        <label>
                            <input type="radio" name="recipient_format" value="normal"{if $config.recipient_format eq 'normal'} checked{/if}>
                            As defined below
                        </label>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    <table class="table">
                        <tr>
                            <td style="vertical-align: bottom;">Line</td>
                            <td style="vertical-align: bottom; writing-mode: vertical-lr;">Plain</td>
                            <td style="vertical-align: bottom; writing-mode: vertical-lr;"><strong>Bold</strong></td>
                            <td style="vertical-align: bottom; writing-mode: vertical-lr;"><em>Italic</em></td>
                            <td style="vertical-align: bottom; writing-mode: vertical-lr;"><span style="text-decoration: underline;">Underline</span></td>
                            <td style="vertical-align: bottom; writing-mode: vertical-lr;">ALL CAPS</td>
                        </tr>
                        <tr>
                            <th>Company name</th>
                            <td><input type="radio" name="recipient_company_font_style" value=""{if $config.recipient_company_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_company_font_style" value="B"{if $config.recipient_company_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_company_font_style" value="I"{if $config.recipient_company_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_company_font_style" value="U"{if $config.recipient_company_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_company_font_caps" value="true"{if $config.recipient_company_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                        <tr>
                            <th>Client name</th>
                            <td><input type="radio" name="recipient_name_font_style" value=""{if $config.recipient_name_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_name_font_style" value="B"{if $config.recipient_name_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_name_font_style" value="I"{if $config.recipient_name_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_name_font_style" value="U"{if $config.recipient_name_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_name_font_caps" value="true"{if $config.recipient_name_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                        <tr>
                            <th>Address 1</th>
                            <td><input type="radio" name="recipient_address1_font_style" value=""{if $config.recipient_address1_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address1_font_style" value="B"{if $config.recipient_address1_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address1_font_style" value="I"{if $config.recipient_address1_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address1_font_style" value="U"{if $config.recipient_address1_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_address1_font_caps" value="true"{if $config.recipient_address1_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                        <tr>
                            <th>Address 2</th>
                            <td><input type="radio" name="recipient_address2_font_style" value=""{if $config.recipient_address2_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address2_font_style" value="B"{if $config.recipient_address2_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address2_font_style" value="I"{if $config.recipient_address2_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_address2_font_style" value="U"{if $config.recipient_address2_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_address2_font_caps" value="true"{if $config.recipient_address2_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                        <tr>
                            <th>City</th>
                            <td><input type="radio" name="recipient_city_font_style" value=""{if $config.recipient_city_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_city_font_style" value="B"{if $config.recipient_city_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_city_font_style" value="I"{if $config.recipient_city_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_city_font_style" value="U"{if $config.recipient_city_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_city_font_caps" value="true"{if $config.recipient_city_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                        <tr>
                            <th>Country</th>
                            <td><input type="radio" name="recipient_country_font_style" value=""{if $config.recipient_country_font_style eq ''} checked{/if}/></td>
                            <td><input type="radio" name="recipient_country_font_style" value="B"{if $config.recipient_country_font_style eq 'B'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_country_font_style" value="I"{if $config.recipient_country_font_style eq 'I'} checked{/if}/></td>
                            <td><input type="radio" name="recipient_country_font_style" value="U"{if $config.recipient_country_font_style eq 'U'} checked{/if}/></td>
                            <td><input type="checkbox" name="recipient_country_font_caps" value="true"{if $config.recipient_country_font_caps eq 'true'} checked{/if}/></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="row">

                <div class="form-group col-md-6">
                    <label for="">Client format</label>
                    <select class="form-control" name="recipient_client_format">
                        <option value="fl"{if $config.recipient_client_format eq 'fl'} selected{/if}>First Last</option>
                        <option value="afl"{if $config.recipient_client_format eq 'afl'} selected{/if}>Attn: First last (if company)</option>
                    </select>
                </div>
                <div class="form-group col-md-6">
                    <label for="">City format</label>
                    <select class="form-control" name="recipient_city_show">
                        <option value="p-z c"{if $config.recipient_city_show eq 'p-z c'} selected{/if}>Country code-ZIP City</option>
                        <option value="z c"{if $config.recipient_city_show eq 'z c'} selected{/if}>ZIP City</option>
                        <option value="z c s"{if $config.recipient_city_show eq 'z c s'} selected{/if}>ZIP City State</option>
                        <option value="z c (s)"{if $config.recipient_city_show eq 'z c (s)'} selected{/if}>ZIP City (State)</option>
                        <option value="c z"{if $config.recipient_city_show eq 'c z'} selected{/if}>City ZIP</option>
                        <option value="c s z"{if $config.recipient_city_show eq 'c s z'} selected{/if}>City State ZIP</option>
                        <option value="c, s, z"{if $config.recipient_city_show eq 'c, s, z'} selected{/if}>City, State, ZIP</option>
                    </select>
                </div>
                <div class="form-group col-md-6">
                    <label for="recipient_country_show">Show country</label>
                    <select class="form-control" name="recipient_country_show">
                        <option value="always"{if $config.recipient_country_show eq 'always'} selected{/if}>Always</option>
                        <option value="nodefault"{if $config.recipient_country_show eq 'nodefault'} selected{/if}>Hide for {$defaultCountry}</option>
                        <option value="never"{if $config.recipient_country_show eq 'never'} selected{/if}>Never</option>
                    </select>
                </div>

            </div>
        </div>
        <div class="col-md-12">
            <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}
