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/vendor_dashboard.blade.php

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-sm-6">
        <div class="card">
            <div class="header">
                <h2><strong>Product Availability Page</strong></h2>
                <h5><strong>Update Area</strong></h5>
                @php
                if($vendor != null){
                    $vendorTime = explode("-",$vendor->order_time);
                    $now = \Carbon\Carbon::now();
                    $toTime = \Carbon\Carbon::parse($now->format('d-M-Y').' '.$vendorTime[0]);
                    $now->subDays(1);
                    $fromTime = \Carbon\Carbon::parse($now->format('d-M-Y').' '.$vendorTime[1]);

                    $nightNow = \Carbon\Carbon::now();
                    $nightFrom = \Carbon\Carbon::parse($nightNow->format('d-M-Y').' '.$vendorTime[1]);
                    $nightNow->addDays(1);
                    $nightTo = \Carbon\Carbon::parse($nightNow->format('d-M-Y').' '.$vendorTime[0]);
                }
                

                @endphp
                @if($vendor != null)
                <p>You can update the menu from {{$vendorTime[1]}} today to {{$vendorTime[0]}} tomorrow</p>
                @endif
            </div>
            
            <form action="/school/manage-food-stock" method="post">
            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover dataTable wrap" id="tableexp">
                    <thead>
                        <tr>
                            <th>Select</th>
                            <th>Photo</th>
                            <th>Name & Description</th>
                            <th>Price</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($food as $value)
                        <tr>
                            <td>  @if(!in_array($value->id, $item))<input type='checkbox' name='products[]' value='{{$value->id}}' /> @endif</td>
                            <td><img src="{{ asset('storage/schools/'.$value->idSchool.'/foods/'.$value->pic)}}" height="60"></td>
                            <td>{{$value->item_name}}<br>{{$value->short_description}}</td>
                            <td>{{$value->price}}</td>
                        </tr>
                        @endforeach
                    </tbody>
                    <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </tfoot>
                </table>
                @if($vendor != null)
                @if (str_contains($fromTime->diffForHumans(), 'ago') && str_contains($toTime->diffForHumans(), 'now'))
                <button class="btn btn-raised btn-warning btn-round waves-effect" type="submit">Update Data</button>
                @endif
                @if (str_contains($nightFrom->diffForHumans(), 'ago') && str_contains($nightTo->diffForHumans(), 'now'))
                <button class="btn btn-raised btn-warning btn-round waves-effect" type="submit">Update Data</button>
                @endif
                @endif
            </div>
            </form>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="card">
            <div class="header">
                <h2><strong>Available Product</strong></h2>
            </div>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover dataTable" id="tableData">
                    <thead>
                        <tr>
                            <th>Photo</th>
                            <th>Name & Description</th>
                            <th>Price</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach ($stock as $value)
                        <tr>
                            <td><img src="{{ asset('storage/schools/'.$value->idSchool.'/foods/'.$value->pic)}}" height="60"></td>
                            <td>{{$value->item_name}}<br>{{$value->short_description}}</td>
                            <td>{{$value->price}}</td>
                            <td> <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idStock}}" data-type="confirm">DELETE</button> </td>
                        </tr>
                        @endforeach
                    </tbody>
                    <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </tfoot>
                </table>
            </div>
            
        </div>
    </div>
</div>
@stop
@section('script')
<script>

$(function () {
    $('#tableexp').DataTable({
      
        dom: 'Bfrtip',
         scrollY:        "500px",
        scrollX:        true,
        scrollCollapse: true,
        fixedColumns:   {
            left: 1
        },
        buttons: [
            { extend: 'csv', footer: true, text: 'Excel',title:'Product List',
                exportOptions: {
                    columns: [1,2,3,],
                    format: {
                     body: function (data, row, column, node ) {
                                if(column === 2 )
                                return "\0" + data ;
                                else if( column === 5 )
                                return data.replace( '<br>', '\r\n');
                                else return data;
                               
                                }
                            }
                }
            }
            
        ]
    });

    $('#tableData').DataTable({
      
      dom: 'Bfrtip',
       scrollY:        "500px",
      scrollX:        true,
      scrollCollapse: true,
      fixedColumns:   {
          left: 1
      },
      buttons: [
          { extend: 'csv', footer: true, text: 'Excel',title:'Product List',
              exportOptions: {
                  columns: [1,2,3,],
                  format: {
                   body: function (data, row, column, node ) {
                              if(column === 2 )
                              return "\0" + data ;
                              else if( column === 5 )
                              return data.replace( '<br>', '\r\n');
                              else return data;
                             
                              }
                          }
              }
          }
          
      ]
  });
});
$(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/remove-food-stock/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Stock 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