<?php $__env->startSection('content'); ?>
<?php
use App\Models\ManufacturingDefaultData;
$Def=ManufacturingDefaultData::orderBy('id','desc')->first();
?>
  <title><?php echo e(trans('admin.ManufacturingModel')); ?></title>
  <style>

      .btn-primary{
          margin:0 8px;
      }
      @media(max-width:600px){
          th{
              padding:20px;
          }
      }
  </style>

  <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.ManufacturingModel')); ?></li>
                        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span
                                class="js-get-date"></span></li>
                    </ol>
                    <div class="subheader">
                        <h1 class="subheader-title">
                            <i class='subheader-icon fal fa-table'></i>  <?php echo e(trans('admin.ManufacturingModel')); ?>

                        </h1>
                    </div>

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

               <?php echo view('honeypot::honeypotFormFields'); ?>
                    <div class="row">
                        <div class="col-lg-12">
                            <div id="panel-2" class="panel">
                                <div class="panel-hdr">
                                    <h2>
                                        <span class="fw-300"><i>   <?php echo e(trans('admin.ManufacturingModel')); ?>  </i></span>
                                    </h2>

                                </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">
                                    <div class="form-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); ?>" class="form-control " disabled>
                                            <input type="hidden" name="Code" value="<?php echo e($Code); ?>" class="form-control">
                                        </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-4">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Arabic_Name')); ?></label>
                              <input type="text" name="Name" value="<?php echo e(old('Name')); ?>" class="form-control" required>
                                        </div>                 
                                        
                                        <div class="form-group col-lg-4">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.English_Name')); ?></label>
                              <input type="text" name="NameEn" value="<?php echo e(old('NameEn')); ?>" class="form-control" >
                                        </div>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Time')); ?></label>
                           <input type="number" step="any" name="Time" value="0" class="form-control" required>
                                        </div>
                                        <div class="form-group col-md-2">
                                            <label class="form-label" for="">   <?php echo e(trans('admin.ManufacturingHalls')); ?> </label>
                                <select class="select2 form-control w-100" name="Hall" required>
                                <option value=""> <?php echo e(trans('admin.ManufacturingHalls')); ?></option>
                                            <?php $__currentLoopData = $ManufacturingHalls; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hall): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($hall->id); ?>" <?php if($Def->Hall == $hall->id): ?> selected <?php endif; ?>>
                                     <?php echo e(app()->getLocale() == 'ar' ?$hall->Arabic_Name :$hall->English_Name); ?>    
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        </div>


                      <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Coin')); ?></label>
                                            <select class="select2 form-control w-100" name="Coin" required>
                                                 <option value=""> <?php echo e(trans('admin.Coin')); ?></option>
                                            <?php $__currentLoopData = $Coins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $coin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($coin->id); ?>" <?php if($Def->Coin == $coin->id): ?> selected <?php endif; ?>>   
                                     <?php echo e(app()->getLocale() == 'ar' ?$coin->Arabic_Name :$coin->English_Name); ?>                 
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        </div>
                     <div class="form-group col-lg-2">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Draw')); ?></label>
                                            <input type="text" name="Draw" value="<?php echo e($Def->Draw); ?>" class="form-control" required>
                                        </div>
                    <div class="form-group col-lg-2">
                                            <label class="form-label" for=""> <?php echo e(trans('admin.Cost_Center')); ?> </label>
                                            <select class="select2 form-control w-100" name="Cost_Center">
                                            <option value=""> <?php echo e(trans('admin.Cost_Center')); ?></option>
                                            <?php $__currentLoopData = $CostCenters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cost): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($cost->id); ?>">
                              
                                          <?php echo e(app()->getLocale() == 'ar' ?$cost->Arabic_Name :$cost->English_Name); ?>                       
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        </div>
                     <div class="form-group col-lg-6">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Notes')); ?>  </label>
                                            <input type="text" name="Note" value="<?php echo e(old('Note')); ?>" class="form-control">
                                        </div>
                                    </div>

                            </div>
                        </div>
                    </div>
                </div>
                    </div>
                    <div class="row">
                        <div class="col-xl-12">
                            <div  class="panel">
                                <div class="panel-container show">
                                    <div class="panel-content">

                                        <div class="panel-container show">
                                            <div class="panel-content">
                                                <ul class="nav nav-tabs" role="tablist">
                                                    <li class="nav-item">
                             <a class="nav-link active" data-toggle="tab" href="#tab_borders_icons-1" role="tab"><i class="fal fa-home mr-1"></i> <?php echo e(trans('admin.Income')); ?>  </a>
                                                    </li>
                                                    <li class="nav-item">
                                                        <a class="nav-link " data-toggle="tab" href="#tab_borders_icons-2" role="tab"><i class="fal fa-home mr-1"></i> <?php echo e(trans('admin.Outcome')); ?>  </a>
                                                    </li>
                                         
                                                </ul>
                                                <div class="tab-content border border-top-0 p-3">
                            <div class="tab-pane fade show active" id="tab_borders_icons-1" role="tabpanel">

                                                       <div class="row">
                                                        <div class="col-xl-12">
                                                            <div id="panel-1" class="panel">

                                                                <div class="panel-container show">
                                                                    <div class="panel-content">

                                                                      <div class="row">
                                                    <div class="form-group col-md-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Store')); ?></label>
                                            <select class="select2 form-control w-100" id="store"  name="StoreIn" required>
                                                <option value=""> <?php echo e(trans('admin.Store')); ?></option>
                                            <?php $__currentLoopData = $Stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($stor->id); ?>">
                                        <?php echo e(app()->getLocale() == 'ar' ?$stor->Name :$stor->NameEn); ?>                   
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                                        </div>
                                                                        <div class="form-group col-lg-9">
                                  <label class="form-label" for="">  <?php echo e(trans('admin.Search_For_Products')); ?>  </label>
                                                                            <div class="input-items">
              <input type="text" id="search" class="form-control" placeholder="<?php echo e(trans('admin.Search_For_Products')); ?>"  >
                                                                                                        <?php if(app()->getLocale() == 'ar' ): ?>
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      <?php else: ?>
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      <?php endif; ?>
                                                                            </div>
                                                                         </div>
                                                                        </div>
                                                                         <div id="mobile-overflow">
                                             <table  class="table table-bordered table-hover table-striped w-100 mobile-width table-color1 mt-2 th-width">
                                                                        <thead>
                                                                            <tr>
                                            <th><?php echo e(trans('admin.Name')); ?></th>
                                            <th style="padding:12px 20px;"><?php echo e(trans('admin.Unit')); ?></th>
                                            <th><?php echo e(trans('admin.Code')); ?></th>
                                            <th><?php echo e(trans('admin.Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Price')); ?></th>
                                            <th style="padding:12px 20px;"><?php echo e(trans('admin.Store')); ?></th>
                                            <th><?php echo e(trans('admin.Depreciation_Precent')); ?>%</th>
                                            <th><?php echo e(trans('admin.Depreciation')); ?></th>
                                            <th><?php echo e(trans('admin.Actions')); ?></th>
                                                                            </tr>
                                                                        </thead>
                                                                        <tbody class="Data">

                                                                        </tbody>
                                                                        </table>
                                                                        </div>
                                                                        <!-- datatable start -->
                                                                         <div id="mobile-overflow">
                    <table id="dt" class="table table-bordered table-hover table-striped w-100 mobile-width table-color2 th-width">
                                                                            <thead>
                                                                                <tr>
                                                            <th><?php echo e(trans('admin.Name')); ?></th>
                                                            <th><?php echo e(trans('admin.Unit')); ?></th>
                                                            <th><?php echo e(trans('admin.Code')); ?></th>
                                                            <th style="padding:20px"><?php echo e(trans('admin.Qty')); ?></th>
                                                            <th style="padding:20px"><?php echo e(trans('admin.Price')); ?></th>
                                                            <th><?php echo e(trans('admin.Total')); ?></th>
                                                            <th><?php echo e(trans('admin.Store')); ?></th>
                                                            <th><?php echo e(trans('admin.Depreciation_Precent')); ?>%</th>
                                                            <th><?php echo e(trans('admin.Depreciation')); ?></th>
                                                            <th><?php echo e(trans('admin.Actions')); ?></th>
                                                                                </tr>
                                                                            </thead>
                                                                            <tbody id="data-dt">

                                                                            </tbody>

                                                                        </table>
                                                                        </div>
                                                                        <!-- datatable end -->

                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    </div>
                                 <div class="tab-pane fade" id="tab_borders_icons-2" role="tabpanel">
                                                        <div class="panel-container show">
                                                            <div class="panel-content">
                                                                <div class="row">
                                                                <div class="form-group col-md-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Store')); ?></label>
                                            <select class="select2 form-control w-100" id="storeOut"  name="StoreOut" required>
                                                <option value=""> <?php echo e(trans('admin.Store')); ?></option>
                                            <?php $__currentLoopData = $Stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($stor->id); ?>">
                                               <?php echo e(app()->getLocale() == 'ar' ?$stor->Name :$stor->NameEn); ?> 
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                                        </div>
                                                                    <div class="form-group col-lg-9" id="SEARCHH">
                                    <label class="form-label" for="">  <?php echo e(trans('admin.Search_For_Products')); ?>  </label>
                                                                        <div class="input-items">
             <input type="text" id="searchOut" class="form-control" placeholder="<?php echo e(trans('admin.Search_For_Products')); ?>" >
                                                                                     <?php if(app()->getLocale() == 'ar' ): ?>
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      <?php else: ?>
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      <?php endif; ?>
                                                                        </div>
                                                                     </div>
                                                                    </div>
                                                                     <div id="mobile-overflow">
                             <table   class="table table-bordered table-hover table-striped w-100 mobile-width table-color1 mt-2 th-width">
                                                                <thead>
                                                                    <tr>
                                                                        <th><?php echo e(trans('admin.Name')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Code')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Unit')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Except_Qty')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Actions')); ?>  </th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody class="DataOut" id="DataOut">

                                                                </tbody>
                                                                </table>
                                                                </div>
                                                                <!-- datatable start -->
                                                                 <div id="mobile-overflow">
                                                                <table id="dtOut"
                                                                    class="table table-bordered table-hover table-striped w-100 mobile-width table-color2 th-width">
                                                                    <thead>
                                                                        <tr>
                                                                        <th><?php echo e(trans('admin.Name')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Code')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Unit')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Except_Qty')); ?>  </th>
                                                                        <th><?php echo e(trans('admin.Actions')); ?>  </th>
                                                                        </tr>
                                                                    </thead>
                                                                    <tbody id="data-dt-first-out">

                                                                    </tbody>
                                                                </table>
                                                                </div>
                                                                <!-- datatable end -->

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

                                                </div>
                                            </div>
                                        </div>
                            </div>
                        </div>
                    </div>
                    </div>
                    </div>
                    <div class="row">
                    <table id="" class="table table-bordered table-hover table-striped w-100">
                    <thead>
                        <tr>
                            <th><?php echo e(trans('admin.Product_Numbers')); ?> </th>
                            <th id="Product_Numbers"></th>
                            <th style="display: none"><?php echo e(trans('admin.Total_Discount')); ?>   </th>
                            <th id="Total_Discount" style="display: none"></th>
                            <th style="display: none"> <?php echo e(trans('admin.Total_Bf_Taxes')); ?> </th>
                            <th id="Total_Bf_Taxes" style="display: none"></th>
                            <th style="display: none"><?php echo e(trans('admin.Total_Taxes')); ?></th>
                            <th id="Total_Taxes" style="display: none"></th>
                        </tr>
                    </thead>
                </table>
                <table id=""
                class="table table-bordered table-hover table-striped w-100">
                <thead>
                    <tr>
                        <th ><?php echo e(trans('admin.Total_Price')); ?> </th>
                        <th id="Total_Price"></th>
                    </tr>
                </thead>
            </table>
            </div>
                  <input type="hidden" name="Product_Numbers" id="Product_NumbersHide">
                  <input type="hidden" name="Total_Discount" id="Total_DiscountHide">
                  <input type="hidden" name="Total_BF_Taxes" id="Total_Bf_TaxesHide">
                  <input type="hidden" name="Total_Taxes" id="Total_TaxesHide">
                  <input type="hidden" name="Total_Price" id="Total_PriceHide">

