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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/vapecompany/demo.vapecompany.com.bd/resources/views/backend/product/edit.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;
            }

      </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">Product Edit</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">Product</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="addProduct" type="POST">
                                    @csrf
                                    <h4 class="card-title">Edit Product</h4>
                                     @include('backend.layout.verror_message')
                                    <div class="form-group row">
                                        <input type="hidden" name="product_id" value="{{$product->product_id}}">
                                        <label for="product_name" class="col-sm-3 text-right control-label col-form-label">Product Code</label>
                                        <div class="col-sm-9">
                                            <input disabled="" name="product_code" type="text" class="form-control" id="product_code" value="{{$product->product_code}}" placeholder="Product Code">
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Category</label>
                                        <div class="col-sm-9">
                                            <select name="category" class="form-control select2 ">
                                                   <option value="">Select Category</option> 
                                                    @foreach($categories as $category)
                                                        @if($category->category_id == $product->category_id)
                                                            <option selected="selected" value="{{$category->category_id}}">{{$category->category_name}}</option>
                                                        @else 
                                                             <option  value="{{$category->category_id}}">{{$category->category_name}}</option>
                                                        @endif     
                                                    @endforeach   
                                            </select>
                                        </div>
                                    </div>

                                     {{-- <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Brand</label>
                                        <div class="col-sm-9">
                                            <select name="brand" class="form-control select2 ">
                                                   <option value="">Select</option> 
                                                    @foreach($brands as $brand)
                                                        @if($brand->brand_id == $product->brand_id)
                                                            <option selected="selected" value="{{$brand->brand_id}}">{{$brand->brand_name}}</option>
                                                        @else 
                                                             <option value="{{$brand->brand_id}}">{{$brand->brand_name}}</option>
                                                        @endif     
                                                    @endforeach   
                                            </select>
                                        </div>
                                    </div> --}}
                                    
                                   
                                    <div class="form-group row">
                                        <label for="product_name" class="col-sm-3 text-right control-label col-form-label">Product Name</label>
                                        <div class="col-sm-9">
                                            <input name="product_name" type="text" class="form-control" id="product_name" value="{{$product->product_name}}" placeholder="Product Name">
                                        </div>
                                    </div>
                                    {{-- <div class="form-group row">
                                        <label for="brand" class="col-sm-3 text-right control-label col-form-label">Model</label>
                                        <div class="col-sm-9">
                                            <select name="model" class="form-control select2">
                                                   <option value="">Select</option> 
                                                    @foreach($models as $model)
                                                        @if($model->model_id == $product->model_id)
                                                            <option selected="selected" value="{{$model->model_id}}">{{$model->model_name}}</option>
                                                        @else 
                                                             <option  value="{{$model->model_id}}">{{$model->model_name}}</option>
                                                        @endif     
                                                    @endforeach   
                                            </select>
                                        </div>
                                    </div> --}}

                                   {{-- <div class="form-group row">
                                        <label for="com1" class="col-sm-3 text-right control-label col-form-label">Product Color</label>
                                        <div class="col-sm-9">
                                            @php 
                                                $pro_color=json_decode($product->product_color);

                                            @endphp
                                            @foreach($colors as $color)
                                                @if(!empty($pro_color))
                                                <div class="custom-control custom-checkbox" id="checkerr">

                                                    <input @if(in_array($color->color_id,$pro_color)) checked @endif value="{{$color->color_id}}" name="product_color[]" type="checkbox" class="custom-control-input" id="customCheck{{$color->color_id}}" >
                                                    <label class="custom-control-label" for="customCheck{{$color->color_id}}">
                                                        
                                                        {{$color->color_name}}   </label>
                                                </div>
                                                @else
                                                 <div class="custom-control custom-checkbox" id="checkerr">

                                                    <input  value="{{$color->color_id}}" name="product_color[]" type="checkbox" class="custom-control-input" id="customCheck{{$color->color_id}}" >
                                                    <label class="custom-control-label" for="customCheck{{$color->color_id}}">
                                                        
                                                        {{$color->color_name}}   </label>
                                                </div>
                                                @endif
                                            @endforeach
                                            
                                           
                                        </div>
                                    </div>    --}}
                                   
                                     
                                    <div class="form-group row">
                                        <label for="mymce" class="col-sm-3 text-right control-label col-form-label">Short Description</label>
                                        <div class="col-sm-9">
                                            <textarea id="mymce" name="specification">{{$product->short_description}}</textarea>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label for="mymce2" class="col-sm-3 text-right control-label col-form-label">Description</label>
                                        <div class="col-sm-9">
                                            <textarea id="mymce2" name="specification">{{$product->description}}</textarea>
                                        </div>
                                    </div>
                           
                                   
                                    <div class="form-group row">
                                        <label class="col-sm-3 text-right control-label col-form-label">Images</label>
                                        <div class="col-sm-9">
                                            <div class="input-group">
                                                <span class="input-group-btn">
                                                    <span class="btn btn-default btn-file" id="imgerr">
                                                        Browse… <input name="product_image" type="file" id="imgInp">
                                                    </span>
                                                </span>
                                                <input type="text" class="form-control"  readonly>
                                            </div>
                                            <div id="img-container">
                                                <input type="hidden" name="oldfile" value="{{$product->product_image}}">
                                                 <img id='img-upload' src="{{url('public/images/product/').'/'.$product->product_image}}"  />
                                            </div>
                                           
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label for="product_price" class="col-sm-3 text-right control-label col-form-label">Sale Price</label>
                                        <div class="col-sm-9">
                                            <input name="sale_price" type="text" class="form-control" value="{{$product->sale_price}}" id="sale_price" placeholder="Sale Price">
                                        </div>
                                    </div>
                                    <!--  <div class="form-group row">
                                        <label for="product_price" class="col-sm-3 text-right control-label col-form-label">Sale Price</label>
                                        <div class="col-sm-9">
                                            <input name="sale_price" type="text" class="form-control" value="{{$product->sale_price}}" id="product_price" placeholder="Model No.">
                                        </div>
                                    </div> -->
                                   <!--  <div class="form-group row">
                                        <label for="product_price" class="col-sm-3 text-right control-label col-form-label">WholeSale Price</label>
                                        <div class="col-sm-9">
                                            <input name="wholesale_price" type="text" class="form-control" value="{{$product->wholesale_price}}" id="product_price" placeholder="Model No.">
                                        </div>
                                    </div> -->
                                    <div class="form-group row">
                                        <label for="product_price" class="col-sm-3 text-right control-label col-form-label">Purchase Price</label>
                                        <div class="col-sm-9">
                                            <input name="purchase_price" type="text" class="form-control" value="{{$product->purchase_price}}" id="product_price" placeholder="Model No.">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="product_price" class="col-sm-3 text-right control-label col-form-label"></label>
                                        <div class="col-sm-9">
                                            <div class="custom-control custom-checkbox" id="">
                                                <input value="1" name="status" @if($product->status == 1) checked="" @endif type="checkbox" class="custom-control-input" id="status" >
                                                <label class="custom-control-label" for="status">Staus</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group mb-0 text-right">
                                        <button type="submit" class="btn btn-info waves-effect waves-light">Update</button>
                                       <!--  <button type="submit" 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>
             <script src="{{url('public/backend/js/tinymce.min.js')}}"></script>
                <script type="text/javascript">
                    //$('.select2').select2();
                    
                    $(document).ready( function() {
                     //product validtion form and insert
                     $("#addProduct").validate({
                                    
                        rules:
                       {
                            product_name: {
                                required: true,
                                maxlength: 200,
                            }, 
                        
                            
                             
                            // product_image: {
                            //     required: true,
                            // },                  
                           
                       },
                        submitHandler: submitForm
                      });
                      
                      
                       function submitForm() {
                             
                            event.preventDefault();
                            var data1 = new FormData(document.getElementById('addProduct'));
                            console.log(data1);
                                
                            $.ajax({
                    
                                type : 'POST',
                                url  : "{{url('admin/product_edit')}}",
                                data : data1,
                                cache:false,
                                contentType: false,
                                processData: false,
                                success :  function (data)
                                {
                                    console.log(data);
                                    if(data.errors=='0'){
                                        $('.alert-success').show();
                                        $('.alert-danger').hide();
                                        $('.alert-success').append('<p>'+data.success+'</p>');
                                        window.location.href = "{{url('admin/all_product')}}"; 
                                        //$("#addProduct").get(0).reset();
                                    }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

                        //image upload
                        $(document).on('change', '.btn-file :file', function() {
                            var input = $(this),
                                label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
                            input.trigger('fileselect', [label]);
                        });

                        $('.btn-file :file').on('fileselect', function(event, label) {
                            
                            var input = $(this).parents('.input-group').find(':text'),
                                log = label;
                            
                            if( input.length ) {
                                input.val(log);
                            } else {
                                if( log ) alert(log);
                            }
                    
                        });
                        function readURL(input) {
                            if (input.files && input.files[0]) {
                                var reader = new FileReader();
                                
                                reader.onload = function (e) {
                                    $('#img-upload').attr('src', e.target.result);
                                }
                            
                                reader.readAsDataURL(input.files[0]);
                            }
                        }

                        $("#imgInp").change(function(){
                            readURL(this);
                        });     
                    });
                    // end image upload

                    //tinymc
                    $(function () {
                        if ($("#mymce").length > 0) {
                            tinymce.init({
                                selector: "textarea#mymce",
                                theme: "modern",
                                height: 300,
                                setup: function (editor) {
                                    editor.on('change', function () {
                                        tinymce.triggerSave();
                                    });
                                },
                                plugins: [
                                    "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                                    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                                    "save table contextmenu directionality emoticons template paste textcolor"
                                ],
                                toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons",
                            });
                        }
                        if ($("#mymce2").length > 0) {
                            tinymce.init({
                                selector: "textarea#mymce2",
                                theme: "modern",
                                height: 300,
                                setup: function (editor) {
                                    editor.on('change', function () {
                                        tinymce.triggerSave();
                                    });
                                },
                                plugins: [
                                    "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                                    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                                    "save table contextmenu directionality emoticons template paste textcolor"
                                ],
                                toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons",
                            });
                        }
                    });
                    //end tinymc
                </script>
            @endsection

VaKeR 2022