
<style>
    .ValSpan{opacity:0}
    .Value, .Symbol{
        font-weight:700;
        font-size:250%;
        text-align:center;
        color:#000;
    }
    .nav-tabs-simple>li:after{
        background-color: #4c0870;
    }
    #CurrentStockAlert span{
        padding:10px;
    }

</style>
<script>
    // to remove many digits after the period
//    $(function () {
//        $(".ValSpan").each(function () {
//            $(this).html(AddCommas(parseFloat($.trim($(this).text())).toFixed(3))).animate({opacity: 1})
//        })
//    })
</script>
<div class="container-fluid container-fixed-lg bg-white" style="height:500px">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"> <?php print CommonLanguage::getMessage('stock_value'); ?></div>
        </div>
        <div id="CurrentStockAlert" class="alert"></div>
        <div class="col-lg-6 col-md-6 col-xs-6">
            <div class="panel panel-transparent">
                <ul class="nav nav-tabs nav-tabs-linetriangle hidden-sm hidden-xs bg-white" id="tab-3">
                    <li class="active">
                        <a data-toggle="tab" href="#Setting"><?php print CommonLanguage::getMessage('stock_setting'); ?></a>
                    </li>
                    <li>
                        <a data-toggle="tab" href="#StockValue"><?php print CommonLanguage::getMessage('stock_value'); ?></a>
                    </li>
                    <li>
                        <a data-toggle="tab" href="#CloseStock"> <?php print CommonLanguage::getMessage('close_stock'); ?></a>
                    </li>
                </ul>
                <div class="tab-content bg-white">
                    <div class="tab-pane active" id="Setting">
                        <div class="row column-seperation">
                            <div class="col-md-12">
                                <div class="col-md-6">
                                <?php if ($CanChooseMethodPrice == 0) {
                                    ?>
                                    <select required id="Method_Type" name="Method_Type" class="full-width " data-init-plugin="select2">
                                        <option > <?php print CommonLanguage::getMessage('select_method_type'); ?></option>
                                        <?php foreach ($all_Method_Type as $Method_Type): ?>
                                            <option value="<?php echo $Method_Type['Pricing_Method_ID']; ?>"><?php echo $Method_Type['Pricing_Method_Name']; ?></option>
                                    <?php endforeach; ?>
                                    </select>
                                    <div class="col-md-6">
                                <button id="SubmitMethod" class="btn btn-primary"><i class="fa fa-times-check"></i> <?php print CommonLanguage::getMessage('Save'); ?></button>
                                </div>
                                <?php } else { ?>
                                    <h4>  <?php print CommonLanguage::getMessage('default_pricing_method'); ?>:  <?php echo ($Method_Type_Name) ?></h4>
<?php } ?>
                                    </div>
                                
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane" id="StockValue">
                        <span class="Value"><?php echo Forms::DecimalNumber($viewStockValue['Stock_Value']) ?></span><span class="Symbol"> <?php echo $currency_symbol ?></span>
                    </div>
                    <div class="tab-pane" id="CloseStock">
                        <button id="ClosingStock" class="btn btn-primary"><i class="fa fa-times-circle"></i> <?php print CommonLanguage::getMessage('close_stock'); ?></button>
                    </div>
                </div>
            </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')); ?>;
    $(function () {
        new Switchery($("#ClosingStock").get(0), {color: $.Pages.getColor("primary")})
        $('#SubmitMethod').on("click", function () {
            $.ajax({
                url: "InventoryAjax/StockAjax",
                data: {Method_ID: $('#Method_Type').val()},
                method: "POST",
                complete: function (v1, v2) {
                    if (v2 == 'success' && v1.responseText == "OK") {
                        $("#CurrentStockAlert").addClass("alert-success").empty().html(Submitted_Successfully);
                    } else {
                        $("#CurrentStockAlert").addClass("alert-danger").empty().html(Failed_Submit);
                    }
                }
            })
        })
        $('#ClosingStock').on("click", function () {
            $.ajax({
                url: "InventoryAjax/StockAjax",
                data: {ClosingStock: $('#ClosingStock').val()},
                method: "POST",
                complete: function (v1, v2) {
                    if (v2 == 'success' & v1.responseText == "OK") {
                        $("#CurrentStockAlert").addClass("alert-success").empty().html(Submitted_Successfully);
                        $('#ClosingStock').addClass('disabled')
                    } else {
                        $("#CurrentStockAlert").addClass("alert-danger").empty().html(Failed_Submit);
                    }
                }
            })
        })
    })
</script>
