<html>
<body>
    <form action="/snippet/rubric/save" method="post" name="hm" id="hm" enctype="multipart/form-data" style="margin:0;padding:0;">
        <div class="panel panel-fcs-border">
            <div class="panel-heading">
                <h2 class="panel-title-fcs">Textbausteine</h2>
            </div>
            <input type="hidden" name="SnippetRubricID" id="SnippetRubricID" value="{{ $SnippetRubric->SnippetRubricID }}" />

            <div class="panel-body">
                <div class="col-lg-6 col-lg-offset-3">
                    <div class="panel panel-fcs-content">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-lg-6 text-left">
                                    <h3 class="panel-title text-left" style="font-size: 24px; display:inline">Rubrik bearbeiten</h3>
                                </div>
                                <div class="col-lg-6 text-right">
                                    <div class="btn-group">
                                        <input type="submit" id="btnSave" class="btn btn-success" value="Speichern" />
                                        <input type="button" id="btnCancel" class="btn btn-default" onclick="window.location.href = '/snippet/rubrics';" value="Zur&uuml;ck" />
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="panel-body">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="">Rubriktitel</label>
                                    <input type="text" class="form-control" name="RubricTitle" id="RubricTitle" value="{{ $SnippetRubric->Name }}" maxlength="255" />
                                </div>

                                <div class="form-group">
                                    <label for="">Beschreibung</label>
                                    <input type="text" class="form-control" name="RubricDescription" id="RubricDescription" value="{{ $SnippetRubric->Description }}" maxlength="255" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>

</body>
</html>

<script>
        function SaveSnippetRubric(ADShoppingCartArticleID) {
            $("#ADOrderCatalogError").html('');

            $.post('ordercatalog/EditArticle', {ShoppingCartArticleID: ADShoppingCartArticleID, Amount: $("#Amount_" + ADShoppingCartArticleID).val(), ArticleName: $("#ArticleName_" + ADShoppingCartArticleID).val()}, function (res) {
                if (!res.success) {
                    $("#ADOrderCatalogError").append('<h4>Fehler</h4>');
                    var keys = Object.keys(res);
                    for (var i = 0; i < keys.length; i++) {
                        res[keys[i]].forEach((message) => {
                            $("#ADOrderCatalogError").append('<li>' + message + '</li>');
                        });
                    }

                } else {
                    var newAmount = $("#Amount_" + ADShoppingCartArticleID).val();
                    var oldAmount = $("#OldAmount_" + ADShoppingCartArticleID).val();
                    var price = $("#Price_" + ADShoppingCartArticleID).val();
                    var totalPrice = $("#totalPriceInput").val();
                    var newTotalPrice = parseFloat(totalPrice) + ((parseFloat(newAmount) - parseFloat(oldAmount)) * parseFloat(price));
                    $("#totalPriceInput").val(newTotalPrice);
                    $("#OldAmount_" + ADShoppingCartArticleID).val(newAmount);
                    $("#TotalPrice").html(parseFloat(newTotalPrice).toFixed(2) + " " + res.Currency);
                }
            });
        }
</script>
