IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/students/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/students/checkout-canteen.blade.php

@extends('students.student_layout')
@section('content')
<div class="container-fluid">
<div class="row clearfix">
<div class="col-lg-12">
<div class="tab-content">
<div role="tabpanel" class="tab-pane in active" id="details" aria-expanded="true">
<div class="card" id="details">
    <div class="body">                                
        <div class="row">
            <div class="col-md-6 col-sm-6">
                <address>
                    <strong>{{$student->firstName}} {{$student->middleName}} {{$student->lastName}}</strong><br>
                    {{$student->ecNo}} <br>
                    {{$student->father_fname}} {{$student->father_lname}}<br>
                    <abbr title="Phone">Mobile:</abbr> {{$student->father_mobile}} 
                </address>
            </div>
            <div class="col-md-6 col-sm-6 text-right">
                <p class="m-b-0"><strong>Order Date: </strong> <?php echo date("d-m-Y");?></p>
                <p class="m-b-0"><strong>Order Status: </strong> <span class="badge bg-yellow">Pending</span></p>
            </div>
        </div>
        <div class="mt-40"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>#</th>                                                        
                                <th width="60px">Item</th>
                                <th></th>
                                <th>Quantity</th>
                                <th class="hidden-sm-down">Unit Cost</th>
                                <th>Total</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $k =0; $subtotal = 0;$isBook = 1;$isUniform = 1;?>
                            @foreach($cart as $det)
                            <?php 
                            $product =  \App\Food::select('id as idProduct','item_name as productName','pic as productImage','price as salePrice','idSchool','max_buy as max')->where('id',$det->idProduct)->first();

                            $k++; ?>
                            <tr>
                                <td>{{$k}}</td>
                                <td>
                                    @if(isset($product->productImage))
                                    <img src="{{ asset('storage/schools/'.$product->idSchool.'/foods/'.$product->productImage)}}" width="40" alt="Product img">
                                    @endif
                                </td>
                                <td>{{$product->productName}}</td>
                                <td>{{$det->qty}} Pcs</td>
                                <td class="hidden-sm-down">₹{{$product->salePrice}}</td>
                                @php
                                    $price = $product->salePrice * $det->qty;
                                    $subtotal = $subtotal + $price;
                                @endphp
                                <td>₹{{$product->salePrice * $det->qty}}</td>
                                <td><a class="btn btn-danger btn-round waves-effect" href="/student/canteen-checkout?removeItem={{base64_encode($det->idCart)}}">Remove Item</a></td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-md-6">
            </div>
            <div class="col-md-6 text-right">
                <p class="m-b-0"><b>Total Amount</b> : ₹{{$subtotal}}</p>   
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
            </div>
            <div class="col-md-6 text-right">
                <button class="btn btn-primary btn-round waves-effect" type="button" id="submit-btn">Pay Now  ₹{{$subtotal}}</button>
            </div>
        </div>
    </div>
</div>
</div>                  
</div>
</div>
</div>

<div class="modal" tabindex="-1" role="dialog" id="paymentModal" aria-labelledby="paymentModalLabel" aria-hidden="true" data-backdrop="">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-body">
        <div id="payment-form"></div>
      </div>
    </div>
  </div>
</div>

@stop
@section('script')
@if($mode == "cashfree")
<script src="https://sdk.cashfree.com/js/ui/1.0.26/dropinClient.prod.js"></script>
<script>
    document.getElementById('submit-btn').onclick = function (e) {
        e.preventDefault();
        $("#submit-btn").prop('disabled', true);
        $.ajax({
            method: 'post',
            beforeSend: function(request) {
                request.setRequestHeader("X-CSRF-TOKEN", "{{csrf_token()}}");
            },
            url: "{!!url('student/canteen/order')!!}",
            success:function(result){
//               console.log(result);
               $('#paymentModal').modal('show')
               var orderToken = result["order_token"];
               const dropConfig = {
                    "components": [
                        "order-details",
                        "card",
                        "netbanking",
                        "app",
                        "upi"
                    ],
                    "orderToken": orderToken,
                    "onSuccess": function(data) {
                        //on payment flow complete
                        if (data.order && data.order.status == "PAID") {
                            $.ajax({
                                url: "{!!url('student/checkpaymentstatus-cashfree?order_id=')!!}" + data.order.orderId,
                                success: function(result) {
                                    window.location.href = "{{url('student/canteen-receipts')}}";
                                },
                            });
                        } else {
                            //order is still active
                            alert("Order is ACTIVE")
                        }
                    },
                    "onFailure": function(data) {
                        //on failure during payment initiation
                        alert(data.order.errorText);
                    },
                    "style": {
                        //to be replaced by the desired values
                        "backgroundColor": "#ffffff",
                        "color": "#11385b",
                        "fontFamily": "Lato",
                        "fontSize": "14px",
                        "errorColor": "#ff0000",
                        "theme": "light", //(or dark)
                    }
                }
                $('#submit-btn').hide();
                const cashfree = new Cashfree();
                const paymentElement = document.getElementById("payment-form");
                cashfree.initialiseDropin(paymentElement, dropConfig);
            }
        });
    }
</script>
@else
<script src="https://ebz-static.s3.ap-south-1.amazonaws.com/easecheckout/easebuzz-checkout.js"></script> 
<script>
    document.getElementById('submit-btn').onclick = function (e) {
        e.preventDefault();
        $("#submit-btn").prop('disabled', true);
        $.ajax({
            method: 'post',
            beforeSend: function(request) {
                request.setRequestHeader("X-CSRF-TOKEN", "{{csrf_token()}}");
            },
            url: "{!!url('student/canteen/order')!!}",
            success:function(result){
//               console.log(result);
                $('#paymentModal').modal('show')
               var easebuzzCheckout = new EasebuzzCheckout(result["key"], 'prod')
               var options = {
                    access_key: result["token"], // access key received via Initiate Payment
                    onResponse: (response) => {
                        if (response.status == "success") {
                            $.ajax({
                                url: "{!!url('student/checkpaymentstatus-easebuzz?order_id=')!!}" + response.txnid,
                                success: function(result) {
                                    window.location.href = "{{url('student/canteen-receipts')}}";
                                },
                            });
                        } 
                    },
                    theme: "#11385b" // color hex
                }
                $('#submit-btn').hide();
                easebuzzCheckout.initiatePayment(options);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
                var err = JSON.parse(XMLHttpRequest.responseText);
                alert(err.message);
            }
        });
    }
</script>

@endif
@stop

Copyright © 2021 - 2025 IMMREX7