IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/storage/framework/views/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/storage/framework/views/2b6146f594c27af00d792f2d4b10a27a57b667bd.php

<?php $__env->startSection('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">
                                    <?php echo Form::open(['method' => 'GET',  'action' => ['School\StdTransactionReportController@todayReport'], 'class' => 'form-horizontal']); ?>

                                    <div class="row clearfix">
                                        <div class="col-sm-4">
                                            <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;">
                                                            <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <div class="checkbox-inline" style="padding-left:10px;padding-top:5px;">
                                                                <input type="checkbox" name="classes[]" value="<?php echo e($key); ?>" class="class_ids">
                                                                <label><?php echo e($value); ?></label>
                                                            </div>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row clearfix">
                                                <div class="col-sm-3 form-control-label">
                                                    <label for="classname">From Date</label>
                                                </div>
                                                <div class="col-sm-7">
                                                    <div class="form-group">
                                                        <?php echo Form::text('fromDate',null,['class' => 'form-control datepicker']); ?>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-4">
                                            <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 class="row clearfix">
                                                <div class="col-sm-3 form-control-label">
                                                    <label for="classname">To Date</label>
                                                </div>
                                                <div class="col-sm-7">
                                                    <div class="form-group">
                                                        <?php echo Form::text('toDate',null,['class' => 'form-control datepicker']); ?>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        
                                        
                                        <div class="col-sm-4">
                                            <div class="row clearfix">
                                                <div class="col-sm-3 form-control-label">
                                                    <label for="headername">Headers</label>
                                                </div>
                                                <div class="col-sm-7">
                                                    <div class="form-group">
                                                        <div id="idHeaders" style="border:1px solid #ccc; width:250px; height: 150px; overflow-y: scroll;">
                                                             <?php $__currentLoopData = $feeHeaders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <div class="checkbox-inline" style="padding-left:10px;padding-top:5px;">
                                                                <input type="checkbox" name="feeHeaders[]" value="<?php echo e($key); ?>" class="fee_ids">
                                                                <label><?php echo e($value); ?></label>
                                                            </div>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            
                                            <div class="row clearfix">
                                                <div class="col-sm-5 form-control-label">
                                                    <label for="classname">Payment Mode</label>
                                                </div>
                                                <div class="col-sm-6">
                                                    <div class="form-group">
                                                        <?php echo Form::select('paymentMode',payModeReport(),null,['class' => 'form-control show-tick ms','id'=>'paymode']); ?>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row clearfix">
                                        <div class="col-sm-8 offset-sm-2">
                                            <?php echo Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>

                                            <?php echo Form::close(); ?> 
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--</div>-->
    </div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>Students Combined Data</strong></h2>
            </div>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover dataTable" id="tableexp">
                    <thead>
                        <tr>
                            <th>Receipt No.</th>
                            <th>Date</th>
                            <th>Ec No.</th>
                            <th>Name</th>
                            <th>Name - Ec No.</th>
                            <th>Father </th>
                            <th>Mobile</th>
                            <th>Class</th>
                            <th>Section</th>
                            <th>Headers</th>
                            <th>Payment Mode</th>
                            <th>Total Fee</th>
                            <th>Discount</th>
                            <th>Penalty</th>
                            <th>Total Paid</th>
                            <th>Previous Total</th>
                            <th>Balance</th>
                            <th>Extra Amount</th>
                            <th>Collector Name</th>
                            <th>Cheque No</th>
                            <th>Bank Name</th>
                            <th>Sale No</th>
                            <th>Agst Bill</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php  
                            $exceltotalFee = 0;
                            $exceldiscountFee = 0;
                            $excelpenaltyAmount = 0;
                            $exceltotalPaidAmount = 0;
                            $excelPrevAmount = 0;
                            $excelbalanceAmount = 0;
                            $excelExtraAmount = 0;
                            $i = 0;
                            ?>
                            <?php $__currentLoopData = $extra_transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <?php  
                                $feetotal = 0;
                                $discount = 0;
                                $fine = 0;
                                $penalty = 0;
                                $paidAmount = 0;
                                $extraAmount = 0;

                                $plan = '';
                                $paidHeaders=\DB::table('student_transaction_extra_details')
                                            ->join('extra_feehead', 'student_transaction_extra_details.idFeehead', '=', 'extra_feehead.idExtraFeehead')
                                            ->select('extra_feehead.feeheadName','student_transaction_extra_details.status','student_transaction_extra_details.amountPaid','student_transaction_extra_details.fine','student_transaction_extra_details.discount')
                                            ->where('student_transaction_extra_details.idStudent', '=', $var->idStudent)
                                            ->where('student_transaction_extra_details.idTransaction', '=', $var->idTransaction)
                                            ->where(function($query) {
                                                $query->whereNull('status');
                                                $query->orWhere('status', '=', 'In-Process');
                                                $query->orWhere('status', '=', 'Cleared');
                                                $query->orWhere('status', '=', 'Success');
                                            })
                                            ->get();

                                $feetotal = \DB::table('student_transaction_extra_details')
                                    ->join('extra_feehead', 'student_transaction_extra_details.idFeehead', '=', 'extra_feehead.idExtraFeehead')
                                    ->selectRaw('SUM(amount) as total')
                                    ->where('student_transaction_extra_details.idStudent', '=', $var->idStudent)
                                    ->where('student_transaction_extra_details.idTransaction', '=', $var->idTransaction)
                                    ->where(function($query) {
                                        $query->whereNull('status');
                                        $query->orWhere('status', '=', 'In-Process');
                                        $query->orWhere('status', '=', 'Cleared');
                                        $query->orWhere('status', '=', 'Success');
                                    })
                                    ->first()->total;       
                            ?>
                            <td><?php echo e($var->receiptNo); ?></td>
                            <td><?php echo e(Carbon\Carbon::createFromFormat('Y-m-d', $var->paymentDate)->format('d-m-Y')); ?></td>
                            <td><?php echo e(ltrim($var->ecNo, "0")); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?> - <?php echo e($var->ecNo); ?></td>
                            <td><?php echo e($var->father_fname); ?> <?php echo e($var->father_lname); ?></td>
                            <td><?php echo e($var->father_mobile); ?></td>
                            <td><?php echo e($var->className); ?></td>
                            <td><?php echo e($var->sectionName); ?></td>
                            <td>
                            
                                <?php 
                                $headerNames="";
                                $headerCount=0;
                                foreach($paidHeaders as $headers)
                                {
                                  $headerNames=$headerNames.$headers->feeheadName;
                                  if($headerCount < (sizeof($paidHeaders)-1))
                                  $headerNames=$headerNames." | ";
                                  $headerCount++;

                                  $discount = $discount + $headers->discount;
                                  $fine = $fine + $headers->fine;
                                  $paidAmount = $paidAmount + $headers->amountPaid;
                                } 

                                ?>
                                <?php echo e($headerNames); ?>

                            </td>
                            
                            <td>
                                <?php
                                $mode="";
                                if($var->paymentMode == "Cheque")
                                $mode=$var->paymentMode;
                                else $mode=$var->paymentMode; 
                                ?>
                                <?php echo e($mode); ?> <?php if(isset($var->bankName)): ?> (<?php echo e($var->bankName); ?>) <?php endif; ?>
                            </td>
                            
                            <td><?php echo e($feetotal); ?></td>
                            <td><?php echo e($var->discount); ?>

                            <td><?php echo e($var->penaltyAmount + $var->fine); ?> 
                            <td><?php echo e($var->totalPaid); ?>

                            <td>0.00</td>
                            <td>
                                <?php 
                                   $b = $feetotal + $fine - ($discount + $paidAmount + $fine);
                                ?>
                                <?php echo e($b); ?>

                            </td>
                            <td>0.00</td>
                            
                            <?php  
                            $exceltotalFee = $exceltotalFee + $feetotal;
                            $exceldiscountFee = $exceldiscountFee + $discount;
                            $excelpenaltyAmount = $excelpenaltyAmount + $penalty + $fine;
                            $exceltotalPaidAmount = $exceltotalPaidAmount + $paidAmount;
                            $excelbalanceAmount = $excelbalanceAmount + $b;
                            $excelExtraAmount = $excelExtraAmount + $extraAmount;
                            ?>
                            <td><?php echo e($var->name); ?></td>
                            <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php echo e($var->chequeNo); ?>

                            <?php endif; ?>
                            </td>
                            <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php $bank = \DB::table('banks')->where('idBank',$var->idBank)->first();?>
                                <?php if($bank != null): ?>
                                <?php echo e($bank->bankName); ?>

                                <?php endif; ?>
                            <?php endif; ?>
                            </td>
                            <td>
                                <?php echo e(strtoupper($var->idStudent.substr($headerNames,0,3))); ?>

                            </td>
                            <td>
                                <?php echo e(strtoupper($var->idStudent.substr($headerNames,0,3))); ?>

                            </td>
                        </tr>
                        <?php $i++; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <?php $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                        <?php  $student = \App\AdmEntry::where('idStudent', '=', $var->idStudent)->first();
                                    $feetotal = 0;
                                    $prevtotal = 0;
                                    $plan = '';
                                    
                                    $totalPaid = \DB::table('student_transaction')
                                                ->where('idStudent', '=', $var->idStudent)
                                                ->where('idFinancialYear', '=', $var->idFinancialYear)
                                                ->where('idTransaction','<', $var->idTransaction)
                                                 ->where(function($query) {
                                                        $query->whereNull('status');
                                                        $query->orWhere('status', '=', 'In-Process');
                                                        $query->orWhere('status', '=', 'Cleared');
                                                        $query->orWhere('status', '=', 'Success');
                                                    })
                                                ->select(DB::raw('SUM(additionalAmount) as additionalAmount'),
                                                            DB::raw('SUM(totalPaid) as totalPaid'),
                                                            DB::raw('SUM(fine) as fineTotal'),
                                                            DB::raw('SUM(discount) as discountTotal'),
                                                            DB::raw('SUM(penaltyAmount) as penaltyAmount'))
                                                ->first();

                                    $lessPaid =  \App\LesserTransaction::where('idStudent','=',$var->idStudent)
                                                    ->select(DB::raw('SUM(totalPaid) as totalPaid'),
                                                    DB::raw('SUM(fine) as fineTotal'),
                                                    DB::raw('SUM(discount) as discountTotal'),
                                                    DB::raw('SUM(additionalAmount) as additionalAmount'),
                                                    DB::raw('SUM(penaltyAmount) as penaltyAmount'))
                                                    ->where(function($query) {
                                                        $query->whereNull('status');
                                                        $query->orWhere('status', '=', 'In-Process');
                                                        $query->orWhere('status', '=', 'Cleared');
                                                        $query->orWhere('status', '=', 'Success');
                                                    })
                                                    ->first();
                                    
                                    $prevtotal = $totalPaid->totalPaid +  $lessPaid->totalPaid ;                                    
                                    $paidHeaders=\DB::table('student_transaction_details')
                                            ->join('feeheads', 'student_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
                                            ->select('feeheads.feeheadName','feeheads.feeheadLabel','student_transaction_details.status','student_transaction_details.chqPenalty','student_transaction_details.amountPaid','student_transaction_details.discount','student_transaction_details.fine')
                                            ->where('student_transaction_details.idStudent', '=', $student->idStudent)
                                            ->where('student_transaction_details.idTransaction', '=', $var->idTransaction)
                                            ->where(function($query) {
                                                $query->whereNull('status');
                                                $query->orWhere('status', '=', 'In-Process');
                                                $query->orWhere('status', '=', 'Cleared');
                                                $query->orWhere('status', '=', 'Success');
                                            })
                                            ->get();
                                            
                                    $chqPenaltyPaid=0;       
                                    if($paidHeaders->count() > 0){
                                        foreach($paidHeaders as $transaction){

                                            $chqPenaltyPaid = $chqPenaltyPaid + $transaction->chqPenalty;
                                            if (str_contains($transaction->feeheadLabel, 'Plan A')) {
                                                $plan = 'Plan A';
                                                break;
                                            }else if (str_contains($transaction->feeheadLabel, 'Plan B')) {
                                                $plan = 'Plan B';
                                                break;
                                            }else if (str_contains($transaction->feeheadLabel, 'Plan C')) {
                                                $plan = 'Plan C';
                                                break;
                                            }
                                        }
                                    }

                                    $excessAmount = 0;
                                    $excess  = \App\ExcessTransaction::where('idTransaction','=',$var->idTransaction)->where('isActive','Y')->first();
                                    if($excess != null)
                                    $excessAmount = $excess->excessAmount;

                                    if($plan == "") $plan = 'Plan A';
                                    $outstanding = \DB::table('feeheads')
                                            ->where('idStudent', '=', $student->idStudent)
                                            ->where('idFinancialYear', '=', $student->idFinancialYear)
                                            ->where('feeheadName', '=', "Outstanding Payment");

                                    $class_feeheads = \DB::table('feeheads')->where('idClass', '=', $student->idClass)
                                            ->where('idSection', '=', $student->idSection)
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('studentCategory', '=', $student->studentType)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->whereNull('idStudent');

                                    $allcat_feeheads = \DB::table('feeheads')->where('idClass', '=', $student->idClass)
                                            ->where('idSection', '=', $student->idSection)
                                            ->where('studentCategory', '=', 'All')
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->whereNull('idStudent');

                                    $feeheads = \DB::table('feeheads')->where('idStudent', '=', $student->idStudent)
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->union($class_feeheads)
                                            ->union($allcat_feeheads)
                                            ->union($outstanding)
                                            ->orderBy('idFeehead','ASC')
                                            ->orderBy('toDate')
                                            ->get();

                                    $feetotal = $feeheads->sum('amount');  
                                    
                                    
                                ?>
                            <td><?php echo e($var->receiptNo); ?></td>
                            <td><?php echo e(Carbon\Carbon::createFromFormat('Y-m-d', $var->paymentDate)->format('d-m-Y')); ?></td>
                            <td><?php echo e(ltrim($var->ecNo, "0")); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?> - <?php echo e($var->ecNo); ?></td>
                            <td><?php echo e($var->father_fname); ?> <?php echo e($var->father_lname); ?></td>
                            <td><?php echo e($var->father_mobile); ?></td>
                            <td><?php echo e($var->className); ?></td>
                            <td><?php echo e($var->sectionName); ?></td>
                            <td>
                            
                                <?php 
                                $headerNames="";
                                $headerCount=0;
                                foreach($paidHeaders as $headers)
                                {
                                  $headerNames=$headerNames.$headers->feeheadName;
                                  if($headerCount < (sizeof($paidHeaders)-1))
                                  $headerNames=$headerNames." | ";
                                  $headerCount++;
                                } 

                                ?>
                                <?php echo e($headerNames); ?>

                            </td>
                            
                            <td>
                                <?php
                                $mode="";
                                if($var->paymentMode == "Cheque")
                                $mode=$var->paymentMode;
                                else $mode=$var->paymentMode; 
                                ?>
                                <?php if($var->paymentMode != "Cash"): ?>
                                <?php echo e($mode); ?> <?php if(isset($var->bankName)): ?> (<?php echo e($var->bankName); ?>) <?php endif; ?>
                                <?php else: ?>
                                <?php echo e($mode); ?>

                                <?php endif; ?>
                            </td>

                            <td><?php echo e($feetotal); ?></td>
                            <td><?php echo e($var->discount); ?> </td>
                            <?php 
                                    $extraFine = 0;
                                   $b = $feetotal - ($var->totalPaid + $var->additionalAmount + $excessAmount + $prevtotal);
                                   if($b < 0){
                                        $extraFine = 0 - $b;
                                        $b = 0;
                                   }
                                ?>    
                                
                            <td><?php echo e($var->penaltyAmount + $var->fine + $chqPenaltyPaid + $extraFine); ?></td>
                            <td><?php echo e($var->totalPaid + $var->additionalAmount + $excessAmount); ?></td>
                            <td><?php echo e($prevtotal); ?></td>
                            <td>
                                <?php echo e($b); ?>

                            </td>
                            <td><?php echo e($var->additionalAmount); ?></td>

                            <?php  
                            $exceltotalFee = $exceltotalFee + $feetotal;
                            $exceldiscountFee = $exceldiscountFee + $var->discount;
                            $excelpenaltyAmount = $excelpenaltyAmount + $var->penaltyAmount + $var->fine + $chqPenaltyPaid;
                            $exceltotalPaidAmount = $exceltotalPaidAmount + $var->totalPaid + $var->additionalAmount + $excessAmount;
                            $excelbalanceAmount = $excelbalanceAmount + $b;
                            $excelExtraAmount = $excelExtraAmount + $var->additionalAmount;
                            ?>
                            <td><?php echo e($var->name); ?></td>
                            <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php echo e($var->chequeNo." "); ?>

                            <?php endif; ?>
                            </td>
                           <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php $bank = \DB::table('banks')->where('idBank',$var->idBank)->first();?>
                                <?php if($bank != null): ?>
                                <?php echo e($bank->bankName); ?>

                                <?php endif; ?>
                            <?php endif; ?>
                            </td>
                            
                            <td>
                                <?php if($headerNames == 'Fees in Full Payment'): ?>
                                <?php echo e($var->idStudent.'FR'); ?>

                                <?php endif; ?>
                                <?php if($headerNames == 'Fees in Term- I'): ?>
                                <?php echo e($var->idStudent.'FR'); ?>

                                <?php endif; ?>
                                <?php if($headerNames == 'Fees in Installment - I'): ?>
                                <?php echo e($var->idStudent.'FR'); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(str_contains($headerNames, 'Outstanding Payment')): ?>
                                <?php echo e($var->idStudent.'OT'); ?>

                                <?php else: ?>
                                <?php echo e($var->idStudent.'FR'); ?>

                                <?php endif; ?>
                            </td>
                            </tr>
                        <?php $i++; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <?php $__currentLoopData = $lesser_transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                        <?php  $student = \App\AdmEntry::where('idStudent', '=', $var->idStudent)->first();
                                    $feetotal = 0;
                                    $prevtotal = 0;
                                    $plan = '';
                                    
                                    $totalPaid = \DB::table('student_transaction')
                                                ->where('idStudent', '=', $var->idStudent)
                                                ->where('idFinancialYear', '=', $var->idFinancialYear)
                                                
                                                 ->where(function($query) {
                                                        $query->whereNull('status');
                                                        $query->orWhere('status', '=', 'In-Process');
                                                        $query->orWhere('status', '=', 'Cleared');
                                                        $query->orWhere('status', '=', 'Success');
                                                    })
                                                ->select(DB::raw('SUM(additionalAmount) as additionalAmount'),
                                                            DB::raw('SUM(totalPaid) as totalPaid'),
                                                            DB::raw('SUM(fine) as fineTotal'),
                                                            DB::raw('SUM(discount) as discountTotal'),
                                                            DB::raw('SUM(penaltyAmount) as penaltyAmount'))
                                                ->first();

                                    $lessPaid =  \App\LesserTransaction::where('idStudent','=',$var->idStudent)
                                                    ->select(DB::raw('SUM(totalPaid) as totalPaid'),
                                                    DB::raw('SUM(fine) as fineTotal'),
                                                    DB::raw('SUM(discount) as discountTotal'),
                                                    DB::raw('SUM(additionalAmount) as additionalAmount'),
                                                    DB::raw('SUM(penaltyAmount) as penaltyAmount'))
                                                    ->where('idLesserTransaction','<', $var->idLesserTransaction)
                                                    ->where(function($query) {
                                                        $query->whereNull('status');
                                                        $query->orWhere('status', '=', 'In-Process');
                                                        $query->orWhere('status', '=', 'Cleared');
                                                        $query->orWhere('status', '=', 'Success');
                                                    })
                                                    ->first();
                                    
                                    $prevtotal = $totalPaid->totalPaid +  $lessPaid->totalPaid ;                                    
                                    $paidHeaders=\DB::table('lesser_transaction_details')
                                            ->join('feeheads', 'lesser_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
                                            ->select('feeheads.feeheadName','feeheads.feeheadLabel','lesser_transaction_details.status','lesser_transaction_details.amountPaid','lesser_transaction_details.discount','lesser_transaction_details.fine')
                                            ->where('lesser_transaction_details.idStudent', '=', $student->idStudent)
                                            ->where('lesser_transaction_details.idLesserTransaction', '=', $var->idLesserTransaction)
                                            ->where(function($query) {
                                                $query->whereNull('status');
                                                $query->orWhere('status', '=', 'In-Process');
                                                $query->orWhere('status', '=', 'Cleared');
                                                $query->orWhere('status', '=', 'Success');
                                            })
                                            ->get();
                                            
                                    $chqPenaltyPaid=0;  
                                    $fineAmount = 0;

                                    if($paidHeaders->count() > 0){
                                        foreach($paidHeaders as $transaction){
                                            $fineAmount = $fineAmount +  $transaction->fine;
                                            if (str_contains($transaction->feeheadLabel, 'Plan A')) {
                                                $plan = 'Plan A';
                                                break;
                                            }else if (str_contains($transaction->feeheadLabel, 'Plan B')) {
                                                $plan = 'Plan B';
                                                break;
                                            }else if (str_contains($transaction->feeheadLabel, 'Plan C')) {
                                                $plan = 'Plan C';
                                                break;
                                            }
                                        }
                                    }

                                    $var->fine = $fineAmount;

                                    $excessAmount = 0;
                                    if($plan == "") $plan = 'Plan A';
                                    $outstanding = \DB::table('feeheads')
                                            ->where('idStudent', '=', $student->idStudent)
                                            ->where('idFinancialYear', '=', $student->idFinancialYear)
                                            ->where('feeheadName', '=', "Outstanding Payment");

                                    $class_feeheads = \DB::table('feeheads')->where('idClass', '=', $student->idClass)
                                            ->where('idSection', '=', $student->idSection)
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('studentCategory', '=', $student->studentType)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->whereNull('idStudent');

                                    $allcat_feeheads = \DB::table('feeheads')->where('idClass', '=', $student->idClass)
                                            ->where('idSection', '=', $student->idSection)
                                            ->where('studentCategory', '=', 'All')
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->whereNull('idStudent');

                                    $feeheads = \DB::table('feeheads')->where('idStudent', '=', $student->idStudent)
                                            ->where('idFinancialYear','=', $student->idFinancialYear)
                                            ->where('feeheadLabel', 'LIKE', $plan.'%')
                                            ->union($class_feeheads)
                                            ->union($allcat_feeheads)
                                            ->union($outstanding)
                                            ->orderBy('idFeehead','ASC')
                                            ->orderBy('toDate')
                                            ->get();

                                    $feetotal = $feeheads->sum('amount');  
                                    
                                    
                                ?>
                            <td><?php echo e($var->receiptNo); ?></td>
                            <td><?php echo e(Carbon\Carbon::createFromFormat('Y-m-d', $var->paymentDate)->format('d-m-Y')); ?></td>
                            <td><?php echo e(ltrim($var->ecNo, "0")); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?></td>
                            <td><?php echo e($var->firstName); ?> <?php echo e($var->middleName); ?> <?php echo e($var->lastName); ?> - <?php echo e($var->ecNo); ?></td>
                            <td><?php echo e($var->father_fname); ?> <?php echo e($var->father_lname); ?></td>
                            <td><?php echo e($var->father_mobile); ?></td>
                            <td><?php echo e($var->className); ?></td>
                            <td><?php echo e($var->sectionName); ?></td>
                            <td>
                            
                                <?php 
                                $headerNames="";
                                $headerCount=0;
                                foreach($paidHeaders as $headers)
                                {
                                  $headerNames=$headerNames.$headers->feeheadName;
                                  if($headerCount < (sizeof($paidHeaders)-1))
                                  $headerNames=$headerNames." | ";
                                  $headerCount++;
                                } 

                                ?>
                                <?php echo e($headerNames); ?>

                            </td>
                            
                            <td>
                                <?php
                                $mode="";
                                if($var->paymentMode == "Cheque")
                                $mode=$var->paymentMode;
                                else $mode=$var->paymentMode; 
                                ?>
                                <?php if($var->paymentMode != "Cash"): ?>
                                <?php echo e($mode); ?> <?php if(isset($var->bankName)): ?> (<?php echo e($var->bankName); ?>) <?php endif; ?>
                                <?php else: ?>
                                <?php echo e($mode); ?>

                                <?php endif; ?>
                            </td>

                            <td><?php echo e($feetotal); ?></td>
                            <td><?php echo e($var->discount); ?> </td>
                            <?php 
                                   $extraFine = 0;
                                   $b = $feetotal - ($var->totalPaid + $var->additionalAmount + $excessAmount + $prevtotal);
                                   if($b < 0){
                                     $extraFine = 0 - $b;
                                     $b = 0 ;
                                   }
                                   
                                ?> 
                            <td><?php echo e($var->penaltyAmount + $var->fine + $chqPenaltyPaid + $extraFine); ?></td>
                            <td><?php echo e($var->totalPaid + $var->additionalAmount + $excessAmount); ?></td>
                            <td><?php echo e($prevtotal); ?></td>
                            <td>  
                                <?php echo e($b); ?>

                            </td>
                            <td><?php echo e($var->additionalAmount); ?></td>

                            <?php  
                            $exceltotalFee = $exceltotalFee + $feetotal;
                            $exceldiscountFee = $exceldiscountFee + $var->discount;
                            $excelpenaltyAmount = $excelpenaltyAmount + $var->penaltyAmount + $var->fine + $chqPenaltyPaid;
                            $exceltotalPaidAmount = $exceltotalPaidAmount + $var->totalPaid + $var->additionalAmount + $excessAmount;
                            $excelbalanceAmount = $excelbalanceAmount + $b;
                            $excelExtraAmount = $excelExtraAmount + $var->additionalAmount;
                            ?>
                            <td><?php echo e($var->name); ?></td>
                            <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php echo e($var->chequeNo." "); ?>

                            <?php endif; ?>
                            </td>
                           <td>
                            <?php if($var->paymentMode == "Cheque"): ?>
                                <?php $bank = \DB::table('banks')->where('idBank',$var->idBank)->first();?>
                                <?php if($bank != null): ?>
                                <?php echo e($bank->bankName); ?>

                                <?php endif; ?>
                            <?php endif; ?>
                            </td>
                            <td>
                            <?php
                                    $lessPaid = \DB::table('lesser_transaction')
                                    ->join('lesser_transaction_details', 'lesser_transaction.idLesserTransaction', '=', 'lesser_transaction_details.idLesserTransaction')
                                    ->join('feeheads', 'lesser_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
                                    ->where('lesser_transaction.idStudent', '=', $var->idStudent)
                                    ->where('lesser_transaction.idFinancialYear', '=', $var->idFinancialYear)
                                    ->where(function($query){
                                        $query->whereNull('lesser_transaction.status');
                                        $query->orWhere('lesser_transaction.status', '=', 'In-Process');
                                        $query->orWhere('lesser_transaction.status', '=', 'Cleared');
                                        $query->orWhere('lesser_transaction.status', '=', 'Success');
                                    })
                                    ->where(function($query){
                                        $query->where('feeheadName', '=', 'Fees in Full Payment');
                                        $query->orWhere('feeheadName', '=', 'Fees in Term- I');
                                        $query->orWhere('feeheadName', '=', 'Fees in Installment - I');
                                    })
                                    ->first();

                                    $fullPaid =\DB::table('student_transaction')
                                    ->join('student_transaction_details', 'student_transaction.idTransaction', '=', 'student_transaction_details.idTransaction')
                                    ->join('feeheads', 'student_transaction_details.idFeehead', '=', 'feeheads.idFeehead')
                                    ->where('student_transaction.idStudent', '=', $var->idStudent)
                                    ->where('student_transaction.idFinancialYear', '=', $var->idFinancialYear)
                                    ->where(function($query){
                                        $query->whereNull('student_transaction.status');
                                        $query->orWhere('student_transaction.status', '=', 'In-Process');
                                        $query->orWhere('student_transaction.status', '=', 'Cleared');
                                        $query->orWhere('student_transaction.status', '=', 'Success');
                                    })
                                    ->where(function($query){
                                        $query->where('feeheadName', '=', 'Fees in Full Payment');
                                        $query->orWhere('feeheadName', '=', 'Fees in Term- I');
                                        $query->orWhere('feeheadName', '=', 'Fees in Installment - I');
                                    })
                                    ->first();


                                    if( $fullPaid == null){
                                        if($lessPaid != null){
                                            if( $lessPaid->idLesserTransaction == $var->idLesserTransaction){
                                                if(str_contains($lessPaid->feeheadName, 'Fees in Full Payment'))
                                                echo $var->idStudent.'FR';
                                                
                                                if(str_contains($lessPaid->feeheadName, 'Fees in Term- I'))
                                                echo $var->idStudent.'FR';
                                                
                                                if(str_contains($lessPaid->feeheadName, 'Fees in Installment - I'))
                                                echo $var->idStudent.'FR';
                                            }
                                        }
                                    }
                                    ?>
                            </td>
                            <td>
                                <?php if(str_contains($headerNames, 'Outstanding Payment')): ?>
                                <?php echo e($var->idStudent.'OT'); ?>

                                <?php else: ?>
                                <?php echo e($var->idStudent.'FR'); ?>

                                <?php endif; ?>
                            </td>
                            </tr>
                        <?php $i++; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </tbody>
                    <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td>Total</td>
                            <td><?php echo e($exceltotalFee); ?></td>
                            <td><?php echo e($exceldiscountFee); ?></td>
                            <td><?php echo e($excelpenaltyAmount); ?></td>
                            <td><?php echo e($exceltotalPaidAmount); ?></td>
                            <td></td>
                            <td><?php echo e($excelbalanceAmount); ?></td>
                            <td><?php echo e($excelExtraAmount); ?></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
$(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: "<?php echo e(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>');
                    });
                }
            });
        }
});
$(function () {
    $('#tableexp').DataTable({
      
        dom: 'Bfrtip',
        scrollY:        "500px",
        scrollX:        true,
        scrollCollapse: true,
        fixedColumns:   {
            left: 1
        },
        buttons: [
            { extend: 'csv', footer: true, text: 'Export to Excel',title:'Student Combined Report',
                exportOptions: {
                    columns: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],
                    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;
                                
                                }
                            }
                }
            },{ extend: 'excel', footer: true, text: 'Export to Tally Excel',title:'Student Combined Report',footer: false,
                exportOptions: {
                    columns: [0,1,2,3,5,6,7,8,9,10,11,12,13,14,16,17,19,20,21,22],
                    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', '.select-all', function(){
    var checkAll = this.checked;
        if(checkAll === true){
            $('.sectionclass').each(function () {
                this.checked = checkAll;
            });
        }else{
            $('.sectionclass').each(function () {
                this.checked = checkAll;
            });
        }
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

Copyright © 2021 - 2025 IMMREX7