 @extends('adminlte::page') @section('content')
<?php Fun::lang();?>
<style>
    .content-wrapper{
        height: 100% !important;
    }
</style>
@include('administrator.seeting.form-add-promotion')
@include('administrator.seeting.form-edit-promotion')
<div class="modal fade bs-modal-lg" id="show-promotion" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dm modal-lg" style="width: 90%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3>Show Promotion</h3>
            </div>
            <br />
            <div class="row">
                <div class="col-sm-12" style="margin-top: 10px;">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 required control-label">Name</label>
                            <div class="col-sm-8">
                                <input type="text" name="name" class="form-control" readonly id="promotion-name-show" required>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 required control-label">Type</label>
                            <div class="col-sm-8">
                                <select name="promotion_type" readonly class="form-control select2" id="promotion-type-show">
                                    
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12" id="date-duration-show" style="margin-top:10px;">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 required control-label">From Date</label>
                            <div class="col-sm-8">
                                <input type="text" name="from_date" readonly id="promotion-form-date-show" class="form-control date_picker" required>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 required control-label">To Date</label>
                            <div class="col-sm-8">
                                <input type="text" name="to_date" readonly id="promotion-to-date-show" class="form-control date_picker" required>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12" style="padding: 5%;">
                    <table class="table table-striped table-bordered" style="width: 90%;">
                        <thead>
                        <tr>
                            <th>Product Name</th>
                            <th>Brand</th>
                            <th>Unit Cost($)</th>
                            <th>Qty</th>
                            <th>Amount($)</th>
                            <th>Qty Used</th>
                            <th width="30%">Description</th>
                        </tr>
                        </thead>
                        <tbody class="resultbody">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Promotion</a></li>
            <li><a href="#">List</a></li>
        </ul>
    </div>
