IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/north/transaction/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/north/transaction/feedetails_form.blade.php

@extends('schools.school_layout')
@section('content')
<div role="tabpanel" class="tab-pane in active" id="details" aria-expanded="true">
    <div class="card" id="details">
        <div class="body">                                
            <div class="row">
                <div class="col-sm-6 col-sm-offset-1">
                    <address>
                        <strong> Student Name : </strong>{{$student->firstName}} {{$student->middleName}} {{$student->lastName}}<br>
                        <strong> Father Name : </strong>{{$student->father_fname}} {{$student->father_lname or ''}}<br>
                        <strong> Mobile : </strong>{{$student->father_mobile}}<br>
                        <strong> Class : </strong>{{$student->classM->className}}<br>
                        <strong> Section : </strong>{{$student->section->sectionName}}<br>
                        <strong> Ec No. : </strong>{{$student->ecNo}}<br>
                    </address>
                </div>
            </div>
            <div class="mt-40"></div>
            <div class="row">
                
               <div class="col-md-7">
                   <div class="table-responsive">
                       {!! Form::open(['url' => 'school/north/stdtransaction', 'class' => 'form-horizontal','id'=>'feesubmission']) !!}
                       <input type="hidden" name="idStudent" value="{{$student->idStudent}}">
                       <input type="hidden" name="idFinancialYear" value="{{$student->idFinancialYear}}">
                       <table class="table table-hover">
                           <thead>
                               <tr>
                                   <th></th>
                                   <th style="width:60px;">Due Date</th>
                                   <th>Particular</th>
                                   <th>Amount</th>
                                   <th>Discount</th>
                                   <th>Fine</th>
                                   <th>Category</th>
                                   <th>Status</th>
                               </tr>
                           </thead>
                           <tbody>
                               <?php $totalFine=0;$totalFee=0;$totalDis=0;?>
                               <?php $flatfine=0;
                                     $perDay=array();
                                     foreach($fineheads as $fine){
                                         if($fine->isFlat==1)
                                          $flatfine=$fine->amount;
                                         else{
                                            array_push($perDay,$fine); 
                                         } 
                                     }
                               ?>
                               
                               @foreach($feeheads as $fee)
                               <tr>
                                   <?php
                                    $k=0;
                                    $feedetails = \App\NorthFeeHead::where('isParent','=',$fee->idFeehead)->get();
                                    
                                    $date = Carbon\Carbon::parse($fee->toDate);
                                    $startDate = Carbon\Carbon::parse($fee->fromDate);
                                    $now = Carbon\Carbon::now();
                                    
                                    $diff = $date->diffInDays($now,false);
                                    
                                    if($fee->idType=='fee')
                                    $std_trdet = \App\StudentTransactionDetail::where('idStudent','=',$student->idStudent)
                                               ->whereIn('idFeehead',$feedetails->pluck('idFeehead'))->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })
                                               ->select(DB::raw('amountPaid as amount'),DB::raw('discount as discount'),DB::raw('fine as fine'),'status')->latest()->first();
                                    elseif($fee->idType=='bus')           
                                    $std_trdet = \App\BusTransactionDetail::where('idStudent','=',$student->idStudent)
                                               ->whereIn('idBusFeehead',$feedetails->pluck('idFeehead'))->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })
                                               ->select(DB::raw('amountPaid as amount'),DB::raw('discount as discount'),DB::raw('fine as fine'),'status')->latest()->first();
                                    else 
                                    $std_trdet = \App\HostelTransactionDetail::where('idStudent','=',$student->idStudent)
                                               ->whereIn('idFeehead',$feedetails->pluck('idFeehead'))->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })
                                               ->select(DB::raw('amountPaid as amount'),DB::raw('discount as discount'),DB::raw('fine as fine'),'status')->latest()->first();
                                               
                                               
                                               
                                    
                                     if($fee->idType=='fee')
                                    $std_ledet=DB::table('lesser_transaction_details')
                                    ->where('idStudent','=',$student->idStudent)
                                               ->whereIn('idFeehead',$feedetails->pluck('idFeehead'))
                                        ->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })       
                                               ->select(DB::raw('SUM(amountPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('fine as fine'),'status')->latest()->first();
                                               elseif($fee->idType=='bus')
                                        $std_ledet=DB::table('bus_lesser_transaction_details')
                                    ->where('idStudent','=',$student->idStudent)
                                               ->whereIn('idBusFeehead',$feedetails->pluck('idFeehead'))
                                        ->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })       
                                               ->select(DB::raw('SUM(amountPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('fine as fine'),'status')->latest()->first();   
                                               else
                                        $std_ledet=DB::table('hostel_lesser_transaction_details')
                                    ->where('idStudent','=',$student->idStudent)
                                               ->whereIn('idFeehead',$feedetails->pluck('idFeehead'))
                                        ->where(function($query) {
                                                    $query->whereNull('status');
                                                  $query->orWhere('status', '=', 'Cleared');
                                                    $query->orWhere('status', '=', 'In-Process');
                                                    $query->orWhere('status', '=', 'Success');
                                                })       
                                               ->select(DB::raw('SUM(amountPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('fine as fine'),'status')->latest()->first();          
                                    
                                   ?>
                                   <td>
                                       @if($std_trdet['amount'] != null && ($std_trdet['status'] == null || $std_trdet['status'] == 'Cleared'))
                                       <div></div>
                                       @elseif(isset($std_ledet->amount))
                                       @if( ($std_ledet->amount+$std_ledet->discount) == $fee->amount && ($std_ledet->status == null || $std_ledet->status == 'Cleared'))
                                       <div></div>
                                       @else
                                       <div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="selectedHeaders[]" value="{{$fee->idFeehead}}" class="feeclass"></div>
                                       @endif
                                       @else
                                        <div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="selectedHeaders[]" value="{{$fee->idFeehead}}" class="feeclass"></div>
                                        @endif
                                        
                                    </td>
                                   <td>{{ Carbon\Carbon::parse($fee->toDate)->format('d-m-Y') }}</td>
                                   <td>
                                       {{$fee->demandName}}
                                       <i class="zmdi zmdi-chevron-down" style="padding-right: 10px;
padding-left: 10px;" onclick="openDemand({{$fee->idFeehead}})"></i><br>
                                        
                                        @if(isset($std_ledet->amount))
                                        @if(($std_ledet->amount+ $std_ledet->discount ) != $fee->amount && ($std_ledet->status == null || $std_ledet->status == 'Cleared'))
                                        <span  class="badge badge-info" style="font-size:12px;"> Paid :  {{$std_ledet->amount}}</span>
                                        @endif
                                        @endif
                                    </td>
                                   <td class='amt'>
                                       {{$fee->amount}}
                                       <?php $totalFee=$totalFee+$fee->amount; ?>
                                       <input type="hidden" name='feeheads[{{$fee->idFeehead}}][famount]' value="{{$fee->amount}}">
                                   </td>
                                   <?php
                                   $discounts = \App\NorthFeeHead::where('isParent','=',$fee->idFeehead)->select(DB::raw('SUM(discount) as total_discount'))->first();
                                   $fineAmount=0;
                                   ?>
                                   <td class="discount">
                                       @if(isset($discounts))
                                         {{$discounts->total_discount}}
                                         <?php $totalDis=$totalDis+$discounts->total_discount;?>
                                        @endif
                                   </td>
                                   <td class="fine">
                                       @if(isset($std_ledet->amount))
                                       {{$fineAmount}}
                                       @elseif($fee->fine == 'flat' && $diff > 0)
                                       {{$flatfine}}
                                       <?php $fineAmount=$flatfine;?>
                                       @elseif($fee->fine == 'per' && $diff > 0)
                                       <?php
                                         if($diff > 0){
                                             foreach($perDay as $per){
                                                if($per->days <= $diff){
                                                    $fineAmount=$per->amount;
                                                    break;
                                                } 
                                             }
                                         }
                                         
                                       ?>
                                       {{$fineAmount}}
                                       @else
                                       {{$fineAmount}}
                                       @endif
                                       <input type="hidden" id="fine_{{$fee->idFeehead}}" value=" {{$fineAmount}}"/>
                                   </td>
                                   <td>
                                       @if($fee->idType=='fee') 
                                       School Fee
                                       @elseif($fee->idType=='bus')
                                       Bus Fee
                                       @elseif($fee->idType=='hostel')
                                       Hostel Fee
                                       @endif
                                   </td>
                                   <td>
                                       
                                       @if(isset($std_ledet->amount))
                                        @if(($std_ledet->amount+ $std_ledet->discount ) == $fee->amount && ($std_ledet->status == null || $std_ledet->status == 'Cleared'))
                                         <span class="badge badge-success">Paid </span>
                                        @else
                                        <span class="badge badge-info">Partial-Paid</span>
                                        @endif
                                        @elseif($std_trdet['amount'] != null && ($std_trdet['status'] == null || $std_trdet['status'] == 'Cleared'))
                                            <span class="badge badge-success">Paid </span>
                                            @elseif( $std_trdet['status'] == 'In-Process')
                                            <span class="badge badge-info">In-Process </span>
                                            @elseif( ($startDate->diffInDays($now,false)) > 0)
                                            <span class="badge badge-danger">DUE</span>
                                            @else
                                            <span class="badge badge-info">UPCOMING</span>
                                            @endif
                                   </td>
                               </tr>
                               <tr class="header_table_{{$fee->idFeehead}}" style="display:none;">
                                <td colspan="7">
                                    <table class="table"  style=" border: none;">
                                        <tbody  id="optional_list">
                                            
                                          @foreach($feedetails as $headers)
                                            <tr>
                                                <th style="border:0;">{{$headers->header->headerName or ''}}
                                        <input type="hidden" name="subhead[{{$fee->idFeehead}}][{{$k}}][id]" value="{{$headers->idFeehead}}" form="feesubmission"/>         </th>
                                                <th style="border:0;"><input class="form-control" type="number" name="subhead[{{$fee->idFeehead}}][{{$k}}][headerAmount]" required="required" id="amount_{{$k}}" value="{{$headers->amount}}" readonly></th>
                                                <th style="border:0;"><input class="form-control" type="number" name="subhead[{{$fee->idFeehead}}][{{$k}}][headerDiscount]" required="required" id="discount_{{$k}}" value="{{$headers->discount}}" readonly><span id="amounterror{{$k}}"></span></th>
                                        @if(isset($std_ledet->amount))
                                            <th style="border:0;"><input class="form-control" type="number" name="subhead[{{$fee->idFeehead}}][{{$k}}][headerPaid]" required="required" id="paidamount_{{$fee->idFeehead.$k}}" value="{{ ( $headers->amount - $headers->discount ) - $std_ledet->amount }}" onkeyup="calculateAmt({{$fee->idFeehead}})" readonly><span id="amounterror{{$k}}"></span></th>
                                        @else
                                                <th style="border:0;"><input class="form-control" type="number" name="subhead[{{$fee->idFeehead}}][{{$k}}][headerPaid]" required="required" id="paidamount_{{$fee->idFeehead.$k}}" value="{{$headers->amount - $headers->discount }}" onkeyup="calculateAmt({{$fee->idFeehead}})"><span id="amounterror{{$k}}"></span></th>
                                        @endif        
                                            </tr>
                                        <?php $k++; ?>    
                                         @endforeach  
                                         <input type="hidden" id="total_row_{{$fee->idFeehead}}" value="{{$k}}"/>
                                        </tbody>
                                    </table>      
                                </td>
                               </tr>
                               <?php $totalFine=$totalFine+$fineAmount;?>
                               @endforeach
                           </tbody>
                       </table>
                   </div>
                </div>
                <div class="col-sm-5">
                    <div class="table-responsive">
                        <table class="table table-hover">
                               <thead>
                                   <tr>
                                       <th>Date</th>
                                       <th>Amount</th>
                                       <!--<th>Balance</th>-->
                                       <th>Payment Mode</th>
                                       <th>Category</th>
                                       <th>Print</th>
                                   </tr>
                               </thead>
                               <tbody>
                                   @foreach($paidfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                        <td>School Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null || $var->status == 'Success')
                                       <td><a href="{{url('school/north/stdfees/'.$var->idTransaction.'/print')}}" target="_blank" class="btn btn-sm btn-info">Print</a></td>
                                       
                                       
                                       @endif
                                   </tr>
                                   @endforeach
                                   @foreach($paidbusfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                       <td>Bus Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null || $var->status == 'Success')
                                       <td><a href="{{url('school/north/bus/'.$var->idBusTransaction.'/print')}}" target="_blank" class="btn btn-sm btn-info">Print</a></td>
                                       @endif
                                   </tr>
                                   @endforeach
                                @foreach($paidhostelfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                       <td>Hostel Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null || $var->status == 'Success')
                                       <td><a href="{{url('school/north/hostelfees/'.$var->idHostelTransaction.'/print')}}" target="_blank" class="btn btn-sm btn-info">Print</a></td>
                                       @endif
                                   </tr>
                                   @endforeach
                                </tbody>
                        </table>
                    </div>
                    <br>
                    <h5>Lesser Paid Receipt</h5>
                    <div class="table-responsive">
                        <table class="table table-hover">
                               <thead>
                                   <tr>
                                       <th>Date</th>
                                       <th>Amount</th>
                                       <!--<th>Balance</th>-->
                                       <th>Payment Mode</th>
                                       <th>Category</th>
                                       <th>Print</th>
                                   </tr>
                               </thead>
                               <tbody>
                                    @foreach($lesserfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                       <td>School Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null )
                                       <td><a href="{{url('school/north/lessamt/'.$var->idLesserTransaction.'/print')}}" target="_blank" class="btn btn-sm btn-info">Print</a></td>
                                       @endif
                                   </tr>
                                   @endforeach
                                @foreach($lesserbusfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                       <td>Bus Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null )
                                       <td></td>
                                       @endif
                                   </tr>
                                   @endforeach
                                @foreach($lesserhostelfees as $var)
                                    <tr>
                                       <td>{{$var->paymentDate}}</td>
                                       <td>{{$var->totalPaid}}</td>
                                       <!--<td></td>-->
                                       <td>{{$var->paymentMode}}</td>
                                        <td>Hostel Fee</td>
                                       @if($var->status == 'Cleared' || $var->status == null )
                                       <td></td>
                                       @endif
                                   </tr>
                                   @endforeach
                                </tbody>
                        </table>
                    </div>
                </div>
               
                
            </div>
            <hr>
            <div class="row">
                <div class="col-md-5">
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">Payment Date</label>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <input type="text"  name="paymentDate" class="form-control datepicker">
                                </div>
                            </div>
                        </div>
                         <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">Fine </label>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <span style="color:red;">*To be filled at last</span>
                                    <input type="number" name="totalFine" class="form-control custom_fine" onkeypress = 'return onlyNumbersandSpecialChar(event)' onkeyup="calculateFineAmt()">
                                    @if ($errors->has('totalPaid'))
                                    <label id="minmaxlength-error" class="error" for="minmaxlength">
                                        <strong>{{ $errors->first('totalPaid') }}</strong>
                                    </label>
                                    @endif
                                    <span id='totalerror'></span>
                                </div>
                            </div>
                        </div>
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">Payable Amount</label>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <input type="text" name="payable" class="form-control payableAmount" readonly="readonly"  style="color: black;font-size: 1.2em;">
                                    <span id="payableerror"></span>
                                </div>
                            </div>
                        </div>
                       
                        <div class="row clearfix">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">Select Payment Mode</label>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    {!! Form::select('paymentMode',payMode(),null,['class' => 'form-control show-tick ms paymentMode','id'=>'paymode']) !!}
                                </div>
                            </div>
                        </div>
                        <div class="row clearfix cardpayment">
                            <div class="col-sm-5 form-control-label">
                                <label for="classname">CardNo./Trans ID</label>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <input type="text" name="cardNo" class="form-control">
                                    <span id='cardnoerror'></span>
                                </div>
                            </div>
                        </div>

                </div>
                <div class="col-md-6 text-right">
                    <p class="m-b-0"><b>Fee Total: </b>
                    <span  id='total_fee'>{{$totalFee}}</span>
                        <input type="hidden" name="feeTotal" id="feetotal">
                    </p>
                    <p class="m-b-0">
                        <b>Discount: </b>
                        <span  id='total_discount'>{{$totalDis}}</span>
                        <input type="hidden" name="discount" id="discounttotal">
                    </p>     
                    <?php 
                    
                    $std_tr = \App\StudentTransaction::where('idStudent','=',$student->idStudent)->where(function($query) {
                            $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                        })->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                                    
                    $std_bus_tr = \App\BusTransaction::where('idStudent','=',$student->idStudent)->where(function($query) {
                            $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                        })->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                        
                    $std_hostel_tr = \App\HostelTransaction::where('idStudent','=',$student->idStudent)->where(function($query) {
                            $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                        })->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                                    
                    $std_le=DB::table('lesser_transaction')
                                    ->where('idStudent','=',$student->idStudent)
                                     ->where(function($query) {
                                                 $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                                            })
                                               ->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                                               
                    $std_bus_le=DB::table('bus_lesser_transaction')
                                    ->where('idStudent','=',$student->idStudent)
                                     ->where(function($query) {
                                                $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                                            })
                                               ->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                                               
                    $std_hostel_le=DB::table('hostel_lesser_transaction')
                                    ->where('idStudent','=',$student->idStudent)
                                     ->where(function($query) {
                                                $query->whereNull('status');
                          $query->orWhere('status', '=', 'Cleared');
                            $query->orWhere('status', '=', 'In-Process');
                            $query->orWhere('status', '=', 'Success');
                                            })
                                               ->select(DB::raw('SUM(totalPaid) as amount'),DB::raw('SUM(discount) as discount'),DB::raw('SUM(fine) as fine'))->latest()->first();
                                               
                    $totalFinePaid=0;
                    $totalAmountPaid=0;
                    
                    if(isset($std_le->fine))
                    $totalFinePaid=$totalFinePaid+$std_le->fine;
                    if(isset($std_bus_tr->fine))
                    $totalFinePaid=$totalFinePaid+$std_bus_tr->fine;
                    if(isset($std_bus_le->fine))
                    $totalFinePaid=$totalFinePaid+$std_bus_le->fine;
                     if(isset($std_hostel_tr->fine))
                    $totalFinePaid=$totalFinePaid+$std_hostel_tr->fine;
                    if(isset($std_hostel_le->fine))
                    $totalFinePaid=$totalFinePaid+$std_hostel_le->fine;
                    if(isset($std_tr->fine))
                    $totalFinePaid=$totalFinePaid+$std_tr->fine;
                    
                    if(isset($std_le->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_le->amount;
                    if(isset($std_bus_tr->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_bus_tr->amount;
                    if(isset($std_bus_le->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_bus_le->amount;
                    if(isset($std_hostel_tr->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_hostel_tr->amount;
                    if(isset($std_hostel_le->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_hostel_le->amount;
                    if(isset($std_tr->amount))
                    $totalAmountPaid=$totalAmountPaid+$std_tr->amount;
                    
                    
                    
                    
                    ?>
                    <p class="m-b-0">
                        <b>Fine: </b>
                        <span id='total_fine'>{{$totalFinePaid}}</span>
                        <input type="hidden" name="fine" id="finetotal">
                    </p>
                    <p class="m-b-0">
                        <b>Cheque Bounce Penalty: </b>
                        <span id="penaltyAmt"></span>
                         <?php $chqbounce = \App\StudentTransaction::where('idStudent','=',$student->idStudent)
                                ->where('idFinancialYear','=',$student->idFinancialYear)
                                ->where('status','=','Bounced')
                                ->get();
                                
                                $chqPenaltyAmount=0;
                                $chqPenaltyPaid=0;
                                $chqPenaltyUnPaid=0;
                                if(isset($chqbounce)){
                                foreach($chqbounce as $chqFine)
                                    {
                                        if($chqFine->chqFineStatus == 1)
                                        $chqPenaltyPaid=$chqPenaltyPaid+$chqFine->chequeBounceCharge;
                                        else
                                        $chqPenaltyUnPaid=$chqPenaltyUnPaid+$chqFine->chequeBounceCharge;
                                        
                                        $chqPenaltyAmount=$chqPenaltyAmount+$chqFine->chequeBounceCharge;
                                    }
                                }
                            ?>
                            @if(isset($chqbounce))
                            {{$chqPenaltyAmount}}
                            @if($chqPenaltyAmount==0)
                            <span></span>
                            @elseif($chqPenaltyAmount > $chqPenaltyPaid)
                            <span style="color:red"> | {{$chqPenaltyUnPaid}}(Unpaid)</span>
                            @else
                            <span style="color:green">(Paid)</span>
                            @endif
                            @else
                            <span>0.00</span>
                            @endif
                    </p>
                    <p class="m-b-0"><b>Excess Amount : </b>
                    <span>0.00</span>
                    </p>
                   
                    <p class="m-b-0"><b>Total Amount : </b>
                    <?php
                        $totalAmount=$totalFee+$totalFinePaid-$totalDis;
                        echo'<span>'.$totalAmount.'<span>';
                    ?>
                    </p> 
                    <p class="m-b-0"><b>Total Paid: </b>
                    <span>{{$totalAmountPaid}}</span>
                    </p>
                    <p class="m-b-0"><b>Balance Amount: </b>
                     <?php
                        $totalBalance= ( $totalFee+$totalFinePaid-$totalDis ) - $totalAmountPaid;
                        echo'<span>'.$totalBalance.'<span>';
                    ?>     
                    </p>
                </div>
            </div>
            <!--<hr>-->
            <div class="row otherpaymode">
                <div class="col-sm-12">
                    <hr>
                    
                   <div class="row clearfix">
                        <div class="col-sm-3 form-control-label required">
                            <label for="classname">Bank</label>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                {!! Form::select('idBank',banks(),null,['class' => 'form-control show-tick ms select2']) !!}
                                <span id='bankerror'></span>
                            </div>
                        </div>
                        <div class="col-sm-3 form-control-label required">
                            <label for="classname">Cheque No. / DD No.</label>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <input type="text" name="chequeNo" class="form-control">
                                    <span id='chequenoerror'></span>
                            </div>
                        </div>
                    </div>
                    <div class="row clearfix">
                        
                        <div class="col-sm-3 form-control-label required">
                            <label for="classname">Cheque / DD Date</label>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <input type="text" name="chequeDate" class="form-control datepicker">
                                   <span id='chequedateerror'></span>
                            </div>
                        </div>
                        <div class="col-sm-3 form-control-label required">
                            <label for="classname">Amount</label>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <input type="text" name="amount" class="form-control" onkeypress = 'return onlyNumbersandSpecialChar(event)'>
                                <span id='amounterror'></span>
                            </div>
                        </div>
                    </div>
              
<!--                    <h5>Note</h5>
                    <p>Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles, weebly ning heekya handango imeem plugg dopplr jibjab, movity jajah plickers sifteo edmodo ifttt zimbra.</p>-->
                </div>
                
            </div>
            <hr>
            <div class="hidden-print col-md-12 text-right">
                <button class="btn btn-primary btn-round" id='submit-btn'>Submit</button>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
$(document).ready(function(){
 $('.otherpaymode').hide(); 
 $('.cardpayment').hide();
 $('#paymode').change(function() {
        var val = $(this).val();
        if((val == 'Cheque')){
           $('.cardpayment').hide();
           $('.otherpaymode').show();
        }else if(val == 'DD'){
           $('.cardpayment').hide();
           $('.otherpaymode').show();
        }else if(val == 'Card'){
           $('.cardpayment').show();
           $('.otherpaymode').hide();
        }else{
            $('.otherpaymode').hide();
            $('.cardpayment').hide();
        }
    });
    
    var feeheaderIds = [];
    $('.feeclass').change(function() {
        $('input[type=number].custom_fine').val('<?php echo $totalFine;?>');
        feeheaderIds = [];
        var totalfine=0;
        $("input:checkbox[name='selectedHeaders[]']:checked").each(function () {
                feeheaderIds.push($(this).val());
                totalfine=totalfine+parseInt($('#fine_'+$(this).val()).val());
        });
        var totalPayable=0;
        
        if(feeheaderIds.length>0)
        {
            $.each(feeheaderIds, function( index, value ) {
              var i;
                for (i = 0; i < $('#total_row_'+value).val(); i++) { 
                    var amount=$('#paidamount_'+value+i).val();
                    if( amount!='NaN')    
                     totalPayable = totalPayable+parseInt(amount);
                     
                }
            });
            $('input[type=number].custom_fine').val(totalfine);
            finalAmount=totalPayable;
            totalPayable=totalPayable+parseInt( $('input[type=number].custom_fine').val());
            
            $('input[type=text].payableAmount').val(totalPayable);    
             
        }
        else {
            $('input[type=text].payableAmount').val(" "); 
            finalAmount=0;
        }
    });
});

function openDemand(id){
     $('.header_table_'+id).toggle();
}
var finalAmount=0;
function calculateFineAmt(){
        var totalFine=parseInt($('input[type=number].custom_fine').val());
        if( totalFine > 0)
         $('input[type=text].payableAmount').val(finalAmount+totalFine); 
        else  $('input[type=text].payableAmount').val(finalAmount);
}
function calculateAmt(id)
    {
         var totalfine=0;
        $('input[type=number].custom_fine').val('<?php echo $totalFine;?>');
        var feeheaderIds = [];
        $("input:checkbox[name='selectedHeaders[]']:checked").each(function () {
                feeheaderIds.push($(this).val());
                totalfine=totalfine+parseInt($('#fine_'+$(this).val()).val());
        });
        var totalPayable=0;
       
        if(feeheaderIds.length>0)
        {
            $.each(feeheaderIds, function( index, value ) {
              var i;
                for (i = 0; i < $('#total_row_'+value).val(); i++) { 
                    var amount=$('#paidamount_'+value+i).val();
                    if( amount!='NaN')    
                     totalPayable = totalPayable+parseInt(amount);
                }
            });
            $('input[type=number].custom_fine').val(totalfine);
            finalAmount=totalPayable;
            totalPayable=totalPayable+parseInt( $('input[type=number].custom_fine').val());
             
              $('input[type=text].payableAmount').val(totalPayable);    
             
        }
        else {
            $('input[type=text].payableAmount').val(" ");
        finalAmount=0;
        }
    }
    
$('#feesubmission').on('submit',function(e){
     $.ajaxSetup({
        header:$('meta[name="_token"]').attr('content')
    });
    var formData =  new FormData($('#feesubmission')[0]);
    $("#submit-btn").prop('disabled', true);
    $.ajax({
        type:"POST",
        url: "{{url('school/north/stdtransaction') }}",
        processData: false,
        contentType: false,
        data:formData,
        dataType: 'json',
        success:function(data){
            console.log(data);
            if( data[Object.keys(data)[0]] === 'SUCCESS' ){
               $("#submit-btn").prop('disabled', true);
               window.location = "{{url('school/north/stdtransaction/')}}" + '/'+ {{$student->idStudent}} +'/details';
            }
            else {                  //False Case: With error msg
            $("#msg").html(data);   //$msg is the id of empty msg
            }

        },

        error: function(data){
             console.log(data);
                    if( data.status === 422 ) {
                        $("#submit-btn").prop('disabled', false);
                        var errors = data.responseJSON.errors;
                        var errorHtml = '<div class="alert alert-danger"><ul>';
                           $('#formerrors').html(errorHtml);
                                if(errors['totalPaid']=== undefined){
                                    $( '#totalerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['totalPaid']+'</strong></span>';
                                   $( '#totalerror' ).html( errorname );
                                }
                                if(errors['idBank']=== undefined){
                                    $( '#bankerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idBank']+'</strong></span>';
                                   $( '#bankerror' ).html( errorname );
                                }
                                if(errors['chequeNo']=== undefined){
                                    $( '#chequenoerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['chequeNo']+'</strong></span>';
                                   $( '#chequenoerror' ).html( errorname );
                                }
                                if(errors['chequeDate']=== undefined){
                                    $( '#chequedateerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['chequeDate']+'</strong></span>';
                                   $( '#chequedateerror' ).html( errorname );
                                }
                                if(errors['chequeDate']=== undefined){
                                    $( '#chequedateerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['chequeDate']+'</strong></span>';
                                   $( '#chequedateerror' ).html( errorname );
                                }
                                if(errors['amount']=== undefined){
                                    $( '#amounterror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['amount']+'</strong></span>';
                                   $( '#amounterror' ).html( errorname );
                                }
                                if(errors['cardNo']=== undefined){
                                    $( '#cardnoerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['cardNo']+'</strong></span>';
                                   $( '#cardnoerror' ).html( errorname );
                                }
                                if(errors['payable']=== undefined){
                                    $( '#payableerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['payable']+'</strong></span>';
                                   $( '#payableerror' ).html( errorname );
                                }
                                
                    }
            }
    });
    return false;
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7