Subversion Repositories SmartDukaan

Rev

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

<section class="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header">
                <i class="icon_document_alt"></i>Manage PCM
            </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>Manage PCM</li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-10">
            <table class="table table-condensed" id="partner-pcm">
                <thead>
                <tr>
                    <th>Id</th>
                    <th>Code</th>
                    <th>Partner Name</th>
                    <th>City</th>
                    <th>State</th>
                    <th>PCM Date</th>
                </tr>
                </thead>
                <tbody>
                    #foreach($retailer in $retailerMap.values())
                    <tr>
                        <td>$retailer.getPartnerId()</td>
                        <td>$retailer.getCode()</td>
                        <td>$retailer.getBusinessName()</td>
                        <td>$retailer.getAddress().getCity()</td>
                        <td>$retailer.getAddress().getState()</td>
                        <td><input type="date" onchange="onPcmDateChanged(this)" data-id="$retailer.getPartnerId()"
                            #if($samsungPCMMap.get($retailer.getPartnerId()))
                                   value="$samsungPCMMap.get($retailer.getPartnerId())"
                            #end
                        />
                        </td>
                    </tr>
                    #end
                </tbody>
            </table>
        </div>
    </div>
</section>

<script type="text/javascript">
    $(document).ready(function () {
        $('#partner-pcm').DataTable({
            "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
        });
    });

    function onPcmDateChanged(pcmDateInput, event) {
        console.log(typeof pcmDateInput.value);
        const fofoId = $(pcmDateInput).data("id");
        if (confirm("Are you sure you want to change the PCM Date")) {
            let pcmModel = {
                fofoId: fofoId,
                pcmDate: pcmDateInput.value
            }
            doPostAjaxRequestWithJsonHandler(`${context}/brand-pcm`, JSON.stringify(pcmModel), function (response) {
                if (response) {
                    alert("Date updated Successfully");
                    window.open(`${context}/brand-pcm/download?fofoId=${fofoId}`, "_blank");
                }
            });
        } else {
            pcmDateInput.value = pcmDateInput.oldValue;
        }

    }


</script>