<div class="row" id="Submit">
                          <input type="hidden" id="sp" name="SP">
            <button type="button"  class="btn btn-primary" onclick="SPS()"> <i class="fal fa-folder"></i> <?php echo e(trans('admin.Save')); ?> </button>
 <button type="button"  class="btn btn-primary" onclick="SPP()"><i class="fal fa-save"></i>  <?php echo e(trans('admin.ExecutionSave')); ?> </button>
         </div>
      </form>
                </main>


<?php if(app()->getLocale() == 'ar' ): ?> 
<input type="hidden" id="LANG" value="ar">
<?php else: ?>
<input type="hidden" id="LANG" value="en">
<?php endif; ?>

<?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')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/dropzone/dropzone.css')); ?>">

  <script src="j<?php echo e(asset('Admin/s/datagrid/datatables/datatables.bundle.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.export.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 src="<?php echo e(asset('Admin/js/formplugins/dropzone/dropzone.js')); ?>"></script>

    <script>
        /* demo scripts for change table color */
        /* change background */


        $(document).ready(function () {

            $('#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 ' + title + '" />');

                $('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: false,

                    dom: "<'row mb-3'<'col-sm-12 col-md-6 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-6 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: '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>
        $(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
                }

                $(".js-data-example-ajax").select2(
                {
                    ajax:
                    {
                        url: "https://api.github.com/search/repositories",
                        dataType: 'json',
                        delay: 250,
                        data: function(params)
                        {
                            return {
                                q: params.term, // search term
                                page: params.page
                            };
                        },
                        processResults: function(data, params)
                        {
                            // parse the results into the format expected by Select2
                            // since we are using custom formatting functions we do not need to
                            // alter the remote JSON data, except to indicate that infinite
                            // scrolling can be used
                            params.page = params.page || 1;

                            return {
                                results: data.items,
                                pagination:
                                {
                                    more: (params.page * 30) < data.total_count
                                }
                            };
                        },
                        cache: true
                    },
                    placeholder: 'Search for a repository',
                    escapeMarkup: function(markup)
                    {
                        return markup;
                    }, // let our custom formatter work
                    minimumInputLength: 1,
                    templateResult: formatRepo,
                    templateSelection: formatRepoSelection
                });

                function formatRepo(repo)
                {
                    if (repo.loading)
                    {
                        return repo.text;
                    }

                    var markup = "<div class='select2-result-repository clearfix d-flex'>" +
                        "<div class='select2-result-repository__avatar mr-2'><img src='" + repo.owner.avatar_url + "' class='width-2 height-2 mt-1 rounded' /></div>" +
                        "<div class='select2-result-repository__meta'>" +
                        "<div class='select2-result-repository__title fs-lg fw-500'>" + repo.full_name + "</div>";

                    if (repo.description)
                    {
                        markup += "<div class='select2-result-repository__description fs-xs opacity-80 mb-1'>" + repo.description + "</div>";
                    }

                    markup += "<div class='select2-result-repository__statistics d-flex fs-sm'>" +
                        "<div class='select2-result-repository__forks mr-2'><i class='fal fa-lightbulb'></i> " + repo.forks_count + " Forks</div>" +
                        "<div class='select2-result-repository__stargazers mr-2'><i class='fal fa-star'></i> " + repo.stargazers_count + " Stars</div>" +
                        "<div class='select2-result-repository__watchers mr-2'><i class='fal fa-eye'></i> " + repo.watchers_count + " Watchers</div>" +
                        "</div>" +
                        "</div></div>";

                    return markup;
                }

                function formatRepoSelection(repo)
                {
                    return repo.full_name || repo.text;
                }
            });
        });

    </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>


    <script type="text/javascript">

        $(function () {

        $('.dz-details').click(function () {

        $('.dz-image').hide();



        });

        });

        </script>
        <!-- upload input file -->
        <script>
               function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah').attr('src', e.target.result);

            }

            reader.readAsDataURL(input.files[0]);

        }
    }

    $("#imgInp").change(function(){
        readURL(this);

    });
  $(function () {

        $('.close').click(function () {

        $('#blah').hide(),
        $('.close').hide();



        });

        });
        </script>

