IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/canteen/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/canteen/food.blade.php

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>@if(isset($product))Edit @else  Add @endif Food Items</strong></h2>
            </div>
            <div class="body">
                @if(isset($product))
                {!! Form::model($product, ['method' => 'PATCH', 'action' => ['School\Canteen\FoodController@update', $product->id], 'class' => 'form-horizontal','files'=>true]) !!}
                @else
                {!! Form::open(['url' => 'school/add-food-items', 'class' => 'form-horizontal','id'=>'form','files'=>true]) !!}
                @endif
                
                <div class="row clearfix">
                    <div class="col-sm-2 form-control-label required">
                        <label for="classname">Product Name</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('item_name',null,['class' => 'form-control','required'=>'required']) !!}
                            @if ($errors->has('item_name'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('item_name') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                    <div class="col-sm-2 form-control-label">
                        <label for="classname">Product Image</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            <img style="border-radius: 60px; width: 100px;height: 100px; margin-top:10px;"  id="uploadPreview" name="image">
                            @if(isset($product))
                            <img src="{{ asset('storage/schools/'.$product->idSchool.'/products/'.$product->productImage)}}" height="100">
                            @endif
                            <input type="file"  name="productImage" id="image" onchange="PreviewImage();">
                            @if ($errors->has('productImage'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('productImage') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-2 form-control-label required">
                        <label for="classname">Max Buy</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('max_buy',null,['class' => 'form-control','required'=>'required']) !!}
                            @if ($errors->has('max_buy'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('max_buy') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                    <div class="col-sm-2 form-control-label required">
                        <label for="classname">Sale Price</label>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            {!! Form::text('price',null,['class' => 'form-control','required'=>'required']) !!}
                            @if ($errors->has('price'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('price') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-2 form-control-label">
                        <label for="classname">Short Description</label>
                    </div>
                    <div class="col-sm-7">
                        <div class="form-group">
                            {!! Form::textarea('short_description',null,['class' => 'form-control','size'=>'30x2']) !!}
                            @if ($errors->has('short_description'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('short_description') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                    
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        @if(isset($product))
                        {!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        @else
                        {!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
                        @endif
                        {!! Form::close() !!} 
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Food Items</strong></h2>
            </div>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Image</th>
                            <th>Name</th>
                            <th>Price</th>
                            <th>Max Buy</th>
                            <th>Description</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($products as $value)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            <td><img src="{{ asset('storage/schools/'.$value->idSchool.'/foods/'.$value->pic)}}" height="60"></td>
                            <td>{{$value->item_name}}</td>
                            <td>{{$value->price}}</td>
                            <td>{{$value->max_buy}}</td>
                            <td>{{$value->short_description}}</td>
                            <td>
                                <a href="{{ url('school/add-food-items/' . $value->id . '/edit') }}"  class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
                                <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->id}}" data-type="confirm">DELETE</button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
function PreviewImage() {
    var oFReader = new FileReader();
    oFReader.readAsDataURL(document.getElementById("image").files[0]);
    oFReader.onload = function (oFREvent) {
        document.getElementById("uploadPreview").src = oFREvent.target.result;
    };
}
$(document).on('click', '.js-sweetalert', function (e) {
    $.ajaxSetup({
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    e.preventDefault();
    var id = $(this).data('id');
    swal({
            title: "Are you sure?",
            text: "Are You sure you want to delete this item!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/add-food-items/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Food Item has been successfully deleted", 
                    type: "success"
                },function() {
                    location.reload();
                });
            })
            .error(function(data) {
              swal("Oops", "We couldn't connect to the server!", "error");
            });
            return false;
    });
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7