</div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-page">
                        <div class="pull-left">
                            <h3>Promotion List</h3>
                        </div>
                    </div>
                    <div class="pull-right">
                        <a class="button_sm button_primary" href="javascipt:void(0)" onclick="add_promotion()" data-toggle="modal"><span class="fa fa-plus"></span>  Create New</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body table-responsive">
                        
            <table id="datatable_promotion" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>Date</th>
                        <th>Name</th>
                        <th>Amount</th>
                        <th>Promotion Type</th>
                        <th>Status</th>
                        <th>Description</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                        {!!$data!!}
                </tbody>
            </table>
        </div>
    </div>
    @endsection
    @section('js')
    <script type="text/javascript">
            function close_promotion(obj)
            {
                var id = $(obj).data("id");
                $.confirm({
                    title:'Are you sure ?',
                    content:'',
                    theme:'modern',
                    buttons:{
                        cancel:{
                            btnClass:'btn btn-warning',
                            text:'Cancel',
                            action:function () {

                            }
                        },
                        submit:{
                            btnClass:'btn btn-success',
                            text:"Submit",
                            action:function () {
                                    window.location.replace('{{route("payment-promotion.close_promotion")}}?id='+id);
                            }
                        },
                    },
                });
            }
            function delete_promotion(obj)
            {
                var id = $(obj).data("id");
                $.confirm({
                    title:'Are you sure ?',
                    content:'',
                    theme:'modern',
                    buttons:{
                        cancel:{
                            btnClass:'btn btn-primary',
                            text:'Cancel',
                            action:function () {

                            }
                        },
                        submit:{
                            btnClass:'btn btn-danger',
                            text:"Delete",
                            action:function () {
                                    window.location.replace('{{route("payment-promotion.delete")}}?id='+id);
                            }
                        },
                    },
                });
            }
            function check_qty_type_promotion_create()
            {
                var type = $("#promotion-type").val();
                var tr = $("#create-promotion-table").find("tbody").find("tr");
                
                $(tr).each(function(index,value)
                {
                    var input = $(value).find("td:eq(3)").find("input");
                    if(type==1){
                        $(input).val(1);
                        $(input).attr("readonly",true);
                    }
                    else{
                        $(input).attr("readonly",false);
                        $(input).val("");
                    }
                });
                

            }
            function check_qty_type_promotion_edit()
            {
                var type = $("#promotion-type-edit").val();
                var tr = $("#edit-promotion-table").find("tbody").find("tr");
                
                $(tr).each(function(index,value)
                {
                    var input = $(value).find("td:eq(3)").find("input");
                    if(type==1){
                        $(input).val(1);
                        $(input).attr("readonly",true);
                    }
                    else{
                        $(input).attr("readonly",false);
                        $(input).val("");
                    }
                });
                

            }
            function show(obj){
                 $("#main-spinner").show();
                var id = $(obj).data("id");
                var route = "{{route('payment-promotion.edit',":id")}}";
                route = route.replace(":id",id);
                $.ajax({
                    url:route,
                    type:"GET",
                    dataType:"JSON",
                    success:function (data) {
                        $("#main-spinner").hide();
                        $("#promotion-name-show").val(data['promotion'].name);

                        if(Number(data['promotion'].promotion_type)==1){

                            var from_date = data['promotion'].from_date.split('-')[2]+'-'+data['promotion'].from_date.split('-')[1]+'-'+data['promotion'].from_date.split('-')[0];
                            var to_date = data['promotion'].to_date.split('-')[2]+'-'+data['promotion'].to_date.split('-')[1]+'-'+data['promotion'].to_date.split('-')[0];
                            $("#date-duration-show").empty();
                            $("#date-duration-show").append(`<div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">From Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="from_date" id="promotion-form-date-edit" value="${from_date}" class="form-control date_picker" readonly required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">To Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="to_date" id="promotion-to-date-edit" value="${to_date}" class="form-control date_picker" readonly required>
                                                                    </div>
                                                                </div>
                                                            </div>`);
                            $(".date_picker").datepicker({
                                dateFormat: "dd-mm-yy",
                                changeMonth: true,
                                changeYear: true,
                            });
                            $("#promotion-type-show").empty();
                            $("#promotion-type-show").append(`
                                    <option value="1" selected>Promotion By Duration</option>
                            `);
                        }
                        else{
                            $("#date-duration-show").empty();
                            var from_date = data['promotion'].from_date.split('-')[2]+'-'+data['promotion'].from_date.split('-')[1]+'-'+data['promotion'].from_date.split('-')[0];
                            $("#date-duration-show").empty();
                            $("#date-duration-show").append(`<div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">From Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="from_date" id="promotion-form-date-edit" value="${from_date}" class="form-control date_picker" readonly required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            `);
                            $(".date_picker").datepicker({
                                dateFormat: "dd-mm-yy",
                                changeMonth: true,
                                changeYear: true,
                            });
                             $("#promotion-type-show").empty();
                            $("#promotion-type-show").append(`
                                    <option value="2" selected>Promotion By Quantities</option>
                            `);
                            
                        }

                        var tr=``;
                        $.each(data['promotion_detail'],function (index,val) {
                            if(index==0){
                                tr+=`<tr class="tr-promotion-edit">
                                        <td><input type="hidden"  name="detail_id[]" readonly value="${val.id}"><input type="text" name="product_name[]" class="form-control" readonly placeholder="Product Name" value="${val.product_name}"></td>
                                        <td><input type="text" readonly name="product_brand[]" class="form-control" placeholder="Product Brand" value="${val.product_brand==null?"":val.product_brand}"></td>
                                        <td><input type="text" readonly name="product_cost[]" class="form-control number-only input-cost-edit" placeholder="Product Cost" value="${val.product_cost}"></td>
                                        <td><input type="text" readonly name="qty[]" class="form-control number-only input-qty-edit" placeholder="Qty" onkeyup="edit_calculate_amount(this)" value="${val.qty}"></td>
                                        <td><input type="text" readonly name="product_amount[]" class="form-control number-only input-amount-edit" placeholder="Amount" readonly value="${val.product_amount}"></td>
                                        <td><input type="text" name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used"  value="${val.qty_used}"  readonly></td>
                                        <td><textarea class='form-control' readonly>${val.description==null?"":val.description}</textarea></td>
                                    </tr>`;

                            }else{
                                
                                tr+=`<tr class="tr-promotion-edit">
                                        <td><input type="hidden" readonly name="detail_id[]" value="${val.id}"><input type="text" name="product_name[]" class="form-control" readonly placeholder="Product Name" value="${val.product_name}"></td>
                                        <td><input type="text" readonly name="product_brand[]" class="form-control" placeholder="Product Brand" value="${val.product_brand==null?"":val.product_brand}"></td>
                                        <td><input type="text" readonly name="product_cost[]" class="form-control number-only input-cost-edit" placeholder="Product Cost" value="${val.product_cost}"></td>
                                        <td><input type="text" readonly name="qty[]" class="form-control number-only input-qty-edit" onkeyup="edit_calculate_amount(this)" placeholder="Qty" value="${val.qty}"></td>
                                        <td><input type="text" readonly name="product_amount[]" class="form-control number-only input-amount-edit" placeholder="Amount" value="${val.product_amount}"></td>
                                        <td><input type="text" readonly name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used" value="${val.qty_used}" readonly></td>
                                        <td><textarea class='form-control' readonly>${val.description==null?"":val.description}</textarea></td>
                                    </tr>`;
                            }
                        });
                        $("#show-promotion").modal("show");
                        $(".resultbody").empty();
                        $(".resultbody").append(tr);
                    },
                    error:function () {

                    }
                });
            }
            $(document).on("change","#promotion-type",function(){
                check_qty_type_promotion_create();
                if($(this).val()==1){
                    $("#date-duration").html(`
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label class="col-sm-4 required control-label">From Date</label>
                                <div class="col-sm-8">
                                    <input type="text" name="from_date" class="form-control date_picker"required>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label class="col-sm-4 required control-label">To Date</label>
                                <div class="col-sm-8">
                                    <input type="text" name="to_date" class="form-control date_picker"required>
                                </div>
                            </div>
                        </div>
                    `);
                    $(".date_picker").datepicker();
                }
                else  {
                    $("#date-duration").html(`
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label class="col-sm-4 required control-label">From Date</label>
                                <div class="col-sm-8">
                                    <input type="text" name="from_date" class="form-control date_picker"required>
                                </div>
                            </div>
                        </div>
                        
                    `);
                    $(".date_picker").datepicker();
                }
            });
            function add_promotion() {
                $("#create-promotion").modal("show");
                $(".input-cost").val("");
                $(".input-qty").val("");
                $(".input-amount").val("");
                $("#total-amount-promotion").val("");
            }
            $(document).on("change","#promotion-type-edit",function(){
                check_qty_type_promotion_edit();
                if($(this).val()==1){
                    $("#date-duration-edit").show();
                    if($("#date-duration-edit").text()==""){
                         $("#date-duration-edit").append(`<div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">From Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="from_date" id="promotion-form-date-edit" class="form-control date_picker" required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">To Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="to_date" id="promotion-to-date-edit" class="form-control date_picker" required>
                                                                    </div>
                                                                </div>
                                                            </div>`);
                            $(".date_picker").datepicker({
                                dateFormat: "dd-mm-yy",
                                changeMonth: true,
                                changeYear: true,
                            });
                    }
                }
                else{
                    $("#date-duration-edit").html(`<div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label class="col-sm-4 required control-label">From Date</label>
                                                                <div class="col-sm-8">
                                                                    <input type="text" name="from_date" id="promotion-form-date-edit" class="form-control date_picker" required>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        `);
                        $(".date_picker").datepicker({
                            dateFormat: "dd-mm-yy",
                            changeMonth: true,
                            changeYear: true,
                        });

                }

            });
            function edit(obj)
            {
                $("#main-spinner").show();
                var id = $(obj).data("id");
                var route = "{{route('payment-promotion.edit',":id")}}";
                route = route.replace(":id",id);
                $.ajax({
                    url:route,
                    type:"GET",
                    dataType:"JSON",
                    success:function (data) {
                        $("#main-spinner").hide();
                        $("#promotion-id").val(id);
                        $("#promotion-name-edit").val(data['promotion'].name);

                        if(Number(data['promotion'].promotion_type)==1){

                            var from_date = data['promotion'].from_date.split('-')[2]+'-'+data['promotion'].from_date.split('-')[1]+'-'+data['promotion'].from_date.split('-')[0];
                            var to_date = data['promotion'].to_date.split('-')[2]+'-'+data['promotion'].to_date.split('-')[1]+'-'+data['promotion'].to_date.split('-')[0];
                            $("#date-duration-edit").empty();
                            $("#date-duration-edit").append(`<div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">From Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="from_date" id="promotion-form-date-edit" value="${from_date}" class="form-control date_picker" required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">To Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="to_date" id="promotion-to-date-edit" value="${to_date}" class="form-control date_picker" required>
                                                                    </div>
                                                                </div>
                                                            </div>`);
                            $(".date_picker").datepicker({
                                dateFormat: "dd-mm-yy",
                                changeMonth: true,
                                changeYear: true,
                            });
                            $("#promotion-type-edit").empty();
                            $("#promotion-type-edit").append(`
                                    <option value="2">Promotion By Quantities</option>
                                    <option value="1" selected>Promotion By Duration</option>
                            `);
                        }
                        else{
                            var from_date = data['promotion'].from_date.split('-')[2]+'-'+data['promotion'].from_date.split('-')[1]+'-'+data['promotion'].from_date.split('-')[0];
                            
                            $("#date-duration-edit").empty();
                            $("#date-duration-edit").append(`<div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label class="col-sm-4 required control-label">From Date</label>
                                                                    <div class="col-sm-8">
                                                                        <input type="text" name="from_date" id="promotion-form-date-edit" value="${from_date}" class="form-control date_picker" required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            `);
                            $(".date_picker").datepicker({
                                dateFormat: "dd-mm-yy",
                                changeMonth: true,
                                changeYear: true,
                            });
                             $("#promotion-type-edit").empty();
                            $("#promotion-type-edit").append(`
                                    <option value="2" selected>Promotion By Quantities</option>
                                    <option value="1">Promotion By Duration</option>
                            `);
                            
                        }

                        var tr=``;
                        $.each(data['promotion_detail'],function (index,val) {

                            if(index==0){
                                tr+=`<tr class="tr-promotion-edit">
                                        <td><input type="hidden" name="detail_id[]" value="${val.id}"><input type="text" name="product_name[]" class="form-control" placeholder="Product Name" value="${val.product_name}"></td>
                                        <td><input type="text" name="product_brand[]" class="form-control" placeholder="Product Brand" value="${val.product_brand==null?"":val.product_brand}"></td>
                                        <td><input type="text" name="product_cost[]" class="form-control number-only input-cost-edit" placeholder="Product Cost" value="${val.product_cost}"></td>
                                        <td><input type="text" name="qty[]" class="form-control number-only input-qty-edit" placeholder="Qty" onkeyup="edit_calculate_amount(this)" value="${val.qty}"></td>
                                        <td><input type="text" name="product_amount[]" class="form-control number-only input-amount-edit" placeholder="Amount" value="${val.product_amount}"></td>
                                        <td><input type="text" name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used"  value="${val.qty_used}"  readonly></td>
                                        <td>
                                            <textarea name="description_detail[]" class="form-control description-edit" placeholder="Description">${val.description==null?"":val.description}</textarea>
                                        </td>
                                        <td><span class="btn btn-sm btn-primary" id="add-new-product-edit"><i class="fa fa-plus"></i></span></td>
                                    </tr>`;

                            }else{
                                if(val.qty_used>0){
                                    var button_remove=`<span class="btn btn-sm btn-danger" disabled onclick="#"><i class="fa fa-remove"></i></span>`;
                                }else{
                                    var button_remove=`<span class="btn btn-sm btn-danger" onclick="$(this).closest('tr').remove()"><i class="fa fa-remove"></i></span>`;
                                }
                                
                                tr+=`<tr class="tr-promotion-edit">
                                        <td><input type="hidden" name="detail_id[]" value="${val.id}"><input type="text" name="product_name[]" class="form-control" placeholder="Product Name" value="${val.product_name}"></td>
                                        <td><input type="text" name="product_brand[]" class="form-control" placeholder="Product Brand" value="${val.product_brand==null?"":val.product_brand}"></td>
                                        <td><input type="text" name="product_cost[]" class="form-control number-only input-cost-edit" placeholder="Product Cost" value="${val.product_cost}"></td>
                                        <td><input type="text" name="qty[]" class="form-control number-only input-qty-edit" onkeyup="edit_calculate_amount(this)" placeholder="Qty" value="${val.qty}"></td>
                                        <td><input type="text" name="product_amount[]" class="form-control number-only input-amount-edit" placeholder="Amount" value="${val.product_amount}"></td>
                                        <td><input type="text" name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used" value="${val.qty_used}" readonly></td>
                                        <td>
                                            <textarea name="description_detail[]" class="form-control description-edit" placeholder="Description">${val.description==null?"":val.description}
                                                </textarea>
                                        </td>
                                        <td>${button_remove}</td>
                                    </tr>`;
                            }
                        });
                        $("#edit-promotion").modal("show");
                        $(".resultbody").empty();
                        $(".resultbody").append(tr);

                        var type = $("#promotion-type-edit").val();
                        var tr = $("#edit-promotion-table").find("tbody").find("tr");
                        
                        $(tr).each(function(index,value)
                        {
                            var input = $(value).find("td:eq(3)").find("input");
                            if(type==1){
                                $(input).val(1);
                                $(input).attr("readonly",true);
                            }
                            else{
                                $(input).attr("readonly",false);
                            }
                        });
                    },
                    error:function () {

                    }
                });
            }
            $(document).on("click","#add-new-product-edit",function () {
                var tr=`<tr class="tr-promotion-edit">
                            <td><input type="text" name="product_name[]" class="form-control" placeholder="Product Name"></td>
                            <td><input type="text" name="product_brand[]" class="form-control" placeholder="Product Brand"></td>
                            <td><input type="text" name="product_cost[]" class="form-control number-only input-cost-edit" placeholder="Product Cost"></td>
                            <td><input type="text" name="qty[]" class="form-control number-only input-qty-edit" placeholder="Qty" onkeyup="edit_calculate_amount(this)"></td>
                            <td><input type="text" name="product_amount[]" class="form-control number-only input-amount-edit" placeholder="Amount"></td>
                            <td><input type="text" name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used" value="0" readonly></td>
                            <td>
                                <textarea name="description_detail[]" class="form-control description-edit" placeholder="Description"></textarea>
                            </td>
                            <td><span class="btn btn-sm btn-danger" onclick="$(this).closest('tr').remove()"><i class="fa fa-remove"></i></span></td>
                        </tr>`;
                $(".resultbody").append(tr);
                
                var type = $("#promotion-type-edit").val();
                var tr = $("#edit-promotion-table").find("tbody").find("tr");
                
                $(tr).each(function(index,value)
                {
                    var input = $(value).find("td:eq(3)").find("input");
                    if(type==1){
                        $(input).val(1);
                        $(input).attr("readonly",true);
                    }
                    else{
                        $(input).attr("readonly",false);
                    }
                });
            });
            function edit_calculate_amount(obj){
                var unit_cost = Number($(obj).closest('tr').find('td:eq(2)').find('input').val());
                var amount = 0;var total_amount = 0;var qty=0;
                if(unit_cost==0 || isNaN(unit_cost) || unit_cost=="" || unit_cost == null){
                    alert("Please input Unit Cost !");$(obj).val(0);
                }else{
                    qty = Number($(obj).val());
                    amount = qty*unit_cost;
                    $(obj).closest('tr').find('td:eq(4)').find('input').val(amount);
                }
                console.log(amount);
                $(".tr-promotion-edit").each(function () {

                    total_amount = total_amount + Number($(this).find('td:eq(4)').find('input').val());
                    console.log("1/"+Number($(this).find('td:eq(4)').find('input').val()));
                    console.log("2/"+total_amount);
                });
                $(".input-total-amount-edit").val(total_amount);
            }

            $(document).on("keyup",".input-qty",function () {
                var unit_cost = Number($(this).closest('tr').find('td:eq(2)').find('input').val());
                var amount = 0;var total_amount = 0;var qty=0;
                console.log(unit_cost);
                if(unit_cost==0 || isNaN(unit_cost) || unit_cost=="" || unit_cost == null){
                    alert("Please input Unit Cost !");$(this).val(0);
                }else{
                    qty = Number($(this).val());
                    amount = qty*unit_cost;
                    $(this).closest('tr').find('td:eq(4)').find('input').val(amount);
                }
                $(".input-qty").each(function () {
                    total_amount += Number($(this).closest('tr').find('td:eq(4)').find('input').val());
                });
                $(".input-total-amount").val(total_amount);
            });
            $(document).ready(function() {
                $('.main-spinner').show();
                $('#datatable_promotion').DataTable();
            });
            $(document).on("click","#add-new-product",function () {
                var tr=`<tr>
                            <td><input type="text" name="product_name[]" class="form-control" placeholder="Product Name"></td>
                            <td><input type="text" name="product_brand[]" class="form-control" placeholder="Product Brand"></td>
                            <td><input type="text" name="product_cost[]" class="form-control number-only input-cost" placeholder="Product Cost"></td>
                            <td><input type="text" name="qty[]" class="form-control number-only input-qty" placeholder="Qty"></td>
                            <td><input type="text" name="product_amount[]" class="form-control number-only input-amount" placeholder="Amount"></td>
                            <td><input type="text" name="qty_used[]" class="form-control number-only qty-used" placeholder="Qty Used" value="0" readonly></td>
                            <td>
                                <textarea name="description_detail[]" class="form-control description-add" placeholder="Description"></textarea>
                            </td>
                            <td><span class="btn btn-sm btn-danger" onclick="$(this).closest('tr').remove()"><i class="fa fa-remove"></i></span></td>
                        </tr>`;
                $(".resultbody").append(tr);
                check_qty_type_promotion_create();
            });
    </script>
    @endsection
<style>
    .modal-lg {
        width: 800px;
    }
</style>