<script type="text/javascript">

    $(document).ready(function() {

    $('.show-table').click(function () {

    $('.hide-products-table').show();



    });

    });

    </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 ' + title + '" />');

                $('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>

<!-- Unit Code and Name -->
<script>
   function  UnitCodePurchh(r){

   var countryId = $('#UnitPurch'+r).val();
   var Pro = $('#Product'+r).val();
   var store = $('#StorePurch'+r).val();
   var code = $('#CodePurch'+r).val();
                     if(countryId) {
                         $.ajax({
                             url: 'UnitPurchasesFilter/'+countryId+'/'+Pro+'/'+store+'/'+code,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {
                                 $.each(data, function(key, value){

                       $('#CodePurch'+r).val(data.code);
                       $('#UnitPurchName'+r).val(data.name);
                       $('#TaxRate'+r).val(data.rate);
                       $('#TaxType'+r).val(data.type);
                       $('#Price'+r).val(data.price);
                       $('#PurchTax'+r).val(data.tax);
                                         $('#UnitPriceOne'+r).val(data.priceOne);
                       $('#UnitPriceTwo'+r).val(data.priceTwo);
                       $('#UnitPriceThree'+r).val(data.priceThree);

                                 });

                                var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

          //Number
        var BF = ( parseFloat(Qty) *  parseFloat(Price) );
         $("#TotalBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#Tax"+r).val(parseFloat(i));


           $("#Total"+r).val(parseFloat(BF));
                                 
                                 
        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();

       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == ''){

        document.getElementById("AddBtnPur"+r).style.display = "none";
     }


       if(TaxRate != ''  && TaxType != ''  &&  Qty != '' && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != ''){

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }




                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }

   }
</script>


<!-- Store Name -->
<script>
   function  StoreNamePurch(r){

   var countryId = $('#StorePurch'+r).val();
                     if(countryId) {
                         $.ajax({
                             url: 'StoreNamePurchasesFilter/'+countryId,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {
                                 $.each(data, function(key, value){

                       $('#StorePurchName'+r).val(data.name);



                                 });

   var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;


        //Number
        var BF = ( parseFloat(Qty) *  parseFloat(Price) );
         $("#TotalBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#Tax"+r).val(parseFloat(i));


           $("#Total"+r).val(parseFloat(BF));

        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();

       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == ''){

        document.getElementById("AddBtnPur"+r).style.display = "none";
     }


       if(TaxRate != ''  && TaxType != ''  &&  Qty != '' && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != ''){

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }




                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }

   }
</script>


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

    fetch_customer_data();

    function fetch_customer_data(search = '',store='')
    {
     $.ajax({
      url:'IncomManufacturingProductsFilter',
      method:'GET',
      data:{search:search,store:store},
      dataType:'json',
      success:function(data)
      {
       $('.Data').html(data.table_data);
      }
     })
    }

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


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

   });
</script>

<!-- Add Products -->
<script>
   function Fun(r) {

             var P_Ar_Name = $("#P_Ar_Name"+r).val();
             var P_En_Name= $("#P_En_Name"+r).val();
             var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
             var UnitName = $("#UnitPurchName"+r).val();
             var Qty = $("#Qty"+r).val();
             var Barcode = $("#CodePurch"+r).val();
             var Price = $("#Price"+r).val();
             var Total = $("#Total"+r).val();
             var DeprecPrecent = $("#DeprecPrecent"+r).val();
             var Deprec = $("#Deprec"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
             var TotalTax = $("#Tax"+r).val();
             var Discount = $("#Discount"+r).val();
             var TotalBFTax = $("#TotalBFTax"+r).val();
             var StorePurch = $("#StorePurch"+r).val();
             var StorePurchName = $("#StorePurchName"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
    var i = 0 ;
    var ii = 0 ;
             var PO='';
          var DO='';
      PO="<input type='number' id='PriD"+r+"' step='any' name='Price[]' value='"+Price+"' class='form-control' onkeyup='TotD("+r+")' onclick='TotD("+r+")'>";
  DO="<input class='Disc form-control' id='DiscD"+r+"' type='hidden' step='any' name='Discount[]' value='"+Discount+"' onkeyup='TotD("+r+")' onclick='TotD("+r+")' >";

      i = parseFloat(DeprecPrecent)  / 100 ;
       ii= parseFloat(Qty) * parseFloat(i) ;
       var TaxRate = $("#TaxRate"+r).val();
             var TaxType = $("#TaxType"+r).val();


             document.getElementById("AddBtnPur"+r).style.display = "none";
             document.getElementById("Row"+r).style.display = "none";

        var LANG = $("#LANG").val();
   if(LANG == 'ar' ){ 
          var Nemo = P_Ar_Name ;
          }else{
             var Nemo = P_En_Name ;   
          } 
             var markup = "<tr><td><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'>" + Nemo + "</td><td><input type='hidden' name='Unit[]' value='"+UnitID+"'>" + UnitName + "</td><td><input type='hidden' name='P_Code[]' value='"+Barcode+"'>" + Barcode + "</td><td><input class='Qun form-control' id='QuntD"+r+"' type='number' step='any' name='Qty[]' value='"+Qty+"' onkeyup='TotD("+r+")' onclick='TotD("+r+")' ></td><td>"+PO+"</td>"+DO+"<td><input class='Tot form-control' type='number' step='any' id='TotD"+r+"' disabled   name='Total[]' value='"+Total+"'><input type='hidden' id='TotDHide"+r+"' name='Total[]'  value='"+Total+"'></td><td><input  type='hidden' name='StorePurch[]' value='"+StorePurch+"'>" + StorePurchName + "</td><td><input type='hidden' id='DeprecPrecentD"+r+"' name='DeprecPrecent[]' value='"+DeprecPrecent+"'>" + DeprecPrecent + "</td><td><input type='hidden' id='DeprecD"+r+"' name='Deprec[]' value='"+ii+"'>" + ii + "</td><td><button id='DelAssem' type='button' class='btn btn-default'><i class='fal fa-trash'></i></button><input type='hidden' name='Product[]' value='"+Product+"'><input type='hidden' name='VOne[]' value=''><input type='hidden' name='VTwo[]' value=''></td><input type='hidden' name='V_Name[]' value=''><input type='hidden' name='VV_Name[]' value=''><input type='hidden' name='PurchTax[]' value='"+PurchTax+"'><input id='TaxRateD"+r+"' type='hidden'  value='"+TaxRate+"'><input type='hidden' id='TaxTypeD"+r+"'  value='"+TaxType+"'><input type='hidden'  id='TotBFTaxDHide"+r+"' name='TotalBFTax[]'  value='"+TotalBFTax+"'><input class='TotalBFTax form-control' id='TotBFTaxD"+r+"' type='hidden' step='any' disabled  value='"+TotalBFTax+"'><input class='TotalTax form-control' id='TaxD"+r+"' type='hidden' step='any' disabled  value='"+TotalTax+"'><input type='hidden' id='TaxDHide"+r+"' name='TotalTax[]'  value='"+TotalTax+"'></tr>";


             $("#data-dt").append(markup);

      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();



    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });


 $('#Product_Numbers').text(parseFloat(rowctr));
   $('#Product_NumbersHide').val(parseFloat(rowctr));


   $('#Total_Price').text(parseFloat(sumT).toFixed(2));
   $('#Total_PriceHide').val(parseFloat(sumT).toFixed(2));


       $('#Total_Discount').text(parseFloat(sumD).toFixed(2));
   $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));

          $('#Total_Bf_Taxes').text(parseFloat(sumBF).toFixed(2));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF).toFixed(2));

          $('#Total_Taxes').text(parseFloat(sumTax).toFixed(2));
   $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));




        $('#data-dt').on('click', '#DelAssem', function(e){
                $(this).closest('tr').remove();


      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });


   $('#Product_Numbers').text(parseFloat(rowctr));
   $('#Product_NumbersHide').val(parseFloat(rowctr));


   $('#Total_Price').text(parseFloat(sumT).toFixed(2));
   $('#Total_PriceHide').val(parseFloat(sumT).toFixed(2));


       $('#Total_Discount').text(parseFloat(sumD).toFixed(2));
   $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));

          $('#Total_Bf_Taxes').text(parseFloat(sumBF).toFixed(2));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF).toFixed(2));

          $('#Total_Taxes').text(parseFloat(sumTax).toFixed(2));
   $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

                    })


     }
