IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/stock/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/stock/vendor_po.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>Purchase Order List</strong></h2>
            </div>
            <div class="body table-responsive">
                 {!! Form::open(['method' => 'GET',  'action' => ['School\Stock\PurchaseOrderController@viewPO'], 'class' => 'form-horizontal']) !!}
                    <div class="row clearfix">
                        <div class="col-sm-2"></div>
                        <div class="col-sm-2 form-control-label">
                            <label for="classname">Financial Year</label>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                               {!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']) !!}
                            </div>
                        </div>
                        <div class="col-sm-2">
                            {!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        </div>
                    </div>
                {!! Form::close() !!} 
                <br>
                <table class="table table-bordered table-striped table-hover dataTable js-basic-example">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Date</th>
                            <th>Purchase Order No.</th>
                            <th>Reference</th>
                            <th>Vendor Name</th>
                            <th>Product</th>
                            <th>Received</th>
                            <th>Status</th>
                            <th>Total Amount</th>
                            <th>Paid Amount</th>
                            <th>Balance Amount</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($purchase_orders as $var)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            <td>{{$var->purchaseDate}}</td>
                            <td>{{$var->poNo}}</td>
                            <td>{{$var->reference}}</td>
                            <td>{{$var->supplier->bussinessName}}</td>
                            <?php 
                                $products = App\PurchaseOrderDetail::join('products','purchase_order_details.idProduct','=','products.idProduct')->select('quantity','productName')->where('idPurchaseOrder',$var->idPurchaseOrder)->get();
                            ?>
                            <td>
                            @foreach($products as $product)
                            <p>{{$product->productName}} - (x{{$product->quantity}})</p>
                            @endforeach
                            </td>
                            <?php 
                                $products = \App\ProductReceived::join('product_received_details','product_received.idProductReceived','=','product_received_details.idProductReceived')
                                ->join('products','product_received_details.idProduct','=','products.idProduct')
                                ->select('quantity','productName')->where('idPurchaseOrder',$var->idPurchaseOrder)->get();
                            ?>
                            <td>
                            @foreach($products as $product)
                            <p>{{$product->productName}} - (x{{$product->quantity}})</p>
                            @endforeach
                            </td>
                            <td>{{$var->status}}</td>
                            <td>
                                <?php
                                $received = \App\ProductReceived::where('idPurchaseOrder', '=', $var->idPurchaseOrder)
                                        ->first();
                                if ($received) {
                                    $pr_payment = \App\ProductPayment::where('idProductReceived', '=', $received->idProductReceived)
                                                    ->select(DB::raw('SUM(amountPaid) as amountPaid'))->first();
                                    if ($pr_payment) {
                                        $balance = $var->totalAmount - $pr_payment->amountPaid;
                                        if($balance < 0) $balance =  0;
                                    }
                                }
                                ?>
                                {{$var->totalAmount}}
                            </td>
                            <?php
                            $paidAmount = \App\ProductReceived::join('product_payment','product_received.idProductReceived','=','product_payment.idProductReceived')->where('idPurchaseOrder', '=', $var->idPurchaseOrder)->sum('amountPaid');
                            ?>
                            <td>{{$paidAmount}}</td>
                            <td>{{$var->totalAmount - $paidAmount}}</td>
                            <td>
                                @if($var->status == 'Closed')
                                <a href="{{url('school/purchaseorder/'.$var->idPurchaseOrder.'/pay')}}" target="_blank" class="btn btn-sm btn-success btn-round">Select</a>
                                @else
                                <a href="{{url('school/purchaseorder/'.$var->idPurchaseOrder.'/details')}}"  class="btn btn-sm btn-warning">Enter Received Items</a> 
                                @endif
                            </td>
                        </tr>
                        <?php $i++; ?>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
    $(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 Purchase Order!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/purchaseorder/')}}" +"/"+id                       
            })
            .done(function(data) {
                if(data.success == "FAILED"){
                    swal({
                        title: "Cannot be deleted", 
                        text: "Failed to delete PO as relation exists", 
                        type: "error"
                    },function() {
                    });   
                }else{
                    swal({
                        title: "Deleted", 
                        text: "Quotation 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