
<div class="container-fluid container-fixed-lg bg-white form-group">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div id="reorderAlert"></div>
            <div class="panel-title"><?php print CommonLanguage::getMessage($is_actual ? 'reorder_actual_invoices' : 'reorder_invoices'); ?></div>

            <div class="clearfix"></div>
        </div>

        <div class="panel-body">
            <div class="row m-b-10">
                <div class="col-md-3" >
                    <label><?php print CommonLanguage::getMessage('From'); ?></label>
                    <input class="from_date full-width form-control" id="from_date" name="from_date" value="<?php echo smc_session()[($is_actual ? 'start_date_act' : 'start_date')] ?>" type="text"  />
                </div>
                <div class="col-md-3" >
                    <label><?php print CommonLanguage::getMessage('first_invoice_number'); ?></label>
                    <input class="first_invoice_number  form-control" id="first_invoice_number" name="first_invoice_number" type="number"  />
                </div>
                <div class="col-md-3" >
                    <label><?php print CommonLanguage::getMessage('first_exist_nb'); ?></label><br/>
                    <input class="first_exist_nb" id="first_exist_nb" name="first_exist_nb" type="checkbox"  />
                </div>
                <?php if (smc_session()['default_setting']['sync_type'] != 2) { ?>
                    <div class="input-group  col-md-3" >
                        <button class=" btn btn-primary btn-cons m-b-10 pull-right " id="submit_reorder" style="padding-top: 10px;top: 20px;min-width:253px;" type="button"><i class="pg-form"></i> <span class="bold"><?php print CommonLanguage::getMessage('reorder_invoices'); ?></span></button>
                    </div>
                <?php } ?>
            </div>


        </div>

    </div>
</div>


<script>
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            title = <?php echo json_encode(CommonLanguage::getMessage('user_customer_list')); ?>,
            is_actual = <?php echo $is_actual; ?>;

    $(function () {
        $("#from_date").datepicker({autoclose: true});
        $("#submit_reorder").on("click", function () {
            $.ajax({
                type: 'POST',
                url: 'InventoryAjax/reorder_invoices',
                data: {
                    from_date: $("#from_date").val(),
                    is_actual: is_actual,
                    first_invoice_nb: $('#first_invoice_number').val(),
                    first_exist_nb: $('#first_exist_nb').is(':checked') == true ? 1 : 0
                },
              
                complete: function (data, vv) {
                    if (vv == "success") {
                        if (data.responseText == 'OK') {
                            $("#reorderAlert").attr("class", "alert alert-success").html(Submitted_Successfully);
                        } else {
                            $("#reorderAlert").attr("class", "alert alert-danger").html(Failed_Submit);

                        }
                    }
                }
            })

        })


    });


</script>