</script>

<!--New Total -->
<script>

    function TotD(r){

         var TaxRate = $("#TaxRateD"+r).val();
   var TaxType = $("#TaxTypeD"+r).val();
   var Qty = $("#QuntD"+r).val();
   var Price = $("#PriD"+r).val();
   var Discount = $("#DiscD"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

        var DeprecPrecent = $("#DeprecPrecentD"+r).val();
        var Deprec = $("#DeprecD"+r).val();
    var p = 0 ;
    var pp = 0 ;


      p = parseFloat(DeprecPrecent)  / 100 ;
       pp= parseFloat(Qty) * parseFloat(p) ;
      $("#DeprecD"+r).val(parseFloat(pp));

        
              var BF = ( parseFloat(Qty) *  parseFloat(Price) );
         $("#TotBFTaxD"+r).val(parseFloat(BF));
         $("#TotBFTaxDHide"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TaxD"+r).val(parseFloat(i));
           $("#TaxDHide"+r).val(parseFloat(i));

     

           $("#TotD"+r).val(parseFloat(BF));
           $("#TotDHide"+r).val(parseFloat(BF));
        
           $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();



    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });


 $('#Product_Numbers').text(parseFloat(rowctr));
   $('#Product_NumbersHide').val(parseFloat(rowctr));


   $('#Total_Price').text(parseFloat(sumT).toFixed(2));
   $('#Total_PriceHide').val(parseFloat(sumT).toFixed(2));


       $('#Total_Discount').text(parseFloat(sumD).toFixed(2));
   $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));

          $('#Total_Bf_Taxes').text(parseFloat(sumBF).toFixed(2));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF).toFixed(2));

          $('#Total_Taxes').text(parseFloat(sumTax).toFixed(2));
   $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));





    }
