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 : |
@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">New Product</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">Add Product</h4> @include('backend.layout.verror_message') <div class="form-group row"> <label for="product_name" class="col-sm-3 text-right control-label col-form-label">Product Code</label> <div class="col-sm-9"> <input type="hidden" id="product_code_h" name="product_code" value="PID-{{$product_code}}"> <input disabled value="PID-{{$product_code}}" name="" type="text" class="form-control" id="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) <option value="{{$category->category_id}}">{{$category->category_name}}</option> @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" placeholder="Product Name"> </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="short_description"></textarea> </div> </div> <div class="form-group row"> <label for="mymce1" class="col-sm-3 text-right control-label col-form-label">Description</label> <div class="col-sm-9"> <textarea id="mymce1" name="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"> <img id='img-upload' src="https://webdevtrick.com/wp-content/uploads/preview-img.jpg" /> </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="" 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">Purchase Price</label> <div class="col-sm-9"> <input name="purchase_price" type="text" class="form-control" value="" id="purchase_price" placeholder="Purchase Price"> </div> </div> <!-- <div class="form-group row"> <label for="product_price" class="col-sm-3 text-right control-label col-form-label">Order Level</label> <div class="col-sm-9"> <input name="position" type="text" class="form-control" value="1" id="position" placeholder="Order Level"> </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" checked="" 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">Save</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_code: { required: true, maxlength: 200, }, model: { required: true, }, brand: { required: true, }, category:{ required: true, }, product_color: { required: true, }, product_image: { required: true, }, sale_price: { required: true, }, purchase_price: { required: true, }, }, submitHandler: submitForm }); function submitForm() { var data1 = new FormData(document.getElementById('addProduct')); event.preventDefault(); //var data1 = new FormData(document.getElementById('addProduct')); //console.log($('#mymce').val()); $.ajax({ type : 'POST', url : "{{url('admin/new_product')}}", data : data1, cache:false, contentType: false, processData: false, success : function (data) { console.log(data); if(data.errors=='0'){ $.ajax({ type : 'GET', url : "{{url('admin/get_new_product_code')}}", success : function (res) { $('.alert-success').show(); $('.alert-danger').hide(); $('.alert-success').append('<p>'+data.success+'</p>'); $("#addProduct").get(0).reset(); $('#img-upload').attr('src','https://webdevtrick.com/wp-content/uploads/preview-img.jpg'); $('#product_code').val('PID-'+res); $('#product_code_h').val('PID-'+res); } }); //window.location="{{url('all_product')}}"; }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, statusbar: false, 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 //tinymc $(function () { if ($("#mymce1").length > 0) { tinymce.init({ selector: "textarea#mymce1", theme: "modern", height: 300, statusbar: false, 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