Subversion Repositories SmartDukaan

Rev

Rev 30122 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<style>
    .btn:hover {
        color: grey;
        text-decoration: none;
    }

    .btn-info:hover {
        color: grey;
        text-decoration: none;
    }
</style>
<section class="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header">
                <i class="icon_document_alt"></i>Catalog Item Management
            </h3>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a
                        href="${rc.contextPath}/dashboard">Home</a></li>
                <li><i class="icon_document_alt"></i>PriceDrop</li>
                <li>
                    <button type="button" data-toggle="modal"
                            class="btn btn-sm btn-primary mk_download_pricing"
                            data-target="#addPricing">Download Pricing
                    </button>
                </li>
                <li>
                    <button type="button" data-toggle="modal" class="btn btn-sm btn-primary"
                            data-target="#addPriceModal">
                        Add/Update Pricing
                    </button>
                </li>
            </ol>
        </div>
    </div>
    <div class="form-group row">
        <div class="col-lg-6">
            <label for="typeaheaditem1">Item:</label> <input
                placeholder="Search Item" type="text" class="form-control typeahead"
                id="typeaheaditem1" name="Item" data-provide="typeahead"
                autocomplete="off">
        </div>
        <div class="col-lg-1">
            <div>&nbsp;</div>
            <button type="button" class="btn btn-primary mk_pause_button">Active/Pause</button>
        </div>

        <div class="col-lg-4">
            <div>&nbsp;</div>
            <button type="button" class="btn btn-primary mk_hotdeal_button">Add/Remove
                Hotdeals
            </button>
        </div>
    </div>
</section>
<script type="text/javascript">
    $(document).ready(function () {
        var start = moment().subtract(29, 'days');
        var end = moment();

        priceDropTable = $('#priceDrop').find('table').DataTable({
            pageLength: 20,
            order: [[5, 'desc']]
        });

        getItemAheadOptions($("#typeaheaditem"), true, function (
                selectedItem) {
            currentItem = selectedItem;
            doGetAjaxRequestHandler(context + "/item-pricing/"
                    + currentItem.itemId, function (response) {
                response = JSON.parse(response);
                $('#oldDp').html(response.dp);
                $('#oldMop').html(response.mop);
                $('#oldTp').html(response.tp);
                $('#oldNlc').html(response.nlc);
            });
        });
        getItemAheadOptions($("#typeaheaditem1"), true, function (
                selectedItem) {
            currentItem = selectedItem;
            doGetAjaxRequestHandler(context + "/item-pricing/"
                    + currentItem.itemId,
                    function (response) {
                        $('.mk_pause_button').data("id",
                                currentItem.catalogId);
                        $('.mk_pause_button').data("description",
                                currentItem.itemDescription);
                        $('.mk_hotdeal_button').data("id",
                                currentItem.catalogId);
                        $('.mk_hotdeal_button').data("description",
                                currentItem.itemDescription);

                        response = JSON.parse(response);
                        $("#mop").val(response.mop);
                        $("#mrp").val(response.mrp);
                        $("#dp").val(response.dp);
                        $("#tp").val(response.tp);
                        $('#dpValue').html("DP -" + response.dp);
                        $('#mopValue').html("MOP -" + response.mop);
                        $('#mrpValue').html("MRP -" + response.mrp);
                        $('#tpValue').html("TP -" + response.tp);
                    });
        });
        affectedDateInput = $('#affectedDate');
        affectedDateInput.daterangepicker(getSingleDatePicker());
        $("#newPriceDropModal").on('hidden.bs.modal', function () {
            $("#pdForm").trigger("reset");
        });
        $("#addPriceModal").on('hidden.bs.modal', function () {
            $("#pdForm1").trigger("reset");
        });
    });

    $(document).on('click', 'button.mk_hotdeal_button', function () {
        let clickedButton = $(this);
        let description = clickedButton.data("description");
        let catalogId = clickedButton.data("id");
        getHotdealsForItems(catalogId, 0, `Add/Remove ${description}`, function (catalogIds) {
            console.log(catalogIds);
            if (catalogIds != null) {
                bootbox.confirm(`Confirm Update ${clickedButton.data("description")}?`, function (result) {
                    if (result) {
                        coloredItems.forEach(function (item) {
                            item.hotDeals = catalogIds.indexOf(item.id + "") >= 0;
                        });
                        doPostAjaxRequestWithJsonHandler(`${context}/indent/confirm-hotdeals-pause/`, JSON.stringify(coloredItems), function (response) {
                            if (response) {
                                bootbox.alert("Item/s  Updated Successfully");
                            } else {
                                bootbox.alert("Could not pause item");
                            }
                        });
                    }
                });
            }
        });
    });
</script>