</script>


<!-- Total Products -->
<script>
   function PurchTotal(r) {
   var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

        var DeprecPrecent = $("#DeprecPrecent"+r).val();
        var Deprec = $("#Deprec"+r).val();
    var p = 0 ;
    var pp = 0 ;


      p = parseFloat(DeprecPrecent)  / 100 ;
       pp= parseFloat(Qty) * parseFloat(p) ;
      $("#Deprec"+r).val(parseFloat(pp));

       
               var BF = ( parseFloat(Qty) *  parseFloat(Price) );
         $("#TotalBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#Tax"+r).val(parseFloat(i));

           $("#Total"+r).val(parseFloat(BF));
       
       

        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();


       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == '' || DeprecPrecent == ''){

        document.getElementById("AddBtnPur"+r).style.display = "none";
     }


       if(TaxRate != ''  && TaxType != ''  &&  Qty != ''  && Qty != 0 && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != '' &&  DeprecPrecent != ''){

          if( Price == 0 ){

        document.getElementById("AddBtnPur"+r).style.display = "none";
     }else{

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }
     }





   }
</script>

<!-- Outcome -->

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

    fetch_customer_data();

    function fetch_customer_data(search = '',store='')
    {
     $.ajax({
      url:'OutcomManufacturingProductsFilter',
      method:'GET',
      data:{search:search,store:store},
      dataType:'json',
      success:function(data)
      {
       $('.DataOut').html(data.table_data);
          $('#DataOut').show();
      }
     })
    }

   $(document).on('keyup', '#searchOut', function(){
     var search = $(this).val();
     var store = $('#storeOut').val();
     fetch_customer_data(search,store);
    });


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

   });
