<style>
    th{
        font-size: 20px;
    }
    .table-striped tbody tr:nth-of-type(odd) {
    background-color: #EFEFEF;
}
    </style>
<table id="example" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%">
    <thead>
    <tr style="background-color: rgb(65, 110, 110);color: white;">
            <th>Sr.No</th>

            <th>MRD No</th>
            <th>Name</th>
            <th>Gender/Age</th>
            <th>In Time</th>
            <th>Type</th>
            <th>Amount</th>
            <th>Opto</th>
            <th>Consultant</th>



            <th>Investigation</th>

            <!-- <th>Whatsapp</th> -->
            <!-- <th>Patient Out</th> -->
            <th>Action</th>
           
            <th></th>
        </tr>
    </thead>
    <tbody>

       <?php  $i=1;
        use App\Http\Controllers\QueueController;
        $currdate = date('Y-m-d');
        foreach($data as $result){
        $MrdNo = $result->MrdNo;
        $otdt = (new QueueController)->checkOtPatient($MrdNo);
        $stpt = (new QueueController)->checkOtStudyPatient($MrdNo);
        $ot_optoname = (new QueueController)->checkOtOpto($MrdNo);
       // $PtDetails = (new QueueController)->getVisitDetails($MrdNo);
        $PtBal = (new QueueController)->getPatientBal($MrdNo);
            if($result->Dilated == 1){
                $bgcolor = "rgb(133 198 205)";
            }
            else if($result->Appointment == 1){
                $bgcolor = "#e3e337";
            }
            else if($stpt != 0){
                $bgcolor = "#f9bef9";
                
            }
            else if($otdt != "" && $currdate<=$otdt){
                $bgcolor = "darkgrey";
            }
            else{
                $bgcolor = "";
            }

           
            if($PtBal == 0){
            $BalAmt = "";
            }
            else{
            $BalAmt = "<br><span style='color:red'>Bal : $PtBal</span>";
            }

            if($result->OpdType == 1){
                $OpdTypeName = "OPD";
                }
                else{
                $OpdTypeName = "App";
                }

                if($result->PayMode == 'Mobile Payment'){
                    $PayMode = "Online";
                    }
                    else{
                    $PayMode = $result->PayMode;
                    }

                   
            ?>
        <tr style="background-color:{{$bgcolor}}">
            <td style="font-size: 17px;text-align:center;"><strong>{{$i}}</strong></td>
            <td style="font-size: 17px;"><a href="#" data-toggle="modal" data-target="#modal-report33" id="add_button33"
                    onclick="showOptoForm({{$result->MrdNo}},{{$result->id}},'{{$result->InDate}}')"><strong>{{$result->MrdNo}}</strong></a>
            </td>
            <td style="font-size: 17px;"><a href="#" data-toggle="modal" data-target="#modal-report33" id="add_button33"
                    onclick="showOptoForm({{$result->MrdNo}},{{$result->id}},'{{$result->InDate}}')"
                    style="font-size:15px;"><strong>{{strtoupper($result->PatientName)}}</strong></a>
                <?php echo $BalAmt;?></td>
            <td style="font-size: 17px;">{{$result->Gender}} / {{$result->Age}}</td>
            <td>{{date("h:i a", strtotime(str_replace('-', '/',$result->InTime)))}}</td>
            <td>{{$result->PatientType}} - ({{$OpdTypeName}})</td>
            
            <?php if($result->chkstatus == 1){?>
                <td>{{$result->Amount}} - ({{$PayMode}})</td>    
            <?php } else{?>
            <td><a data-id="{{$result->id}}" href='javascript:void(0);' data-toggle="tooltip" data-placement="top" title="Edit" data-original-title="Edit" class="update2">{{$result->Amount}} - ({{$PayMode}})</a></td>
            <?php } ?>
            
            <td>{{$result->ConfirmOpto}}</td>
            <td>{{$result->PrevConsultant}}</td>
            <td>{{$result->InvStName}}
                <?php 
                if($stpt != 0){?>
                <span style='color:brown;'>Study - {{$ot_optoname}}</span>
                <?php } else {}?>
           </td>

            <!-- <td><a href='javascript:void(0);' class="badge badge-pill badge-danger"
                    onclick="patientOut({{$result->id}},{{$result->MrdNo}},'{{$result->InDate}}','{{$result->PatientName}}')" style="background-color: rgb(65, 110, 110);font-size: 16px;border-radius: 0rem;">
                    Patient Out</a></td> -->
            <td>

                <a data-id="{{$result->MrdNo}}" href='javascript:void(0);' data-toggle="tooltip" data-placement="top"
                    title="Edit" data-original-title="Edit" class="update"><i
                        class="fas fa-pencil-alt" style="color: rgb(79, 175, 184) !important;"></i></a>&nbsp;&nbsp;
                <!-- <a data-id="{{$result->id}}" href='javascript:void(0);' data-toggle="tooltip" data-placement="top"
                    title="Delete" data-original-title="Delete" class="delete" id="bootbox-confirm"><i
                        class="fas fa-trash" style="color: rgb(79, 175, 184) !important;"></i>&nbsp;&nbsp; -->
                <a href='javascript:void(0);' data-toggle="tooltip" data-placement="top"
                    title="Print Sticker" data-original-title="Print Sticker" onclick="stickerPrint({{$result->MrdNo}})"><i
                        class="fas fa-print" style="color: rgb(79, 175, 184) !important;"></i>   
                    </a>
                    <?php if($MrdNo == 1){}
                    else{?>
                    &nbsp;&nbsp;
                <a href='javascript:void(0);' data-toggle="tooltip" data-placement="top"
                    title="Patient Out" data-original-title="Patient Out" onclick="patientOut({{$result->id}},{{$result->MrdNo}},'{{$result->InDate}}','{{$result->PatientName}}')"><i
                        class="fas fa-external-link-alt" style="color: rgb(79, 175, 184) !important;"></i>   
                    </a><?php } ?>
            </td>
           
            <td>{{$result->InTime}}</td>
        </tr>
        <?php $i++;}?>
    </tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable({
        responsive: true,
        "pageLength": 50,
        "order": [
            [11, "asc"]
        ]

    });
});
</script>