<?php $__env->startSection('content'); ?>

  <title><?php echo e(trans('admin.ExecutingandReceiving')); ?></title>


                <main id="js-page-content" role="main" class="page-content">
                    <ol class="breadcrumb page-breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0);"><?php echo e(trans('admin.Manufacturing')); ?></a></li>
                        <li class="breadcrumb-item active"> <?php echo e(trans('admin.ExecutingandReceiving')); ?></li>
                <li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
                    </ol>
                    <div class="row">
                        <div class="col-xl-12">
                            <div id="panel-1" class="panel">
                                <div class="panel-hdr">
                                   <h2>
<?php echo e(trans('admin.ExecutingandReceiving')); ?>

                                </h2>

                                    <div class="panel-toolbar">

                                        <button class="btn btn-primary btn-sm" data-toggle="dropdown">Table
                                            Style</button>
                                        <?php echo $__env->make('admin.layouts.toolbar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                    </div>


                                </div>
                                <div class="panel-container show">
                                             <span id="ex"> <?php echo $__env->make('admin.layouts.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?></span>
                                    <div class="panel-content">

                              <form action="<?php echo e(url('AddExecutingReceiving')); ?>" method="post" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>

                              <?php echo view('honeypot::honeypotFormFields'); ?>
                            <div class="modal-body">

                               <div class="row">
                                <div class="form-group col-lg-2">
                                    <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Code')); ?></label>
                                    <input type="text"  value="<?php echo e($Code); ?>" disabled class="form-control">
                                    <input type="hidden" name="Code"  value="<?php echo e($Code); ?>">
                                </div>
                                <div class="form-group col-lg-2">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Date')); ?></label>
                                    <input type="date" name="Date" value="<?php echo e(date('Y-m-d')); ?>" class="form-control" required>
                                </div>

                                    <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.ManufacturingModel')); ?></label>
                                            <select class="select2 form-control w-100" id="model" name="Model" required>
                                <option value="<?php echo e($Model->id); ?>" selected>

                                             <?php echo e(app()->getLocale() == 'ar' ?$Model->Name :$Model->NameEn); ?>

                                                </option>
                                            </select>
                                        </div>

                                <div class="form-group col-lg-2">
                                    <label class="form-label" for=""> <?php echo e(trans('admin.Qty')); ?> </label>
                        <input type="number" step="any" onclick="ChangePrice()" onkeyup="ChangePrice()"  name="Qtyy"  id="Qty" value="<?php echo e(old('Qty')); ?>" class="form-control" required>

                                </div>

                                        <div class="form-group col-lg-2">
                                    <label class="form-label" for=""> <?php echo e(trans('admin.Total_Cost')); ?> </label>
                        <input type="text"  id="Total" value="<?php echo e(old('Total')); ?>" class="form-control" disabled>
                            <input type="hidden"  id="TotalHide">
                            <input type="hidden" name="Totall"  id="OriginalTotalHide">
                                </div>

                                              <div class="form-group col-lg-2">
                                    <label class="form-label" for=""> <?php echo e(trans('admin.Name_Outcome')); ?> </label>
    <input type="text"  name="Name_Outcome"  id="Name_Outcome" value="<?php echo e(old('Name_Outcome')); ?>" class="form-control" disabled>
                                </div>
                            <input type="hidden" id="count">
                       <table class="table table-bordered table-hover table-striped " >
                                            <thead class="bg-highlight">
                                                <tr>
                                                    <th><?php echo e(trans('admin.Code')); ?></th>
                                                    <th><?php echo e(trans('admin.Name')); ?></th>
                                                    <th> <?php echo e(trans('admin.Store_Qty')); ?></th>
                                                    <th> <?php echo e(trans('admin.Depreciation')); ?></th>
                                                    <th> <?php echo e(trans('admin.Qty')); ?></th>
                                                    <th> <?php echo e(trans('admin.Store')); ?></th>
                                                    <th> <?php echo e(trans('admin.Unit')); ?></th>
                                                    <th> <?php echo e(trans('admin.Actions')); ?></th>
                                                </tr>
                                            </thead>
                                            <tbody class="Data">

                                            </tbody>
                                        </table>
                               </div>
                            </div>
                            <div class="modal-footer">
                                <button type="submit" id="submit" class="btn btn-primary"><?php echo e(trans('admin.Save')); ?></button>
                            </div>
                        </form>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </main>



<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
   <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/datagrid/datatables/datatables.bundle.css')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/summernote/summernote.css')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/select2/select2.bundle.css')); ?>">

 <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.export.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.bundle.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/formplugins/summernote/summernote.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/formplugins/select2/select2.bundle.js')); ?>"></script>
    <script>
        //_fnFeatureHtmlLength();
        $(document).ready(function () {
            // Setup - add a text input to each footer cell
            $('#dt-basic-example thead tr').clone(true).appendTo('#dt-basic-example thead');
            $('#dt-basic-example thead tr:eq(1) th').each(function (i) {
                var title = $(this).text();
                $(this).html('<input type="text" class="form-control form-control-sm" placeholder="Search ' + '" />');

                $('input', this).on('keyup change', function () {
                    if (table.column(i).search() !== this.value) {
                        table
                            .column(i)
                            .search(this.value)
                            .draw();
                    }
                });
            });
            var table = $('#dt-basic-example').DataTable(
                {
                    // responsive: true,
                    orderCellsTop: true,
                    fixedHeader: true,
                    lengthChange: true,

                    dom: "<'row mb-3'<'col-sm-12 col-md-3 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-9 d-flex align-items-center justify-content-end'B>>" +
                        "<'row'<'col-sm-12'tr>>" +
                        "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",

                    buttons: [
                        {
                            extend: 'pageLength',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'colvis',
                            text: 'Column Visibility',
                            titleAttr: 'Col visibility',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'pdfHtml5',
                            text: 'PDF',
                            titleAttr: 'Generate PDF',
                            className: 'btn-outline-danger btn-sm mr-1'
                        },
                        {
                            extend: 'excelHtml5',
                            text: 'Excel',
                            titleAttr: 'Generate Excel',
                            className: 'btn-outline-success btn-sm mr-1'
                        },
                        {
                            extend: 'csvHtml5',
                            text: 'CSV',
                            titleAttr: 'Generate CSV',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'copyHtml5',
                            text: 'Copy',
                            titleAttr: 'Copy to clipboard',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'print',
                            text: 'Print',
                            titleAttr: 'Print Table',
                            className: 'btn-outline-primary btn-sm'
                        }
                    ],
                });
            $('.js-thead-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example thead').removeClassPrefix('bg-').addClass(theadColor);
            });

            $('.js-tbody-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example').removeClassPrefix('bg-').addClass(theadColor);
            });

        });

    </script>
     <script>
        var autoSave = $('#autoSave');
        var interval;
        var timer = function()
        {
            interval = setInterval(function()
            {
                //start slide...
                if (autoSave.prop('checked'))
                    saveToLocal();

                clearInterval(interval);
            }, 3000);
        };

        //save
        var saveToLocal = function()
        {
            localStorage.setItem('summernoteData', $('#saveToLocal').summernote("code"));
            console.log("saved");
        }

        //delete
        var removeFromLocal = function()
        {
            localStorage.removeItem("summernoteData");
            $('#saveToLocal').summernote('reset');
        }

        $(document).ready(function()
        {
            //init default
            $('.js-summernote').summernote(
            {
                height: 200,
                tabsize: 2,
                placeholder: "Type here...",
                dialogsFade: true,
                toolbar: [
                    ['style', ['style']],
                    ['font', ['strikethrough', 'superscript', 'subscript']],
                    ['font', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']]
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
                callbacks:
                {
                    //restore from localStorage
                    onInit: function(e)
                    {
                        $('.js-summernote').summernote("code", localStorage.getItem("summernoteData"));
                    },
                    onChange: function(contents, $editable)
                    {
                        clearInterval(interval);
                        timer();
                    }
                }
            });

            //load emojis
            $.ajax(
            {
                url: 'https://api.github.com/emojis',
                async: false
            }).then(function(data)
            {
                window.emojis = Object.keys(data);
                window.emojiUrls = data;
            });

            //init emoji example
            $(".js-hint2emoji").summernote(
            {
                height: 100,
                toolbar: false,
                placeholder: 'type starting with : and any alphabet',
                hint:
                {
                    match: /:([\-+\w]+)$/,
                    search: function(keyword, callback)
                    {
                        callback($.grep(emojis, function(item)
                        {
                            return item.indexOf(keyword) === 0;
                        }));
                    },
                    template: function(item)
                    {
                        var content = emojiUrls[item];
                        return '<img src="' + content + '" width="20" /> :' + item + ':';
                    },
                    content: function(item)
                    {
                        var url = emojiUrls[item];
                        if (url)
                        {
                            return $('<img />').attr('src', url).css('width', 20)[0];
                        }
                        return '';
                    }
                }
            });

            //init mentions example
            $(".js-hint2mention").summernote(
            {
                height: 100,
                toolbar: false,
                placeholder: "type starting with @",
                hint:
                {
                    mentions: ['jayden', 'sam', 'alvin', 'david'],
                    match: /\B@(\w*)$/,
                    search: function(keyword, callback)
                    {
                        callback($.grep(this.mentions, function(item)
                        {
                            return item.indexOf(keyword) == 0;
                        }));
                    },
                    content: function(item)
                    {
                        return '@' + item;
                    }
                }
            });

        });

    </script>


   <!-- Search Selecet -->
 <script>
        $(document).ready(function()
        {
            $(function()
            {
                $('.select2').select2();

                $(".select2-placeholder-multiple").select2(
                {
                    placeholder: "Select State"
                });
                $(".js-hide-search").select2(
                {
                    minimumResultsForSearch: 1 / 0
                });
                $(".js-max-length").select2(
                {
                    maximumSelectionLength: 2,
                    placeholder: "Select maximum 2 items"
                });
                $(".select2-placeholder").select2(
                {
                    placeholder: "Select a state",
                    allowClear: true
                });

                $(".js-select2-icons").select2(
                {
                    minimumResultsForSearch: 1 / 0,
                    templateResult: icon,
                    templateSelection: icon,
                    escapeMarkup: function(elm)
                    {
                        return elm
                    }
                });

                function icon(elm)
                {
                    elm.element;
                    return elm.id ? "<i class='" + $(elm.element).data("icon") + " mr-2'></i>" + elm.text : elm.text
                }





            });
        });



    </script>


<!--  Filter Model -->
<script>
   $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(search = '')
    {
     $.ajax({
      url:'1/ModelExecutingFilter',
      method:'GET',
      data:{search:search},
      dataType:'json',
      success:function(data)
      {
       $('.Data').html(data.table_data);
       $('#Name_Outcome').val(data.Outcome);
       $('#Qty').val(data.qty);
       $('#Total').val(data.tot);
       $('#TotalHide').val(data.tot);
       $('#OriginalTotalHide').val(data.tot);
       $('#count').val(data.count);

      }
     })
    }

   $(document).on('change', '#model', function(){
     var search = $(this).val();
     fetch_customer_data(search);
    });


   });


     $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(search = '')
    {
     $.ajax({
      url:'1/ModelExecutingFilter',
      method:'GET',
      data:{search:search},
      dataType:'json',
      success:function(data)
      {
       $('.Data').html(data.table_data);
       $('#Name_Outcome').val(data.Outcome);
       $('#Qty').val(data.qty);
       $('#Total').val(data.tot);
       $('#TotalHide').val(data.tot);
       $('#OriginalTotalHide').val(data.tot);
       $('#count').val(data.count);

      }
     })
    }


     var search = $('#model').val();
     fetch_customer_data(search);



   });