</script>

<!-- Unit Code and Name Outcome -->
<script>
   function  UnitCodePurchhO(r){

   var countryId = $('#UnitPurchO'+r).val();
   var Pro = $('#ProductO'+r).val();
   var code = $('#CodePurchO'+r).val();
    var Qty = $("#QtyO"+r).val();
                     if(countryId) {
                         $.ajax({
                             url: 'UnitPurchasesFilter/'+countryId+'/'+Pro+'/'+store+'/'+code,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {
                                 $.each(data, function(key, value){

                       $('#CodePurchO'+r).val(data.code);
                       $('#UnitPurchNameO'+r).val(data.name);

                                 });

       if( Qty == ''){

        document.getElementById("AddBtnPurO"+r).style.display = "none";
     }


       if( Qty != ''){

        document.getElementById("AddBtnPurO"+r).style.display = "block";
     }




                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }

   }
</script>

<!-- Add Products Outcome -->
<script>
   function FunO(r) {

             var P_Ar_Name = $("#P_Ar_NameO"+r).val();
             var P_En_Name= $("#P_En_NameO"+r).val();
             var Product = $("#ProductO"+r).val();
             var UnitID = $("#UnitPurchO"+r).val();
             var UnitName = $("#UnitPurchNameO"+r).val();
             var Qty = $("#QtyO"+r).val();
             var Barcode = $("#CodePurchO"+r).val();


             document.getElementById("AddBtnPurO"+r).style.display = "none";
             document.getElementById("RowO"+r).style.display = "none";
             document.getElementById("SEARCHH").style.display = "none";
     $('#DataOut').hide();
       
       
             var LANG = $("#LANG").val();
   if(LANG == 'ar' ){ 
          var Nemo = P_Ar_Name ;
          }else{
             var Nemo = P_En_Name ;   
          } 
       
             var markup = "<tr><td><input type='hidden' name='P_Ar_NameO[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_NameO[]' value='"+P_En_Name+"'>" + Nemo + "</td><td><input type='hidden' name='UnitO[]' value='"+UnitID+"'>" + UnitName + "</td><td><input type='hidden' name='P_CodeO[]' value='"+Barcode+"'>" + Barcode + "</td><td><input class='Qun' type='hidden' name='QtyO[]' value='"+Qty+"'>" + Qty + "</td><td><button id='DelAssemO' type='button' class='btn btn-default'><i class='fal fa-trash'></i></button><input type='hidden' name='ProductO[]' value='"+Product+"'></td></tr>";


             $("#data-dt-first-out").append(markup);


        $('#data-dt-first-out').on('click', '#DelAssemO', function(e){
                $(this).closest('tr').remove();
            document.getElementById("SEARCHH").style.display = "block";
                    })


     }
</script>

<!-- Submit Script -->
<script>

        function SPP(){
           $('#sp').val(1);
           var x= $('#sp').val();

               $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dtOut').rowCount();
  
     if(parseFloat(rowctr) == 1){
        
            
            
        if(x == 1){
             document.getElementById("Submit").style.display = "none";
      document.getElementById('form').submit();
        }
            
        }else{
            
            alert('Must Select Outcome  / يجب اختيار مخرجات');
        }       

    }

      function SPS(){
           $('#sp').val(0);
           var x= $('#sp').val();

          
            $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dtOut').rowCount();
          
     
  
     if(parseFloat(rowctr) == 1){
          
        if(x == 0){
             document.getElementById("Submit").style.display = "none";
      document.getElementById('form').submit();
        }
         
        }else{
            
            alert('Must Select Outcome / يجب اختيار مخرجات');
        }

    }


</script>


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

<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/laravel/ERP/resources/views/admin/Manufacturing/ManufacturingModel.blade.php ENDPATH**/ ?>