{extends "[shared]window.tpl"}

{block tabs}
    {windowTab id='flapMargins'}
{/block}

{block size}
    width = 1220;
    height = 900;
{/block}

{block tabsContent}
    <div id="flapMargins" class="tab-pane fade in boxFlex">
        <div class="panel-group panel-group-lists" data-values="margins">
            <div class="row bottom-space">
                <div class="col-md-3">
                    <a href="#" data-form-add class="btn btn-success btn-block"><span class="glyphicon glyphicon-plus"></span>&nbsp;{'buttonAdd'|translate}</a>
                </div>
                <div class="col-md-8">
                    <p>Při úpravě dbejte na správnou návaznost hranic OD-DO, přičemž DO a následné OD použijte stejnou hodnotu.
                        Například při použití hladin od 10 Kč do 50 Kč a následně od 50 Kč do 100 Kč, bude při ceně produktu 50 Kč použita první, tedy nižší hladina.</p>
                </div>

                <div class="col-md-1">
                    <a href="javascript:help('margins');"><i class="btn btn-info bi bi-question-circle"></i></a>
                </div>
            </div>

            <div class="panel">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-md-2 col-md-offset-1" style="padding-left: 0;">
                            <small><strong>{'range_from'|translate}</strong></small>
                        </div>
                        <div class="col-md-2 text-center">
                            <small><strong>{'range_to'|translate}</strong></small>
                        </div>
                        <div class="col-md-2 col-md-offset-1 text-center">
                            <small><strong>{'margin'|translate}</strong></small>
                        </div>
                        <div class="col-md-2 text-center">
                            <small><strong>{'title'|translate}</strong></small>
                        </div>
                    </div>
                </div>
            </div>

            {foreach array_merge([[]], $body.data.margins) as $key => $row}
                <div class="panel
                        {if $row.bad_down_range}row-red{else}row-green{/if}

                        " {if $key == 0}data-form-new style="display:none"{else}data-form-item{/if}>
                        <div class="row bottom-space">
                            {*<div class="col-md-1">*}
                                {*<span class="drag-drop-mover pull-right">*}
                                   {*<i class="bi bi-arrows-move handle"></i>*}
                                {*</span>*}
                            {*</div>*}
                                <div class="col-md-2 col-md-offset-1" style="padding-left: 0;">
                                    {if $row.bad_down_range}
                                        <a class="help-tip" data-toggle="tooltip"title="!! Zadaný rozsah koliduje s jiným !!"><i class="glyphicon glyphicon-warning-sign"></i></a>
                                    {/if}
                                    <input type="text" class="form-control input-sm" name="data[{$key}][range_from]" maxlength="10" value="{$row.range_from}" />
                                </div>
                                <div class="col-md-2">
                                    <input type="text" class="form-control input-sm" name="data[{$key}][range_to]" maxlength="10" value="{$row.range_to}" />
                                    {if $row.pl_range_to}
                                        <a class="help-tip" data-toggle="tooltip" title="Rozsah pro cenové hladiny: OD:{$row.pl_range_from} DO:{$row.pl_range_to} "><i class="glyphicon glyphicon-signal"></i></a>
                                    {/if}
                                </div>
                                <div class="col-md-2 col-md-offset-1">
                                    <div class="input-group">
                                    <input type="text" class="form-control input-sm" name="data[{$key}][margin]" maxlength="10" value="{$row.margin}" />
                                        <span class="input-group-addon">%</span>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <input type="text" class="form-control input-sm" name="data[{$key}][title]" maxlength="100" value="{$row.title}" />
                                </div>
                                <div class="col-md-1">
                                    <div class="btn-group">
                                        <a class="btn-sm btn btn-danger" title="{'buttonDeleteValue'|translate}" data-form-delete>
                                            <input class="hidden" type="checkbox" name="data[{$key}][delete]" />
                                            <input type="hidden" name="data[{$key}][id]" value="{$row.id}" />
                                            <span class="glyphicon glyphicon-remove"></span>
                                        </a>
                                    </div>
                                </div>
                        </div>
                </div>
            {/foreach}
        </div>
    </div>
{/block}

<script type="application/javascript">
{block onready append}
    initForm({
        selector:'[data-values=margins]'
    });
{/block}
</script>


{block buttonsLeft}
    <div class="col-md-3">
        <a href="launch.php?s={$type}.php&amp;acn=recalculateProducts" class="btn btn-block btn-warning confirm"
           title="{'recalculateProductsButtonConfirm'|translate}">{'recalculateProductsButton'|translate}</a>
    </div>
{/block}