</script>

<script>
 function ChangePrice(){

     var count =$('#count').val();
     var Qty =$('#Qty').val();
     var Total =$('#OriginalTotalHide').val();
        var x = 0 ;

     var NewTotal = parseFloat(Qty) * parseFloat(Total) ;

     $('#Total').val(parseFloat(NewTotal).toFixed(2));
     $('#TotalHide').val(parseFloat(NewTotal).toFixed(2));

     for(var i=1; i<= count ; i++){

        var Dep= $('#OriginalDepreciationQty'+i).val();
        var Qtyy= $('#OriginalQtyy'+i).val();
        var StoreQty= $('#StoreQty'+i).val();


        var newDep = parseFloat(Dep) * parseFloat(Qty) ;
        var newQty = parseFloat(Qtyy) * parseFloat(Qty) ;

         $('#DepreciationQty'+i).val(newDep);
         $('#Qtyy'+i).val(newQty);

         if(parseFloat(StoreQty) < parseFloat(newQty)){
             $('#More'+i).val(1);
         }else{

            $('#More'+i).val(0);

         }

     }



   $('.MO').each(function(){
   x += parseFloat($(this).val());
   });



if(parseFloat(x) == 0){

    document.getElementById('submit').style.display='block';

}else{

    document.getElementById('submit').style.display='none';

}



 }
</script>

<?php $__env->stopPush(); ?>


<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/klarapps/public_html/test.klarapps.com/resources/views/admin/Manufacturing/ManuExecution.blade.php ENDPATH**/ ?>