VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /home/vapecompany/demo.vapecompany.com.bd/resources/views/backend/stock/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/vapecompany/demo.vapecompany.com.bd/resources/views/backend/stock/create.blade.php
@extends('backend.layout.app')
@section('content')
      <style type="text/css">
          .btn-file {
                position: initial;
                overflow: hidden;
            }
            .btn-file input[type=file] {
                position: absolute;
                top: 0;
                right: 0;
                min-width: 100%;
                min-height: 100%;
                font-size: 100px;
                text-align: right;
                filter: alpha(opacity=0);
                opacity: 0;
                outline: none;
                background: white;
                cursor: inherit;
                display: block;
            }

            #img-upload{
               width: 100%;
               height: 100%
            }
            #img-container{
                width: 100px;
                height: 100px;
                margin: 10px 0;
                border: 1px solid;
            }
            #checkerr .text-danger{
                position: absolute;
                top: 80px;
            }
            #imgerr label{
                    top: 32px;
                    position: absolute;
                    left: 105px;
            }

            /*new image upload css*/
            .upload-img-box {
                background-color: #f5f5f5;
                border: 1px solid #aaa;
                border-radius: 5px;
                height: 150px;
                position: relative;
            }
            .upload-img-box img {
                width: 100%;
                height: auto;
                max-height: 100%;
                margin: auto;
                display: block;
                z-index: 5;
                position: absolute;
                object-fit: cover;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
            }
            .upload-img-box input[type="file"] {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                opacity: 0;
                z-index: 10;
                width: 100%;
                cursor: pointer;
            }
            .upload-img-box-icon {
                color: #666;
                text-align: center;
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
            }
            .tablegrid{
                border-bottom: 1px solid #eee;
                padding-bottom: 10px;

            }
            .noborder{
                border: 1px solid #fff;
            }
            a{
                 padding: 0 1vh;
            }
            /*end image upload css*/


      </style>
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-5 align-self-center">
                        <h4 class="page-title">Add Stock</h4>
                        <div class="d-flex align-items-center">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="#">Home</a></li>
                                    <li class="breadcrumb-item active" aria-current="page">Stock In</li>
                                </ol>
                            </nav>
                        </div>
                    </div>

                </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-12">

                        <div class="card"> 
                            <div class="card-body">
                                <form id="addStock" type="POST">
                                    @csrf
                                    <h4 class="card-title">New Stock</h4>
                                     @include('backend.layout.verror_message')
                                   <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Stock Date</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <input type="text" name="stock_date" class="form-control" id="datepicker-autoclose" placeholder="mm/dd/yyyy">
                                                <div class="input-group-append">
                                                    <span class="input-group-text"><i class="icon-calender"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Bill No.</label>
                                        <div class="col-sm-9">
                                             <input type="text" class="form-control" id="bill_no" name="bill_no" placeholder="Bill No.">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Supplier</label>
                                        <div class="col-sm-9">
                                            <select name="supplier" class="form-control select2 ">
                                                   <option value="">Select</option>
                                                    @foreach($suppliers as $supplier)
                                                        <option value="{{$supplier->supplier_id}}">{{$supplier->supplier_name}}</option>
                                                    @endforeach
                                            </select>
                                        </div>
                                    </div>

                                    {{-- <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">C&F Name</label>
                                        <div class="col-sm-9">
                                            <select name="cnf" class="form-control select2 ">
                                                   <option value="">Select C&F</option>
                                                    @foreach($cnfs as $cnf)
                                                        <option value="{{$cnf->cnf_id}}">{{$cnf->cnf_name}}</option>
                                                    @endforeach
                                            </select>
                                        </div>
                                    </div> --}}






                                    <div id="cart_items">
                                        <input type="hidden" id="validateProduct" name="product_id[]" value="">
                                    </div>
                                <div  style="margin-top: 50px;"><div style="text-align: center;padding: 10px;display: none;" id="product_exist" class="text-danger">Already Exist</div>
                                    <div class="row form-group">

                                        <label for="category" class="col-sm-3 text-right control-label col-form-label">Add Product</label>
                                        <div class="col-sm-2">
                                            <div class="form-group">
                                                <select onchange="get_product()" class="form-control" id="category" name="educationDate">
                                                    <option>Select Category</option>
                                                    < @foreach($categories as $category)
                                                        <option value="{{$category->category_id}}">{{$category->category_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                        {{-- <div class="col-sm-2">
                                            <div class="form-group">
                                                <select onchange="get_product()" class="form-control" id="brand" name="educationDate">
                                                    <option>Select Brand</option>
                                                    < @foreach($brands as $brand)
                                                        <option value="{{$brand->brand_id}}">{{$brand->brand_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div> --}}
                                        <div class="col-sm-3">
                                            <div class="form-group">
                                                <select class="form-control" onchange="get_purchase_price()" id="product" name="educationDate">
                                                    <option>Product</option>

                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-sm-1">
                                            <div class="form-group">
                                                <input type="text" class="form-control" id="purchase_price_main" name="purchase_price_main" placeholder="Price">
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div class="form-group">
                                                <input type="text" autocomplete="off" class="form-control" id="addQnantity" name="addQnantity" placeholder="Quantity">
                                            </div>
                                        </div>

                                        <div class="col-sm-1">
                                            <div class="form-group">
                                                <button class="btn btn-success" type="button" onclick="addcart();"><i class="fa fa-plus"></i></button>
                                            </div>
                                        </div>
                                    </div>
                                    </div>
                                   <!--  <div class="row">
                                        <div class="col-md-6"></div>
                                        <div class="col-md-4">
                                        <div class="form-group">
                                            <div class="upload-img-box">
                                                <img src="">
                                                <input type="file" name="thumbnail" id="thumbnail" accept="image/*" onchange="previewFile(this)">
                                                <div class="upload-img-box-icon">
                                                    <i class="fa fa-camera"></i>
                                                    <p class="m-0">Add Image</p>
                                                </div>
                                            </div>
                                        </div>
                                        </div>
                                    </div> -->
                                    <div class="form-group mb-0 text-right">

                                        <button type="submit" name="action" value="submit" class=" submit btn btn-info waves-effect waves-light">Save</button>
                                        <button type="submit" name="action" class="btn btn-dark waves-effect waves-light">Cancel</button>
                                    </div>
                                 </form>
                            </div>

                        </div>


                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            @endsection
            @section('script')
             <script src="{{url('public/backend/js/jquery.validate.min.js')}}"></script>
             <link rel="stylesheet" type="text/css" href="{{url('public/backend/css/bootstrap-datepicker.min.css')}}">
             <script src="{{url('public/backend/js/bootstrap-datepicker.min.js')}}"></script>
             <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
             <script src="{{url('public/backend/js/tinymce.min.js')}}"></script>
                <script type="text/javascript">
                    // $(document).on('click','.onchange', function(){
                    //      console.log('Ok');
                    // })
                     var date = new Date();
                        var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
                        $('#datepicker-autoclose').datepicker({
                            format: 'dd-mm-yyyy',
                            autoclose: true,
                            todayHighlight: true
                        });
                        $( '#datepicker-autoclose').datepicker( 'setDate', today );
                   function get_product(){
                        var id=$('#category').val();
                            //console.log("{{url('get_productById')}}/"+id);
                        $.ajax({

                            type : 'POST',
                            url  : "{{url('admin/get_productById')}}",
                            data:{category_id:id},
                             dataType: 'json',
                            success :  function (data)
                            {

                                //var d=JSON.parse(data);

                                var color="<option>Select Product</option>";
                                $.each(data,function(){
                                    console.log(this.product_id);
                                    color +="<option value='"+this.product_id+"'> "+this.product_name+" </option>";
                                });
                               // console.log(color);
                                $('#product').html(color);

                            },
                            error :  function (data)
                            {
                                //console.log(data);
                            }
                        });
                    }
                    function get_purchase_price(){
                        var id=$('#product').val();
                            //console.log("{{url('get_productById')}}/"+id);
                        $.ajax({

                            type : 'POST',
                            url  : "{{url('admin/get_purchasePriceById')}}",
                            data:{product_id:id},
                             dataType: 'json',
                            success :  function (data)
                            {
                                $('#purchase_price_main').val(data.purchase_price);
                            },
                            error :  function (data)
                            {
                                //console.log(data);
                            }
                        });
                    }
                    function get_product_color(){
                        var id=$('#product').val();

                        $.ajax({

                            type : 'POST',
                            url  : "{{url('get_productById')}}",
                            data:{id:id},
                            // dataType: 'json',
                            success :  function (data)
                            {


                                $('#addColor').html(data);

                            },
                            error :  function (data)
                            {
                                //console.log(data);
                            }
                        });
                    }
                    var cartproduct={};
                    function addcart(){
                        event.preventDefault();
                        var category=$('#category').val();
                        var id=$('#product').val();
                        var color=$('#addColor').val();
                        var qty=$('#addQnantity').val();
                        var price=$('#purchase_price_main').val();
                        var uniqueid=id;
                       // console.log(cartproduct[id+'-'+color]);
                        if(cartproduct[id] == undefined)
                        {
                            $('#product_exist').hide();
                            $.ajax(
                            {
                                type : 'POST',
                                url  : "{{url('admin/add_cart_stock')}}",
                                data : {uniqueid:uniqueid,category:category, id: id,color:color,qty:qty,price:price },
                                // dataType: 'json',
                                success :  function (data)
                                {

                                    //console.log($('#validateProduct').length);
                                    cartproduct[id]=id;
                                    if($('#validateProduct').length > 0){
                                        $('#cart_items').html(data);
                                    }else{
                                        $('#cart_items').append(data);
                                    }

                                   //swal("Cart Add!", "Successfully Add", "success");
                                },
                                error :  function (data)
                                {
                                    console.log(data);
                                }
                            });
                        }else{
                            $('#product_exist').show();
                        }

                    }
                    //increate and decreate
                       function increateCart(arg){
                            var v=$('#'+arg).val();
                            v++;
                            $('#'+arg).val(v);
                       }
                        function decreaseCart(arg){
                            var v=$('#'+arg).val();
                            v--;
                            $('#'+arg).val(v);
                       }
                    //Increment purchase price
                    
                    function purchasePrice(total_price_id, qty, val){
                        var total_qty = parseInt($('#'+qty).val());
                        var total_price = parseInt(val)*total_qty;
                        if(total_price){
                            $('#'+total_price_id).val(total_price);
                        }else{
                            $('#'+total_price_id).val(0);
                        }
                    }
                    function qty(total_price_id, purchase_price, qty){ 
                        var price = $('#'+purchase_price).val();
                        var total_price = parseInt(qty)*parseInt(price);
                        if(total_price){
                            $('#'+total_price_id).val(total_price);
                        }else{
                            $('#'+total_price_id).val(0);
                        }
                    }
                    function qty2(total_price_id, purchase_price, qty){
                        var price = $('#'+purchase_price).val();
                        var qty_total = $('#'+qty).val();
                        var total_price = parseInt(qty_total)*parseInt(price);
                        if(total_price){
                            $('#'+total_price_id).val(total_price);
                        }else{
                            $('#'+total_price_id).val(0);
                        }
                    }
                       function closeCart(arg){
                        delete cartproduct[arg];
                        //console.log(cartproduct);
                       // console.log(arg);
                           $('#'+arg).remove();

                       }
                    //end increate and decrease

                    $(document).ready( function() {

                        $("#addStock").validate({
                            ignore: "",
                            rules:
                            {
                                supplier: {
                                    required: true,
                                },
                                bill_no:{
                                    required: true,
                                },
                                stock_date:{
                                    required: true,
                                },
                                cnf:{
                                    required: true,
                                },
                                'product_id[]': {
                                    required: true,
                                },
                            },
                            messages: {
                                'product_id[]': "Please Add Product",
                            },
                            submitHandler: submitForm
                        });
                        // $('.submit').click(function () {
                        //     event.preventDefault();
                        //     if(this.value == 'submit'){
                        //         $('[name="delivery_mode"], [name="bank"],[name="bank_slip"]').each(function () {
                        //             $(this).rules('add', {
                        //                 required: true
                        //             });

                        //         });
                        //         $("#addRequisition").submit();
                        //     }else if(this.value == 'draft'){
                        //         $('[name="delivery_mode"], [name="bank"],[name="bank_slip"]').each(function () {
                        //             $(this).rules('remove');

                        //         });
                        //         $("#addRequisition").submit();
                        //     }

                        //  });

                     //product validtion form and insert



                       function submitForm() {

                            event.preventDefault();
                            var data1 = new FormData(document.getElementById('addStock'));
                            console.log(data1);

                            $.ajax({

                                type : 'POST',
                                url  : "{{url('admin/add_stock')}}",
                                data : data1,
                                cache:false,
                                contentType: false,
                                processData: false,
                                //dataType: 'json',
                                success :  function (data)
                                {
                                    console.log(data);
                                    if(data.errors=='0'){
                                        $('.alert-success').show();
                                        $('.alert-danger').hide();
                                        $('.alert-success').append('<p>'+data.success+'</p>');
                                        $("#addStock").get(0).reset();
                                        $("#cart_items").html("");
                                    }else{
                                         var val="";
                                        $.each(data.errors, function(key, value){
                                            $('.alert-danger').show();
                                            $('.alert-success').hide();
                                            val+= '<p>'+value+'</p>';

                                        });
                                        $('.alert-danger').html(val);
                                    }

                                },error: function(response) {
                                    //console.log(response);
                                }
                            });
                            return false;
                        }
                     //end validation and insert
                        
                    });
                
                </script>
            @endsection

VaKeR 2022