IMMREX7

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

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12">
        <!--<div class="card">-->
        <div class="body">
            <button class="btn btn-raised btn-warning btn-round waves-effect" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Advance Search</button>
            <div class="collapse" id="collapseExample">
                <div class="well">
                    <div class="row clearfix">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <div class="card">
                                <div class="header">
                                    <h2><strong>Advance Search</strong></h2>
                                </div>
                                <div class="body">
                                   <form method ="get" action = "/school/headwisefees-class-report" class = "form-horizontal">
                                    <div class="row clearfix">
                                        <div class="col-sm-6">
                                            <div class="row clearfix">
                                                <div class="col-sm-3 form-control-label">
                                                    <label for="classname">Class</label>
                                                </div>
                                                <div class="col-sm-7">
                                                    <div class="form-group">
                                                        <div style="border:1px solid #ccc; width:250px; height: 150px; overflow-y: scroll;">
                                                            @foreach($classes as $key => $value)
                                                            <div class="checkbox-inline" style="padding-left:10px;padding-top:5px;">
                                                                <input type="checkbox" name="classes[]" value="{{$key}}" class="class_ids">
                                                                <label>{{$value}}</label>
                                                            </div>
                                                            @endforeach
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!--<div class="col-sm-6">
                                            <div class="row clearfix">
                                                <div class="col-sm-3 form-control-label">
                                                    <label for="classname">Section</label>
                                                </div>
                                                <div class="col-sm-7">
                                                    <div class="form-group">
                                                        <div id="idSection" style="border:1px solid #ccc; width:250px; height: 150px; overflow-y: scroll;">

                                                        </div>-->
                                                        <!--<select name='idSection' id="idSection" class="form-control show-tick ms"></select>--> <!--
                                                    </div>
                                                </div>
                                            </div>
                                        </div>-->
                                    </div>

                                    <div class="row clearfix">
                                        <div class="col-sm-8 offset-sm-2">
                                            {!! Form::submit('Search', ['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--</div>-->
    </div>
</div>
<div class="row clearfix">
    <div class="col-lg-3 col-md-6 col-sm-12">
        <div class="card info-box-2 l-seagreen">
            <div class="body">
                <div class="content col-12">
                    <div class="text" style="color: black;">Total Amount</div>
                    <div class="number" style="color: black;"  id="tamount">₹0.00</div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-3 col-md-6 col-sm-12">
        <div class="card info-box-2 l-parpl">
            <div class="body">
                <div class="content col-12">
                    <div class="text" style="color: black;">Total Paid</div>
                    <div class="number" style="color: black;" id="tpaid">₹0.00</div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-2 col-md-6 col-sm-12">
        <div class="card info-box-2 l-coral">
            <div class="body">
                <div class="content col-12">
                    <div class="text" style="color: black;">TOTAL Due</div>
                    <div class="number" style="color: black;" id="tdue">₹0.00</div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-2 col-md-6 col-sm-12">
        <div class="card info-box-2 l-coral">
            <div class="body">
                <div class="content col-12">
                    <div class="text" style="color: black;">Total Fine</div>
                    <div class="number" style="color: black;" id="tfine">₹0.00</div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-2 col-md-6 col-sm-12">
        <div class="card info-box-2 l-blue">
            <div class="body">
                <div class="content col-12">
                    <div class="text" style="color: black;">Total Discount</div>
                    <div class="number" style="color: black;" id="tdiscount">₹0.00</div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header" style="margin-bottom: 0px;">
                <h2><strong>Header Wise Data</strong></h2>
                <br><p style="margin-bottom: 0px;">Note: This is overall data and will not change when a filter is applied.</p>
            </div>
        <div class="body row">
         <div class="col-sm-6 col-lg-4">
                <table style="width:100%;border : 1px solid black;text-align:center;" border="1">
                    <tbody>
                        <tr>
                            <th colspan="2">Today's Collection ({{ \Carbon\Carbon::now()->format('d-m-Y') }})</th>
                        </tr>
                        <tr>
                            <td colspan="2">₹{{ $todayCollection }}</td>
                        </tr>
                    </tbody>
                </table>
         </div>
         <div class="col-sm-6 col-lg-4">
                <table style="width:100%;border : 1px solid black;text-align:center;" border="1">
                    <tbody>
                        <tr>
                            <th colspan="2">Week's Collection ({{ \Carbon\Carbon::now()->startOfWeek()->format('d-m-Y') .' to '. \Carbon\Carbon::now()->endOfWeek()->format('d-m-Y') }})</th>
                        </tr>
                        <tr>
                            <td colspan="2">₹{{ $weekCollection }}</td>
                        </tr>
                    </tbody>
                </table>
         </div>
         <div class="col-sm-6 col-lg-4">
                <table style="width:100%;border : 1px solid black;text-align:center;" border="1">
                    <tbody>
                        <tr>
                            <th colspan="2">@if($monthStart != null) Month's Collection ({{ $monthStart->paymentDate .' to '. $monthEnd->paymentDate }}) 
                                @else  Month's Collection ({{ $firstDay->format('d-m-Y') .' to '. $startDate->format('d-m-Y') }}) @endif</th>
                        </tr>
                        <tr>
                            <td colspan="2">₹{{ $monthCollection }}</td>
                        </tr>
                    </tbody>
                </table>
         </div>
         </div>
         </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Header Wise Data</strong></h2>
           </div>
            <div class="body row">
                @php $headerwise = [];
$headerwiseIds = [];
$indx = 10001; @endphp 
                @foreach ($feeheaders as $k => $vi)
                <div class="col-sm-6 col-lg-3" @if($k > 3) style="margin-top: 20px;" @endif>
                    <table style="width:100%;border : 1px solid black;text-align:center;" border="1">
                        <tbody>
                            <tr>
                                <th colspan="2" style="padding: 15px;">{{ $vi }}</th>
                                @php 
                                $headerwise[base64_encode($vi)]['paid'] = 0;
    $headerwise[base64_encode($vi)]['total'] = 0;
    $headerwiseIds[base64_encode($vi)] = $indx;
                                @endphp 
                            </tr>
                            <tr>
                                <th>Total</th>
                                <th>Paid</th>
                            </tr>
                            <tr>
                                <td style="width : 50%;padding: 15px;" id="{{ $indx }}_t">₹0.00</td>
                                <td style="width : 50%;padding: 15px;" id="{{ $indx }}_p">₹0.00</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <?php    $indx++;?>
                @endforeach
            </div>   
        </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Class & Section Wise Data</strong></h2>
           </div>
            <div class="body row">
                @php $l = 0;
$sectionwise = [];@endphp
                @foreach ($filterClass as $m => $n)
                @php $section = $sectionArr[$m];@endphp
                @foreach ($section as $k => $vi)
                <div class="col-sm-3" @if($l > 3) style="margin-top: 20px;" @endif>
                    <table style="width:100%;border : 1px solid black;text-align:center;" border="1">
                        <tbody>
                            <tr>
                                <th colspan="2" style="padding: 15px;">{{ $n }} - {{ $vi }}</th>
                                @php 
                                $sectionwise[$k]['paid'] = 0;
        $sectionwise[$k]['total'] = 0;
                                @endphp 
                            </tr>
                            <tr>
                                <th>Total</th>
                                <th>Paid</th>
                            </tr>
                            <tr>
                                <td style="width : 50%;padding: 15px;" id="{{ $k  }}_t">₹0.00</td>
                                <td style="width : 50%;padding: 15px;" id="{{ $k  }}_p">₹0.00</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                @php $l++;@endphp
                @endforeach
                @endforeach
            </div>   
        </div>
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Student Wise Fee Data</strong></h2>
           </div>
            <?php $receipt = []; ?>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover dataTable" id="tableexp">
                    <thead>
                        <tr>
                            <th>Ec No.</th>
                            <th>Name</th>
                            <th>Class</th>
                            <th>Section </th>
                            <th>Category</th>
                            @foreach ($feeheaders as $k => $vi)
                            <?php    $receipt[$vi] = 0; ?>
                            <th>{{ $vi }}</th>
                            @endforeach
                            <th>Total  <?php $receipt['total'] = 0; ?></th>
                            <th>Discount  <?php $receipt['discount'] = 0; ?></th>
                            <th>Fine <?php $receipt['fine'] = 0; ?> </th>
                            <th>Paid <?php $receipt['paid'] = 0; ?></th>
                            <th>Due<?php $receipt['due'] = 0; ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($students as $var)
                        <?php
    $paidHeaders = \DB::table('student_transaction_details')
        ->join('student_transaction', 'student_transaction_details.idTransaction', '=', 'student_transaction.idTransaction')
        ->join('feeheads', 'student_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
        ->select('feeheads.feeheadName', 'student_transaction_details.status', 'feeheads.amount as totalPaid', 'student_transaction_details.fine', 'student_transaction_details.discount')
        ->where('student_transaction_details.idStudent', '=', $var->idStudent)
        ->where('student_transaction.idFinancialYear', '=', Session::get('idFinancialYear'))
        ->where(function ($query) {
            $query->whereNull('student_transaction_details.status');
            $query->orWhere('student_transaction_details.status', '=', 'In-Process');
            $query->orWhere('student_transaction_details.status', '=', 'Cleared');
            $query->orWhere('student_transaction_details.status', '=', 'Success');
        })
        ->get();

    $lessHeaders = \DB::table('lesser_transaction_details')
        ->join('lesser_transaction', 'lesser_transaction_details.idLesserTransaction', '=', 'lesser_transaction.idLesserTransaction')
        ->join('feeheads', 'lesser_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
        ->select('feeheads.feeheadName', 'lesser_transaction_details.status', 'lesser_transaction.totalPaid', 'lesser_transaction_details.fine', 'lesser_transaction_details.discount')
        ->where('lesser_transaction_details.idStudent', '=', $var->idStudent)
        ->where('lesser_transaction.idFinancialYear', '=', Session::get('idFinancialYear'))
        ->where(function ($query) {
            $query->whereNull('lesser_transaction_details.status');
            $query->orWhere('lesser_transaction_details.status', '=', 'In-Process');
            $query->orWhere('lesser_transaction_details.status', '=', 'Cleared');
            $query->orWhere('lesser_transaction_details.status', '=', 'Success');
        })
        ->get();
    $plan = "Installment";
    foreach ($paidHeaders as $headers) {
        if (str_contains($headers->feeheadName, 'Full Payment')) {
            $plan = "Plan A (Full Payment)";
        } else if (str_contains($headers->feeheadName, 'Installment'))
            $plan = "Installment";
    }
    foreach ($lessHeaders as $headers) {
        if (str_contains($headers->feeheadName, 'Full Payment')) {
            $plan = "Plan A (Full Payment)";
        } else if (str_contains($headers->feeheadName, 'Installment'))
            $plan = "Installment";
    }                                
                        ?>
                        <tr>
                            <td>{{$var->ecNo}}</td>
                            <td>{{$var->firstName}} {{$var->middleName}} {{$var->lastName}}</td>
                            <td>@if(isset($var->classM)) {{$var->classM->className}} @endif</td>
                            <td>@if(isset($var->section)) {{$var->section->sectionName}} @endif</td>
                            <td>{{$var->studentType}}</td>
                            @php $total = 0;
    $discount = 0;
    $fine = 0;
    $fee = 0;
    $lastParentId = "";
                            @endphp
                            @foreach ($feeheaders as $k => $vk)
                            <?php
        $lesserTransaction = null;
        $transaction = null;
        $feeTotal = 0;
        if ($plan == "Plan A (Full Payment)") {
            if (!str_contains($vk, 'Installment')) {
                $class_feeheads = \DB::table('feeheads')->where('idClass', '=', $var->idClass)
                    ->where('idSection', '=', $var->idSection)
                    ->where('studentCategory', '=', $var->studentType)
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->whereNull('idStudent');
                $allcat_feeheads = \DB::table('feeheads')->where('idClass', '=', $var->idClass)
                    ->where('idSection', '=', $var->idSection)
                    ->where('studentCategory', '=', 'All')
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->whereNull('idStudent');

                $feeheads = \DB::table('feeheads')
                    ->where('idStudent', '=', $var->idStudent)
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->union($class_feeheads)
                    ->union($allcat_feeheads)
                    ->orderBy('toDate')
                    ->get();
                $feeTotal = $feeheads->sum('amount');
            }
        } else {
            if (!str_contains($vk, 'Full Payment')) {
                $class_feeheads = \DB::table('feeheads')->where('idClass', '=', $var->idClass)
                    ->where('idSection', '=', $var->idSection)
                    ->where('studentCategory', '=', $var->studentType)
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->whereNull('idStudent');
                $allcat_feeheads = \DB::table('feeheads')->where('idClass', '=', $var->idClass)
                    ->where('idSection', '=', $var->idSection)
                    ->where('studentCategory', '=', 'All')
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->whereNull('idStudent');

                $feeheads = \DB::table('feeheads')
                    ->where('idStudent', '=', $var->idStudent)
                    ->where('idFinancialYear', '=', $var->idFinancialYear)
                    ->where('feeheadName', $vk)
                    ->union($class_feeheads)
                    ->union($allcat_feeheads)
                    ->orderBy('toDate')
                    ->get();
                $feeTotal = $feeheads->sum('amount');
            }
        }

        $transaction = DB::table('student_transaction_details')
            ->join('feeheads', 'student_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
            ->select('student_transaction_details.*')
            ->where('feeheadName', $vk)
            ->where('student_transaction_details.idStudent', '=', $var->idStudent)
            ->where(function ($query) {
                $query->whereNull('status');
                $query->orWhere('status', '=', 'In-Process');
                $query->orWhere('status', '=', 'Cleared');
                $query->orWhere('status', '=', 'Success');
            })
            ->first();

        if ($transaction == null) {
            $lesserTransaction = DB::table('lesser_transaction_details')
                ->join('feeheads', 'lesser_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
                ->select(DB::raw('SUM(amountPaid) as amountPaid'), DB::raw('SUM(lesser_transaction_details.fine) as fine'), DB::raw('SUM(lesser_transaction_details.discount) as discount'))
                ->where('feeheadName', $vk)
                ->where('lesser_transaction_details.idStudent', '=', $var->idStudent)
                ->where(function ($query) {
                    $query->whereNull('status');
                    $query->orWhere('status', '=', 'In-Process');
                    $query->orWhere('status', '=', 'Cleared');
                    $query->orWhere('status', '=', 'Success');
                })
                ->first();

            if ($lesserTransaction != null) {
                $actual = $lesserTransaction->amountPaid - $lesserTransaction->fine;
                $total += $actual;
                $discount += $lesserTransaction->discount;
                $fine += $lesserTransaction->fine;
            }
        } else if ($transaction != null) {
            $parent = DB::table('student_transaction')->where('idTransaction', $transaction->idTransaction)
                ->where(function ($query) {
                    $query->whereNull('status');
                    $query->orWhere('status', '=', 'In-Process');
                    $query->orWhere('status', '=', 'Cleared');
                    $query->orWhere('status', '=', 'Success');
                })->first();
            if ($parent != null) {
                if ($lastParentId != $transaction->idTransaction) {
                    $lastParentId = $transaction->idTransaction;
                    $fine += $parent->fine;
                    $discount += $parent->discount;
                }
                $total += $feeTotal;
            }
            //$fine += $transaction->fine;
        }
        $fee += $feeTotal;
                            ?>
                            <td @if($transaction != null) 
                            style="background-color:green;color:white;"  @else 
                            @if($lesserTransaction != null) @if($lesserTransaction->amountPaid > 0) style="background-color:orange;color:black;" @endif @endif  @endif>
                            
                            @if($transaction != null) 
                             {{ $feeTotal }} (Paid)
                            @elseif($lesserTransaction != null)  
                                @if($lesserTransaction->amountPaid > 0) {{ $lesserTransaction->amountPaid - $lesserTransaction->fine }} (Paid) - {{ $feeTotal }} (Actual) 
                                @else {{ $feeTotal }}
                                @endif 
                            @else {{ $feeTotal }} @endif </td>

                            <?php        if ($transaction != null) {
            $receipt[$vk] += $feeTotal;
            $headerwise[base64_encode($vk)]['paid'] += $feeTotal;
            $headerwise[base64_encode($vk)]['total'] += $feeTotal;
            $sectionwise[$var->idSection]['paid'] += $feeTotal;
            $sectionwise[$var->idSection]['total'] += $feeTotal;
        } else if ($lesserTransaction != null) {
            $receipt[$vk] += ($lesserTransaction->amountPaid - $lesserTransaction->fine);
            $headerwise[base64_encode($vk)]['paid'] += ($lesserTransaction->amountPaid - $lesserTransaction->fine);
            $headerwise[base64_encode($vk)]['total'] += $feeTotal;
            $sectionwise[$var->idSection]['paid'] += ($lesserTransaction->amountPaid - $lesserTransaction->fine);
            $sectionwise[$var->idSection]['total'] += $feeTotal;
        } else {
            $receipt[$vk] += $feeTotal;
            $headerwise[base64_encode($vk)]['total'] += $feeTotal;
            $sectionwise[$var->idSection]['total'] += $feeTotal;
        } 
                            ?>
                            @endforeach
                            <td>{{ $fee }} <?php    $receipt['total'] += $fee; ?></td>
                            <td>{{ $discount }} <?php    $receipt['discount'] += $discount; ?></td>
                            <td>{{ $fine }} <?php    $receipt['fine'] += $fine; ?></td>
                            <td>{{ $total }} <?php    $receipt['paid'] += $total; ?></td>
                            <td>{{ $fee - $total }} <?php    $receipt['due'] += ($fee - $total); ?></td>
                        </tr>
                        @endforeach
                    </tbody>
                    <tfoot>
                        <tr>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            @foreach ($feeheaders as $k => $vi)
                            <th>{{ $vi }}: {{ $receipt[$vi] }}</th>
                            @endforeach
                            <th>Total : {{ $receipt['total'] }}</th>
                            <th>Discount : {{ $receipt['discount'] }}</th>
                            <th>Fine: {{ $receipt['fine'] }}</th>
                            <th>Paid: {{ $receipt['paid'] }}</th>
                            <th>Due: {{ $receipt['due'] }}</th>
                        </tr>
                    </tfoot>
                </table>
           </div>
        </section>
    </div>
</div>
@stop
@section('script')
<script>
    $('.selectAll').on('click', function () {
        var checkAll = this.checked;
        if (checkAll === true) {
            $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });
        } else {
            $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });
        }
    });
    $(function () {
        @foreach ($headerwise as $header => $value)
        $('#{{ $headerwiseIds[$header]}}_t').html('₹{{ $value['total'] }}');
        $('#{{ $headerwiseIds[$header]}}_p').html('₹{{ $value['paid'] }}');
        @endforeach
        @foreach ($sectionwise as $header => $value)
        $('#{{ $header}}_t').html('₹{{ $value['total'] }}');
        $('#{{ $header}}_p').html('₹{{ $value['paid'] }}');
        @endforeach
        $('#tfine').html('₹{{ $receipt['fine'] }}');
        $('#tpaid').html('₹{{ $receipt['paid'] }}');
        $('#tdue').html('₹{{ $receipt['due'] }}');
        $('#tdiscount').html('₹{{ $receipt['discount'] }}');
        $('#tamount').html('₹{{ $receipt['total'] }}');
        $('#tableexp').DataTable({
        
            dom: 'Bfrtip',
            scrollY:        "500px",
            scrollX:        true,
            scrollCollapse: true,
            fixedColumns:   {
                left: 1
            },
            buttons: [
                {
                     extend: 'csv', footer: true, text: 'Export to Excel',title:'Student Due Report',
                }
                
            ]
        });
    });
    $(document).on('click', '.class_ids', function () {
        //var checkAll = this.checked;
        var classIds = [];
        $("input:checkbox[name='classes[]']:checked").each(function () {
            classIds.push($(this).val());
        });
        if (classIds.length > 0) {
            $.ajax({
                url: "{{url('/school/schclass') }}" + '/' + classIds + "/sections",
                type: "GET",
                dataType: "json",
                success: function (data) {
                    $('#idSection').empty();
                    $('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><input type="checkbox" class="select-all" id="selectall"><label><strong>Select All</label></strong></div>');
                    $.each(data, function (key, value) {
                        $('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="sections[]" value="' + key + '" class="sectionclass"><label>' + value + '</label></div>');
                    });
                }
            });
        }
    });
    $(document).on('click', '.select-all', function () {
        var checkAll = this.checked;
        if (checkAll === true) {
            $('.sectionclass').each(function () {
                this.checked = checkAll;
            });
        } else {
            $('.sectionclass').each(function () {
                this.checked = checkAll;
            });
        }
    });
</script>
@stop

Copyright © 2021 - 2025 IMMREX7