{extends file="config.tpl"}

{block name="content"}
<form method="POST" action="{$modulelink}&amp;page=integrations" autocomplete="off">
    <div class="row">
        <div class="col-md-12">
            <h2><i class="fas fa-puzzle-piece"></i> Integrations</h2>
            BlueRabbIT offers additional WHMCS modules that work best in combination with BestPDF.
            <hr class="mb-4">
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <h2 class="mb-3"><i class="fas fa-shipping-fast"></i> Pingen
                {if $pingen}<span class="label label-success">Detected</span>{else}<span class="label label-default">Not installed</span>{/if}
            </h2>

        {if !$pingen}
            <p>
                Pingen.com is a service that sends letters worldwide at affordable prices.
                <br/>They even support the Swiss ISR slips our <strong>SwissQR</strong> module generates.
            </p>
            <p>
                Our Pingen Addon for WHMCS can manually or automatically send PDF invoices based on configured criteria to Pingen.
                <br/>It provides a comprehensive and easy to use interface where you can manage and track all your invoices.
            </p>
            <p>Pingen.com will then proceed to print and send the invoice, and even notify you about non-deliverable mailings.</p>

            <a href="https://marketplace.whmcs.com/product/4743" target="_blank" class="btn btn-info">More information</a>
        {else}
            <div class="alert alert-info" role="alert">
                <i class="fas fa-info-circle"></i>
                BestPDF will automatically omit the sender address, the fold marks{if $swissqr} and the orange slip background{/if}
                when sending PDF files to Pingen. They will add their sender line and handle any returns.
            </div>

            <h4>Configuration check</h4>
            <ul>
                <li><a href="{$modulelink}&page=layout">Layout</a></li>
                <ul>
                    <li>
                        First page top margin: minimum 100mm
                        {if $config.margin_top_1 gte 100}
                            <i class="fas fa-check"></i>
                        {else}
                            <i class="fas fa-times"></i>
                        {/if}
                    </li>
                    <li>
                        All other margins: minimum 5mm
                        {if $config.margin_top_2 gte 5 and $config.margin_right gte 5 and $config.margin_bottom_1 gte 5 and $config.margin_bottom_2 gte 5 and $config.margin_left gte 5}
                            <i class="fas fa-check"></i>
                        {else}
                            <i class="fas fa-times"></i>
                        {/if}
                    </li>
                </ul>
                <li><a href="{$modulelink}&page=address">Address</a> (position: {$pingen_address_position})</li>
                <ul>
                    {if $pingen_address_position eq 'Right'}
                        <li>
                            Recipient position x: 118-123
                            {if $config.recipient_position_x gte 118 and $config.recipient_position_x lte 123}
                                <i class="fas fa-check"></i>
                            {else}
                                <i class="fas fa-times"></i>
                            {/if}
                        </li>
                    {else}
                        <li>
                            Recipient position x: 23-28
                            {if $config.recipient_position_x gte 23 and $config.recipient_position_x lte 28}
                                <i class="fas fa-check"></i>
                            {else}
                                <i class="fas fa-times"></i>
                            {/if}
                        </li>
                    {/if}
                    <li>
                        Recipient position y: 60-65
                        {if $config.recipient_position_y gte 60 and $config.recipient_position_y lte 65}
                            <i class="fas fa-check"></i>
                        {else}
                            <i class="fas fa-times"></i>
                        {/if}
                    </li>
                    <li>
                        Automatic address formatting (optional)
                        {if $config.recipient_format eq 'auto'}
                            <i class="fas fa-check"></i>
                        {else}
                            <i class="fas fa-times"></i>
                        {/if}
                    </li>
                </ul>
            </ul>
        {/if}

            <hr class="mb-4">

            <h2 class="mb-3"><i class="fas fa-qrcode"></i> SEPA QR
                {if $sepaqr}<span class="label label-success">Detected</span>{else}<span class="label label-default">Not installed</span>{/if}
            </h2>

            {if !$sepaqr}
                <p>SEPA QR is interesting for those with European Bank Accounts.</p>
                <p>It generates QR codes following the xyz standard, allowing customers to easily pay with their banking app.</p>
                <a href="https://marketplace.whmcs.com/product/5792" target="_blank" class="btn btn-info">More information</a>
            {else}
                <div class="alert alert-info" role="alert">
                    <i class="fas fa-info-circle"></i>
                    SEPA QR will automatically add the QR code to the PDFs if the following conditions are met:
                    <ul>
                        <li>Customer country is a SEPA member</li>
                        <li>Customer currency is EUR or CZK</li>
                        <li>Invoice balance is &gt; 0</li>
                    </ul>
                </div>

                <div class="row">
                    <div class="form-group col-md-6">
                        <label for="sepaqr_show">Show QR</label>
                        <select name="sepaqr_show" class="form-control">
                            <option value="before_text"{if $config.sepaqr_show eq 'before_text'} selected{/if}>Before invoice text</option>
                            <option value="before_items"{if $config.sepaqr_show eq 'before_items'} selected{/if}>Before invoice items</option>
                            <option value="after_summary"{if $config.sepaqr_show eq 'after_summary'} selected{/if}>After invoice summary</option>
                            <option value="after_transactions"{if $config.sepaqr_show eq 'after_transactions'} selected{/if}>After transactions</option>
                            <option value="after_notes"{if $config.sepaqr_show eq 'after_notes'} selected{/if}>After notes</option>
                            {if $swissqr}
                            <option value="like_swissqr"{if $config.sepaqr_show eq 'like_swissqr'} selected{/if}>Same as SwissQR</option>
                            {/if}
                            <option value="position"{if $config.sepaqr_show eq 'position'} selected{/if}>On first page at position X,Y</option>
                        </select>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6">
                        <label for="sepaqr_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="sepaqr_position_x" value="{$config.sepaqr_position_x}" required>
                            <span class="input-group-addon">mm</span>
                        </div>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="sepaqr_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="sepaqr_position_y" value="{$config.sepaqr_position_y}" required>
                            <span class="input-group-addon">mm</span>
                        </div>
                    </div>
                </div>
            {/if}
        </div>
        <div class="col-md-6">
            <h2 class="mb-3"><i class="fas fa-qrcode"></i> SwissQR
                {if $swissqr}<span class="label label-success">Detected</span>{else}<span class="label label-default">Not installed</span>{/if}
            </h2>

        {if !$swissqr}
            <p>
                SwissQR is interesting for those with Swiss Bank Accounts.
            </p>
            <p>
                It supports both the old ISR Orange Payment Slip and the new Swiss QR standard
                and it automatically inserts the payment slip into the PDF invoice.
            </p>
            <p>
                It also has the ability to parse camt054 xml files and automatically apply payments to the affected invoices.
            </p>

            <a href="https://marketplace.whmcs.com/product/4397" target="_blank" class="btn btn-info">More information</a>
        {else}
            <div class="alert alert-info" role="alert">
                <i class="fas fa-info-circle"></i>
                SwissQR will automatically add the invoice slip to the PDFs if the following conditions are met:
                <ul>
                    <li>Customer country is Switzerland or Liechtenstein</li>
                    <li>Customer currency is either CHF or EUR</li>
                    <li>You configured an account number for the customer's currency</li>
                </ul>
            </div>

            <div class="row">
                <div class="form-group col-md-6">
                    <label for="swissqr_slip">Show slip on</label>
                    <select name="swissqr_slip" class="form-control">
                        <option value="first"{if $config.swissqr_slip eq 'first'} selected{/if}>First page</option>
                        <option value="last"{if $config.swissqr_slip eq 'last'} selected{/if}>Last page</option>
                        <option value="extra"{if $config.swissqr_slip eq 'extra'} selected{/if}>Extra page</option>
                    </select>
                </div>
            </div>

            <div class="row">
                <div class="form-group col-md-6">
                    <label for="swissqr_separation">Show separation lines</label>
                    <select name="swissqr_separation" class="form-control">
                        <option value="always"{if $config.swissqr_separation eq 'always'} selected{/if}>Always</option>
                        <option value="noadmin"{if $config.swissqr_separation eq 'noadmin'} selected{/if}>Always except admin area</option>
                        <option value="emails"{if $config.swissqr_separation eq 'emails'} selected{/if}>In e-mails only</option>
                        <option value="never"{if $config.swissqr_separation eq 'never'} selected{/if}>Never</option>
                    </select>
                </div>
            </div>

            <h4>Configuration considerations</h4>
            <ul>
                <li>Make sure your template does not contain anything in the bottom 110mm of the {if $config.swissqr_slip eq 'first'}first{else}second{/if} page</li>
                <li>Make sure you position elements so that they do not interfere with the bottom 110mm of the page</li>
                <li>When inserting the slip, BestPDF will automatically override the bottom margin regardless of setting</li>
            </ul>
        {/if}
        </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}
