<?php if (!empty($freelancer->results)) {
    $i = $correct_answer = $wrong_answer = 0;
    $total_answer = count($freelancer->results);
    foreach ($freelancer->results as $results) :
        if ($results->answer_status == 1) {
            $correct_answer++;
        } else {
            $wrong_answer++;
        }
    endforeach;
    $percentage = round(($correct_answer / $total_answer) * 100) . '%';
} ?>

<?php if (!empty($freelancer->transactions)) {
    $total_amount = 0;
    $total_transaction = count($freelancer->transactions);
    foreach ($freelancer->transactions as $transactions) :
        $total_amount += $transactions->pay_amount;
    endforeach;
} ?>
<style>
.iframe-modal{
    height: 60vh;
}
</style>
<div class="pcoded-main-container <?=(@$this->request->params['?']['view'] == 'iframe')?' m-0':'' ?>">
    <div class="pcoded-content">
        <button class="btn  btn-secondary pull-right" onclick="window.history.back();"><i class="feather icon-chevron-left"></i> Go Back</button>
        <div class="user-profile user-card mb-4">
            <div class="card-body py-0 mt-5">
                <div class="user-about-block m-0">
                    <div class="row">

                        <div class="col-md-4 text-center mt-n5">

                            <div class="change-profile text-center">
                                <div class="dropdown w-auto d-inline-block">
                                    <a class="dropdown-toggle1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <div class="profile-dp">
                                            <div class="position-relative d-inline-block">
                                                <img class="img-radius img-fluid wid-100" src="<?= $s3url . 'profile_image/' . $freelancer->image ?>" onerror="this.src='<?= $base_url . 'img/user.png'; ?>';" alt="User image">
                                            </div>
                                            <!-- <div class="overlay">
                                                    <span>change</span>
                                                </div> -->
                                        </div>
                                        <?php if ($freelancer->reg_stage == 4 && $freelancer->status == 1) { ?>
                                            <div class="certificated-badge">
                                                <i class="fas fa-certificate text-c-blue bg-icon"></i>
                                                <i class="fas fa-check front-icon text-white"></i>
                                            </div>
                                        <?php } ?>
                                    </a>
                                    <!-- <div class="dropdown-menu">
                                            <a class="dropdown-item" href="#"><i class="feather icon-upload-cloud mr-2"></i>upload new</a>
                                            <a class="dropdown-item" href="#"><i class="feather icon-image mr-2"></i>from photos</a>
                                            <a class="dropdown-item" href="#"><i class="feather icon-shield mr-2"></i>Protact</a>
                                            <a class="dropdown-item" href="#"><i class="feather icon-trash-2 mr-2"></i>remove</a>
                                        </div> -->
                                </div>
                            </div>

                            <h5 class="mb-1"><?= h($freelancer->name) ?> <span class="badge bg-info text-white"> <?= ($freelancer->profile_percentage) ?>% </span></h5>
                            <p class="mb-2 text-muted"> Proficient :
                                <?php $proffArr = explode(',', $freelancer->proficient);
                                $prificiantSubjects = '-';
                                foreach ($proffArr as $k => $proff) {
                                    $prificiantSubjects .= $k == 0 ? @$Subjects[$proff] : ', ' . @$Subjects[$proff];
                                }
                                echo $prificiantSubjects;
                                ?>
                            </p>
                            <?php  if (!empty($freelancer->category_to_freelancer)) { ?>
                                <p class="mb-2 text-muted"> <b class="badge badge-secondary">Category:</b> 
                                <?php if(!empty(@$freelancer->category_to_freelancer)) {
                                    
                                    foreach($freelancer->category_to_freelancer as $catergory){
                                       echo  $this->Custom->getCategoryName($catergory->category_id).', ' ;
                                    }
                                    echo '</p>';

                                } } ?>
                            
                            <?php if (!empty($freelancer->rating)) { ?>
                                <div class="stars stars-example-css">
                                    <div class="br-wrapper br-theme-css-stars" style="margin-left: 100px;">
                                        <div class="br-widget">

                                            <?php for ($i = 0; $i <= 4; $i++) {
                                                $thisClass = '';
                                                $thisClass = ($i < $freelancer->rating) ? 'br-selected' : '';
                                            ?>

                                                <span class="text-center"><a href="#" data-rating-value="<?= $i ?>" data-rating-text="<?= $i ?>" class="<?= $thisClass ?>"></a>
                                                </span>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>

                            <?php } ?>
                        </div>
                        <div class="col-md-8 mt-md-4">
                            <div class="row">
                                <div class="col-md-6">
                                    <!-- <a href="#!" class="mb-1 text-muted d-flex align-items-end text-h-primary"><i class="feather icon-globe mr-2 f-18"></i>www.Codedthemes.net</a> -->
                                    <div class="clearfix"></div>
                                    <a class="mb-1 text-muted d-flex align-items-end text-h-primary" href="mailto:<?= h($freelancer->email) ?>"><i class="feather icon-mail mr-2 f-18"></i><span><?= h($freelancer->email) ?></span></a>
                                    <div class="clearfix"></div>
                                    <a href="#!" class="mb-1 text-muted d-flex align-items-end text-h-primary"><i class="feather icon-phone mr-2 f-18"></i><?= h($freelancer->mobile) ?></a>
                                </div>
                                <div class="col-md-6">
                                    <div class="media">
                                        <i class="feather icon-map-pin mr-2 mt-1 f-18"></i>
                                        <div class="media-body" style="text-align: left;">

                                            <p class="mb-0 text-muted"><?php echo $freelancer->city;
                                                                        echo $freelancer->state == '' ? '' : ',' . $freelancer->state; ?></p>
                                            <p class="mb-0 text-muted"><?php echo $freelancer->country;
                                                                        echo $freelancer->pin_code == '' ? '' : '(' . $freelancer->pin_code . ')'; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <ul class="nav nav-tabs profile-tabs nav-fill" id="myTab" role="tablist">

                                <li class="nav-item" onclick="$('#examDiv').fadeIn(1000);">
                                    <a class="nav-link text-reset active" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false"><i class="feather icon-user mr-2"></i>Profile</a>
                                </li>
                                <li class="nav-item" onclick="$('#examDiv').hide();">
                                    <a class="nav-link text-reset" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false"><i class="feather icon-book mr-2"></i>Examinations</a>
                                </li>
                                <li class="nav-item" onclick="$('#examDiv').fadeIn(1000);">
                                    <a class="nav-link text-reset" id="gallery-tab" data-toggle="tab" href="#gallery" role="tab" aria-controls="gallery" aria-selected="false"><i class="feather icon-repeat mr-2"></i>Transactions</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-md-8 order-md-2">
                <div class="tab-content" id="myTabContent">

                    <div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
                        <div class="card">
                            <div class="card-body align-items-center justify-content-between">
                                <h5 class="mb-0">Personal details</h5>
                                <a href="<?= $base_url . 'freelancers/edit/' . $freelancer->id ?>" class="btn btn-primary btn-sm rounded m-0 float-right">
                                    <i class="feather icon-edit" onclick="location.href='<?= $base_url . 'freelancers/edit/' . $freelancer->id ?>"></i>
                                </a>

                            </div>
                            <div class="card-body border-top pro-det-edit collapse show" id="pro-det-edit-1">
                                <form>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Full Name</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->name; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Address</label>
                                        <div class="col-sm-9">
                                            <p class="mb-0 text-muted"><?= h($freelancer->address); ?></p>
                                            <p class="mb-0 text-muted"><?php echo $freelancer->city;
                                                                        echo $freelancer->state == '' ? '' : ',' . $freelancer->state; ?></p>
                                            <p class="mb-0 text-muted">Zip Code : <?php echo $freelancer->country;
                                                                                    echo $freelancer->pin_code == '' ? '' : '(' . $freelancer->pin_code . ')'; ?> </p>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body d-flex align-items-center justify-content-between">
                                <h5 class="mb-0">Contact Information</h5>
                                <a href="<?= $base_url . 'freelancers/edit/' . $freelancer->id ?>" class="btn btn-primary btn-sm rounded m-0 float-right">
                                    <i class="feather icon-edit"></i>
                                </a>
                            </div>
                            <div class="card-body border-top pro-dont-edit collapse show" id="pro-dont-edit-1">
                                <form>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Mobile Number</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->mobile; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Email Address</label>
                                        <div class="col-sm-9">
                                            <a href="mailto:<?= $freelancer->email; ?>"><?= $freelancer->email; ?></a>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Skype</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->skyp_id == '' ? '-' : $freelancer->skyp_id; ?>
                                        </div>
                                    </div>
                                </form>
                            </div>

                        </div>
                        <div class="card">
                            <div class="card-body d-flex align-items-center justify-content-between">
                                <h5 class="mb-0">Payment Information</h5>
                                <a href="<?= $base_url . 'freelancers/edit/' . $freelancer->id ?>" class="btn btn-primary btn-sm rounded m-0 float-right">
                                    <i class="feather icon-edit"></i>
                                </a>
                            </div>
                            <div class="card-body border-top pro-wrk-edit collapse show" id="pro-wrk-edit-1">
                                <form>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Bank Name</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->bank_name == '' ? '-' : $freelancer->bank_name;; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">IFSC Code</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->ifsc == '' ? '-' : $freelancer->ifsc; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Account Number</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->ac_no == '' ? '-' : $freelancer->ac_no; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Account Number (UPI)</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->upi == '' ? '-' : $freelancer->upi; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Paypal Id</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->paypal == '' ? '-' : $freelancer->paypal; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Primary Payment</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->primary_payment == '' ? '-' : $freelancer->primary_payment; ?>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body d-flex align-items-center justify-content-between">
                                <h5 class="mb-0">Other Information</h5>
                                <a href="<?= $base_url . 'freelancers/edit/' . $freelancer->id ?>" class="btn btn-primary btn-sm rounded m-0 float-right">
                                    <i class="feather icon-edit"></i>
                                </a>
                            </div>
                            <div class="card-body border-top pro-wrk-edit collapse show" id="pro-wrk-edit-1">
                                <form>
                                    <!-- <div class="form-group row">
                                            <label class="col-sm-3 col-form-label font-weight-bolder">Language</label>
                                            <div class="col-sm-9">
                                                <?= $freelancer->language; ?>
                                            </div>
                                        </div> -->
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Proficient</label>
                                        <div class="col-sm-9">
                                            <?= $prificiantSubjects; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Degree</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->degree == '' ? '-' : $freelancer->degree; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Experience</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->experience == '' ? '-' : $freelancer->experience . ' Year(s)'; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Time-Zone</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->time_zone; ?>
                                        </div>
                                    </div>
                                    <!-- <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Language</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->language; ?>
                                        </div>
                                    </div> -->
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Rating</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->rating; ?>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-3 col-form-label font-weight-bolder">Work Group Status</label>
                                        <div class="col-sm-9">
                                            <?= $freelancer->group_work_status; ?>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="font-weight-normal"><a class="text-h-primary text-reset"><i class="feather icon-edit-1 mr-2"></i><b class="font-weight-bolder">Examination Result: </b></a></h5>
                                <!-- <?php //if ($freelancer->reg_stage > 3) : ?><span class="btn bg-warning pull-right"><b><?//= ($freelancer->reg_stage == 4 ? 'Pass' : 'fail') ?></b></span>
                                <?php //endif; ?> -->
                                <!-- <p class="mb-0 text-muted">50 minutes ago</p> -->
                                <!-- <?php //if ($freelancer->reg_stage < 4 || $freelancer->status != 1) { ?>
                                    <button type="button" class="btn btn-success float-right approveProfile">
                                        <div class="spinner-border" role="status" style="width: 15px;height: 15px;display:none"></div>
                                        <i class="fas fa-check"></i> Approve
                                    </button>
                                <?php //} ?> -->
                                <?php if (!empty($freelancer->results)) {  ?>
                                    <div class="table-responsive m-b-5 mt-3">
                                        <table class="table m-b-0 f-14 b-solid requid-table">
                                            <tbody class="text-muted">
                                                <tr>
                                                    <td>Total Answered :</td>
                                                    <td> <?= count(@$freelancer->results); ?></td>
                                                    <td>Correct Answered: </td>
                                                    <td><?= @$correct_answer; ?></td>
                                                </tr>
                                                <tr>
                                                    <td>Wrong Answered: </td>
                                                    <td><?= @$wrong_answer; ?></td>
                                                    <td>Percentage: </td>
                                                    <td><?= @$percentage; ?></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                <?php } ?>
                            </div>
                            <div class="card-body">
                                <h6 class="font-weight-normal"><b>Objective Exam:</b></h6>
                                <?php if (!empty($freelancer->results)) { ?>
                                    <div class="table-responsive dataTables_wrapper dt-bootstrap4 " style="overflow-y: auto;height: 100%;overflow-x: hidden;">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <!-- <div class="pull-right">
                                                <?= $this->Form->create('freelancers') ?>

                                                <div id="colum-rendr_filter" class="dataTables_filter">
                                                    <label><input type="search" placeholder='Search by name, email and mobile' name="search"  class="form-control"  aria-controls="freelancers" value="<?php echo @$searchData['search']; ?>"></label>
                                                    <?= $this->Form->button('<i class="fas fa-search"></i> Submit', ['type' => 'submit', 'class' => 'btn btn-success'], ['escape' => false]) ?>
                                                </div>

                                                <?= $this->Form->end() ?>
                                            </div> -->

                                                <table class="table">
                                                    <thead>
                                                        <tr>
                                                            <th scope="col">#</th>
                                                            <th scope="col"><?= $this->Paginator->sort('Question') ?></th>
                                                            <th scope="col" class="actions"><?= __('Answer') ?></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>

                                                        <?php $i = 0;
                                                        foreach ($freelancer->results as $results) :
                                                            $answer_status = ($results->answer_status == 1) ? '<span class="badge badge-pill badge-success">Correct</span>' : '<span class="badge badge-pill badge-danger">In Correct</span>';
                                                        ?>
                                                            <tr>
                                                                <td><?= ++$i; ?></td>
                                                                <td><?= h($results->question->question) ?></td>
                                                                <td><?= $answer_status; ?></td>
                                                            </tr>
                                                        <?php endforeach;   ?>

                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>

                                <?php } else { ?>
                                    <h4 class="text-muted text-center">No Questions or Paper Attended!</h4>
                                <?php } ?>
                                <h6 class="font-weight-normal"><b>Subjective Exam:</b></h6>
                                <?php if (!empty($freelancer->essayTest)) { ?>
                                    <!-- <div class="table-responsive dataTables_wrapper dt-bootstrap4 " style="overflow-y: auto;height: 100%;overflow-x: hidden;">
                                        <h5 class="card-title p-3 bg-light ">Question: <?= $freelancer->essayTest['topic'] ?></h5>
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <pre class="text-break text-wrap">
                                                    <?= html_entity_decode(($freelancer->essayTest['essay'])) ?>
                                                </pre>
                                            </div>
                                        </div>
                                    </div> -->
                                    <!-- <div class="col-md-6"> -->
                                    <!-- <div class="card">
                                            <div class="card-header"> -->
                                    <h6 class="mt-3">Exam Result</h6>
                                    <!-- </div> -->
                                    <!-- <div class="card-body"> -->
                                    <div class="table-responsive">
                                        <table class="table table-sm">
                                            <thead>
                                                <tr>
                                                    <th>S.No</th>
                                                    <th>Category Name</th>
                                                    <!-- <th>Approve Date</th> -->
                                                    <th>Result</th>
                                                    <th>edit</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($freelancer->essayTest as $k => $test) :
                                                    $arr = (($test->result == 2) ? array('cls' => 'danger', 'txt' => 'Fail') : (($test->result == 1) ? array('cls' => 'success', 'txt' => 'Pass') : array('cls' => 'warning', 'txt' => 'Pending')))


                                                ?>
                                                    <tr>
                                                        <td><?= $k + 1 ?></td>
                                                        <td><?= (!empty($test->category_id) ? @$this->Custom->getCategoryName($test->category_id) : '') ?></td>
                                                        <td><span class="badge rounded-pill text-white  bg-<?= @$arr['cls'] ?>"><?= @$arr['txt'] ?></span></td>
                                                        <td>
                                                        <?php if(@$userright_arr[0]->edit):?>
                                                        <a href="" class="btn btn-success  btn-sm rounded m-0" data-toggle="modal" data-target=".bd-example-modal-lg_<?= $k ?>">
                                                        <!-- <button type='button' class='btn  btn-primary' data-toggle='modal' data-target='.bd-example-modal-lg'>Large modal</button> -->
                                                        <div class='modal fade bd-example-modal-lg_<?= $k ?>' tabindex='-1' role='dialog' aria-labelledby='myLargeModalLabel' aria-hidden='true' style='display: none;'>
                                                            <div class='modal-dialog modal-lg'>
                                                                <button type='button' class='close text-white' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
                                                                <div class='modal-content' >
                                                                    <!-- <div class='modal-header'> -->
                                                                        <!-- <h5 class='modal-title h4' id='myLargeModalLabel'>Large Modal</h5> -->
                                                                    <!-- </div> -->
                                                                    <div class='modal-body p-0'>
                                                                        <iframe width="100%" class="iframe-modal" src='<?= $this->Url->build(['controller' => 'EssayTest','action' => 'view',$test->id]) ?>?view=iframe'   frameborder="0"></iframe>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                                <i class="feather icon-eye"></i>
                                                            </a>
                                                        <?php endif;?>
                                                        </td>
                                                    </tr>
                                                <?php endforeach; ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- </div>
                                        </div> -->
                                    <!-- </div> -->
                                <?php } else { ?>
                                    <h4 class="text-muted text-center">Subjective Exam not attended!</h4>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="gallery" role="tabpanel" aria-labelledby="gallery-tab">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="font-weight-normal"><a href="#!" class="text-h-primary text-reset"><i class="feather icon-repeat mr-2"></i><b class="font-weight-bolder">Transaction history: </b></a></h5>
                                <!-- <p class="mb-0 text-muted">50 minutes ago</p> -->
                                <?php if (!empty($freelancer->transactions)) { ?>
                                    <div class="table-responsive m-b-5 mt-3">
                                        <table class="table m-b-0 f-14 b-solid requid-table">
                                            <tbody class="text-muted">
                                                <tr>
                                                    <td>Total transactions :</td>
                                                    <td> <?= @$total_transaction ?></td>
                                                    <td>Total Transaction Amount: </td>
                                                    <td><?= @$total_amount; ?></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                <?php } ?>
                            </div>
                            <?php if (!empty($freelancer->transactions)) { ?>
                                <div class="card-body">
                                    <div class="table-responsive dataTables_wrapper dt-bootstrap4 " scroll="no" style="overflow-y: auto;height: 600px;overflow-x: hidden;">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <table class="table">
                                                    <thead>
                                                        <tr>
                                                            <th scope="col">#</th>
                                                            <th scope="col"><?= $this->Paginator->sort('Order Id') ?></th>

                                                            <th scope="col"><?= $this->Paginator->sort('Amount') ?></th>
                                                            <th scope="col" class="actions"><?= __('Date') ?></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <!-- <?= pr($freelancer->results); ?> -->
                                                        <?php if (!empty($freelancer->transactions)) {
                                                            $i = 0;
                                                            foreach ($freelancer->transactions as $transactions) :

                                                        ?>
                                                                <tr>
                                                                    <td><?= ++$i; ?></td>
                                                                    <td><?= h($transactions->order_id) ?></td>
                                                                    <td><?= $transactions->pay_amount; ?></td>
                                                                    <td><?= date('d M,Y', strtotime($transactions->pay_date)) ?></td>

                                                                </tr>
                                                            <?php endforeach;
                                                        } else { ?>
                                                            <tr>
                                                                <td colspan="10">No Records Found</td>
                                                            </tr>
                                                        <?php } ?>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php } else { ?>
                                <h4 class="text-center text-muted">No Transaction found!</h4>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4 order-md-1">
                <?php if (!empty($freelancer->results)) { ?>
                    <div class="card" id="examDiv">
                        <div class="card-header">
                            <h5><i class="feather icon-edit-1 mr-2"></i>Examination results</h5>
                            <!-- <?php if ($freelancer->reg_stage < 4 || $freelancer->status != 1) { ?>
                                <button type="button" class="btn btn-success float-right approveProfile">
                                    <div class="spinner-border" role="status" style="width: 15px;height: 15px;display:none"></div>
                                    <i class="fas fa-check"></i> Approve
                                </button>
                            <?php } ?> -->

                        </div>
                        <div class="card-body">
                            <div class="taskboard-right-revision user-box">
                                <div class="media">
                                    <div class="media-left mr-3">
                                        <a class="btn waves-effect waves-light btn-outline-primary btn-icon" href="#!" role="button">Q
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <div class="chat-header f-w-400 mb-1">Total question</div>
                                        <p class="chat-header text-muted"><?= count($freelancer->results); ?></p>
                                    </div>
                                </div>
                                <div class="media">
                                    <div class="media-left mr-3">
                                        <a class="btn waves-effect waves-light btn-outline-success btn-icon" href="#!" role="button"><i class="fas fa-check"></i>
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <div class="chat-header f-w-400 mb-1">Correct Answered</div>
                                        <p class="chat-header text-muted"><?= @$correct_answer; ?></p>
                                    </div>
                                </div>
                                <div class="media">
                                    <div class="media-left mr-3">
                                        <a class="btn waves-effect waves-light btn-outline-warning btn-icon" href="#!" role="button"><i class="feather icon-x"></i>
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <div class="chat-header f-w-400 mb-1">Wrong Answered</div>
                                        <p class="chat-header text-muted"><?= @$wrong_answer; ?></p>
                                    </div>
                                </div>
                                <div class="media">
                                    <div class="media-left mr-3">
                                        <a class="btn waves-effect waves-light btn-outline-secondary btn-icon" href="#!" role="button"><i class="feather icon-percent"></i>
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <div class="chat-header">Percentage</div>
                                        <p class="chat-header text-muted"><?= @$percentage; ?></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php } ?>
                <div class="card">
                    <div class="card-header d-flex align-items-center justify-content-between">
                        <h5 class="mb-0">Bids on Projects</h5>

                    </div>
                    <?php if (!empty($freelancer->bids)) {  ?>
                        <div class="card-body">
                            <ul class="list-inline">
                                <?php foreach ($freelancer->bids as $bids) :  ?>
                                    <li class=""><i class="fas fa-gavel p-2"></i> <a href="<?= $base_url . 'Projects/view/' . $bids->project_id ?>" target="_blank"> <?= h($bids->project->topic) ?></a><span class="pull-right">(<?= date('d M,Y', strtotime($bids->created)) ?>)</span></li>
                                <?php endforeach;  ?>
                            </ul>
                        </div>
                    <?php } else { ?>
                        <p class="text-muted text-center">No Bids Placed!</p>
                    <?php } ?>
                </div>

                <div class="card new-cust-card">
                    <div class="card-header d-flex align-items-center justify-content-between">
                        <h5>Assigned Projects</h5>
                    </div>
                    <div class="cust-scroll" style="height:auto;position:relative;">
                        <?php if (!empty($freelancer->projects)) {   ?>
                            <div class="card-body py-1 pb-2">
                                <?php foreach ($freelancer->projects as $key => $projects) {
                                    // $status_class = $this->Custom->ProjectStage($projects->status) > 4 ? 'badge-success' :(($this->Custom->ProjectStage($projects->status)>3)?'badge-light-warning': 'badge-error'); 
                                    $icon_class = $this->Custom->ProjectStage($projects->status) > 4 ? 'feather icon-check-circle text-success' :(($this->Custom->ProjectStage($projects->status)>3)?'feather icon-x-circle text-danger': 'far fa-question-circle text-warning'); ?>
                                    <img src="">
                                    <div class="align-middle">

                                        <div class="d-inline-block">
                                            <span class="badge badge-pill <?//= $status_class; ?>">
                                                <i class=" <?= $icon_class?>" title="<?= $projects->status ?>"  data-toggle="tooltip" data-placement="bottom"  data-original-title="<?= $projects->status ?>" style="font-size:16px"></i></span> <?= $this->Html->link($projects['topic'], ['controller' => 'Projects', 'action' => 'view', $projects->id], ['target' => '_blank']); ?>
                                            <p class="m-b-0"></p>
                                            <span class="status deactive" style="top: 0!important;" data-toggle="tooltip" data-placement="left"  data-original-title="<?= date('d M,Y', strtotime($projects->created)) ?>"><?= $this->Custom->getChatTime($projects->created); ?></span>
                                        </div>
                                    </div>
                                <?php } ?>
                            </div>
                        <?php  } else { ?>

                            <p class="text-muted text-center"> No Projects Assigned!</p>

                        <?php } ?>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header">
                        <h5>Documents</h5>
                    </div>
                    <div class="card-body task-attachment">
                        <ul class="media-list p-0">
                            <li class="media d-flex m-b-15">
                                <div class="m-r-20 file-attach">
                                    <i class="far fa-file-image f-28 text-muted"></i>
                                </div>
                                <div class="media-body">
                                    <a class="m-b-5 d-block text-secondary">Pan Card</a>
                                    <!-- <div class="text-muted">
                                <small>Size: 1.2Mb</small>
                                <small>
                                    Added by <a href="#!" class="text-secondary">Winnie</a>
                                </small>
                            </div> -->
                                </div>
                                <?php
                                if ($freelancer->pan_card != '') {
                                    echo ' <a target="_blank" download href="' . $s3url . 'pan/' . $freelancer->pan_card . '" class="float-right text-muted" data-toggle="tooltip" style="cursor: pointer;" data-placement="top" title="Download">
                                    <i class="fas fa-download f-18"></i>
                                </a>';
                                } else {
                                    echo ' <div class="float-right text-muted" data-toggle="tooltip" data-placement="top" title="Not Available">
                                    <i class="fas fa-times-circle f-18" style="color: #b93e21;cursor: pointer;"></i>
                                </div>';
                                }
                                ?>
                            </li>
                            <li class="media d-flex m-b-15">
                                <div class="m-r-20 file-attach">
                                    <i class="far fa-file-image f-28 text-muted"></i>
                                </div>
                                <div class="media-body">
                                    <a class="m-b-5 d-block text-secondary">Cheque</a>
                                    <!-- <div class="text-muted">
                                <small>Size: 0.11Mb</small>
                                <small>
                                    Added by <a href="#!" class="text-secondary">Eugene</a>
                                </small>
                            </div> -->
                                </div>
                                <?php
                                if ($freelancer->cheque != '') {
                                    echo '<a target="_blank" download href="' . $s3url . 'cheque/' . $freelancer->cheque . '" class="float-right text-muted" data-toggle="tooltip" style="cursor: pointer;" data-placement="top" title="Download">
                                    <i class="fas fa-download f-18"></i>
                                </a>';
                                } else {
                                    echo ' <div class="float-right text-muted" data-toggle="tooltip" data-placement="top" title="Not Available">
                                    <i class="fas fa-times-circle f-18" style="color: #b93e21;cursor: pointer;"></i>
                                </div>';
                                }
                                ?>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <script>
        // $('.approveProfile').click(function() {
        //     if (confirm("are you sure?")) {
        //         $('.fa-check', this).hide();
        //         $('.spinner-border', this).show();
        //         $(this).css({
        //             "pointer-events": "none"
        //         });
        //         $.ajax({
        //             type: "post",
        //             url: "<?= $this->Url->build(['controller' => 'freelancers', 'action' => 'approveProfile']); ?>",
        //             data: {
        //                 id: <?= $freelancer->id ?>,
        //                 name: '<?= $freelancer->name ?>',
        //                 email: '<?= $freelancer->email ?>'
        //             },
        //             success: function(res) {
        //                 window.location = '';
        //             }
        //         });
        //     }
        // });
    </script>